@@ -39,7 +39,7 @@ constexpr byte app1_ = 0xe1; //!< JPEG APP1 marker
3939constexpr byte app2_ = 0xe2 ; // !< JPEG APP2 marker
4040constexpr byte app13_ = 0xed ; // !< JPEG APP13 marker
4141constexpr byte com_ = 0xfe ; // !< JPEG Comment marker
42- constexpr byte soi_ = 0xd8 ; // /!< SOI marker
42+ constexpr byte soi_ = 0xd8 ; // /!< SOI marker
4343
4444// Start of Frame markers, nondifferential Huffman-coding frames
4545constexpr byte sof0_ = 0xc0 ; // !< JPEG Start-Of-Frame marker
@@ -74,6 +74,16 @@ inline bool inRange(int lo, int value, int hi) {
7474inline bool inRange2 (int value, int lo1, int hi1, int lo2, int hi2) {
7575 return inRange (lo1, value, hi1) || inRange (lo2, value, hi2);
7676}
77+
78+ // / @brief has the segment a non-zero payload?
79+ // / @param marker The marker at the start of a segment
80+ // / @return true if the segment has a length field/payload
81+ bool markerHasLength (byte marker) {
82+ // / \todo there are less markers without payload. Maybe we should revert the logic.
83+ return (marker >= sof0_ && marker <= sof15_) || (marker >= app0_ && marker <= (app0_ | 0x0F )) || marker == dht_ ||
84+ marker == dqt_ || marker == dri_ || marker == com_ || marker == sos_;
85+ }
86+
7787} // namespace
7888
7989bool Photoshop::isIrb (const byte* pPsData) {
@@ -250,11 +260,6 @@ DataBuf Photoshop::setIptcIrb(const byte* pPsData, size_t sizePsData, const Iptc
250260 return rc;
251261}
252262
253- bool JpegBase::markerHasLength (byte marker) {
254- return (marker >= sof0_ && marker <= sof15_) || (marker >= app0_ && marker <= (app0_ | 0x0F )) || marker == dht_ ||
255- marker == dqt_ || marker == dri_ || marker == com_ || marker == sos_;
256- }
257-
258263JpegBase::JpegBase (ImageType type, BasicIo::UniquePtr io, bool create, const byte initData[], size_t dataSize) :
259264 Image (type, mdExif | mdIptc | mdXmp | mdComment, std::move(io)) {
260265 if (create) {
@@ -314,6 +319,7 @@ void JpegBase::readMetadata() {
314319 byte marker = advanceToMarker (ErrorCode::kerNotAJpeg);
315320
316321 while (marker != sos_ && marker != eoi_ && search > 0 ) {
322+ // / @todo the block to read the size of the segment is repeated in 3 places. Factor-out
317323 // 2-byte buffer for reading the size.
318324 std::array<byte, 2 > sizebuf;
319325 uint16_t size = 0 ; // Size of the segment, including the 2-byte size field
0 commit comments