diff options
author | Alex Converse <alex.converse@gmail.com> | 2010-06-19 18:14:51 +0400 |
---|---|---|
committer | Alex Converse <alex.converse@gmail.com> | 2010-06-19 18:14:51 +0400 |
commit | a20639017bfca0490bb1799575714f22bf470b4f (patch) | |
tree | 7ece4b88c997a02342f75f91d1b928dd67257681 /libavcodec/aacsbr.c | |
parent | 4d49a5a785220c3430739de8b1e340a4ea3f1864 (diff) |
Add HE-AAC v2 support to the AAC decoder.
Originally committed as revision 23647 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/aacsbr.c')
-rw-r--r-- | libavcodec/aacsbr.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index b6631a07fc..c8ff299fe0 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -31,6 +31,7 @@ #include "aacsbr.h" #include "aacsbrdata.h" #include "fft.h" +#include "ps.h" #include <stdint.h> #include <float.h> @@ -120,6 +121,8 @@ av_cold void ff_aac_sbr_init(void) for (n = 0; n < 320; n++) sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; + + ff_ps_init(); } av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) @@ -130,6 +133,7 @@ av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); ff_mdct_init(&sbr->mdct, 7, 1, 1.0/64); ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0); + ff_ps_ctx_init(&sbr->ps); } av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) @@ -890,7 +894,6 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int bs_extension_id, int *num_bits_left) { -//TODO - implement ps_data for parametric stereo parsing switch (bs_extension_id) { case EXTENSION_ID_PS: if (!ac->m4ac.ps) { @@ -898,8 +901,8 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, skip_bits_long(gb, *num_bits_left); // bs_fill_bits *num_bits_left = 0; } else { -#if 0 - *num_bits_left -= ff_ps_data(gb, ps); +#if 1 + *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); #else av_log_missing_feature(ac->avctx, "Parametric Stereo is", 0); skip_bits_long(gb, *num_bits_left); // bs_fill_bits @@ -1008,6 +1011,11 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, num_bits_left -= 2; read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id } + if (num_bits_left < 0) { + av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n"); + } + if (num_bits_left > 0) + skip_bits(gb, num_bits_left); } return get_bits_count(gb) - cnt; @@ -1166,7 +1174,7 @@ static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in, * (14496-3 sp04 p206) */ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, - float *out, float X[2][32][64], + float *out, float X[2][38][64], float mdct_buf[2][64], float *v0, int *v_off, const unsigned int div, float bias, float scale) @@ -1402,7 +1410,7 @@ static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, } /// Generate the subband filtered lowband -static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][32][64], +static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64], const float X_low[32][40][2], const float Y[2][38][64][2], int ch) { @@ -1424,7 +1432,7 @@ static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][32][64], } for (k = 0; k < sbr->kx[1]; k++) { - for (i = i_Temp; i < i_f; i++) { + for (i = i_Temp; i < 38; i++) { X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; } @@ -1740,6 +1748,16 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, /* synthesis */ sbr_x_gen(sbr, sbr->X[ch], sbr->X_low, sbr->data[ch].Y, ch); } + + if (ac->m4ac.ps == 1) { + if (sbr->ps.start) { + ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); + } else { + memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); + } + nch = 2; + } + sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, L, sbr->X[0], sbr->qmf_filter_scratch, sbr->data[0].synthesis_filterbank_samples, &sbr->data[0].synthesis_filterbank_samples_offset, |