[FFmpeg-cvslog] h264: add a parameter to the FIELD_PICTURE macro.

Anton Khirnov git at videolan.org
Thu Mar 21 12:56:57 CET 2013


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Mar  9 20:37:11 2013 +0100| [7fa00653a550c0d24b3951c0f9fed6350ecf5ce4] | committer: Anton Khirnov

h264: add a parameter to the FIELD_PICTURE macro.

This way it does not look like a constant.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7fa00653a550c0d24b3951c0f9fed6350ecf5ce4
---

 libavcodec/h264.c            |   24 ++++++++++++------------
 libavcodec/h264.h            |    6 +++---
 libavcodec/h264_cabac.c      |    2 +-
 libavcodec/h264_loopfilter.c |    6 +++---
 libavcodec/h264_refs.c       |   12 ++++++------
 5 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index d52349a..14369ac 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -751,7 +751,7 @@ static void await_references(H264Context *h)
                 row <<= MB_MBAFF(h);
                 nrefs[list]--;
 
-                if (!FIELD_PICTURE && ref_field_picture) { // frame referencing two fields
+                if (!FIELD_PICTURE(h) && ref_field_picture) { // frame referencing two fields
                     ff_thread_await_progress(&ref_pic->tf,
                                              FFMIN((row >> 1) - !(row & 1),
                                                    pic_height - 1),
@@ -759,12 +759,12 @@ static void await_references(H264Context *h)
                     ff_thread_await_progress(&ref_pic->tf,
                                              FFMIN((row >> 1), pic_height - 1),
                                              0);
-                } else if (FIELD_PICTURE && !ref_field_picture) { // field referencing one field of a frame
+                } else if (FIELD_PICTURE(h) && !ref_field_picture) { // field referencing one field of a frame
                     ff_thread_await_progress(&ref_pic->tf,
                                              FFMIN(row * 2 + ref_field,
                                                    pic_height - 1),
                                              0);
-                } else if (FIELD_PICTURE) {
+                } else if (FIELD_PICTURE(h)) {
                     ff_thread_await_progress(&ref_pic->tf,
                                              FFMIN(row, pic_height - 1),
                                              ref_field);
@@ -2801,7 +2801,7 @@ static int field_end(H264Context *h, int in_setup)
      * past end by one (callers fault) and resync_mb_y != 0
      * causes problems for the first MB line, too.
      */
-    if (!FIELD_PICTURE) {
+    if (!FIELD_PICTURE(h)) {
         h->er.cur_pic  = h->cur_pic_ptr;
         h->er.last_pic = h->ref_count[0] ? &h->ref_list[0][0] : NULL;
         h->er.next_pic = h->ref_count[1] ? &h->ref_list[1][0] : NULL;
@@ -3098,7 +3098,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
     first_mb_in_slice = get_ue_golomb(&h->gb);
 
     if (first_mb_in_slice == 0) { // FIXME better field boundary detection
-        if (h0->current_slice && FIELD_PICTURE) {
+        if (h0->current_slice && FIELD_PICTURE(h)) {
             field_end(h, 1);
         }
 
@@ -3327,7 +3327,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
             assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
 
             /* figure out if we have a complementary field pair */
-            if (!FIELD_PICTURE || h->picture_structure == last_pic_structure) {
+            if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
                 /* Previous field is unmatched. Don't display it, but let it
                  * remain for reference if marked as such. */
                 if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
@@ -3411,11 +3411,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
             assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
 
             /* figure out if we have a complementary field pair */
-            if (!FIELD_PICTURE || h->picture_structure == last_pic_structure) {
+            if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
                 /* Previous field is unmatched. Don't display it, but let it
                  * remain for reference if marked as such. */
                 h0->cur_pic_ptr = NULL;
-                h0->first_field = FIELD_PICTURE;
+                h0->first_field = FIELD_PICTURE(h);
             } else {
                 if (h0->cur_pic_ptr->frame_num != h->frame_num) {
                     /* This and the previous field had different frame_nums.
@@ -3430,10 +3430,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
             }
         } else {
             /* Frame or first field in a potentially complementary pair */
-            h0->first_field = FIELD_PICTURE;
+            h0->first_field = FIELD_PICTURE(h);
         }
 
-        if (!FIELD_PICTURE || h0->first_field) {
+        if (!FIELD_PICTURE(h) || h0->first_field) {
             if (h264_frame_start(h) < 0) {
                 h0->first_field = 0;
                 return -1;
@@ -4058,8 +4058,8 @@ static void predict_field_decoding_flag(H264Context *h)
  */
 static void decode_finish_row(H264Context *h)
 {
-    int top            = 16 * (h->mb_y      >> FIELD_PICTURE);
-    int pic_height     = 16 *  h->mb_height >> FIELD_PICTURE;
+    int top            = 16 * (h->mb_y      >> FIELD_PICTURE(h));
+    int pic_height     = 16 *  h->mb_height >> FIELD_PICTURE(h);
     int height         =  16      << FRAME_MBAFF(h);
     int deblock_border = (16 + 4) << FRAME_MBAFF(h);
 
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 077202d..66708c0 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -62,7 +62,7 @@
 #define MB_MBAFF(h)    h->mb_mbaff
 #define MB_FIELD(h)    h->mb_field_decoding_flag
 #define FRAME_MBAFF(h) h->mb_aff_frame
-#define FIELD_PICTURE (h->picture_structure != PICT_FRAME)
+#define FIELD_PICTURE(h) (h->picture_structure != PICT_FRAME)
 #define LEFT_MBS 2
 #define LTOP     0
 #define LBOT     1
@@ -71,7 +71,7 @@
 #define MB_MBAFF(h)      0
 #define MB_FIELD(h)      0
 #define FRAME_MBAFF(h)   0
-#define FIELD_PICTURE 0
+#define FIELD_PICTURE(h) 0
 #undef  IS_INTERLACED
 #define IS_INTERLACED(mb_type) 0
 #define LEFT_MBS 1
@@ -79,7 +79,7 @@
 #define LBOT     0
 #define LEFT(i)  0
 #endif
-#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF(h) || FIELD_PICTURE)
+#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF(h) || FIELD_PICTURE(h))
 
 #ifndef CABAC
 #define CABAC h->pps.cabac
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index 258e9ee..8cd60dc 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -1341,7 +1341,7 @@ static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
     }else{
         int mb_xy = h->mb_xy;
         mba_xy = mb_xy - 1;
-        mbb_xy = mb_xy - (h->mb_stride << FIELD_PICTURE);
+        mbb_xy = mb_xy - (h->mb_stride << FIELD_PICTURE(h));
     }
 
     if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP(h->cur_pic.mb_type[mba_xy] ))
diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
index 8756619..bd1cf9c 100644
--- a/libavcodec/h264_loopfilter.c
+++ b/libavcodec/h264_loopfilter.c
@@ -271,7 +271,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
     if( IS_INTRA(mb_type) ) {
         static const int16_t bS4[4] = {4,4,4,4};
         static const int16_t bS3[4] = {3,3,3,3};
-        const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4;
+        const int16_t *bSH = FIELD_PICTURE(h) ? bS3 : bS4;
         if(left_type)
             filter_mb_edgev( &img_y[4*0<<pixel_shift], linesize, bS4, qp0, a, b, h, 1);
         if( IS_8x8DCT(mb_type) ) {
@@ -372,12 +372,12 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
             int step =  1+(mb_type>>24); //IS_8x8DCT(mb_type) ? 2 : 1;
             edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15)); //(mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4;
             h->h264dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache,
-                                              h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE);
+                                              h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE(h));
         }
         if( IS_INTRA(left_type) )
             AV_WN64A(bS[0][0], 0x0004000400040004ULL);
         if( IS_INTRA(top_type) )
-            AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL);
+            AV_WN64A(bS[1][0], FIELD_PICTURE(h) ? 0x0003000300030003ULL : 0x0004000400040004ULL);
 
 #define FILTER(hv,dir,edge,intra)\
         if(AV_RN64A(bS[dir][edge])) {                                   \
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 796f829..c965033 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -122,7 +122,7 @@ int ff_h264_fill_default_ref_list(H264Context *h)
         int cur_poc, list;
         int lens[2];
 
-        if (FIELD_PICTURE)
+        if (FIELD_PICTURE(h))
             cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
         else
             cur_poc = h->cur_pic_ptr->poc;
@@ -191,7 +191,7 @@ static void print_long_term(H264Context *h);
 static int pic_num_extract(H264Context *h, int pic_num, int *structure)
 {
     *structure = h->picture_structure;
-    if (FIELD_PICTURE) {
+    if (FIELD_PICTURE(h)) {
         if (!(pic_num & 1))
             /* opposite field */
             *structure ^= PICT_FRAME;
@@ -291,7 +291,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
                             COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]);
                         }
                         COPY_PICTURE(&h->ref_list[list][index], ref);
-                        if (FIELD_PICTURE) {
+                        if (FIELD_PICTURE(h)) {
                             pic_as_field(&h->ref_list[list][index], pic_structure);
                         }
                     }
@@ -524,11 +524,11 @@ int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
 
     if (h->short_ref_count &&
         h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
-        !(FIELD_PICTURE && !h->first_field && h->cur_pic_ptr->reference)) {
+        !(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {
         mmco[0].opcode        = MMCO_SHORT2UNUSED;
         mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
         mmco_index            = 1;
-        if (FIELD_PICTURE) {
+        if (FIELD_PICTURE(h)) {
             mmco[0].short_pic_num *= 2;
             mmco[1].opcode         = MMCO_SHORT2UNUSED;
             mmco[1].short_pic_num  = mmco[0].short_pic_num + 1;
@@ -751,7 +751,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
                     if (long_arg >= 32 ||
                         (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG &&
                                              long_arg == 16) &&
-                         !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))) {
+                         !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE(h)))) {
                         av_log(h->avctx, AV_LOG_ERROR,
                                "illegal long ref in memory management control "
                                "operation %d\n", opcode);



More information about the ffmpeg-cvslog mailing list