diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-04-21 14:39:42 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-21 14:39:55 +0200 |
commit | 7434225ed15d7326cf9d906a7cd3539eb8184e8e (patch) | |
tree | 028363b61042619d7f3db2d08665a50dec6bc04c | |
parent | c9f17afe4e3c1fb57d089a8de5237851b0c0122b (diff) | |
parent | 30e58e65e543d04d5e52bf188b31abf4dd41a104 (diff) | |
download | ffmpeg-7434225ed15d7326cf9d906a7cd3539eb8184e8e.tar.gz |
Merge commit '30e58e65e543d04d5e52bf188b31abf4dd41a104' into release/1.1
* commit '30e58e65e543d04d5e52bf188b31abf4dd41a104':
h264_refs: make sure not to write over the bounds of the default ref list
Conflicts:
libavcodec/h264_refs.c
See: 0a5ca63c24b8a07f94611637ba29e41b8b47ce24
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/h264_refs.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index 2c9c71680a..ea697b0b80 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -63,7 +63,9 @@ static int split_field_copy(Picture *dest, Picture *src, return match; } -static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel){ +static int build_def_list(Picture *def, int def_len, + Picture **in, int len, int is_long, int sel) +{ int i[2]={0}; int index=0; @@ -73,10 +75,12 @@ static int build_def_list(Picture *def, Picture **in, int len, int is_long, int while (i[1] < len && !(in[ i[1] ] && (in[ i[1] ]->f.reference & (sel^3)))) i[1]++; if(i[0] < len){ + av_assert0(index < def_len); in[ i[0] ]->pic_id= is_long ? i[0] : in[ i[0] ]->frame_num; split_field_copy(&def[index++], in[ i[0]++ ], sel , 1); } if(i[1] < len){ + av_assert0(index < def_len); in[ i[1] ]->pic_id= is_long ? i[1] : in[ i[1] ]->frame_num; split_field_copy(&def[index++], in[ i[1]++ ], sel^3, 0); } @@ -124,8 +128,12 @@ int ff_h264_fill_default_ref_list(H264Context *h){ len= add_sorted(sorted , h->short_ref, h->short_ref_count, cur_poc, 1^list); len+=add_sorted(sorted+len, h->short_ref, h->short_ref_count, cur_poc, 0^list); av_assert0(len<=32); - len= build_def_list(h->default_ref_list[list] , sorted , len, 0, s->picture_structure); - len+=build_def_list(h->default_ref_list[list]+len, h->long_ref, 16 , 1, s->picture_structure); + len = build_def_list(h->default_ref_list[list], FF_ARRAY_ELEMS(h->default_ref_list[0]), + sorted, len, 0, s->picture_structure); + len += build_def_list(h->default_ref_list[list] + len, + FF_ARRAY_ELEMS(h->default_ref_list[0]) - len, + h->long_ref, 16, 1, s->picture_structure); + av_assert0(len<=32); if(len < h->ref_count[list]) @@ -139,8 +147,12 @@ int ff_h264_fill_default_ref_list(H264Context *h){ FFSWAP(Picture, h->default_ref_list[1][0], h->default_ref_list[1][1]); } }else{ - len = build_def_list(h->default_ref_list[0] , h->short_ref, h->short_ref_count, 0, s->picture_structure); - len+= build_def_list(h->default_ref_list[0]+len, h-> long_ref, 16 , 1, s->picture_structure); + len = build_def_list(h->default_ref_list[0], FF_ARRAY_ELEMS(h->default_ref_list[0]), + h->short_ref, h->short_ref_count, 0, s->picture_structure); + len += build_def_list(h->default_ref_list[0] + len, + FF_ARRAY_ELEMS(h->default_ref_list[0]) - len, + h-> long_ref, 16, 1, s->picture_structure); + av_assert0(len<=32); if(len < h->ref_count[0]) memset(&h->default_ref_list[0][len], 0, sizeof(Picture)*(h->ref_count[0] - len)); |