From patchwork Thu Oct 22 10:20:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23148 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 43BB54498B0 for ; Thu, 22 Oct 2020 13:20:38 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2B31368A98A; Thu, 22 Oct 2020 13:20:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 867606880F2 for ; Thu, 22 Oct 2020 13:20:32 +0300 (EEST) Received: by mail-ed1-f53.google.com with SMTP id bc23so1200382edb.5 for ; Thu, 22 Oct 2020 03:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YZ3qy0oOFyBSSZQApHD6+wvdee6nemVasFSpkJeyCXk=; b=PNrwnQzBURwCUtiVPSe0PMINh5vbr/s9eKxsUweH3SbbV3IXG7zykRGU/plQPy2ij/ He2KGhb1fPpDL1gBhx2mPMGIvpUcSPLnXJuRuwtbdZWPTirKxF2Gk7aF/gIUL+iYKGJ2 KJ8VE0bNopRkeC85lJPVUTOJ8+9VpKbr19QHES+atW7aljU5mIrCMSf9+RHkB5rB4r4J OLwCbOFvGveV/iu6XBjq1mkvx48+HTqgi5DsHRimTRpbtX6TZPYLvG/MNehp3v7F1mBw KEfd6NK5Imite1XpVnyUmP1pmWGt6fvlHsyYIWyApRQboL/sdPZCko4pFQJqtk/NAjrA WPvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YZ3qy0oOFyBSSZQApHD6+wvdee6nemVasFSpkJeyCXk=; b=YBaDosPjOEEpFMTRhV6YYoM0DZ0eUmborFimApEiIiLpsn6ufZThIdTLqWOzxwEs3Y PE0ub9+W7BeGRLXTcOx4Xyn7kAy5EEvHrY+LpN4YcrYGRpK3KQBgfB5+MPG8Bkzn6pSX EZXcIov2dqy7PvWJnRWAkq9cZgM5xrmDvE84rbcCqUL+5tH24pPoP91MF5CKIvvsxko7 Hy+nNAVmarLb134GU924QEhyCHCrpIILg51k1sjXJeXZJmz1WydbmbxDhoMF1lxFHQz6 lf+zVJ06+zDf5/bM6LfL1NMQi7wNe4XtIaNpa89nRROcuxvtOGBAJ4xXnuQoihOcf6fW BL4Q== X-Gm-Message-State: AOAM5327dJ6zSIoDC83nU7V6l613HSZ96z4kwVvmI+FH2y3SEEgkPlg3 JAAVcO5XnZW6+D5JY5/DHvzx4/LtZDI= X-Google-Smtp-Source: ABdhPJwuy4Psg576ljqc52WdDq88brOoSfMTGXbM/dvMUTThfll5LOQtwDiFxp09DQyiOHj2mKzWJw== X-Received: by 2002:a50:f307:: with SMTP id p7mr1193125edm.235.1603362031586; Thu, 22 Oct 2020 03:20:31 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id p16sm582746ejz.103.2020.10.22.03.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 03:20:31 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Oct 2020 12:20:06 +0200 Message-Id: <20201022102006.571413-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201022102006.571413-1-andreas.rheinhardt@gmail.com> References: <20201022102006.571413-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/rv34: Simplify getting right VLC X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" For both RealVideo 3.0 as well as RealVideo 4.0 the VLC table to use depends upon the slice's quantization parameter; these are coded on five bits in the bitstream and are therefore in the range of 0..31; yet the last element here is not valid and therefore the quantizer is clipped to the range 0..30 to get the index. But this is unnecessary: One can just add one element more to the relevant array to avoid the clipping. Signed-off-by: Andreas Rheinhardt --- libavcodec/rv34.c | 6 ++++-- libavcodec/rv34data.h | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index d251c6817c..09fa962b2f 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -24,6 +24,7 @@ * RV30/40 decoder common data */ +#include "libavutil/avassert.h" #include "libavutil/imgutils.h" #include "libavutil/internal.h" @@ -339,8 +340,9 @@ static inline RV34VLC* choose_vlc_set(int quant, int mod, int type) { if(mod == 2 && quant < 19) quant += 10; else if(mod && quant < 26) quant += 5; - return type ? &inter_vlcs[rv34_quant_to_vlc_set[1][av_clip(quant, 0, 30)]] - : &intra_vlcs[rv34_quant_to_vlc_set[0][av_clip(quant, 0, 30)]]; + av_assert2(quant >= 0 && quant < 32); + return type ? &inter_vlcs[rv34_quant_to_vlc_set[1][quant]] + : &intra_vlcs[rv34_quant_to_vlc_set[0][quant]]; } /** diff --git a/libavcodec/rv34data.h b/libavcodec/rv34data.h index 4b2701fee6..32ecc395a8 100644 --- a/libavcodec/rv34data.h +++ b/libavcodec/rv34data.h @@ -90,13 +90,13 @@ static const uint16_t rv34_qscale_tab[32] = { /** * tables used to translate a quantizer value into a VLC set for decoding - * The first table is used for intraframes. + * The first table is used for intraframes. The two last entries are invalid. */ -static const uint8_t rv34_quant_to_vlc_set[2][31] = { +static const uint8_t rv34_quant_to_vlc_set[2][32] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0 }, + 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, - 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6 }, + 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6 }, }; /**