MCPcopy Create free account
hub / github.com/darktable-org/rawspeed / decodeMetaDataInternal

Method decodeMetaDataInternal

src/librawspeed/decoders/Cr2Decoder.cpp:216–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216void Cr2Decoder::decodeMetaDataInternal(const CameraMetaData* meta) {
217 int iso = 0;
218 mRaw->cfa.setCFA(iPoint2D(2,2), CFA_RED, CFA_GREEN, CFA_GREEN, CFA_BLUE);
219
220 string mode;
221
222 if (mRaw->metadata.subsampling.y == 2 && mRaw->metadata.subsampling.x == 2)
223 mode = "sRaw1";
224
225 if (mRaw->metadata.subsampling.y == 1 && mRaw->metadata.subsampling.x == 2)
226 mode = "sRaw2";
227
228 if (mRootIFD->hasEntryRecursive(ISOSPEEDRATINGS))
229 iso = mRootIFD->getEntryRecursive(ISOSPEEDRATINGS)->getU32();
230 if(65535 == iso) {
231 // ISOSPEEDRATINGS is a SHORT EXIF value. For larger values, we have to look
232 // at RECOMMENDEDEXPOSUREINDEX (maybe Canon specific).
233 if (mRootIFD->hasEntryRecursive(RECOMMENDEDEXPOSUREINDEX))
234 iso = mRootIFD->getEntryRecursive(RECOMMENDEDEXPOSUREINDEX)->getU32();
235 }
236
237 // Fetch the white balance
238 try{
239 if (mRootIFD->hasEntryRecursive(CANONCOLORDATA)) {
240 TiffEntry *wb = mRootIFD->getEntryRecursive(CANONCOLORDATA);
241 // this entry is a big table, and different cameras store used WB in
242 // different parts, so find the offset, default is the most common one
243 int offset = hints.get("wb_offset", 126);
244
245 offset /= 2;
246 mRaw->metadata.wbCoeffs[0] = static_cast<float>(wb->getU16(offset + 0));
247 mRaw->metadata.wbCoeffs[1] = static_cast<float>(wb->getU16(offset + 1));
248 mRaw->metadata.wbCoeffs[2] = static_cast<float>(wb->getU16(offset + 3));
249 } else {
250 if (mRootIFD->hasEntryRecursive(CANONSHOTINFO) &&
251 mRootIFD->hasEntryRecursive(CANONPOWERSHOTG9WB)) {
252 TiffEntry *shot_info = mRootIFD->getEntryRecursive(CANONSHOTINFO);
253 TiffEntry *g9_wb = mRootIFD->getEntryRecursive(CANONPOWERSHOTG9WB);
254
255 uint16_t wb_index = shot_info->getU16(7);
256 int wb_offset = (wb_index < 18) ? "012347800000005896"[wb_index]-'0' : 0;
257 wb_offset = wb_offset*8 + 2;
258
259 mRaw->metadata.wbCoeffs[0] =
260 static_cast<float>(g9_wb->getU32(wb_offset + 1));
261 mRaw->metadata.wbCoeffs[1] =
262 (static_cast<float>(g9_wb->getU32(wb_offset + 0)) +
263 static_cast<float>(g9_wb->getU32(wb_offset + 3))) /
264 2.0F;
265 mRaw->metadata.wbCoeffs[2] =
266 static_cast<float>(g9_wb->getU32(wb_offset + 2));
267 } else if (mRootIFD->hasEntryRecursive(static_cast<TiffTag>(0xa4))) {
268 // WB for the old 1D and 1DS
269 TiffEntry* wb = mRootIFD->getEntryRecursive(static_cast<TiffTag>(0xa4));
270 if (wb->count >= 3) {
271 mRaw->metadata.wbCoeffs[0] = wb->getFloat(0);
272 mRaw->metadata.wbCoeffs[1] = wb->getFloat(1);
273 mRaw->metadata.wbCoeffs[2] = wb->getFloat(2);

Callers

nothing calls this directly

Calls 9

setCFAMethod · 0.80
setErrorMethod · 0.80
iPoint2DClass · 0.70
hasEntryRecursiveMethod · 0.45
getU32Method · 0.45
getEntryRecursiveMethod · 0.45
getMethod · 0.45
getU16Method · 0.45
getFloatMethod · 0.45

Tested by

no test coverage detected