mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Add --input-res CLI parameter.
- Also set default width and height to 0 because it makes no sense to assume dimensions. It's kind of like defaulting to the most common altitude when the altimeter is broken. - Add config_validate to have a place for checks on overall cfg state.
This commit is contained in:
parent
a644848b36
commit
7e507fd615
31
src/config.c
31
src/config.c
|
@ -56,8 +56,8 @@ int config_init(config *cfg)
|
|||
cfg->output = NULL;
|
||||
cfg->debug = NULL;
|
||||
cfg->frames = 0;
|
||||
cfg->width = 320;
|
||||
cfg->height = 240;
|
||||
cfg->width = 0;
|
||||
cfg->height = 0;
|
||||
cfg->qp = 32;
|
||||
cfg->intra_period = 0;
|
||||
cfg->deblock_enable = 1;
|
||||
|
@ -181,6 +181,11 @@ static int config_parse(config *cfg, const char *name, const char *value)
|
|||
cfg->width = atoi(value);
|
||||
OPT("height")
|
||||
cfg->height = atoi(value);
|
||||
OPT("input-res") {
|
||||
if (2 != sscanf(value, "%dx%d", &cfg->width, &cfg->height)) {
|
||||
cfg->width = cfg->height = 0;
|
||||
}
|
||||
}
|
||||
OPT("frames")
|
||||
cfg->frames = atoi(value);
|
||||
OPT("qp")
|
||||
|
@ -276,11 +281,12 @@ int config_read(config *cfg,int argc, char *argv[])
|
|||
{ "output", required_argument, NULL, 'o' },
|
||||
{ "debug", required_argument, NULL, 'd' },
|
||||
{ "width", required_argument, NULL, 'w' },
|
||||
{ "height", required_argument, NULL, 'h' },
|
||||
{ "frames", required_argument, NULL, 'n' },
|
||||
{ "height", required_argument, NULL, 'h' }, // deprecated
|
||||
{ "frames", required_argument, NULL, 'n' }, // deprecated
|
||||
{ "qp", required_argument, NULL, 'q' },
|
||||
{ "period", required_argument, NULL, 'p' },
|
||||
{ "ref", required_argument, NULL, 'r' },
|
||||
{ "input-res", required_argument, NULL, 0 },
|
||||
{ "no-deblock", no_argument, NULL, 0 },
|
||||
{ "deblock", required_argument, NULL, 0 },
|
||||
{ "no-sao", no_argument, NULL, 0 },
|
||||
|
@ -332,3 +338,20 @@ int config_read(config *cfg,int argc, char *argv[])
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief A function that does additional checks after config_init.
|
||||
*
|
||||
* Add checks that don't make sense to have in config_init here.
|
||||
* This should be called when cfg is in it's final state.
|
||||
*
|
||||
* \return 0 if config fails, otherwise 1.
|
||||
*/
|
||||
int config_validate(config *cfg)
|
||||
{
|
||||
if (cfg->width == 0 || cfg->height == 0) {
|
||||
fprintf(stderr, "Input error: one of the dimensions is 0: dims=%dx%d", cfg->width, cfg->height);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -69,5 +69,6 @@ config *config_alloc(void);
|
|||
int config_init(config *cfg);
|
||||
int config_destroy(config *cfg);
|
||||
int config_read(config *cfg,int argc, char *argv[]);
|
||||
int config_validate(config *cfg);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -88,11 +88,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
fprintf(stderr,
|
||||
"Usage:\n"
|
||||
"kvazaar -i <input> -w <width> -h <height> -o <output>\n"
|
||||
"kvazaar -i <input> -w <width> --input-res <width>:<height> -o <output>\n"
|
||||
"\n"
|
||||
"Optional parameters:\n"
|
||||
" -n, --frames <integer> : Number of frames to code [all]\n"
|
||||
" --seek <integer> : First frame to code [0]\n"
|
||||
" --input-res <int>x<int> : Input resolution (width x height)\n"
|
||||
" -q, --qp <integer> : Quantization Parameter [32]\n"
|
||||
" -p, --period <integer> : Period of intra pictures [0]\n"
|
||||
" 0: only first picture is intra\n"
|
||||
|
@ -126,7 +127,12 @@ int main(int argc, char *argv[])
|
|||
" --colormatrix <string> : Specify color matrix setting [\"undef\"]\n"
|
||||
" - undef, bt709, fcc, bt470bg, smpte170m,\n"
|
||||
" smpte240m, GBR, YCgCo, bt2020nc, bt2020c\n"
|
||||
" --chromaloc <integer> : Specify chroma sample location (0 to 5) [0]\n");
|
||||
" --chromaloc <integer> : Specify chroma sample location (0 to 5) [0]\n"
|
||||
"\n"
|
||||
" Deprecated parameters: (might be removed at some point)\n"
|
||||
" Use --input-res:\n"
|
||||
" -w, --width : Width of input in pixels\n"
|
||||
" -h, --height : Height of input in pixels\n");
|
||||
|
||||
if (cfg)
|
||||
config_destroy(cfg);
|
||||
|
@ -134,6 +140,12 @@ int main(int argc, char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Do more validation to make sure the parameters we have make sense.
|
||||
if (!config_validate(cfg)) {
|
||||
config_destroy(cfg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Dig CPU features with cpuid
|
||||
kvz_cpu_cpuid(&ecx,&edx);
|
||||
printf("CPU features enabled: ");
|
||||
|
|
Loading…
Reference in a new issue