diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-03-12 12:41:16 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-03-12 12:49:59 +0100 |
commit | f9fd6f983b979b2da0f9bba3d6b150a302deb1fe (patch) | |
tree | 6e1f91b358394778f798a4d32b22f8317d93a06e /libavcodec | |
parent | a7f9d92a6d54495f812317abe249582c66efb7b6 (diff) | |
parent | 2eba9087f3031c6050f8dcd996225490be6c2410 (diff) | |
download | ffmpeg-f9fd6f983b979b2da0f9bba3d6b150a302deb1fe.tar.gz |
Merge commit '2eba9087f3031c6050f8dcd996225490be6c2410'
* commit '2eba9087f3031c6050f8dcd996225490be6c2410':
lavc: make up a fake frame channel layout when there is no real one.
Conflicts:
libavcodec/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/internal.h | 2 | ||||
-rw-r--r-- | libavcodec/utils.c | 30 |
2 files changed, 27 insertions, 5 deletions
diff --git a/libavcodec/internal.h b/libavcodec/internal.h index eb82d79793..e51757f9d6 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -134,7 +134,7 @@ unsigned int avpriv_toupper4(unsigned int x); /** * does needed setup of pkt_pts/pos and such for (re)get_buffer(); */ -void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame); +int ff_init_buffer_info(AVCodecContext *s, AVFrame *frame); void avpriv_color_frame(AVFrame *frame, const int color[4]); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index a7a15e4dcf..5b53bee3a1 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -597,7 +597,7 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags } } -void ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) +int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) { if (avctx->pkt) { frame->pkt_pts = avctx->pkt->pts; @@ -628,11 +628,32 @@ void ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) 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; + } + } av_frame_set_channels(frame, avctx->channels); break; } + return 0; } #if FF_API_GET_BUFFER @@ -670,7 +691,8 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) return AVERROR(EINVAL); } } - ff_init_buffer_info(avctx, frame); + if ((ret = ff_init_buffer_info(avctx, frame)) < 0) + return ret; #if FF_API_GET_BUFFER /* |