]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpegpicture.c
fftools/ffmpeg: make specifying thread_queue_size turn on threaded input
[ffmpeg] / libavcodec / mpegpicture.c
index c0e06900fe2a79e4c9335bf3cb3423cac68bd938..83426bbda6bba3a4cbbe5ceb3c2b334d8867aeec 100644 (file)
@@ -23,6 +23,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/imgutils.h"
 
 #include "avcodec.h"
 #include "motion_est.h"
@@ -57,6 +58,7 @@ do {\
 int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
                             ScratchpadContext *sc, int linesize)
 {
+#   define EMU_EDGE_HEIGHT (4 * 70)
     int alloc_size = FFALIGN(FFABS(linesize) + 64, 32);
 
     if (avctx->hwaccel)
@@ -67,26 +69,24 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
         return AVERROR_PATCHWELCOME;
     }
 
+    if (av_image_check_size2(alloc_size, EMU_EDGE_HEIGHT, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)
+        return AVERROR(ENOMEM);
+
     // edge emu needs blocksize + filter length - 1
     // (= 17x17 for  halfpel / 21x21 for H.264)
     // VC-1 computes luma and chroma simultaneously and needs 19X19 + 9x9
     // at uvlinesize. It supports only YUV420 so 24x24 is enough
     // linesize * interlaced * MBsize
     // we also use this buffer for encoding in encode_mb_internal() needig an additional 32 lines
-    FF_ALLOCZ_ARRAY_OR_GOTO(avctx, sc->edge_emu_buffer, alloc_size, 4 * 70,
-                      fail);
-
-    FF_ALLOCZ_ARRAY_OR_GOTO(avctx, me->scratchpad, alloc_size, 4 * 16 * 2,
-                      fail)
+    if (!FF_ALLOCZ_TYPED_ARRAY(sc->edge_emu_buffer, alloc_size * EMU_EDGE_HEIGHT) ||
+        !FF_ALLOCZ_TYPED_ARRAY(me->scratchpad,      alloc_size * 4 * 16 * 2))
+        return AVERROR(ENOMEM);
     me->temp            = me->scratchpad;
     sc->rd_scratchpad   = me->scratchpad;
     sc->b_scratchpad    = me->scratchpad;
     sc->obmc_scratchpad = me->scratchpad + 16;
 
     return 0;
-fail:
-    av_freep(&sc->edge_emu_buffer);
-    return AVERROR(ENOMEM);
 }
 
 /**
@@ -206,7 +206,7 @@ static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encodin
 #if FF_API_DEBUG_MV
         avctx->debug_mv ||
 #endif
-        (avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS)) {
+        (avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS)) {
         int mv_size        = 2 * (b8_array_size + 4) * sizeof(int16_t);
         int ref_index_size = 4 * mb_array_size;