Commit 6d5d33d4 authored by Rémi Duraffort's avatar Rémi Duraffort

codec: use var_Get(Integer|Float|String) when applicable.

parent 2987efc5
......@@ -202,7 +202,9 @@ int OpenEncoder( vlc_object_t *p_this )
AVCodec *p_codec;
int i_codec_id, i_cat;
const char *psz_namecodec;
vlc_value_t val;
float f_val;
char *psz_val;
int i_val;
if( !GetFfmpegCodec( p_enc->fmt_out.i_codec, &i_cat, &i_codec_id,
&psz_namecodec ) )
......@@ -306,106 +308,77 @@ int OpenEncoder( vlc_object_t *p_this )
config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );
var_Get( p_enc, ENC_CFG_PREFIX "keyint", &val );
p_sys->i_key_int = val.i_int;
p_sys->i_key_int = var_GetInteger( p_enc, ENC_CFG_PREFIX "keyint" );
p_sys->i_b_frames = var_GetInteger( p_enc, ENC_CFG_PREFIX "bframes" );
p_sys->i_vtolerance = var_GetInteger( p_enc, ENC_CFG_PREFIX "vt" ) * 1000;
p_sys->b_interlace = var_GetBool( p_enc, ENC_CFG_PREFIX "interlace" );
p_sys->b_interlace_me = var_GetBool( p_enc, ENC_CFG_PREFIX "interlace-me" );
p_sys->b_pre_me = var_GetBool( p_enc, ENC_CFG_PREFIX "pre-me" );
p_sys->b_hurry_up = var_GetBool( p_enc, ENC_CFG_PREFIX "hurry-up" );
var_Get( p_enc, ENC_CFG_PREFIX "bframes", &val );
p_sys->i_b_frames = val.i_int;
var_Get( p_enc, ENC_CFG_PREFIX "vt", &val );
p_sys->i_vtolerance = val.i_int * 1000;
var_Get( p_enc, ENC_CFG_PREFIX "interlace", &val );
p_sys->b_interlace = val.b_bool;
var_Get( p_enc, ENC_CFG_PREFIX "interlace-me", &val );
p_sys->b_interlace_me = val.b_bool;
var_Get( p_enc, ENC_CFG_PREFIX "pre-me", &val );
p_sys->b_pre_me = val.b_bool;
var_Get( p_enc, ENC_CFG_PREFIX "hurry-up", &val );
p_sys->b_hurry_up = val.b_bool;
if( p_sys->b_hurry_up )
{
/* hurry up mode needs noise reduction, even small */
p_sys->i_noise_reduction = 1;
}
var_Get( p_enc, ENC_CFG_PREFIX "rc-buffer-size", &val );
p_sys->i_rc_buffer_size = val.i_int;
var_Get( p_enc, ENC_CFG_PREFIX "rc-buffer-aggressivity", &val );
p_sys->f_rc_buffer_aggressivity = val.f_float;
var_Get( p_enc, ENC_CFG_PREFIX "i-quant-factor", &val );
p_sys->f_i_quant_factor = val.f_float;
p_sys->i_rc_buffer_size = var_GetInteger( p_enc, ENC_CFG_PREFIX "rc-buffer-size" );
p_sys->f_rc_buffer_aggressivity = var_GetFloat( p_enc, ENC_CFG_PREFIX "rc-buffer-aggressivity" );
p_sys->f_i_quant_factor = var_GetFloat( p_enc, ENC_CFG_PREFIX "i-quant-factor" );
p_sys->i_noise_reduction = var_GetInteger( p_enc, ENC_CFG_PREFIX "noise-reduction" );
p_sys->b_mpeg4_matrix = var_GetBool( p_enc, ENC_CFG_PREFIX "mpeg4-matrix" );
var_Get( p_enc, ENC_CFG_PREFIX "noise-reduction", &val );
p_sys->i_noise_reduction = val.i_int;
f_val = var_GetFloat( p_enc, ENC_CFG_PREFIX "qscale" );
if( f_val < 0.01 || f_val > 255.0 ) f_val = 0;
p_sys->i_quality = (int)(FF_QP2LAMBDA * f_val + 0.5);
var_Get( p_enc, ENC_CFG_PREFIX "mpeg4-matrix", &val );
p_sys->b_mpeg4_matrix = val.b_bool;
var_Get( p_enc, ENC_CFG_PREFIX "qscale", &val );
if( val.f_float < 0.01 || val.f_float > 255.0 ) val.f_float = 0;
p_sys->i_quality = (int)(FF_QP2LAMBDA * val.f_float + 0.5);
var_Get( p_enc, ENC_CFG_PREFIX "hq", &val );
psz_val = var_GetString( p_enc, ENC_CFG_PREFIX "hq" );
p_sys->i_hq = FF_MB_DECISION_RD;
if( val.psz_string && *val.psz_string )
if( psz_val && *psz_val )
{
if( !strcmp( val.psz_string, "rd" ) )
if( !strcmp( psz_val, "rd" ) )
p_sys->i_hq = FF_MB_DECISION_RD;
else if( !strcmp( val.psz_string, "bits" ) )
else if( !strcmp( psz_val, "bits" ) )
p_sys->i_hq = FF_MB_DECISION_BITS;
else if( !strcmp( val.psz_string, "simple" ) )
else if( !strcmp( psz_val, "simple" ) )
p_sys->i_hq = FF_MB_DECISION_SIMPLE;
else
p_sys->i_hq = FF_MB_DECISION_RD;
}
else
p_sys->i_hq = FF_MB_DECISION_RD;
free( val.psz_string );
var_Get( p_enc, ENC_CFG_PREFIX "qmin", &val );
p_sys->i_qmin = val.i_int;
var_Get( p_enc, ENC_CFG_PREFIX "qmax", &val );
p_sys->i_qmax = val.i_int;
var_Get( p_enc, ENC_CFG_PREFIX "trellis", &val );
p_sys->b_trellis = val.b_bool;
var_Get( p_enc, ENC_CFG_PREFIX "strict", &val );
if( val.i_int < - 1 || val.i_int > 1 ) val.i_int = 0;
p_context->strict_std_compliance = val.i_int;
var_Get( p_enc, ENC_CFG_PREFIX "lumi-masking", &val );
p_sys->f_lumi_masking = val.f_float;
var_Get( p_enc, ENC_CFG_PREFIX "dark-masking", &val );
p_sys->f_dark_masking = val.f_float;
var_Get( p_enc, ENC_CFG_PREFIX "p-masking", &val );
p_sys->f_p_masking = val.f_float;
var_Get( p_enc, ENC_CFG_PREFIX "border-masking", &val );
p_sys->f_border_masking = val.f_float;
var_Get( p_enc, ENC_CFG_PREFIX "luma-elim-threshold", &val );
p_sys->i_luma_elim = val.i_int;
var_Get( p_enc, ENC_CFG_PREFIX "chroma-elim-threshold", &val );
p_sys->i_chroma_elim = val.i_int;
var_Get( p_enc, ENC_CFG_PREFIX "aac-profile", &val );
free( psz_val );
p_sys->i_qmin = var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" );
p_sys->i_qmax = var_GetInteger( p_enc, ENC_CFG_PREFIX "qmax" );
p_sys->b_trellis = var_GetBool( p_enc, ENC_CFG_PREFIX "trellis" );
i_val = var_GetInteger( p_enc, ENC_CFG_PREFIX "strict" );
if( i_val < - 1 || i_val > 1 ) i_val = 0;
p_context->strict_std_compliance = i_val;
p_sys->f_lumi_masking = var_GetFloat( p_enc, ENC_CFG_PREFIX "lumi-masking" );
p_sys->f_dark_masking = var_GetFloat( p_enc, ENC_CFG_PREFIX "dark-masking" );
p_sys->f_p_masking = var_GetFloat( p_enc, ENC_CFG_PREFIX "p-masking" );
p_sys->f_border_masking = var_GetFloat( p_enc, ENC_CFG_PREFIX "border-masking" );
p_sys->i_luma_elim = var_GetInteger( p_enc, ENC_CFG_PREFIX "luma-elim-threshold" );
p_sys->i_chroma_elim = var_GetInteger( p_enc, ENC_CFG_PREFIX "chroma-elim-threshold" );
psz_val = var_GetString( p_enc, ENC_CFG_PREFIX "aac-profile" );
/* ffmpeg uses faac encoder atm, and it has issues with
* other than low-complexity profile, so default to that */
p_sys->i_aac_profile = FF_PROFILE_AAC_LOW;
if( val.psz_string && *val.psz_string )
if( psz_val && *psz_val )
{
if( !strncmp( val.psz_string, "main", 4 ) )
if( !strncmp( psz_val, "main", 4 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_MAIN;
else if( !strncmp( val.psz_string, "low", 3 ) )
else if( !strncmp( psz_val, "low", 3 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_LOW;
#if 0 /* Not supported by FAAC encoder */
else if( !strncmp( val.psz_string, "ssr", 3 ) )
else if( !strncmp( psz_val, "ssr", 3 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_SSR;
#endif
else if( !strncmp( val.psz_string, "ltp", 3 ) )
else if( !strncmp( psz_val, "ltp", 3 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_LTP;
else
{
......@@ -413,7 +386,7 @@ int OpenEncoder( vlc_object_t *p_this )
p_sys->i_aac_profile = FF_PROFILE_AAC_LOW;
}
}
free( val.psz_string );
free( psz_val );
if( p_enc->fmt_in.i_cat == VIDEO_ES )
{
......
......@@ -323,7 +323,6 @@ static int Open( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t *) p_this;
decoder_sys_t *p_sys;
vlc_value_t val;
int i_posx, i_posy;
if( p_dec->fmt_in.i_codec != VLC_CODEC_DVBS )
......@@ -332,10 +331,9 @@ static int Open( vlc_object_t *p_this )
}
p_dec->pf_decode_sub = Decode;
p_sys = p_dec->p_sys = malloc( sizeof(decoder_sys_t) );
p_sys = p_dec->p_sys = calloc( 1, sizeof(decoder_sys_t) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof(decoder_sys_t) );
p_sys->i_pts = (mtime_t) 0;
p_sys->i_id = p_dec->fmt_in.subs.dvb.i_id & 0xFFFF;
......@@ -348,18 +346,10 @@ static int Open( vlc_object_t *p_this )
/* configure for SD res in case DDS is not present */
default_dds_init( p_dec );
var_Create( p_this, DVBSUB_CFG_PREFIX "position",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_this, DVBSUB_CFG_PREFIX "position", &val );
p_sys->i_spu_position = val.i_int;
var_Create( p_this, DVBSUB_CFG_PREFIX "x",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_this, DVBSUB_CFG_PREFIX "x", &val );
i_posx = val.i_int;
var_Create( p_this, DVBSUB_CFG_PREFIX "y",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_this, DVBSUB_CFG_PREFIX "y", &val );
i_posy = val.i_int;
p_sys->i_spu_position = var_CreateGetInteger( p_this,
DVBSUB_CFG_PREFIX "position" );
i_posx = var_CreateGetInteger( p_this, DVBSUB_CFG_PREFIX "x" );
i_posy = var_CreateGetInteger( p_this, DVBSUB_CFG_PREFIX "y" );
/* Check if subpicture position was overridden */
p_sys->b_absolute = true;
......@@ -876,10 +866,9 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s )
#ifdef DEBUG_DVBSUB
msg_Dbg( p_dec, "new region: %i", i_id );
#endif
p_region = *pp_region = malloc( sizeof(dvbsub_region_t) );
p_region = *pp_region = calloc( 1, sizeof(dvbsub_region_t) );
if( !p_region )
return;
memset( p_region, 0, sizeof(dvbsub_region_t) );
p_region->p_object_defs = NULL;
p_region->p_pixbuf = NULL;
p_region->p_next = NULL;
......@@ -1708,7 +1697,6 @@ static int OpenEncoder( vlc_object_t *p_this )
{
encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys;
vlc_value_t val;
if( ( p_enc->fmt_out.i_codec != VLC_CODEC_DVBS ) &&
!p_enc->b_force )
......@@ -1733,12 +1721,8 @@ static int OpenEncoder( vlc_object_t *p_this )
p_sys->i_regions = 0;
p_sys->p_regions = 0;
var_Create( p_this, ENC_CFG_PREFIX "x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_this, ENC_CFG_PREFIX "x", &val );
p_sys->i_offset_x = val.i_int;
var_Create( p_this, ENC_CFG_PREFIX "y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_this, ENC_CFG_PREFIX "y", &val );
p_sys->i_offset_y = val.i_int;
p_sys->i_offset_x = var_CreateGetInteger( p_this, ENC_CFG_PREFIX "x" );
p_sys->i_offset_y = var_CreateGetInteger( p_this, ENC_CFG_PREFIX "y" );
return VLC_SUCCESS;
}
......
......@@ -228,7 +228,6 @@ static int OpenDecoder( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
vlc_value_t val;
switch( p_dec->fmt_in.i_codec )
{
......@@ -312,9 +311,7 @@ static int OpenDecoder( vlc_object_t *p_this )
}
free (psz_charset);
var_Create( p_dec, "subsdec-align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_dec, "subsdec-align", &val );
p_sys->i_align = val.i_int;
p_sys->i_align = var_CreateGetInteger( p_dec, "subsdec-align" );
if( p_dec->fmt_in.i_codec == VLC_CODEC_SSA
&& var_CreateGetBool( p_dec, "subsdec-formatted" ) )
......@@ -685,6 +682,7 @@ static char *CreateHtmlSubtitle( int *pi_align, char *psz_subtitle )
psz_tag[ 0 ] = '\0';
/* */
//Oo + 100 ???
size_t i_buf_size = strlen( psz_subtitle ) + 100;
char *psz_html_start = malloc( i_buf_size );
char *psz_html = psz_html_start;
......
......@@ -171,8 +171,8 @@ static int Open( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t *) p_this;
decoder_sys_t *p_sys = NULL;
vlc_value_t val;
int i;
int i_val;
if( p_dec->fmt_in.i_codec != VLC_CODEC_TELETEXT)
{
......@@ -187,25 +187,21 @@ static int Open( vlc_object_t *p_this )
p_dec->fmt_out.i_codec = 0;
p_sys->i_align = 0;
for ( i = 0; i < 9; i++ )
for ( int i = 0; i < 9; i++ )
p_sys->pi_active_national_set[i] = ppi_national_subsets[1];
var_Create( p_dec, "telx-override-page",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_dec, "telx-override-page", &val );
if( val.i_int == -1 &&
p_dec->fmt_in.subs.teletext.i_magazine != -1 &&
i_val = var_CreateGetInteger( p_dec, "telx-override-page" );
if( i_val == -1 && p_dec->fmt_in.subs.teletext.i_magazine != -1 &&
( p_dec->fmt_in.subs.teletext.i_magazine != 1 ||
p_dec->fmt_in.subs.teletext.i_page != 0 ) ) /* ignore if TS demux wants page 100 (unlikely to be sub) */
{
bool b_val;
p_sys->i_wanted_magazine = p_dec->fmt_in.subs.teletext.i_magazine;
p_sys->i_wanted_page = p_dec->fmt_in.subs.teletext.i_page;
var_Create( p_dec, "telx-french-workaround",
VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Get( p_dec, "telx-french-workaround", &val );
b_val = var_CreateGetBool( p_dec, "telx-french-workaround" );
if( p_sys->i_wanted_page < 100 &&
(val.b_bool || (p_sys->i_wanted_page % 16) >= 10))
(b_val || (p_sys->i_wanted_page % 16) >= 10))
{
/* See http://www.nada.kth.se/~ragge/vdr/ttxtsubs/TROUBLESHOOTING.txt
* paragraph about French channels - they mix up decimal and
......@@ -214,21 +210,19 @@ static int Open( vlc_object_t *p_this )
(p_sys->i_wanted_page % 10);
}
}
else if( val.i_int <= 0 )
else if( i_val <= 0 )
{
p_sys->i_wanted_magazine = -1;
p_sys->i_wanted_page = -1;
}
else
{
p_sys->i_wanted_magazine = val.i_int / 100;
p_sys->i_wanted_page = (((val.i_int % 100) / 10) << 4)
| ((val.i_int % 100) % 10);
p_sys->i_wanted_magazine = i_val / 100;
p_sys->i_wanted_page = (((i_val % 100) / 10) << 4)
|((i_val % 100) % 10);
}
var_Create( p_dec, "telx-ignore-subtitle-flag",
VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Get( p_dec, "telx-ignore-subtitle-flag", &val );
p_sys->b_ignore_sub_flag = val.b_bool;
p_sys->b_ignore_sub_flag = var_CreateGetBool( p_dec,
"telx-ignore-subtitle-flag" );
msg_Dbg( p_dec, "starting telx on magazine %d page %02x flag %d",
p_sys->i_wanted_magazine, p_sys->i_wanted_page,
......
......@@ -605,7 +605,6 @@ static int OpenEncoder( vlc_object_t *p_this )
encoder_sys_t *p_sys;
ogg_packet header;
uint8_t *p_extra;
vlc_value_t val;
int i_quality, i;
if( p_enc->fmt_out.i_codec != VLC_CODEC_THEORA &&
......@@ -625,8 +624,7 @@ static int OpenEncoder( vlc_object_t *p_this )
config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );
var_Get( p_enc, ENC_CFG_PREFIX "quality", &val );
i_quality = val.i_int;
i_quality = var_GetInteger( p_enc, ENC_CFG_PREFIX "quality" );
if( i_quality > 10 ) i_quality = 10;
if( i_quality < 0 ) i_quality = 0;
......
......@@ -129,7 +129,6 @@ static int OpenEncoder( vlc_object_t *p_this )
{
encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys;
vlc_value_t val;
int i_frequency;
if( p_enc->fmt_out.i_codec != VLC_CODEC_MPGA &&
......@@ -216,8 +215,7 @@ static int OpenEncoder( vlc_object_t *p_this )
else
{
twolame_set_num_channels( p_sys->p_twolame, 2 );
var_Get( p_enc, ENC_CFG_PREFIX "mode", &val );
switch ( val.i_int )
switch( var_GetInteger( p_enc, ENC_CFG_PREFIX "mode" ) )
{
case 1:
twolame_set_mode( p_sys->p_twolame, TWOLAME_DUAL_CHANNEL );
......@@ -232,8 +230,8 @@ static int OpenEncoder( vlc_object_t *p_this )
}
}
var_Get( p_enc, ENC_CFG_PREFIX "psy", &val );
twolame_set_psymodel( p_sys->p_twolame, val.i_int );
twolame_set_psymodel( p_sys->p_twolame,
var_GetInteger( p_enc, ENC_CFG_PREFIX "psy" ) );
if ( twolame_init_params( p_sys->p_twolame ) )
{
......
......@@ -786,7 +786,6 @@ static int OpenEncoder( vlc_object_t *p_this )
encoder_sys_t *p_sys;
int i_quality, i_min_bitrate, i_max_bitrate, i;
ogg_packet header[3];
vlc_value_t val;
uint8_t *p_extra;
if( p_enc->fmt_out.i_codec != VLC_CODEC_VORBIS &&
......@@ -806,16 +805,13 @@ static int OpenEncoder( vlc_object_t *p_this )
config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );
var_Get( p_enc, ENC_CFG_PREFIX "quality", &val );
i_quality = val.i_int;
i_quality = var_GetInteger( p_enc, ENC_CFG_PREFIX "quality" );
if( i_quality > 10 ) i_quality = 10;
if( i_quality < 0 ) i_quality = 0;
var_Get( p_enc, ENC_CFG_PREFIX "cbr", &val );
if( val.b_bool ) i_quality = 0;
var_Get( p_enc, ENC_CFG_PREFIX "max-bitrate", &val );
i_max_bitrate = val.i_int;
var_Get( p_enc, ENC_CFG_PREFIX "min-bitrate", &val );
i_min_bitrate = val.i_int;
if( var_GetBool( p_enc, ENC_CFG_PREFIX "cbr" ) ) i_quality = 0;
i_max_bitrate = var_GetInteger( p_enc, ENC_CFG_PREFIX "max-bitrate" );
i_min_bitrate = var_GetInteger( p_enc, ENC_CFG_PREFIX "min-bitrate" );
/* Initialize vorbis encoder */
vorbis_info_init( &p_sys->vi );
......
......@@ -644,7 +644,8 @@ static int Open ( vlc_object_t *p_this )
{
encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys;
vlc_value_t val;
int i_val;
char *psz_val;
int i_qmin = 0, i_qmax = 0;
x264_nal_t *nal;
int i, i_nal;
......@@ -676,8 +677,7 @@ static int Open ( vlc_object_t *p_this )
p_sys->param.i_width = p_enc->fmt_in.video.i_width;
p_sys->param.i_height = p_enc->fmt_in.video.i_height;
var_Get( p_enc, SOUT_CFG_PREFIX "qcomp", &val );
p_sys->param.rc.f_qcompress = val.f_float;
p_sys->param.rc.f_qcompress = var_GetFloat( p_enc, SOUT_CFG_PREFIX "qcomp" );
/* transcode-default bitrate is 0,
* set more to ABR if user specifies bitrate */
......@@ -688,275 +688,249 @@ static int Open ( vlc_object_t *p_this )
}
else /* Set default to CRF */
{
var_Get( p_enc, SOUT_CFG_PREFIX "crf", &val );
if( val.i_int > 0 && val.i_int <= 51 )
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "crf" );
if( i_val > 0 && i_val <= 51 )
{
p_sys->param.rc.f_rf_constant = val.i_int;
p_sys->param.rc.f_rf_constant = i_val;
p_sys->param.rc.i_rc_method = X264_RC_CRF;
}
}
var_Get( p_enc, SOUT_CFG_PREFIX "qpstep", &val );
if( val.i_int >= 0 && val.i_int <= 51 ) p_sys->param.rc.i_qp_step = val.i_int;
var_Get( p_enc, SOUT_CFG_PREFIX "qpmin", &val );
if( val.i_int >= 0 && val.i_int <= 51 )
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "qpstep" );
if( i_val >= 0 && i_val <= 51 ) p_sys->param.rc.i_qp_step = i_val;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "qpmin" );
if( i_val >= 0 && i_val <= 51 )
{
i_qmin = val.i_int;
i_qmin = i_val;
p_sys->param.rc.i_qp_min = i_qmin;
}
var_Get( p_enc, SOUT_CFG_PREFIX "qpmax", &val );
if( val.i_int >= 0 && val.i_int <= 51 )
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "qpmax" );
if( i_val >= 0 && i_val <= 51 )
{
i_qmax = val.i_int;
i_qmax = i_val;
p_sys->param.rc.i_qp_max = i_qmax;
}
var_Get( p_enc, SOUT_CFG_PREFIX "qp", &val );
if( val.i_int >= 0 && val.i_int <= 51 )
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "qp" );
if( i_val >= 0 && i_val <= 51 )
{
if( i_qmin > val.i_int ) i_qmin = val.i_int;
if( i_qmax < val.i_int ) i_qmax = val.i_int;
if( i_qmin > i_val ) i_qmin = i_val;
if( i_qmax < i_val ) i_qmax = i_val;
/* User defined QP-value, so change ratecontrol method */
p_sys->param.rc.i_rc_method = X264_RC_CQP;
p_sys->param.rc.i_qp_constant = val.i_int;
p_sys->param.rc.i_qp_constant = i_val;
p_sys->param.rc.i_qp_min = i_qmin;
p_sys->param.rc.i_qp_max = i_qmax;
}
var_Get( p_enc, SOUT_CFG_PREFIX "ratetol", &val );
p_sys->param.rc.f_rate_tolerance = val.f_float;
var_Get( p_enc, SOUT_CFG_PREFIX "vbv-init", &val );
p_sys->param.rc.f_vbv_buffer_init = val.f_float;
var_Get( p_enc, SOUT_CFG_PREFIX "vbv-bufsize", &val );
p_sys->param.rc.i_vbv_buffer_size = val.i_int;
p_sys->param.rc.f_rate_tolerance = var_GetFloat( p_enc,
SOUT_CFG_PREFIX "ratetol" );
p_sys->param.rc.f_vbv_buffer_init = var_GetFloat( p_enc,
SOUT_CFG_PREFIX "vbv-init" );
p_sys->param.rc.i_vbv_buffer_size = var_GetInteger( p_enc,
SOUT_CFG_PREFIX "vbv-bufsize" );
/* max bitrate = average bitrate -> CBR */
var_Get( p_enc, SOUT_CFG_PREFIX "vbv-maxrate", &val );
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "vbv-maxrate" );
if( !val.i_int && p_sys->param.rc.i_rc_method == X264_RC_ABR )
if( !i_val && p_sys->param.rc.i_rc_method == X264_RC_ABR )
p_sys->param.rc.i_vbv_max_bitrate = p_sys->param.rc.i_bitrate;
else if ( val.i_int )
p_sys->param.rc.i_vbv_max_bitrate = val.i_int;
else if ( i_val )
p_sys->param.rc.i_vbv_max_bitrate = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "cabac", &val );
p_sys->param.b_cabac = val.b_bool;
p_sys->param.b_cabac = var_GetBool( p_enc, SOUT_CFG_PREFIX "cabac" );
/* disable deblocking when nf (no loop filter) is enabled */
var_Get( p_enc, SOUT_CFG_PREFIX "nf", &val );
p_sys->param.b_deblocking_filter = !val.b_bool;
p_sys->param.b_deblocking_filter = !var_GetBool( p_enc, SOUT_CFG_PREFIX "nf" );
var_Get( p_enc, SOUT_CFG_PREFIX "deblock", &val );
if( val.psz_string )
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "deblock" );
if( psz_val )
{
char *p = strchr( val.psz_string, ':' );
p_sys->param.i_deblocking_filter_alphac0 = atoi( val.psz_string );
p_sys->param.i_deblocking_filter_beta = p ? atoi( p+1 ) : p_sys->param.i_deblocking_filter_alphac0;
free( val.psz_string );
char *p = strchr( psz_val, ':' );
p_sys->param.i_deblocking_filter_alphac0 = atoi( psz_val );
p_sys->param.i_deblocking_filter_beta = p ?
atoi( p+1 ) : p_sys->param.i_deblocking_filter_alphac0;
free( psz_val );
}
var_Get( p_enc, SOUT_CFG_PREFIX "psy-rd", &val );
if( val.psz_string )
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "psy-rd" );
if( psz_val )
{
char *p = strchr( val.psz_string, ':' );
p_sys->param.analyse.f_psy_rd = us_atof( val.psz_string );
char *p = strchr( psz_val, ':' );
p_sys->param.analyse.f_psy_rd = us_atof( psz_val );
p_sys->param.analyse.f_psy_trellis = p ? us_atof( p+1 ) : 0;
free( val.psz_string );
free( psz_val );
}
var_Get( p_enc, SOUT_CFG_PREFIX "level", &val );
if( val.psz_string )
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "level" );
if( psz_val )
{
if( us_atof (val.psz_string) < 6 )
p_sys->param.i_level_idc = (int) (10 * us_atof (val.psz_string)
if( us_atof (psz_val) < 6 )
p_sys->param.i_level_idc = (int) (10 * us_atof (psz_val)
+ .5);
else
p_sys->param.i_level_idc = atoi (val.psz_string);
free( val.psz_string );
p_sys->param.i_level_idc = atoi (psz_val);
free( psz_val );
}
var_Get( p_enc, SOUT_CFG_PREFIX "interlaced", &val );
p_sys->param.b_interlaced = val.b_bool;
var_Get( p_enc, SOUT_CFG_PREFIX "ipratio", &val );
p_sys->param.rc.f_ip_factor = val.f_float;
var_Get( p_enc, SOUT_CFG_PREFIX "pbratio", &val );
p_sys->param.rc.f_pb_factor = val.f_float;
var_Get( p_enc, SOUT_CFG_PREFIX "cplxblur", &val );
p_sys->param.rc.f_complexity_blur = val.f_float;
var_Get( p_enc, SOUT_CFG_PREFIX "qblur", &val );
p_sys->param.rc.f_qblur = val.f_float;
p_sys->param.b_interlaced = var_GetBool( p_enc, SOUT_CFG_PREFIX "interlaced" );
p_sys->param.rc.f_ip_factor = var_GetFloat( p_enc, SOUT_CFG_PREFIX "ipratio" );
p_sys->param.rc.f_pb_factor = var_GetFloat( p_enc, SOUT_CFG_PREFIX "pbratio" );
p_sys->param.rc.f_complexity_blur = var_GetFloat( p_enc, SOUT_CFG_PREFIX "cplxblur" );
p_sys->param.rc.f_qblur = var_GetFloat( p_enc, SOUT_CFG_PREFIX "qblur" );
p_sys->param.rc.i_aq_mode = var_GetInteger( p_enc, SOUT_CFG_PREFIX "aq-mode" );
p_sys->param.rc.f_aq_strength = var_GetFloat( p_enc, SOUT_CFG_PREFIX "aq-strength" );
var_Get( p_enc, SOUT_CFG_PREFIX "aq-mode", &val );
p_sys->param.rc.i_aq_mode = val.i_int;
if( var_GetBool( p_enc, SOUT_CFG_PREFIX "verbose" ) )
p_sys->param.i_log_level = X264_LOG_DEBUG;
var_Get( p_enc, SOUT_CFG_PREFIX "aq-strength", &val );
p_sys->param.rc.f_aq_strength = val.f_float;
if( var_GetBool( p_enc, SOUT_CFG_PREFIX "quiet" ) )
p_sys->param.i_log_level = X264_LOG_NONE;
var_Get( p_enc, SOUT_CFG_PREFIX "verbose", &val );
if( val.b_bool ) p_sys->param.i_log_level = X264_LOG_DEBUG;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "sps-id" );
if( i_val >= 0 ) p_sys->param.i_sps_id = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "quiet", &val );
if( val.b_bool ) p_sys->param.i_log_level = X264_LOG_NONE;
if( var_GetBool( p_enc, SOUT_CFG_PREFIX "aud" ) )
p_sys->param.b_aud = true;
var_Get( p_enc, SOUT_CFG_PREFIX "sps-id", &val );
if( val.i_int >= 0 ) p_sys->param.i_sps_id = val.i_int;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "keyint" );
if(( i_val > 0 ) p_sys->param.i_keyint_max = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "aud", &val );
if( val.b_bool ) p_sys->param.b_aud = val.b_bool;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "min-keyint" );
if( i_val > 0 ) p_sys->param.i_keyint_min = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "keyint", &val );
if( val.i_int > 0 ) p_sys->param.i_keyint_max = val.i_int;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "bframes" );
if( i_val >= 0 && i_val <= 16 )
p_sys->param.i_bframe = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "min-keyint", &val );
if( val.i_int > 0 ) p_sys->param.i_keyint_min = val.i_int;
p_sys->param.b_bframe_pyramid = var_GetBool( p_enc, SOUT_CFG_PREFIX "bpyramid" );
var_Get( p_enc, SOUT_CFG_PREFIX "bframes", &val );
if( val.i_int >= 0 && val.i_int <= 16 )
p_sys->param.i_bframe = val.i_int;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "ref" );
if( i_val > 0 && i_val <= 15 )
p_sys->param.i_frame_reference = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "bpyramid", &val );
p_sys->param.b_bframe_pyramid = val.b_bool;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "scenecut" );
if( i_val >= -1 && i_val <= 100 )
p_sys->param.i_scenecut_threshold = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "ref", &val );
if( val.i_int > 0 && val.i_int <= 15 )
p_sys->param.i_frame_reference = val.i_int;
p_sys->param.b_deterministic = var_GetBool( p_enc,
SOUT_CFG_PREFIX "non-deterministic" );
var_Get( p_enc, SOUT_CFG_PREFIX "scenecut", &val );
if( val.i_int >= -1 && val.i_int <= 100 )
p_sys->param.i_scenecut_threshold = val.i_int;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "subme" );
if( i_val >= 1 && i_val <= SUBME_MAX )
p_sys->param.analyse.i_subpel_refine = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "non-deterministic", &val );
p_sys->param.b_deterministic = val.b_bool;
var_Get( p_enc, SOUT_CFG_PREFIX "subme", &val );
if( val.i_int >= 1 && val.i_int <= SUBME_MAX )
p_sys->param.analyse.i_subpel_refine = val.i_int;
var_Get( p_enc, SOUT_CFG_PREFIX "me", &val );
if( !strcmp( val.psz_string, "dia" ) )
//TODO: psz_val == NULL ?
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "me" );
if( !strcmp( psz_val, "dia" ) )
{
p_sys->param.analyse.i_me_method = X264_ME_DIA;
}
else if( !strcmp( val.psz_string, "hex" ) )
else if( !strcmp( psz_val, "hex" ) )
{
p_sys->param.analyse.i_me_method = X264_ME_HEX;
}
else if( !strcmp( val.psz_string, "umh" ) )
else if( !strcmp( psz_val, "umh" ) )
{
p_sys->param.analyse.i_me_method = X264_ME_UMH;
}
else if( !strcmp( val.psz_string, "esa" ) )
else if( !strcmp( psz_val, "esa" ) )
{
p_sys->param.analyse.i_me_method = X264_ME_ESA;
}
else if( !strcmp( val.psz_string, "tesa" ) )
else if( !strcmp( psz_val, "tesa" ) )
{
p_sys->param.analyse.i_me_method = X264_ME_TESA;
}
free( val.psz_string );
var_Get( p_enc, SOUT_CFG_PREFIX "merange", &val );
if( val.i_int >= 0 && val.i_int <= 64 )
p_sys->param.analyse.i_me_range = val.i_int;
free( psz_val );
var_Get( p_enc, SOUT_CFG_PREFIX "mvrange", &val );
p_sys->param.analyse.i_mv_range = val.i_int;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "merange" );
if( i_val >= 0 && i_val <= 64 )
p_sys->param.analyse.i_me_range = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "mvrange-thread", &val );
p_sys->param.analyse.i_mv_range_thread = val.i_int;
p_sys->param.analyse.i_mv_range = var_GetInteger( p_enc,
SOUT_CFG_PREFIX "mvrange" );
p_sys->param.analyse.i_mv_range_thread = var_GetInteger( p_enc,
SOUT_CFG_PREFIX "mvrange-thread" );
var_Get( p_enc, SOUT_CFG_PREFIX "direct", &val );
if( !strcmp( val.psz_string, "none" ) )
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "direct" );
if( !strcmp( psz_val, "none" ) )
{
p_sys->param.analyse.i_direct_mv_pred = X264_DIRECT_PRED_NONE;
}
else if( !strcmp( val.psz_string, "spatial" ) )
else if( !strcmp( psz_val, "spatial" ) )
{
p_sys->param.analyse.i_direct_mv_pred = X264_DIRECT_PRED_SPATIAL;
}
else if( !strcmp( val.psz_string, "temporal" ) )
else if( !strcmp( psz_val, "temporal" ) )
{
p_sys->param.analyse.i_direct_mv_pred = X264_DIRECT_PRED_TEMPORAL;
}
else if( !strcmp( val.psz_string, "auto" ) )
else if( !strcmp( psz_val, "auto" ) )
{
p_sys->param.analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
}
free( val.psz_string );
var_Get( p_enc, SOUT_CFG_PREFIX "psnr", &val );
p_sys->param.analyse.b_psnr = val.b_bool;
var_Get( p_enc, SOUT_CFG_PREFIX "ssim", &val );
p_sys->param.analyse.b_ssim = val.b_bool;
var_Get( p_enc, SOUT_CFG_PREFIX "weightb", &val );
p_sys->param.analyse.b_weighted_bipred = val.b_bool;
var_Get( p_enc, SOUT_CFG_PREFIX "b-adapt", &val );
p_sys->param.i_bframe_adaptive = val.i_int;
var_Get( p_enc, SOUT_CFG_PREFIX "b-bias", &val );
if( val.i_int >= -100 && val.i_int <= 100 )
p_sys->param.i_bframe_bias = val.i_int;
var_Get( p_enc, SOUT_CFG_PREFIX "chroma-me", &val );
p_sys->param.analyse.b_chroma_me = val.b_bool;
var_Get( p_enc, SOUT_CFG_PREFIX "chroma-qp-offset", &val );
p_sys->param.analyse.i_chroma_qp_offset = val.i_int;
free( psz_val );
var_Get( p_enc, SOUT_CFG_PREFIX "mixed-refs", &val );
p_sys->param.analyse.b_mixed_references = val.b_bool;
p_sys->param.analyse.b_psnr = var_GetBool( p_enc, SOUT_CFG_PREFIX "psnr" );
p_sys->param.analyse.b_ssim = var_GetBool( p_enc, SOUT_CFG_PREFIX "ssim" );
p_sys->param.analyse.b_weighted_bipred = var_GetBool( p_enc,
SOUT_CFG_PREFIX "weightb" );
p_sys->param.i_bframe_adaptive = var_GetInteger( p_enc,
SOUT_CFG_PREFIX "b-adapt" );
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "b-bias" );
if( i_val >= -100 && i_val <= 100 )
p_sys->param.i_bframe_bias = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "trellis", &val );
if( val.i_int >= 0 && val.i_int <= 2 )
p_sys->param.analyse.i_trellis = val.i_int;
p_sys->param.analyse.b_chroma_me = var_GetBool( p_enc,
SOUT_CFG_PREFIX "chroma-me" );
p_sys->param.analyse.i_chroma_qp_offset = var_GetInteger( p_enc,
SOUT_CFG_PREFIX "chroma-qp-offset" );
p_sys->param.analyse.b_mixed_references = var_GetBool( p_enc,
SOUT_CFG_PREFIX "mixed-refs" );
var_Get( p_enc, SOUT_CFG_PREFIX "fast-pskip", &val );
p_sys->param.analyse.b_fast_pskip = val.b_bool;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "trellis" );
if( i_val >= 0 && i_val <= 2 )
p_sys->param.analyse.i_trellis = i_val;
p_sys->param.analyse.b_fast_pskip = var_GetBool( p_enc,
SOUT_CFG_PREFIX "fast-pskip" );
var_Get( p_enc, SOUT_CFG_PREFIX "nr", &val );
if( val.i_int >= 0 && val.i_int <= 1000 )
p_sys->param.analyse.i_noise_reduction = val.i_int;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "nr" );
if( i_val >= 0 && i_val <= 1000 )
p_sys->param.analyse.i_noise_reduction = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "dct-decimate", &val );
p_sys->param.analyse.b_dct_decimate = val.b_bool;
p_sys->param.analyse.b_dct_decimate = var_GetBool( p_enc,
SOUT_CFG_PREFIX "dct-decimate" );
var_Get( p_enc, SOUT_CFG_PREFIX "deadzone-inter", &val );
if( val.i_int >= 0 && val.i_int <= 32 )
p_sys->param.analyse.i_luma_deadzone[0] = val.i_int;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "deadzone-inter" );
if( i_val >= 0 && i_val <= 32 )
p_sys->param.analyse.i_luma_deadzone[0] = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "deadzone-intra", &val );
if( val.i_int >= 0 && val.i_int <= 32 )
p_sys->param.analyse.i_luma_deadzone[1] = val.i_int;
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "deadzone-intra" );
if( i_val >= 0 && i_val <= 32 )
p_sys->param.analyse.i_luma_deadzone[1] = i_val;
var_Get( p_enc, SOUT_CFG_PREFIX "asm", &val );
if( !val.b_bool ) p_sys->param.cpu = 0;
if( !var_GetBool( p_enc, SOUT_CFG_PREFIX "asm" ) )
p_sys->param.cpu = 0;
#ifndef X264_ANALYSE_BSUB16x16
# define X264_ANALYSE_BSUB16x16 0
#endif
var_Get( p_enc, SOUT_CFG_PREFIX "partitions", &val );
if( !strcmp( val.psz_string, "none" ) )
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "partitions" );
if( !strcmp( psz_val, "none" ) )
{
p_sys->param.analyse.inter = 0;
}
else if( !strcmp( val.psz_string, "fast" ) )
else if( !strcmp( psz_val, "fast" ) )
{
p_sys->param.analyse.inter = X264_ANALYSE_I4x4;
}
else if( !strcmp( val.psz_string, "normal" ) )
else if( !strcmp( psz_val, "normal" ) )
{
p_sys->param.analyse.inter =
X264_ANALYSE_I4x4 |
......@@ -965,7 +939,7 @@ static int Open ( vlc_object_t *p_this )
p_sys->param.analyse.inter |= X264_ANALYSE_I8x8;
#endif
}
else if( !strcmp( val.psz_string, "slow" ) )
else if( !strcmp( psz_val, "slow" ) )
{
p_sys->param.analyse.inter =
X264_ANALYSE_I4x4 |
......@@ -975,14 +949,14 @@ static int Open ( vlc_object_t *p_this )
p_sys->param.analyse.inter |= X264_ANALYSE_I8x8;
#endif
}
else if( !strcmp( val.psz_string, "all" ) )
else if( !strcmp( psz_val, "all" ) )
{
p_sys->param.analyse.inter = ~0;
}
free( val.psz_string );
free( psz_val );
var_Get( p_enc, SOUT_CFG_PREFIX "8x8dct", &val );
p_sys->param.analyse.b_transform_8x8 = val.b_bool;
p_sys->param.analyse.b_transform_8x8 = var_GetBool( p_enc,
SOUT_CFG_PREFIX "8x8dct" );
if( p_enc->fmt_in.video.i_aspect > 0 )
{
......@@ -1020,24 +994,24 @@ static int Open ( vlc_object_t *p_this )
/* Check if user has given some profile (baseline,main,high) to limit
* settings, and apply those*/
var_Get( p_enc, SOUT_CFG_PREFIX "profile", &val );
if( val.psz_string )
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "profile" );
if( psz_val )
{
if( !strcasecmp( val.psz_string, "baseline" ) )
if( !strcasecmp( psz_val, "baseline" ) )
{
msg_Dbg( p_enc, "Limiting to baseline profile");
p_sys->param.analyse.b_transform_8x8 = 0;
p_sys->param.b_cabac = 0;
p_sys->param.i_bframe = 0;
}
else if (!strcasecmp( val.psz_string, "main" ) )
else if (!strcasecmp( psz_val, "main" ) )
{
msg_Dbg( p_enc, "Limiting to main-profile");
p_sys->param.analyse.b_transform_8x8 = 0;
}
/* high profile don't restrict stuff*/
}
free( val.psz_string );
free( psz_val );
unsigned i_cpu = vlc_CPU();
......@@ -1065,19 +1039,19 @@ static int Open ( vlc_object_t *p_this )
default unless ofcourse transcode threads is explicitly specified.. */
p_sys->param.i_threads = p_enc->i_threads;
var_Get( p_enc, SOUT_CFG_PREFIX "stats", &val );
if( val.psz_string )
psz_val = var_GetString( p_enc, SOUT_CFG_PREFIX "stats" );
if( psz_val )
{
p_sys->param.rc.psz_stat_in =
p_sys->param.rc.psz_stat_out =
p_sys->psz_stat_name = val.psz_string;
p_sys->psz_stat_name = psz_val;
}
var_Get( p_enc, SOUT_CFG_PREFIX "pass", &val );
if( val.i_int > 0 && val.i_int <= 3 )
i_val = var_GetInteger( p_enc, SOUT_CFG_PREFIX "pass" );
if( i_val > 0 && i_val <= 3 )
{
p_sys->param.rc.b_stat_write = val.i_int & 1;
p_sys->param.rc.b_stat_read = val.i_int & 2;
p_sys->param.rc.b_stat_write = i_val & 1;
p_sys->param.rc.b_stat_read = i_val & 2;
}
/* We need to initialize pthreadw32 before we open the encoder,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment