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 }; From patchwork Fri Oct 23 10:12:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23169 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 29F6744B156 for ; Fri, 23 Oct 2020 13:12:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1549968A912; Fri, 23 Oct 2020 13:12:43 +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 D5CF168A2B6 for ; Fri, 23 Oct 2020 13:12:36 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id b8so1191380wrn.0 for ; Fri, 23 Oct 2020 03:12:36 -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=BO80rg6IhGVa6dO/i72PSElaIe+KNGHzGwM+Y8dT1Kg=; b=tEtRqfaOWftDaYRWfmBWMVQUKUbr/sgovG0vM+vcwvSgfZjlsdooyB5YZgbrK/WBTt a50fkxVPKfMpwJESjIxdi1Z61YxThrCNws5GZdk10tX9CQz+j+jd5R7VNXvmBEJ61wGt L8DbMJq/pB/fnI/Izqw6qzG7gO6d592Ym+h2kZ2nP7G+ykJiE+ARwsLudCjNLqdaOoMn TiiNpCsfIaWUtsyW8fD4DYkwVKpgaxrkpgVLSYqDGoXeBahA3+j23yXMhmkPnG4LlnAf cR3Sc8laAPLSmsKsBnsIj97DPTxKaRJTU1qcqsk0A7ULrqIqP5yd7BOcP/iQ+Tt6hUmW ky+w== 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=BO80rg6IhGVa6dO/i72PSElaIe+KNGHzGwM+Y8dT1Kg=; b=n+nGr/kdziwfkaIG8EO4UxkHdWW5gVfvj5VUt1ZHVGqrwM2+YPGGdNXKe8tZ8YhUZb Pd6cHo/G2Pvv7h6ikElzx4RxrE+JeUqvHQRe09CipDi5H+cUhr/JsfD9mxZXg+q2LQor rINDyYAQbZohqbJBMcHd878dBuT1OojyRyw2Hl22+okyedRwOvsp1Jb2mnCKw/h+3XRz AfQ5nO8t9GXBxztfhqJWlGHYw5CwtZeLPFavB6QteGdFT0Pca0glSMxW8+XCjsWxFylZ Q3uM9EJjNSzIUvj63f/tRcO9xLDAWHhBRDWUCe12oi0SYq9BTdOLmFI3yiAwJt2DAGPx 3e1w== X-Gm-Message-State: AOAM531fAcIEHMDcolvbSNTHOlbYV3+omeFiW90v4GCkxxRfHzEgX/uh XAP0cMQR3nxRyqEOLrIFMFTmvyCHrVc= X-Google-Smtp-Source: ABdhPJwqKRHrLZHrBRyxB3dRrNLhnZuj7pZI7kUf/9Sw/+cGuJa5rayi7C8B+3uKMd5ve+5C0VvAyg== X-Received: by 2002:a5d:688c:: with SMTP id h12mr1894700wru.92.1603447956108; Fri, 23 Oct 2020 03:12:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 03:12:35 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 23 Oct 2020 12:12:03 +0200 Message-Id: <20201023101204.760326-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023101204.760326-1-andreas.rheinhardt@gmail.com> References: <20201023101204.760326-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/atrac3: Inline constants 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" Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 01b7f06bff..a3e7d96a65 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -247,7 +247,7 @@ static void read_quant_spectral_coeffs(GetBitContext *gb, int selector, if (selector != 1) { for (i = 0; i < num_codes; i++) { huff_symb = get_vlc2(gb, spectral_coeff_tab[selector-1].table, - spectral_coeff_tab[selector-1].bits, 3); + ATRAC3_VLC_BITS, 3); huff_symb += 1; code = huff_symb >> 1; if (huff_symb & 1) @@ -257,7 +257,7 @@ static void read_quant_spectral_coeffs(GetBitContext *gb, int selector, } else { for (i = 0; i < num_codes; i++) { huff_symb = get_vlc2(gb, spectral_coeff_tab[selector - 1].table, - spectral_coeff_tab[selector - 1].bits, 3); + ATRAC3_VLC_BITS, 3); mantissas[i * 2 ] = mantissa_vlc_tab[huff_symb * 2 ]; mantissas[i * 2 + 1] = mantissa_vlc_tab[huff_symb * 2 + 1]; } From patchwork Fri Oct 23 10:12:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23170 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 1837044B156 for ; Fri, 23 Oct 2020 13:12:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ED85968A9D5; Fri, 23 Oct 2020 13:12:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE1CD68A7D8 for ; Fri, 23 Oct 2020 13:12:37 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id e2so907110wme.1 for ; Fri, 23 Oct 2020 03:12:37 -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=t5P/8oAKhyTSWnqNGxzFNIgkwI/UdgeqDu4ayjLk4EI=; b=Azo12ogxHcw15xak87GpLPBR61hfENBWRrn80+LjblkiP+7Hr0LY8Zm3ZCIx48OvUJ 2VeAqJ8dBbdvwbLSGsFQqit57W878LogMjyQl07DsPGRahEiY8nPIacxcOTGT6qv3PBB 8y/rjqFa/xYMwuLS/MaCpRGZRoy3MLfoIuLjoLw1aliChsZODzQuwkeLvF+apTLJiXcd b5lTYIjvZFV1Aysrlm0HWbzYnY2rMuoxiBDTcgHSNgePyvNDm1RNTslZtKxUtPqoUiiX eZxI79PpS3RK1idLBeXXgRO2sTFUulau5LdRxGDRK/plKx3kNppeIdHqkiXsZxveMsnv ytpQ== 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=t5P/8oAKhyTSWnqNGxzFNIgkwI/UdgeqDu4ayjLk4EI=; b=j8NeOlsoEHviK2hLz1M2YFy55bPk4uO+paDXmBdL79xl/0RWQs2oxR9h92IgZ/+BRs biBdqqzoonABB+/1MiRVm3VhW7d/xY03sbO5fTF44rL2UhfIcxifYKj9C4/OB8wqb8ik Msxe3+/NS5rFhQIWO8ckgcatecNvzvTmVTzC9uCK13JT9DkO6E2neBjBOhhsV6k8Gb5o RiAOtccC0GMhrhyDHxe9JGz4kZxmQ5UFsKU6ui7yAN1AXPf9m+c33Uug9c6IoTZgi/9M YSEWayYq2jb5u0/dybgcqktGJoI9rVX/eXrOji7LmYHQF5EhWKmU1Bft7DIPSea5qslf pTew== X-Gm-Message-State: AOAM530iBtJTOb0LM2WyPbhPgsQgVTk0t3QgcsJl2Rmxt39h7kd++iUr GR6tbVJsG05zHgznLXYOwTcvdGjKm64= X-Google-Smtp-Source: ABdhPJwHrikRJ4vN3mCOqMwoXEPd+Gc4J5Nup0UChSUVOexpIPqA/xwaKTAULjOMa5b+xt/WnbCn5Q== X-Received: by 2002:a7b:cc89:: with SMTP id p9mr1618268wma.4.1603447957187; Fri, 23 Oct 2020 03:12:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 03:12:36 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 23 Oct 2020 12:12:04 +0200 Message-Id: <20201023101204.760326-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023101204.760326-1-andreas.rheinhardt@gmail.com> References: <20201023101204.760326-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/atrac3: Use least max_depth for get_vlc2() 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" Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index a3e7d96a65..1e884a56b6 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -247,7 +247,7 @@ static void read_quant_spectral_coeffs(GetBitContext *gb, int selector, if (selector != 1) { for (i = 0; i < num_codes; i++) { huff_symb = get_vlc2(gb, spectral_coeff_tab[selector-1].table, - ATRAC3_VLC_BITS, 3); + ATRAC3_VLC_BITS, 1); huff_symb += 1; code = huff_symb >> 1; if (huff_symb & 1) @@ -257,7 +257,7 @@ static void read_quant_spectral_coeffs(GetBitContext *gb, int selector, } else { for (i = 0; i < num_codes; i++) { huff_symb = get_vlc2(gb, spectral_coeff_tab[selector - 1].table, - ATRAC3_VLC_BITS, 3); + ATRAC3_VLC_BITS, 1); mantissas[i * 2 ] = mantissa_vlc_tab[huff_symb * 2 ]; mantissas[i * 2 + 1] = mantissa_vlc_tab[huff_symb * 2 + 1]; }