summaryrefslogtreecommitdiffstats
path: root/image/decoders/EXIF.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /image/decoders/EXIF.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'image/decoders/EXIF.h')
-rw-r--r--image/decoders/EXIF.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/image/decoders/EXIF.h b/image/decoders/EXIF.h
new file mode 100644
index 000000000..9028f2cf8
--- /dev/null
+++ b/image/decoders/EXIF.h
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_image_decoders_EXIF_h
+#define mozilla_image_decoders_EXIF_h
+
+#include <stdint.h>
+#include "nsDebug.h"
+
+#include "Orientation.h"
+
+namespace mozilla {
+namespace image {
+
+enum class ByteOrder : uint8_t {
+ Unknown,
+ LittleEndian,
+ BigEndian
+};
+
+struct EXIFData
+{
+ EXIFData() { }
+ explicit EXIFData(Orientation aOrientation) : orientation(aOrientation) { }
+
+ const Orientation orientation;
+};
+
+class EXIFParser
+{
+public:
+ static EXIFData
+ Parse(const uint8_t* aData, const uint32_t aLength)
+ {
+ EXIFParser parser;
+ return parser.ParseEXIF(aData, aLength);
+ }
+
+private:
+ EXIFParser()
+ : mStart(nullptr)
+ , mCurrent(nullptr)
+ , mLength(0)
+ , mRemainingLength(0)
+ , mByteOrder(ByteOrder::Unknown)
+ { }
+
+ EXIFData ParseEXIF(const uint8_t* aData, const uint32_t aLength);
+ bool ParseEXIFHeader();
+ bool ParseTIFFHeader(uint32_t& aIFD0OffsetOut);
+ bool ParseIFD0(Orientation& aOrientationOut);
+ bool ParseOrientation(uint16_t aType, uint32_t aCount, Orientation& aOut);
+
+ bool Initialize(const uint8_t* aData, const uint32_t aLength);
+ void Advance(const uint32_t aDistance);
+ void JumpTo(const uint32_t aOffset);
+
+ bool MatchString(const char* aString, const uint32_t aLength);
+ bool MatchUInt16(const uint16_t aValue);
+ bool ReadUInt16(uint16_t& aOut);
+ bool ReadUInt32(uint32_t& aOut);
+
+ const uint8_t* mStart;
+ const uint8_t* mCurrent;
+ uint32_t mLength;
+ uint32_t mRemainingLength;
+ ByteOrder mByteOrder;
+};
+
+} // namespace image
+} // namespace mozilla
+
+#endif // mozilla_image_decoders_EXIF_h