Procházet zdrojové kódy

Add long options to makedng

Martijn Braam před 1 rokem
rodič
revize
99ac0aabfa
3 změnil soubory, kde provedl 59 přidání a 37 odebrání
  1. 13 13
      man/makedng.1.scd
  2. 10 10
      tests/test_dng_validate.sh
  3. 36 14
      util/makedng.c

+ 13 - 13
man/makedng.1.scd

@@ -17,45 +17,45 @@ metadata to correctly render the file.
 
 # OPTIONS
 
-*-w width*, *-h height*
+*-w width*, *-h height*, *--width width*, *--height height*
 	Set the width and height of the source data. This is a required option.
 
-*-p pixelfmt*
+*-p pixelfmt*, *--pixfmt pixelfmt*
 	Set the pixelformat for the source data. This accepts a V4L2 fourcc code or
 	the V4L constant name like "RGGB" and "SRGGB8". This is a required option.
 
-*-m make,model*
+*-m make,model*, *--model make,model*
 	Set the camera Make and Model as a comma seperated string.
 
-*-s software*
+*-s software*, *--software software*
 	Set the name of the camera software used to take the picture.
 
-*-o orientation*
+*-o orientation*, *--orientation orientation*
 	Set the orientation of the image data as a number from 1-8 from the DNG
 	specification.
 
-*-c dcp-file*
+*-c dcp-file*, *--calibration dcp-file*
 	Load a DCP calibration file and append the color profile to the final DNG.
 
-*-n red,green,blue*
+*-n red,green,blue*, *--neutral red,green,blue*
 	Set the neutral whitepoint for the picture as the 3 floating point gain values.
 
-*-b red,green,blue*
+*-b red,green,blue*, *--balance red,green,blue*
 	Set the analog sensor gain for the three color channels as three comma seperated floats.
 
-*-e program*
+*-e program*, *--program program*
 	Set the exposure program in the EXIF data using one of the program numbers from the DNG spec.
 
-*-t seconds*
+*-t seconds*, *--exposure seconds*
 	Set the exposure time for the picture in seconds (eg. 0.01 for 1/100)
 
-*-i iso-speed*
+*-i iso-speed*, *--iso iso-speed*
 	Set the ISO speed rating for the picture
 
-*-f fnumber*
+*-f fnumber*, *--fnumber fnumber*
 	Set the aperture size, or f-number of the picture (2.2 for f/2.2)
 
-*-l focal-length,crop-factor* | *-l focal-length*
+*-l focal-length,crop-factor* | *-l focal-length*, *--focal-length len,crop*, *--focal-length len*
 	Set the focal length for the lens. If no crop factor for the system is supplied a 35mm full-frame sensor is assumed.
 
 # PIXEL FORMATS

+ 10 - 10
tests/test_dng_validate.sh

@@ -26,16 +26,16 @@ $makedng -w 1280 -h 720 -p BGGR -m Test,BGGR scratch/data.rgb scratch/BGGR.dng
 $makedng -w 1280 -h 720 -p RG10 scratch/data.rgb scratch/RG10.dng
 $makedng -w 1280 -h 720 -p SRGGB10P scratch/data.rgb scratch/SRGGB10P.dng
 
-$makedng -w 1280 -h 720 -p RGGB \
-  -s "Testsuite" \
-  -o 2 \
-  -n 0.1,0.2,0.3 \
-  -b 0.4,0.5,0.6 \
-  -e 2 \
-  -t 0.01 \
-  -i 1600 \
-  -f 2.8 \
-  -l 50,1.5 \
+$makedng --width 1280 --height 720 --pixfmt RGGB \
+  --software "Testsuite" \
+  --orientation 2 \
+  --neutral 0.1,0.2,0.3 \
+  --balance 0.4,0.5,0.6 \
+  --program 2 \
+  --exposure 0.01 \
+  --iso 1600 \
+  --fnumber 2.8 \
+  --focal-length 50,1.5 \
   scratch/data.rgb scratch/fields.dng
 
 # Validate DNG

+ 36 - 14
util/makedng.c

@@ -12,19 +12,20 @@ usage(char *name)
 	fprintf(stderr, "Usage: %s -w width -h height -p fmt srcfile dstfile\n", name);
 	fprintf(stderr, "Convert raw sensor data to DNG\n\n");
 	fprintf(stderr, "Arguments:\n");
