From patchwork Sat May 25 02:27:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 49232 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:542:0:b0:460:55fa:d5ed with SMTP id 63csp2098040vqf; Fri, 24 May 2024 19:29:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU1iFfRR/y/0NAA48tDhI8ALH2LZBHWziWOtcKGSU6g+DFUUzPJqg2f1UuGMU76c76BFBlBg5y2f69DznTKfp2pKqr6qsmEIVOg4g== X-Google-Smtp-Source: AGHT+IH1td1BB3qpMTD+rp/F2meSrP5hCANp7lQ++OmaPUOWiqSf+1hEUtiDwY+GNu4SMeLQQkur X-Received: by 2002:a17:906:248b:b0:a59:cb29:3fa7 with SMTP id a640c23a62f3a-a626419589fmr243752766b.1.1716604163557; Fri, 24 May 2024 19:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716604163; cv=none; d=google.com; s=arc-20160816; b=VZkzF+yw5eAZnIe8XPBedsGXnPx77PP6mpClUCgR7Em+//eWcmqRZn32QccQ+qxDAK pghwADslgs3gtc0rgMBH4Zb3V/t5QZjr5k+wUltlmWYSJ2S48quYwcim3btdOHpfQL40 +enBGa4bSIMUqju5MTleEnjIJP07O9Doo2y+iIEqUsUNU4e2KpwbWV5QRTaMXclvsiaR aTZTGlanbXItR3axTpruwpsMKUB0mnmmDpXYtXBuJM/ik/KEvgnW+ZJ4qqqWsUnU4Bp4 7WxszAGLvG2iC6UNuyYNxiLaXH2dAOG3sw6P1gplGmnbRCBSrcdRtyzjPgCrBIHM1ZPc zvCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:delivered-to; bh=2G+TFTA7A8YswR8B3ty6J79uH2XNgrG6cvr96sZ+rV8=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=O+ZmVfqb9MmIMuKkIsDruKYgASx65iW7tQVPpG2n6qzitgUASodUMeuf5JPJfDHImk RGNs3wX5xRTgf8oWzpOI8Hu69J7Wuj7RfEJtn5O2s/P5rv+IUpu7r4BLRUgf7TznjOLj 6Fc65LsUoNTX4MpynPA621mOGm2lHBq1iOUiCjfhDN2sW3TtAzg2l2rdNa7qAljx3hqG X6iEhzls1MRzuEJN0Snk4T9UFbyyvvveXmYc1ChWXJ9+6k7T1AvKVXy5DhKJIAoOJs6k eSE0IZYmOCyC/yRFoJgRCkEKyzGoYjVuzwJUpygG8NIQwZMGONKNUk89TE6x07k3RCBb AJHw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a626cc682a4si130750366b.656.2024.05.24.19.29.23; Fri, 24 May 2024 19:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 35FD568D5E3; Sat, 25 May 2024 05:28:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3EB3168D580 for ; Sat, 25 May 2024 05:28:23 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Sat, 25 May 2024 04:27:58 +0200 Message-ID: <20240525022813.2292001-6-dev@lynne.ee> X-Mailer: git-send-email 2.43.0.381.gb435a96ce8 In-Reply-To: <20240525022813.2292001-1-dev@lynne.ee> References: <20240525022813.2292001-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 05/10] aacdec_dsp: implement 768-point transform and windowing X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: hm058V13PWFX Required for USAC --- libavcodec/aac/aacdec.c | 4 ++ libavcodec/aac/aacdec.h | 5 +++ libavcodec/aac/aacdec_dsp_template.c | 67 ++++++++++++++++++++++++++++ libavcodec/aac/aacdec_fixed.c | 2 + libavcodec/aac/aacdec_float.c | 4 ++ libavcodec/sinewin_fixed_tablegen.c | 2 + libavcodec/sinewin_fixed_tablegen.h | 4 ++ 7 files changed, 88 insertions(+) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index a7e5b2a369..6f37ac5361 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1113,10 +1113,12 @@ static av_cold int decode_close(AVCodecContext *avctx) } } + av_tx_uninit(&ac->mdct96); av_tx_uninit(&ac->mdct120); av_tx_uninit(&ac->mdct128); av_tx_uninit(&ac->mdct480); av_tx_uninit(&ac->mdct512); + av_tx_uninit(&ac->mdct768); av_tx_uninit(&ac->mdct960); av_tx_uninit(&ac->mdct1024); av_tx_uninit(&ac->mdct_ltp); @@ -1145,10 +1147,12 @@ static av_cold int init_dsp(AVCodecContext *avctx) if (ret < 0) \ return ret + MDCT_INIT(ac->mdct96, ac->mdct96_fn, 96, 1.0/96); MDCT_INIT(ac->mdct120, ac->mdct120_fn, 120, 1.0/120); MDCT_INIT(ac->mdct128, ac->mdct128_fn, 128, 1.0/128); MDCT_INIT(ac->mdct480, ac->mdct480_fn, 480, 1.0/480); MDCT_INIT(ac->mdct512, ac->mdct512_fn, 512, 1.0/512); + MDCT_INIT(ac->mdct768, ac->mdct768_fn, 768, 1.0/768); MDCT_INIT(ac->mdct960, ac->mdct960_fn, 960, 1.0/960); MDCT_INIT(ac->mdct1024, ac->mdct1024_fn, 1024, 1.0/1024); #undef MDCT_INIT diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index 499bd8eefc..8d1eb74066 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -245,6 +245,7 @@ typedef struct AACDecDSP { ChannelElement *cce, int index); void (*imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce); + void (*imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce); void (*imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement *sce); void (*imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce); void (*imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement *sce); @@ -290,18 +291,22 @@ struct AACDecContext { * @name Computed / set up during initialization * @{ */ + AVTXContext *mdct96; AVTXContext *mdct120; AVTXContext *mdct128; AVTXContext *mdct480; AVTXContext *mdct512; + AVTXContext *mdct768; AVTXContext *mdct960; AVTXContext *mdct1024; AVTXContext *mdct_ltp; + av_tx_fn mdct96_fn; av_tx_fn mdct120_fn; av_tx_fn mdct128_fn; av_tx_fn mdct480_fn; av_tx_fn mdct512_fn; + av_tx_fn mdct768_fn; av_tx_fn mdct960_fn; av_tx_fn mdct1024_fn; av_tx_fn mdct_ltp_fn; diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c index e69970472c..59a69d88f3 100644 --- a/libavcodec/aac/aacdec_dsp_template.c +++ b/libavcodec/aac/aacdec_dsp_template.c @@ -383,6 +383,71 @@ static void AAC_RENAME(imdct_and_windowing)(AACDecContext *ac, SingleChannelElem } } +/** + * Conduct IMDCT and windowing for 768-point frames. + */ +static void AAC_RENAME(imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + INTFLOAT *in = sce->AAC_RENAME(coeffs); + INTFLOAT *out = sce->AAC_RENAME(output); + INTFLOAT *saved = sce->AAC_RENAME(saved); + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96); + const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(aac_kbd_long_768) : AAC_RENAME(sine_768); + const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96); + INTFLOAT *buf = ac->AAC_RENAME(buf_mdct); + INTFLOAT *temp = ac->AAC_RENAME(temp); + int i; + + // imdct + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + for (i = 0; i < 8; i++) + ac->mdct96_fn(ac->mdct96, buf + i * 96, in + i * 96, sizeof(INTFLOAT)); + } else { + ac->mdct768_fn(ac->mdct768, buf, in, sizeof(INTFLOAT)); + } + + /* window overlapping + * NOTE: To simplify the overlapping code, all 'meaningless' short to long + * and long to short transitions are considered to be short to short + * transitions. This leaves just two cases (long to long and short to short) + * with a little special sauce for EIGHT_SHORT_SEQUENCE. + */ + + if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && + (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { + ac->fdsp->vector_fmul_window( out, saved, buf, lwindow_prev, 384); + } else { + memcpy( out, saved, 336 * sizeof(*out)); + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + ac->fdsp->vector_fmul_window(out + 336 + 0*96, saved + 336, buf + 0*96, swindow_prev, 48); + ac->fdsp->vector_fmul_window(out + 336 + 1*96, buf + 0*96 + 48, buf + 1*96, swindow, 48); + ac->fdsp->vector_fmul_window(out + 336 + 2*96, buf + 1*96 + 48, buf + 2*96, swindow, 48); + ac->fdsp->vector_fmul_window(out + 336 + 3*96, buf + 2*96 + 48, buf + 3*96, swindow, 48); + ac->fdsp->vector_fmul_window(temp, buf + 3*96 + 48, buf + 4*96, swindow, 48); + memcpy( out + 336 + 4*96, temp, 48 * sizeof(*out)); + } else { + ac->fdsp->vector_fmul_window(out + 336, saved + 336, buf, swindow_prev, 48); + memcpy( out + 432, buf + 48, 336 * sizeof(*out)); + } + } + + // buffer update + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + memcpy( saved, temp + 48, 48 * sizeof(*saved)); + ac->fdsp->vector_fmul_window(saved + 48, buf + 4*96 + 48, buf + 5*96, swindow, 48); + ac->fdsp->vector_fmul_window(saved + 144, buf + 5*96 + 48, buf + 6*96, swindow, 48); + ac->fdsp->vector_fmul_window(saved + 240, buf + 6*96 + 48, buf + 7*96, swindow, 48); + memcpy( saved + 336, buf + 7*96 + 48, 48 * sizeof(*saved)); + } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { + memcpy( saved, buf + 384, 336 * sizeof(*saved)); + memcpy( saved + 336, buf + 7*96 + 48, 48 * sizeof(*saved)); + } else { // LONG_STOP or ONLY_LONG + memcpy( saved, buf + 384, 384 * sizeof(*saved)); + } +} + /** * Conduct IMDCT and windowing. */ @@ -447,6 +512,7 @@ static void AAC_RENAME(imdct_and_windowing_960)(AACDecContext *ac, SingleChannel memcpy( saved, buf + 480, 480 * sizeof(*saved)); } } + static void AAC_RENAME(imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce) { IndividualChannelStream *ics = &sce->ics; @@ -609,6 +675,7 @@ static av_cold void AAC_RENAME(aac_dsp_init)(AACDecDSP *aac_dsp) SET(apply_prediction); SET(imdct_and_windowing); + SET(imdct_and_windowing_768); SET(imdct_and_windowing_960); SET(imdct_and_windowing_ld); SET(imdct_and_windowing_eld); diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c index de90880884..89f1ea0384 100644 --- a/libavcodec/aac/aacdec_fixed.c +++ b/libavcodec/aac/aacdec_fixed.c @@ -47,6 +47,8 @@ DECLARE_ALIGNED(32, static int, aac_kbd_long_1024_fixed)[1024]; DECLARE_ALIGNED(32, static int, aac_kbd_short_128_fixed)[128]; DECLARE_ALIGNED(32, static int, aac_kbd_long_960_fixed)[960]; DECLARE_ALIGNED(32, static int, aac_kbd_short_120_fixed)[120]; +DECLARE_ALIGNED(32, static int, aac_kbd_long_768_fixed)[768]; +DECLARE_ALIGNED(32, static int, aac_kbd_short_96_fixed)[96]; static void init_tables_fixed_fn(void) { diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c index 03ec264c50..14169e95d8 100644 --- a/libavcodec/aac/aacdec_float.c +++ b/libavcodec/aac/aacdec_float.c @@ -44,10 +44,14 @@ #include "libavutil/mathematics.h" #include "libavcodec/aacsbr.h" +DECLARE_ALIGNED(32, static float, sine_96)[96]; DECLARE_ALIGNED(32, static float, sine_120)[120]; +DECLARE_ALIGNED(32, static float, sine_768)[768]; DECLARE_ALIGNED(32, static float, sine_960)[960]; DECLARE_ALIGNED(32, static float, aac_kbd_long_960)[960]; DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120]; +DECLARE_ALIGNED(32, static float, aac_kbd_long_768)[768]; +DECLARE_ALIGNED(32, static float, aac_kbd_short_96)[96]; static void init_tables_float_fn(void) { diff --git a/libavcodec/sinewin_fixed_tablegen.c b/libavcodec/sinewin_fixed_tablegen.c index 15f0cc2072..86e9dfb1e7 100644 --- a/libavcodec/sinewin_fixed_tablegen.c +++ b/libavcodec/sinewin_fixed_tablegen.c @@ -35,10 +35,12 @@ int main(void) printf("SINETABLE("#size") = {\n"); \ write_int32_t_array(sine_ ## size ## _fixed, size); \ printf("};\n") + PRINT_TABLE(96); PRINT_TABLE(120); PRINT_TABLE(128); PRINT_TABLE(480); PRINT_TABLE(512); + PRINT_TABLE(768); PRINT_TABLE(960); PRINT_TABLE(1024); return 0; diff --git a/libavcodec/sinewin_fixed_tablegen.h b/libavcodec/sinewin_fixed_tablegen.h index 056735704c..660c0056b5 100644 --- a/libavcodec/sinewin_fixed_tablegen.h +++ b/libavcodec/sinewin_fixed_tablegen.h @@ -44,10 +44,12 @@ #include "libavutil/attributes.h" #define SINETABLE_CONST +SINETABLE( 96); SINETABLE( 120); SINETABLE( 128); SINETABLE( 480); SINETABLE( 512); +SINETABLE( 768); SINETABLE( 960); SINETABLE(1024); @@ -62,10 +64,12 @@ static av_cold void sine_window_init_fixed(int *window, int n) static av_cold void init_sine_windows_fixed(void) { + sine_window_init_fixed(sine_96_fixed, 96); sine_window_init_fixed(sine_120_fixed, 120); sine_window_init_fixed(sine_128_fixed, 128); sine_window_init_fixed(sine_480_fixed, 480); sine_window_init_fixed(sine_512_fixed, 512); + sine_window_init_fixed(sine_768_fixed, 768); sine_window_init_fixed(sine_960_fixed, 960); sine_window_init_fixed(sine_1024_fixed, 1024); }