From 58fd85453ec62d829663887b960ff7f2fbbc22d1 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Fri, 12 Feb 2010 03:33:54 -0800 Subject: [PATCH] Implement direct temporal + interlaced This was much easier than I expected. It will also be basically useless until TFF/BFF support gets in, since it requires delta_poc_bottom to be set correctly to work well. --- common/common.h | 5 +++-- common/macroblock.c | 8 ++++---- encoder/encoder.c | 5 ----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/common/common.h b/common/common.h index 8b1b05a5..e2e8facb 100644 --- a/common/common.h +++ b/common/common.h @@ -654,11 +654,12 @@ struct x264_t int i_chroma_lambda2_offset; /* B_direct and weighted prediction */ - int16_t dist_scale_factor[16][2]; + int16_t dist_scale_factor_buf[2][16][2]; + int16_t (*dist_scale_factor)[2]; int8_t bipred_weight_buf[2][32][4]; int8_t (*bipred_weight)[4]; /* maps fref1[0]'s ref indices into the current list0 */ -#define map_col_to_list0(col) h->mb.map_col_to_list0[col+2] +#define map_col_to_list0(col) h->mb.map_col_to_list0[(col)+2] int8_t map_col_to_list0[18]; int ref_blind_dupe; /* The index of the blind reference frame duplicate. */ } mb; diff --git a/common/macroblock.c b/common/macroblock.c index 10f09ac9..cc9a3fd3 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -190,7 +190,8 @@ static int x264_mb_predict_mv_direct16x16_temporal( x264_t *h ) const int x8 = i8%2; const int y8 = i8/2; const int i_part_8x8 = i_mb_8x8 + x8 + y8 * h->mb.i_b8_stride; - const int i_ref = map_col_to_list0(h->fref1[0]->ref[0][i_part_8x8]); + const int i_ref1_ref = h->fref1[0]->ref[0][i_part_8x8]; + const int i_ref = (map_col_to_list0(i_ref1_ref>>h->sh.b_mbaff) << h->sh.b_mbaff) + (i_ref1_ref&h->sh.b_mbaff); if( i_ref >= 0 ) { @@ -1238,6 +1239,7 @@ void x264_macroblock_cache_load( x264_t *h, int i_mb_x, int i_mb_y ) if( h->sh.i_type == SLICE_TYPE_B ) { h->mb.bipred_weight = h->mb.bipred_weight_buf[h->mb.b_interlaced&(i_mb_y&1)]; + h->mb.dist_scale_factor = h->mb.dist_scale_factor_buf[h->mb.b_interlaced&(i_mb_y&1)]; if( h->param.b_cabac ) { uint8_t skipbp; @@ -1477,9 +1479,7 @@ void x264_macroblock_bipred_init( x264_t *h ) dist_scale_factor = x264_clip3( (tb * tx + 32) >> 6, -1024, 1023 ); } - // FIXME: will need this if we ever do temporal MV pred with interlaced - if( !h->sh.b_mbaff ) - h->mb.dist_scale_factor[i_ref0][i_ref1] = dist_scale_factor; + h->mb.dist_scale_factor_buf[field][i_ref0][i_ref1] = dist_scale_factor; dist_scale_factor >>= 2; if( h->param.analyse.b_weighted_bipred diff --git a/encoder/encoder.c b/encoder/encoder.c index d43a7580..9efe88a7 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -430,11 +430,6 @@ static int x264_validate_parameters( x264_t *h ) x264_log( h, X264_LOG_WARNING, "interlace + me=esa is not implemented\n" ); h->param.analyse.i_me_method = X264_ME_UMH; } - if( h->param.analyse.i_direct_mv_pred > X264_DIRECT_PRED_SPATIAL ) - { - x264_log( h, X264_LOG_WARNING, "interlace + direct=temporal is not implemented\n" ); - h->param.analyse.i_direct_mv_pred = X264_DIRECT_PRED_SPATIAL; - } if( h->param.analyse.i_weighted_pred > 0 ) { x264_log( h, X264_LOG_WARNING, "interlace + weightp is not implemented\n" ); -- 2.47.3