MBAFF: Save interlace decision for all macroblocks
authorSimon Horlick <simonhorlick@gmail.com>
Tue, 11 Jan 2011 20:05:54 +0000 (20:05 +0000)
committerJason Garrett-Glaser <jason@x264.com>
Thu, 12 May 2011 06:05:56 +0000 (23:05 -0700)
common/common.h
common/frame.c
common/frame.h
common/macroblock.c
encoder/encoder.c

index 1fe8662..d65c126 100644 (file)
@@ -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];
index ca90539..eff8ca5 100644 (file)
@@ -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] );
index 38d0bf2..0e0ab3d 100644 (file)
@@ -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
index 24c2af9..569d544 100644 (file)
@@ -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];
index 0ca7783..657e295 100644 (file)
@@ -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 );