[FFmpeg-devel] [PATCH 06/12] WMA: use float_to_int16_interleave

Mans Rullgard mans
Sun Sep 27 12:49:22 CEST 2009


Scale/bias for C conversion needs to be done better.
---
 libavcodec/wma.h    |    1 +
 libavcodec/wmadec.c |   26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index 6db60fa..24285bf 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -120,6 +120,7 @@ typedef struct WMACodecContext {
     float *windows[BLOCK_NB_SIZES];
     /* output buffer for one frame and the last for IMDCT windowing */
     DECLARE_ALIGNED_16(float, frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]);
+    const float *frame_out_ptr[MAX_CHANNELS];
     /* last frame info */
     uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */
     int last_bitoffset;
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 9367e97..e5f0508 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -123,6 +123,9 @@ static int wma_decode_init(AVCodecContext * avctx)
         wma_lsp_to_curve_init(s, s->frame_len);
     }
 
+    for (i = 0; i < MAX_CHANNELS; i++)
+        s->frame_out_ptr[i] = s->frame_out[i];
+
     avctx->sample_fmt = SAMPLE_FMT_S16;
     return 0;
 }
@@ -660,8 +663,7 @@ next:
 /* decode a frame of frame_len samples */
 static int wma_decode_frame(WMACodecContext *s, int16_t *samples)
 {
-    int ret, i, n, ch, incr;
-    int16_t *ptr;
+    int ret, i, ch;
     float *iptr;
 
 #ifdef TRACE
@@ -679,18 +681,16 @@ static int wma_decode_frame(WMACodecContext *s, int16_t *samples)
             break;
     }
 
-    /* convert frame to integer */
-    n = s->frame_len;
-    incr = s->nb_channels;
-    for(ch = 0; ch < s->nb_channels; ch++) {
-        ptr = samples + ch;
-        iptr = s->frame_out[ch];
+    if (s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c)
+        for (ch = 0; ch < s->nb_channels; ch++)
+            for (i = 0, iptr = s->frame_out[ch]; i < s->frame_len; i++, iptr++)
+                *iptr = *iptr / 32768.0f + 385.0f;
 
-        for(i=0;i<n;i++) {
-            *ptr = av_clip_int16(lrintf(*iptr++));
-            ptr += incr;
-        }
-        /* prepare for next block */
+    s->dsp.float_to_int16_interleave(samples, s->frame_out_ptr, s->frame_len,
+                                     s->nb_channels);
+
+    /* prepare for next block */
+    for(ch = 0; ch < s->nb_channels; ch++) {
         memmove(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len],
                 s->frame_len * sizeof(float));
     }
-- 
1.6.4.4




More information about the ffmpeg-devel mailing list