From patchwork Thu Sep 24 09:50:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9785 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 8C8EDC3B5C for ; Thu, 24 Sep 2020 09:50:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5C1B262FF1; Thu, 24 Sep 2020 11:50:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jFZ75e9P"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7EC8662FD8 for ; Thu, 24 Sep 2020 11:50:12 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0B19B2FD; Thu, 24 Sep 2020 11:50:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1600941012; bh=PIDcw/gkrxsioFDiTw/zrGf+wR2oddoKwHSX6gJeL7U=; h=From:To:Cc:Subject:Date:From; b=jFZ75e9PwmhbwuCPet5UxG/pkvnTnBnJpWu9olWSHbthmtkAHE+o7BqAR+zIdhAnx OSU7QnEA8RvH7HvOekL0pOQ90dW2t/09ih6jvwVXCgEK7lZPO0+3vPH52ZEwH6XFnO RWByhWdyS6YIJgqhbNNu63v6jiCkc1lZSOl0eY/w= From: Kieran Bingham To: libcamera devel , Umang Jain Date: Thu, 24 Sep 2020 10:50:08 +0100 Message-Id: <20200924095008.338920-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] src: android: exif: Set the class byte ordering X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 redudant, 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. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain --- This patch itself feels like it might be a bit redundant, but I saw the repetition, and whilst we're not likely to change the byte order, I thought it might make sense to ensure it's always set from the same state variable. If this is helpful we can add it, but if this is overkill I don't mind dropping it. It's just an idea. src/android/jpeg/exif.cpp | 11 ++++++----- src/android/jpeg/exif.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index 1ced55343ee9..f29a7c71d1ec 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -25,7 +25,8 @@ LOG_DEFINE_CATEGORY(EXIF) * 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(); @@ -49,7 +50,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_); /* Create the mandatory EXIF fields with default data. */ exif_data_fix(data_); @@ -131,7 +132,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); } @@ -141,7 +142,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); } @@ -151,7 +152,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 622de4cfd593..6e8ce04a2e67 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_;