]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264_refs.c
Merge commit '3741aa37c2a0d0717faff74a5c4cc357d16f6d1d'
[ffmpeg] / libavcodec / h264_refs.c
index 0ca4878345a017ae67d64c4cfc3128fe2ca37cb0..e5152dc3e5f2072cf1098edde1355857793aed41 100644 (file)
@@ -225,16 +225,16 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
         for (i = 0; i < h->ref_count[list]; i++)
             COPY_PICTURE(&h->ref_list[list][i], &h->default_ref_list[list][i]);
 
-        if (get_bits1(&h->gb)) {
+        if (get_bits1(&h->gb)) {    // ref_pic_list_modification_flag_l[01]
             int pred = h->curr_pic_num;
 
             for (index = 0; ; index++) {
-                unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(&h->gb);
+                unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&h->gb);
                 unsigned int pic_id;
                 int i;
                 Picture *ref = NULL;
 
-                if (reordering_of_pic_nums_idc == 3)
+                if (modification_of_pic_nums_idc == 3)
                     break;
 
                 if (index >= h->ref_count[list]) {
@@ -242,7 +242,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
                     return -1;
                 }
 
-                switch (reordering_of_pic_nums_idc) {
+                switch (modification_of_pic_nums_idc) {
                 case 0:
                 case 1: {
                     const unsigned int abs_diff_pic_num = get_ue_golomb(&h->gb) + 1;
@@ -254,7 +254,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
                         return AVERROR_INVALIDDATA;
                     }
 
-                    if (reordering_of_pic_nums_idc == 0)
+                    if (modification_of_pic_nums_idc == 0)
                         pred -= abs_diff_pic_num;
                     else
                         pred += abs_diff_pic_num;
@@ -298,7 +298,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
                 }
                 default:
                     av_log(h->avctx, AV_LOG_ERROR,
-                           "illegal reordering_of_pic_nums_idc\n");
+                           "illegal modification_of_pic_nums_idc %u\n",
+                           modification_of_pic_nums_idc);
                     return AVERROR_INVALIDDATA;
                 }
 
@@ -551,7 +552,7 @@ static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos)
 int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
 {
     MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
-    int mmco_index = 0, i;
+    int mmco_index = 0, i = 0;
 
     if (h->short_ref_count &&
         h->long_ref_count + h->short_ref_count >= h->sps.ref_frame_count &&
@@ -752,6 +753,15 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
         }
     }
 
+    for (i = 0; i<h->short_ref_count; i++) {
+        pic = h->short_ref[i];
+        if (pic->invalid_gap) {
+            int d = (h->cur_pic_ptr->frame_num - pic->frame_num) & ((1 << h->sps.log2_max_frame_num)-1);
+            if (d > h->sps.ref_frame_count)
+                remove_short(h, pic->frame_num, 0);
+        }
+    }
+
     print_short_term(h);
     print_long_term(h);