1 module libraw.types;
2 
3 import libraw.const_;
4 import libraw.version_;
5 
6 import core.sys.posix.sys.types;
7 version (Windows) alias time_t = ulong;
8 else import core.sys.posix.sys.time;
9 import core.stdc.stdio;
10 import core.stdc.stdint;
11 import core.stdc.config;
12 
13 /*#if defined(USE_LCMS)
14 #include <lcms.h>
15 #elif defined(USE_LCMS2)
16 #include <lcms2.h>
17 #else
18 #define NO_LCMS
19 #endif*/
20 version = NO_LCMS;
21 
22 extern (C)
23 {
24 	struct libraw_decoder_info_t {
25 		const char *decoder_name;
26 		uint decoder_flags;
27 	}
28 
29 	struct libraw_internal_output_params_t {
30 		uint mix_green;
31 		uint raw_color;
32 		uint zero_is_bad;
33 		ushort shrink;
34 		ushort fuji_width;
35 	}
36 
37 	alias memory_callback = void function(void *data, const char *file, const char *where);
38 	alias exif_parser_callback = void function(void *context, int tag, int type, int len, uint ord, void *ifp, long base);
39 
40 	void default_memory_callback(void *data, const char *file, const char *where);
41 
42 	alias data_callback = void function(void *data, const char *file, const int offset);
43 
44 	void default_data_callback(void *data, const char *file, const int offset);
45 
46 	alias progress_callback = int function(void *data, LibRaw_progress stage, int iteration, int expected);
47 	alias pre_identify_callback = int function(void *ctx);
48 	alias post_identify_callback = void function(void *ctx);
49 	alias process_step_callback = void function(void *ctx);
50 
51 	struct libraw_callbacks_t {
52 		memory_callback mem_cb;
53 		void *memcb_data;
54 
55 		data_callback data_cb;
56 		void *datacb_data;
57 
58 		progress_callback progress_cb;
59 		void *progresscb_data;
60 
61 		exif_parser_callback exif_cb;
62 		void *exifparser_data;
63 		pre_identify_callback pre_identify_cb;
64 		post_identify_callback post_identify_cb;
65 		process_step_callback pre_subtractblack_cb, pre_scalecolors_cb, pre_preinterpolate_cb, pre_interpolate_cb,
66 				interpolate_bayer_cb, interpolate_xtrans_cb,
67 					post_interpolate_cb, pre_converttorgb_cb, post_converttorgb_cb;
68 	}
69 
70 	struct libraw_abstract_datastream_t {
71 		int function(void *userptr) valid;
72 		int function(void *, size_t, size_t, void *userptr) read;
73 		int function(long, int, void *userptr) seek;
74 		long function(void *userptr) tell;
75 		long function(void *userptr) size;
76 		int function(void *userptr) get_char;
77 		char *function(char *, int, void *userptr) gets;
78 		int function(const(char)*, void*, void *userptr) scanf_one;
79 		int function(void *userptr) eof;
80 		void *function(void *userptr) make_jas_stream;
81 
82 		void* userptr;
83 	}
84 
85 	struct libraw_processed_image_t {
86 		LibRaw_image_formats type;
87 		ushort height, width, colors, bits;
88 		uint data_size;
89 		ubyte[1] data;
90 	}
91 
92 	struct libraw_iparams_t {
93 		char[4] guard;
94 		char[64] make;
95 		char[64] model;
96 		char[64] software;
97 		char[64] normalized_make;
98 		char[64] normalized_model;
99 		uint maker_index;
100 		uint raw_count;
101 		uint dng_version;
102 		uint is_foveon;
103 		int colors;
104 		uint filters;
105 		char[6][6] xtrans;
106 		char[6][6] xtrans_abs;
107 		char[5] cdesc;
108 		uint xmplen;
109 		char *xmpdata;
110 
111 	}
112 
113 	struct libraw_raw_inset_crop_t {
114 		ushort cleft, ctop, cwidth, cheight;
115 	}
116 
117 	struct libraw_image_sizes_t {
118 		ushort raw_height, raw_width, height, width, top_margin, left_margin;
119 		ushort iheight, iwidth;
120 		uint raw_pitch;
121 		double pixel_aspect;
122 		int flip;
123 		int[4][8] mask;
124     	ushort raw_aspect;
125     	libraw_raw_inset_crop_t[2] raw_inset_crops;
126 	}
127 
128 	struct libraw_area_t {
129 		short t,l,b,r; // top, left, bottom, right pixel coordinates, (0,0) is top left pixel;
130 	}
131 
132 	struct ph1_t
133 	{
134 		int format, key_off, tag_21a;
135 		int t_black, split_col, black_col, split_row, black_row;
136 		float tag_210;
137 	}
138 
139 	struct libraw_dng_color_t {
140 		uint parsedfields;
141 		ushort illuminant;
142 		float[4][4] calibration;
143 		float[3][4] colormatrix;
144 		float[4][3] forwardmatrix;
145 	}
146 
147 	struct libraw_dng_levels_t {
148 		uint parsedfields;
149 		uint[LIBRAW_CBLACK_SIZE] dng_cblack;
150 		uint dng_black;
151 		float[LIBRAW_CBLACK_SIZE] dng_fcblack;
152 		float dng_fblack;
153 		uint[4] dng_whitelevel;
154 		ushort[4] default_crop; /* Origin and size */
155 		float[4] user_crop; // top-left-bottom-right relative to default_crop
156 		uint preview_colorspace;
157 		float[4] analogbalance;
158 		float[4] asshotneutral;
159 		float baseline_exposure;
160 		float LinearResponseLimit;
161 	}
162 
163 	struct libraw_P1_color_t {
164 		float[9] romm_cam;
165 	}
166 
167 	struct libraw_canon_makernotes_t {
168 		int ColorDataVer;
169 		int ColorDataSubVer;
170 		int SpecularWhiteLevel;
171 		int NormalWhiteLevel;
172 		int[4] ChannelBlackLevel;
173 		int AverageBlackLevel;
174 		/* multishot */
175 		uint[4] multishot;
176 		/* metering */
177 		short MeteringMode;
178 		short SpotMeteringMode;
179 		ubyte FlashMeteringMode;
180 		short FlashExposureLock;
181 		short ExposureMode;
182 		short AESetting;
183 		/* stabilization */
184 		short ImageStabilization;
185 		/* flash */
186 		short FlashMode;
187 		short FlashActivity;
188 		short FlashBits;
189 		short ManualFlashOutput;
190 		short FlashOutput;
191 		short FlashGuideNumber;
192 		/* drive */
193 		short ContinuousDrive;
194 		/* sensor */
195 		short SensorWidth;
196 		short SensorHeight;
197 
198 		int   AFMicroAdjMode;
199 		float AFMicroAdjValue;
200 		short MakernotesFlip;
201 		short RecordMode;
202 		short SRAWQuality;
203 		uint wbi;
204 		short RF_lensID;
205 		int AutoLightingOptimizer;
206 		int HighlightTonePriority;
207 
208 		/* -1 = n/a            1 = Economy
209 		    2 = Normal         3 = Fine
210 		    4 = RAW            5 = Superfine
211 		    7 = CRAW         130 = Normal Movie, CRM LightRaw
212 		  131 = CRM  StandardRaw */
213 		short Quality;
214 		/* Increases dynamic range of sensor data
215 		    0 = OFF  1 = CLogV1 2 = CLogV2? 3 = CLogV3 */
216 		int CanonLog;
217 
218 		libraw_area_t DefaultCropAbsolute;
219 		libraw_area_t RecommendedImageArea;   // contains the image in proper aspect ratio?
220 		libraw_area_t LeftOpticalBlack;       // use this, when present, to estimate black levels?
221 		libraw_area_t UpperOpticalBlack;
222 		libraw_area_t ActiveArea;
223 
224 		short[2] ISOgain; // AutoISO & BaseISO per ExifTool
225 	}
226 
227 	struct libraw_hasselblad_makernotes_t {
228 		int    BaseISO;
229 		double Gain;
230 		char[8]   Sensor;
231 		char[64]   SensorUnit; // SU
232 		char[64]   HostBody;   // HB
233 		int    SensorCode;
234 		int    SensorSubCode;
235 		int    CoatingCode;
236 		int    uncropped;
237 
238 /* CaptureSequenceInitiator is based on the content of the 'model' tag
239 	- values like 'Pinhole', 'Flash Sync', '500 Mech.' etc in .3FR 'model' tag
240 		come from MAIN MENU > SETTINGS > Camera;
241 	- otherwise 'model' contains:
242 		1. if CF/CFV/CFH, SU enclosure, can be with SU type if '-' is present
243 		2. else if '-' is present, HB + SU type;
244 		3. HB;
245 */
246 		char[32] CaptureSequenceInitiator;
247 
248 /* SensorUnitConnector, makernotes 0x0015 tag:
249  - in .3FR - SU side
250  - in .FFF - HB side
251 */
252 		char[64] SensorUnitConnector;
253 
254 		int format; // 3FR, FFF, Imacon (H3D-39 and maybe others), Hasselblad/Phocus DNG, Adobe DNG
255 		int[2] nIFD_CM; // number of IFD containing CM
256 		int[2] RecommendedCrop;
257 
258 /* mnColorMatrix is in makernotes tag 0x002a;
259 	not present in .3FR files and Imacon/H3D-39 .FFF files;
260 	when present in .FFF and Phocus .DNG files, it is a copy of CM1 from .3FR;
261 	available samples contain all '1's in the first 3 elements
262 */
263 		double[3][4] mnColorMatrix;
264 
265 	}
266 
267 	struct libraw_fuji_info_t {
268 		float  ExpoMidPointShift;
269 		ushort DynamicRange;
270 		ushort FilmMode;
271 		ushort DynamicRangeSetting;
272 		ushort DevelopmentDynamicRange;
273 		ushort AutoDynamicRange;
274 		ushort DRangePriority;
275 		ushort DRangePriorityAuto;
276 		ushort DRangePriorityFixed;
277 
278 		/*
279 		tag 0x9200, converted to BrightnessCompensation
280 		F700, S3Pro, S5Pro, S20Pro, S200EXR
281 		E550, E900, F810, S5600, S6500fd, S9000, S9500, S100FS
282 		*/
283 		float BrightnessCompensation; /* in EV, if =4, raw data * 2^4 */
284 
285 		ushort FocusMode;
286 		ushort AFMode;
287 		ushort[2] FocusPixel;
288 		ushort PrioritySettings;
289 		uint FocusSettings;
290 		uint AF_C_Settings;
291 		ushort FocusWarning;
292 		ushort[3] ImageStabilization;
293 		ushort FlashMode;
294 		ushort WB_Preset;
295 
296 		/* ShutterType:
297 			 0 - mechanical
298 			 1 = electronic
299 			 2 = electronic, long shutter speed
300 			 3 = electronic, front curtain
301 		*/
302 		ushort ShutterType;
303 		ushort ExrMode;
304 		ushort Macro;
305 		uint Rating;
306 
307 		/* CropMode:
308 			 1 - FF on GFX,
309 			 2 - sports finder (mechanical shutter),
310 			 4 - 1.25x crop (electronic shutter, continuous high)
311 		*/
312 		ushort CropMode;
313 		char[0x0c + 1]   SerialSignature;
314 		char[4 + 1]   SensorID;
315 		char[4 + 1]   RAFVersion;
316 		int    RAFDataGeneration; // 0 (none), 1..4, 4096
317 		ushort RAFDataVersion;
318 		int    isTSNERDTS;
319 
320 		/* DriveMode:
321 			 0 - single frame
322 			 1 - continuous low
323 			 2 - continuous high
324 		*/
325 		short DriveMode;
326 
327 		/*
328 		tag 0x4000 BlackLevel:
329 		S9100, S9000, S7000, S6000fd, S5200, S5100, S5000,
330 		S5Pro, S3Pro, S2Pro, S20Pro,
331 		S200EXR, S100FS,
332 		F810, F700,
333 		E900, E550,
334 		DBP, and aliases for all of the above
335 		*/
336 		ushort[9] BlackLevel;
337 		uint[32] RAFData_ImageSizeTable;
338 		int AutoBracketing;
339 		int SequenceNumber;
340 		int SeriesLength;
341 		float[2] PixelShiftOffset;
342 		int ImageCount;
343 	}
344 
345 	struct libraw_sensor_highspeed_crop_t {
346 		ushort cleft, ctop, cwidth, cheight;
347 	}
348 
349 	struct libraw_nikon_makernotes_t {
350 		double ExposureBracketValue;
351 		ushort ActiveDLighting;
352 		ushort ShootingMode;
353 		/* stabilization */
354 		ubyte[7] ImageStabilization;
355 		ubyte VibrationReduction;
356 		ubyte VRMode;
357 		/* flash */
358 		char[13] FlashSetting;
359 		char[20] FlashType;
360 		ubyte[4] FlashExposureCompensation;
361 		ubyte[4] ExternalFlashExposureComp;
362 		ubyte[4] FlashExposureBracketValue;
363 		ubyte FlashMode;
364 		byte FlashExposureCompensation2;
365 		byte FlashExposureCompensation3;
366 		byte FlashExposureCompensation4;
367 		ubyte FlashSource;
368 		ubyte[2] FlashFirmware;
369 		ubyte ExternalFlashFlags;
370 		ubyte FlashControlCommanderMode;
371 		ubyte FlashOutputAndCompensation;
372 		ubyte FlashFocalLength;
373 		ubyte FlashGNDistance;
374 		ubyte[4] FlashGroupControlMode;
375 		ubyte[4] FlashGroupOutputAndCompensation;
376 		ubyte FlashColorFilter;
377 
378 /* NEF compression, comments follow those for ExifTool tag 0x0093:
379 	 1: Lossy (type 1)
380 	 2: Uncompressed
381 	 3: Lossless
382 	 4: Lossy (type 2)
383 	 5: Striped packed 12-bit
384 	 6: Uncompressed (14-bit reduced to 12-bit)
385 	 7: Unpacked 12-bit
386 	 8: Small raw
387 	 9: Packed 12-bit
388 	10: Packed 14-bit
389 */
390 		ushort NEFCompression;
391 
392 		int    ExposureMode;
393 		int    ExposureProgram;
394 		int    nMEshots;
395 		int    MEgainOn;
396 		double[4] ME_WB;
397 		ubyte AFFineTune;
398 		ubyte AFFineTuneIndex;
399 		int8_t AFFineTuneAdj;
400 		uint LensDataVersion;
401 		uint FlashInfoVersion;
402 		uint ColorBalanceVersion;
403 		ubyte key;
404 		ushort[4] NEFBitDepth;
405 		ushort HighSpeedCropFormat; /* 1 -> 1.3x; 2 -> DX; 3 -> 5:4; 4 -> 3:2; 6 ->
406 																	 16:9; 11 -> FX uncropped; 12 -> DX uncropped;
407 																	 17 -> 1:1 */
408 		libraw_sensor_highspeed_crop_t SensorHighSpeedCrop;
409 		ushort SensorWidth;
410 		ushort SensorHeight;
411 		ushort Active_D_Lighting;
412 		uint ShotInfoVersion;
413 		short MakernotesFlip;
414 		double RollAngle;  // positive is clockwise, CW
415 		double PitchAngle; // positive is upwords
416 		double YawAngle;   // positive is to the right
417 	}
418 
419 	struct libraw_olympus_makernotes_t {
420 		char[6]  CameraType2;
421 		ushort   ValidBits;
422 		int[2]   SensorCalibration;
423 		ushort[5] DriveMode;
424 		ushort   ColorSpace;
425 		ushort[2] FocusMode;
426 		ushort   AutoFocus;
427 		ushort   AFPoint;
428 		uint[64] AFAreas;
429 		double[5] AFPointSelected;
430 		ushort   AFResult;
431 		ubyte    AFFineTune;
432 		short[3] AFFineTuneAdj;
433 		uint[3]  SpecialMode;
434 		ushort   ZoomStepCount;
435 		ushort   FocusStepCount;
436 		ushort   FocusStepInfinity;
437 		ushort   FocusStepNear;
438 		double   FocusDistance;
439 		ushort[4] AspectFrame; // left, top, width, height
440 		uint[2]  StackedImage;
441 		ubyte    isLiveND;
442 		uint     LiveNDfactor;
443 		ushort   Panorama_mode;
444 		ushort   Panorama_frameNum;
445 	}
446 
447 	struct libraw_panasonic_makernotes_t {
448 		/* Compression:
449 		 34826 (Panasonic RAW 2): LEICA DIGILUX 2;
450 		 34828 (Panasonic RAW 3): LEICA D-LUX 3; LEICA V-LUX 1; Panasonic DMC-LX1;
451 		 Panasonic DMC-LX2; Panasonic DMC-FZ30; Panasonic DMC-FZ50; 34830 (not in
452 		 exiftool): LEICA DIGILUX 3; Panasonic DMC-L1; 34316 (Panasonic RAW 1):
453 		 others (LEICA, Panasonic, YUNEEC);
454 		*/
455 		ushort   Compression;
456 		ushort   BlackLevelDim;
457 		float[8] BlackLevel;
458 		uint     Multishot; /* 0 is Off, 65536 is Pixel Shift */
459 		float    gamma;
460 		int[3]   HighISOMultiplier; /* 0->R, 1->G, 2->B */
461 		short    FocusStepNear;
462 		short    FocusStepCount;
463 		uint     ZoomPosition;
464 		uint     LensManufacturer;
465 	}
466 
467 	struct libraw_pentax_makernotes_t {
468 		ubyte[4] DriveMode;
469 		ushort[2] FocusMode;
470 		ushort[2] AFPointSelected;
471 		ushort   AFPointSelected_Area;
472 		int      AFPointsInFocus_version;
473 		uint     AFPointsInFocus;
474 		ushort   FocusPosition;
475 		short    AFAdjustment;
476 		ubyte    AFPointMode;
477 		ubyte    MultiExposure; /* last bit is not "1" if ME is not used */
478 		ushort   Quality; /* 4 is raw, 7 is raw w/ pixel shift, 8 is raw w/ dynamic
479 											 pixel shift */
480 	}
481 
482 	struct libraw_ricoh_makernotes_t {
483 		ushort   AFStatus;
484 		uint[2]  AFAreaXPosition;
485 		uint[2]  AFAreaYPosition;
486 		ushort   AFAreaMode;
487 		uint     SensorWidth;
488 		uint     SensorHeight;
489 		uint     CroppedImageWidth;
490 		uint     CroppedImageHeight;
491 		ushort   WideAdapter;
492 		ushort   CropMode;
493 		ushort   NDFilter;
494 		ushort   AutoBracketing;
495 		ushort   MacroMode;
496 		ushort   FlashMode;
497 		double   FlashExposureComp;
498 		double   ManualFlashOutput;
499 	}
500 
501 	struct libraw_samsung_makernotes_t {
502 		uint[4]  ImageSizeFull;
503 		uint[4]  ImageSizeCrop;
504 		int[2]   ColorSpace;
505 		uint[11] key;
506 		double   DigitalGain; /* PostAEGain, digital stretch */
507 		int      DeviceType;
508 		char[32] LensFirmware;
509 	}
510 
511 	struct libraw_kodak_makernotes_t {
512 		ushort BlackLevelTop;
513 		ushort BlackLevelBottom;
514 		short offset_left, offset_top; /* KDC files, negative values or zeros */
515 		ushort clipBlack, clipWhite;   /* valid for P712, P850, P880 */
516 		float[3][3] romm_camDaylight;
517 		float[3][3] romm_camTungsten;
518 		float[3][3] romm_camFluorescent;
519 		float[3][3] romm_camFlash;
520 		float[3][3] romm_camCustom;
521 		float[3][3] romm_camAuto;
522 		ushort val018percent, val100percent, val170percent;
523 		short MakerNoteKodak8a;
524 		float ISOCalibrationGain;
525 		float AnalogISO;
526 	}
527 
528 	struct libraw_p1_makernotes_t {
529 		char[64] Software;        // tag 0x0203
530 		char[64] SystemType;      // tag 0x0204
531 		char[256] FirmwareString; // tag 0x0301
532 		char[64] SystemModel;
533 	}
534 
535 	struct libraw_sony_info_t {
536 		/* afdata:
537 		  0x0010 CameraInfo
538 		  0x2020 AFPointsUsed
539 		  0x2022 FocalPlaneAFPointsUsed
540 		  0x202a Tag202a
541 		  0x940e AFInfo
542 		*/
543 		ushort   CameraType;                      // init in 0xffff
544 		ubyte    Sony0x9400_version; /* 0 if not found/deciphered,
545 		                            0xa, 0xb, 0xc following exiftool convention */
546 		ubyte    Sony0x9400_ReleaseMode2;
547 		uint     Sony0x9400_SequenceImageNumber;
548 		ubyte    Sony0x9400_SequenceLength1;
549 		uint     Sony0x9400_SequenceFileNumber;
550 		ubyte    Sony0x9400_SequenceLength2;
551 		uint8_t  AFAreaModeSetting;               // init in 0xff; +
552 		uint16_t AFAreaMode;                      // init in 0xffff; +
553 		ushort[2] FlexibleSpotPosition;           // init in (0xffff, 0xffff)
554 		uint8_t  AFPointSelected;                 // init in 0xff
555 		uint8_t  AFPointSelected_0x201e;          // init in 0xff
556 	    short    nAFPointsUsed;
557 		uint8_t[10] AFPointsUsed;
558 		uint8_t  AFTracking;                      // init in 0xff
559 		uint8_t  AFType;
560 		ushort[4] FocusLocation;
561 		ushort   FocusPosition;                    // init in 0xffff
562 		int8_t   AFMicroAdjValue;                  // init in 0x7f
563 		int8_t   AFMicroAdjOn;                     // init in -1
564 		ubyte    AFMicroAdjRegisteredLenses;       // init in 0xff
565 		ushort   VariableLowPassFilter;
566 		uint     LongExposureNoiseReduction;      // init in 0xffffffff
567 		ushort   HighISONoiseReduction;           // init in 0xffff
568 		ushort[2] HDR;
569 		ushort   group2010;
570 		ushort   group9050;
571 		ushort   real_iso_offset;                 // init in 0xffff
572 		ushort   MeteringMode_offset;
573 		ushort   ExposureProgram_offset;
574 		ushort   ReleaseMode2_offset;
575 	    uint     MinoltaCamID;                    // init in 0xffffffff
576 		float    firmware;
577 		ushort   ImageCount3_offset;              // init in 0xffff
578 		uint     ImageCount3;
579 		uint     ElectronicFrontCurtainShutter;   // init in 0xffffffff
580 		ushort   MeteringMode2;
581 		char[20] SonyDateTime;
582 		uint     ShotNumberSincePowerUp;
583 		ushort   PixelShiftGroupPrefix;
584 		uint     PixelShiftGroupID;
585 		char     nShotsInPixelShiftGroup;
586 		char     numInPixelShiftGroup; /* '0' if ARQ, first shot in the group has '1'
587 																	here */
588 		ushort   prd_ImageHeight, prd_ImageWidth;
589 		ushort   prd_Total_bps;
590 		ushort   prd_Active_bps;
591 		ushort   prd_StorageMethod; /* 82 -> Padded; 89 -> Linear */
592 		ushort   prd_BayerPattern;  /* 0 -> not valid; 1 -> RGGB; 4 -> GBRG */
593 
594 		ushort   SonyRawFileType; /* init in 0xffff
595 		                           valid for ARW 2.0 and up (FileFormat >= 3000)
596 		                           takes precedence over RAWFileType and Quality:
597 		                           0  for uncompressed 14-bit raw
598 		                           1  for uncompressed 12-bit raw
599 		                           2  for compressed raw (lossy)
600 		                           3  for lossless compressed raw
601 		                           4  for lossless compressed raw v.2 (ILCE-1)
602 		                        */
603 		ushort RAWFileType;     /* init in 0xffff
604 		                           takes precedence over Quality
605 		                           0 for compressed raw,
606 		                           1 for uncompressed;
607 		                           2 lossless compressed raw v.2
608 		                        */
609 		uint Quality;           /* init in 0xffffffff
610 		                           0 or 6 for raw, 7 or 8 for compressed raw */
611 		ushort FileFormat;      /*  1000 SR2
612 		                            2000 ARW 1.0
613 		                            3000 ARW 2.0
614 		                            3100 ARW 2.1
615 		                            3200 ARW 2.2
616 		                            3300 ARW 2.3
617 		                            3310 ARW 2.3.1
618 		                            3320 ARW 2.3.2
619 		                            3330 ARW 2.3.3
620 		                            3350 ARW 2.3.5
621 		                            4000 ARW 4.0
622 		                         */
623 		char[16] MetaVersion;
624 	}
625 
626 	struct libraw_colordata_t {
627 		ushort[0x10000] curve;
628 		uint[LIBRAW_CBLACK_SIZE] cblack;
629 		uint black;
630 		uint data_maximum;
631 		uint maximum;
632 
633 // Canon (SpecularWhiteLevel)
634 // Kodak (14N, 14nx, SLR/c/n, DCS720X, DCS760C, DCS760M, ProBack, ProBack645, P712, P880, P850)
635 // Olympus, except:
636 //	C5050Z, C5060WZ, C7070WZ, C8080WZ
637 //	SP350, SP500UZ, SP510UZ, SP565UZ
638 //	E-10, E-20
639 //	E-300, E-330, E-400, E-410, E-420, E-450, E-500, E-510, E-520
640 //	E-1, E-3
641 //	XZ-1
642 // Panasonic
643 // Pentax
644 // Sony
645 // and aliases of the above
646 // DNG
647 		c_long[4] linear_max;
648 
649 		float fmaximum;
650 		float fnorm;
651 		ushort[8][8] white;
652 		float[4] cam_mul;
653 		float[4] pre_mul;
654 		float[4][3] cmatrix;
655 		float[4][3] ccm;
656 		float[4][3] rgb_cam;
657 		float[3][4] cam_xyz;
658 		ph1_t phase_one_data;
659 		float flash_used;
660 		float canon_ev;
661 		char[64] model2;
662 		char[64] UniqueCameraModel;
663 		char[64] LocalizedCameraModel;
664 		char[64] ImageUniqueID;
665 		char[17] RawDataUniqueID;
666 		char[64] OriginalRawFileName;
667 		void *profile;
668 		uint profile_length;
669 		uint[8] black_stat;
670 		libraw_dng_color_t[2] dng_color;
671 		libraw_dng_levels_t dng_levels;
672 		int[4][256] WB_Coeffs;    /* R, G1, B, G2 coeffs */
673 		float[5][64] WBCT_Coeffs; /* CCT, than R, G1, B, G2 coeffs */
674 		int as_shot_wb_applied;
675 		libraw_P1_color_t[2] P1_color;
676 		uint raw_bps; /* for Phase One, raw format */
677 											/* Phase One raw format values, makernotes tag 0x010e:
678 											0    Name unknown
679 											1    "RAW 1"
680 											2    "RAW 2"
681 											3    "IIQ L" (IIQ L14)
682 											4    Never seen
683 											5    "IIQ S"
684 											6    "IIQ Sv2" (S14 / S14+)
685 											7    Never seen
686 											8    "IIQ L16" (IIQ L16EX / IIQ L16)
687 											*/
688 		int ExifColorSpace;
689 	}
690 
691 	struct libraw_thumbnail_t {
692 		LibRaw_thumbnail_formats tformat;
693 		ushort twidth, theight;
694 		uint tlength;
695 		int tcolors;
696 		char *thumb;
697 	}
698 
699 	struct libraw_gps_info_t {
700 		float[3] latitude;     /* Deg,min,sec */
701 		float[3] longitude;    /* Deg,min,sec */
702 		float[3] gpstimestamp; /* Deg,min,sec */
703 		float altitude;
704 		char altref, latref, longref, gpsstatus;
705 		char gpsparsed;
706 	}
707 
708 	struct libraw_imgother_t {
709 		float iso_speed;
710 		float shutter;
711 		float aperture;
712 		float focal_len;
713 		time_t timestamp;
714 		uint shot_order;
715 		uint[32] gpsdata;
716 		libraw_gps_info_t parsed_gps;
717 		char[512] desc;
718 		char[64] artist;
719 		float[4] analogbalance;
720 	}
721 
722 	struct libraw_afinfo_item_t {
723 		uint     AFInfoData_tag;
724 		short    AFInfoData_order;
725 		uint     AFInfoData_version;
726 		uint     AFInfoData_length;
727 		ubyte*   AFInfoData;
728 	}
729 
730 	struct libraw_metadata_common_t {
731 		float FlashEC;
732 		float FlashGN;
733 		float CameraTemperature;
734 		float SensorTemperature;
735 		float SensorTemperature2;
736 		float LensTemperature;
737 		float AmbientTemperature;
738 		float BatteryTemperature;
739 		float exifAmbientTemperature;
740 		float exifHumidity;
741 		float exifPressure;
742 		float exifWaterDepth;
743 		float exifAcceleration;
744 		float exifCameraElevationAngle;
745 		float real_ISO;
746 		float exifExposureIndex;
747 		ushort ColorSpace;
748 		char[128] firmware;
749 	    float ExposureCalibrationShift;
750 		libraw_afinfo_item_t[LIBRAW_AFDATA_MAXCOUNT] afdata;
751 		int afcount;
752 }
753 
754 	struct libraw_output_params_t {
755 		uint[4] greybox;       /* -A  x1 y1 x2 y2 */
756 		uint[4] cropbox;       /* -B x1 y1 x2 y2 */
757 		double[4] aber;        /* -C */
758 		double[6] gamm;        /* -g */
759 		float[4] user_mul;     /* -r mul0 mul1 mul2 mul3 */
760 		float bright;          /* -b */
761 		float threshold;       /* -n */
762 		int half_size;         /* -h */
763 		int four_color_rgb;    /* -f */
764 		int highlight;         /* -H */
765 		int use_auto_wb;       /* -a */
766 		int use_camera_wb;     /* -w */
767 		int use_camera_matrix; /* +M/-M */
768 		int output_color;      /* -o */
769 		char *output_profile;  /* -o */
770 		char *camera_profile;  /* -p */
771 		char *bad_pixels;      /* -P */
772 		char *dark_frame;      /* -K */
773 		int output_bps;        /* -4 */
774 		int output_tiff;       /* -T */
775 		int output_flags;
776 		int user_flip;         /* -t */
777 		int user_qual;         /* -q */
778 		int user_black;        /* -k */
779 		int[4] user_cblack;
780 		int user_sat;          /* -S */
781 		int med_passes;        /* -m */
782 		float auto_bright_thr;
783 		float adjust_maximum_thr;
784 		int no_auto_bright;    /* -W */
785 		int use_fuji_rotate;   /* -j */
786 		int green_matching;
787 		/* DCB parameters */
788 		int dcb_iterations;
789 		int dcb_enhance_fl;
790 		int fbdd_noiserd;
791 		int exp_correc;
792 		float exp_shift;
793 		float exp_preser;
794 		/* Disable Auto-scale */
795 		int no_auto_scale;
796 		/* Disable interpolation */
797 		int no_interpolation;
798 	}
799 
800 	struct libraw_raw_unpack_params_t {
801 		/* Raw speed */
802 		int use_rawspeed;
803 		/* DNG SDK */
804 		int use_dngsdk;
805 		uint options;
806 		uint shot_select;  /* -s */
807 		uint specials;
808 		uint max_raw_memory_mb;
809 		int sony_arw2_posterization_thr;
810 		/* Nikon Coolscan */
811 		float coolscan_nef_gamma;
812 		char[5] p4shot_order;
813 		/* Custom camera list */
814 		char** custom_camera_strings;
815 	}
816 
817 	struct libraw_rawdata_t {
818 		/* really allocated bitmap */
819 		void *raw_alloc;
820 		/* alias to single_channel variant */
821 		ushort *raw_image;
822 		/* alias to 4-channel variant */
823 		ushort[4]* color4_image;
824 		/* alias to 3-color variand decoded by RawSpeed */
825 		ushort[3]* color3_image;
826 		/* float bayer */
827 		float *float_image;
828 		/* float 3-component */
829 		float[3]* float3_image;
830 		/* float 4-component */
831 		float[4]* float4_image;
832 
833 		/* Phase One black level data; */
834 		short[2]* ph1_cblack;
835 		short[2]* ph1_rblack;
836 		/* save color and sizes here, too.... */
837 		libraw_iparams_t iparams;
838 		libraw_image_sizes_t sizes;
839 		libraw_internal_output_params_t ioparams;
840 		libraw_colordata_t color;
841 	}
842 
843 	struct libraw_makernotes_lens_t {
844 		ulong LensID;
845 		char[128] Lens;
846 		ushort LensFormat; /* to characterize the image circle the lens covers */
847 		ushort LensMount;  /* 'male', lens itself */
848 		ulong CamID;
849 		ushort CameraFormat; /* some of the sensor formats */
850 		ushort CameraMount;  /* 'female', body throat */
851 		char[64] body;
852 		short FocalType; /* -1/0 is unknown; 1 is fixed focal; 2 is zoom */
853 		char[16] LensFeatures_pre, LensFeatures_suf;
854 		float MinFocal, MaxFocal;
855 		float MaxAp4MinFocal, MaxAp4MaxFocal, MinAp4MinFocal, MinAp4MaxFocal;
856 		float MaxAp, MinAp;
857 		float CurFocal, CurAp;
858 		float MaxAp4CurFocal, MinAp4CurFocal;
859 		float MinFocusDistance;
860 		float FocusRangeIndex;
861 		float LensFStops;
862 		ulong TeleconverterID;
863 		char[128] Teleconverter;
864 		ulong AdapterID;
865 		char[128] Adapter;
866 		ulong AttachmentID;
867 		char[128] Attachment;
868 		ushort FocalUnits;
869 		float FocalLengthIn35mmFormat;
870 	}
871 
872 	struct libraw_nikonlens_t {
873 		float EffectiveMaxAp;
874 		ubyte LensIDNumber, LensFStops, MCUVersion, LensType;
875 	}
876 
877 	struct libraw_dnglens_t {
878 		float MinFocal, MaxFocal, MaxAp4MinFocal, MaxAp4MaxFocal;
879 	}
880 
881 	struct libraw_lensinfo_t {
882 		float MinFocal, MaxFocal, MaxAp4MinFocal, MaxAp4MaxFocal, EXIF_MaxAp;
883 		char[128] LensMake, Lens, LensSerial, InternalLensSerial;
884 		ushort FocalLengthIn35mmFormat;
885 		libraw_nikonlens_t nikon;
886 		libraw_dnglens_t dng;
887 		libraw_makernotes_lens_t makernotes;
888 	}
889 
890 	struct libraw_makernotes_t {
891 		libraw_canon_makernotes_t canon;
892 		libraw_nikon_makernotes_t nikon;
893 		libraw_hasselblad_makernotes_t hasselblad;
894 		libraw_fuji_info_t fuji;
895 		libraw_olympus_makernotes_t olympus;
896 		libraw_sony_info_t sony;
897 		libraw_kodak_makernotes_t kodak;
898 		libraw_panasonic_makernotes_t panasonic;
899 		libraw_pentax_makernotes_t pentax;
900 		libraw_p1_makernotes_t phaseone;
901 		libraw_ricoh_makernotes_t ricoh;
902 		libraw_samsung_makernotes_t samsung;
903 		libraw_metadata_common_t common;
904 	}
905 
906 	struct libraw_shootinginfo_t {
907 		short DriveMode;
908 		short FocusMode;
909 		short MeteringMode;
910 		short AFPoint;
911 		short ExposureMode;
912 		short ExposureProgram;
913 		short ImageStabilization;
914 		char[64] BodySerial;
915 		char[64] InternalBodySerial; /* this may be PCB or sensor serial, depends on make/model*/
916 	}
917 
918 	struct libraw_custom_camera_t {
919 		uint fsize;
920 		ushort rw, rh;
921 		ubyte lm, tm, rm, bm;
922 		ushort lf;
923 		ubyte cf, max, flags;
924 		char[10] t_make;
925 		char[20] t_model;
926 		ushort offset;
927 	}
928 
929 	struct libraw_data_t {
930 		ushort[4]* image;
931 		libraw_image_sizes_t sizes;
932 		libraw_iparams_t idata;
933 		libraw_lensinfo_t lens;
934 		libraw_makernotes_t makernotes;
935 		libraw_shootinginfo_t shootinginfo;
936 		libraw_output_params_t params;
937 		libraw_raw_unpack_params_t rawparams;
938 		uint progress_flags;
939 		uint process_warnings;
940 		libraw_colordata_t color;
941 		libraw_imgother_t other;
942 		libraw_thumbnail_t thumbnail;
943 		libraw_rawdata_t rawdata;
944 		void *parent_class;
945 	}
946 
947 	struct fuji_q_table {
948 		int8_t* q_table; /* quantization table */
949 		int raw_bits;
950 		int total_values;
951 		int max_grad;    // sdp val
952 		int q_grad_mult; // quant_gradient multiplier
953 		int q_base;
954 	}
955 
956 	struct fuji_compressed_params {
957 		fuji_q_table[4] qt;
958 		void* buf;
959 		int max_bits;
960 		int min_value;
961 		int max_value;   // q_point[4]
962 		ushort line_width;
963 	}
964 
965 	struct libraw_static_table_t
966 	{
967 		this(const(int)* a, const(uint) s) {
968 			data = a;
969 			_size = s;
970 		}
971 		this(ref const(libraw_static_table_t) s) {
972 			data = s.data;
973 			_size = s._size;
974 		}
975 		uint size() const { return _size; }
976 		int opIndex(uint idx) const
977 		{
978 			if (idx < _size) return data[idx];
979 			if(_size>0 && data) return data[0];
980 			return 0;
981 		}
982 	private:
983 		const(int)* data;
984 		uint _size;
985 	}
986 }
987 
988 static import std.system;
989 enum LibRawBigEndian = std.system.endian == std.system.Endian.bigEndian;
990 
991 
992 // sanity check struct sizes to match the C/C++ side
993 version (Win64) {
994 	static assert(libraw_decoder_info_t.sizeof == 16);
995 	static assert(libraw_internal_output_params_t.sizeof == 16);
996 	static assert(libraw_callbacks_t.sizeof == 152);
997 	static assert(libraw_abstract_datastream_t.sizeof == 88);
998 	static assert(libraw_processed_image_t.sizeof == 20);
999 	static assert(libraw_iparams_t.sizeof == 440);
1000 	static assert(libraw_raw_inset_crop_t.sizeof == 8);
1001 	static assert(libraw_image_sizes_t.sizeof == 184);
1002 	static assert(libraw_area_t.sizeof == 8);
1003 	static assert(ph1_t.sizeof == 36);
1004 	static assert(libraw_dng_color_t.sizeof == 168);
1005 	static assert(libraw_dng_levels_t.sizeof == 32928);
1006 	static assert(libraw_P1_color_t.sizeof == 36);
1007 	static assert(libraw_canon_makernotes_t.sizeof == 168);
1008 	static assert(libraw_hasselblad_makernotes_t.sizeof == 384);
1009 	static assert(libraw_fuji_info_t.sizeof == 280);
1010 	static assert(libraw_sensor_highspeed_crop_t.sizeof == 8);
1011 	static assert(libraw_nikon_makernotes_t.sizeof == 224);
1012 	static assert(libraw_olympus_makernotes_t.sizeof == 408);
1013 	static assert(libraw_panasonic_makernotes_t.sizeof == 68);
1014 	static assert(libraw_pentax_makernotes_t.sizeof == 32);
1015 	static assert(libraw_ricoh_makernotes_t.sizeof == 72);
1016 	static assert(libraw_samsung_makernotes_t.sizeof == 136);
1017 	static assert(libraw_kodak_makernotes_t.sizeof == 244);
1018 	static assert(libraw_p1_makernotes_t.sizeof == 448);
1019 	static assert(libraw_sony_info_t.sizeof == 180);
1020 	static assert(libraw_colordata_t.sizeof == 187032);
1021 	static assert(libraw_thumbnail_t.sizeof == 24);
1022 	static assert(libraw_gps_info_t.sizeof == 48);
1023 	static assert(libraw_imgother_t.sizeof == 800);
1024 	static assert(libraw_afinfo_item_t.sizeof == 24);
1025 	static assert(libraw_metadata_common_t.sizeof == 304);
1026 	static assert(libraw_output_params_t.sizeof == 304);
1027 	static assert(libraw_raw_unpack_params_t.sizeof == 48);
1028 	static assert(libraw_rawdata_t.sizeof == 187744);
1029 	static assert(libraw_makernotes_lens_t.sizeof == 736);
1030 	static assert(libraw_nikonlens_t.sizeof == 8);
1031 	static assert(libraw_dnglens_t.sizeof == 16);
1032 	static assert(libraw_lensinfo_t.sizeof == 1296);
1033 	static assert(libraw_makernotes_t.sizeof == 2952);
1034 	static assert(libraw_shootinginfo_t.sizeof == 142);
1035 	static assert(libraw_custom_camera_t.sizeof == 52);
1036 	static assert(libraw_data_t.sizeof == 380992);
1037 	static assert(fuji_q_table.sizeof == 32);
1038 	static assert(fuji_compressed_params.sizeof == 152);
1039 }