diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-05-07 16:56:20 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-05-09 17:47:11 +0200 |
commit | c22953b8a3abc1ddd02e2f468845dc2bf0e45253 (patch) | |
tree | e4e302b8e5ba78cebefcf4aae8e63089edee2d55 /libavcodec | |
parent | a5117a2444f3e636ff824ea467bc828d482c68fc (diff) | |
download | ffmpeg-c22953b8a3abc1ddd02e2f468845dc2bf0e45253.tar.gz |
lavc: check that extended_data is properly set in avcodec_encode_audio2().
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/utils.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 9631c99899..9ec4a9e848 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -908,6 +908,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, const AVFrame *frame, int *got_packet_ptr) { + AVFrame tmp; AVFrame *padded_frame = NULL; int ret; int user_packet = !!avpkt->data; @@ -920,6 +921,22 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, return 0; } + /* ensure that extended_data is properly set */ + if (frame && !frame->extended_data) { + if (av_sample_fmt_is_planar(avctx->sample_fmt) && + avctx->channels > AV_NUM_DATA_POINTERS) { + av_log(avctx, AV_LOG_ERROR, "Encoding to a planar sample format, " + "with more than %d channels, but extended_data is not set.\n", + AV_NUM_DATA_POINTERS); + return AVERROR(EINVAL); + } + av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n"); + + tmp = *frame; + tmp.extended_data = tmp.data; + frame = &tmp; + } + /* check for valid frame size */ if (frame) { if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) { |