Exiv2
bmffimage.hpp
1// ***************************************************************** -*- C++ -*-
2/*
3 * Copyright (C) 2021 Exiv2 authors
4 * This program is part of the Exiv2 distribution.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19 */
20
21#pragma once
22
23// *****************************************************************************
24#include "exiv2lib_export.h"
25
26// included header files
27#include "image.hpp"
28#include "iostream"
29
30// *****************************************************************************
31// namespace extensions
32namespace Exiv2
33{
34 EXIV2API bool enableBMFF(bool enable = true);
35}
36
37#ifdef EXV_ENABLE_BMFF
38namespace Exiv2
39{
40 struct Iloc
41 {
42 explicit Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0)
43 : ID_(ID), start_(start), length_(length){};
44 virtual ~Iloc() = default;
45
46 uint32_t ID_;
47 uint32_t start_;
48 uint32_t length_;
49
50 std::string toString() const;
51 }; // class Iloc
52
53 // *****************************************************************************
54 // class definitions
55
56 // Add Base Media File Format to the supported image formats
57 namespace ImageType
58 {
59 const int bmff = 19;
60 }
61
65 class EXIV2API BmffImage : public Image
66 {
67 public:
69
70
84 BmffImage(BasicIo::UniquePtr io, bool create);
86
88
95 void parseTiff(uint32_t root_tag, uint64_t length);
96 void parseTiff(uint32_t root_tag, uint64_t length,uint64_t start);
98
100
106 void parseXmp(uint64_t length,uint64_t start);
108
110
123 std::ostream &out,
124 bool bTrace,
125 uint8_t version,
126 uint32_t width_offset,
127 uint32_t height_offset,
128 uint32_t size_offset,
129 uint32_t relative_position);
131
133
134 void readMetadata() override /* override */;
135 void writeMetadata() override /* override */;
136 void setComment(const std::string& comment) override /* override */;
137 void printStructure(std::ostream& out, Exiv2::PrintStructureOption option, int depth) override;
139
141
142 std::string mimeType() const override /* override */;
143 int pixelWidth() const override;
144 int pixelHeight() const override;
146
147 Exiv2::ByteOrder endian_{Exiv2::bigEndian};
148
149 private:
150 void openOrThrow();
159 long boxHandler(std::ostream& out, Exiv2::PrintStructureOption option,
160 const long pbox_end, int depth);
161 std::string indent(int i)
162 {
163 return std::string(2*i,' ');
164 }
165
166 uint32_t fileType_{0};
167 std::set<uint64_t> visits_;
168 uint64_t visits_max_{0};
169 uint16_t unknownID_{0xffff};
170 uint16_t exifID_{0xffff};
171 uint16_t xmpID_{0};
172 std::map<uint32_t, Iloc> ilocs_;
173 bool bReadMetadata_{false};
175
179 static std::string toAscii(long n);
180 std::string boxName(uint32_t box);
181 static bool superBox(uint32_t box);
182 static bool fullBox(uint32_t box);
183 static std::string uuidName(Exiv2::DataBuf& uuid);
184
185 }; // class BmffImage
186
187 // *****************************************************************************
188 // template, inline and free functions
189
190 // These could be static private functions on Image subclasses but then
191 // ImageFactory needs to be made a friend.
198
200 EXIV2API bool isBmffType(BasicIo& iIo, bool advance);
201} // namespace Exiv2
202#endif // EXV_ENABLE_BMFF
An interface for simple binary IO.
Definition: basicio.hpp:55
std::unique_ptr< BasicIo > UniquePtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
Class to access BMFF images.
Definition: bmffimage.hpp:66
void parseCr3Preview(DataBuf &data, std::ostream &out, bool bTrace, uint8_t version, uint32_t width_offset, uint32_t height_offset, uint32_t size_offset, uint32_t relative_position)
Parse a Canon PRVW or THMB box and add an entry to the set of native previews.
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
BmffImage(BasicIo::UniquePtr io, bool create)
Constructor to open a BMFF image. Since the constructor can not return a result, callers should check...
void parseTiff(uint32_t root_tag, uint64_t length)
parse embedded tiff file (Exif metadata)
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:78
std::unique_ptr< Image > UniquePtr
Image auto_ptr type.
Definition: image.hpp:81
const int bmff
BMFF (bmff) image type (see class BMFF)
Definition: bmffimage.hpp:59
std::string indent(int32_t d)
indent output for kpsRecursive in printStructure() .
Definition: image_int.cpp:106
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: basicio.hpp:43
PrintStructureOption
Options for printStructure.
Definition: image.hpp:64
EXIV2API const char * version()
Return the version of Exiv2 as "C" string eg "0.27.0.2".
Definition: version.cpp:105
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 ...
@ comment
Exiv2 type for the Exif user comment.
Definition: types.hpp:120
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:83
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:162
Definition: bmffimage.hpp:41