summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2020-09-24 10:47:27 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2020-10-02 10:21:45 +0100
commit39d56fcfa0206f373bd169c408d6501f3551d124 (patch)
tree71c5aecee4022a1dd9e2ca861b327279ec0ce593
parentd4432da031b76a17d437d4f4b6ff56d657a08051 (diff)
src: android: exif: Set the class byte ordering
The exif object sets the byte ordering on construction, and then during later calls re-states the byte ordering when setting values. It could be argued that this ordering should already be known to the exif library and is redundant, but even so we must provide it. Ensure we are consistent in always using the same byte ordering by setting a private class member to re-use a single value. Reviewed-by: Umang Jain <email@uajain.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--src/android/jpeg/exif.cpp11
-rw-r--r--src/android/jpeg/exif.h1
2 files changed, 7 insertions, 5 deletions
diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp
index 32cf8974..3fd5d556 100644
--- a/src/android/jpeg/exif.cpp
+++ b/src/android/jpeg/exif.cpp
@@ -35,7 +35,8 @@ enum class _ExifTag {
* data can be obtained using the data() method.
*/
Exif::Exif()
- : valid_(false), data_(nullptr), exifData_(0), size_(0)
+ : valid_(false), data_(nullptr), order_(EXIF_BYTE_ORDER_INTEL),
+ exifData_(0), size_(0)
{
/* Create an ExifMem allocator to construct entries. */
mem_ = exif_mem_new_default();
@@ -59,7 +60,7 @@ Exif::Exif()
* Big-Endian: EXIF_BYTE_ORDER_MOTOROLA
* Little Endian: EXIF_BYTE_ORDER_INTEL
*/
- exif_data_set_byte_order(data_, EXIF_BYTE_ORDER_INTEL);
+ exif_data_set_byte_order(data_, order_);
setString(EXIF_IFD_EXIF, EXIF_TAG_EXIF_VERSION,
EXIF_FORMAT_UNDEFINED, "0231");
@@ -144,7 +145,7 @@ void Exif::setShort(ExifIfd ifd, ExifTag tag, uint16_t item)
if (!entry)
return;
- exif_set_short(entry->data, EXIF_BYTE_ORDER_INTEL, item);
+ exif_set_short(entry->data, order_, item);
exif_entry_unref(entry);
}
@@ -154,7 +155,7 @@ void Exif::setLong(ExifIfd ifd, ExifTag tag, uint32_t item)
if (!entry)
return;
- exif_set_long(entry->data, EXIF_BYTE_ORDER_INTEL, item);
+ exif_set_long(entry->data, order_, item);
exif_entry_unref(entry);
}
@@ -164,7 +165,7 @@ void Exif::setRational(ExifIfd ifd, ExifTag tag, ExifRational item)
if (!entry)
return;
- exif_set_rational(entry->data, EXIF_BYTE_ORDER_INTEL, item);
+ exif_set_rational(entry->data, order_, item);
exif_entry_unref(entry);
}
diff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h
index f04cefce..77d1177e 100644
--- a/src/android/jpeg/exif.h
+++ b/src/android/jpeg/exif.h
@@ -46,6 +46,7 @@ private:
ExifData *data_;
ExifMem *mem_;
+ ExifByteOrder order_;
unsigned char *exifData_;
unsigned int size_;