From: Andreas Eversberg Date: Thu, 25 Jun 2015 11:59:04 +0000 (+0200) Subject: Fix and option for "fields" X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=colorize.git;a=commitdiff_plain;h=a329b4558597a2c6685d350f25ca471c5b6d9308 Fix and option for "fields" --- diff --git a/tools/fields.c b/tools/fields.c index 8649a65..508afbc 100644 --- a/tools/fields.c +++ b/tools/fields.c @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { unsigned short *field1_img = NULL, *field2_img = NULL, *frame_img = NULL; int width, height; - int frame, field; + int frame, field, swap = 0; int _argc = argc - 1; int _arg = 1; @@ -50,13 +50,20 @@ int main(int argc, char *argv[]) _argc -= 2; } + if (_argc > 0 && !strcmp(argv[_arg], "--even")) { + swap = 1; + _arg += 1; + _argc -= 1; + } + if (_argc != 4) { usage: printf("This tool will split images to fields or join from frames.\n"); printf("The odd lines (second line, fourth line, ...) is the first field.\n\n"); - printf("Usage: %s [--depth 8] frame2field \n", argv[0]); - printf(" %s [--depth 8] field2frame \n", argv[0]); + printf("Usage: %s [--depth 8] frame2field \n", argv[0]); + printf(" %s [--depth 8] field2frame \n", argv[0]); printf(" --depth Change color depth from default %d to given bits\n", save_depth); + printf(" --even Use even lines for first field and odd for second\n"); return 0; } @@ -67,7 +74,7 @@ usage: else goto usage; - frame = field = atoi(argv[_arg+2]); + frame = field = atoi(argv[_arg+3]); next_frame: printf("\n\nProcessing frame %d, field %d+%d\n", frame, field, field+1); @@ -79,7 +86,10 @@ next_frame: goto out; if (!(field2_img = malloc(width * height/2 * 3 * sizeof(unsigned short)))) goto out; - split_image(frame_img, field1_img, field2_img, width, height); + if (swap) + split_image(frame_img, field2_img, field1_img, width, height); + else + split_image(frame_img, field1_img, field2_img, width, height); if (save_img(field1_img, width, height/2, 0, argv[_arg+2], field++)) goto out; if (save_img(field2_img, width, height/2, 0, argv[_arg+2], field++)) @@ -98,7 +108,10 @@ next_frame: goto out; if (!(frame_img = malloc(width * height*2 * 3 * sizeof(unsigned short)))) goto out; - join_image(field1_img, field2_img, frame_img, width, height*2); + if (swap) + join_image(field2_img, field1_img, frame_img, width, height*2); + else + join_image(field1_img, field2_img, frame_img, width, height*2); if (save_img(frame_img, width, height*2, 0, argv[_arg+2], frame++)) goto out; free(field1_img);