[x264-devel] MBAFF: Save interlace decision for all macroblocks

Simon Horlick git at videolan.org
Thu May 12 08:38:57 CEST 2011


x264 | branch: master | Simon Horlick <simonhorlick at gmail.com> | Tue Jan 11 20:05:54 2011 +0000| [7af78892ec523ae3f0bc5de86dd123f39516ceaa] | committer: Jason Garrett-Glaser

MBAFF: Save interlace decision for all macroblocks

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

 common/common.h     |    1 +
 common/frame.c      |    3 +++
 common/frame.h      |    1 +
 common/macroblock.c |    1 +
 encoder/encoder.c   |    8 ++++++++
 5 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/common/common.h b/common/common.h
index 1fe8662..d65c126 100644
--- a/common/common.h
+++ b/common/common.h
@@ -623,6 +623,7 @@ struct x264_t
         int8_t  *mb_transform_size;         /* transform_size_8x8_flag of each mb */
         uint16_t *slice_table;              /* sh->first_mb of the slice that the indexed mb is part of
                                              * NOTE: this will fail on resolutions above 2^16 MBs... */
+        uint8_t *field;
 
          /* buffer for weighted versions of the reference frames */
         pixel *p_weight_buf[X264_REF_MAX];
diff --git a/common/frame.c b/common/frame.c
index ca90539..eff8ca5 100644
--- a/common/frame.c
+++ b/common/frame.c
@@ -145,6 +145,8 @@ x264_frame_t *x264_frame_new( x264_t *h, int b_fdec )
                             frame->i_stride[0] * (frame->i_lines[0] + 2*i_padv) * sizeof(uint16_t) << h->frames.b_have_sub8x8_esa );
             frame->integral = (uint16_t*)frame->buffer[3] + frame->i_stride[0] * i_padv + PADH;
         }
+        if( h->param.b_interlaced )
+            CHECKED_MALLOC( frame->field, i_mb_count * sizeof(uint8_t) );
     }
     else /* fenc frame */
     {
@@ -219,6 +221,7 @@ void x264_frame_delete( x264_frame_t *frame )
         x264_free( frame->i_inv_qscale_factor );
         x264_free( frame->i_row_bits );
         x264_free( frame->f_row_qp );
+        x264_free( frame->field );
         x264_free( frame->mb_type );
         x264_free( frame->mb_partition );
         x264_free( frame->mv[0] );
diff --git a/common/frame.h b/common/frame.h
index 38d0bf2..0e0ab3d 100644
--- a/common/frame.h
+++ b/common/frame.h
@@ -92,6 +92,7 @@ typedef struct x264_frame
     int16_t (*mv[2])[2];
     int16_t (*mv16x16)[2];
     int16_t (*lowres_mvs[2][X264_BFRAME_MAX+1])[2];
+    uint8_t *field;
 
     /* Stored as (lists_used << LOWRES_COST_SHIFT) + (cost).
      * Doesn't need special addressing for intra cost because
diff --git a/common/macroblock.c b/common/macroblock.c
index 24c2af9..569d544 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -371,6 +371,7 @@ void x264_macroblock_slice_init( x264_t *h )
     h->mb.ref[1] = h->fdec->ref[1];
     h->mb.type = h->fdec->mb_type;
     h->mb.partition = h->fdec->mb_partition;
+    h->mb.field = h->fdec->field;
 
     h->fdec->i_ref[0] = h->i_ref[0];
     h->fdec->i_ref[1] = h->i_ref[1];
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 0ca7783..657e295 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -2029,6 +2029,14 @@ static int x264_slice_write( x264_t *h )
         if( i_mb_x == 0 && !h->mb.b_reencode_mb )
             x264_fdec_filter_row( h, i_mb_y, 1 );
 
+        if( h->param.b_interlaced )
+        {
+            if( !(i_mb_y&1) )
+                h->mb.b_interlaced = 1;
+            x264_zigzag_init( h->param.cpu, &h->zigzagf, h->mb.b_interlaced );
+            h->mb.field[mb_xy] = h->mb.b_interlaced;
+        }
+
         /* load cache */
         x264_macroblock_cache_load( h, i_mb_x, i_mb_y );
 



More information about the x264-devel mailing list