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