diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-01-27 15:20:43 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-01-28 03:15:35 +0100 |
commit | 733dbe7d18c267728ef03762d83e9e1b086668cd (patch) | |
tree | 41345c1989e46631e4209c3b09206b0fd45bc54a /libavcodec/aacdec.c | |
parent | 2f7d8977bcdeb2c39fd9acbd753d605298824db8 (diff) | |
download | ffmpeg-733dbe7d18c267728ef03762d83e9e1b086668cd.tar.gz |
Remove the add bias hack for the C version of DSPContext.float_to_int16_*().
(cherry picked from commit 9d06d7bce3babb82ed650c13ed13a57f6f626a71)
Diffstat (limited to 'libavcodec/aacdec.c')
-rw-r--r-- | libavcodec/aacdec.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index fd65b1c3ba..fddec17fcc 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -566,18 +566,10 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->random_state = 0x1f2e3d4c; // -1024 - Compensate wrong IMDCT method. - // 32768 - Required to scale values to the correct range for the bias method - // for float to int16 conversion. - - if (ac->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) { - ac->add_bias = 385.0f; - ac->sf_scale = 1. / (-1024. * 32768.); - ac->sf_offset = 0; - } else { - ac->add_bias = 0.0f; + // 60 - Required to scale values to the correct range [-32768,32767] + // for float to int16 conversion. (1 << (60 / 4)) == 32768 ac->sf_scale = 1. / -1024.; ac->sf_offset = 60; - } ff_aac_tableinit(); @@ -1701,7 +1693,7 @@ static void apply_tns(float coef[1024], TemporalNoiseShaping *tns, /** * Conduct IMDCT and windowing. */ -static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float bias) +static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) { IndividualChannelStream *ics = &sce->ics; float *in = sce->coeffs; @@ -1729,29 +1721,29 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float */ if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { - ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, bias, 512); + ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, 0, 512); } else { for (i = 0; i < 448; i++) - out[i] = saved[i] + bias; + out[i] = saved[i]; if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, bias, 64); - ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, bias, 64); - ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, bias, 64); - ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, bias, 64); - ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, bias, 64); + ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 0, 64); + ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 0, 64); + ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 0, 64); + ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 0, 64); + ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 0, 64); memcpy( out + 448 + 4*128, temp, 64 * sizeof(float)); } else { - ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, bias, 64); + ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 0, 64); for (i = 576; i < 1024; i++) - out[i] = buf[i-512] + bias; + out[i] = buf[i-512]; } } // buffer update if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { for (i = 0; i < 64; i++) - saved[i] = temp[64 + i] - bias; + saved[i] = temp[64 + i]; ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 0, 64); ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 0, 64); ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 0, 64); @@ -1811,13 +1803,12 @@ static void apply_independent_coupling(AACContext *ac, { int i; const float gain = cce->coup.gain[index][0]; - const float bias = ac->add_bias; const float *src = cce->ch[0].ret; float *dest = target->ret; const int len = 1024 << (ac->m4ac.sbr == 1); for (i = 0; i < len; i++) - dest[i] += gain * (src[i] - bias); + dest[i] += gain * src[i]; } /** @@ -1861,7 +1852,6 @@ static void apply_channel_coupling(AACContext *ac, ChannelElement *cc, static void spectral_to_sample(AACContext *ac) { int i, type; - float imdct_bias = (ac->m4ac.sbr <= 0) ? ac->add_bias : 0.0f; for (type = 3; type >= 0; type--) { for (i = 0; i < MAX_ELEM_ID; i++) { ChannelElement *che = ac->che[type][i]; @@ -1875,9 +1865,9 @@ static void spectral_to_sample(AACContext *ac) if (type <= TYPE_CPE) apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling); if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) { - imdct_and_windowing(ac, &che->ch[0], imdct_bias); + imdct_and_windowing(ac, &che->ch[0]); if (type == TYPE_CPE) { - imdct_and_windowing(ac, &che->ch[1], imdct_bias); + imdct_and_windowing(ac, &che->ch[1]); } if (ac->m4ac.sbr > 0) { ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret); |