h264: use mbaff ref indices in fill_colmap() only for mbaff references
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 6 Oct 2011 20:54:00 +0000 (22:54 +0200)
committerJanne Grunau <janne-libav@jannau.net>
Tue, 18 Dec 2012 10:02:23 +0000 (11:02 +0100)
Prevents writing beyond array bounds.

Signed-off-by: Janne Grunau <janne-libav@jannau.net>
libavcodec/h264_direct.c

index cc6e018..fc429ae 100644 (file)
@@ -89,7 +89,8 @@ static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field,
             for(j=start; j<end; j++){
                 if (4 * h->ref_list[0][j].frame_num + (h->ref_list[0][j].f.reference & 3) == poc) {
                     int cur_ref= mbafi ? (j-16)^field : j;
-                    map[list][2*old_ref + (rfield^field) + 16] = cur_ref;
+                    if (ref1->mbaff)
+                        map[list][2 * old_ref + (rfield^field) + 16] = cur_ref;
                     if(rfield == field || !interl)
                         map[list][old_ref] = cur_ref;
                     break;