diff --git a/README.md b/README.md index 608ab02d..4a9f1b37 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,9 @@ http://ultravideo.cs.tut.fi/#encoder for more information. --bitrate : Target bitrate. [0] 0: disable rate-control N: target N bits per second + --preset : Use preset + ultrafast, superfast,veryfast, faster, + fast, medium, slow, slower, veryslow, placebo Video Usability Information: --sar : Specify Sample Aspect Ratio diff --git a/src/cli.c b/src/cli.c index d044262e..ab4ea1c0 100644 --- a/src/cli.c +++ b/src/cli.c @@ -81,6 +81,7 @@ static const struct option long_options[] = { { "gop", required_argument, NULL, 0 }, { "bipred", no_argument, NULL, 0 }, { "bitrate", required_argument, NULL, 0 }, + { "preset", required_argument, NULL, 0 }, {0, 0, 0, 0} }; @@ -307,6 +308,9 @@ void print_help(void) " --bitrate : Target bitrate. [0]\n" " 0: disable rate-control\n" " N: target N bits per second\n" + " --preset : Use preset\n" + " ultrafast, superfast,veryfast, faster,\n" + " fast, medium, slow, slower, veryslow, placebo\n" "\n" " Video Usability Information:\n" " --sar : Specify Sample Aspect Ratio\n" diff --git a/src/config.c b/src/config.c index 6cfbe903..b46d911d 100644 --- a/src/config.c +++ b/src/config.c @@ -278,6 +278,22 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) static const char * const colormatrix_names[] = { "GBR", "bt709", "undef", "", "fcc", "bt470bg", "smpte170m", "smpte240m", "YCgCo", "bt2020nc", "bt2020c", NULL }; + static const char * const preset_values[11][21] = { + { "ultrafast", "subme","0", "rd","1", "transform-skip","0", "pu-depth-intra", "2-3", + "pu-depth-inter","1-3", "sao","0", "rdoq","0", "deblock", "0", "ref", "1", NULL }, + { "superfast", "subme","0", "rd","1", "transform-skip","0", "pu-depth-intra", "2-3", + "pu-depth-inter","1-3", "rdoq","0", "ref", "2", NULL }, + { "veryfast", "subme","0", "rd","1", "pu-depth-intra","1-3", NULL }, + { "faster", "subme","0", "rd","1", NULL }, + { "fast", "subme","0", "rd","1", NULL }, + { "medium", "subme","0", "rd","1", "bipred","1", NULL }, + { "slow", "subme","0", "rd","2", "bipred","1", NULL }, + { "slower", "subme","1", "rd","2", "bipred","1", "me","tz", NULL }, + { "veryslow", "subme","1", "rd","2", "bipred","1", "me","tz", NULL }, + { "placebo", "subme","1", "rd","2", "bipred","1", "me","tz", "full-intra-search","1", "ref", "15", NULL }, + { NULL } + }; + if (!name) return 0; @@ -438,6 +454,30 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) cfg->bipred = atobool(value); else if OPT("bitrate") cfg->target_bitrate = atoi(value); + else if OPT("preset") { + bool preset_found = false; + int preset_line = 0; + int preset_value = 0; + // Find the selected preset from the list + while (preset_values[preset_line][0] != NULL) { + if (!strcmp(value, preset_values[preset_line][0])) { + preset_found = true; + fprintf(stderr, "Using preset %s: ", value); + // Loop all the name and value pairs and push to the config parser + for (preset_value = 1; preset_values[preset_line][preset_value] != NULL; preset_value+=2) { + fprintf(stderr, "--%s=%s ", preset_values[preset_line][preset_value], preset_values[preset_line][preset_value + 1]); + kvz_config_parse(cfg, preset_values[preset_line][preset_value], preset_values[preset_line][preset_value + 1]); + } + fprintf(stderr, "\n"); + break; + } + preset_line++; + } + if (!preset_found) { + fprintf(stderr, "Input error: unknown preset \"%s\"\n", value); + return 0; + } + } else return 0; #undef OPT