summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-02-11 08:13:22 +0100
committerAnton Khirnov <anton@khirnov.net>2013-03-08 07:40:06 +0100
commit2eba9087f3031c6050f8dcd996225490be6c2410 (patch)
treeb4d94a4f2e72ee1f3d5c6083630d1cb9ab3a534a /libavcodec
parent192f1984b1a93aa08af053b8f9ab4950f307bd5d (diff)
lavc: make up a fake frame channel layout when there is no real one.
This should ensure that a valid channel layout is always set on a frame, until a better solution is implemented.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/utils.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 90f25377f6..62fc1b56b1 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -569,8 +569,28 @@ 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) {
+ if (av_get_channel_layout_nb_channels(avctx->channel_layout) !=
+ avctx->channels) {
+ av_log(avctx, AV_LOG_ERROR, "Inconsistent channel "
+ "configuration.\n");
+ return AVERROR(EINVAL);
+ }
+
+ frame->channel_layout = avctx->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 = av_get_default_channel_layout(avctx->channels);
+ if (!frame->channel_layout)
+ frame->channel_layout = (1ULL << avctx->channels) - 1;
+ }
+ }
break;
default: return AVERROR(EINVAL);
}