]> git.videolan.org Git - x264.git/commitdiff
Implement direct temporal + interlaced
authorJason Garrett-Glaser <darkshikari@gmail.com>
Fri, 12 Feb 2010 11:33:54 +0000 (03:33 -0800)
committerJason Garrett-Glaser <darkshikari@gmail.com>
Mon, 15 Feb 2010 08:59:55 +0000 (00:59 -0800)
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
common/macroblock.c
encoder/encoder.c

index 8b1b05a5cd0cc61b5be36f1080406ed7adc6527e..e2e8facb7678df4a1212e942722bdca2e7e71532 100644 (file)
@@ -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;
index 10f09ac96c38edc71c0407747de6395fd5113879..cc9a3fd3680631fb1d2af24cd4f9ecc5cc2183b0 100644 (file)
@@ -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
index d43a75809af56a3ac21f54eed7a3be282df1ce10..9efe88a7ac8acba6aef996683b619dec20e9a50d 100644 (file)
@@ -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" );