summaryrefslogtreecommitdiff
path: root/libavcodec/h264.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-04-30 23:51:30 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-01 00:06:26 +0200
commitfbaf75b166cd067cf383a75ffcccb1e2b370bf6d (patch)
tree1a7c61ea24dc0d7d61abb087947a5f9b789840be /libavcodec/h264.c
parent5299ee54a73ff1c4d4a4a3ee7b84dae2ffb2fb5f (diff)
h264: Use the correct croping values.
This fixes returning pictures with corrupted data pointers. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r--libavcodec/h264.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 03b6bda0e1..05623fcb2b 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -275,6 +275,9 @@ static int ref_picture(H264Context *h, Picture *dst, Picture *src)
dst->needs_realloc = src->needs_realloc;
dst->reference = src->reference;
dst->sync = src->sync;
+ dst->crop = src->crop;
+ dst->crop_left = src->crop_left;
+ dst->crop_top = src->crop_top;
return 0;
fail:
@@ -349,6 +352,9 @@ static int alloc_picture(H264Context *h, Picture *pic)
h->linesize = pic->f.linesize[0];
h->uvlinesize = pic->f.linesize[1];
+ pic->crop = h->sps.crop;
+ pic->crop_top = h->sps.crop_top;
+ pic->crop_left= h->sps.crop_left;
if (h->avctx->hwaccel) {
const AVHWAccel *hwaccel = h->avctx->hwaccel;
@@ -4843,21 +4849,22 @@ static int get_consumed_bytes(int pos, int buf_size)
return pos;
}
-static int output_frame(H264Context *h, AVFrame *dst, AVFrame *src)
+static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
{
+ AVFrame *src = &srcp->f;
int i;
int ret = av_frame_ref(dst, src);
if (ret < 0)
return ret;
- if (!h->sps.crop)
+ if (!srcp->crop)
return 0;
for (i = 0; i < 3; i++) {
int hshift = (i > 0) ? h->chroma_x_shift : 0;
int vshift = (i > 0) ? h->chroma_y_shift : 0;
- int off = ((h->sps.crop_left >> hshift) << h->pixel_shift) +
- (h->sps.crop_top >> vshift) * dst->linesize[i];
+ int off = ((srcp->crop_left >> hshift) << h->pixel_shift) +
+ (srcp->crop_top >> vshift) * dst->linesize[i];
dst->data[i] += off;
}
return 0;
@@ -4902,7 +4909,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
if (out) {
out->reference &= ~DELAYED_PIC_REF;
- ret = output_frame(h, pict, &out->f);
+ ret = output_frame(h, pict, out);
if (ret < 0)
return ret;
*got_frame = 1;
@@ -4960,7 +4967,7 @@ not_extra:
/* Wait for second field. */
*got_frame = 0;
if (h->next_output_pic && (h->next_output_pic->sync || h->sync>1)) {
- ret = output_frame(h, pict, &h->next_output_pic->f);
+ ret = output_frame(h, pict, h->next_output_pic);
if (ret < 0)
return ret;
*got_frame = 1;