]> granicus.if.org Git - libx264/commitdiff
add an option to control direct_8x8_inference_flag, default to enabled.
authorLoren Merritt <pengvado@videolan.org>
Sun, 1 Oct 2006 07:25:01 +0000 (07:25 +0000)
committerLoren Merritt <pengvado@videolan.org>
Sun, 1 Oct 2006 07:25:01 +0000 (07:25 +0000)
slightly faster encoding and decoding of p4x4 + B-frames,
and is needed for strict Levels compliance.

git-svn-id: svn://svn.videolan.org/x264/trunk@573 df754926-b1dd-0310-bc7b-ec298dee348c

common/common.c
encoder/encoder.c
encoder/set.c
x264.c
x264.h

index 4c17c768a701b11f4e737d575b6cb6453a52ee77..79f2b7d8b2e15ebea815588a39ac7d1b952da32d 100644 (file)
@@ -119,6 +119,7 @@ void    x264_param_default( x264_param_t *param )
     param->analyse.i_subpel_refine = 5;
     param->analyse.b_chroma_me = 1;
     param->analyse.i_mv_range = -1; // set from level_idc
+    param->analyse.i_direct_8x8_inference = -1; // set from level_idc
     param->analyse.i_chroma_qp_offset = 0;
     param->analyse.b_fast_pskip = 1;
     param->analyse.b_dct_decimate = 1;
@@ -383,6 +384,8 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
         p->analyse.b_weighted_bipred = atobool(value);
     OPT("direct")
         b_error |= parse_enum( value, x264_direct_pred_names, &p->analyse.i_direct_mv_pred );
+    OPT("direct-8x8")
+        p->analyse.i_direct_8x8_inference = atoi(value);
     OPT("chroma-qp-offset")
         p->analyse.i_chroma_qp_offset = atoi(value);
     OPT("me")
index 620f31391f18da6fe2b3d92750701f3e19bf3aa7..940162a907429ec1ff0e1e8f9df95c0fdb9c2640 100644 (file)
@@ -472,6 +472,8 @@ static int x264_validate_parameters( x264_t *h )
             h->param.analyse.i_mv_range = l->mv_range;
         else
             h->param.analyse.i_mv_range = x264_clip3(h->param.analyse.i_mv_range, 32, 2048);
+        if( h->param.analyse.i_direct_8x8_inference < 0 )
+            h->param.analyse.i_direct_8x8_inference = l->direct8x8;
     }
 
     if( h->param.rc.f_qblur < 0 )
@@ -493,6 +495,7 @@ static int x264_validate_parameters( x264_t *h )
     BOOLIFY( b_deblocking_filter );
     BOOLIFY( b_interlaced );
     BOOLIFY( analyse.b_transform_8x8 );
+    BOOLIFY( analyse.i_direct_8x8_inference );
     BOOLIFY( analyse.b_bidir_me );
     BOOLIFY( analyse.b_chroma_me );
     BOOLIFY( analyse.b_fast_pskip );
index a6b3efd76d19ccae703e204027c34278ca5162bd..dba5571c1ade047098630d3fc59d55c6da23c4ee 100644 (file)
@@ -132,12 +132,9 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
         sps->i_mb_height = ( sps->i_mb_height + 1 ) & ~1;
     sps->b_frame_mbs_only = ! param->b_interlaced;
     sps->b_mb_adaptive_frame_field = param->b_interlaced;
-    sps->b_direct8x8_inference = 0;
-    if( ! sps->b_frame_mbs_only ||
-        !(param->analyse.inter & X264_ANALYSE_PSUB8x8) )
-    {
-        sps->b_direct8x8_inference = 1;
-    }
+    sps->b_direct8x8_inference = param->analyse.i_direct_8x8_inference
+                              || ! sps->b_frame_mbs_only
+                              || !(param->analyse.inter & X264_ANALYSE_PSUB8x8);
 
     sps->crop.i_left   = 0;
     sps->crop.i_top    = 0;
@@ -553,6 +550,8 @@ void x264_validate_levels( x264_t *h )
 
     if( h->param.i_fps_den > 0 )
         CHECK( "MB rate", l->mbps, (int64_t)mbs * h->param.i_fps_num / h->param.i_fps_den );
+    if( h->sps->b_direct8x8_inference < l->direct8x8 )
+        x264_log( h, X264_LOG_WARNING, "direct 8x8 inference (0) < level requirement (1)\n" );
 
     /* TODO check the rest of the limits */
 }
diff --git a/x264.c b/x264.c
index 6dabaeda5b93d9d26ccc8946db9017dc2c596fa1..37be0f13ff38bfd4d5838801a50084173b8493b6 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -209,6 +209,11 @@ static void Help( x264_param_t *defaults, int b_longhelp )
     H0( "      --direct <string>       Direct MV prediction mode [\"%s\"]\n"
         "                                  - none, spatial, temporal, auto\n",
                                        strtable_lookup( x264_direct_pred_names, defaults->analyse.i_direct_mv_pred ) );
+    H1( "      --direct-8x8 <-1|0|1>   Direct prediction size [%d]\n"
+        "                                  -  0: 4x4\n"
+        "                                  -  1: 8x8\n"
+        "                                  - -1: smallest possible according to level\n",
+                                       defaults->analyse.i_direct_8x8_inference );
     H0( "  -w, --weightb               Weighted prediction for B-frames\n" );
     H0( "      --me <string>           Integer pixel motion estimation method [\"%s\"]\n",
                                        strtable_lookup( x264_motion_est_names, defaults->analyse.i_me_method ) );
@@ -374,6 +379,7 @@ static int  Parse( int argc, char **argv,
             { "output",  required_argument, NULL, 'o' },
             { "analyse", required_argument, NULL, 'A' },
             { "direct",  required_argument, NULL, 0 },
+            { "direct-8x8", required_argument, NULL, 0 },
             { "weightb", no_argument,       NULL, 'w' },
             { "me",      required_argument, NULL, 0 },
             { "merange", required_argument, NULL, 0 },
diff --git a/x264.h b/x264.h
index 036afb2f802d60eb796e3675386fb5301ba48e88..816eb2fbb5bac8fa23a0e9ed8f7ef08f3cfc45da 100644 (file)
--- a/x264.h
+++ b/x264.h
@@ -35,7 +35,7 @@
 
 #include <stdarg.h>
 
-#define X264_BUILD 51
+#define X264_BUILD 52
 
 /* x264_t:
  *      opaque handler for decoder and encoder */
@@ -203,11 +203,12 @@ typedef struct
         int          b_transform_8x8;
         int          b_weighted_bipred; /* implicit weighting for B-frames */
         int          i_direct_mv_pred; /* spatial vs temporal mv prediction */
+        int          i_direct_8x8_inference; /* forbid 4x4 direct partitions. -1 = auto, based on level */
         int          i_chroma_qp_offset;
 
         int          i_me_method; /* motion estimation algorithm to use (X264_ME_*) */
         int          i_me_range; /* integer pixel motion estimation search range (from predicted mv) */
-        int          i_mv_range; /* maximum length of a mv (in pixels) */
+        int          i_mv_range; /* maximum length of a mv (in pixels). -1 = auto, based on level */
         int          i_subpel_refine; /* subpixel motion estimation quality */
         int          b_bidir_me; /* jointly optimize both MVs in B-frames */
         int          b_chroma_me; /* chroma ME for subpel and mode decision in P-frames */