From 6ce9b4310cf1eba1a356191f30460a97e6653b91 Mon Sep 17 00:00:00 2001
From: Stefano Sabatini <stefano.sabatini-lala@poste.it>
Date: Fri, 6 Aug 2010 09:37:04 +0000
Subject: [PATCH] Remove use of the deprecated function
 avcodec_check_dimensions(), use av_check_image_size() instead.

Originally committed as revision 24711 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavcodec/bink.c               | 3 ++-
 libavcodec/dirac.c              | 3 ++-
 libavcodec/dnxhddec.c           | 3 ++-
 libavcodec/dpx.c                | 3 ++-
 libavcodec/eacmv.c              | 3 ++-
 libavcodec/eamad.c              | 3 ++-
 libavcodec/eatgv.c              | 3 ++-
 libavcodec/flvdec.c             | 3 ++-
 libavcodec/gifdec.c             | 3 ++-
 libavcodec/h264_ps.c            | 3 ++-
 libavcodec/iff.c                | 3 ++-
 libavcodec/imgconvert.c         | 4 ++--
 libavcodec/indeo3.c             | 3 ++-
 libavcodec/kgv1dec.c            | 3 ++-
 libavcodec/libdiracdec.c        | 4 ++--
 libavcodec/libopenjpeg.c        | 2 +-
 libavcodec/libschroedingerdec.c | 4 ++--
 libavcodec/libvpxdec.c          | 2 +-
 libavcodec/mjpegdec.c           | 3 ++-
 libavcodec/mpegvideo.c          | 3 ++-
 libavcodec/nuv.c                | 3 ++-
 libavcodec/pcx.c                | 3 ++-
 libavcodec/pictordec.c          | 3 ++-
 libavcodec/pngdec.c             | 3 ++-
 libavcodec/pnm.c                | 5 +++--
 libavcodec/ptx.c                | 3 ++-
 libavcodec/qtrleenc.c           | 3 ++-
 libavcodec/rv10.c               | 3 ++-
 libavcodec/rv40.c               | 4 +++-
 libavcodec/sgidec.c             | 3 ++-
 libavcodec/sunrast.c            | 3 ++-
 libavcodec/targa.c              | 3 ++-
 libavcodec/tiff.c               | 5 +++--
 libavcodec/txd.c                | 3 ++-
 libavcodec/utils.c              | 8 ++++----
 libavcodec/vp3.c                | 3 ++-
 libavcodec/vp8.c                | 3 ++-
 libavcodec/vqavideo.c           | 3 ++-
 libavcodec/xsubdec.c            | 3 ++-
 libavcodec/yop.c                | 3 ++-
 libavdevice/Makefile            | 2 +-
 libavdevice/avdevice.h          | 2 +-
 libavdevice/v4l.c               | 3 ++-
 libavdevice/v4l2.c              | 3 ++-
 libavfilter/avfilter.h          | 2 +-
 libavfilter/vf_pad.c            | 3 ++-
 46 files changed, 92 insertions(+), 54 deletions(-)

diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index 0a0b5bc9155..806733fc111 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "binkdata.h"
@@ -971,7 +972,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     c->pic.data[0] = NULL;
 
-    if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
+    if (av_check_image_size(avctx->width, avctx->height, 0, avctx) < 0) {
         return 1;
     }
 
diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c
index c65a51f9643..3eddc6708f0 100644
--- a/libavcodec/dirac.c
+++ b/libavcodec/dirac.c
@@ -25,6 +25,7 @@
  * @author Marco Gerards <marco@gnu.org>
  */
 
+#include "libavcore/imgutils.h"
 #include "dirac.h"
 #include "avcodec.h"
 #include "golomb.h"
@@ -268,7 +269,7 @@ int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,
     if (parse_source_parameters(avctx, gb, source))
         return -1;
 
