[FFmpeg-devel] [PATCH] h264: fix poc values after reset mmco (broken by adedd840e)

Jeff Downs heydowns at somuchpressure.net
Fri Sep 7 22:16:04 CEST 2012


Move current picture mmco_reset flagging from mmco execute to mmco decode
so it is available when used for output picture selection.
Removes mmco_reset state variable used to mark pics as it isn't needed
with above.
Restore (and enhance) code removed by above commit in mmco reset execution
which resets cur pic's poc and field pocs (spec 8.2.1 paragraph 5),
poc_msb and poc_lsb (8.2.1.1), and prev_frame_num_offset (8.2.1.2 and 8.2.1.3)
Files cited in above commit (fate-h264-conformance-{mr2_tandberg_e,mr3_tandberg_b})
still work properly.
---
 libavcodec/h264.c      |    5 ++---
 libavcodec/h264.h      |    1 -
 libavcodec/h264_refs.c |   10 ++++++++--
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 713fda7..99ef286 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1434,8 +1434,6 @@ static void decode_postinit(H264Context *h, int setup_finished)
         }
     }
 
-    cur->mmco_reset = h->mmco_reset;
-    h->mmco_reset = 0;
     // FIXME do something with unavailable reference frames
 
     /* Sort B-frames into display order */
@@ -1505,8 +1503,9 @@ static void decode_postinit(H264Context *h, int setup_finished)
             h->delayed_pic[i] = h->delayed_pic[i + 1];
     }
     if (!out_of_order && pics > s->avctx->has_b_frames) {
+        Picture *pic = h->delayed_pic[0] ? h->delayed_pic[0] : out;
         h->next_output_pic = out;
-        if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
+        if (out_idx == 0 && (pic->f.key_frame || pic->mmco_reset)) {
             h->next_outputed_poc = INT_MIN;
         } else
             h->next_outputed_poc = out->poc;
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 4d07a8a..d855c05 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -499,7 +499,6 @@ typedef struct H264Context {
      */
     MMCO mmco[MAX_MMCO_COUNT];
     int mmco_index;
-    int mmco_reset;
 
     int long_ref_count;     ///< number of actual long term references
     int short_ref_count;    ///< number of actual short term references
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index d68a7d8..c4d89f6 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -585,10 +585,14 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
             for(j = 0; j < 16; j++) {
                 remove_long(h, j, 0);
             }
+            s->current_picture_ptr->field_poc[0]-= s->current_picture_ptr->poc;
+            s->current_picture_ptr->field_poc[1]-= s->current_picture_ptr->poc;
+            s->current_picture_ptr->poc=
+            h->poc_msb=
             h->frame_num=
+            h->frame_num_offset=
             s->current_picture_ptr->frame_num= 0;
-            h->mmco_reset = 1;
-            s->current_picture_ptr->mmco_reset=1;
+            h->poc_lsb= (s->picture_structure == PICT_BOTTOM_FIELD) ? 0 : s->current_picture_ptr->field_poc[0];
             for (j = 0; j < MAX_DELAYED_PIC_COUNT; j++)
                 h->last_pocs[j] = INT_MIN;
             break;
@@ -690,6 +694,8 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb){
                         return -1;
                     }*/
                 }
+                if (opcode == MMCO_RESET)
+                    s->current_picture_ptr->mmco_reset = 1;
                 if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
                     unsigned int long_arg= get_ue_golomb_31(gb);
                     if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG && long_arg == 16) && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){
-- 
1.7.8.6



More information about the ffmpeg-devel mailing list