summaryrefslogtreecommitdiff
path: root/args.c
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2010-12-17 09:43:39 -0500
committerJohn Koleszar <jkoleszar@google.com>2010-12-17 10:01:05 -0500
commitb0da9b399d8e9129f47c81366902e66823063878 (patch)
tree11bd71c9ebaf7e4a7ba3e17e2075b09d7edd1970 /args.c
parent64baa8df2e3f5cd8036fac9715d3f7d348620fa6 (diff)
downloadlibvpx-b0da9b399d8e9129f47c81366902e66823063878.tar
libvpx-b0da9b399d8e9129f47c81366902e66823063878.tar.gz
libvpx-b0da9b399d8e9129f47c81366902e66823063878.tar.bz2
libvpx-b0da9b399d8e9129f47c81366902e66823063878.zip
Add psnr/ssim tuning option
Add a new encoder control, VP8E_SET_TUNING, to allow the application to inform the encoder that the material will benefit from certain tuning. Expose this control as the --tune option to vpxenc. The args helper is expanded to support enumerated arguments by name or value. Two tunings are provided by this patch, PSNR (default) and SSIM. Activity masking is made dependent on setting --tune=ssim, as the current implementation hurts speed (10%) and PSNR (2.7% avg, 10% peak) too much for it to be a default yet. Change-Id: I110d969381c4805347ff5a0ffaf1a14ca1965257
Diffstat (limited to 'args.c')
-rw-r--r--args.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/args.c b/args.c
index 782929022..7b2cc3a10 100644
--- a/args.c
+++ b/args.c
@@ -135,6 +135,17 @@ void arg_show_usage(FILE *fp, const struct arg_def *const *defs)
def->long_name, long_val);
fprintf(fp, " %-37s\t%s\n", option_text, def->desc);
+
+ if(def->enums)
+ {
+ const struct arg_enum_list *listptr;
+
+ fprintf(fp, " %-37s\t ", "");
+
+ for(listptr = def->enums; listptr->name; listptr++)
+ fprintf(fp, "%s%s", listptr->name,
+ listptr[1].name ? ", " : "\n");
+ }
}
}
@@ -218,3 +229,37 @@ struct vpx_rational arg_parse_rational(const struct arg *arg)
return rat;
}
+
+
+int arg_parse_enum(const struct arg *arg)
+{
+ const struct arg_enum_list *listptr;
+ long int rawval;
+ char *endptr;
+
+ /* First see if the value can be parsed as a raw value */
+ rawval = strtol(arg->val, &endptr, 10);
+ if (arg->val[0] != '\0' && endptr[0] == '\0')
+ {
+ /* Got a raw value, make sure it's valid */
+ for(listptr = arg->def->enums; listptr->name; listptr++)
+ if(listptr->val == rawval)
+ return rawval;
+ }
+
+ /* Next see if it can be parsed as a string */
+ for(listptr = arg->def->enums; listptr->name; listptr++)
+ if(!strcmp(arg->val, listptr->name))
+ return listptr->val;
+
+ die("Option %s: Invalid value '%s'\n", arg->name, arg->val);
+ return 0;
+}
+
+
+int arg_parse_enum_or_int(const struct arg *arg)
+{
+ if(arg->def->enums)
+ return arg_parse_enum(arg);
+ return arg_parse_int(arg);
+}