Exiv2
Loading...
Searching...
No Matches
bmffimage.hpp
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#pragma once
4
5// *****************************************************************************
6#include "exiv2lib_export.h"
7
8// included header files
9#include "image.hpp"
10
11#include <set>
12
13// *****************************************************************************
14// namespace extensions
15namespace Exiv2 {
16[[deprecated]] EXIV2API bool enableBMFF(bool enable = true);
17} // namespace Exiv2
18
19#ifdef EXV_ENABLE_BMFF
20namespace Exiv2 {
21struct Iloc {
22 explicit Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length) {
23 }
24 virtual ~Iloc() = default;
25 Iloc(const Iloc&) = default;
26 Iloc& operator=(const Iloc&) = default;
27
28 uint32_t ID_;
29 uint32_t start_;
30 uint32_t length_;
31
32 [[nodiscard]] std::string toString() const;
33}; // class Iloc
34
35// *****************************************************************************
36// class definitions
37
41class EXIV2API BmffImage : public Image {
42 public:
44
45
59 BmffImage(BasicIo::UniquePtr io, bool create, size_t max_box_depth = 1000);
61
63 void parseTiff(uint32_t root_tag, uint64_t length);
71 void parseTiff(uint32_t root_tag, uint64_t length, uint64_t start);
73
75
81 void parseXmp(uint64_t length, uint64_t start);
83
85
97 void parseCr3Preview(const DataBuf& data, std::ostream& out, bool bTrace, uint8_t version, size_t width_offset,
98 size_t height_offset, size_t size_offset, size_t relative_position);
100
102
103 void readMetadata() override;
104 void writeMetadata() override;
105 void setExifData(const ExifData&) override;
106 void setIptcData(const IptcData&) override;
107 void setXmpData(const XmpData&) override;
108 void setComment(const std::string& comment) override;
109 void printStructure(std::ostream& out, Exiv2::PrintStructureOption option, size_t depth) override;
111
113
114 [[nodiscard]] std::string mimeType() const override;
115 [[nodiscard]] uint32_t pixelWidth() const override;
116 [[nodiscard]] uint32_t pixelHeight() const override;
118
119 static constexpr Exiv2::ByteOrder endian_{Exiv2::bigEndian};
120
121 private:
122 void openOrThrow() const;
131 uint64_t boxHandler(std::ostream& out, Exiv2::PrintStructureOption option, uint64_t pbox_end, size_t depth);
132
133 uint32_t fileType_{0};
134 std::set<size_t> visits_;
135 uint64_t visits_max_{0};
136 uint16_t unknownID_{0xffff};
137 uint16_t exifID_{0xffff};
138 uint16_t xmpID_{0};
139 std::map<uint32_t, Iloc> ilocs_;
140 bool bReadMetadata_{false};
141 const size_t max_box_depth_;
143
147 static std::string toAscii(uint32_t n);
148 std::string boxName(uint32_t box);
149 static bool superBox(uint32_t box);
150 static bool fullBox(uint32_t box);
151 static std::string uuidName(const Exiv2::DataBuf& uuid);
152
156#ifdef EXV_HAVE_BROTLI
157 static void brotliUncompress(const byte* compressedBuf, size_t compressedBufSize, DataBuf& arr);
158#endif
159
160}; // class BmffImage
161
162// *****************************************************************************
163// template, inline and free functions
164
165// These could be static private functions on Image subclasses but then
166// ImageFactory needs to be made a friend.
173
175EXIV2API bool isBmffType(BasicIo& iIo, bool advance);
176} // namespace Exiv2
177#endif // EXV_ENABLE_BMFF
An interface for simple binary IO.
Definition basicio.hpp:35
std::unique_ptr< BasicIo > UniquePtr
BasicIo auto_ptr type.
Definition basicio.hpp:38
Class to access BMFF images.
Definition bmffimage.hpp:41
void writeMetadata() override
Write metadata back to the image.
void readMetadata() override
Read all metadata supported by a specific image format from the image. Before this method is called,...
void parseXmp(uint64_t length, uint64_t start)
parse embedded xmp/xml
void parseTiff(uint32_t root_tag, uint64_t length, uint64_t start)
parse embedded tiff file (Exif metadata)
void printStructure(std::ostream &out, Exiv2::PrintStructureOption option, size_t depth) override
Print out the structure of image file.
uint32_t pixelHeight() const override
Return the pixel height of the image.
void setComment(const std::string &comment) override
Set the image comment. The comment is written to the image when writeMetadata() is called.
std::string mimeType() const override
Return the MIME type of the image.
void setIptcData(const IptcData &) override
Assign new IPTC data. The new IPTC data is not written to the image until the writeMetadata() method ...
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...
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.
uint32_t pixelWidth() const override
Return the pixel width of the image.
void setExifData(const ExifData &) override
Assign new Exif data. The new Exif data is not written to the image until the writeMetadata() method ...
void setXmpData(const XmpData &) override
Assign new XMP data. The new XMP data is not written to the image until the writeMetadata() method is...
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition exif.hpp:379
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition image.hpp:50
std::unique_ptr< Image > UniquePtr
Image auto_ptr type.
Definition image.hpp:53
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition iptc.hpp:153
A container for XMP data. This is a top-level class of the Exiv2 library.
Definition xmp_exiv2.hpp:138
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
PrintStructureOption
Options for printStructure.
Definition image.hpp:38
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 ...
ByteOrder
Type to express the byte order (little or big endian)
Definition types.hpp:34
EXIV2API bool isBmffType(BasicIo &iIo, bool advance)
Check if the file iIo is a BMFF image.
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124
Definition bmffimage.hpp:21