]> git.sesse.net Git - vlc/blobdiff - modules/codec/x264.c
omxil: If OMX_IndexParamVideoInit failed, assume 2 ports with index 0 and 1
[vlc] / modules / codec / x264.c
index feda9590b1d5c01be1544f164a2d5228d501e628..c8178d01ec39d5b6ad81eb0a8720563d74672cd7 100644 (file)
@@ -122,6 +122,10 @@ static void x264_log( void *, int i_level, const char *psz, va_list );
     " - normal: Non-strict (not Blu-ray compatible)\n"\
     )
 
+#define FULLRANGE_TEXT N_("Use fullrange instead of TV colorrange")
+#define FULLRANGE_LONGTEXT N_("TV-range is usually used colorrange, defining this to true " \
+                              "will enable libx264 to use full colorrange on encoding")
+
 #define CABAC_TEXT N_("CABAC")
 #define CABAC_LONGTEXT N_( "CABAC (Context-Adaptive Binary Arithmetic "\
     "Coding). Slightly slows down encoding and decoding, but should save " \
@@ -497,6 +501,9 @@ vlc_module_begin ()
     add_bool( SOUT_CFG_PREFIX "cabac", true, CABAC_TEXT, CABAC_LONGTEXT,
               true )
 
+    add_bool( SOUT_CFG_PREFIX "fullrange", false, FULLRANGE_TEXT, FULLRANGE_LONGTEXT,
+              true )
+
     add_integer( SOUT_CFG_PREFIX "ref", 3, REF_TEXT,
                  REF_LONGTEXT, true )
         change_integer_range( 1, 16 )
@@ -517,7 +524,10 @@ vlc_module_begin ()
 
     add_string( SOUT_CFG_PREFIX "profile", "high", PROFILE_TEXT,
                PROFILE_LONGTEXT, false )
-        change_string_list( x264_profile_names, x264_profile_names )
+        vlc_config_set (VLC_CONFIG_LIST,
+            (sizeof(x264_profile_names) / sizeof (char*)) - 1,
+            x264_profile_names, x264_profile_names);
+
 
     add_bool( SOUT_CFG_PREFIX "interlaced", false, INTERLACED_TEXT, INTERLACED_LONGTEXT,
               true )
@@ -534,7 +544,9 @@ vlc_module_begin ()
 
 #if X264_BUILD >= 89
     add_string( SOUT_CFG_PREFIX "hrd", "none", HRD_TEXT, HRD_TEXT, true )
-        change_string_list( x264_nal_hrd_names, x264_nal_hrd_names )
+        vlc_config_set (VLC_CONFIG_LIST,
+            (sizeof(x264_nal_hrd_names) / sizeof (char*)) - 1,
+            x264_nal_hrd_names, x264_nal_hrd_names);
 #endif
 
 
@@ -720,9 +732,13 @@ vlc_module_begin ()
                 STATS_LONGTEXT, true )
 
     add_string( SOUT_CFG_PREFIX "preset", NULL , PRESET_TEXT , PRESET_TEXT, false )
-        change_string_list( x264_preset_names, x264_preset_names )
+        vlc_config_set (VLC_CONFIG_LIST,
+            (sizeof(x264_preset_names) / sizeof (char*)) - 1,
+            x264_preset_names, x264_preset_names);
     add_string( SOUT_CFG_PREFIX "tune", NULL , TUNE_TEXT, TUNE_TEXT, false )
-        change_string_list( x264_tune_names, x264_tune_names )
+        vlc_config_set (VLC_CONFIG_LIST,
+            (sizeof(x264_tune_names) / sizeof (char*)) - 1,
+            x264_tune_names, x264_tune_names);
 
     add_string( SOUT_CFG_PREFIX "options", NULL, X264_OPTIONS_TEXT,
                 X264_OPTIONS_LONGTEXT, true )
@@ -747,6 +763,7 @@ static const char *const ppsz_sout_options[] = {
     "aq-mode", "aq-strength", "psy-rd", "psy", "profile", "lookahead", "slices",
     "slice-max-size", "slice-max-mbs", "intra-refresh", "mbtree", "hrd",
     "tune","preset", "opengop", "bluray-compat", "frame-packing", "options",
+    "fullrange",
     NULL
 };
 
@@ -782,6 +799,7 @@ static int  Open ( vlc_object_t *p_this )
     int i_qmin = 0, i_qmax = 0;
     x264_nal_t    *nal;
     int i, i_nal;
