On 03/04/2013 05:35 AM, Anton Khirnov wrote:
> This should ensure that a valid channel layout is always set on a frame,
> until a better solution is implemented.
> ---
> libavcodec/utils.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 7e6974f..4d2c2f2 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -558,8 +558,18 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame,
> int flags)
> frame->sample_rate = avctx->sample_rate;
> if (frame->format < 0)
> frame->format = avctx->sample_fmt;
> - if (!frame->channel_layout)
> - frame->channel_layout = avctx->channel_layout;
> + if (!frame->channel_layout) {
> + if (avctx->channel_layout)
> + frame->channel_layout = avctx->channel_layout;
Here is where we could check for mismatching channel count and channel
layout.
> + else {
> + if (avctx->channels > FF_SANE_NB_CHANNELS) {
> + av_log(avctx, AV_LOG_ERROR, "Too many channels: %d.\n",
> + avctx->channels);
> + return AVERROR(ENOSYS);
> + }
> + frame->channel_layout = (1ULL << avctx->channels) - 1;
> + }
> + }
> break;
> default: return AVERROR(EINVAL);
> }
It might be better to use av_get_default_channel_layout() first and then
if it's still 0 use (1<<channels)-1.
Thanks,
Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel