Mercurial > libavcodec.hg
changeset 6021:90b36c43c4ef libavcodec
Make AC3 decoder honor avctx->request_channels
author | andoma |
---|---|
date | Sat, 15 Dec 2007 07:00:19 +0000 |
parents | c531defb03ee |
children | 6dd429a5d0be |
files | ac3dec.c |
diffstat | 1 files changed, 5 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/ac3dec.c Sat Dec 15 06:06:16 2007 +0000 +++ b/ac3dec.c Sat Dec 15 07:00:19 2007 +0000 @@ -1128,23 +1128,12 @@ /* 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->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; } - 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; - } - ctx->out_channels = avctx->channels; + avctx->channels = ctx->out_channels; /* parse the audio blocks */ for (blk = 0; blk < NB_BLOCKS; blk++) {