]> git.sesse.net Git - x264/blobdiff - encoder/set.c
Check for 16x16 partitions masquerading as smaller ones
[x264] / encoder / set.c
index 1008551a69e40091481bb6674aa6d5fb28c1f5d9..5c00096d253c869848ae13f7b2335d72ee91c2f1 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef _MSC_VER
 #include "config.h"
 #endif
+#include "set.h"
 
 #define bs_write_ue bs_write_ue_big
 
@@ -79,10 +80,10 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
 
     sps->b_qpprime_y_zero_transform_bypass = param->rc.i_rc_method == X264_RC_CQP && param->rc.i_qp_constant == 0;
     if( sps->b_qpprime_y_zero_transform_bypass )
-        sps->i_profile_idc  = PROFILE_HIGH444;
+        sps->i_profile_idc  = PROFILE_HIGH444_PREDICTIVE;
     else if( param->analyse.b_transform_8x8 || param->i_cqm_preset != X264_CQM_FLAT )
         sps->i_profile_idc  = PROFILE_HIGH;
-    else if( param->b_cabac || param->i_bframe > 0 )
+    else if( param->b_cabac || param->i_bframe > 0 || param->b_interlaced )
         sps->i_profile_idc  = PROFILE_MAIN;
     else
         sps->i_profile_idc  = PROFILE_BASELINE;
@@ -132,9 +133,7 @@ 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 = param->analyse.i_direct_8x8_inference
-                              || ! sps->b_frame_mbs_only
-                              || !(param->analyse.inter & X264_ANALYSE_PSUB8x8);
+    sps->b_direct8x8_inference = 1;
 
     sps->crop.i_left   = 0;
     sps->crop.i_top    = 0;
@@ -150,11 +149,11 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
         sps->vui.i_sar_width = param->vui.i_sar_width;
         sps->vui.i_sar_height= param->vui.i_sar_height;
     }
-    
+
     sps->vui.b_overscan_info_present = ( param->vui.i_overscan ? 1 : 0 );
     if( sps->vui.b_overscan_info_present )
         sps->vui.b_overscan_info = ( param->vui.i_overscan == 2 ? 1 : 0 );
-    
+
     sps->vui.b_signal_type_present = 0;
     sps->vui.i_vidformat = ( param->vui.i_vidformat <= 5 ? param->vui.i_vidformat : 5 );
     sps->vui.b_fullrange = ( param->vui.b_fullrange ? 1 : 0 );
@@ -176,7 +175,7 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
     {
         sps->vui.b_signal_type_present = 1;
     }
-    
+
     /* FIXME: not sufficient for interlaced video */
     sps->vui.b_chroma_loc_info_present = ( param->vui.i_chroma_loc ? 1 : 0 );
     if( sps->vui.b_chroma_loc_info_present )
@@ -471,7 +470,7 @@ void x264_pps_write( bs_t *s, x264_pps_t *pps )
     bs_rbsp_trailing( s );
 }
 
-void x264_sei_version_write( x264_t *h, bs_t *s )
+int x264_sei_version_write( x264_t *h, bs_t *s )
 {
     int i;
     // random ID number generated according to ISO-11578
@@ -480,11 +479,15 @@ void x264_sei_version_write( x264_t *h, bs_t *s )
         0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef
     };
     char *opts = x264_param2string( &h->param, 0 );
-    char *version = x264_malloc( 200 + strlen(opts) );
+    char *version;
     int length;
 
+    if( !opts )
+        return -1;
+    CHECKED_MALLOC( version, 200 + strlen( opts ) );
+
     sprintf( version, "x264 - core %d%s - H.264/MPEG-4 AVC codec - "
-             "Copyleft 2003-2008 - http://www.videolan.org/x264.html - options: %s",
+             "Copyleft 2003-2009 - http://www.videolan.org/x264.html - options: %s",
              X264_BUILD, X264_VERSION, opts );
     length = strlen(version)+1+16;
 
@@ -503,6 +506,10 @@ void x264_sei_version_write( x264_t *h, bs_t *s )
 
     x264_free( opts );
     x264_free( version );
+    return 0;
+fail:
+    x264_free( opts );
+    return -1;
 }
 
 const x264_level_t x264_levels[] =
@@ -538,6 +545,7 @@ int x264_validate_levels( x264_t *h, int verbose )
     int ret = 0;
     int mbs = h->sps->i_mb_width * h->sps->i_mb_height;
     int dpb = mbs * 384 * h->sps->i_num_ref_frames;
+    int cbp_factor = h->sps->i_profile_idc==PROFILE_HIGH ? 5 : 4;
 
     const x264_level_t *l = x264_levels;
     while( l->level_idc != 0 && l->level_idc != h->param.i_level_idc )
@@ -556,15 +564,13 @@ int x264_validate_levels( x264_t *h, int verbose )
     if( (val) > (limit) ) \
         ERROR( name " (%d) > level limit (%d)\n", (int)(val), (limit) );
 
-    CHECK( "VBV bitrate", l->bitrate, h->param.rc.i_vbv_max_bitrate );
-    CHECK( "VBV buffer", l->cpb, h->param.rc.i_vbv_buffer_size );
+    CHECK( "VBV bitrate", (l->bitrate * cbp_factor) / 4, h->param.rc.i_vbv_max_bitrate );
+    CHECK( "VBV buffer", (l->cpb * cbp_factor) / 4, h->param.rc.i_vbv_buffer_size );
     CHECK( "MV range", l->mv_range, h->param.analyse.i_mv_range );
     CHECK( "interlaced", !l->frame_only, h->param.b_interlaced );
 
     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 )
-        ERROR( "direct 8x8 inference (0) < level requirement (1)\n" );
 
     /* TODO check the rest of the limits */
     return ret;