From: Loren Merritt Date: Sat, 30 Oct 2010 21:39:50 +0000 (-0700) Subject: Add numeric names for the presets (0==ultrafast ... 9==placebo) X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=fe0808bbf2042c59d688a7f2a8c80d73f3ce7f86;p=x264.git Add numeric names for the presets (0==ultrafast ... 9==placebo) This mapping will of course change if new presets are added in between, but will always be ordered from fastest to slowest. --- diff --git a/common/common.c b/common/common.c index 7c498386..3fe5c96a 100644 --- a/common/common.c +++ b/common/common.c @@ -169,6 +169,11 @@ void x264_param_default( x264_param_t *param ) static int x264_param_apply_preset( x264_param_t *param, const char *preset ) { + char *end; + int i = strtol( preset, &end, 10 ); + if( *end == 0 && i >= 0 && i < sizeof(x264_preset_names)/sizeof(*x264_preset_names)-1 ) + preset = x264_preset_names[i]; + if( !strcasecmp( preset, "ultrafast" ) ) { param->i_frame_reference = 1; diff --git a/x264.h b/x264.h index a1c1a400..0461264b 100644 --- a/x264.h +++ b/x264.h @@ -526,7 +526,13 @@ int x264_param_parse( x264_param_t *, const char *name, const char *value ); * Currently available presets are, ordered from fastest to slowest: */ static const char * const x264_preset_names[] = { "ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo", 0 }; -/* Warning: the speed of these presets scales dramatically. Ultrafast is a full +/* The presets can also be indexed numerically, as in: + * x264_param_default_preset( ¶m, "3", ... ) + * with ultrafast mapping to "0" and placebo mapping to "9". This mapping may + * of course change if new presets are added in between, but will always be + * ordered from fastest to slowest. + * + * Warning: the speed of these presets scales dramatically. Ultrafast is a full * 100 times faster than placebo! * * Currently available tunings are: */