diff options
author | Vitor Sessak <vitor1001@gmail.com> | 2011-05-19 21:33:27 +0200 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-05-19 20:32:18 -0400 |
commit | 984ece7503597d30e6f3bdeb67e337ea1616f880 (patch) | |
tree | 2e10c424c58442b6dcfd707503c58edace0203c5 | |
parent | 4e987f8282ff7658a6f804b9db39954bb59fa72e (diff) | |
download | ffmpeg-984ece7503597d30e6f3bdeb67e337ea1616f880.tar.gz |
qdm2: Use floating point synthesis filter.
This avoid needlessly convertion from floating point to fixed point and back.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
-rw-r--r-- | libavcodec/qdm2.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index f74cfd9258..53ee304a28 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -172,9 +172,9 @@ typedef struct { /// Synthesis filter MPADSPContext mpadsp; - DECLARE_ALIGNED(16, MPA_INT, synth_buf)[MPA_MAX_CHANNELS][512*2]; + DECLARE_ALIGNED(32, float, synth_buf)[MPA_MAX_CHANNELS][512*2]; int synth_buf_offset[MPA_MAX_CHANNELS]; - DECLARE_ALIGNED(16, int32_t, sb_samples)[MPA_MAX_CHANNELS][128][SBLIMIT]; + DECLARE_ALIGNED(32, float, sb_samples)[MPA_MAX_CHANNELS][128][SBLIMIT]; /// Mixed temporary data used in decoding float tone_level[MPA_MAX_CHANNELS][30][64]; @@ -331,11 +331,6 @@ static av_cold void qdm2_init_vlc(void) } } - -/* for floating point to fixed point conversion */ -static const float f2i_scale = (float) (1 << (FRAC_BITS - 15)); - - static int qdm2_get_vlc (GetBitContext *gb, VLC *vlc, int flag, int depth) { int value; @@ -484,8 +479,8 @@ static void build_sb_samples_from_noise (QDM2Context *q, int sb) for (ch = 0; ch < q->nb_channels; ch++) for (j = 0; j < 64; j++) { - q->sb_samples[ch][j * 2][sb] = (int32_t)(f2i_scale * SB_DITHERING_NOISE(sb,q->noise_idx) * q->tone_level[ch][sb][j] + .5); - q->sb_samples[ch][j * 2 + 1][sb] = (int32_t)(f2i_scale * SB_DITHERING_NOISE(sb,q->noise_idx) * q->tone_level[ch][sb][j] + .5); + q->sb_samples[ch][j * 2][sb] = SB_DITHERING_NOISE(sb,q->noise_idx) * q->tone_level[ch][sb][j]; + q->sb_samples[ch][j * 2 + 1][sb] = SB_DITHERING_NOISE(sb,q->noise_idx) * q->tone_level[ch][sb][j]; } } @@ -925,11 +920,11 @@ static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int l for (chs = 0; chs < q->nb_channels; chs++) for (k = 0; k < run; k++) if ((j + k) < 128) - q->sb_samples[chs][j + k][sb] = (int32_t)(f2i_scale * q->tone_level[chs][sb][((j + k)/2)] * tmp[k][chs] + .5); + q->sb_samples[chs][j + k][sb] = q->tone_level[chs][sb][((j + k)/2)] * tmp[k][chs]; } else { for (k = 0; k < run; k++) if ((j + k) < 128) - q->sb_samples[ch][j + k][sb] = (int32_t)(f2i_scale * q->tone_level[ch][sb][(j + k)/2] * samples[k] + .5); + q->sb_samples[ch][j + k][sb] = q->tone_level[ch][sb][(j + k)/2] * samples[k]; } j += run; @@ -1603,7 +1598,7 @@ static void qdm2_calculate_fft (QDM2Context *q, int channel, int sub_packet) */ static void qdm2_synthesis_filter (QDM2Context *q, int index) { - OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE]; + float samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE]; int i, k, ch, sb_used, sub_sampling, dither_state = 0; /* copy sb_samples */ @@ -1615,12 +1610,12 @@ static void qdm2_synthesis_filter (QDM2Context *q, int index) q->sb_samples[ch][(8 * index) + i][k] = 0; for (ch = 0; ch < q->nb_channels; ch++) { - OUT_INT *samples_ptr = samples + ch; + float *samples_ptr = samples + ch; for (i = 0; i < 8; i++) { - ff_mpa_synth_filter_fixed(&q->mpadsp, + ff_mpa_synth_filter_float(&q->mpadsp, q->synth_buf[ch], &(q->synth_buf_offset[ch]), - ff_mpa_synth_window_fixed, &dither_state, + ff_mpa_synth_window_float, &dither_state, samples_ptr, q->nb_channels, q->sb_samples[ch][(8 * index) + i]); samples_ptr += 32 * q->nb_channels; @@ -1632,7 +1627,7 @@ static void qdm2_synthesis_filter (QDM2Context *q, int index) for (ch = 0; ch < q->channels; ch++) for (i = 0; i < q->frame_size; i++) - q->output_buffer[q->channels * i + ch] += (float)(samples[q->nb_channels * sub_sampling * i + ch] >> (sizeof(OUT_INT)*8-16)); + q->output_buffer[q->channels * i + ch] += (1 << 23) * samples[q->nb_channels * sub_sampling * i + ch]; } @@ -1649,7 +1644,7 @@ static av_cold void qdm2_init(QDM2Context *q) { initialized = 1; qdm2_init_vlc(); - ff_mpa_synth_init_fixed(ff_mpa_synth_window_fixed); + ff_mpa_synth_init_float(ff_mpa_synth_window_float); softclip_table_init(); rnd_table_init(); init_noise_samples(); |