From patchwork Tue Nov 10 10:48:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23564 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 2E70F44BA69 for ; Tue, 10 Nov 2020 13:11:34 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F10468BFAB; Tue, 10 Nov 2020 12:51:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2988168BF73 for ; Tue, 10 Nov 2020 12:50:49 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id s8so5054300wrw.10 for ; Tue, 10 Nov 2020 02:50:49 -0800 (PST) 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:reply-to :mime-version:content-transfer-encoding; bh=zAEfyK0D8FCXfVdA+6KrlxkCyINpFblxXGWWtiz0hgM=; b=GEg06YXSQ3v+v5CCzljj7i5y+OLNKILr3fxn/Q0idhgKXZbmcGlbqfBcTFCRb/yYqm ecvBFlXt1DX4vtSXW4fAlzj9wb53vbNF4nzLe03ZnTWqAGXWDlDywuC6Pn1mdZXvonMo QOvv9zqex6uSs/w3jj82Lzz5qx/Yz8pFLwVXUK+9q6A6qS5tG4nIWw8ahhSy14iFEk7v ol+2+4Oqs5vosKBvFXaJmBHoTKRrEQpYmpIPeUNucRo//HAroOrKwm0NrYgOo/ZB9M9m DZiHjQFZ0VwwVR+PwdG8+mdLZQL3HQBdweKUx6aWBrAO2gKiTfVtSbxN2XK3P3KYDo2C B9PQ== 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:reply-to:mime-version:content-transfer-encoding; bh=zAEfyK0D8FCXfVdA+6KrlxkCyINpFblxXGWWtiz0hgM=; b=DY+k3HCl+YReunZchszO1wV9bg3D7Va3OMqBfZMjCQhYrUSQP2BG99kvPwokT9c0gN lp9bbhD3nqZvqMf3uPIuk7qCY5VUAY26ql1xxRF8+3mhnTmVUajcUffAM6XFddSsR5S4 8NhzMHmIw6buQXMaQjQ1A+EzHvMAZGm6lN+JIO6Oa9u69poyBvC2SW31QneVijTR2B+w h1ynfwmijpohBBQgdZM32HXik7G7UfzL9tsgBh3EJXkbCDUJe9Ba2qB05eyCLXCUQmL9 A6nvU29TfRSIDBGSBdLZ8s7dA0gdCmqddQtGjVgqYcImf6h6vMCM059k6ln71hbKvlbr QX7A== X-Gm-Message-State: AOAM533cewI4TCPXtusNcgPGfv3OoHIWc4wqAHIzMffU3Emi2dudwXAs 6KOW/wSoQKnU0+jzZxyPw5ck4rf5aXg= X-Google-Smtp-Source: ABdhPJw/EIBDRWNjP7e3RFkuPF2F8hCSQT7stOlihMXnIfYoz+O6/CalPzBrIyVmI8eUfMUQknLFrA== X-Received: by 2002:a05:6000:345:: with SMTP id e5mr22199873wre.333.1605005448391; Tue, 10 Nov 2020 02:50:48 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id l24sm2572543wmi.7.2020.11.10.02.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 02:50:47 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Nov 2020 11:48:28 +0100 Message-Id: <20201110104851.321029-92-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> References: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 091/114] avcodec/atrac9dec: Don't use unnecessarily large VLC tables 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" Using more bits for a VLC than the longest code has has no advantage. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac9dec.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index ecf95f1777..0477b304d2 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -26,6 +26,8 @@ #include "libavutil/lfg.h" #include "libavutil/float_dsp.h" +#define ATRAC9_SF_VLC_BITS 8 + typedef struct ATRAC9ChannelData { int band_ext; int q_unit_cnt; @@ -272,7 +274,8 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b, c->scalefactors[0] = get_bits(gb, len); for (int i = 1; i < b->band_ext_q_unit; i++) { - int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 1); + int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, + ATRAC9_SF_VLC_BITS, 1); c->scalefactors[i] = val & ((1 << len) - 1); } @@ -302,7 +305,7 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b, const VLC *tab = &s->sf_vlc[1][len]; for (int i = 0; i < unit_cnt; i++) { - int dist = get_vlc2(gb, tab->table, 9, 1); + int dist = get_vlc2(gb, tab->table, ATRAC9_SF_VLC_BITS, 1); c->scalefactors[i] = baseline[i] + dist; } @@ -325,7 +328,8 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b, c->scalefactors[0] = get_bits(gb, len); for (int i = 1; i < unit_cnt; i++) { - int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 1); + int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, + ATRAC9_SF_VLC_BITS, 1); c->scalefactors[i] = val & ((1 << len) - 1); } @@ -930,7 +934,8 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx) for (int i = 1; i < 7; i++) { const HuffmanCodebook *hf = &at9_huffman_sf_unsigned[i]; - init_vlc(&s->sf_vlc[0][i], 9, hf->size, hf->bits, 1, 1, hf->codes, + init_vlc(&s->sf_vlc[0][i], ATRAC9_SF_VLC_BITS, hf->size, + hf->bits, 1, 1, hf->codes, 2, 2, 0); } @@ -943,7 +948,7 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx) for (int j = 0; j < nums; j++) sym[j] = sign_extend(j, hf->value_bits); - ff_init_vlc_sparse(&s->sf_vlc[1][i], 9, hf->size, hf->bits, 1, 1, + ff_init_vlc_sparse(&s->sf_vlc[1][i], ATRAC9_SF_VLC_BITS, hf->size, hf->bits, 1, 1, hf->codes, 2, 2, sym, sizeof(*sym), sizeof(*sym), 0); }