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" ) )