Loading...
Searching...
No Matches
bmffimage.hpp
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
// *****************************************************************************
#include "exiv2lib_export.h"
// included header files
#include "image.hpp"
#include <set>
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
[[deprecated]] EXIV2API bool enableBMFF(bool enable = true);
} // namespace Exiv2
#ifdef EXV_ENABLE_BMFF
namespace Exiv2 {
struct Iloc {
explicit Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length) {
}
virtual ~Iloc() = default;
Iloc(const Iloc&) = default;
Iloc& operator=(const Iloc&) = default;
uint32_t ID_;
uint32_t start_;
uint32_t length_;
[[nodiscard]] std::string toString() const;
}; // class Iloc
// *****************************************************************************
// class definitions
class EXIV2API BmffImage : public Image {
public:
BmffImage(BasicIo::UniquePtr io, bool create, size_t max_box_depth = 1000);
void parseTiff(uint32_t root_tag, uint64_t length);
void parseTiff(uint32_t root_tag, uint64_t length, uint64_t start);
void parseXmp(uint64_t length, uint64_t start);
void parseCr3Preview(const DataBuf& data, std::ostream& out, bool bTrace, uint8_t version, size_t width_offset,
size_t height_offset, size_t size_offset, size_t relative_position);
void readMetadata() override;
void writeMetadata() override;
void setExifData(const ExifData&) override;
void setIptcData(const IptcData&) override;
void setXmpData(const XmpData&) override;
void setComment(const std::string& comment) override;
void printStructure(std::ostream& out, Exiv2::PrintStructureOption option, size_t depth) override;
[[nodiscard]] std::string mimeType() const override;
[[nodiscard]] uint32_t pixelWidth() const override;
[[nodiscard]] uint32_t pixelHeight() const override;
static constexpr Exiv2::ByteOrder endian_{Exiv2::bigEndian};
private:
void openOrThrow() const;
uint64_t boxHandler(std::ostream& out, Exiv2::PrintStructureOption option, uint64_t pbox_end, size_t depth);
uint32_t fileType_{0};
std::set<size_t> visits_;
uint64_t visits_max_{0};
uint16_t unknownID_{0xffff};
uint16_t exifID_{0xffff};
uint16_t xmpID_{0};
std::map<uint32_t, Iloc> ilocs_;
bool bReadMetadata_{false};
const size_t max_box_depth_;
static std::string toAscii(uint32_t n);
std::string boxName(uint32_t box);
static bool superBox(uint32_t box);
static bool fullBox(uint32_t box);
static std::string uuidName(const Exiv2::DataBuf& uuid);
#ifdef EXV_HAVE_BROTLI
static void brotliUncompress(const byte* compressedBuf, size_t compressedBufSize, DataBuf& arr);
#endif
}; // class BmffImage
// *****************************************************************************
// template, inline and free functions
// These could be static private functions on Image subclasses but then
// ImageFactory needs to be made a friend.
EXIV2API Image::UniquePtr newBmffInstance(BasicIo::UniquePtr io, bool create);
EXIV2API bool isBmffType(BasicIo& iIo, bool advance);
} // namespace Exiv2
#endif // EXV_ENABLE_BMFF
Exiv2::BasicIo
An interface for simple binary IO.
Definition basicio.hpp:35
Exiv2::BasicIo::UniquePtr
std::unique_ptr< BasicIo > UniquePtr
BasicIo auto_ptr type.
Definition basicio.hpp:38
Exiv2::BmffImage::writeMetadata
void writeMetadata() override
Write metadata back to the image.
Exiv2::BmffImage::readMetadata
void readMetadata() override
Read all metadata supported by a specific image format from the image. Before this method is called,...
Exiv2::BmffImage::parseXmp
void parseXmp(uint64_t length, uint64_t start)
parse embedded xmp/xml
Exiv2::BmffImage::parseTiff
void parseTiff(uint32_t root_tag, uint64_t length, uint64_t start)
parse embedded tiff file (Exif metadata)
Exiv2::BmffImage::printStructure
void printStructure(std::ostream &out, Exiv2::PrintStructureOption option, size_t depth) override
Print out the structure of image file.
Exiv2::BmffImage::pixelHeight
uint32_t pixelHeight() const override
Return the pixel height of the image.
Exiv2::BmffImage::setComment
void setComment(const std::string &comment) override
Set the image comment. The comment is written to the image when writeMetadata() is called.
Exiv2::BmffImage::mimeType
std::string mimeType() const override
Return the MIME type of the image.
Exiv2::BmffImage::setIptcData
void setIptcData(const IptcData &) override
Assign new IPTC data. The new IPTC data is not written to the image until the writeMetadata() method ...
Exiv2::BmffImage::BmffImage
BmffImage(BasicIo::UniquePtr io, bool create, size_t max_box_depth=1000)
Constructor to open a BMFF image. Since the constructor can not return a result, callers should check...
Exiv2::BmffImage::parseCr3Preview
void parseCr3Preview(const DataBuf &data, std::ostream &out, bool bTrace, uint8_t version, size_t width_offset, size_t height_offset, size_t size_offset, size_t relative_position)
Parse a Canon PRVW or THMB box and add an entry to the set of native previews.
Exiv2::BmffImage::pixelWidth
uint32_t pixelWidth() const override
Return the pixel width of the image.
Exiv2::BmffImage::setExifData
void setExifData(const ExifData &) override
Assign new Exif data. The new Exif data is not written to the image until the writeMetadata() method ...
Exiv2::BmffImage::setXmpData
void setXmpData(const XmpData &) override
Assign new XMP data. The new XMP data is not written to the image until the writeMetadata() method is...
Exiv2::ExifData
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition exif.hpp:379
Exiv2::Image::Image
Image(ImageType type, uint16_t supportedMetadata, BasicIo::UniquePtr io)
Constructor taking the image type, a bitmap of the supported metadata types and an auto-pointer that ...
Definition image.cpp:132
Exiv2::Image::comment
virtual std::string comment() const
Return a copy of the image comment. May be an empty string.
Definition image.cpp:688
Exiv2::Image::io
virtual BasicIo & io() const
Return a reference to the BasicIo instance being used for Io.
Definition image.cpp:696
Exiv2::Image::UniquePtr
std::unique_ptr< Image > UniquePtr
Image auto_ptr type.
Definition image.hpp:53
Exiv2::IptcData
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition iptc.hpp:153
Exiv2::XmpData
A container for XMP data. This is a top-level class of the Exiv2 library.
Definition xmp_exiv2.hpp:138
Exiv2
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
Exiv2::PrintStructureOption
PrintStructureOption
Options for printStructure.
Definition image.hpp:38
Exiv2::version
EXIV2API const char * version()
Return the version of Exiv2 as "C" string eg "0.27.0.2".
Definition version.cpp:82
Exiv2::newBmffInstance
EXIV2API Image::UniquePtr newBmffInstance(BasicIo::UniquePtr io, bool create)
Create a new BMFF instance and return an auto-pointer to it. Caller owns the returned object and the ...
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian).
Definition types.hpp:34
Exiv2::isBmffType
EXIV2API bool isBmffType(BasicIo &iIo, bool advance)
Check if the file iIo is a BMFF image.
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124