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 E883D468B2 for ; Sun, 22 Oct 2023 21:52:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CF67D68CACB; Mon, 23 Oct 2023 00:51:30 +0300 (EEST) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7BF4C68CA44 for ; Mon, 23 Oct 2023 00:51:21 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id E01B720005 for ; Sun, 22 Oct 2023 21:51:20 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 22 Oct 2023 23:51:13 +0200 Message-Id: <20231022215113.3469-9-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 9/9] avcodec/vlc: simplify min/maxbits 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: nothing uses maxbits, so its removed minbits is just the last entry (verified with assert on fate) This basically reverts 58d9b5caf3d332c6495f9af437158bf45531a05e for the minbits computation Signed-off-by: Michael Niedermayer --- libavcodec/vlc.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c index ceabeba5408..de16424c93d 100644 --- a/libavcodec/vlc.c +++ b/libavcodec/vlc.c @@ -395,7 +395,7 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single, const int is16bit, const int nb_codes, const int numbits, VLCcode *buf, void *logctx) { - int minbits, maxbits, max; + int minbits, max; unsigned count[VLC_MULTI_MAX_SYMBOLS-1] = { 0, }; VLC_MULTI_ELEM info = { { 0, }, 0, 0, }; int count0 = 0; @@ -407,14 +407,9 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single, } } - minbits = 32; - maxbits = 0; - - for (int n = nb_codes - count0; n < nb_codes; n++) { - minbits = FFMIN(minbits, buf[n].bits); - maxbits = FFMAX(maxbits, buf[n].bits); - } - av_assert0(maxbits <= numbits); + //This is only correct if count0 > 0 and the table is sorted + //minbits is not used if count0 == 0 and other parts assume the table is sorted too + minbits = buf[nb_codes - 1].bits; for (max = nb_codes; max > nb_codes - count0; max--) { // We can only add a code that fits with the shortest other code into the table -- 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".