h264: set mb_aff_frame in frame_start()
authorAnton Khirnov <anton@khirnov.net>
Tue, 17 May 2016 13:07:23 +0000 (15:07 +0200)
committerAnton Khirnov <anton@khirnov.net>
Tue, 21 Jun 2016 09:08:32 +0000 (11:08 +0200)
Avoid unnecessary modification of the decoder-global state in per-slice
code.

libavcodec/h264_slice.c

index c43a0be..4b0adab 100644 (file)
@@ -377,6 +377,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
     h->coded_picture_number = h1->coded_picture_number;
     h->first_field          = h1->first_field;
     h->picture_structure    = h1->picture_structure;
+    h->mb_aff_frame         = h1->mb_aff_frame;
     h->droppable            = h1->droppable;
 
     for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
@@ -501,6 +502,8 @@ static int h264_frame_start(H264Context *h)
 
     h->postpone_filter = 0;
 
+    h->mb_aff_frame = h->ps.sps->mb_aff && (h->picture_structure == PICT_FRAME);
+
     assert(h->cur_pic_ptr->long_ref == 0);
 
     return 0;
@@ -1173,7 +1176,6 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl,
     unsigned int slice_type, tmp, i;
     int field_pic_flag, bottom_field_flag;
     int frame_num, droppable, picture_structure;
-    int mb_aff_frame = 0;
 
     sl->first_mb_addr = get_ue_golomb(&sl->gb);
 
@@ -1236,12 +1238,8 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl,
             picture_structure = PICT_TOP_FIELD + bottom_field_flag;
         } else {
             picture_structure = PICT_FRAME;
-            mb_aff_frame      = sps->mb_aff;
         }
     }
-    if (!h->setup_finished) {
-        h->mb_aff_frame      = mb_aff_frame;
-    }
     sl->picture_structure      = picture_structure;
     sl->mb_field_decoding_flag = picture_structure != PICT_FRAME;