33#ifndef JPGIMAGE_HPP_
44#define JPGIMAGE_HPP_
55
6- // *****************************************************************************
76#include " exiv2lib_export.h"
87
9- #include < array>
10-
118// included header files
129#include " error.hpp"
1310#include " image.hpp"
@@ -18,59 +15,6 @@ namespace Exiv2 {
1815// *****************************************************************************
1916// class definitions
2017
21- // / @brief Helper class, has methods to deal with %Photoshop "Information Resource Blocks" (IRBs).
22- struct EXIV2API Photoshop {
23- // Todo: Public for now
24- static constexpr std::array irbId_{" 8BIM" , " AgHg" , " DCSR" , " PHUT" }; // !< %Photoshop IRB markers
25- static constexpr auto ps3Id_ = " Photoshop 3.0\0 " ; // !< %Photoshop marker
26- static constexpr uint16_t iptc_ = 0x0404 ; // !< %Photoshop IPTC marker
27- static constexpr uint16_t preview_ = 0x040c ; // !< %Photoshop preview marker
28-
29- // / @brief Checks an IRB
30- // / @param pPsData Existing IRB buffer. It is expected to be of size 4.
31- // / @return true if the IRB marker is known
32- // / @todo This should be an implementation detail and not exposed in the API. An attacker could try to pass
33- // / a smaller buffer or null pointer.
34- static bool isIrb (const byte* pPsData);
35-
36- // / @brief Validates all IRBs
37- // / @param pPsData Existing IRB buffer
38- // / @param sizePsData Size of the IRB buffer, may be 0
39- // / @return true if all IRBs are valid;<BR> false otherwise
40- static bool valid (const byte* pPsData, size_t sizePsData);
41-
42- // / @brief Locates the data for a %Photoshop tag in a %Photoshop formated memory buffer.
43- // / Operates on raw data to simplify reuse.
44- // / @param pPsData Pointer to buffer containing entire payload of %Photoshop formated data (from APP13 Jpeg segment)
45- // / @param sizePsData Size in bytes of pPsData.
46- // / @param psTag %Tag number of the block to look for.
47- // / @param record Output value that is set to the start of the data block within pPsData (may not be null).
48- // / @param sizeHdr Output value that is set to the size of the header within the data block pointed to by record
49- // / (may not be null).
50- // / @param sizeData Output value that is set to the size of the actual data within the data block pointed to by record
51- // / (may not be null).
52- // / @return 0 if successful;<BR>
53- // / 3 if no data for psTag was found in pPsData;<BR>
54- // / -2 if the pPsData buffer does not contain valid data.
55- static int locateIrb (const byte* pPsData, size_t sizePsData, uint16_t psTag, const byte** record,
56- uint32_t * const sizeHdr, uint32_t * const sizeData);
57-
58- // / @brief Forwards to locateIrb() with \em psTag = \em iptc_
59- static int locateIptcIrb (const byte* pPsData, size_t sizePsData, const byte** record, uint32_t * const sizeHdr,
60- uint32_t * const sizeData);
61-
62- // / @brief Forwards to locatePreviewIrb() with \em psTag = \em preview_
63- static int locatePreviewIrb (const byte* pPsData, size_t sizePsData, const byte** record, uint32_t * const sizeHdr,
64- uint32_t * const sizeData);
65-
66- // / @brief Set the new IPTC IRB, keeps existing IRBs but removes the IPTC block if there is no new IPTC data to write.
67- // / @param pPsData Existing IRB buffer
68- // / @param sizePsData Size of the IRB buffer, may be 0
69- // / @param iptcData Iptc data to embed, may be empty
70- // / @return A data buffer containing the new IRB buffer, may have 0 size
71- static DataBuf setIptcIrb (const byte* pPsData, size_t sizePsData, const IptcData& iptcData);
72- };
73-
7418/* !
7519 @brief Abstract helper base class to access JPEG images.
7620 */
@@ -151,44 +95,6 @@ class EXIV2API JpegBase : public Image {
15195 virtual int writeHeader (BasicIo& oIo) const = 0;
15296 // @}
15397
154- // Constant Data
155- static constexpr byte dht_ = 0xc4 ; // !< JPEG DHT marker
156- static constexpr byte dqt_ = 0xdb ; // !< JPEG DQT marker
157- static constexpr byte dri_ = 0xdd ; // !< JPEG DRI marker
158- static constexpr byte sos_ = 0xda ; // !< JPEG SOS marker
159- static constexpr byte eoi_ = 0xd9 ; // !< JPEG EOI marker
160- static constexpr byte app0_ = 0xe0 ; // !< JPEG APP0 marker
161- static constexpr byte app1_ = 0xe1 ; // !< JPEG APP1 marker
162- static constexpr byte app2_ = 0xe2 ; // !< JPEG APP2 marker
163- static constexpr byte app13_ = 0xed ; // !< JPEG APP13 marker
164- static constexpr byte com_ = 0xfe ; // !< JPEG Comment marker
165-
166- // Start of Frame markers, nondifferential Huffman-coding frames
167- static constexpr byte sof0_ = 0xc0 ; // !< JPEG Start-Of-Frame marker
168- static constexpr byte sof1_ = 0xc1 ; // !< JPEG Start-Of-Frame marker
169- static constexpr byte sof2_ = 0xc2 ; // !< JPEG Start-Of-Frame marker
170- static constexpr byte sof3_ = 0xc3 ; // !< JPEG Start-Of-Frame marker
171-
172- // Start of Frame markers, differential Huffman-coding frames
173- static constexpr byte sof5_ = 0xc5 ; // !< JPEG Start-Of-Frame marker
174- static constexpr byte sof6_ = 0xc6 ; // !< JPEG Start-Of-Frame marker
175- static constexpr byte sof7_ = 0xc7 ; // !< JPEG Start-Of-Frame marker
176-
177- // Start of Frame markers, nondifferential arithmetic-coding frames
178- static constexpr byte sof9_ = 0xc9 ; // !< JPEG Start-Of-Frame marker
179- static constexpr byte sof10_ = 0xca ; // !< JPEG Start-Of-Frame marker
180- static constexpr byte sof11_ = 0xcb ; // !< JPEG Start-Of-Frame marker
181-
182- // Start of Frame markers, differential arithmetic-coding frames
183- static constexpr byte sof13_ = 0xcd ; // !< JPEG Start-Of-Frame marker
184- static constexpr byte sof14_ = 0xce ; // !< JPEG Start-Of-Frame marker
185- static constexpr byte sof15_ = 0xcf ; // !< JPEG Start-Of-Frame marker
186-
187- static constexpr auto exifId_ = " Exif\0\0 " ; // !< Exif identifier
188- static constexpr auto jfifId_ = " JFIF\0 " ; // !< JFIF identifier
189- static constexpr auto xmpId_ = " http://ns.adobe.com/xap/1.0/\0 " ; // !< XMP packet identifier
190- static constexpr auto iccId_ = " ICC_PROFILE\0 " ; // !< ICC profile identifier
191-
19298 private:
19399 // ! @name Manipulators
194100 // @{
@@ -225,14 +131,7 @@ class EXIV2API JpegBase : public Image {
225131 // @}
226132
227133 DataBuf readNextSegment (byte marker);
228-
229- /* !
230- @brief Is the marker followed by a non-zero payload?
231- @param marker The marker at the start of a segment
232- @return true if the marker is followed by a non-zero payload
233- */
234- static bool markerHasLength (byte marker);
235- }; // class JpegBase
134+ };
236135
237136/* !
238137 @brief Class to access JPEG images
@@ -292,9 +191,8 @@ class EXIV2API JpegImage : public JpegBase {
292191
293192 private:
294193 // Constant data
295- static constexpr byte soi_ = 0xd8 ; // SOI marker
296- static const byte blank_[]; // Minimal Jpeg image
297- }; // class JpegImage
194+ static const byte blank_[]; // /< Minimal Jpeg image
195+ };
298196
299197// ! Helper class to access %Exiv2 files
300198class EXIV2API ExvImage : public JpegBase {
0 commit comments