Changeset 1807


Ignore:
Timestamp:
04/14/12 01:02:01 (14 months ago)
Author:
philmoz
Message:

DNG updates:

  • don't save GPS info for cameras without GPS
  • clean up DNG version handling code
  • remove commented out bad pixel opcodes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/dng.c

    r1805 r1807  
    8585    BE(2),              // BayerPhase = 2 (top left pixel is green in a green/blue row) 
    8686#endif 
    87  
    88 //    BE(4),              // FixBadPixelsConstant = 4 
    89 //    BE(0x01030000),     // DNG version = 1.3.0.0 
    90 //    BE(1),              // Flags = 1 
    91 //    BE(8),              // Opcode length = 8 bytes 
    92 //    BE(1),              // Constant = 1 
    93 //#if   cam_CFAPattern == 0x02010100 
    94 //    BE(0),              // BayerPhase = 0 (top left pixel is red) 
    95 //#elif cam_CFAPattern == 0x01020001 
    96 //    BE(1),              // BayerPhase = 1 (top left pixel is green in a green/red row) 
    97 //#elif cam_CFAPattern == 0x01000201 
    98 //    BE(2),              // BayerPhase = 2 (top left pixel is green in a green/blue row) 
    99 //#elif cam_CFAPattern == 0x00010102 
    100 //    BE(3),              // BayerPhase = 3 (top left pixel is blue) 
    101 //#endif 
    102 // 
    103 //    BE(4),              // FixBadPixelsConstant = 4 
    104 //    BE(0x01030000),     // DNG version = 1.3.0.0 
    105 //    BE(1),              // Flags = 1 
    106 //    BE(8),              // Opcode length = 8 bytes 
    107 //    BE(2),              // Constant = 2 
    108 //#if   cam_CFAPattern == 0x02010100 
    109 //    BE(0),              // BayerPhase = 0 (top left pixel is red) 
    110 //#elif cam_CFAPattern == 0x01020001 
    111 //    BE(1),              // BayerPhase = 1 (top left pixel is green in a green/red row) 
    112 //#elif cam_CFAPattern == 0x01000201 
    113 //    BE(2),              // BayerPhase = 2 (top left pixel is green in a green/blue row) 
    114 //#elif cam_CFAPattern == 0x00010102 
    115 //    BE(3),              // BayerPhase = 3 (top left pixel is blue) 
    116 //#endif 
    117 // 
    118 //    BE(4),              // FixBadPixelsConstant = 4 
    119 //    BE(0x01030000),     // DNG version = 1.3.0.0 
    120 //    BE(1),              // Flags = 1 
    121 //    BE(8),              // Opcode length = 8 bytes 
    122 //    BE(3),              // Constant = 3 
    123 //#if   cam_CFAPattern == 0x02010100 
    124 //    BE(0),              // BayerPhase = 0 (top left pixel is red) 
    125 //#elif cam_CFAPattern == 0x01020001 
    126 //    BE(1),              // BayerPhase = 1 (top left pixel is green in a green/red row) 
    127 //#elif cam_CFAPattern == 0x01000201 
    128 //    BE(2),              // BayerPhase = 2 (top left pixel is green in a green/blue row) 
    129 //#elif cam_CFAPattern == 0x00010102 
    130 //    BE(3),              // BayerPhase = 3 (top left pixel is blue) 
    131 //#endif 
    13287}; 
    13388 
    13489// warning: according to TIFF format specification, elements must be sorted by tag value in ascending order! 
     90 
     91// Index of DNGVersion in IFD0 below. 
     92// *** warning - if entries are added or removed this should be updated *** 
     93#define DNG_VERSION_INDEX   22 
    13594 
    13695struct dir_entry IFD0[]={ 
     
    171130}; 
    172131 
     132// Index of the badpixel opcode entry in IFD1 below 
     133// *** warning - if entries are added or removed this should be updated *** 
     134#define BADPIXEL_OPCODE_INDEX   21 
    173135                                                                                       
    174136struct dir_entry IFD1[]={ 
     
    194156 {0xC620, T_LONG,       2,  (int)&camera_sensor.crop.size}, 
    195157 {0xC68D, T_LONG,       4,  (int)&camera_sensor.dng_active_area}, 
    196  {0xC740, T_UNDEFINED|T_PTR, sizeof(badpixel_opcode),  (int)&badpixel_opcode},  // Note: should be the last entry! 
     158 {0xC740, T_UNDEFINED|T_PTR, sizeof(badpixel_opcode),  (int)&badpixel_opcode}, 
    197159 {0, T_END} 
    198160}; 
    199  
    200161 
    201162static int cam_shutter[2]       = { 0, 1000000 };       // Shutter speed 
     
    262223} 
    263224 
     225// Index of the GPS IFD in IFD_LIST below 
     226// *** warning - if entries are added or removed this should be updated *** 
     227#define GPS_IFD_INDEX 3 
     228 
    264229struct {struct dir_entry* entry; int count;} IFD_LIST[]={{IFD0,0}, {IFD1,0}, {EXIF_IFD,0}, {GPS_IFD, 0}}; 
    265230 
     
    285250 int raw_offset; 
    286251 
    287  // Find entries for DNG version and bad pixel opcodes 
    288  for (i=0; IFD0[i].tag != 0xC612; i++); 
    289  for (j=0; (IFD1[j].type != 0) && (IFD1[j].tag != 0xC740); j++); 
    290252 // Set version and opcodes 
    291253 if (conf.dng_version) 
    292254 { 
    293255     // If CHDK is removing bad pixels then set DNG version to 1.1 and remove opcodes 
    294      IFD0[i].offset = BE(0x01010000); 
    295      IFD1[j].tag = 0; 
    296      IFD1[j].type = T_END; 
     256     IFD0[DNG_VERSION_INDEX].offset = BE(0x01010000); 
     257     IFD1[BADPIXEL_OPCODE_INDEX].tag = 0; 
     258     IFD1[BADPIXEL_OPCODE_INDEX].type = T_END; 
    297259 } 
    298260 else 
    299261 { 
    300262     // Set DNG version to 1.3 and add bad pixel opcodes 
    301      IFD0[i].offset = BE(0x01030000); 
    302      IFD1[j].tag = 0xC740; 
    303      IFD1[j].type = T_UNDEFINED|T_PTR; 
     263     IFD0[DNG_VERSION_INDEX].offset = BE(0x01030000); 
     264     IFD1[BADPIXEL_OPCODE_INDEX].tag = 0xC740; 
     265     IFD1[BADPIXEL_OPCODE_INDEX].type = T_UNDEFINED|T_PTR; 
    304266 } 
    305267 
    306268 // filling EXIF fields 
    307269 
    308  gps_getData(&gps_data);  
     270 if (camera_info.props.gps) 
     271 { 
     272    // If camera has GPS get the GPS data 
     273    gps_getData(&gps_data);  
     274 } 
     275 else 
     276 { 
     277    // If no GPS then remove the GPS data from the header 
     278    IFD_LIST[GPS_IFD_INDEX].entry = 0; 
     279 } 
    309280 
    310281 for (j=0;j<IFDs;j++) { 
Note: See TracChangeset for help on using the changeset viewer.