From 688b09fa597804ab4708271ce467a6ae025f0c17 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 19 Apr 2011 19:03:47 -0400 Subject: [PATCH] If AVCodecContext.channels is 0 and AVCodecContext.channel_layout is non-zero, set channels based on channel_layout. This allows the user to set only channel_layout and not channels. --- libavcodec/utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index e4ea1e5bf..68441881d 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -584,6 +584,8 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) ret = AVERROR(EINVAL); goto free_and_end; } + } else if (avctx->channel_layout) { + avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout); } } -- 2.11.0