From: Simon Horlick Date: Tue, 11 Jan 2011 20:05:54 +0000 (+0000) Subject: MBAFF: Save interlace decision for all macroblocks X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=7af78892ec523ae3f0bc5de86dd123f39516ceaa;p=x264.git MBAFF: Save interlace decision for all macroblocks --- diff --git a/common/common.h b/common/common.h index 1fe86629..d65c1266 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 ca905391..eff8ca58 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 38d0bf2d..0e0ab3db 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 24c2af92..569d5443 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 0ca77836..657e2951 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 );