From patchwork Fri Nov 20 07:33: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: 23892 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 3211644A412 for ; Fri, 20 Nov 2020 09:52:06 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B4F7568BD87; Fri, 20 Nov 2020 09:34:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 42DDD68BD06 for ; Fri, 20 Nov 2020 09:34:47 +0200 (EET) Received: by mail-ej1-f68.google.com with SMTP id s25so11525360ejy.6 for ; Thu, 19 Nov 2020 23:34:47 -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=gmcigc7yjHrNxdfWKdEvT5JPnyY3oS6VMBly1M8tDnA=; b=lOiJLYMduYdDiVS0xfCcfsEH1OYXleiOBNcZXkKLiC5MERo2fX+vMvzSqMNczoguaJ lRZH9oS++rmoL5vIBw4lcWMBBDv3ZWzhH8NUXfrZYwonABFpOTaSYleLJXokbbYi2zzI fYBWfZQ2UFwou4fTO3aWnIA0ie0j4EdW40YXcVY5lsm8eLGXI4WZnajJLe/OwbCjqk/P z/idE0jFhOsBX4NCFZUnQEj3IIHWMgbPG0SjFi1bFXiUhA/44j0qLwcdhV+KtuswuXwN gkxOTkoS0nOSYRAHEVtW5+OFeSlV4cl0r8Usaj+YovI9x9z0SkWRGf8XvC4D/KKM0x13 YcbA== 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=gmcigc7yjHrNxdfWKdEvT5JPnyY3oS6VMBly1M8tDnA=; b=KPok7Qz1eEfEkGq8ijJEkm+XZEaIbvMsb6q4Ngm6zXij0XEx7u7TB/Sl9YBqNkdgyY Mi1IimyEfP9/Ccja+uW3Hx802zdEuqb7Tfhd38v3tCdxD0QDEjLLyZUypkMjGmm+dYmO VV7rmEhQqGxu+xd4lAVveT67px3b491yZbYH5ipUXWlarHPV6VCHa+Cb93JTnSRCng+q +HyG50E1C7lRG+FUy060ADqtYG4aEiq6Xsz+mA5LNsoIlJgXvFvxwEGGAQXUsa3FmeYq NaRIe62uNdBWKOH77LrhFhoe7pQKY0KFJN9bqpLgZOsO/G4RetIVG+gN7++RZJxgacYQ YQRA== X-Gm-Message-State: AOAM5310DSAoctXiNebdtyYXqLjwGSysR+dppO63sGQciIPCfuqxtQmz 1mhBDQoFaUXZYH27X216Lm8c6sdATSzR3Q== X-Google-Smtp-Source: ABdhPJwpGZHwUHWvGhpKY0dwrj3gZhpvgfsS9UlzqFg98qjz1aEza9GZiNlpvP4JAr/5qYjkZUabHQ== X-Received: by 2002:a17:906:580e:: with SMTP id m14mr30540351ejq.237.1605857686390; Thu, 19 Nov 2020 23:34:46 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id i13sm769110ejv.84.2020.11.19.23.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:34:45 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:33:06 +0100 Message-Id: <20201120073327.820745-42-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> References: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 141/162] avcodec/aacdec_template: Use VLC symbols table 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" Expressions like array[get_vlc2()] can be optimized by using a symbols table if the array is always the same for a given VLC. This requirement is fulfilled for several VLCs used by the AAC decoders. Signed-off-by: Andreas Rheinhardt --- libavcodec/aacdec_template.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 473a075201..186175e6e6 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1204,11 +1204,13 @@ static av_cold void aac_static_table_init(void) for (unsigned i = 0, offset = 0; i < 11; i++) { vlc_spectral[i].table = &vlc_buf[offset]; vlc_spectral[i].table_allocated = FF_ARRAY_ELEMS(vlc_buf) - offset; - init_vlc(&vlc_spectral[i], 8, ff_aac_spectral_sizes[i], - ff_aac_spectral_bits[i], sizeof(ff_aac_spectral_bits[i][0]), - sizeof(ff_aac_spectral_bits[i][0]), - ff_aac_spectral_codes[i], sizeof(ff_aac_spectral_codes[i][0]), - sizeof(ff_aac_spectral_codes[i][0]), + ff_init_vlc_sparse(&vlc_spectral[i], 8, ff_aac_spectral_sizes[i], + ff_aac_spectral_bits[i], sizeof(ff_aac_spectral_bits[i][0]), + sizeof(ff_aac_spectral_bits[i][0]), + ff_aac_spectral_codes[i], sizeof(ff_aac_spectral_codes[i][0]), + sizeof(ff_aac_spectral_codes[i][0]), + ff_aac_codebook_vector_idx[i], sizeof(ff_aac_codebook_vector_idx[i][0]), + sizeof(ff_aac_codebook_vector_idx[i][0]), INIT_VLC_STATIC_OVERLONG); offset += vlc_spectral[i].table_size; } @@ -1796,7 +1798,6 @@ static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], #if !USE_FIXED const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; #endif /* !USE_FIXED */ - const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1]; VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table; OPEN_READER(re, gb); @@ -1812,7 +1813,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; + cb_idx = code; #if USE_FIXED cf = DEC_SQUAD(cf, cb_idx); #else @@ -1835,7 +1836,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; + cb_idx = code; nnz = cb_idx >> 8 & 15; bits = nnz ? GET_CACHE(re, gb) : 0; LAST_SKIP_BITS(re, gb, nnz); @@ -1859,7 +1860,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; + cb_idx = code; #if USE_FIXED cf = DEC_SPAIR(cf, cb_idx); #else @@ -1883,7 +1884,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); - cb_idx = cb_vector_idx[code]; + cb_idx = code; nnz = cb_idx >> 8 & 15; sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; LAST_SKIP_BITS(re, gb, nnz); @@ -1916,14 +1917,14 @@ static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); + cb_idx = code; - if (!code) { + if (cb_idx == 0x0000) { *icf++ = 0; *icf++ = 0; continue; } - cb_idx = cb_vector_idx[code]; nnz = cb_idx >> 12; nzt = cb_idx >> 8; bits = SHOW_UBITS(re, gb, nnz) << (32-nnz);