summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-04-04 10:47:45 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-04-08 18:45:58 -0400
commit1337de0c4bea8bbf8e142e8401edd0b25dd059b5 (patch)
treef2963e4c2b775c20baeaec37d960b2e018dbf284 /libavcodec/utils.c
parentb2db35995f056720cc4e932d507ea09c0106bce9 (diff)
avcodec: validate the channel layout vs. channel count for decoders
Set avctx->channel_layout to 0 if the channel count does not match avctx->channels.
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index aa0f5b6d86..4037bfd327 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -810,6 +810,15 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
goto free_and_end;
}
}
+
+ if (av_codec_is_decoder(avctx->codec)) {
+ /* validate channel layout from the decoder */
+ if (avctx->channel_layout &&
+ av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) {
+ av_log(avctx, AV_LOG_WARNING, "channel layout does not match number of channels\n");
+ avctx->channel_layout = 0;
+ }
+ }
end:
entangled_thread_counter--;