-    if (avcodec_check_dimensions(avctx, source->width, source->height))
+    if (av_check_image_size(source->width, source->height, 0, avctx))
         return -1;
 
     avcodec_set_dimensions(avctx, source->width, source->height);
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 8b7c343d09c..7438773be04 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -22,6 +22,7 @@
 //#define TRACE
 //#define DEBUG
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "dnxhddata.h"
@@ -305,7 +306,7 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     }
 
     avctx->pix_fmt = PIX_FMT_YUV422P;
-    if (avcodec_check_dimensions(avctx, ctx->width, ctx->height))
+    if (av_check_image_size(ctx->width, ctx->height, 0, avctx))
         return -1;
     avcodec_set_dimensions(avctx, ctx->width, ctx->height);
 
diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index 94a91816c5f..a976ba40248 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 #include "bytestream.h"
 #include "avcodec.h"
 
@@ -139,7 +140,7 @@ static int decode_frame(AVCodecContext *avctx,
 
     if (s->picture.data[0])
         avctx->release_buffer(avctx, &s->picture);
-    if (avcodec_check_dimensions(avctx, w, h))
+    if (av_check_image_size(w, h, 0, avctx))
         return -1;
     if (w != avctx->width || h != avctx->height)
         avcodec_set_dimensions(avctx, w, h);
diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c
index 517b3072710..2933136103a 100644
--- a/libavcodec/eacmv.c
+++ b/libavcodec/eacmv.c
@@ -29,6 +29,7 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 
 typedef struct CmvContext {
@@ -156,7 +157,7 @@ static int cmv_decode_frame(AVCodecContext *avctx,
         return buf_size;
     }
 
-    if (avcodec_check_dimensions(s->avctx, s->width, s->height))
+    if (av_check_image_size(s->width, s->height, 0, s->avctx))
         return -1;
 
     /* shuffle */
diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
index 3077c0883d0..f12b3e60721 100644
--- a/libavcodec/eamad.c
+++ b/libavcodec/eamad.c
@@ -34,6 +34,7 @@
 #include "aandcttab.h"
 #include "mpeg12.h"
 #include "mpeg12data.h"
+#include "libavcore/imgutils.h"
 
 #define EA_PREAMBLE_SIZE    8
 #define MADk_TAG MKTAG('M', 'A', 'D', 'k')    /* MAD i-frame */
@@ -260,7 +261,7 @@ static int decode_frame(AVCodecContext *avctx,
     buf += 16;
 
     if (avctx->width != s->width || avctx->height != s->height) {
-        if (avcodec_check_dimensions(avctx, s->width, s->height) < 0)
+        if (av_check_image_size(s->width, s->height, 0, avctx) < 0)
             return -1;
         avcodec_set_dimensions(avctx, s->width, s->height);
         if (t->frame.data[0])
diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c
index 8c6a654fad8..cfb0f8f5636 100644
--- a/libavcodec/eatgv.c
+++ b/libavcodec/eatgv.c
@@ -32,6 +32,7 @@
 #define ALT_BITSTREAM_READER_LE
 #include "get_bits.h"
 #include "libavutil/lzo.h"
+#include "libavcore/imgutils.h"
 
 #define EA_PREAMBLE_SIZE    8
 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T')
@@ -275,7 +276,7 @@ static int tgv_decode_frame(AVCodecContext *avctx,
         }
     }
 
-    if (avcodec_check_dimensions(avctx, s->width, s->height))
+    if (av_check_image_size(s->width, s->height, 0, avctx))
         return -1;
 
     /* shuffle */
diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index b21a9e4a341..dd15f2dd70f 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -20,6 +20,7 @@
 #include "mpegvideo.h"
 #include "h263.h"
 #include "flv.h"
+#include "libavcore/imgutils.h"
 
 void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){
     int is11 = get_bits1(gb);
@@ -82,7 +83,7 @@ int ff_flv_decode_picture_header(MpegEncContext *s)
         width = height = 0;
         break;
     }
-    if(avcodec_check_dimensions(s->avctx, width, height))
+    if(av_check_image_size(width, height, 0, s->avctx))
         return -1;
     s->width = width;
     s->height = height;
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 1daf1b7b1a4..06cd42142d3 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -22,6 +22,7 @@
 
 //#define DEBUG
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "lzw.h"
@@ -296,7 +297,7 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *data_size, A
         return -1;
 
     avctx->pix_fmt = PIX_FMT_PAL8;
-    if (avcodec_check_dimensions(avctx, s->screen_width, s->screen_height))
+    if (av_check_image_size(s->screen_width, s->screen_height, 0, avctx))
         return -1;
     avcodec_set_dimensions(avctx, s->screen_width, s->screen_height);
 
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 7648e2c7a60..92dcead9aeb 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -25,6 +25,7 @@
  * @author Michael Niedermayer <michaelni@gmx.at>
  */
 
+#include "libavcore/imgutils.h"
 #include "internal.h"
 #include "dsputil.h"
 #include "avcodec.h"
@@ -341,7 +342,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
     sps->mb_width = get_ue_golomb(&s->gb) + 1;
     sps->mb_height= get_ue_golomb(&s->gb) + 1;
     if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||
-       avcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height)){
+       av_check_image_size(16*sps->mb_width, 16*sps->mb_height, 0, h->s.avctx)){
         av_log(h->s.avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
         goto fail;
     }
diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 2992cb43ad6..7ddcbc6c927 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -25,6 +25,7 @@
  * IFF PBM/ILBM bitmap decoder
  */
 
+#include "libavcore/imgutils.h"
 #include "bytestream.h"
 #include "avcodec.h"
 #include "get_bits.h"
@@ -160,7 +161,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         return AVERROR_INVALIDDATA;
     }
 
