[x264-devel] [PATCH] set a valid value in direct_8x8_inference_flag

Loïc Le Loarer lll+vlc at m4x.org
Thu May 11 19:44:55 CEST 2006


Hi,

This patch avoid to produce invalid streams by enforcing the level
restrictions on direct_8x8_inference_flag value. It also allows the
application to ask for a given value of direct_8x8_inference_flag.

Is it OK for you ?

Best regards.

-- 
Loïc

"heaven is not a place, it's a feeling"
-------------- next part --------------
Index: encoder/encoder.c
===================================================================
--- encoder/encoder.c	(revision 522)
+++ encoder/encoder.c	(working copy)
@@ -427,6 +427,23 @@
             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);
+        /* Validate direct_8x8_inference_flag: */
+        if( -1 == h->param.i_direct_8x8_inference_flag )
+        {
+            /* The flag isn't forced, set it to 0 if the level doesn't
+             * limit it to 1 and it it possible to generate P macroblocks
+             * with partitions smaller than 8x8 */
+            h->param.i_direct_8x8_inference_flag = l->direct8x8 ? 1 : !(h->param.analyse.inter & X264_ANALYSE_PSUB8x8);
+        }
+        else
+        {
+            /* if the level limits this flag to 1, check it isn't forced to 0 */
+            if (h->param.i_direct_8x8_inference_flag < l->direct8x8)
+            {
+                x264_log( h, X264_LOG_ERROR, "invalid direct_8x8_inference_flag %d for level %d\n", h->param.i_direct_8x8_inference_flag, h->param.i_level_idc );
+                return -1;
+            }
+        }
     }
 
     if( h->param.rc.f_qblur < 0 )
Index: encoder/set.c
===================================================================
--- encoder/set.c	(revision 522)
+++ encoder/set.c	(working copy)
@@ -127,13 +127,7 @@
     sps->i_mb_height= ( param->i_height + 15 )/ 16;
     sps->b_frame_mbs_only = 1;
     sps->b_mb_adaptive_frame_field = 0;
-    sps->b_direct8x8_inference = 0;
-    if( sps->b_frame_mbs_only == 0 ||
-        !(param->analyse.inter & X264_ANALYSE_PSUB8x8) )
-    {
-        sps->b_direct8x8_inference = 1;
-    }
-
+    sps->b_direct8x8_inference = param->i_direct_8x8_inference_flag;
     sps->crop.i_left   = 0;
     sps->crop.i_top    = 0;
     sps->crop.i_right  = (- param->i_width)  & 15;
Index: common/common.c
===================================================================
--- common/common.c	(revision 522)
+++ common/common.c	(working copy)
@@ -72,6 +72,7 @@
     param->b_bframe_adaptive = 1;
     param->i_bframe_bias = 0;
     param->b_bframe_pyramid = 0;
+    param->i_direct_8x8_inference_flag = -1;
 
     param->b_deblocking_filter = 1;
     param->i_deblocking_filter_alphac0 = 0;
@@ -485,10 +486,10 @@
     s += sprintf( s, " bframes=%d", p->i_bframe );
     if( p->i_bframe )
     {
-        s += sprintf( s, " b_pyramid=%d b_adapt=%d b_bias=%d direct=%d wpredb=%d bime=%d",
+        s += sprintf( s, " b_pyramid=%d b_adapt=%d b_bias=%d direct=%d d8x8=%d wpredb=%d bime=%d",
                       p->b_bframe_pyramid, p->b_bframe_adaptive, p->i_bframe_bias,
-                      p->analyse.i_direct_mv_pred, p->analyse.b_weighted_bipred,
-                      p->analyse.b_bidir_me );
+                      p->analyse.i_direct_mv_pred, p->i_direct_8x8_inference_flag,
+                      p->analyse.b_weighted_bipred, p->analyse.b_bidir_me );
     }
 
     s += sprintf( s, " keyint=%d keyint_min=%d scenecut=%d",
Index: x264.h
===================================================================
--- x264.h	(revision 522)
+++ x264.h	(working copy)
@@ -159,6 +159,7 @@
     int         b_bframe_adaptive;
     int         i_bframe_bias;
     int         b_bframe_pyramid;   /* Keep some B-frames as references */
+    int         i_direct_8x8_inference_flag; /* Use direct_8x8_inference_flag in SPS: (-1: 0 if possible according to level and partition mode) */
 
     int         b_deblocking_filter;
     int         i_deblocking_filter_alphac0;    /* [-6, 6] -6 light filter, 6 strong */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.videolan.org/pipermail/x264-devel/attachments/20060511/55c0ef90/attachment.pgp 


More information about the x264-devel mailing list