-	fprintf(stderr, "  -w width       Source data width\n");
-	fprintf(stderr, "  -h height      Source data height\n");
-	fprintf(stderr, "  -p fmt         Source data pixelformat\n");
-	fprintf(stderr, "  -m make,model  Make and model, comma seperated\n");
-	fprintf(stderr, "  -s software    Software name\n");
-	fprintf(stderr, "  -o orientation Orientation number [0-9]\n");
-	fprintf(stderr, "  -c dcp         Append calibration data from .dcp file\n");
-	fprintf(stderr, "  -n r,g,b       Set the whitepoint as 3 comma seperated floats\n");
-	fprintf(stderr, "  -b r,g,b       Set sensor analog gain as 3 comma seperated floats\n");
-	fprintf(stderr, "  -e program     Set the exposure program in EXIF, 0-8\n");
-	fprintf(stderr, "  -t seconds     Set the exposure time in seconds\n");
-	fprintf(stderr, "  -i speed       Set the ISO speed rating\n");
-	fprintf(stderr, "  -f fnumber     Set the aperture as f/value\n");
+	fprintf(stderr, "  -w, --width width               Source data width\n");
+	fprintf(stderr, "  -h, --height height             Source data height\n");
+	fprintf(stderr, "  -p, --pixfmt fmt                Source data pixelformat\n");
+	fprintf(stderr, "  -m, --model make,model          Make and model, comma seperated\n");
+	fprintf(stderr, "  -s, --software software         Software name\n");
+	fprintf(stderr, "  -o, --orientation orientation   Orientation number [0-9]\n");
+	fprintf(stderr, "  -c, --calibration dcp           Append calibration data from .dcp file\n");
+	fprintf(stderr, "  -n, --neutral r,g,b             Set the whitepoint as 3 comma seperated floats\n");
+	fprintf(stderr, "  -b, --balance r,g,b             Set sensor analog gain as 3 comma seperated floats\n");
+	fprintf(stderr, "  -e, --program program           Set the exposure program in EXIF, 0-8\n");
+	fprintf(stderr, "  -t, --exposure seconds          Set the exposure time in seconds\n");
+	fprintf(stderr, "  -i, --iso speed                 Set the ISO speed rating\n");
+	fprintf(stderr, "  -f, --fnumber fnumber           Set the aperture as f/value\n");
+	fprintf(stderr, "  -l, --focal-length length,crop  Set the aperture as f/value\n");
 }
 
 int
@@ -54,7 +55,25 @@ main(int argc, char *argv[])
 	float focal_length = 0.0f;
 	float crop_factor = 1.0f;
 
-	while ((c = getopt(argc, argv, "w:h:p:o:m:s:c:n:b:e:t:i:f:l:")) != -1) {
+	static struct option long_options[] = {
+		{"width", required_argument, NULL, 'w'},
+		{"height", required_argument, NULL, 'h'},
+		{"orientation", required_argument, NULL, 'o'},
+		{"pixfmt", required_argument, NULL, 'p'},
+		{"model", required_argument, NULL, 'm'},
+		{"software", required_argument, NULL, 's'},
+		{"calibration", required_argument, NULL, 'c'},
+		{"neutral", required_argument, NULL, 'n'},
+		{"balance", required_argument, NULL, 'b'},
+		{"program", required_argument, NULL, 'e'},
+		{"exposure", required_argument, NULL, 't'},
+		{"iso", required_argument, NULL, 'i'},
+		{"fnumber", required_argument, NULL, 'f'},
+		{"focal-length", required_argument, NULL, 'l'},
+		{"help", no_argument, NULL, 'H'},
+	};
+	int option_index = 0;
+	while ((c = getopt_long(argc, argv, "w:h:p:o:m:s:c:n:b:e:t:i:f:l:", long_options, &option_index)) != -1) {
 		switch (c) {
 			case 'w':
 				val = strtol(optarg, &end, 10);
@@ -119,6 +138,9 @@ main(int argc, char *argv[])
 					return 1;
 				}
 				break;
+			case 'H':
+				usage(argv[0]);
+				return 0;
 			case '?':
 				if (optopt == 'd' || optopt == 'l') {
 					fprintf(stderr, "Option -%c requires an argument.\n", optopt);