ffmpeg | branch: master | Hendrik Leppkes <h.lepp...@gmail.com> | Mon Nov 14 12:16:32 2016 +0100| [bbd0ebfd835761d1abbe030a8a7866d88b2a8777] | committer: Hendrik Leppkes
Merge commit 'd8f3b0fb584677d4882e3a2d7c28f8b15c7319f5' * commit 'd8f3b0fb584677d4882e3a2d7c28f8b15c7319f5': targaenc: Move size check to initialization function Merged-by: Hendrik Leppkes <h.lepp...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bbd0ebfd835761d1abbe030a8a7866d88b2a8777 --- libavcodec/targaenc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c index 66bc55c..79030a0 100644 --- a/libavcodec/targaenc.c +++ b/libavcodec/targaenc.c @@ -89,10 +89,6 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int bpp, picsize, datasize = -1, ret, i; uint8_t *out; - if(avctx->width > 0xffff || avctx->height > 0xffff) { - av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n"); - return AVERROR(EINVAL); - } picsize = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1); if ((ret = ff_alloc_packet2(avctx, pkt, picsize + 45, 0)) < 0) @@ -190,6 +186,11 @@ FF_ENABLE_DEPRECATION_WARNINGS static av_cold int targa_encode_init(AVCodecContext *avctx) { + if (avctx->width > 0xffff || avctx->height > 0xffff) { + av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n"); + return AVERROR(EINVAL); + } + #if FF_API_CODED_FRAME FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->key_frame = 1; ====================================================================== diff --cc libavcodec/targaenc.c index 66bc55c,f0cee38..79030a0 --- a/libavcodec/targaenc.c +++ b/libavcodec/targaenc.c @@@ -86,17 -86,15 +86,13 @@@ static int targa_encode_frame(AVCodecCo const AVFrame *p, int *got_packet) { TargaContext *s = avctx->priv_data; - int bpp, picsize, datasize = -1, ret; + int bpp, picsize, datasize = -1, ret, i; uint8_t *out; - if(avctx->width > 0xffff || avctx->height > 0xffff) { - av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n"); - return AVERROR(EINVAL); - } picsize = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1); - if ((ret = ff_alloc_packet(pkt, picsize + 45)) < 0) { - av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n"); + if ((ret = ff_alloc_packet2(avctx, pkt, picsize + 45, 0)) < 0) return ret; - } /* zero out the header and only set applicable fields */ memset(pkt->data, 0, 12); _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog