{
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;
_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 <field> <frame> <first>\n", argv[0]);
- printf(" %s [--depth 8] field2frame <frame> <field> <first>\n", argv[0]);
+ printf("Usage: %s [--depth 8] frame2field <frame> <field> <first>\n", argv[0]);
+ printf(" %s [--depth 8] field2frame <field> <frame> <first>\n", argv[0]);
printf(" --depth <bits> 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;
}
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);
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++))
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);