diff options
author | Michael Niedermayer <[email protected]> | 2016-12-08 23:51:45 +0100 |
---|---|---|
committer | Michael Niedermayer <[email protected]> | 2017-02-08 21:17:50 +0100 |
commit | 774461ea629a18258ba45a707dbdc35b17d9b298 (patch) | |
tree | 209111b62c734cb0f37392f1cf039795e6809a36 | |
parent | 94a0a484b703b78d5c4d780b884a1541a30410d8 (diff) |
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: Michael Niedermayer <[email protected]>
(cherry picked from commit 38a7834bbb24ef62466b076715e0add60e1d6962)
Signed-off-by: Michael Niedermayer <[email protected]>
-rw-r--r-- | libavcodec/ffv1enc.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 9d02be72ce..3b425d68ed 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1247,6 +1247,11 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (f->version > 3) 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) return ret; |