diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-03-30 16:04:07 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-01-16 00:52:56 +0100 |
commit | 3f2efac0fec16de92dd110723d73694e3e63946f (patch) | |
tree | 21d1790d44c15dde765bde41b1549a921fc1980a | |
parent | b9058f58bde97af4178c8cffa1bbdc85787de2ab (diff) | |
download | ffmpeg-3f2efac0fec16de92dd110723d73694e3e63946f.tar.gz |
h264: Move slice_table clean out of frame_start
Fixes inconsistency ultimately leading to an out of array read
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 746016598d1885afd1fee976b6d315ed7eeefa68)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/h264.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index dd16627364..8bc8d7dbb0 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1782,11 +1782,6 @@ int ff_h264_frame_start(H264Context *h) h->block_offset[48 + 32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * h->uvlinesize * ((scan8[i] - scan8[0]) >> 3); } - /* Some macroblocks can be accessed before they're available in case - * of lost slices, MBAFF or threading. */ - memset(h->slice_table, -1, - (h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table)); - // s->decode = (h->flags & CODEC_FLAG_PSNR) || !s->encoding || // h->cur_pic.f.reference /* || h->contains_intra */ || 1; @@ -3499,6 +3494,15 @@ static int decode_slice_header(H264Context *h, H264Context *h0) } else { release_unused_pictures(h, 0); } + /* Some macroblocks can be accessed before they're available in case + * of lost slices, MBAFF or threading. */ + if (FIELD_PICTURE) { + for(i = (h->picture_structure == PICT_BOTTOM_FIELD); i<h->mb_height; i++) + memset(h->slice_table + i*h->mb_stride, -1, (h->mb_stride - (i+1==h->mb_height)) * sizeof(*h->slice_table)); + } else { + memset(h->slice_table, -1, + (h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table)); + } } if (h != h0 && (ret = clone_slice(h, h0)) < 0) return ret; |