diff options
author | Andreas Öman <andreas@lonelycoder.com> | 2007-12-15 07:00:19 +0000 |
---|---|---|
committer | Andreas Öman <andreas@lonelycoder.com> | 2007-12-15 07:00:19 +0000 |
commit | 6708eefe558eb8c307c5bca00083bf4c406dd600 (patch) | |
tree | 4d83c8c6c70ea577bc54e7e590fdd746559e52b1 | |
parent | 626464fb53672cd88049f29b7738388360cbd370 (diff) | |
download | ffmpeg-6708eefe558eb8c307c5bca00083bf4c406dd600.tar.gz |
Make AC3 decoder honor avctx->request_channels
Originally committed as revision 11220 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/ac3dec.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 4750f0fd46..33f87ab7ff 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1128,23 +1128,12 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, /* channel config */ ctx->out_channels = ctx->channels; - if (avctx->channels == 0) { - avctx->channels = ctx->out_channels; - } else if(ctx->out_channels < avctx->channels) { - av_log(avctx, AV_LOG_ERROR, "Cannot upmix AC3 from %d to %d channels.\n", - ctx->out_channels, avctx->channels); - return -1; - } - if(avctx->channels == 2) { - ctx->output_mode = AC3_CHMODE_STEREO; - } else if(avctx->channels == 1) { - ctx->output_mode = AC3_CHMODE_MONO; - } else if(avctx->channels != ctx->out_channels) { - av_log(avctx, AV_LOG_ERROR, "Cannot downmix AC3 from %d to %d channels.\n", - ctx->out_channels, avctx->channels); - return -1; + if (avctx->request_channels > 0 && avctx->request_channels <= 2 && + avctx->request_channels < ctx->channels) { + ctx->out_channels = avctx->request_channels; + ctx->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; } - ctx->out_channels = avctx->channels; + avctx->channels = ctx->out_channels; /* parse the audio blocks */ for (blk = 0; blk < NB_BLOCKS; blk++) { |