// readName will read the make and model of the image. // // If the name is read, it will return true, and the make/model // will be available in camera_make/camera_model members. boolean X3fDecoder::readName() { if (camera_make.length() != 0 && camera_model.length() != 0) { return ((boolean)TRUE); } // Read from properties if (hasProp("CAMMANUF") && hasProp("CAMMODEL")) { camera_make = getProp("CAMMANUF"); camera_model = getProp("CAMMODEL"); return ((boolean)TRUE); } // See if we can find EXIF info and grab the name from there. // This is needed for Sigma DP2 Quattro and possibly later cameras. vector<X3fImage>::iterator img = mImages.begin(); for (; img != mImages.end(); img++) { X3fImage cimg = *img; if (cimg.type == 2 && cimg.format == 0x12 && cimg.dataSize > 100) { if (!mFile->isValid(cimg.dataOffset + cimg.dataSize - 1)) { return ((boolean)FALSE); } ByteStream i(mFile->getDataWrt(cimg.dataOffset), cimg.dataSize); // Skip jpeg header i.skipBytes(6); if (i.getInt() == 0x66697845) { // Match text 'Exif' TiffParser t(new FileMap(mFile->getDataWrt(cimg.dataOffset+12), i.getRemainSize())); try { t.parseData(); } catch (...) { return ((boolean)FALSE); } TiffIFD *root = t.RootIFD(); try { if (root->hasEntryRecursive(MAKE) && root->hasEntryRecursive(MODEL)) { camera_model = root->getEntryRecursive(MODEL)->getString(); camera_make = root->getEntryRecursive(MAKE)->getString(); mProperties.props["CAMMANUF"] = root->getEntryRecursive(MAKE)->getString(); mProperties.props["CAMMODEL"] = root->getEntryRecursive(MODEL)->getString(); return ((boolean)TRUE); } } catch (...) {} return ((boolean)FALSE); } } } return ((boolean)FALSE); }
void KdcDecoder::decodeMetaDataInternal(CameraMetaData *meta) { vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL); if (data.empty()) ThrowRDE("KDC Decoder: Model name found"); if (!data[0]->hasEntry(MAKE)) ThrowRDE("KDC Decoder: Make name not found"); string make = data[0]->getEntry(MAKE)->getString(); string model = data[0]->getEntry(MODEL)->getString(); setMetaData(meta, make, model, "", 0); // Try the kodak hidden IFD for WB if (mRootIFD->hasEntryRecursive(KODAK_IFD2)) { TiffEntry *ifdoffset = mRootIFD->getEntryRecursive(KODAK_IFD2); TiffIFD *kodakifd = NULL; try { if (mRootIFD->endian == getHostEndianness()) kodakifd = new TiffIFD(mFile, ifdoffset->getInt()); else kodakifd = new TiffIFDBE(mFile, ifdoffset->getInt()); if (kodakifd && kodakifd->hasEntryRecursive(KODAK_KDC_WB)) { TiffEntry *wb = kodakifd->getEntryRecursive(KODAK_KDC_WB); if (wb->count == 3) { const uint32 *tmp = wb->getIntArray(); mRaw->metadata.wbCoeffs[0] = (float)tmp[0]; mRaw->metadata.wbCoeffs[1] = (float)tmp[1]; mRaw->metadata.wbCoeffs[2] = (float)tmp[2]; } } } catch(TiffParserException e) { mRaw->setError(e.what()); } if (kodakifd) delete kodakifd; } // Use the normal WB if available if (mRootIFD->hasEntryRecursive(KODAKWB)) { TiffEntry *wb = mRootIFD->getEntryRecursive(KODAKWB); if (wb->count == 734 || wb->count == 1502) { const uchar8 *tmp = wb->getData(); mRaw->metadata.wbCoeffs[0] = (float)((((ushort16) tmp[148])<<8)|tmp[149])/256.0f; mRaw->metadata.wbCoeffs[1] = 1.0f; mRaw->metadata.wbCoeffs[2] = (float)((((ushort16) tmp[150])<<8)|tmp[151])/256.0f; } } }