[x264-devel] commit: Add numeric names for the presets (0==ultrafast ... 9==placebo) ( Loren Merritt )
git at videolan.org
git at videolan.org
Wed Nov 10 10:12:33 CET 2010
x264 | branch: master | Loren Merritt <pengvado at akuvian.org> | Sat Oct 30 14:39:50 2010 -0700| [fe0808bbf2042c59d688a7f2a8c80d73f3ce7f86] | committer: Jason Garrett-Glaser
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.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=fe0808bbf2042c59d688a7f2a8c80d73f3ce7f86
---
common/common.c | 5 +++++
x264.h | 8 +++++++-
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/common/common.c b/common/common.c
index 7c49838..3fe5c96 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 a1c1a40..0461264 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: */
More information about the x264-devel
mailing list