lavc: set channel count from channel layout in avcodec_open2().

Some decoders (e.g. nellymoser) only set channel_layout and do not set
channel count.
This commit is contained in:
Anton Khirnov 2012-09-28 20:46:20 +02:00
parent 7d1d446990
commit 12e1e83461
1 changed files with 9 additions and 4 deletions

View File

@ -856,10 +856,15 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if (av_codec_is_decoder(avctx->codec)) { if (av_codec_is_decoder(avctx->codec)) {
/* validate channel layout from the decoder */ /* validate channel layout from the decoder */
if (avctx->channel_layout && if (avctx->channel_layout) {
av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) { int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
av_log(avctx, AV_LOG_WARNING, "channel layout does not match number of channels\n"); if (!avctx->channels)
avctx->channel_layout = 0; avctx->channels = channels;
else if (channels != avctx->channels) {
av_log(avctx, AV_LOG_WARNING,
"channel layout does not match number of channels\n");
avctx->channel_layout = 0;
}
} }
} }
end: end: