]> git.sesse.net Git - x264/commitdiff
Add numeric names for the presets (0==ultrafast ... 9==placebo)
authorLoren Merritt <pengvado@akuvian.org>
Sat, 30 Oct 2010 21:39:50 +0000 (14:39 -0700)
committerFiona Glaser <fiona@x264.com>
Wed, 10 Nov 2010 08:10:57 +0000 (00:10 -0800)
This mapping will of course change if new presets are added in between, but will always be ordered from fastest to slowest.

common/common.c
x264.h

index 7c498386e0d1f6f928e7d6137404bd035afc24bf..3fe5c96af848d05d163d98b46b077fa49617c14b 100644 (file)
@@ -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 cc6784c729f2ea7156bfa27ee0e0f982d2693f4b..cd2fe9cca79bcf9f4e65729ea44873526c97d278 100644 (file)
--- 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( &param, "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: */