diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 8468720615..5c3c3e81cb 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -111,11 +111,9 @@ static int decode_frame(AVCodecContext *avctx, buf = avpkt->data + 0x304; w = read32(&buf, endian); h = read32(&buf, endian); - if ((ret = av_image_check_size(w, h, 0, avctx)) < 0) - return ret; - if (w != avctx->width || h != avctx->height) - avcodec_set_dimensions(avctx, w, h); + if ((ret = ff_set_dimensions(avctx, w, h)) < 0) + return ret; // Need to end in 0x320 to read the descriptor buf += 20; diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index c46c2fff32..e7da50bf4c 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -319,7 +319,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, int buf_size = avpkt->size; DVVideoContext *s = avctx->priv_data; const uint8_t* vsc_pack; - int ret, apt, is16_9; + int apt, is16_9, ret; s->sys = avpriv_dv_frame_profile2(avctx, s->sys, buf, buf_size); if (!s->sys || buf_size < s->sys->frame_size || ff_dv_init_dynamic_tables(s->sys)) { @@ -331,7 +331,11 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, s->picture.pict_type = AV_PICTURE_TYPE_I; avctx->pix_fmt = s->sys->pix_fmt; avctx->time_base = s->sys->time_base; - avcodec_set_dimensions(avctx, s->sys->width, s->sys->height); + + ret = ff_set_dimensions(avctx, s->sys->width, s->sys->height); + if (ret < 0) + return ret; + if ((ret = ff_get_buffer(avctx, &s->picture, 0)) < 0) return ret; s->picture.interlaced_frame = 1; diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index f0dd289139..87afc1e7ba 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -21,6 +21,8 @@ #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" +#include "internal.h" + #include "libavutil/attributes.h" #include "libavutil/colorspace.h" #include "libavutil/opt.h" @@ -598,9 +600,11 @@ static int dvdsub_parse_extradata(AVCodecContext *avctx) parse_palette(ctx, data + 8); } else if (strncmp("size:", data, 5) == 0) { int w, h; - if (sscanf(data + 5, "%dx%d", &w, &h) == 2 && - av_image_check_size(w, h, 0, avctx) >= 0) - avcodec_set_dimensions(avctx, w, h); + if (sscanf(data + 5, "%dx%d", &w, &h) == 2) { + int ret = ff_set_dimensions(avctx, w, h); + if (ret < 0) + return ret; + } } data += pos; diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c index 3f22c74798..b3ffb3f07b 100644 --- a/libavcodec/eacmv.c +++ b/libavcodec/eacmv.c @@ -130,21 +130,23 @@ static void cmv_decode_inter(CmvContext *s, AVFrame *frame, const uint8_t *buf, } } -static void cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *buf_end) +static int cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *buf_end) { - int pal_start, pal_count, i; + int pal_start, pal_count, i, ret; if(buf_end - buf < 16) { av_log(s->avctx, AV_LOG_WARNING, "truncated header\n"); - return; + return AVERROR_INVALIDDATA; } s->width = AV_RL16(&buf[4]); s->height = AV_RL16(&buf[6]); if (s->avctx->width!=s->width || s->avctx->height!=s->height) { - avcodec_set_dimensions(s->avctx, s->width, s->height); av_frame_unref(s->last_frame); av_frame_unref(s->last2_frame); + ret = ff_set_dimensions(s->avctx, s->width, s->height); + if (ret < 0) + return ret; } s->avctx->time_base.num = 1; @@ -158,6 +160,8 @@ static void cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t s->palette[i] = 0xFFU << 24 | AV_RB24(buf); buf += 3; } + + return 0; } #define EA_PREAMBLE_SIZE 8 @@ -179,7 +183,9 @@ static int cmv_decode_frame(AVCodecContext *avctx, if (AV_RL32(buf)==MVIh_TAG||AV_RB32(buf)==MVIh_TAG) { unsigned size = AV_RL32(buf + 4); - cmv_process_header(s, buf+EA_PREAMBLE_SIZE, buf_end); + ret = cmv_process_header(s, buf+EA_PREAMBLE_SIZE, buf_end); + if (ret < 0) + return ret; if (size > buf_end - buf - EA_PREAMBLE_SIZE) return -1; buf += size;