void CrwDecoder::decodeMetaDataInternal(CameraMetaData *meta) { int iso = 0; mRaw->cfa.setCFA(iPoint2D(2,2), CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE); vector<CiffIFD*> data = mRootIFD->getIFDsWithTag(CIFF_MAKEMODEL); if (data.empty()) ThrowRDE("CRW Support check: Model name not found"); vector<string> makemodel = data[0]->getEntry(CIFF_MAKEMODEL)->getStrings(); if (makemodel.size() < 2) ThrowRDE("CRW Support check: wrong number of strings for make/model"); string make = makemodel[0]; string model = makemodel[1]; string mode = ""; if (mRootIFD->hasEntryRecursive(CIFF_SHOTINFO)) { CiffEntry *shot_info = mRootIFD->getEntryRecursive(CIFF_SHOTINFO); if (shot_info->type == CIFF_SHORT && shot_info->count >= 2) { // os << exp(canonEv(value.toLong()) * log(2.0)) * 100.0 / 32.0; ushort16 iso_index = shot_info->getShort(2); iso = expf(canonEv((long)iso_index) * logf(2.0)) * 100.0f / 32.0f; } } // Fetch the white balance try { if(mRootIFD->hasEntryRecursive((CiffTag)0x0032)) { CiffEntry *wb = mRootIFD->getEntryRecursive((CiffTag)0x0032); if (wb->type == CIFF_BYTE && wb->count == 768) { // We're in a D30 file, values are RGGB // This will probably not get used anyway as a 0x102c tag should exist mRaw->metadata.wbCoeffs[0] = (float) (1024.0 /wb->getByte(72)); mRaw->metadata.wbCoeffs[1] = (float) ((1024.0/wb->getByte(73))+(1024.0/wb->getByte(74)))/2.0f; mRaw->metadata.wbCoeffs[2] = (float) (1024.0 /wb->getByte(75)); } else if (wb->type == CIFF_BYTE && wb->count > 768) { // Other G series and S series cameras // correct offset for most cameras int offset = 120; // check for the hint that we need to use other offset if (hints.find("wb_offset") != hints.end()) { stringstream wb_offset(hints.find("wb_offset")->second); wb_offset >> offset; } ushort16 key[] = { 0x410, 0x45f3 }; if (hints.find("wb_mangle") == hints.end()) key[0] = key[1] = 0; offset /= 2; mRaw->metadata.wbCoeffs[0] = (float) (wb->getShort(offset+1) ^ key[1]); mRaw->metadata.wbCoeffs[1] = (float) (wb->getShort(offset+0) ^ key[0]); mRaw->metadata.wbCoeffs[2] = (float) (wb->getShort(offset+2) ^ key[0]); }
void Cr2Decoder::decodeMetaDataInternal(CameraMetaData *meta) { int iso = 0; mRaw->cfa.setCFA(iPoint2D(2,2), CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE); vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL); if (data.empty()) ThrowRDE("CR2 Meta Decoder: Model name not found"); string make = data[0]->getEntry(MAKE)->getString(); string model = data[0]->getEntry(MODEL)->getString(); string mode = ""; if (mRaw->metadata.subsampling.y == 2 && mRaw->metadata.subsampling.x == 2) mode = "sRaw1"; if (mRaw->metadata.subsampling.y == 1 && mRaw->metadata.subsampling.x == 2) mode = "sRaw2"; if (mRootIFD->hasEntryRecursive(ISOSPEEDRATINGS)) iso = mRootIFD->getEntryRecursive(ISOSPEEDRATINGS)->getInt(); // Fetch the white balance try{ if (mRootIFD->hasEntryRecursive(CANONCOLORDATA)) { TiffEntry *wb = mRootIFD->getEntryRecursive(CANONCOLORDATA); // this entry is a big table, and different cameras store used WB in // different parts, so find the offset, starting with the most common one int offset = 126; // replace it with a hint if it exists if (hints.find("wb_offset") != hints.end()) { stringstream wb_offset(hints.find("wb_offset")->second); wb_offset >> offset; } offset /= 2; mRaw->metadata.wbCoeffs[0] = (float) wb->getShort(offset + 0); mRaw->metadata.wbCoeffs[1] = (float) wb->getShort(offset + 1); mRaw->metadata.wbCoeffs[2] = (float) wb->getShort(offset + 3); } else {
void Cr2Decoder::decodeMetaDataInternal(CameraMetaData *meta) { int iso = 0; mRaw->cfa.setCFA(iPoint2D(2,2), CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE); vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL); if (data.empty()) ThrowRDE("CR2 Meta Decoder: Model name not found"); string make = data[0]->getEntry(MAKE)->getString(); string model = data[0]->getEntry(MODEL)->getString(); string mode = ""; if (mRaw->metadata.subsampling.y == 2 && mRaw->metadata.subsampling.x == 2) mode = "sRaw1"; if (mRaw->metadata.subsampling.y == 1 && mRaw->metadata.subsampling.x == 2) mode = "sRaw2"; if (mRootIFD->hasEntryRecursive(ISOSPEEDRATINGS)) iso = mRootIFD->getEntryRecursive(ISOSPEEDRATINGS)->getInt(); // Fetch the white balance if (mRootIFD->hasEntryRecursive(CANONCOLORDATA)) { TiffEntry *color_data = mRootIFD->getEntryRecursive(CANONCOLORDATA); // this entry is a big table, and different cameras store used WB in // different parts, so find the offset // correct offset for most cameras int offset = 126; // check for the hint that we need to use other offset if (hints.find("wb_offset") != hints.end()) { stringstream wb_offset(hints.find("wb_offset")->second); wb_offset >> offset; }