OSDN Git Service

If AVCodecContext.channels is 0 and AVCodecContext.channel_layout is
authorJustin Ruggles <justin.ruggles@gmail.com>
Tue, 19 Apr 2011 23:03:47 +0000 (19:03 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Wed, 27 Apr 2011 16:57:43 +0000 (12:57 -0400)
non-zero, set channels based on channel_layout.

This allows the user to set only channel_layout and not channels.

libavcodec/utils.c

index e4ea1e5..6844188 100644 (file)
@@ -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);
         }
     }