diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-04-23 05:30:19 +0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-05-19 01:27:06 +0400 |
commit | 9aa8193a234ccb6a79cba5cc550531f62ffb0a17 (patch) | |
tree | 699dce38e0c73e2daf1aa8afb2d31e42da860515 /libavcodec/aacsbr.c | |
parent | bc778a0cea3027941afa1ff6bbb424b3159a0b27 (diff) |
Add floating-point sample format support to the ac3, eac3, dca, aac, and vorbis
decoders.
Based on patches by clsid2 in ffdshow-tryout.
Diffstat (limited to 'libavcodec/aacsbr.c')
-rw-r--r-- | libavcodec/aacsbr.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 7a217abfda..81b0b4c001 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -126,14 +126,19 @@ av_cold void ff_aac_sbr_init(void) ff_ps_init(); } -av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) +av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr) { + float mdct_scale; sbr->kx[0] = sbr->kx[1] = 32; //Typo in spec, kx' inits to 32 sbr->data[0].e_a[1] = sbr->data[1].e_a[1] = -1; sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); 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); + /* SBR requires samples to be scaled to +/-32768.0 to work correctly. + * mdct scale factors are adjusted to scale up from +/-1.0 at analysis + * and scale back down at synthesis. */ + mdct_scale = ac->avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? 32768.0f : 1.0f; + ff_mdct_init(&sbr->mdct, 7, 1, 1.0 / (64 * mdct_scale)); + ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0 * mdct_scale); ff_ps_ctx_init(&sbr->ps); } |