Commit 38a7834b authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/ffv1enc: Allocate smaller packet if the worst case size cannot be allocated

We are checking during encoding if there is enough space as version 4 needs that
check.

Fixes Ticket6005
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent cff1c0ed
...@@ -1151,6 +1151,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, ...@@ -1151,6 +1151,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (f->version > 3) if (f->version > 3)
maxsize = AV_INPUT_BUFFER_MIN_SIZE + avctx->width*avctx->height*3LL*4; maxsize = AV_INPUT_BUFFER_MIN_SIZE + avctx->width*avctx->height*3LL*4;
if (maxsize > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 32) {
av_log(avctx, AV_LOG_WARNING, "Cannot allocate worst case packet size, the encoding could fail\n");
maxsize = INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 32;
}
if ((ret = ff_alloc_packet2(avctx, pkt, maxsize, 0)) < 0) if ((ret = ff_alloc_packet2(avctx, pkt, maxsize, 0)) < 0)
return ret; return ret;
......
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