[FFmpeg-devel] [PATCH] DCA floating point output
FB2000
flybird2k
Mon Apr 26 10:44:07 CEST 2010
On Mon, Apr 26, 2010 at 3:55 PM, Kostya <kostya.shishkov at gmail.com> wrote:
>
> DCA maintainer 0 hint: s->scale_bias = 1.0 / 32768.0 may do the trick
>
>
Indeed, I just verified and found it it did the trick. Thanks Kostya!
I've revised the patch and send it in the attachment. No floating-point
conversion is required for output this time.
-------------- next part --------------
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];
+ samples += channels;
+ }
}
return buf_size;
@@ -1294,21 +1297,16 @@
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;
+ s->scale_bias = 1.0 / 32768.0f;
/* allow downmixing to stereo */
if (avctx->channels > 0 && avctx->request_channels < avctx->channels &&
avctx->request_channels == 2) {
avctx->channels = avctx->request_channels;
}
- }
return 0;
More information about the ffmpeg-devel
mailing list