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>
This commit is contained in:
Kieran Bingham 2020-09-24 10:47:27 +01:00
parent d4432da031
commit 39d56fcfa0
2 changed files with 7 additions and 5 deletions

View file

@ -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);
}

View file

@ -46,6 +46,7 @@ private:
ExifData *data_;
ExifMem *mem_;
ExifByteOrder order_;
unsigned char *exifData_;
unsigned int size_;