1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_image_decoders_EXIF_h
7 #define mozilla_image_decoders_EXIF_h
12 #include "Orientation.h"
17 enum class ByteOrder
: uint8_t { Unknown
, LittleEndian
, BigEndian
};
21 explicit EXIFData(Orientation aOrientation
) : orientation(aOrientation
) {}
23 const Orientation orientation
;
28 static EXIFData
Parse(const uint8_t* aData
, const uint32_t aLength
) {
30 return parser
.ParseEXIF(aData
, aLength
);
39 mByteOrder(ByteOrder::Unknown
) {}
41 EXIFData
ParseEXIF(const uint8_t* aData
, const uint32_t aLength
);
42 bool ParseEXIFHeader();
43 bool ParseTIFFHeader(uint32_t& aIFD0OffsetOut
);
44 bool ParseIFD0(Orientation
& aOrientationOut
);
45 bool ParseOrientation(uint16_t aType
, uint32_t aCount
, Orientation
& aOut
);
47 bool Initialize(const uint8_t* aData
, const uint32_t aLength
);
48 void Advance(const uint32_t aDistance
);
49 void JumpTo(const uint32_t aOffset
);
51 bool MatchString(const char* aString
, const uint32_t aLength
);
52 bool MatchUInt16(const uint16_t aValue
);
53 bool ReadUInt16(uint16_t& aOut
);
54 bool ReadUInt32(uint32_t& aOut
);
56 const uint8_t* mStart
;
57 const uint8_t* mCurrent
;
59 uint32_t mRemainingLength
;
64 } // namespace mozilla
66 #endif // mozilla_image_decoders_EXIF_h