diff options
author | clsid2 <clsid2@3b938f2f-1a1a-0410-8054-a526ea5ff92c> | 2011-03-07 03:08:34 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-04-04 00:52:58 +0400 |
commit | 0e09997fa452565e59bfbdf81a96917b3c503470 (patch) | |
tree | 51148224344500d4342cdd2da8ea65952d07688e /libavcodec/ac3dec.c | |
parent | 361fa0ed40a042393a2691e3dba9bd7c4bcfe188 (diff) |
Libavcodec AC3/E-AC3/DTS decoders now output floating point data.
git-svn-id: https://ffdshow-tryout.svn.sourceforge.net/svnroot/ffdshow-tryout@3769 3b938f2f-1a1a-0410-8054-a526ea5ff92c
Diffstat (limited to 'libavcodec/ac3dec.c')
-rw-r--r-- | libavcodec/ac3dec.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 8a0f96a11c..b0e7647877 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -188,8 +188,13 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) ff_fmt_convert_init(&s->fmt_conv, avctx); av_lfg_init(&s->dith_state, 0); + /* ffdshow custom code */ +#if CONFIG_AUDIO_FLOAT + s->mul_bias = 1.0f; +#else /* set scale value for float to int16 conversion */ s->mul_bias = 32767.0f; +#endif /* allow downmixing to stereo or mono */ if (avctx->channels > 0 && avctx->request_channels > 0 && @@ -204,7 +209,12 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) if (!s->input_buffer) return AVERROR(ENOMEM); + /* ffdshow custom code */ +#if CONFIG_AUDIO_FLOAT + avctx->sample_fmt = AV_SAMPLE_FMT_FLT; +#else avctx->sample_fmt = AV_SAMPLE_FMT_S16; +#endif return 0; } @@ -1299,7 +1309,12 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AC3DecodeContext *s = avctx->priv_data; + /* ffdshow custom code */ +#if CONFIG_AUDIO_FLOAT + float *out_samples = (float *)data; +#else int16_t *out_samples = (int16_t *)data; +#endif int blk, ch, err; const uint8_t *channel_map; const float *output[AC3_MAX_CHANNELS]; @@ -1405,10 +1420,15 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n"); err = 1; } + /* ffdshow custom code */ +#if CONFIG_AUDIO_FLOAT + float_interleave_noscale(out_samples, output, 256, s->out_channels); +#else s->fmt_conv.float_to_int16_interleave(out_samples, output, 256, s->out_channels); +#endif out_samples += 256 * s->out_channels; } - *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t); + *data_size = s->num_blocks * 256 * avctx->channels * sizeof (out_samples[0]); /* ffdshow custom code */ return FFMIN(buf_size, s->frame_size); } |