mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Move level argument parsing to the correct place and give it initial values
This commit is contained in:
parent
61a31054e1
commit
fb4d0c3cf2
53
src/cfg.c
53
src/cfg.c
|
@ -125,6 +125,9 @@ int kvz_config_init(kvz_config *cfg)
|
|||
|
||||
cfg->optional_key = NULL;
|
||||
|
||||
cfg->level = 62; // hevc level 6.2, the highest
|
||||
cfg->force_level = true;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1109,10 +1112,56 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
|
|||
|
||||
fclose(f);
|
||||
}
|
||||
else if OPT("erp-aqp")
|
||||
else if OPT("erp-aqp") {
|
||||
cfg->erp_aqp = (bool)atobool(value);
|
||||
else
|
||||
}
|
||||
else if (OPT("level") || OPT("force-level")) {
|
||||
if OPT("force-level") {
|
||||
cfg->force_level = true;
|
||||
} else {
|
||||
cfg->force_level = false;
|
||||
}
|
||||
|
||||
unsigned int num_first, num_second, level = 0;
|
||||
int matched_amount = sscanf(value, "%u.%u", &num_first, &num_second);
|
||||
|
||||
if (matched_amount == 2) {
|
||||
// of form x.y
|
||||
level = num_first * 10 + num_second;
|
||||
}
|
||||
else if (matched_amount == 1) {
|
||||
// no dot
|
||||
if (num_first < 10) {
|
||||
// of form x
|
||||
level = num_first * 10;
|
||||
}
|
||||
else {
|
||||
// of form xx
|
||||
level = num_first;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the level has a valid value
|
||||
switch (level)
|
||||
{
|
||||
case 10:
|
||||
case 20: case 21:
|
||||
case 30: case 31:
|
||||
case 40: case 41:
|
||||
case 50: case 51: case 52:
|
||||
case 60: case 61: case 62:
|
||||
// a-ok
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "invalid level value: \"%s\"", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cfg->level = level;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
#undef OPT
|
||||
|
||||
return 1;
|
||||
|
|
40
src/cli.c
40
src/cli.c
|
@ -123,6 +123,7 @@ static const struct option long_options[] = {
|
|||
{ "erp-aqp", no_argument, NULL, 0 },
|
||||
{ "no-erp-aqp", no_argument, NULL, 0 },
|
||||
{ "level", required_argument, NULL, 0 },
|
||||
{ "force-level", required_argument, NULL, 0 },
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -235,45 +236,6 @@ cmdline_opts_t* cmdline_opts_parse(const kvz_api *const api, int argc, char *arg
|
|||
goto done;
|
||||
} else if (!strcmp(name, "loop-input")) {
|
||||
opts->loop_input = true;
|
||||
} else if (!strcmp(name, "level")) {
|
||||
unsigned int num_first, num_second, level = 0;
|
||||
int matched_amount = sscanf(optarg, "%u.%u", &num_first, &num_second);
|
||||
|
||||
if (matched_amount == 2) {
|
||||
// of form x.y
|
||||
level = num_first * 10 + num_second;
|
||||
} else if (matched_amount == 1) {
|
||||
// no dot
|
||||
if (num_first < 10) {
|
||||
// of form x
|
||||
level = num_first * 10;
|
||||
} else {
|
||||
// of form xx
|
||||
level = num_first;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the level has a valid value
|
||||
switch (level)
|
||||
{
|
||||
case 10:
|
||||
case 20: case 21:
|
||||
case 30: case 31:
|
||||
case 40: case 41:
|
||||
case 50: case 51: case 52:
|
||||
case 60: case 61: case 62:
|
||||
// a-ok
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "invalid level value: \"%s\"", optarg);
|
||||
ok = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
fprintf(stderr, "lvl: %u", level);
|
||||
|
||||
opts->level = level;
|
||||
} else if (!api->config_parse(opts->config, name, optarg)) {
|
||||
fprintf(stderr, "invalid argument: %s=%s\n", name, optarg);
|
||||
ok = 0;
|
||||
|
|
|
@ -47,8 +47,6 @@ typedef struct cmdline_opts_t {
|
|||
bool version;
|
||||
/** \brief Whether to loop input */
|
||||
bool loop_input;
|
||||
/* \brief The HEVC level */
|
||||
uint8_t level;
|
||||
} cmdline_opts_t;
|
||||
|
||||
cmdline_opts_t* cmdline_opts_parse(const kvz_api *api, int argc, char *argv[]);
|
||||
|
|
|
@ -351,6 +351,11 @@ typedef struct kvz_config
|
|||
* \brief Use adaptive QP for 360 video with equirectangular projection.
|
||||
*/
|
||||
int32_t erp_aqp;
|
||||
|
||||
/** \brief The HEVC level */
|
||||
uint8_t level;
|
||||
/** \brief Whether we ignore and just warn from all of the errors about the output not conforming to the level's requirements. */
|
||||
uint8_t force_level;
|
||||
} kvz_config;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue