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 0BB604580C for ; Sun, 22 Oct 2023 21:51:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6DB3C68CA38; Mon, 23 Oct 2023 00:51:24 +0300 (EEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 91C9968CA20 for ; Mon, 23 Oct 2023 00:51:16 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id DEF33C0006 for ; Sun, 22 Oct 2023 21:51:15 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 22 Oct 2023 23:51:07 +0200 Message-Id: <20231022215113.3469-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231022215113.3469-1-michael@niedermayer.cc> References: <20231022215113.3469-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 3/9] avcodec/vlc: Skip subtable entries in multi VLC 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: These entries do not correspond to VLC symbols that can be used they do corrupt various variables like min/max bits This also no longer assumes that there is a single non subtable entry Probably fixes some infinite loops too Signed-off-by: Michael Niedermayer --- libavcodec/vlc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c index 77860430861..65883a506ff 100644 --- a/libavcodec/vlc.c +++ b/libavcodec/vlc.c @@ -401,15 +401,23 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single, int minbits, maxbits, max = nb_codes-1; unsigned count[VLC_MULTI_MAX_SYMBOLS-1] = { 0, }; VLC_MULTI_ELEM info = { { 0, }, 0, 0, }; + int count0 = 0; - minbits = buf[0].bits; - maxbits = buf[0].bits; + for (int j = 0; j < 1<table[j].len > 0) { + count0 ++; + j += (1 << (numbits - single->table[j].len)) - 1; + } + } + + minbits = 32; + maxbits = 0; - for (int n = 1; n < nb_codes; n++) { + for (int n = nb_codes - count0; n < nb_codes; n++) { minbits = FFMIN(minbits, buf[n].bits); maxbits = FFMAX(maxbits, buf[n].bits); } - maxbits = FFMIN(maxbits, numbits); + av_assert0(maxbits <= numbits); while (max >= nb_codes/2) { if (buf[max].bits+minbits > maxbits) -- 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".