]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pnmenc.c
avcodec/dxtory: Fix input size check in dxtory_decode_v1_420()
[ffmpeg] / libavcodec / pnmenc.c
index b3eb5d90d3e483513ea2ea825d0b02d531d75998..ba9478d0da517c1fc7b56b917138e4b8e039c9bd 100644 (file)
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/imgutils.h"
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
 #include "internal.h"
@@ -29,10 +30,10 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     uint8_t *bytestream, *bytestream_start, *bytestream_end;
     int i, h, h1, c, n, linesize, ret;
     uint8_t *ptr, *ptr1, *ptr2;
+    int size = av_image_get_buffer_size(avctx->pix_fmt,
+                                        avctx->width, avctx->height, 1);
 
-    if ((ret = ff_alloc_packet2(avctx, pkt, avpicture_get_size(avctx->pix_fmt,
-                                                       avctx->width,
-                                                       avctx->height) + 200, 0)) < 0)
+    if ((ret = ff_alloc_packet2(avctx, pkt, size + 200, 0)) < 0)
         return ret;
 
     bytestream_start =