]> git.sesse.net Git - x264/commitdiff
MBAFF: Save interlace decision for all macroblocks
authorSimon Horlick <simonhorlick@gmail.com>
Tue, 11 Jan 2011 20:05:54 +0000 (20:05 +0000)
committerFiona Glaser <fiona@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 1fe86629c0b3a62604d7fece9dee915e884de6fa..d65c12663f9af7d87937aea7c0390644c0d7b817 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 44129c409c549ebe4129867738bdd7f3fd6607fc..7273f2b327acfc07a33497a010fe0cd2e9b4b11b 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 7670c850caf6893741ff85fc39f167777ef62cdc..4abef19eaa5c9ec0733d1d0dcb9785905d9f414b 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 8f0b82cdc8deea632ebba74d47c89bc623b1d99f..48c3244b9e695a572f7426fa578fd7fab8dd20cc 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 3de70b15c7535c6b469c315f9ee3ae038f402edf..99973f26ab4b8f9be01528c0331fb77c501c9a8a 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 );