Commit c22953b8 authored by Anton Khirnov's avatar Anton Khirnov

lavc: check that extended_data is properly set in avcodec_encode_audio2().

parent a5117a24
...@@ -908,6 +908,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, ...@@ -908,6 +908,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
const AVFrame *frame, const AVFrame *frame,
int *got_packet_ptr) int *got_packet_ptr)
{ {
AVFrame tmp;
AVFrame *padded_frame = NULL; AVFrame *padded_frame = NULL;
int ret; int ret;
int user_packet = !!avpkt->data; int user_packet = !!avpkt->data;
...@@ -920,6 +921,22 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, ...@@ -920,6 +921,22 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
return 0; 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 */ /* check for valid frame size */
if (frame) { if (frame) {
if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) { if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment