Commit 0b07708c authored by Loren Merritt's avatar Loren Merritt

api addition: x264_param_parse() to set options by name


git-svn-id: svn://svn.videolan.org/x264/trunk@542 df754926-b1dd-0310-bc7b-ec298dee348c
parent 99b8471e
......@@ -136,6 +136,339 @@ void x264_param_default( x264_param_t *param )
param->b_aud = 0;
}
static int parse_enum( const char *arg, const char * const *names, int *dst )
{
int i;
for( i = 0; names[i]; i++ )
if( !strcmp( arg, names[i] ) )
{
*dst = i;
return 0;
}
return -1;
}
static int parse_cqm( const char *str, uint8_t *cqm, int length )
{
int i = 0;
do {
int coef;
if( !sscanf( str, "%d", &coef ) || coef < 1 || coef > 255 )
return -1;
cqm[i++] = coef;
} while( i < length && (str = strchr( str, ',' )) && str++ );
return (i == length) ? 0 : -1;
}
static int atobool( const char *str )
{
if( !strcmp(str, "1") ||
!strcmp(str, "true") ||
!strcmp(str, "yes") )
return 1;
if( !strcmp(str, "0") ||
!strcmp(str, "false") ||
!strcmp(str, "no") )
return 0;
return -1;
}
#define atobool(str) ( (i = atobool(str)) < 0 ? (b_error = 1) : i )
int x264_param_parse( x264_param_t *p, const char *name, const char *value )
{
int b_error = 0;
int i;
if( !name )
return X264_PARAM_BAD_NAME;
if( !value )
return X264_PARAM_BAD_VALUE;
if( value[0] == '=' )
value++;
if( (!strncmp( name, "no-", 3 ) && (i = 3)) ||
(!strncmp( name, "no", 2 ) && (i = 2)) )
{
name += i;
value = atobool(value) ? "false" : "true";
}
#define OPT(STR) else if( !strcmp( name, STR ) )
if(0);
OPT("asm")
p->cpu = atobool(value) ? x264_cpu_detect() : 0;
OPT("threads")
p->i_threads = atoi(value);
OPT("level")
{
if( atof(value) < 6 )
p->i_level_idc = (int)(10*atof(value)+.5);
else
p->i_level_idc = atoi(value);
}
OPT("sar")
{
b_error = ( 2 != sscanf( value, "%d:%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) &&
2 != sscanf( value, "%d/%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) );
}
OPT("overscan")
b_error |= parse_enum( value, x264_overscan_names, &p->vui.i_overscan );
OPT("vidformat")
b_error |= parse_enum( value, x264_vidformat_names, &p->vui.i_vidformat );
OPT("fullrange")
b_error |= parse_enum( value, x264_fullrange_names, &p->vui.b_fullrange );
OPT("colourprim")
b_error |= parse_enum( value, x264_colorprim_names, &p->vui.i_colorprim );
OPT("transfer")
b_error |= parse_enum( value, x264_transfer_names, &p->vui.i_transfer );
OPT("colourmatrix")
b_error |= parse_enum( value, x264_colmatrix_names, &p->vui.i_colmatrix );
OPT("chromaloc")
{
p->vui.i_chroma_loc = atoi(value);
b_error = ( p->vui.i_chroma_loc < 0 || p->vui.i_chroma_loc > 5 );
}
OPT("fps")
{
float fps;
if( sscanf( value, "%d/%d", &p->i_fps_num, &p->i_fps_den ) == 2 )
;
else if( sscanf( value, "%f", &fps ) )
{
p->i_fps_num = (int)(fps * 1000 + .5);
p->i_fps_den = 1000;
}
else
b_error = 1;
}
OPT("ref")
p->i_frame_reference = atoi(value);
OPT("keyint")
{
p->i_keyint_max = atoi(value);
if( p->i_keyint_min > p->i_keyint_max )
p->i_keyint_min = p->i_keyint_max;
}
OPT("min-keyint")
{
p->i_keyint_min = atoi(value);
if( p->i_keyint_max < p->i_keyint_min )
p->i_keyint_max = p->i_keyint_min;
}
OPT("scenecut")
p->i_scenecut_threshold = atoi(value);
OPT("bframes")
p->i_bframe = atoi(value);
OPT("b-adapt")
p->b_bframe_adaptive = atobool(value);
OPT("b-bias")
p->i_bframe_bias = atoi(value);
OPT("b-pyramid")
p->b_bframe_pyramid = atobool(value);
OPT("nf")
p->b_deblocking_filter = 0;
OPT("filter")
{
int count;
if( 0 < (count = sscanf( value, "%d:%d", &p->i_deblocking_filter_alphac0, &p->i_deblocking_filter_beta )) ||
0 < (count = sscanf( value, "%d,%d", &p->i_deblocking_filter_alphac0, &p->i_deblocking_filter_beta )) )
{
p->b_deblocking_filter = 1;
if( count == 1 )
p->i_deblocking_filter_beta = p->i_deblocking_filter_alphac0;
}
else
p->b_deblocking_filter = atobool(value);
}
OPT("cabac")
p->b_cabac = atobool(value);
OPT("cabac-idc")
p->i_cabac_init_idc = atoi(value);
OPT("cqm")
{
if( strstr( value, "flat" ) )
p->i_cqm_preset = X264_CQM_FLAT;
else if( strstr( value, "jvt" ) )
p->i_cqm_preset = X264_CQM_JVT;
else
b_error = 1;
}
OPT("cqmfile")
p->psz_cqm_file = strdup(value);
OPT("cqm4")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_4iy, 16 );
b_error |= parse_cqm( value, p->cqm_4ic, 16 );
b_error |= parse_cqm( value, p->cqm_4py, 16 );
b_error |= parse_cqm( value, p->cqm_4pc, 16 );
}
OPT("cqm8")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_8iy, 64 );
b_error |= parse_cqm( value, p->cqm_8py, 64 );
}
OPT("cqm4i")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_4iy, 16 );
b_error |= parse_cqm( value, p->cqm_4ic, 16 );
}
OPT("cqm4p")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_4py, 16 );
b_error |= parse_cqm( value, p->cqm_4pc, 16 );
}
OPT("cqm4iy")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_4iy, 16 );
}
OPT("cqm4ic")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_4ic, 16 );
}
OPT("cqm4py")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_4py, 16 );
}
OPT("cqm4pc")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_4pc, 16 );
}
OPT("cqm8i")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_8iy, 64 );
}
OPT("cqm8p")
{
p->i_cqm_preset = X264_CQM_CUSTOM;
b_error |= parse_cqm( value, p->cqm_8py, 64 );
}
OPT("log")
p->i_log_level = atoi(value);
OPT("analyse")
{
p->analyse.inter = 0;
if( strstr( value, "none" ) ) p->analyse.inter = 0;
if( strstr( value, "all" ) ) p->analyse.inter = ~0;
if( strstr( value, "i4x4" ) ) p->analyse.inter |= X264_ANALYSE_I4x4;
if( strstr( value, "i8x8" ) ) p->analyse.inter |= X264_ANALYSE_I8x8;
if( strstr( value, "p8x8" ) ) p->analyse.inter |= X264_ANALYSE_PSUB16x16;
if( strstr( value, "p4x4" ) ) p->analyse.inter |= X264_ANALYSE_PSUB8x8;
if( strstr( value, "b8x8" ) ) p->analyse.inter |= X264_ANALYSE_BSUB16x16;
}
OPT("8x8dct")
p->analyse.b_transform_8x8 = atobool(value);
OPT("weightb")
p->analyse.b_weighted_bipred = atobool(value);
OPT("direct")
b_error |= parse_enum( value, x264_direct_pred_names, &p->analyse.i_direct_mv_pred );
OPT("chroma-qp-offset")
p->analyse.i_chroma_qp_offset = atoi(value);
OPT("me")
b_error |= parse_enum( value, x264_motion_est_names, &p->analyse.i_me_method );
OPT("merange")
p->analyse.i_me_range = atoi(value);
OPT("mvrange")
p->analyse.i_mv_range = atoi(value);
OPT("subme")
p->analyse.i_subpel_refine = atoi(value);
OPT("bime")
p->analyse.b_bidir_me = atobool(value);
OPT("chroma-me")
p->analyse.b_chroma_me = atobool(value);
OPT("b-rdo")
p->analyse.b_bframe_rdo = atobool(value);
OPT("mixed-refs")
p->analyse.b_mixed_references = atobool(value);
OPT("trellis")
p->analyse.i_trellis = atoi(value);
OPT("fast-pskip")
p->analyse.b_fast_pskip = atobool(value);
OPT("dct-decimate")
p->analyse.b_dct_decimate = atobool(value);
OPT("nr")
p->analyse.i_noise_reduction = atoi(value);
OPT("bitrate")
{
p->rc.i_bitrate = atoi(value);
p->rc.i_rc_method = X264_RC_ABR;
}
OPT("qp")
{
p->rc.i_qp_constant = atoi(value);
p->rc.i_rc_method = X264_RC_CQP;
}
OPT("crf")
{
p->rc.i_rf_constant = atoi(value);
p->rc.i_rc_method = X264_RC_CRF;
}
OPT("qpmin")
p->rc.i_qp_min = atoi(value);
OPT("qpmax")
p->rc.i_qp_max = atoi(value);
OPT("qpstep")
p->rc.i_qp_step = atoi(value);
OPT("ratetol")
p->rc.f_rate_tolerance = !strncmp("inf", value, 3) ? 1e9 : atof(value);
OPT("vbv-maxrate")
p->rc.i_vbv_max_bitrate = atoi(value);
OPT("vbv-bufsize")
p->rc.i_vbv_buffer_size = atoi(value);
OPT("vbv-init")
p->rc.f_vbv_buffer_init = atof(value);
OPT("ipratio")
p->rc.f_ip_factor = atof(value);
OPT("pbratio")
p->rc.f_pb_factor = atof(value);
OPT("pass")
{
int i = x264_clip3( atoi(value), 0, 3 );
p->rc.b_stat_write = i & 1;
p->rc.b_stat_read = i & 2;
}
OPT("stats")
{
p->rc.psz_stat_in = strdup(value);
p->rc.psz_stat_out = strdup(value);
}
OPT("rceq")
p->rc.psz_rc_eq = strdup(value);
OPT("qcomp")
p->rc.f_qcompress = atof(value);
OPT("qblur")
p->rc.f_qblur = atof(value);
OPT("cplxblur")
p->rc.f_complexity_blur = atof(value);
OPT("zones")
p->rc.psz_zones = strdup(value);
OPT("psnr")
p->analyse.b_psnr = atobool(value);
OPT("aud")
p->b_aud = atobool(value);
OPT("sps-id")
p->i_sps_id = atoi(value);
OPT("repeat-headers")
p->b_repeat_headers = atobool(value);
else
return X264_PARAM_BAD_NAME;
#undef OPT
#undef atobool
return b_error ? X264_PARAM_BAD_VALUE : 0;
}
/****************************************************************************
* x264_log:
****************************************************************************/
......
......@@ -111,13 +111,6 @@ int main( int argc, char **argv )
return Encode( &param, &opt );
}
static const char * const overscan_str[] = { "undef", "show", "crop", NULL };
static const char * const vidformat_str[] = { "component", "pal", "ntsc", "secam", "mac", "undef", NULL };
static const char * const fullrange_str[] = { "off", "on", NULL };
static const char * const colorprim_str[] = { "", "bt709", "undef", "", "bt470m", "bt470bg", "smpte170m", "smpte240m", "film", NULL };
static const char * const transfer_str[] = { "", "bt709", "undef", "", "bt470m", "bt470bg", "smpte170m", "smpte240m", "linear", "log100", "log316", NULL };
static const char * const colmatrix_str[] = { "GBR", "bt709", "undef", "", "fcc", "bt470bg", "smpte170m", "smpte240m", "YCgCo", NULL };
static char const *strtable_lookup( const char * const table[], int index )
{
int i = 0; while( table[i] ) i++;
......@@ -321,41 +314,17 @@ static void Help( x264_param_t *defaults )
defaults->analyse.i_subpel_refine,
defaults->analyse.i_trellis,
defaults->analyse.i_noise_reduction,
strtable_lookup( overscan_str, defaults->vui.i_overscan ),
strtable_lookup( vidformat_str, defaults->vui.i_vidformat ),
strtable_lookup( fullrange_str, defaults->vui.b_fullrange ),
strtable_lookup( colorprim_str, defaults->vui.i_colorprim ),
strtable_lookup( transfer_str, defaults->vui.i_transfer ),
strtable_lookup( colmatrix_str, defaults->vui.i_colmatrix ),
strtable_lookup( x264_overscan_names, defaults->vui.i_overscan ),
strtable_lookup( x264_vidformat_names, defaults->vui.i_vidformat ),
strtable_lookup( x264_fullrange_names, defaults->vui.b_fullrange ),
strtable_lookup( x264_colorprim_names, defaults->vui.i_colorprim ),
strtable_lookup( x264_transfer_names, defaults->vui.i_transfer ),
strtable_lookup( x264_colmatrix_names, defaults->vui.i_colmatrix ),
defaults->vui.i_chroma_loc,
defaults->i_sps_id
);
}
static int parse_enum( const char *arg, const char * const *names, int *dst )
{
int i;
for( i = 0; names[i]; i++ )
if( !strcmp( arg, names[i] ) )
{
*dst = i;
return 0;
}
return -1;
}
static int parse_cqm( const char *str, uint8_t *cqm, int length )
{
int i = 0;
do {
int coef;
if( !sscanf( str, "%d", &coef ) || coef < 1 || coef > 255 )
return -1;
cqm[i++] = coef;
} while( i < length && (str = strchr( str, ',' )) && str++ );
return (i == length) ? 0 : -1;
}
/*****************************************************************************
* Parse:
*****************************************************************************/
......@@ -385,169 +354,109 @@ static int Parse( int argc, char **argv,
p_close_outfile = close_file_bsf;
/* Parse command line options */
opterr = 0; // no error message
for( ;; )
{
int b_error = 0;
int long_options_index;
#define OPT_QPMIN 256
#define OPT_QPMAX 257
#define OPT_QPSTEP 258
#define OPT_IPRATIO 260
#define OPT_PBRATIO 261
#define OPT_RATETOL 262
#define OPT_RCSTATS 264
#define OPT_RCEQ 265
#define OPT_QCOMP 266
#define OPT_NOPSNR 267
#define OPT_QUIET 268
#define OPT_SCENECUT 270
#define OPT_QBLUR 271
#define OPT_CPLXBLUR 272
#define OPT_FRAMES 273
#define OPT_FPS 274
#define OPT_DIRECT 275
#define OPT_LEVEL 276
#define OPT_NOBADAPT 277
#define OPT_BBIAS 278
#define OPT_BPYRAMID 279
#define OPT_CHROMA_QP 280
#define OPT_NO_CHROMA_ME 281
#define OPT_NO_CABAC 282
#define OPT_AUD 283
#define OPT_PROGRESS 284
#define OPT_ME 285
#define OPT_MERANGE 286
#define OPT_VBVMAXRATE 287
#define OPT_VBVBUFSIZE 288
#define OPT_VBVINIT 289
#define OPT_VISUALIZE 290
#define OPT_SEEK 291
#define OPT_ZONES 292
#define OPT_THREADS 293
#define OPT_CQM 294
#define OPT_CQM4 295
#define OPT_CQM4I 296
#define OPT_CQM4IY 297
#define OPT_CQM4IC 298
#define OPT_CQM4P 299
#define OPT_CQM4PY 300
#define OPT_CQM4PC 301
#define OPT_CQM8 302
#define OPT_CQM8I 303
#define OPT_CQM8P 304
#define OPT_CQMFILE 305
#define OPT_SAR 306
#define OPT_OVERSCAN 307
#define OPT_VIDFORMAT 308
#define OPT_FULLRANGE 309
#define OPT_COLOURPRIM 310
#define OPT_TRANSFER 311
#define OPT_COLOURMATRIX 312
#define OPT_CHROMALOC 313
#define OPT_MIXED_REFS 314
#define OPT_CRF 315
#define OPT_B_RDO 316
#define OPT_NO_FAST_PSKIP 317
#define OPT_BIME 318
#define OPT_NR 319
#define OPT_THREAD_INPUT 320
#define OPT_NO_DCT_DECIMATE 321
#define OPT_SPS_ID 322
#define OPT_QPFILE 323
int long_options_index = -1;
#define OPT_FRAMES 256
#define OPT_SEEK 257
#define OPT_QPFILE 258
#define OPT_THREAD_INPUT 259
#define OPT_QUIET 260
#define OPT_PROGRESS 261
#define OPT_VISUALIZE 262
static struct option long_options[] =
{
{ "help", no_argument, NULL, 'h' },
{ "bitrate", required_argument, NULL, 'B' },
{ "bframes", required_argument, NULL, 'b' },
{ "no-b-adapt", no_argument, NULL, OPT_NOBADAPT },
{ "b-bias", required_argument, NULL, OPT_BBIAS },
{ "b-pyramid", no_argument, NULL, OPT_BPYRAMID },
{ "no-b-adapt", no_argument, NULL, 0 },
{ "b-bias", required_argument, NULL, 0 },
{ "b-pyramid", no_argument, NULL, 0 },
{ "min-keyint",required_argument,NULL,'i' },
{ "keyint", required_argument, NULL, 'I' },
{ "scenecut",required_argument, NULL, OPT_SCENECUT },
{ "nf", no_argument, NULL, 'n' },
{ "scenecut",required_argument, NULL, 0 },
{ "nf", no_argument, NULL, 0 },
{ "filter", required_argument, NULL, 'f' },
{ "no-cabac",no_argument, NULL, OPT_NO_CABAC },
{ "no-cabac",no_argument, NULL, 0 },
{ "qp", required_argument, NULL, 'q' },
{ "qpmin", required_argument, NULL, OPT_QPMIN },
{ "qpmax", required_argument, NULL, OPT_QPMAX },
{ "qpstep", required_argument, NULL, OPT_QPSTEP },
{ "crf", required_argument, NULL, OPT_CRF },
{ "qpmin", required_argument, NULL, 0 },
{ "qpmax", required_argument, NULL, 0 },
{ "qpstep", required_argument, NULL, 0 },
{ "crf", required_argument, NULL, 0 },
{ "ref", required_argument, NULL, 'r' },
{ "no-asm", no_argument, NULL, 'C' },
{ "sar", required_argument, NULL, OPT_SAR },
{ "fps", required_argument, NULL, OPT_FPS },
{ "no-asm", no_argument, NULL, 0 },
{ "sar", required_argument, NULL, 0 },
{ "fps", required_argument, NULL, 0 },
{ "frames", required_argument, NULL, OPT_FRAMES },
{ "seek", required_argument, NULL, OPT_SEEK },
{ "output", required_argument, NULL, 'o' },
{ "analyse", required_argument, NULL, 'A' },
{ "direct", required_argument, NULL, OPT_DIRECT },
{ "direct", required_argument, NULL, 0 },
{ "weightb", no_argument, NULL, 'w' },
{ "me", required_argument, NULL, OPT_ME },
{ "merange", required_argument, NULL, OPT_MERANGE },
{ "me", required_argument, NULL, 0 },
{ "merange", required_argument, NULL, 0 },
{ "subme", required_argument, NULL, 'm' },
{ "b-rdo", no_argument, NULL, OPT_B_RDO },
{ "mixed-refs", no_argument, NULL, OPT_MIXED_REFS },
{ "no-chroma-me", no_argument, NULL, OPT_NO_CHROMA_ME },
{ "bime", no_argument, NULL, OPT_BIME },
{ "b-rdo", no_argument, NULL, 0 },
{ "mixed-refs", no_argument, NULL, 0 },
{ "no-chroma-me", no_argument, NULL, 0 },
{ "bime", no_argument, NULL, 0 },
{ "8x8dct", no_argument, NULL, '8' },
{ "trellis", required_argument, NULL, 't' },
{ "no-fast-pskip", no_argument, NULL, OPT_NO_FAST_PSKIP },
{ "no-dct-decimate", no_argument, NULL, OPT_NO_DCT_DECIMATE },
{ "level", required_argument, NULL, OPT_LEVEL },
{ "ratetol", required_argument, NULL, OPT_RATETOL },
{ "vbv-maxrate", required_argument, NULL, OPT_VBVMAXRATE },
{ "vbv-bufsize", required_argument, NULL, OPT_VBVBUFSIZE },
{ "vbv-init", required_argument,NULL, OPT_VBVINIT },
{ "ipratio", required_argument, NULL, OPT_IPRATIO },
{ "pbratio", required_argument, NULL, OPT_PBRATIO },
{ "chroma-qp-offset", required_argument, NULL, OPT_CHROMA_QP },
{ "no-fast-pskip", no_argument, NULL, 0 },
{ "no-dct-decimate", no_argument, NULL, 0 },
{ "level", required_argument, NULL, 0 },
{ "ratetol", required_argument, NULL, 0 },
{ "vbv-maxrate", required_argument, NULL, 0 },
{ "vbv-bufsize", required_argument, NULL, 0 },
{ "vbv-init", required_argument,NULL, 0 },
{ "ipratio", required_argument, NULL, 0 },
{ "pbratio", required_argument, NULL, 0 },
{ "chroma-qp-offset", required_argument, NULL, 0 },
{ "pass", required_argument, NULL, 'p' },
{ "stats", required_argument, NULL, OPT_RCSTATS },
{ "rceq", required_argument, NULL, OPT_RCEQ },
{ "qcomp", required_argument, NULL, OPT_QCOMP },
{ "qblur", required_argument, NULL, OPT_QBLUR },
{ "cplxblur",required_argument, NULL, OPT_CPLXBLUR },
{ "zones", required_argument, NULL, OPT_ZONES },
{ "stats", required_argument, NULL, 0 },
{ "rceq", required_argument, NULL, 0 },
{ "qcomp", required_argument, NULL, 0 },
{ "qblur", required_argument, NULL, 0 },
{ "cplxblur",required_argument, NULL, 0 },
{ "zones", required_argument, NULL, 0 },
{ "qpfile", required_argument, NULL, OPT_QPFILE },
{ "threads", required_argument, NULL, OPT_THREADS },
{ "threads", required_argument, NULL, 0 },
{ "thread-input", no_argument, NULL, OPT_THREAD_INPUT },
{ "no-psnr", no_argument, NULL, OPT_NOPSNR },
{ "no-psnr", no_argument, NULL, 0 },
{ "quiet", no_argument, NULL, OPT_QUIET },
{ "verbose", no_argument, NULL, 'v' },
{ "progress",no_argument, NULL, OPT_PROGRESS },
{ "visualize",no_argument, NULL, OPT_VISUALIZE },
{ "sps-id", required_argument, NULL, OPT_SPS_ID },
{ "aud", no_argument, NULL, OPT_AUD },
{ "nr", required_argument, NULL, OPT_NR },
{ "cqm", required_argument, NULL, OPT_CQM },
{ "cqmfile", required_argument, NULL, OPT_CQMFILE },
{ "cqm4", required_argument, NULL, OPT_CQM4 },
{ "cqm4i", required_argument, NULL, OPT_CQM4I },
{ "cqm4iy", required_argument, NULL, OPT_CQM4IY },
{ "cqm4ic", required_argument, NULL, OPT_CQM4IC },
{ "cqm4p", required_argument, NULL, OPT_CQM4P },
{ "cqm4py", required_argument, NULL, OPT_CQM4PY },
{ "cqm4pc", required_argument, NULL, OPT_CQM4PC },
{ "cqm8", required_argument, NULL, OPT_CQM8 },
{ "cqm8i", required_argument, NULL, OPT_CQM8I },
{ "cqm8p", required_argument, NULL, OPT_CQM8P },
{ "overscan", required_argument, NULL, OPT_OVERSCAN },
{ "videoformat", required_argument, NULL, OPT_VIDFORMAT },
{ "fullrange", required_argument, NULL, OPT_FULLRANGE },
{ "colorprim", required_argument, NULL, OPT_COLOURPRIM },
{ "transfer", required_argument, NULL, OPT_TRANSFER },
{ "colormatrix", required_argument, NULL, OPT_COLOURMATRIX },
{ "chromaloc", required_argument, NULL, OPT_CHROMALOC },
{ "sps-id", required_argument, NULL, 0 },
{ "aud", no_argument, NULL, 0 },
{ "nr", required_argument, NULL, 0 },
{ "cqm", required_argument, NULL, 0 },
{ "cqmfile", required_argument, NULL, 0 },
{ "cqm4", required_argument, NULL, 0 },
{ "cqm4i", required_argument, NULL, 0 },
{ "cqm4iy", required_argument, NULL, 0 },
{ "cqm4ic", required_argument, NULL, 0 },
{ "cqm4p", required_argument, NULL, 0 },
{ "cqm4py", required_argument, NULL, 0 },
{ "cqm4pc", required_argument, NULL, 0 },
{ "cqm8", required_argument, NULL, 0 },
{ "cqm8i", required_argument, NULL, 0 },
{ "cqm8p", required_argument, NULL, 0 },
{ "overscan", required_argument, NULL, 0 },
{ "videoformat", required_argument, NULL, 0 },
{ "fullrange", required_argument, NULL, 0 },
{ "colorprim", required_argument, NULL, 0 },
{ "transfer", required_argument, NULL, 0 },
{ "colormatrix", required_argument, NULL, 0 },
{ "chromaloc", required_argument, NULL, 0 },
{0, 0, 0, 0}
};
int c;
c = getopt_long( argc, argv, "hi:I:b:r:cxB:q:f:o:A:m:p:t:vw8",
long_options, &long_options_index);
int c = getopt_long( argc, argv, "8A:B:b:f:hI:i:m:o:p:q:r:t:vw",
long_options, &long_options_index);
if( c == -1 )
{
......@@ -559,78 +468,6 @@ static int Parse( int argc, char **argv,
case 'h':
Help( &defaults );
return -1;
case 0:
break;
case 'B':
param->rc.i_bitrate = atol( optarg );
param->rc.i_rc_method = X264_RC_ABR;
break;
case OPT_CRF:
param->rc.i_rf_constant = atol( optarg );
param->rc.i_rc_method = X264_RC_CRF;
break;
case 'b':
param->i_bframe = atol( optarg );
break;
case OPT_NOBADAPT:
param->b_bframe_adaptive = 0;
break;
case OPT_BBIAS:
param->i_bframe_bias = atol( optarg );
break;
case OPT_BPYRAMID:
param->b_bframe_pyramid = 1;
break;
case 'i':
param->i_keyint_min = atol( optarg );
if( param->i_keyint_max < param->i_keyint_min )
param->i_keyint_max = param->i_keyint_min;
break;
case 'I':
param->i_keyint_max = atol( optarg );
if( param->i_keyint_min > param->i_keyint_max )
param->i_keyint_min = param->i_keyint_max;
break;
case OPT_SCENECUT:
param->i_scenecut_threshold = atol( optarg );
break;
case 'n':
param->b_deblocking_filter = 0;
break;
case 'f':
{
char *p = strchr( optarg, ':' );
if( !p ) p = strchr( optarg, ',' );
param->i_deblocking_filter_alphac0 = atoi( optarg );
param->i_deblocking_filter_beta = p ? atoi( p+1 ) : param->i_deblocking_filter_alphac0;
break;
}
case 'q':
param->rc.i_qp_constant = atoi( optarg );
param->rc.i_rc_method = X264_RC_CQP;
break;
case OPT_QPMIN:
param->rc.i_qp_min = atoi( optarg );
break;
case OPT_QPMAX:
param->rc.i_qp_max = atoi( optarg );
break;
case OPT_QPSTEP:
param->rc.i_qp_step = atoi( optarg );
break;
case 'r':
param->i_frame_reference = atoi( optarg );
break;
case OPT_NO_CABAC:
param->b_cabac = 0;
break;
case 'x':
opt->b_decompress = 1;
break;
case 'C':
param->cpu = 0;
break;
case OPT_FRAMES: