From 6e4e85d6db9c3c0ebf00a8c49f8298c6cfc746d4 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 7 Dec 2022 12:14:00 +0100 Subject: [PATCH] crop: prefer "size" than width/height Added option "size" instead of separate "widht"/"height". Both dimensions need to be entered, anyway, so it is not needed to type more characters than necessary. Width/height param is parsing is left for compatibility (for now). --- src/vo_postprocess/crop.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vo_postprocess/crop.c b/src/vo_postprocess/crop.c index 87d04b84b..b152c3ece 100644 --- a/src/vo_postprocess/crop.c +++ b/src/vo_postprocess/crop.c @@ -50,6 +50,8 @@ #include "video_display.h" #include "vo_postprocess.h" +#define MOD_NAME "[crop] " + struct state_crop { int width; int height; @@ -72,7 +74,7 @@ static void usage(_Bool capture_filter) { TBOLD("height") ", " TBOLD("xoff") " and " TBOLD("yoff") ". Example:\n" - "\t" TBOLD(TRED("%s crop") "[:width=][:height=][:xoff=][:yoff=]") "\n\n", + "\t" TBOLD(TRED("%s crop") "[:size=x][:xoff=][:yoff=]") "\n\n", capture_filter ? "--capture-filter" : "-p"); } @@ -89,7 +91,13 @@ static void * crop_init(const char *config) { char *config_copy = tmp; char *item, *save_ptr; while ((item = strtok_r(config_copy, ":", &save_ptr))) { - if (strncasecmp(item, "width=", strlen("width=")) == 0) { + if (strstr(item, "size=") == item) { + if (strchr(item, 'x') == NULL) { + log_msg(LOG_LEVEL_ERROR, MOD_NAME "Missing height!\n"); + } + s->width = atoi(strchr(item, '=') + 1); + s->height = atoi(strchr(item, 'x') + 1); + } else if (strncasecmp(item, "width=", strlen("width=")) == 0) { s->width = atoi(item + strlen("width=")); } else if (strncasecmp(item, "height=", strlen("height=")) == 0) { s->height = atoi(item + strlen("height="));