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
11131113 }
11141114 }
11151115
1116+ av_tx_uninit(&ac->mdct96);
11161117 av_tx_uninit(&ac->mdct120);
11171118 av_tx_uninit(&ac->mdct128);
11181119 av_tx_uninit(&ac->mdct480);
11191120 av_tx_uninit(&ac->mdct512);
1121+ av_tx_uninit(&ac->mdct768);
11201122 av_tx_uninit(&ac->mdct960);
11211123 av_tx_uninit(&ac->mdct1024);
11221124 av_tx_uninit(&ac->mdct_ltp);
@@ -1145,10 +1147,12 @@ static av_cold int init_dsp(AVCodecContext *avctx) · 22 unmodified lines
11451147 if (ret < 0) \
11461148 return ret
11471149
1150+ MDCT_INIT(ac->mdct96, ac->mdct96_fn, 96, 1.0/96);
11481151 MDCT_INIT(ac->mdct120, ac->mdct120_fn, 120, 1.0/120);
11491152 MDCT_INIT(ac->mdct128, ac->mdct128_fn, 128, 1.0/128);
11501153 MDCT_INIT(ac->mdct480, ac->mdct480_fn, 480, 1.0/480);
11511154 MDCT_INIT(ac->mdct512, ac->mdct512_fn, 512, 1.0/512);
1155+ MDCT_INIT(ac->mdct768, ac->mdct768_fn, 768, 1.0/768);
11521156 MDCT_INIT(ac->mdct960, ac->mdct960_fn, 960, 1.0/960);
11531157 MDCT_INIT(ac->mdct1024, ac->mdct1024_fn, 1024, 1.0/1024);
11541158 #undef MDCT_INIT
libavcodec/aac/aacdec.h+5−0
@@ -245,6 +245,7 @@ typedef struct AACDecDSP { · 244 unmodified lines
245245 ChannelElement *cce, int index);
246246
247247 void (*imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce);
248+ void (*imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce);
248249 void (*imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement *sce);
249250 void (*imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce);
250251 void (*imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement *sce);
@@ -290,18 +291,22 @@ struct AACDecContext { · 39 unmodified lines
290291 * @name Computed / set up during initialization
291292 * @{
292293 */
294+ AVTXContext *mdct96;
293295 AVTXContext *mdct120;
294296 AVTXContext *mdct128;
295297 AVTXContext *mdct480;
296298 AVTXContext *mdct512;
299+ AVTXContext *mdct768;
297300 AVTXContext *mdct960;
298301 AVTXContext *mdct1024;
299302 AVTXContext *mdct_ltp;
300303
304+ av_tx_fn mdct96_fn;
301305 av_tx_fn mdct120_fn;
302306 av_tx_fn mdct128_fn;
303307 av_tx_fn mdct480_fn;
304308 av_tx_fn mdct512_fn;
309+ av_tx_fn mdct768_fn;
305310 av_tx_fn mdct960_fn;
306311 av_tx_fn mdct1024_fn;
307312 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
383383 }
384384 }
385385
386+/**
387+ * Conduct IMDCT and windowing for 768-point frames.
388+ */
389+static 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+
386451 /**
387452 * Conduct IMDCT and windowing.
388453 */
@@ -447,6 +512,7 @@ static void AAC_RENAME(imdct_and_windowing_960)(AACDecContext *ac, SingleChannel · 58 unmodified lines
447512 memcpy( saved, buf + 480, 480 * sizeof(*saved));
448513 }
449514 }
515+
450516 static void AAC_RENAME(imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce)
451517 {
452518 IndividualChannelStream *ics = &sce->ics;
@@ -609,6 +675,7 @@ static av_cold void AAC_RENAME(aac_dsp_init)(AACDecDSP *aac_dsp) · 156 unmodified lines
609675 SET(apply_prediction);
610676
611677 SET(imdct_and_windowing);
678+ SET(imdct_and_windowing_768);
612679 SET(imdct_and_windowing_960);
613680 SET(imdct_and_windowing_ld);
614681 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
4747 DECLARE_ALIGNED(32, static int, aac_kbd_short_128_fixed)[128];
4848 DECLARE_ALIGNED(32, static int, aac_kbd_long_960_fixed)[960];
4949 DECLARE_ALIGNED(32, static int, aac_kbd_short_120_fixed)[120];
50+DECLARE_ALIGNED(32, static int, aac_kbd_long_768_fixed)[768];
51+DECLARE_ALIGNED(32, static int, aac_kbd_short_96_fixed)[96];
5052
5153 static void init_tables_fixed_fn(void)
5254 {
libavcodec/aac/aacdec_float.c+4−0
@@ -44,10 +44,14 @@ · 43 unmodified lines
4444 #include "libavutil/mathematics.h"
4545 #include "libavcodec/aacsbr.h"
4646
47+DECLARE_ALIGNED(32, static float, sine_96)[96];
4748 DECLARE_ALIGNED(32, static float, sine_120)[120];
49+DECLARE_ALIGNED(32, static float, sine_768)[768];
4850 DECLARE_ALIGNED(32, static float, sine_960)[960];
4951 DECLARE_ALIGNED(32, static float, aac_kbd_long_960)[960];
5052 DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120];
53+DECLARE_ALIGNED(32, static float, aac_kbd_long_768)[768];
54+DECLARE_ALIGNED(32, static float, aac_kbd_short_96)[96];
5155
5256 static void init_tables_float_fn(void)
5357 {
libavcodec/sinewin_fixed_tablegen.c+2−0
@@ -35,10 +35,12 @@ int main(void) · 34 unmodified lines
3535 printf("SINETABLE("#size") = {\n"); \
3636 write_int32_t_array(sine_ ## size ## _fixed, size); \
3737 printf("};\n")
38+ PRINT_TABLE(96);
3839 PRINT_TABLE(120);
3940 PRINT_TABLE(128);
4041 PRINT_TABLE(480);
4142 PRINT_TABLE(512);
43+ PRINT_TABLE(768);
4244 PRINT_TABLE(960);
4345 PRINT_TABLE(1024);
4446 return 0;
libavcodec/sinewin_fixed_tablegen.h+4−0
@@ -44,10 +44,12 @@ · 43 unmodified lines
4444 #include "libavutil/attributes.h"
4545
4646 #define SINETABLE_CONST
47+SINETABLE( 96);
4748 SINETABLE( 120);
4849 SINETABLE( 128);
4950 SINETABLE( 480);
5051 SINETABLE( 512);
52+SINETABLE( 768);
5153 SINETABLE( 960);
5254 SINETABLE(1024);
5355
@@ -62,10 +64,12 @@ static av_cold void sine_window_init_fixed(int *window, int n) · 8 unmodified lines
6264
6365 static av_cold void init_sine_windows_fixed(void)
6466 {
67+ sine_window_init_fixed(sine_96_fixed, 96);
6568 sine_window_init_fixed(sine_120_fixed, 120);
6669 sine_window_init_fixed(sine_128_fixed, 128);
6770 sine_window_init_fixed(sine_480_fixed, 480);
6871 sine_window_init_fixed(sine_512_fixed, 512);
72+ sine_window_init_fixed(sine_768_fixed, 768);
6973 sine_window_init_fixed(sine_960_fixed, 960);
7074 sine_window_init_fixed(sine_1024_fixed, 1024);
7175 }

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