From d5a7229ba4aabc2b6407c731d9175879ae54c5ea Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 21 May 2012 12:58:41 -0400 Subject: Add a float DSP framework to libavutil Move vector_fmul() from DSPContext to AVFloatDSPContext. --- libavcodec/aacenc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'libavcodec/aacenc.c') diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 6021c375bb..0186011136 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -30,6 +30,7 @@ * add temporal noise shaping ***********************************/ +#include "libavutil/float_dsp.h" #include "libavutil/opt.h" #include "avcodec.h" #include "put_bits.h" @@ -182,7 +183,9 @@ static void put_audio_specific_config(AVCodecContext *avctx) } #define WINDOW_FUNC(type) \ -static void apply_ ##type ##_window(DSPContext *dsp, SingleChannelElement *sce, const float *audio) +static void apply_ ##type ##_window(DSPContext *dsp, AVFloatDSPContext *fdsp, \ + SingleChannelElement *sce, \ + const float *audio) WINDOW_FUNC(only_long) { @@ -190,7 +193,7 @@ WINDOW_FUNC(only_long) const float *pwindow = sce->ics.use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; float *out = sce->ret; - dsp->vector_fmul (out, audio, lwindow, 1024); + fdsp->vector_fmul (out, audio, lwindow, 1024); dsp->vector_fmul_reverse(out + 1024, audio + 1024, pwindow, 1024); } @@ -200,7 +203,7 @@ WINDOW_FUNC(long_start) const float *swindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; float *out = sce->ret; - dsp->vector_fmul(out, audio, lwindow, 1024); + fdsp->vector_fmul(out, audio, lwindow, 1024); memcpy(out + 1024, audio + 1024, sizeof(out[0]) * 448); dsp->vector_fmul_reverse(out + 1024 + 448, audio + 1024 + 448, swindow, 128); memset(out + 1024 + 576, 0, sizeof(out[0]) * 448); @@ -213,7 +216,7 @@ WINDOW_FUNC(long_stop) float *out = sce->ret; memset(out, 0, sizeof(out[0]) * 448); - dsp->vector_fmul(out + 448, audio + 448, swindow, 128); + fdsp->vector_fmul(out + 448, audio + 448, swindow, 128); memcpy(out + 576, audio + 576, sizeof(out[0]) * 448); dsp->vector_fmul_reverse(out + 1024, audio + 1024, lwindow, 1024); } @@ -227,7 +230,7 @@ WINDOW_FUNC(eight_short) int w; for (w = 0; w < 8; w++) { - dsp->vector_fmul (out, in, w ? pwindow : swindow, 128); + fdsp->vector_fmul (out, in, w ? pwindow : swindow, 128); out += 128; in += 128; dsp->vector_fmul_reverse(out, in, swindow, 128); @@ -235,7 +238,9 @@ WINDOW_FUNC(eight_short) } } -static void (*const apply_window[4])(DSPContext *dsp, SingleChannelElement *sce, const float *audio) = { +static void (*const apply_window[4])(DSPContext *dsp, AVFloatDSPContext *fdsp, + SingleChannelElement *sce, + const float *audio) = { [ONLY_LONG_SEQUENCE] = apply_only_long_window, [LONG_START_SEQUENCE] = apply_long_start_window, [EIGHT_SHORT_SEQUENCE] = apply_eight_short_window, @@ -248,7 +253,7 @@ static void apply_window_and_mdct(AACEncContext *s, SingleChannelElement *sce, int i; float *output = sce->ret; - apply_window[sce->ics.window_sequence[0]](&s->dsp, sce, audio); + apply_window[sce->ics.window_sequence[0]](&s->dsp, &s->fdsp, sce, audio); if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) s->mdct1024.mdct_calc(&s->mdct1024, sce->coeffs, output); @@ -694,6 +699,7 @@ static av_cold int dsp_init(AVCodecContext *avctx, AACEncContext *s) int ret = 0; ff_dsputil_init(&s->dsp, avctx); + avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); // window init ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); -- cgit v1.2.3