Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-26 01:10:30 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-03-26 01:10:30 +0400
commit9621646eb316d7595f0f8198efd39f36efa30440 (patch)
tree8cc20303687a958f7a1530e14c65e9eadd54be8f /libavcodec/utvideo.c
parent8d7f2db60a9cc2b6fd87a410a69f4deafa3edff9 (diff)
parent62ce9defb81d0b6bd179131d1502858c8778f411 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: x86: dsputil: prettyprint gcc inline asm x86: K&R prettyprinting cosmetics for dsputil_mmx.c x86: conditionally compile H.264 QPEL optimizations dsputil_mmx: Surround QPEL macros by "do { } while (0);" blocks. Ignore generated files below doc/. dpcm: convert to bytestream2. interplayvideo: convert to bytestream2. movenc: Merge if statements h264: fix memleak in error path. pthread: Immediately release all frames in ff_thread_flush() h264: Add check for invalid chroma_format_idc utvideo: port header reading to bytestream2. Conflicts: .gitignore configure libavcodec/h264_ps.c libavcodec/interplayvideo.c libavcodec/pthread.c libavcodec/x86/dsputil_mmx.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/utvideo.c')
-rw-r--r--libavcodec/utvideo.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/libavcodec/utvideo.c b/libavcodec/utvideo.c
index cdc688da22..f0161ac9fc 100644
--- a/libavcodec/utvideo.c
+++ b/libavcodec/utvideo.c
@@ -358,13 +358,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
- const uint8_t *buf_end = buf + buf_size;
UtvideoContext *c = avctx->priv_data;
- const uint8_t *ptr;
int i, j;
const uint8_t *plane_start[5];
int plane_size, max_slice_size = 0, slice_start, slice_end, slice_size;
int ret;
+ GetByteContext gb;
if (c->pic.data[0])
ff_thread_release_buffer(avctx, &c->pic);
@@ -377,20 +376,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
}
/* parse plane structure to retrieve frame flags and validate slice offsets */
- ptr = buf;
+ bytestream2_init(&gb, buf, buf_size);
for (i = 0; i < c->planes; i++) {
- plane_start[i] = ptr;
- if (buf_end - ptr < 256 + 4 * c->slices) {
+ plane_start[i] = gb.buffer;
+ if (bytestream2_get_bytes_left(&gb) < 256 + 4 * c->slices) {
av_log(avctx, AV_LOG_ERROR, "Insufficient data for a plane\n");
return AVERROR_INVALIDDATA;
}
- ptr += 256;
+ bytestream2_skipu(&gb, 256);
slice_start = 0;
slice_end = 0;
for (j = 0; j < c->slices; j++) {
- slice_end = bytestream_get_le32(&ptr);
+ slice_end = bytestream2_get_le32u(&gb);
slice_size = slice_end - slice_start;
- if (slice_size < 0) {
+ if (slice_end <= 0 || slice_size <= 0 ||
+ bytestream2_get_bytes_left(&gb) < slice_end) {
av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n");
return AVERROR_INVALIDDATA;
}
@@ -398,18 +398,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
max_slice_size = FFMAX(max_slice_size, slice_size);
}
plane_size = slice_end;
- if (buf_end - ptr < plane_size) {
- av_log(avctx, AV_LOG_ERROR, "Plane size is bigger than available data\n");
- return AVERROR_INVALIDDATA;
- }
- ptr += plane_size;
+ bytestream2_skipu(&gb, plane_size);
}
- plane_start[c->planes] = ptr;
- if (buf_end - ptr < c->frame_info_size) {
+ plane_start[c->planes] = gb.buffer;
+ if (bytestream2_get_bytes_left(&gb) < c->frame_info_size) {
av_log(avctx, AV_LOG_ERROR, "Not enough data for frame information\n");
return AVERROR_INVALIDDATA;
}
- c->frame_info = AV_RL32(ptr);
+ c->frame_info = bytestream2_get_le32u(&gb);
av_log(avctx, AV_LOG_DEBUG, "frame information flags %X\n", c->frame_info);
c->frame_pred = (c->frame_info >> 8) & 3;