diff --git a/src/cfg.c b/src/cfg.c index a16f29f8..28666437 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -567,6 +567,32 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) return parse_tiles_specification(value, &cfg->tiles_width_count, &cfg->tiles_width_split); else if OPT("tiles-height-split") return parse_tiles_specification(value, &cfg->tiles_height_count, &cfg->tiles_height_split); + else if OPT("tiles") + { + // A simpler interface for setting tiles, accepting only uniform split. + unsigned width = 0; + unsigned height = 0; + if (2 != sscanf(value, "%ux%u", &width, &height)) { + fprintf(stderr, "Wrong format for tiles. Expected \"%%ux%%u\", but got \"%s\"\n", value); + return 0; + } + + if (MAX_TILES_PER_DIM <= width || 0 >= width) { + fprintf(stderr, "Invalid number of tiles (0 < %d <= %d = MAX_TILES_PER_DIM)!\n", width, MAX_TILES_PER_DIM); + return 0; + } + if (MAX_TILES_PER_DIM <= height || 0 >= height) { + fprintf(stderr, "Invalid number of tiles (0 < %d <= %d = MAX_TILES_PER_DIM)!\n", height, MAX_TILES_PER_DIM); + return 0; + } + + // Free split arrays incase they have already been set by another parameter. + FREE_POINTER(cfg->tiles_width_split); + FREE_POINTER(cfg->tiles_height_split); + cfg->tiles_width_count = width; + cfg->tiles_height_count = height; + return 1; + } else if OPT("wpp") cfg->wpp = atobool(value); else if OPT("owf") { diff --git a/src/cli.c b/src/cli.c index 9ca9b987..57fcdb0d 100644 --- a/src/cli.c +++ b/src/cli.c @@ -78,6 +78,7 @@ static const struct option long_options[] = { { "no-aud", no_argument, NULL, 0 }, { "cqmfile", required_argument, NULL, 0 }, { "seek", required_argument, NULL, 0 }, + { "tiles", required_argument, NULL, 0 }, { "tiles-width-split", required_argument, NULL, 0 }, { "tiles-height-split", required_argument, NULL, 0 }, { "wpp", no_argument, NULL, 0 }, @@ -395,6 +396,7 @@ void print_help(void) " Disable threads if set to 0.\n" "\n" " Tiles:\n" + " --tiles x : Split picture into wdith x height uniform tiles.\n" " --tiles-width-split |u :\n" " Specifies a comma separated list of pixel\n" " positions of tiles columns separation coordinates.\n"