run clang-format on new files

main
Christoph Hasse 4 years ago
parent 29f3d5cac9
commit 28b41f59bd

@ -32,20 +32,22 @@ namespace Exiv2
{ {
EXIV2API bool enableBMFF(bool enable = true); EXIV2API bool enableBMFF(bool enable = true);
class Iloc ;// We'll define this in bmffimage.cpp class Iloc; // We'll define this in bmffimage.cpp
// ***************************************************************************** // *****************************************************************************
// class definitions // class definitions
// Add Base Media File Format to the supported image formats // Add Base Media File Format to the supported image formats
namespace ImageType { namespace ImageType
const int bmff = 15; //!< BMFF (bmff) image type (see class BMFF) {
const int bmff = 15; //!< BMFF (bmff) image type (see class BMFF)
} }
/*! /*!
@brief Class to access BMFF images. @brief Class to access BMFF images.
*/ */
class EXIV2API BmffImage : public Image { class EXIV2API BmffImage : public Image
{
public: public:
//! @name Creators //! @name Creators
//@{ //@{
@ -70,11 +72,11 @@ namespace Exiv2
BmffImage(BasicIo::AutoPtr io, size_t start, size_t count); BmffImage(BasicIo::AutoPtr io, size_t start, size_t count);
//@} //@}
void parseTiff(uint32_t root_tag,uint32_t length); void parseTiff(uint32_t root_tag, uint32_t length);
//! @name Manipulators //! @name Manipulators
//@{ //@{
void readMetadata() /* override */ ; void readMetadata() /* override */;
void writeMetadata() /* override */ ; void writeMetadata() /* override */;
/*! /*!
@brief Print out the structure of image file. @brief Print out the structure of image file.
@ -82,18 +84,18 @@ namespace Exiv2
not valid (does not look like data of the specific image type). not valid (does not look like data of the specific image type).
@warning This function is not thread safe and intended for exiv2 -pS for debugging. @warning This function is not thread safe and intended for exiv2 -pS for debugging.
*/ */
void printStructure(std::ostream& out, PrintStructureOption option,int depth) /* override */ ; void printStructure(std::ostream& out, PrintStructureOption option, int depth) /* override */;
/*! /*!
@brief Todo: Not supported yet(?). Calling this function will throw @brief Todo: Not supported yet(?). Calling this function will throw
an instance of Error(kerInvalidSettingForImage). an instance of Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string& comment) /* override */ ; void setComment(const std::string& comment) /* override */;
//@} //@}
//! @name Accessors //! @name Accessors
//@{ //@{
std::string mimeType() const /* override */ ; std::string mimeType() const /* override */;
//@} //@}
#if 0 #if 0
BmffImage& operator=(const BmffImage& rhs) /* = delete*/ ; BmffImage& operator=(const BmffImage& rhs) /* = delete*/ ;
@ -109,16 +111,22 @@ namespace Exiv2
@return address of next box @return address of next box
@warning This function should only be called by readMetadata() @warning This function should only be called by readMetadata()
*/ */
long boxHandler(int depth=0); long boxHandler(int depth = 0);
uint32_t fileType ; uint32_t fileType;
std::set<uint64_t> visits_ ; std::set<uint64_t> visits_;
uint64_t visits_max_; uint64_t visits_max_;
std::string indent(int i) { std::string r; while ( i-- > 0 ) r+=std::string(" "); return r; } std::string indent(int i)
{
uint16_t unknownID_ ; // 0xffff std::string r;
uint16_t exifID_ ; while (i-- > 0)
std::map<uint32_t,Iloc> ilocs_; r += std::string(" ");
return r;
}
uint16_t unknownID_; // 0xffff
uint16_t exifID_;
std::map<uint32_t, Iloc> ilocs_;
/*! /*!
@brief Provides the main implementation of writeMetadata() by @brief Provides the main implementation of writeMetadata() by
@ -133,16 +141,16 @@ namespace Exiv2
/*! /*!
@brief box utilities @brief box utilities
*/ */
std::string toAscii (long n); std::string toAscii(long n);
std::string boxName (uint32_t box); std::string boxName(uint32_t box);
bool superBox(uint32_t box); bool superBox(uint32_t box);
bool fullBox (uint32_t box); bool fullBox(uint32_t box);
std::string uuidName(Exiv2::DataBuf& uuid); std::string uuidName(Exiv2::DataBuf& uuid);
}; // class BmffImage }; // class BmffImage
// ***************************************************************************** // *****************************************************************************
// template, inline and free functions // template, inline and free functions
// These could be static private functions on Image subclasses but then // These could be static private functions on Image subclasses but then
// ImageFactory needs to be made a friend. // ImageFactory needs to be made a friend.
@ -155,4 +163,4 @@ namespace Exiv2
//! Check if the file iIo is a BMFF image. //! Check if the file iIo is a BMFF image.
EXIV2API bool isBmffType(BasicIo& iIo, bool advance); EXIV2API bool isBmffType(BasicIo& iIo, bool advance);
} // namespace Exiv2 } // namespace Exiv2

@ -23,26 +23,26 @@
#define EXIV2_DEBUG_MESSAGES #define EXIV2_DEBUG_MESSAGES
// included header files // included header files
#include "config.h" #include "bmffimage.hpp"
#include "basicio.hpp"
#include "config.h"
#include "error.hpp"
#include "futils.hpp"
#include "image.hpp" #include "image.hpp"
#include "image_int.hpp" #include "image_int.hpp"
#include "safe_op.hpp"
#include "tiffimage.hpp" #include "tiffimage.hpp"
#include "tiffimage_int.hpp" #include "tiffimage_int.hpp"
#include "bmffimage.hpp"
#include "basicio.hpp"
#include "error.hpp"
#include "futils.hpp"
#include "types.hpp" #include "types.hpp"
#include "safe_op.hpp"
#include "unused.h" #include "unused.h"
// + standard includes // + standard includes
#include <string>
#include <cstring>
#include <iostream>
#include <cassert> #include <cassert>
#include <cstdio> #include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
struct BmffBoxHeader struct BmffBoxHeader
{ {
@ -54,7 +54,7 @@ struct BmffBoxHeader
#define TAG_avif 0x61766966 /**< "avif" AVIF */ #define TAG_avif 0x61766966 /**< "avif" AVIF */
#define TAG_heic 0x68656963 /**< "heic" HEIC */ #define TAG_heic 0x68656963 /**< "heic" HEIC */
#define TAG_heif 0x68656966 /**< "heif" HEIF */ #define TAG_heif 0x68656966 /**< "heif" HEIF */
#define TAG_crx 0x63727820 /**< "crx " Canon CR3 */ #define TAG_crx 0x63727820 /**< "crx " Canon CR3 */
#define TAG_moov 0x6d6f6f76 /**< "moov" Movie */ #define TAG_moov 0x6d6f6f76 /**< "moov" Movie */
#define TAG_meta 0x6d657461 /**< "meta" Metadata */ #define TAG_meta 0x6d657461 /**< "meta" Metadata */
#define TAG_mdat 0x6d646174 /**< "mdat" Media data */ #define TAG_mdat 0x6d646174 /**< "mdat" Media data */
@ -72,7 +72,6 @@ struct BmffBoxHeader
#define TAG_cmt3 0x434D5433 /**< canonID */ #define TAG_cmt3 0x434D5433 /**< canonID */
#define TAG_cmt4 0x434D5434 /**< gpsID */ #define TAG_cmt4 0x434D5434 /**< gpsID */
// ***************************************************************************** // *****************************************************************************
// class member definitions // class member definitions
namespace Exiv2 namespace Exiv2
@ -84,153 +83,141 @@ namespace Exiv2
#ifdef EXV_ENABLE_BMFF #ifdef EXV_ENABLE_BMFF
enabled = enable; enabled = enable;
return true; return true;
#endif // EXV_ENABLE_BMFF #endif // EXV_ENABLE_BMFF
enable = false; // unused enable = false; // unused
return enable; return enable;
} }
class Iloc class Iloc
{ {
public: public:
Iloc(uint32_t ID=0,uint32_t start=0,uint32_t length=0) Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length){};
: ID_ (ID) virtual ~Iloc(){};
, start_ (start )
, length_ (length) uint32_t ID_;
{}; uint32_t start_;
virtual ~Iloc() {} ; uint32_t length_;
uint32_t ID_ ; std::string toString(long address = 0) const
uint32_t start_ ; {
uint32_t length_ ; return Internal::stringFormat("ID = %d from,length = %d,%d", ID_, start_ + address, length_);
std::string toString(long address=0) const {
return Internal::stringFormat("ID = %d from,length = %d,%d", ID_,start_+address,length_);
} }
}; // class Iloc }; // class Iloc
BmffImage::BmffImage(BasicIo::AutoPtr io, bool /* create */) BmffImage::BmffImage(BasicIo::AutoPtr io, bool /* create */) : Image(ImageType::bmff, mdExif | mdIptc | mdXmp, io)
: Image(ImageType::bmff, mdExif | mdIptc | mdXmp, io)
{ {
pixelWidth_ =0; pixelWidth_ = 0;
pixelHeight_ =0; pixelHeight_ = 0;
} // BmffImage::BmffImage } // BmffImage::BmffImage
std::string BmffImage::toAscii(long n) std::string BmffImage::toAscii(long n)
{ {
const char* p = (const char*) &n; const char* p = (const char*)&n;
std::string result; std::string result;
bool bBigEndian = isBigEndianPlatform(); bool bBigEndian = isBigEndianPlatform();
for ( int i = 0 ; i < 4 ; i++) { for (int i = 0; i < 4; i++) {
result += p[ bBigEndian ? i : (3-i) ]; result += p[bBigEndian ? i : (3 - i)];
} }
return result; return result;
} }
std::string BmffImage::boxName(uint32_t box) std::string BmffImage::boxName(uint32_t box)
{ {
char name[5]; char name[5];
std::memcpy (name,&box,4); std::memcpy(name, &box, 4);
name[4] = 0 ; name[4] = 0;
return std::string(name) ; return std::string(name);
} }
bool BmffImage::superBox(uint32_t box) bool BmffImage::superBox(uint32_t box)
{ {
return box == TAG_moov return box == TAG_moov || box == TAG_dinf || box == TAG_iprp || box == TAG_ipco || box == TAG_meta ||
|| box == TAG_dinf box == TAG_iinf || box == TAG_iloc;
|| box == TAG_iprp
|| box == TAG_ipco
|| box == TAG_meta
|| box == TAG_iinf
|| box == TAG_iloc
;
} }
bool BmffImage::fullBox(uint32_t box) bool BmffImage::fullBox(uint32_t box)
{ {
return box == TAG_meta return box == TAG_meta || box == TAG_iinf || box == TAG_iloc;
|| box == TAG_iinf
|| box == TAG_iloc
;
} }
std::string BmffImage::mimeType() const std::string BmffImage::mimeType() const
{ {
switch (fileType) switch (fileType) {
{ case TAG_avif:
case TAG_avif: return "image/avif"; return "image/avif";
case TAG_heic: case TAG_heic:
case TAG_heif: return "image/heif"; case TAG_heif:
case TAG_crx : return "image/x-canon-cr3"; return "image/heif";
default : return "image/generic"; case TAG_crx:
return "image/x-canon-cr3";
default:
return "image/generic";
} }
} }
std::string BmffImage::uuidName(Exiv2::DataBuf& uuid) std::string BmffImage::uuidName(Exiv2::DataBuf& uuid)
{ {
const char* uuidCano = "\x85\xC0\xB6\x87\x82\xF\x11\xE0\x81\x11\xF4\xCE\x46\x2B\x6A\x48"; const char* uuidCano = "\x85\xC0\xB6\x87\x82\xF\x11\xE0\x81\x11\xF4\xCE\x46\x2B\x6A\x48";
const char* uuidXmp = "\xBE\x7A\xCF\xCB\x97\xA9\x42\xE8\x9C\x71\x99\x94\x91\xE3\xAF\xAC"; const char* uuidXmp = "\xBE\x7A\xCF\xCB\x97\xA9\x42\xE8\x9C\x71\x99\x94\x91\xE3\xAF\xAC";
const char* uuidCanp = "\xEA\xF4\x2B\x5E\x1C\x98\x4B\x88\xB9\xFB\xB7\xDC\x40\x6E\x4D\x16"; const char* uuidCanp = "\xEA\xF4\x2B\x5E\x1C\x98\x4B\x88\xB9\xFB\xB7\xDC\x40\x6E\x4D\x16";
const char* result = std::memcmp(uuid.pData_, uuidCano, 16) == 0 ? "cano" const char* result = std::memcmp(uuid.pData_, uuidCano, 16) == 0 ? "cano"
: std::memcmp(uuid.pData_, uuidXmp, 16) == 0 ? "xmp" : std::memcmp(uuid.pData_, uuidXmp, 16) == 0 ? "xmp"
: std::memcmp(uuid.pData_, uuidCanp, 16) == 0 ? "canp" : std::memcmp(uuid.pData_, uuidCanp, 16) == 0 ? "canp"
: "" ; : "";
return result; return result;
} }
long BmffImage::boxHandler(int depth /* =0 */) long BmffImage::boxHandler(int depth /* =0 */)
{ {
long result = (long) io_->size(); long result = (long)io_->size();
long address = (long) io_->tell(); long address = (long)io_->tell();
if ( visits_.find(address) != visits_.end() || visits_.size() > visits_max_ ) { if (visits_.find(address) != visits_.end() || visits_.size() > visits_max_) {
throw Error(kerCorruptedMetadata); throw Error(kerCorruptedMetadata);
} }
visits_.insert(address); visits_.insert(address);
BmffBoxHeader box = {0,0}; BmffBoxHeader box = {0, 0};
if ( io_->read((byte*)&box, sizeof(box)) != sizeof(box)) return result; if (io_->read((byte*)&box, sizeof(box)) != sizeof(box))
return result;
box.length = getLong((byte*)&box.length, bigEndian); box.length = getLong((byte*)&box.length, bigEndian);
box.type = getLong((byte*)&box.type, bigEndian); box.type = getLong((byte*)&box.type, bigEndian);
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
bool bLF = true; bool bLF = true;
std::cerr << indent(depth) << "Exiv2::BmffImage::boxHandler: " << toAscii(box.type) std::cerr << indent(depth) << "Exiv2::BmffImage::boxHandler: " << toAscii(box.type)
<< Internal::stringFormat(" %8ld->%u ",address,box.length) << Internal::stringFormat(" %8ld->%u ", address, box.length);
;
#endif #endif
if ( box.length == 1 ) { if (box.length == 1) {
DataBuf data(8); DataBuf data(8);
io_->read(data.pData_,data.size_ ); io_->read(data.pData_, data.size_);
result = address + (long) getULongLong(data.pData_,littleEndian); result = address + (long)getULongLong(data.pData_, littleEndian);
// sanity check // sanity check
if ( result < 0 || result > (long) io_->size() ) { if (result < 0 || result > (long)io_->size()) {
result = (long) io_->size(); result = (long)io_->size();
box.length = result - address; box.length = result - address;
} }
std::cerr << Internal::stringFormat(" (%lu)",result); std::cerr << Internal::stringFormat(" (%lu)", result);
} }
// read data in box and restore file position // read data in box and restore file position
long restore = io_->tell(); long restore = io_->tell();
DataBuf data(box.length-8); DataBuf data(box.length - 8);
io_->read(data.pData_,data.size_ ); io_->read(data.pData_, data.size_);
io_->seek(restore ,BasicIo::beg); io_->seek(restore, BasicIo::beg);
uint32_t skip = 0 ; // read position in data.pData_ uint32_t skip = 0; // read position in data.pData_
uint8_t version = 0 ; uint8_t version = 0;
uint32_t flags = 0 ; uint32_t flags = 0;
if ( fullBox(box.type) ) { if (fullBox(box.type)) {
flags = getLong(data.pData_+skip,bigEndian) ; // version/flags flags = getLong(data.pData_ + skip, bigEndian); // version/flags
version = (int8_t ) flags >> 24 ; version = (int8_t)flags >> 24;
version &= 0x00ffffff ; version &= 0x00ffffff;
skip += 4 ; skip += 4;
} }
switch (box.type) switch (box.type) {
{ case TAG_ftyp: {
case TAG_ftyp:
{
fileType = getLong(data.pData_, bigEndian); fileType = getLong(data.pData_, bigEndian);
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Brand: " << toAscii(fileType); std::cerr << "Brand: " << toAscii(fileType);
@ -238,52 +225,51 @@ namespace Exiv2
} break; } break;
// 8.11.6.1 // 8.11.6.1
case TAG_iinf: case TAG_iinf: {
{
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << std::endl; std::cerr << std::endl;
bLF=false; bLF = false;
#endif #endif
int n = getShort(data.pData_+skip,bigEndian) ; int n = getShort(data.pData_ + skip, bigEndian);
skip+= 2 ; skip += 2;
io_->seek(skip,BasicIo::cur); io_->seek(skip, BasicIo::cur);
while ( n-- > 0 ) while (n-- > 0)
io_->seek(boxHandler(depth+1),BasicIo::beg); io_->seek(boxHandler(depth + 1), BasicIo::beg);
} break; } break;
// 8.11.6.2 // 8.11.6.2
case TAG_infe : { // .__._.__hvc1_ 2 0 0 1 0 1 0 0 104 118 99 49 0 case TAG_infe: { // .__._.__hvc1_ 2 0 0 1 0 1 0 0 104 118 99 49 0
/* getLong (data.pData_+skip,bigEndian) ; */ skip+=4; /* getLong (data.pData_+skip,bigEndian) ; */ skip += 4;
uint16_t ID = getShort(data.pData_+skip,bigEndian) ; skip+=2; uint16_t ID = getShort(data.pData_ + skip, bigEndian);
/* getShort(data.pData_+skip,bigEndian) ; */ skip+=2; // protection skip += 2;
std::string name((const char*)data.pData_+skip); /* getShort(data.pData_+skip,bigEndian) ; */ skip += 2; // protection
if ( name.find("Exif")== 0 ) { // "Exif" or "ExifExif" std::string name((const char*)data.pData_ + skip);
exifID_ = ID ; if (name.find("Exif") == 0) { // "Exif" or "ExifExif"
exifID_ = ID;
} }
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << Internal::stringFormat("%3d ",ID) << name << " "; std::cerr << Internal::stringFormat("%3d ", ID) << name << " ";
#endif #endif
} break; } break;
case TAG_moov: case TAG_moov:
case TAG_iprp: case TAG_iprp:
case TAG_ipco: case TAG_ipco:
case TAG_meta: { case TAG_meta: {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << std::endl; std::cerr << std::endl;
bLF=false; bLF = false;
#endif #endif
io_->seek(skip,BasicIo::cur); io_->seek(skip, BasicIo::cur);
while ( (long) io_->tell() < (long)(address + box.length) ) { while ((long)io_->tell() < (long)(address + box.length)) {
io_->seek(boxHandler(depth+1),BasicIo::beg); io_->seek(boxHandler(depth + 1), BasicIo::beg);
} }
if ( box.type == TAG_meta && ilocs_.find(exifID_) != ilocs_.end() ) { if (box.type == TAG_meta && ilocs_.find(exifID_) != ilocs_.end()) {
const Iloc& iloc = ilocs_.find(exifID_)->second; const Iloc& iloc = ilocs_.find(exifID_)->second;
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << indent(depth) << "Exiv2::BMFF Exif: " << iloc.toString(address+20) << std::endl; std::cerr << indent(depth) << "Exiv2::BMFF Exif: " << iloc.toString(address + 20) << std::endl;
#endif #endif
// parseTiff(Internal::Tag::root,iloc.length_,iloc.start_+address); // parseTiff(Internal::Tag::root,iloc.length_,iloc.start_+address);
exifID_ = unknownID_; exifID_ = unknownID_;
@ -292,9 +278,9 @@ namespace Exiv2
// 8.11.3.1 // 8.11.3.1
case TAG_iloc: { case TAG_iloc: {
uint8_t u = data.pData_[skip++]; uint8_t u = data.pData_[skip++];
uint16_t offsetSize = u >> 4 ; uint16_t offsetSize = u >> 4;
uint16_t lengthSize = u & 0xF ; uint16_t lengthSize = u & 0xF;
#if 0 #if 0
uint16_t indexSize = 0 ; uint16_t indexSize = 0 ;
u = data.pData_[skip++]; u = data.pData_[skip++];
@ -304,50 +290,52 @@ namespace Exiv2
#else #else
skip++; skip++;
#endif #endif
uint32_t itemCount = version < 2 ? getShort(data.pData_+skip,bigEndian) : getLong(data.pData_+skip,bigEndian); uint32_t itemCount =
skip += version < 2 ? 2 : 4 ; version < 2 ? getShort(data.pData_ + skip, bigEndian) : getLong(data.pData_ + skip, bigEndian);
if ( itemCount && itemCount < box.length/14 && offsetSize == 4 && lengthSize == 4 && ((box.length-16) % itemCount) == 0 ) { skip += version < 2 ? 2 : 4;
if (itemCount && itemCount < box.length / 14 && offsetSize == 4 && lengthSize == 4 &&
((box.length - 16) % itemCount) == 0) {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << std::endl; std::cerr << std::endl;
bLF=false; bLF = false;
#endif #endif
uint32_t step = (box.length-16)/itemCount ; // length of data per item. uint32_t step = (box.length - 16) / itemCount; // length of data per item.
uint32_t base = skip; uint32_t base = skip;
for ( uint32_t i = 0 ; i < itemCount ; i++ ) { for (uint32_t i = 0; i < itemCount; i++) {
skip=base+i*step ; // move in 16 or 14 byte steps skip = base + i * step; // move in 16 or 14 byte steps
uint32_t ID = version > 2 ? getLong(data.pData_+skip,bigEndian) : getShort(data.pData_+skip,bigEndian); uint32_t ID = version > 2 ? getLong(data.pData_ + skip, bigEndian)
uint32_t offset = getLong(data.pData_+skip+step-8,bigEndian); : getShort(data.pData_ + skip, bigEndian);
uint32_t ldata = getLong(data.pData_+skip+step-4,bigEndian); uint32_t offset = getLong(data.pData_ + skip + step - 8, bigEndian);
uint32_t ldata = getLong(data.pData_ + skip + step - 4, bigEndian);
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << indent(depth) std::cerr << indent(depth)
<< Internal::stringFormat("%8ld | %8u | ext | %4u | %6u,%6u",address+skip,step,ID,offset,ldata) << Internal::stringFormat("%8ld | %8u | ext | %4u | %6u,%6u", address + skip, step,
<< std::endl ID, offset, ldata)
; << std::endl;
#endif #endif
ilocs_[ID] = Iloc(ID,offset,ldata); ilocs_[ID] = Iloc(ID, offset, ldata);
} }
} }
} break; } break;
case TAG_ispe: { case TAG_ispe: {
skip+=4; skip += 4;
int width = (int) getLong(data.pData_ + skip, bigEndian); skip+=4; int width = (int)getLong(data.pData_ + skip, bigEndian);
int height = (int) getLong(data.pData_ + skip, bigEndian); skip+=4; skip += 4;
int height = (int)getLong(data.pData_ + skip, bigEndian);
skip += 4;
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "pixelWidth_, pixelHeight_ = " std::cerr << "pixelWidth_, pixelHeight_ = " << Internal::stringFormat("%d, %d", width, height);
<< Internal::stringFormat("%d, %d", width, height)
;
// HEIC files can have multiple ispe records // HEIC files can have multiple ispe records
// Store largest width/height // Store largest width/height
if ( width > pixelWidth_ && height > pixelHeight_ ) { if (width > pixelWidth_ && height > pixelHeight_) {
pixelWidth_ = width ; pixelWidth_ = width;
pixelHeight_ = height ; pixelHeight_ = height;
} }
#endif #endif
} break; } break;
case TAG_uuid: case TAG_uuid: {
{
DataBuf uuid(16); DataBuf uuid(16);
io_->read(uuid.pData_, uuid.size_); io_->read(uuid.pData_, uuid.size_);
std::string name = uuidName(uuid); std::string name = uuidName(uuid);
@ -361,26 +349,37 @@ namespace Exiv2
} }
} break; } break;
case TAG_cmt1: parseTiff(Internal::Tag::root ,box.length); break; case TAG_cmt1:
case TAG_cmt2: parseTiff(Internal::Tag::cr3_exif,box.length); break; parseTiff(Internal::Tag::root, box.length);
case TAG_cmt3: parseTiff(Internal::Tag::cr3_mn ,box.length); break; break;
case TAG_cmt4: parseTiff(Internal::Tag::cr3_gps ,box.length); break; case TAG_cmt2:
parseTiff(Internal::Tag::cr3_exif, box.length);
default: {} ; /* do nothing */ break;
case TAG_cmt3:
parseTiff(Internal::Tag::cr3_mn, box.length);
break;
case TAG_cmt4:
parseTiff(Internal::Tag::cr3_gps, box.length);
break;
default: {
}; /* do nothing */
} }
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
if ( bLF ) std::cerr << std::endl; if (bLF)
std::cerr << std::endl;
#endif #endif
// return address of next box // return address of next box
if ( box.length != 1 ) result = static_cast<long>(address + box.length); if (box.length != 1)
result = static_cast<long>(address + box.length);
return result ; return result;
} }
void BmffImage::parseTiff(uint32_t root_tag,uint32_t length) void BmffImage::parseTiff(uint32_t root_tag, uint32_t length)
{ {
if ( length > 8 ) { if (length > 8) {
DataBuf data(length - 8); DataBuf data(length - 8);
// rawData.alloc(length - 8); // rawData.alloc(length - 8);
long bufRead = io_->read(data.pData_, data.size_); long bufRead = io_->read(data.pData_, data.size_);
@ -390,7 +389,7 @@ namespace Exiv2
throw Error(kerInputDataReadFailed); throw Error(kerInputDataReadFailed);
Internal::TiffParserWorker::decode(exifData(), iptcData(), xmpData(), data.pData_, data.size_, root_tag, Internal::TiffParserWorker::decode(exifData(), iptcData(), xmpData(), data.pData_, data.size_, root_tag,
Internal::TiffMapping::findDecoder); Internal::TiffMapping::findDecoder);
} }
} }
@ -398,34 +397,34 @@ namespace Exiv2
{ {
// Todo: implement me! // Todo: implement me!
throw(Error(kerInvalidSettingForImage, "Image comment", "BMFF")); throw(Error(kerInvalidSettingForImage, "Image comment", "BMFF"));
} // BmffImage::setComment } // BmffImage::setComment
void BmffImage::readMetadata() void BmffImage::readMetadata()
{ {
if (io_->open() != 0) if (io_->open() != 0) {
{
throw Error(kerDataSourceOpenFailed, io_->path(), strError()); throw Error(kerDataSourceOpenFailed, io_->path(), strError());
} }
IoCloser closer(*io_); IoCloser closer(*io_);
// Ensure that this is the correct image type // Ensure that this is the correct image type
if (!isBmffType(*io_, false)) { if (!isBmffType(*io_, false)) {
if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData); if (io_->error() || io_->eof())
throw Error(kerFailedToReadImageData);
throw Error(kerNotAnImage, "BMFF"); throw Error(kerNotAnImage, "BMFF");
} }
ilocs_ .clear() ; ilocs_.clear();
visits_.clear(); visits_.clear();
visits_max_ = io_->size() / 16; visits_max_ = io_->size() / 16;
unknownID_ = 0xffff ; unknownID_ = 0xffff;
exifID_ = unknownID_ ; exifID_ = unknownID_;
long address = 0 ; long address = 0;
while ( address < (long) io_->size() ) { while (address < (long)io_->size()) {
io_->seek(address,BasicIo::beg); io_->seek(address, BasicIo::beg);
address = boxHandler(); address = boxHandler();
} }
} // BmffImage::readMetadata } // BmffImage::readMetadata
void BmffImage::printStructure(std::ostream& out, PrintStructureOption option, int depth) void BmffImage::printStructure(std::ostream& out, PrintStructureOption option, int depth)
{ {
@ -441,19 +440,18 @@ namespace Exiv2
UNUSED(out); UNUSED(out);
UNUSED(option); UNUSED(option);
UNUSED(depth); UNUSED(depth);
} // BmffImage::printStructure } // BmffImage::printStructure
void BmffImage::writeMetadata() void BmffImage::writeMetadata()
{ {
} // BmffImage::writeMetadata } // BmffImage::writeMetadata
// ************************************************************************* // *************************************************************************
// free functions // free functions
Image::AutoPtr newBmffInstance(BasicIo::AutoPtr io, bool create) Image::AutoPtr newBmffInstance(BasicIo::AutoPtr io, bool create)
{ {
Image::AutoPtr image(new BmffImage(io, create)); Image::AutoPtr image(new BmffImage(io, create));
if (!image->good()) if (!image->good()) {
{
image.reset(); image.reset();
} }
return image; return image;
@ -461,8 +459,7 @@ namespace Exiv2
bool isBmffType(BasicIo& iIo, bool advance) bool isBmffType(BasicIo& iIo, bool advance)
{ {
if (!enabled) if (!enabled) {
{
return false; return false;
} }
const int32_t len = 12; const int32_t len = 12;
@ -478,4 +475,4 @@ namespace Exiv2
} }
return matched; return matched;
} }
} // namespace Exiv2 } // namespace Exiv2

Loading…
Cancel
Save