comparison ac3dec.c @ 6021:90b36c43c4ef libavcodec

Make AC3 decoder honor avctx->request_channels
author andoma
date Sat, 15 Dec 2007 07:00:19 +0000
parents ed7a232d570a
children a165936f0d9e
comparison
equal deleted inserted replaced
6020:c531defb03ee 6021:90b36c43c4ef
1126 return -1; 1126 return -1;
1127 } 1127 }
1128 1128
1129 /* channel config */ 1129 /* channel config */
1130 ctx->out_channels = ctx->channels; 1130 ctx->out_channels = ctx->channels;
1131 if (avctx->channels == 0) { 1131 if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
1132 avctx->channels = ctx->out_channels; 1132 avctx->request_channels < ctx->channels) {
1133 } else if(ctx->out_channels < avctx->channels) { 1133 ctx->out_channels = avctx->request_channels;
1134 av_log(avctx, AV_LOG_ERROR, "Cannot upmix AC3 from %d to %d channels.\n", 1134 ctx->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
1135 ctx->out_channels, avctx->channels); 1135 }
1136 return -1; 1136 avctx->channels = ctx->out_channels;
1137 }
1138 if(avctx->channels == 2) {
1139 ctx->output_mode = AC3_CHMODE_STEREO;
1140 } else if(avctx->channels == 1) {
1141 ctx->output_mode = AC3_CHMODE_MONO;
1142 } else if(avctx->channels != ctx->out_channels) {
1143 av_log(avctx, AV_LOG_ERROR, "Cannot downmix AC3 from %d to %d channels.\n",
1144 ctx->out_channels, avctx->channels);
1145 return -1;
1146 }
1147 ctx->out_channels = avctx->channels;
1148 1137
1149 /* parse the audio blocks */ 1138 /* parse the audio blocks */
1150 for (blk = 0; blk < NB_BLOCKS; blk++) { 1139 for (blk = 0; blk < NB_BLOCKS; blk++) {
1151 if (ac3_parse_audio_block(ctx, blk)) { 1140 if (ac3_parse_audio_block(ctx, blk)) {
1152 av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n"); 1141 av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n");