[x264-devel] [PATCH] set constraint_set[01]_flag when possible

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


Hi,

Here is a patch which set the flags constraint_set0_flag and
constraint_set1_flag when possible. This has the advandage of giving
more information on the stream which may help decoders.

I have included the text from the H.264 norm so that in case of
improvement in x264 supported feature, the flags can be corrected
accordingly easily.

Hope this helps adn can be included in x264.

Best regards.

-- 
Loïc
-------------- next part --------------
Index: encoder/set.c
===================================================================
--- encoder/set.c	(revision 522)
+++ encoder/set.c	(working copy)
@@ -88,8 +88,60 @@
         sps->i_profile_idc  = PROFILE_BASELINE;
     sps->i_level_idc = param->i_level_idc;
 
-    sps->b_constraint_set0  = 0;
-    sps->b_constraint_set1  = 0;
+    sps->b_frame_mbs_only = 1;
+
+    /* Set constraint_set0_flag if the BASELINE constraint are fulfilled even if
+     * the profile is not BASELINE, this allows a BASELINE only decoder to decode
+     * the stream */
+    /* Bitstreams conforming to the Baseline profile shall obey the following constraints: */
+    sps->b_constraint_set0  = 1
+        /* - Only I and P slice types may be present. */
+        && (0 == param->i_bframe)
+        /* - NAL unit streams shall not contain nal_unit_type values in the range of 2 to 4, inclusive. */
+        && 1
+        /* - Sequence parameter sets shall have frame_mbs_only_flag equal to 1. */
+        && sps->b_frame_mbs_only
+        /* - The syntax elements chroma_format_idc, bit_depth_luma_minus8, bit_depth_chroma_minus8, qpprime_y_zero_transform_bypass_flag, and seq_scaling_matrix_present_flag shall not be present in sequence parameter sets. */
+        && (sps->i_profile_idc < PROFILE_HIGH)
+        /* - Picture parameter sets shall have weighted_pred_flag and weighted_bipred_idc both equal to 0. */
+        && (0 == param->analyse.b_weighted_bipred)
+        /* - Picture parameter sets shall have entropy_coding_mode_flag equal to 0. */
+        && !param->b_cabac
+        /* - Picture parameter sets shall have num_slice_groups_minus1 in the range of 0 to 7, inclusive. */
+        && 1
+        /* - The syntax elements transform_8x8_mode_flag, pic_scaling_matrix_present_flag, and second_chroma_qp_index_offset shall not be present in picture parameter sets. */
+        && 1 /* already checked by PROFILE_HIGH check upper */
+        /* - The syntax element level_prefix shall not be greater than 15. */
+        && 1 /* x264 doesn't support level_prefix > 15 yet */
+        /* - The level constraints specified for the Baseline profile in subclause A.3 shall be fulfilled. */
+        /* Warning: the constraint on MaxSubMbRectSize is not checked */
+        ;
+
+    /* Set constraint_set1_flag if the MAIN constraint are fulfilled even if
+     * the profile isn't MAIN, this allows MAIN only decoder to decode
+     * the stream and allows a BASELINE/MAIN decoder to decode the stream
+     * more efficiently by doing deblocking on the fly */
+    /* Bitstreams conforming to the Main profile shall obey the following constraints: */
+    sps->b_constraint_set1  = 1
+        /* Only I, P, and B slice types may be present. */
+        && 1
+        /* NAL unit streams shall not contain nal_unit_type values in the range of 2 to 4, inclusive. */
+        && 1
+        /* - The syntax elements chroma_format_idc, bit_depth_luma_minus8, bit_depth_chroma_minus8, qpprime_y_zero_transform_bypass_flag, and seq_scaling_matrix_present_flag shall not be present in sequence parameter sets. */
+        && (sps->i_profile_idc < PROFILE_HIGH)
+        /* Arbitrary slice order is not allowed. */
+        && 1
+        /* Picture parameter sets shall have num_slice_groups_minus1 equal to 0 only. */
+        && 1
+        /* Picture parameter sets shall have redundant_pic_cnt_present_flag equal to 0 only. */
+        && 1
+        /* - The syntax elements transform_8x8_mode_flag, pic_scaling_matrix_present_flag, and second_chroma_qp_index_offset shall not be present in picture parameter sets. */
+        && 1 /* already checked by PROFILE_HIGH check upper */
+        /* - The syntax element level_prefix shall not be greater than 15. */
+        && 1 /* x264 doesn't support level_prefix > 15 yet */
+        /* The level constraints specified for the Main profile in subclause A.3 shall be fulfilled. */
+        ;
+    /* Never set constraint_set2, it is not necessary as not used in real world */
     sps->b_constraint_set2  = 0;
 
     sps->i_log2_max_frame_num = 4;  /* at least 4 */
@@ -125,7 +177,6 @@
     sps->b_gaps_in_frame_num_value_allowed = 0;
     sps->i_mb_width = ( param->i_width + 15 ) / 16;
     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 ||
-------------- 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/f9a736eb/attachment.pgp 


More information about the x264-devel mailing list