History

aacdec_dsp: implement 768-point transform and windowing

Required for USAC

Lynne committed 2 years ago

Commit 0513c5c1 parent f8543f37 files · +88 −0Browse files

Unified · Split

7 files
  1. libavcodec/aac/aacdec.c +4 −0
  2. libavcodec/aac/aacdec.h +5 −0
  3. libavcodec/aac/aacdec_dsp_template.c +67 −0
  4. libavcodec/aac/aacdec_fixed.c +2 −0
  5. libavcodec/aac/aacdec_float.c +4 −0
  6. libavcodec/sinewin_fixed_tablegen.c +2 −0
  7. libavcodec/sinewin_fixed_tablegen.h +4 −0
libavcodec/aac/aacdec.c+4−0
@@ -1113,10 +1113,12 @@ static av_cold int decode_close(AVCodecContext *avctx) · 1112 unmodified lines
1113 }1113 }
1114 }1114 }
1115 1115
1116 av_tx_uninit(&ac->mdct96);
1116 av_tx_uninit(&ac->mdct120);1117 av_tx_uninit(&ac->mdct120);
1117 av_tx_uninit(&ac->mdct128);1118 av_tx_uninit(&ac->mdct128);
1118 av_tx_uninit(&ac->mdct480);1119 av_tx_uninit(&ac->mdct480);
1119 av_tx_uninit(&ac->mdct512);1120 av_tx_uninit(&ac->mdct512);
1121 av_tx_uninit(&ac->mdct768);
1120 av_tx_uninit(&ac->mdct960);1122 av_tx_uninit(&ac->mdct960);
1121 av_tx_uninit(&ac->mdct1024);1123 av_tx_uninit(&ac->mdct1024);
1122 av_tx_uninit(&ac->mdct_ltp);1124 av_tx_uninit(&ac->mdct_ltp);
@@ -1145,10 +1147,12 @@ static av_cold int init_dsp(AVCodecContext *avctx) · 22 unmodified lines
1145 if (ret < 0) \1147 if (ret < 0) \
1146 return ret1148 return ret
1147 1149
1150 MDCT_INIT(ac->mdct96, ac->mdct96_fn, 96, 1.0/96);
1148 MDCT_INIT(ac->mdct120, ac->mdct120_fn, 120, 1.0/120);1151 MDCT_INIT(ac->mdct120, ac->mdct120_fn, 120, 1.0/120);
1149 MDCT_INIT(ac->mdct128, ac->mdct128_fn, 128, 1.0/128);1152 MDCT_INIT(ac->mdct128, ac->mdct128_fn, 128, 1.0/128);
1150 MDCT_INIT(ac->mdct480, ac->mdct480_fn, 480, 1.0/480);1153 MDCT_INIT(ac->mdct480, ac->mdct480_fn, 480, 1.0/480);
1151 MDCT_INIT(ac->mdct512, ac->mdct512_fn, 512, 1.0/512);1154 MDCT_INIT(ac->mdct512, ac->mdct512_fn, 512, 1.0/512);
1155 MDCT_INIT(ac->mdct768, ac->mdct768_fn, 768, 1.0/768);
1152 MDCT_INIT(ac->mdct960, ac->mdct960_fn, 960, 1.0/960);1156 MDCT_INIT(ac->mdct960, ac->mdct960_fn, 960, 1.0/960);
1153 MDCT_INIT(ac->mdct1024, ac->mdct1024_fn, 1024, 1.0/1024);1157 MDCT_INIT(ac->mdct1024, ac->mdct1024_fn, 1024, 1.0/1024);
1154#undef MDCT_INIT1158#undef MDCT_INIT
libavcodec/aac/aacdec.h+5−0
@@ -245,6 +245,7 @@ typedef struct AACDecDSP { · 244 unmodified lines
245 ChannelElement *cce, int index);245 ChannelElement *cce, int index);
246 246
247 void (*imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce);247 void (*imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce);
248 void (*imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce);
248 void (*imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement *sce);249 void (*imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement *sce);
249 void (*imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce);250 void (*imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce);
250 void (*imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement *sce);251 void (*imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement *sce);
@@ -290,18 +291,22 @@ struct AACDecContext { · 39 unmodified lines
290 * @name Computed / set up during initialization291 * @name Computed / set up during initialization
291 * @{292 * @{
292 */293 */
294 AVTXContext *mdct96;
293 AVTXContext *mdct120;295 AVTXContext *mdct120;
294 AVTXContext *mdct128;296 AVTXContext *mdct128;
295 AVTXContext *mdct480;297 AVTXContext *mdct480;
296 AVTXContext *mdct512;298 AVTXContext *mdct512;
299 AVTXContext *mdct768;
297 AVTXContext *mdct960;300 AVTXContext *mdct960;
298 AVTXContext *mdct1024;301 AVTXContext *mdct1024;
299 AVTXContext *mdct_ltp;302 AVTXContext *mdct_ltp;
300 303
304 av_tx_fn mdct96_fn;
301 av_tx_fn mdct120_fn;305 av_tx_fn mdct120_fn;
302 av_tx_fn mdct128_fn;306 av_tx_fn mdct128_fn;
303 av_tx_fn mdct480_fn;307 av_tx_fn mdct480_fn;
304 av_tx_fn mdct512_fn;308 av_tx_fn mdct512_fn;
309 av_tx_fn mdct768_fn;
305 av_tx_fn mdct960_fn;310 av_tx_fn mdct960_fn;
306 av_tx_fn mdct1024_fn;311 av_tx_fn mdct1024_fn;
307 av_tx_fn mdct_ltp_fn;312 av_tx_fn mdct_ltp_fn;
libavcodec/aac/aacdec_dsp_template.c+67−0
@@ -383,6 +383,71 @@ static void AAC_RENAME(imdct_and_windowing)(AACDecContext *ac, SingleChannelElem · 382 unmodified lines
383 }383 }
384}384}
385 385
386/**
387 * Conduct IMDCT and windowing for 768-point frames.
388 */
389static void AAC_RENAME(imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce)
390{
391 IndividualChannelStream *ics = &sce->ics;
392 INTFLOAT *in = sce->AAC_RENAME(coeffs);
393 INTFLOAT *out = sce->AAC_RENAME(output);
394 INTFLOAT *saved = sce->AAC_RENAME(saved);
395 const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96);
396 const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(aac_kbd_long_768) : AAC_RENAME(sine_768);
397 const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96);
398 INTFLOAT *buf = ac->AAC_RENAME(buf_mdct);
399 INTFLOAT *temp = ac->AAC_RENAME(temp);
400 int i;
401
402 // imdct
403 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
404 for (i = 0; i < 8; i++)
405 ac->mdct96_fn(ac->mdct96, buf + i * 96, in + i * 96, sizeof(INTFLOAT));
406 } else {
407 ac->mdct768_fn(ac->mdct768, buf, in, sizeof(INTFLOAT));
408 }
409
410 /* window overlapping
411 * NOTE: To simplify the overlapping code, all 'meaningless' short to long
412 * and long to short transitions are considered to be short to short
413 * transitions. This leaves just two cases (long to long and short to short)
414 * with a little special sauce for EIGHT_SHORT_SEQUENCE.
415 */
416
417 if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) &&
418 (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) {
419 ac->fdsp->vector_fmul_window( out, saved, buf, lwindow_prev, 384);
420 } else {
421 memcpy( out, saved, 336 * sizeof(*out));
422
423 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
424 ac->fdsp->vector_fmul_window(out + 336 + 0*96, saved + 336, buf + 0*96, swindow_prev, 48);
425 ac->fdsp->vector_fmul_window(out + 336 + 1*96, buf + 0*96 + 48, buf + 1*96, swindow, 48);
426 ac->fdsp->vector_fmul_window(out + 336 + 2*96, buf + 1*96 + 48, buf + 2*96, swindow, 48);
427 ac->fdsp->vector_fmul_window(out + 336 + 3*96, buf + 2*96 + 48, buf + 3*96, swindow, 48);
428 ac->fdsp->vector_fmul_window(temp, buf + 3*96 + 48, buf + 4*96, swindow, 48);
429 memcpy( out + 336 + 4*96, temp, 48 * sizeof(*out));
430 } else {
431 ac->fdsp->vector_fmul_window(out + 336, saved + 336, buf, swindow_prev, 48);
432 memcpy( out + 432, buf + 48, 336 * sizeof(*out));
433 }
434 }
435
436 // buffer update
437 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
438 memcpy( saved, temp + 48, 48 * sizeof(*saved));
439 ac->fdsp->vector_fmul_window(saved + 48, buf + 4*96 + 48, buf + 5*96, swindow, 48);
440 ac->fdsp->vector_fmul_window(saved + 144, buf + 5*96 + 48, buf + 6*96, swindow, 48);
441 ac->fdsp->vector_fmul_window(saved + 240, buf + 6*96 + 48, buf + 7*96, swindow, 48);
442 memcpy( saved + 336, buf + 7*96 + 48, 48 * sizeof(*saved));
443 } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {
444 memcpy( saved, buf + 384, 336 * sizeof(*saved));
445 memcpy( saved + 336, buf + 7*96 + 48, 48 * sizeof(*saved));
446 } else { // LONG_STOP or ONLY_LONG
447 memcpy( saved, buf + 384, 384 * sizeof(*saved));
448 }
449}
450
386/**451/**
387 * Conduct IMDCT and windowing.452 * Conduct IMDCT and windowing.
388 */453 */
@@ -447,6 +512,7 @@ static void AAC_RENAME(imdct_and_windowing_960)(AACDecContext *ac, SingleChannel · 58 unmodified lines
447 memcpy( saved, buf + 480, 480 * sizeof(*saved));512 memcpy( saved, buf + 480, 480 * sizeof(*saved));
448 }513 }
449}514}
515
450static void AAC_RENAME(imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce)516static void AAC_RENAME(imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce)
451{517{
452 IndividualChannelStream *ics = &sce->ics;518 IndividualChannelStream *ics = &sce->ics;
@@ -609,6 +675,7 @@ static av_cold void AAC_RENAME(aac_dsp_init)(AACDecDSP *aac_dsp) · 156 unmodified lines
609 SET(apply_prediction);675 SET(apply_prediction);
610 676
611 SET(imdct_and_windowing);677 SET(imdct_and_windowing);
678 SET(imdct_and_windowing_768);
612 SET(imdct_and_windowing_960);679 SET(imdct_and_windowing_960);
613 SET(imdct_and_windowing_ld);680 SET(imdct_and_windowing_ld);
614 SET(imdct_and_windowing_eld);681 SET(imdct_and_windowing_eld);
libavcodec/aac/aacdec_fixed.c+2−0
@@ -47,6 +47,8 @@ DECLARE_ALIGNED(32, static int, aac_kbd_long_1024_fixed)[1024]; · 46 unmodified lines
47DECLARE_ALIGNED(32, static int, aac_kbd_short_128_fixed)[128];47DECLARE_ALIGNED(32, static int, aac_kbd_short_128_fixed)[128];
48DECLARE_ALIGNED(32, static int, aac_kbd_long_960_fixed)[960];48DECLARE_ALIGNED(32, static int, aac_kbd_long_960_fixed)[960];
49DECLARE_ALIGNED(32, static int, aac_kbd_short_120_fixed)[120];49DECLARE_ALIGNED(32, static int, aac_kbd_short_120_fixed)[120];
50DECLARE_ALIGNED(32, static int, aac_kbd_long_768_fixed)[768];
51DECLARE_ALIGNED(32, static int, aac_kbd_short_96_fixed)[96];
50 52
51static void init_tables_fixed_fn(void)53static void init_tables_fixed_fn(void)
52{54{
libavcodec/aac/aacdec_float.c+4−0
@@ -44,10 +44,14 @@ · 43 unmodified lines
44#include "libavutil/mathematics.h"44#include "libavutil/mathematics.h"
45#include "libavcodec/aacsbr.h"45#include "libavcodec/aacsbr.h"
46 46
47DECLARE_ALIGNED(32, static float, sine_96)[96];
47DECLARE_ALIGNED(32, static float, sine_120)[120];48DECLARE_ALIGNED(32, static float, sine_120)[120];
49DECLARE_ALIGNED(32, static float, sine_768)[768];
48DECLARE_ALIGNED(32, static float, sine_960)[960];50DECLARE_ALIGNED(32, static float, sine_960)[960];
49DECLARE_ALIGNED(32, static float, aac_kbd_long_960)[960];51DECLARE_ALIGNED(32, static float, aac_kbd_long_960)[960];
50DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120];52DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120];
53DECLARE_ALIGNED(32, static float, aac_kbd_long_768)[768];
54DECLARE_ALIGNED(32, static float, aac_kbd_short_96)[96];
51 55
52static void init_tables_float_fn(void)56static void init_tables_float_fn(void)
53{57{
libavcodec/sinewin_fixed_tablegen.c+2−0
@@ -35,10 +35,12 @@ int main(void) · 34 unmodified lines
35 printf("SINETABLE("#size") = {\n"); \35 printf("SINETABLE("#size") = {\n"); \
36 write_int32_t_array(sine_ ## size ## _fixed, size); \36 write_int32_t_array(sine_ ## size ## _fixed, size); \
37 printf("};\n")37 printf("};\n")
38 PRINT_TABLE(96);
38 PRINT_TABLE(120);39 PRINT_TABLE(120);
39 PRINT_TABLE(128);40 PRINT_TABLE(128);
40 PRINT_TABLE(480);41 PRINT_TABLE(480);
41 PRINT_TABLE(512);42 PRINT_TABLE(512);
43 PRINT_TABLE(768);
42 PRINT_TABLE(960);44 PRINT_TABLE(960);
43 PRINT_TABLE(1024);45 PRINT_TABLE(1024);
44 return 0;46 return 0;
libavcodec/sinewin_fixed_tablegen.h+4−0
@@ -44,10 +44,12 @@ · 43 unmodified lines
44#include "libavutil/attributes.h"44#include "libavutil/attributes.h"
45 45
46#define SINETABLE_CONST46#define SINETABLE_CONST
47SINETABLE( 96);
47SINETABLE( 120);48SINETABLE( 120);
48SINETABLE( 128);49SINETABLE( 128);
49SINETABLE( 480);50SINETABLE( 480);
50SINETABLE( 512);51SINETABLE( 512);
52SINETABLE( 768);
51SINETABLE( 960);53SINETABLE( 960);
52SINETABLE(1024);54SINETABLE(1024);
53 55
@@ -62,10 +64,12 @@ static av_cold void sine_window_init_fixed(int *window, int n) · 8 unmodified lines
62 64
63static av_cold void init_sine_windows_fixed(void)65static av_cold void init_sine_windows_fixed(void)
64{66{
67 sine_window_init_fixed(sine_96_fixed, 96);
65 sine_window_init_fixed(sine_120_fixed, 120);68 sine_window_init_fixed(sine_120_fixed, 120);
66 sine_window_init_fixed(sine_128_fixed, 128);69 sine_window_init_fixed(sine_128_fixed, 128);
67 sine_window_init_fixed(sine_480_fixed, 480);70 sine_window_init_fixed(sine_480_fixed, 480);
68 sine_window_init_fixed(sine_512_fixed, 512);71 sine_window_init_fixed(sine_512_fixed, 512);
72 sine_window_init_fixed(sine_768_fixed, 768);
69 sine_window_init_fixed(sine_960_fixed, 960);73 sine_window_init_fixed(sine_960_fixed, 960);
70 sine_window_init_fixed(sine_1024_fixed, 1024);74 sine_window_init_fixed(sine_1024_fixed, 1024);
71}75}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t