[FFmpeg-cvslog] atrac3: decode output to float samples instead of converting to s16

Justin Ruggles git at videolan.org
Sun Oct 30 02:04:14 CEST 2011


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Fri Oct 14 16:13:30 2011 -0400| [c4a6fde33feeb0519588f52a64082083c4afdbe6] | committer: Justin Ruggles

atrac3: decode output to float samples instead of converting to s16

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c4a6fde33feeb0519588f52a64082083c4afdbe6
---

 libavcodec/atrac3.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index accaae3..ee70cfe 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -208,7 +208,7 @@ static av_cold void init_atrac3_transforms(ATRAC3Context *q) {
         }
 
     /* Initialize the MDCT transform. */
-    ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0);
+    ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768);
 }
 
 /**
@@ -825,7 +825,7 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
     ATRAC3Context *q = avctx->priv_data;
     int result = 0, i;
     const uint8_t* databuf;
-    int16_t* samples = data;
+    float *samples = data;
 
     if (buf_size < avctx->block_align) {
         av_log(avctx, AV_LOG_ERROR,
@@ -852,16 +852,15 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
     if (q->channels == 1) {
         /* mono */
         for (i = 0; i<1024; i++)
-            samples[i] = av_clip_int16(round(q->outSamples[i]));
-        *data_size = 1024 * sizeof(int16_t);
+            samples[i] = q->outSamples[i];
     } else {
         /* stereo */
         for (i = 0; i < 1024; i++) {
-            samples[i*2] = av_clip_int16(round(q->outSamples[i]));
-            samples[i*2+1] = av_clip_int16(round(q->outSamples[1024+i]));
+            samples[i*2]   = q->outSamples[i];
+            samples[i*2+1] = q->outSamples[1024+i];
         }
-        *data_size = 2048 * sizeof(int16_t);
     }
+    *data_size = 1024 * q->channels * av_get_bytes_per_sample(avctx->sample_fmt);
 
     return avctx->block_align;
 }
@@ -1014,7 +1013,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
         return AVERROR(ENOMEM);
     }
 
-    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+    avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list