Merge remote-tracking branch 'qatar/release/9' into release/1.1

* qatar/release/9:
  vmd: refactor the inner decode loop

Conflicts:
	libavcodec/vmdav.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer
2013-06-03 02:21:38 +02:00

View File

@@ -270,9 +270,11 @@ static int vmd_decode(VmdVideoContext *s)
return AVERROR_INVALIDDATA;
}
}
if (s->size > 0) {
if (!s->size)
return 0;
/* originally UnpackFrame in VAG's code */
bytestream2_init(&gb, gb.buffer, s->buf + s->size - gb.buffer);
if (bytestream2_get_bytes_left(&gb) < 1)
return AVERROR_INVALIDDATA;
meth = bytestream2_get_byteu(&gb);
@@ -293,7 +295,8 @@ static int vmd_decode(VmdVideoContext *s)
len = bytestream2_get_byte(&gb);
if (len & 0x80) {
len = (len & 0x7F) + 1;
if (ofs + len > frame_width || bytestream2_get_bytes_left(&gb) < len)
if (ofs + len > frame_width ||
bytestream2_get_bytes_left(&gb) < len)
return AVERROR_INVALIDDATA;
bytestream2_get_buffer(&gb, &dp[ofs], len);
ofs += len;
@@ -306,7 +309,8 @@ static int vmd_decode(VmdVideoContext *s)
}
} while (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,
"VMD video: offset > width (%d > %d)\n",
ofs, frame_width);
return AVERROR_INVALIDDATA;
}
@@ -346,7 +350,8 @@ static int vmd_decode(VmdVideoContext *s)
}
} while (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,
"VMD video: offset > width (%d > %d)\n",
ofs, frame_width);
return AVERROR_INVALIDDATA;
}
@@ -355,7 +360,6 @@ static int vmd_decode(VmdVideoContext *s)
}
break;
}
}
return 0;
}