From patchwork Fri Oct 23 10:12:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23168 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 A5E3C44B156 for ; Fri, 23 Oct 2020 13:12:23 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5601268A0FA; Fri, 23 Oct 2020 13:12:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 506D86897E2 for ; Fri, 23 Oct 2020 13:12:16 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id n6so1139513wrm.13 for ; Fri, 23 Oct 2020 03:12:16 -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:mime-version :content-transfer-encoding; bh=jd3YgU0pklSMwTKqsB+OxRgfKZ9W612K2yvTffpJUdY=; b=L3Nu607E/R3x3IZADkjWYfrQnXO7dYTiZn7sGiDw2l3sv2dsUEuZ8BfD3+VdldgqAr By9KUt8rhMMP5lP7UirLmxZ10Ndvpw32//fdSOX5n3YsaU23r9bsQrk9ZsHgd//0Zx+s nX5szdAw/ZIqQjFZOVwXdFgG/YWYXLgKgKbgIpLPuLAiCxHKP+BNzREL53kWcsLUXEjF QUwfrX2yR9NDBTuMEZaZzGVUaRqDVoA7l/3/W3Pg62q+SEEyTNro4C9vafB6MRos3032 nnvvGBuNr6jIxDhR+5iO3o082Vb4iTtxJ12jX5z03lPnZgvNfAhNXcTJPFV/MM4d2/zb KbBA== 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:mime-version :content-transfer-encoding; bh=jd3YgU0pklSMwTKqsB+OxRgfKZ9W612K2yvTffpJUdY=; b=TQAcgmIoxVhYRUTV0+3iN7mcJHfXJt3VmDMfDTLR/lQGJ/itVp9OB8Q83LyswvUzdi bOyTtrdWJWGjYKrYgjw+V1gmWJ8aW3zwd2Z+ibA/KRPpxbilsgRjJxpyAI1WkxI0CAvg /TEUUJf5rm4C3Vd+N5Q9m/gd9D8TOZDFBItpc20Rv1QrrCEprvBM+FCh2p/FRt+SyNZH rl4pQUpVYO0fs4FrnUcLnnxdzLlFJMnBn0JLUMkDYR4k+deSyONWOoYgZtAfocMb8DNg 7Sc6ZH3ZDPEaKouFtnXTcS8cliXoO6bQBtQGrad4bB/CIcTcEp/7SJ/cll+JAF7lz6BU vBxA== X-Gm-Message-State: AOAM532agFonR93KebS/+T6gvraKHzeOTCP31BgMp6irvX0Ow684T7QD 2lB+ADUdpLRsSePOK01Tal+eOQifV1Y= X-Google-Smtp-Source: ABdhPJxTBeXbdimSwNUPkbk/dTzl6ZC6bLSHeX3PENl90EUvNBMMpsW37wGRwO7uYTwAp4IUfBQ/1w== X-Received: by 2002:adf:97cb:: with SMTP id t11mr1943728wrb.292.1603447935586; Fri, 23 Oct 2020 03:12:15 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id c130sm2515263wma.1.2020.10.23.03.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 03:12:14 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 23 Oct 2020 12:12:02 +0200 Message-Id: <20201023101204.760326-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/atrac3: Don't use too big 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" The longest code of any of the VLC tables used is eight bits long, so using nine bits long VLC tables is wasteful. Furthermore, there are only seven VLC tables used, yet the code up until now made it look like there should be eight. This has been corrected, too. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac3.c | 13 ++++++++----- libavcodec/atrac3data.h | 4 ---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index dc68e507aa..01b7f06bff 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -58,6 +58,8 @@ #define SAMPLES_PER_FRAME 1024 #define MDCT_SIZE 512 +#define ATRAC3_VLC_BITS 8 + typedef struct GainBlock { AtracGainInfo g_block[4]; } GainBlock; @@ -116,7 +118,7 @@ typedef struct ATRAC3Context { } ATRAC3Context; static DECLARE_ALIGNED(32, float, mdct_window)[MDCT_SIZE]; -static VLC_TYPE atrac3_vlc_table[4096][2]; +static VLC_TYPE atrac3_vlc_table[7 * 1 << ATRAC3_VLC_BITS][2]; static VLC spectral_coeff_tab[7]; /** @@ -851,6 +853,7 @@ static int atrac3al_decode_frame(AVCodecContext *avctx, void *data, static av_cold void atrac3_init_static_data(void) { + VLC_TYPE (*table)[2] = atrac3_vlc_table; int i; init_imdct_window(); @@ -858,12 +861,12 @@ static av_cold void atrac3_init_static_data(void) /* Initialize the VLC tables. */ for (i = 0; i < 7; i++) { - spectral_coeff_tab[i].table = &atrac3_vlc_table[atrac3_vlc_offs[i]]; - spectral_coeff_tab[i].table_allocated = atrac3_vlc_offs[i + 1] - - atrac3_vlc_offs[i ]; - init_vlc(&spectral_coeff_tab[i], 9, huff_tab_sizes[i], + spectral_coeff_tab[i].table = table; + spectral_coeff_tab[i].table_allocated = 256; + init_vlc(&spectral_coeff_tab[i], ATRAC3_VLC_BITS, huff_tab_sizes[i], huff_bits[i], 1, 1, huff_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); + table += 256; } } diff --git a/libavcodec/atrac3data.h b/libavcodec/atrac3data.h index 5d91274f48..a731fb7c4a 100644 --- a/libavcodec/atrac3data.h +++ b/libavcodec/atrac3data.h @@ -103,10 +103,6 @@ static const uint8_t* const huff_bits[7] = { huffbits1, huffbits2, huffbits3, huffbits4, huffbits5, huffbits6, huffbits7, }; -static const uint16_t atrac3_vlc_offs[9] = { - 0, 512, 1024, 1536, 2048, 2560, 3072, 3584, 4096 -}; - /* selector tables */ static const uint8_t clc_length_tab[8] = { 0, 4, 3, 3, 4, 4, 5, 6 };