From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 933E0468B2 for ; Sun, 22 Oct 2023 21:51:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 246C068CA16; Mon, 23 Oct 2023 00:51:21 +0300 (EEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC44D68C65F for ; Mon, 23 Oct 2023 00:51:14 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 1866CE0002 for ; Sun, 22 Oct 2023 21:51:13 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 22 Oct 2023 23:51:05 +0200 Message-Id: <20231022215113.3469-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/9] avcodec/vlc: merge lost 16bit end of array check X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Also cleanup related code Signed-off-by: Michael Niedermayer --- libavcodec/vlc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c index e4bbf2945e1..4f62eddf0fb 100644 --- a/libavcodec/vlc.c +++ b/libavcodec/vlc.c @@ -358,8 +358,8 @@ static void add_level(VLC_MULTI_ELEM *table, const int nb_elems, const int minlen, const int max, unsigned* levelcnt, VLC_MULTI_ELEM *info) { - if (nb_elems > 256 && curlevel > 2) - return; // No room + int is16bit = nb_elems>256; + int max_symbols = VLC_MULTI_MAX_SYMBOLS >> is16bit; for (int i = num-1; i > max; i--) { for (int j = 0; j < 2; j++) { int newlimit, sym; @@ -373,7 +373,7 @@ static void add_level(VLC_MULTI_ELEM *table, const int nb_elems, code = curcode + (buf[t].code >> curlen); newlimit = curlimit - l; l += curlen; - if (nb_elems>256) AV_WN16(info->val+2*curlevel, sym); + if (is16bit) AV_WN16(info->val+2*curlevel, sym); else info->val[curlevel] = sym&0xFF; if (curlevel) { // let's not add single entries @@ -386,7 +386,7 @@ static void add_level(VLC_MULTI_ELEM *table, const int nb_elems, levelcnt[curlevel-1]++; } - if (curlevel+1 < VLC_MULTI_MAX_SYMBOLS && newlimit >= minlen) { + if (curlevel+1 < max_symbols && newlimit >= minlen) { add_level(table, nb_elems, num, numbits, buf, code, l, newlimit, curlevel+1, minlen, max, levelcnt, info); -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".