-    if ((err = avcodec_check_dimensions(avctx, avctx->width, avctx->height)))
+    if ((err = av_check_image_size(avctx->width, avctx->height, 0, avctx)))
         return err;
     s->planesize = FFALIGN(avctx->width, 16) >> 3; // Align plane size in bits to word-boundary
     s->planebuf = av_malloc(s->planesize + FF_INPUT_BUFFER_PADDING_SIZE);
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index 95c5df84e80..60f3a65c7e9 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -515,7 +515,7 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
                    enum PixelFormat pix_fmt, int width, int height)
 {
 
-    if(avcodec_check_dimensions(NULL, width, height))
+    if(av_check_image_size(width, height, 0, NULL))
         return -1;
 
     if (av_fill_image_linesizes(picture->linesize, pix_fmt, width))
@@ -597,7 +597,7 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width,
 int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height)
 {
     AVPicture dummy_pict;
-    if(avcodec_check_dimensions(NULL, width, height))
+    if(av_check_image_size(width, height, 0, NULL))
         return -1;
     switch (pix_fmt) {
     case PIX_FMT_RGB8:
diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index 63d91da6a55..f2b6d0b789e 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "bytestream.h"
@@ -995,7 +996,7 @@ static int iv_decode_frame(AVCodecContext *avctx,
     image_height = bytestream_get_le16(&buf_pos);
     image_width  = bytestream_get_le16(&buf_pos);
 
-    if(avcodec_check_dimensions(avctx, image_width, image_height))
+    if(av_check_image_size(image_width, image_height, 0, avctx))
         return -1;
     if (image_width != avctx->width || image_height != avctx->height) {
         int ret;
diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c
index 7ecb28d4170..7d2ba48b577 100644
--- a/libavcodec/kgv1dec.c
+++ b/libavcodec/kgv1dec.c
@@ -25,6 +25,7 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 
 typedef struct {
@@ -50,7 +51,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
     h = (buf[1] + 1) * 8;
     buf += 2;
 
-    if (avcodec_check_dimensions(avctx, w, h))
+    if (av_check_image_size(w, h, 0, avctx))
         return -1;
 
     if (w != avctx->width || h != avctx->height)
diff --git a/libavcodec/libdiracdec.c b/libavcodec/libdiracdec.c
index d24d3baf998..c1b0b7f333a 100644
--- a/libavcodec/libdiracdec.c
+++ b/libavcodec/libdiracdec.c
@@ -105,8 +105,8 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
             /* tell FFmpeg about sequence details */
             dirac_sourceparams_t *src_params = &p_dirac_params->p_decoder->src_params;
 
-            if (avcodec_check_dimensions(avccontext, src_params->width,
-                                         src_params->height) < 0) {
+            if (av_check_image_size(src_params->width, src_params->height,
+                                    0, avccontext) < 0) {
                 av_log(avccontext, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n",
                        src_params->width, src_params->height);
                 avccontext->height = avccontext->width = 0;
diff --git a/libavcodec/libopenjpeg.c b/libavcodec/libopenjpeg.c
index f85ec001502..93ef4e2e864 100644
--- a/libavcodec/libopenjpeg.c
+++ b/libavcodec/libopenjpeg.c
@@ -113,7 +113,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
     }
     width  = image->comps[0].w << avctx->lowres;
     height = image->comps[0].h << avctx->lowres;
-    if(avcodec_check_dimensions(avctx, width, height) < 0) {
+    if(av_check_image_size(width, height, 0, avctx) < 0) {
         av_log(avctx, AV_LOG_ERROR, "%dx%d dimension invalid.\n", width, height);
         goto done;
     }
diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c
index ef20f20f334..776f293624a 100644
--- a/libavcodec/libschroedingerdec.c
+++ b/libavcodec/libschroedingerdec.c
@@ -169,8 +169,8 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
     p_schro_params->format = schro_decoder_get_video_format(decoder);
 
     /* Tell FFmpeg about sequence details. */
-    if (avcodec_check_dimensions(avccontext, p_schro_params->format->width,
-                                 p_schro_params->format->height) < 0) {
+    if (av_check_image_size(p_schro_params->format->width, p_schro_params->format->height,
+                            0, avccontext) < 0) {
         av_log(avccontext, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n",
                p_schro_params->format->width, p_schro_params->format->height);
         avccontext->height = avccontext->width = 0;
diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index 0464d12e718..a71099af69f 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -86,7 +86,7 @@ static int vp8_decode(AVCodecContext *avctx,
         if ((int) img->d_w != avctx->width || (int) img->d_h != avctx->height) {
             av_log(avctx, AV_LOG_INFO, "dimension change! %dx%d -> %dx%d\n",
                    avctx->width, avctx->height, img->d_w, img->d_h);
-            if (avcodec_check_dimensions(avctx, img->d_w, img->d_h))
+            if (av_check_image_size(img->d_w, img->d_h, 0, avctx))
                 return AVERROR_INVALIDDATA;
             avcodec_set_dimensions(avctx, img->d_w, img->d_h);
         }
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 8aff966f6e3..4e900a5c734 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -33,6 +33,7 @@
 //#define DEBUG
 #include <assert.h>
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "mjpeg.h"
@@ -218,7 +219,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
         height= s->height;
 
     av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height);
-    if(avcodec_check_dimensions(s->avctx, width, height))
+    if(av_check_image_size(width, height, 0, s->avctx))
         return -1;
 
     nb_components = get_bits(&s->gb, 8);
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 684bdfe1389..2fab73dba7f 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -28,6 +28,7 @@
  */
 
 #include "libavutil/intmath.h"
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "internal.h"
@@ -510,7 +511,7 @@ av_cold int MPV_common_init(MpegEncContext *s)
         return -1;
     }
 
-    if((s->width || s->height) && avcodec_check_dimensions(s->avctx, s->width, s->height))
+    if((s->width || s->height) && av_check_image_size(s->width, s->height, 0, s->avctx))
         return -1;
 
     dsputil_init(&s->dsp, s->avctx);
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
index 791f4509137..e52ea88b182 100644
--- a/libavcodec/nuv.c
+++ b/libavcodec/nuv.c
@@ -23,6 +23,7 @@
 
 #include "libavutil/bswap.h"
 #include "libavutil/lzo.h"
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "rtjpeg.h"
@@ -111,7 +112,7 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, int qualit
     if (quality >= 0)
         get_quant_quality(c, quality);
     if (width != c->width || height != c->height) {
-        if (avcodec_check_dimensions(avctx, height, width) < 0)
+        if (av_check_image_size(height, width, 0, avctx) < 0)
             return 0;
         avctx->width = c->width = width;
         avctx->height = c->height = height;
diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c
index 072d136d810..988febbb8fb 100644
--- a/libavcodec/pcx.c
+++ b/libavcodec/pcx.c
@@ -22,6 +22,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "get_bits.h"
@@ -142,7 +143,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     if (p->data[0])
         avctx->release_buffer(avctx, p);
 
-    if (avcodec_check_dimensions(avctx, w, h))
+    if (av_check_image_size(w, h, 0, avctx))
         return -1;
     if (w != avctx->width || h != avctx->height)
         avcodec_set_dimensions(avctx, w, h);
diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
index f990b1852be..26c9c005f7b 100644
--- a/libavcodec/pictordec.c
+++ b/libavcodec/pictordec.c
@@ -24,6 +24,7 @@
  * Pictor/PC Paint decoder
  */
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "cga_data.h"
@@ -135,7 +136,7 @@ static int decode_frame(AVCodecContext *avctx,
     avctx->pix_fmt = PIX_FMT_PAL8;
 
     if (s->width != avctx->width && s->height != avctx->height) {
-        if (avcodec_check_dimensions(avctx, s->width, s->height) < 0)
+        if (av_check_image_size(s->width, s->height, 0, avctx) < 0)
             return -1;
         avcodec_set_dimensions(avctx, s->width, s->height);
         if (s->frame.data[0])
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 037c5a0e58a..8a2e7c01e10 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -18,6 +18,7 @@
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "png.h"
@@ -441,7 +442,7 @@ static int decode_frame(AVCodecContext *avctx,
                 goto fail;
             s->width = bytestream_get_be32(&s->bytestream);
             s->height = bytestream_get_be32(&s->bytestream);
-            if(avcodec_check_dimensions(avctx, s->width, s->height)){
+            if(av_check_image_size(s->width, s->height, 0, avctx)){
                 s->width= s->height= 0;
                 goto fail;
             }
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index cb6a7139f2c..de21d6ca75a 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "pnm.h"
 
@@ -101,7 +102,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
             }
         }
         /* check that all tags are present */
-        if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || avcodec_check_dimensions(avctx, w, h))
+        if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || av_check_image_size(w, h, 0, avctx))
             return -1;
 
         avctx->width  = w;
@@ -134,7 +135,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
         return -1;
     pnm_get(s, buf1, sizeof(buf1));
     avctx->height = atoi(buf1);
-    if(avcodec_check_dimensions(avctx, avctx->width, avctx->height))
+    if(av_check_image_size(avctx->width, avctx->height, 0, avctx))
         return -1;
     if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
         pnm_get(s, buf1, sizeof(buf1));
diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c
index d8798f2e9c8..c026d966b08 100644
--- a/libavcodec/ptx.c
+++ b/libavcodec/ptx.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 
 typedef struct PTXContext {
@@ -64,7 +65,7 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     if (p->data[0])
         avctx->release_buffer(avctx, p);
 
-    if (avcodec_check_dimensions(avctx, w, h))
+    if (av_check_image_size(w, h, 0, avctx))
         return -1;
     if (w != avctx->width || h != avctx->height)
         avcodec_set_dimensions(avctx, w, h);
diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index 6cc7a556f31..ac8c00c3f18 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -22,6 +22,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "bytestream.h"
 
@@ -62,7 +63,7 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx)
 {
     QtrleEncContext *s = avctx->priv_data;
 
-    if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
+    if (av_check_image_size(avctx->width, avctx->height, 0, avctx) < 0) {
         return -1;
     }
     s->avctx=avctx;
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index e9face622b1..ad73d91a183 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -25,6 +25,7 @@
  * RV10/RV20 decoder
  */
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "mpegvideo.h"
@@ -369,7 +370,7 @@ static int rv20_decode_picture_header(MpegEncContext *s)
         }
         if(new_w != s->width || new_h != s->height){
             av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h);
-            if (avcodec_check_dimensions(s->avctx, new_w, new_h) < 0)
+            if (av_check_image_size(new_w, new_h, 0, s->avctx) < 0)
                 return -1;
             MPV_common_end(s);
             avcodec_set_dimensions(s->avctx, new_w, new_h);
diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
index e4a46c18896..598a8f6ce36 100644
--- a/libavcodec/rv40.c
+++ b/libavcodec/rv40.c
@@ -24,6 +24,8 @@
  * RV40 decoder
  */
 
+#include "libavcore/imgutils.h"
+
 #include "avcodec.h"
 #include "dsputil.h"
 #include "mpegvideo.h"
@@ -142,7 +144,7 @@ static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn
     si->pts = get_bits(gb, 13);
     if(!si->type || !get_bits1(gb))
         rv40_parse_picture_size(gb, &w, &h);
-    if(avcodec_check_dimensions(r->s.avctx, w, h) < 0)
+    if(av_check_image_size(w, h, 0, r->s.avctx) < 0)
         return -1;
     si->width  = w;
     si->height = h;
diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
index bbfd94bdf0e..9d42104591c 100644
--- a/libavcodec/sgidec.c
+++ b/libavcodec/sgidec.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "sgi.h"
@@ -201,7 +202,7 @@ static int decode_frame(AVCodecContext *avctx,
         return -1;
     }
 
-    if (avcodec_check_dimensions(avctx, s->width, s->height))
+    if (av_check_image_size(s->width, s->height, 0, avctx))
         return -1;
     avcodec_set_dimensions(avctx, s->width, s->height);
 
diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c
index 456ab85a88a..9fdfef5f1b7 100644
--- a/libavcodec/sunrast.c
+++ b/libavcodec/sunrast.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 
 #define RT_OLD          0
@@ -97,7 +98,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
     if (p->data[0])
         avctx->release_buffer(avctx, p);
 
-    if (avcodec_check_dimensions(avctx, w, h))
+    if (av_check_image_size(w, h, 0, avctx))
         return -1;
     if (w != avctx->width || h != avctx->height)
         avcodec_set_dimensions(avctx, w, h);
diff --git a/libavcodec/targa.c b/libavcodec/targa.c
index 50fe107ea9f..d5766476de5 100644
--- a/libavcodec/targa.c
+++ b/libavcodec/targa.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 
 enum TargaCompr{
@@ -145,7 +146,7 @@ static int decode_frame(AVCodecContext *avctx,
     if(s->picture.data[0])
         avctx->release_buffer(avctx, &s->picture);
 
-    if(avcodec_check_dimensions(avctx, w, h))
+    if(av_check_image_size(w, h, 0, avctx))
         return -1;
     if(w != avctx->width || h != avctx->height)
         avcodec_set_dimensions(avctx, w, h);
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 2f3cef2b00d..78c52cb2dd5 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -33,6 +33,7 @@
 #include "faxcompr.h"
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 
 typedef struct TiffContext {
     AVCodecContext *avctx;
@@ -305,7 +306,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
             return -1;
         }
         if(s->width != s->avctx->width || s->height != s->avctx->height){
-            if(avcodec_check_dimensions(s->avctx, s->width, s->height))
+            if(av_check_image_size(s->width, s->height, 0, s->avctx))
                 return -1;
             avcodec_set_dimensions(s->avctx, s->width, s->height);
         }
@@ -507,7 +508,7 @@ static int decode_frame(AVCodecContext *avctx,
         s->bpp = 1;
         avctx->pix_fmt = PIX_FMT_MONOBLACK;
         if(s->width != s->avctx->width || s->height != s->avctx->height){
-            if(avcodec_check_dimensions(s->avctx, s->width, s->height))
+            if(av_check_image_size(s->width, s->height, 0, s->avctx))
                 return -1;
             avcodec_set_dimensions(s->avctx, s->width, s->height);
         }
diff --git a/libavcodec/txd.c b/libavcodec/txd.c
index ac8229f9e43..320949ec1fd 100644
--- a/libavcodec/txd.c
+++ b/libavcodec/txd.c
@@ -22,6 +22,7 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "s3tc.h"
 
@@ -79,7 +80,7 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     if (p->data[0])
         avctx->release_buffer(avctx, p);
 
-    if (avcodec_check_dimensions(avctx, w, h))
+    if (av_check_image_size(w, h, 0, avctx))
         return -1;
     if (w != avctx->width || h != avctx->height)
         avcodec_set_dimensions(avctx, w, h);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 693b7d8f450..f13b271fc62 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -235,7 +235,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
         return -1;
     }
 
-    if(avcodec_check_dimensions(s,w,h))
+    if(av_check_image_size(w, h, 0, s))
         return -1;
 
     if(s->internal_buffer==NULL){
@@ -487,7 +487,7 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
 
 #define SANE_NB_CHANNELS 128U
     if (((avctx->coded_width || avctx->coded_height)
-        && avcodec_check_dimensions(avctx, avctx->coded_width, avctx->coded_height))
+        && av_check_image_size(avctx->coded_width, avctx->coded_height, 0, avctx))
         || avctx->channels > SANE_NB_CHANNELS) {
         ret = AVERROR(EINVAL);
         goto free_and_end;
@@ -554,7 +554,7 @@ int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf
         av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
         return -1;
     }
-    if(avcodec_check_dimensions(avctx,avctx->width,avctx->height))
+    if(av_check_image_size(avctx->width, avctx->height, 0, avctx))
         return -1;
     if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
         int ret = avctx->codec->encode(avctx, buf, buf_size, pict);
@@ -604,7 +604,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
     int ret;
 
     *got_picture_ptr= 0;
-    if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
+    if((avctx->coded_width||avctx->coded_height) && av_check_image_size(avctx->coded_width, avctx->coded_height, 0, avctx))
         return -1;
     if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
         ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 9a247404e35..9b9cbd9be7a 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "get_bits.h"
@@ -1980,7 +1981,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
     visible_width  = s->width  = get_bits(gb, 16) << 4;
     visible_height = s->height = get_bits(gb, 16) << 4;
 
-    if(avcodec_check_dimensions(avctx, s->width, s->height)){
+    if(av_check_image_size(s->width, s->height, 0, avctx)){
         av_log(avctx, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n", s->width, s->height);
         s->width= s->height= 0;
         return -1;
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 56bfbbb6562..0d9889b5c3b 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -22,6 +22,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "vp56.h"
 #include "vp8data.h"
@@ -224,7 +225,7 @@ static void vp8_decode_flush(AVCodecContext *avctx)
 
 static int update_dimensions(VP8Context *s, int width, int height)
 {
-    if (avcodec_check_dimensions(s->avctx, width, height))
+    if (av_check_image_size(width, height, 0, s->avctx))
         return AVERROR_INVALIDDATA;
 
     vp8_decode_flush(s->avctx);
diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index a1698394ef7..2d3e0e23692 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -68,6 +68,7 @@
 #include <string.h>
 
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 
 #define PALETTE_COUNT 256
@@ -147,7 +148,7 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
     s->vqa_version = vqa_header[0];
     s->width = AV_RL16(&vqa_header[6]);
     s->height = AV_RL16(&vqa_header[8]);
-    if(avcodec_check_dimensions(avctx, s->width, s->height)){
+    if(av_check_image_size(s->width, s->height, 0, avctx)){
         s->width= s->height= 0;
         return -1;
     }
diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c
index 0055ebb20be..ff1d5bf1900 100644
--- a/libavcodec/xsubdec.c
+++ b/libavcodec/xsubdec.c
@@ -18,6 +18,7 @@
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+#include "libavcore/imgutils.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "bytestream.h"
@@ -76,7 +77,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     // read header
     w = bytestream_get_le16(&buf);
     h = bytestream_get_le16(&buf);
-    if (avcodec_check_dimensions(avctx, w, h) < 0)
+    if (av_check_image_size(w, h, 0, avctx) < 0)
         return -1;
     x = bytestream_get_le16(&buf);
     y = bytestream_get_le16(&buf);
diff --git a/libavcodec/yop.c b/libavcodec/yop.c
index 72aebc68da7..b1064c97152 100644
--- a/libavcodec/yop.c
+++ b/libavcodec/yop.c
@@ -24,6 +24,7 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
 
 #include "avcodec.h"
 #include "get_bits.h"
@@ -84,7 +85,7 @@ static av_cold int yop_decode_init(AVCodecContext *avctx)
     s->avctx = avctx;
 
     if (avctx->width & 1 || avctx->height & 1 ||
-        avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
+        av_check_image_size(avctx->width, avctx->height, 0, avctx) < 0) {
         av_log(avctx, AV_LOG_ERROR, "YOP has invalid dimensions\n");
         return -1;
     }
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index be28f4a0ade..1c0630b38c1 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -1,7 +1,7 @@
 include $(SUBDIR)../config.mak
 
 NAME    = avdevice
-FFLIBS  = avformat avcodec avutil
+FFLIBS  = avformat avcodec avcore avutil
 
 HEADERS = avdevice.h
 
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index b9c0fd7b835..09f366eeadf 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -23,7 +23,7 @@
 
 #define LIBAVDEVICE_VERSION_MAJOR 52
 #define LIBAVDEVICE_VERSION_MINOR  2
-#define LIBAVDEVICE_VERSION_MICRO  0
+#define LIBAVDEVICE_VERSION_MICRO  1
 
 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
                                                LIBAVDEVICE_VERSION_MINOR, \
diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c
index d0ef7d5e047..50a113a72a2 100644
--- a/libavdevice/v4l.c
+++ b/libavdevice/v4l.c
@@ -22,6 +22,7 @@
 #undef __STRICT_ANSI__ //workaround due to broken kernel headers
 #include "config.h"
 #include "libavutil/rational.h"
+#include "libavcore/imgutils.h"
 #include "libavformat/avformat.h"
 #include "libavcodec/dsputil.h"
 #include <unistd.h>
@@ -116,7 +117,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
         }
     }
 
-    if(avcodec_check_dimensions(s1, s->video_win.width, s->video_win.height) < 0)
+    if(av_check_image_size(s->video_win.width, s->video_win.height, 0, s1) < 0)
         return -1;
 
     desired_palette = -1;
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index ce88903c3a0..c00785f51e8 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -43,6 +43,7 @@
 #endif
 #include <time.h>
 #include <strings.h>
+#include "libavcore/imgutils.h"
 
 static const int desired_video_buffers = 256;
 
@@ -623,7 +624,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
 
         return AVERROR(EIO);
     }
-    if (avcodec_check_dimensions(s1, s->width, s->height) < 0)
+    if (av_check_image_size(s->width, s->height, 0, s1) < 0)
         return AVERROR(EINVAL);
     s->frame_format = desired_format;
 
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index ebb5ad73bc8..c0193789bad 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -26,7 +26,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR  1
 #define LIBAVFILTER_VERSION_MINOR 27
-#define LIBAVFILTER_VERSION_MICRO  0
+#define LIBAVFILTER_VERSION_MICRO  1
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index bfa2dd532a2..76bc4d38ca8 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -28,6 +28,7 @@
 #include "parseutils.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/colorspace.h"
+#include "libavcore/imgutils.h"
 #include "libavcore/parseutils.h"
 
 enum { RED = 0, GREEN, BLUE, ALPHA };
@@ -406,7 +407,7 @@ static int color_config_props(AVFilterLink *inlink)
 
     color->w &= ~((1 << color->hsub) - 1);
     color->h &= ~((1 << color->vsub) - 1);
-    if (avcodec_check_dimensions(ctx, color->w, color->h) < 0)
+    if (av_check_image_size(color->w, color->h, 0, ctx) < 0)
         return AVERROR(EINVAL);
 
     memcpy(rgba_color, color->color, sizeof(rgba_color));
-- 
GitLab