Merge commit 'c8f3cb9119c2183680d44a509a1b5a9817a3bee9'

* commit 'c8f3cb9119c2183680d44a509a1b5a9817a3bee9':
  vmd: return meaningful errors

Conflicts:
	libavcodec/vmdav.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
pull/23/head
Michael Niedermayer 12 years ago
commit 8ef89833d0
  1. 19
      libavcodec/vmdav.c

@ -227,12 +227,18 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
frame_x >= s->avctx->width || frame_x >= s->avctx->width ||
frame_width > s->avctx->width || frame_width > s->avctx->width ||
frame_x + frame_width > s->avctx->width) { frame_x + frame_width > s->avctx->width) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid horizontal range %d-%d\n",
frame_x, frame_width);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (frame_y < 0 || frame_height < 0 || if (frame_y < 0 || frame_height < 0 ||
frame_y >= s->avctx->height || frame_y >= s->avctx->height ||
frame_height > s->avctx->height || frame_height > s->avctx->height ||
frame_y + frame_height > s->avctx->height) { frame_y + frame_height > s->avctx->height) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid vertical range %d-%d\n",
frame_x, frame_width);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
@ -259,6 +265,9 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
palette32[i] = 0xFFU << 24 | (r << 16) | (g << 8) | (b); palette32[i] = 0xFFU << 24 | (r << 16) | (g << 8) | (b);
palette32[i] |= palette32[i] >> 6 & 0x30303; palette32[i] |= palette32[i] >> 6 & 0x30303;
} }
} else {
av_log(s->avctx, AV_LOG_ERROR, "Incomplete palette\n");
return AVERROR_INVALIDDATA;
} }
} }
if (s->size > 0) { if (s->size > 0) {
@ -299,7 +308,7 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
if (ofs > frame_width) { if (ofs > frame_width) {
av_log(s->avctx, AV_LOG_ERROR, "offset > width (%d > %d)\n", av_log(s->avctx, AV_LOG_ERROR, "offset > width (%d > %d)\n",
ofs, frame_width); ofs, frame_width);
break; return AVERROR_INVALIDDATA;
} }
dp += frame->linesize[0]; dp += frame->linesize[0];
pp += s->prev_frame.linesize[0]; pp += s->prev_frame.linesize[0];
@ -339,6 +348,7 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
if (ofs > frame_width) { if (ofs > frame_width) {
av_log(s->avctx, AV_LOG_ERROR, "offset > width (%d > %d)\n", av_log(s->avctx, AV_LOG_ERROR, "offset > width (%d > %d)\n",
ofs, frame_width); ofs, frame_width);
return AVERROR_INVALIDDATA;
} }
dp += frame->linesize[0]; dp += frame->linesize[0];
pp += s->prev_frame.linesize[0]; pp += s->prev_frame.linesize[0];
@ -346,7 +356,6 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
break; break;
} }
} }
return 0; return 0;
} }
@ -405,13 +414,13 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx,
s->size = buf_size; s->size = buf_size;
if (buf_size < 16) if (buf_size < 16)
return buf_size; return AVERROR_INVALIDDATA;
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret; return ret;
if (vmd_decode(s, frame) < 0) if ((ret = vmd_decode(s, frame)) < 0)
av_log(avctx, AV_LOG_WARNING, "decode error\n"); return ret;
/* make the palette available on the way out */ /* make the palette available on the way out */
memcpy(frame->data[1], s->palette, PALETTE_COUNT * 4); memcpy(frame->data[1], s->palette, PALETTE_COUNT * 4);

Loading…
Cancel
Save