From patchwork Sun Oct 22 21:51:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44328 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1b28:b0:15d:8365:d4b8 with SMTP id ch40csp1070042pzb; Sun, 22 Oct 2023 14:52:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTrOfu393kScqqAqd7xIKQxEBsiKDLwOaEw2Q8kYRmI6MlNNsJ1Emh2FxgDb8Bw9Dbc832 X-Received: by 2002:a17:907:2cc4:b0:9c3:d356:ad0c with SMTP id hg4-20020a1709072cc400b009c3d356ad0cmr5961456ejc.24.1698011554652; Sun, 22 Oct 2023 14:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698011554; cv=none; d=google.com; s=arc-20160816; b=E+O8idESUBQ4TlhQMU+iYoaehKfFAIx1nucezGM4T0coGzbKaKoIea/tIRlSkfMt1X RTWkLVBA3CqDhB8AiBE+sCfGu89+CI6W8fvx+Pszarxup32L/tCJIQqXoLBNffXa+ZGR Zj5ziTeRjntzKg3ucU3AVv6psTUeEDkUDmV2GnOjVZRYlaWqADFf2joEztk5FGCP/eXc j7tugteGXf51dh0ngAe/Kbpew1136avjUqpqMfgp2qqrNMyAm78WgSXPsysY/01QMmUa +BxjRwERkXHcFlI6E/j6gwpHwu+DiRi+C0Nq1Ik45b7YiW1QHa5NxXKuHSs/eUgrCf2Q Td6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=pl2k5m118YDg+PM5EbcQen3mj3nMeBvxVzFFBt94WVk=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=O4iYeRHO3JtBrs6Q8ioLm/qALz+zytYMPf+79jX9a56GBzk+4NgW/rwTr9FfGcftSb NS3Yv1whe2J6mtjcOaNGdjHx0ZmVm5YWEmAr16aAhz1cITk3cxnBtSXQJnC8vaL3fQqy Oxoo1dnRQ1cvIjq9JkAXecGQqtDHwaDB/l7h6xWOFUQU0zk593Ji2dNxF+lkcB80RiUj qpMkKsO+edkgZy5SOAZTzHIMBgSBKyy11kqyUQjsoKJRoV3FgvDRpQiZ6w2aTDWaI4hK UF5aTdX2PfswQ5mR6c3um9RCmyN3QPzrb3mnwd8SJcp6d4SFsrl+xn6DhzsnHtdfA85E 7UUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j7-20020a170906534700b0099279210464si2680747ejo.420.2023.10.22.14.52.34; Sun, 22 Oct 2023 14:52:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1218168CAD1; Mon, 23 Oct 2023 00:51:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PBoLDc+Aj4Oy 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