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

Method decodeMetaDataInternal

src/librawspeed/decoders/Rw2Decoder.cpp:192–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void Rw2Decoder::decodeMetaDataInternal(const CameraMetaData* meta) {
193 parseCFA();
194
195 auto id = mRootIFD->getID();
196 string mode = guessMode();
197 int iso = 0;
198 if (mRootIFD->hasEntryRecursive(PANASONIC_ISO_SPEED))
199 iso = mRootIFD->getEntryRecursive(PANASONIC_ISO_SPEED)->getU32();
200
201 if (this->checkCameraSupported(meta, id, mode)) {
202 setMetaData(meta, id, mode, iso);
203 } else {
204 mRaw->metadata.mode = mode;
205 writeLog(DEBUG_PRIO_EXTRA, "Mode not found in DB: %s", mode.c_str());
206 setMetaData(meta, id, "", iso);
207 }
208
209 const TiffIFD* raw = mRootIFD->hasEntryRecursive(PANASONIC_STRIPOFFSET)
210 ? mRootIFD->getIFDWithTag(PANASONIC_STRIPOFFSET)
211 : mRootIFD->getIFDWithTag(STRIPOFFSETS);
212
213 // Read blacklevels
214 if (raw->hasEntry(static_cast<TiffTag>(0x1c)) &&
215 raw->hasEntry(static_cast<TiffTag>(0x1d)) &&
216 raw->hasEntry(static_cast<TiffTag>(0x1e))) {
217 const auto getBlack = [&raw](TiffTag t) -> int {
218 const auto val = raw->getEntry(t)->getU32();
219 int out;
220 if (__builtin_sadd_overflow(val, 15, &out))
221 ThrowRDE("Integer overflow when calculating black level");
222 return out;
223 };
224
225 const int blackRed = getBlack(static_cast<TiffTag>(0x1c));
226 const int blackGreen = getBlack(static_cast<TiffTag>(0x1d));
227 const int blackBlue = getBlack(static_cast<TiffTag>(0x1e));
228
229 for(int i = 0; i < 2; i++) {
230 for(int j = 0; j < 2; j++) {
231 const int k = i + 2 * j;
232 const CFAColor c = mRaw->cfa.getColorAt(i, j);
233 switch (c) {
234 case CFA_RED:
235 mRaw->blackLevelSeparate[k] = blackRed;
236 break;
237 case CFA_GREEN:
238 mRaw->blackLevelSeparate[k] = blackGreen;
239 break;
240 case CFA_BLUE:
241 mRaw->blackLevelSeparate[k] = blackBlue;
242 break;
243 default:
244 ThrowRDE("Unexpected CFA color %s.",
245 ColorFilterArray::colorToString(c).c_str());
246 }
247 }
248 }
249 }

Callers

nothing calls this directly

Calls 11

writeLogFunction · 0.85
getIDMethod · 0.80
getIFDWithTagMethod · 0.80
getColorAtMethod · 0.80
hasEntryRecursiveMethod · 0.45
getU32Method · 0.45
getEntryRecursiveMethod · 0.45
checkCameraSupportedMethod · 0.45
hasEntryMethod · 0.45
getEntryMethod · 0.45
getU16Method · 0.45

Tested by

no test coverage detected