changeset 7550:f9e4afa46993 libavcodec

use float_to_int16_interleave in ac3
author lorenm
date Tue, 12 Aug 2008 03:01:17 +0000
parents 60b5c1e5a7ee
children 0a0208d7582f
files ac3dec.c ac3dec.h
diffstat 2 files changed, 9 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ac3dec.c	Tue Aug 12 01:30:24 2008 +0000
+++ b/ac3dec.c	Tue Aug 12 03:01:17 2008 +0000
@@ -201,7 +201,7 @@
     av_init_random(0, &s->dith_state);
 
     /* set bias values for float to int16 conversion */
-    if(s->dsp.float_to_int16 == ff_float_to_int16_c) {
+    if(s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
         s->add_bias = 385.0f;
         s->mul_bias = 1.0f;
     } else {
@@ -604,13 +604,13 @@
             for(i=0; i<128; i++)
                 x[i] = s->transform_coeffs[ch][2*i];
             ff_imdct_half(&s->imdct_256, s->tmp_output, x);
-            s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 0, 128);
+            s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128);
             for(i=0; i<128; i++)
                 x[i] = s->transform_coeffs[ch][2*i+1];
             ff_imdct_half(&s->imdct_256, s->delay[ch-1], x);
         } else {
             ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]);
-            s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 0, 128);
+            s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128);
             memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float));
         }
     }
@@ -1018,14 +1018,6 @@
         do_imdct(s, s->out_channels);
     }
 
-    /* convert float to 16-bit integer */
-    for(ch=0; ch<s->out_channels; ch++) {
-        for(i=0; i<256; i++) {
-            s->output[ch][i] += s->add_bias;
-        }
-        s->dsp.float_to_int16(s->int_output[ch], s->output[ch], 256);
-    }
-
     return 0;
 }
 
@@ -1037,7 +1029,7 @@
 {
     AC3DecodeContext *s = avctx->priv_data;
     int16_t *out_samples = (int16_t *)data;
-    int i, blk, ch, err;
+    int blk, ch, err;
 
     /* initialize the GetBitContext with the start of valid AC-3 Frame */
     if (s->input_buffer) {
@@ -1127,14 +1119,14 @@
 
     /* decode the audio blocks */
     for (blk = 0; blk < s->num_blocks; blk++) {
+        const float *output[s->out_channels];
         if (!err && decode_audio_block(s, blk)) {
             av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
         }
-
-        /* interleave output samples */
-        for (i = 0; i < 256; i++)
-            for (ch = 0; ch < s->out_channels; ch++)
-                *(out_samples++) = s->int_output[ch][i];
+        for (ch = 0; ch < s->out_channels; ch++)
+            output[ch] = s->output[ch];
+        s->dsp.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
+        out_samples += 256 * s->out_channels;
     }
     *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
     return s->frame_size;
--- a/ac3dec.h	Tue Aug 12 01:30:24 2008 +0000
+++ b/ac3dec.h	Tue Aug 12 03:01:17 2008 +0000
@@ -167,7 +167,6 @@
     DECLARE_ALIGNED_16(float, window[AC3_BLOCK_SIZE]);                              ///< window coefficients
     DECLARE_ALIGNED_16(float, tmp_output[AC3_BLOCK_SIZE]);                          ///< temporary storage for output before windowing
     DECLARE_ALIGNED_16(float, output[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]);            ///< output after imdct transform and windowing
-    DECLARE_ALIGNED_16(short, int_output[AC3_MAX_CHANNELS-1][AC3_BLOCK_SIZE]);      ///< final 16-bit integer output
 ///@}
 } AC3DecodeContext;