Bumping manifests a=b2g-bump
[gecko.git] / image / decoders / EXIF.h
blob62a83cedb57e3b0b238ec11fa5eb2a0f5709749f
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_IMAGELIB_EXIF_H_
7 #define MOZILLA_IMAGELIB_EXIF_H_
9 #include <stdint.h>
10 #include "mozilla/TypedEnum.h"
11 #include "nsDebug.h"
13 #include "Orientation.h"
15 namespace mozilla {
16 namespace image {
18 MOZ_BEGIN_ENUM_CLASS(ByteOrder, uint8_t)
19 Unknown,
20 LittleEndian,
21 BigEndian
22 MOZ_END_ENUM_CLASS(ByteOrder)
24 struct EXIFData
26 EXIFData() { }
27 explicit EXIFData(Orientation aOrientation) : orientation(aOrientation) { }
29 const Orientation orientation;
32 class EXIFParser
34 public:
35 static EXIFData
36 Parse(const uint8_t* aData, const uint32_t aLength)
38 EXIFParser parser;
39 return parser.ParseEXIF(aData, aLength);
42 private:
43 EXIFParser()
44 : mStart(nullptr)
45 , mCurrent(nullptr)
46 , mLength(0)
47 , mRemainingLength(0)
48 , mByteOrder(ByteOrder::Unknown)
49 { }
51 EXIFData ParseEXIF(const uint8_t* aData, const uint32_t aLength);
52 bool ParseEXIFHeader();
53 bool ParseTIFFHeader(uint32_t& aIFD0OffsetOut);
54 bool ParseIFD0(Orientation& aOrientationOut);
55 bool ParseOrientation(uint16_t aType, uint32_t aCount, Orientation& aOut);
57 bool Initialize(const uint8_t* aData, const uint32_t aLength);
58 void Advance(const uint32_t aDistance);
59 void JumpTo(const uint32_t aOffset);
61 bool MatchString(const char* aString, const uint32_t aLength);
62 bool MatchUInt16(const uint16_t aValue);
63 bool ReadUInt16(uint16_t& aOut);
64 bool ReadUInt32(uint32_t& aOut);
66 const uint8_t* mStart;
67 const uint8_t* mCurrent;
68 uint32_t mLength;
69 uint32_t mRemainingLength;
70 ByteOrder mByteOrder;
76 #endif