diff --git a/src/config.c b/src/config.c
index ce4a1a42..32984907 100644
--- a/src/config.c
+++ b/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;
+}
diff --git a/src/config.h b/src/config.h
index 8bb1074d..13e20f72 100644
--- a/src/config.h
+++ b/src/config.h
@@ -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
diff --git a/src/encmain.c b/src/encmain.c
index bff01674..5f86cd59 100644
--- a/src/encmain.c
+++ b/src/encmain.c
@@ -88,11 +88,12 @@ int main(int argc, char *argv[])
fprintf(stderr,
"Usage:\n"
- "kvazaar -i -w -h -o