+    bool fullrange = false;
 
     if( p_enc->fmt_out.i_codec != VLC_CODEC_H264 &&
         !p_enc->b_force )
@@ -799,7 +817,8 @@ static int  Open ( vlc_object_t *p_this )
     if( !p_sys )
         return VLC_ENOMEM;
 
-    p_enc->fmt_in.i_codec = VLC_CODEC_I420;
+    fullrange = var_GetBool( p_enc, SOUT_CFG_PREFIX "fullrange" );
+    p_enc->fmt_in.i_codec = fullrange ? VLC_CODEC_J420 : VLC_CODEC_I420;
     p_sys->i_colorspace = X264_CSP_I420;
 #if X264_BUILD >= 118
     char *psz_profile = var_GetString( p_enc, SOUT_CFG_PREFIX "profile" );
@@ -817,17 +836,17 @@ static int  Open ( vlc_object_t *p_this )
 
         if( !strcmp( psz_profile, "high10" ) )
         {
-            p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I420_10L : VLC_CODEC_I420;
+            p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I420_10L : fullrange ? VLC_CODEC_J420 : VLC_CODEC_I420;
             p_sys->i_colorspace = X264_CSP_I420 | mask;
         }
         else if( !strcmp( psz_profile, "high422" ) )
         {
-            p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I422_10L : VLC_CODEC_I422;
+            p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I422_10L : fullrange ? VLC_CODEC_J422 : VLC_CODEC_I422;
             p_sys->i_colorspace = X264_CSP_I422 | mask;
         }
         else if( !strcmp( psz_profile, "high444" ) )
         {
-            p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I444_10L : VLC_CODEC_I444;
+            p_enc->fmt_in.i_codec = mask ? VLC_CODEC_I444_10L : fullrange ? VLC_CODEC_J444 : VLC_CODEC_I444;
             p_sys->i_colorspace = X264_CSP_I444 | mask;
         }
 #ifdef MODULE_NAME_IS_x26410b
@@ -870,6 +889,7 @@ static int  Open ( vlc_object_t *p_this )
     p_sys->param.i_csp = p_sys->i_colorspace;
     p_sys->param.i_width  = p_enc->fmt_in.video.i_width;
     p_sys->param.i_height = p_enc->fmt_in.video.i_height;
+    p_sys->param.vui.b_fullrange = fullrange;
 
     if( fabs(var_GetFloat( p_enc, SOUT_CFG_PREFIX "qcomp" ) - 0.60) > 0.005 )
        p_sys->param.rc.f_qcompress = var_GetFloat( p_enc, SOUT_CFG_PREFIX "qcomp" );
@@ -930,6 +950,8 @@ static int  Open ( vlc_object_t *p_this )
 
     /* max bitrate = average bitrate -> CBR */
     p_sys->param.rc.i_vbv_max_bitrate = var_GetInteger( p_enc, SOUT_CFG_PREFIX "vbv-maxrate" );
+    if( p_sys->param.rc.i_vbv_max_bitrate && p_sys->param.rc.i_rc_method != X264_RC_ABR )
+        p_enc->fmt_out.i_bitrate = p_sys->param.rc.i_vbv_max_bitrate * 1000;
 
 
     if( !var_GetBool( p_enc, SOUT_CFG_PREFIX "mbtree" ) )
@@ -1238,7 +1260,7 @@ static int  Open ( vlc_object_t *p_this )
         p_sys->param.i_fps_den = p_enc->fmt_in.video.i_frame_rate_base;
         p_sys->param.i_timebase_num = 1;
         p_sys->param.i_timebase_den = INT64_C(1000000);
-        p_sys->param.b_vfr_input = 1;
+        p_sys->param.b_vfr_input = 0;
     }
 
     /* Check slice-options */
@@ -1255,7 +1277,7 @@ static int  Open ( vlc_object_t *p_this )
     /* Check if user has given some profile (baseline,main,high) to limit
      * settings, and apply those*/
     psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "profile" );
-    if( psz_val )
+    if( psz_val && *psz_val )
         x264_param_apply_profile( &p_sys->param, psz_val );
     free( psz_val );
 
@@ -1464,7 +1486,7 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict )
     for( i = 0; i < i_nal; i++ )
         i_out += nal[i].i_payload;
 
-    p_block = block_New( p_enc, i_out + p_sys->i_sei_size );
+    p_block = block_Alloc( i_out + p_sys->i_sei_size );
     if( !p_block ) return NULL;
 
     unsigned int i_offset = 0;