[FFmpeg-devel] [PATCH] DCA floating point output

FB2000 flybird2k
Mon Apr 26 03:32:30 CEST 2010


OK. Corrected.

Index: libavcodec/dca.c
===================================================================
--- libavcodec/dca.c    (revision 22960)
+++ libavcodec/dca.c    (working copy)
@@ -1203,8 +1203,8 @@
     const uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;

-    int i;
-    int16_t *samples = data;
+    int i, j, k;
+    float *samples = data;
     DCAContext *s = avctx->priv_data;
     int channels;

@@ -1259,13 +1259,16 @@
     if (!avctx->channels)
         avctx->channels = channels;

-    if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) *
channels)
+    if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(float) *
channels)
         return -1;
-    *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels;
+    *data_size = 256 / 8 * s->sample_blocks * sizeof(float) * channels;
     for (i = 0; i < (s->sample_blocks / 8); i++) {
         dca_decode_block(s);
-        s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256,
channels);
-        samples += 256 * channels;
+        for (j = 0; j < 256; j++) {
+            for (k = 0; k < channels; k++)
+                samples[k] = s->samples[j + k * 256] / 32768.0f;
+            samples += channels;
+        }
     }

     return buf_size;
@@ -1294,12 +1297,8 @@

     for(i = 0; i < 6; i++)
         s->samples_chanptr[i] = s->samples + i * 256;
-    avctx->sample_fmt = SAMPLE_FMT_S16;
+    avctx->sample_fmt = SAMPLE_FMT_FLT;

-    if(s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c)
{
-        s->add_bias = 385.0f;
-        s->scale_bias = 1.0 / 32768.0;
-    } else {
         s->add_bias = 0.0f;
         s->scale_bias = 1.0;

@@ -1308,7 +1307,6 @@
                 avctx->request_channels == 2) {
             avctx->channels = avctx->request_channels;
         }
-    }


     return 0;


On Mon, Apr 26, 2010 at 7:12 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:

>
> Please remove the cosmetic changes from your patch (do not re-indent the
> unchanged lines).
>
> And please fix your line length, Carl Eugen
>
>



More information about the ffmpeg-devel mailing list