Skip to content

Commit 6e4e85d

Browse files
committed
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).
1 parent b61d7dd commit 6e4e85d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/vo_postprocess/crop.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
#include "video_display.h"
5151
#include "vo_postprocess.h"
5252

53+
#define MOD_NAME "[crop] "
54+
5355
struct state_crop {
5456
int width;
5557
int height;
@@ -72,7 +74,7 @@ static void usage(_Bool capture_filter) {
7274
TBOLD("height") ", "
7375
TBOLD("xoff") " and "
7476
TBOLD("yoff") ". Example:\n"
75-
"\t" TBOLD(TRED("%s crop") "[:width=<w>][:height=<h>][:xoff=<x>][:yoff=<y>]") "\n\n",
77+
"\t" TBOLD(TRED("%s crop") "[:size=<w>x<h>][:xoff=<x>][:yoff=<y>]") "\n\n",
7678
capture_filter ? "--capture-filter" : "-p");
7779
}
7880

@@ -89,7 +91,13 @@ static void * crop_init(const char *config) {
8991
char *config_copy = tmp;
9092
char *item, *save_ptr;
9193
while ((item = strtok_r(config_copy, ":", &save_ptr))) {
92-
if (strncasecmp(item, "width=", strlen("width=")) == 0) {
94+
if (strstr(item, "size=") == item) {
95+
if (strchr(item, 'x') == NULL) {
96+
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Missing height!\n");
97+
}
98+
s->width = atoi(strchr(item, '=') + 1);
99+
s->height = atoi(strchr(item, 'x') + 1);
100+
} else if (strncasecmp(item, "width=", strlen("width=")) == 0) {
93101
s->width = atoi(item + strlen("width="));
94102
} else if (strncasecmp(item, "height=", strlen("height=")) == 0) {
95103
s->height = atoi(item + strlen("height="));

0 commit comments

Comments
 (0)