From patchwork Thu Sep 24 18:36:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 9797 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 6EA9EC3B5B for ; Thu, 24 Sep 2020 18:37:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3AF2F63017; Thu, 24 Sep 2020 20:37:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="BgRgXaPj"; dkim-atps=neutral Received: from mail.uajain.com (static.126.159.217.95.clients.your-server.de [95.217.159.126]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 237E263017 for ; Thu, 24 Sep 2020 20:37:01 +0200 (CEST) From: Umang Jain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail; t=1600972620; bh=p6IGTgqQJYCq195rt+k/VmYPhmpuFyEdXEo1tSaemnY=; h=From:To:Cc:Subject:In-Reply-To:References; b=BgRgXaPjqua+5naGIiAZG91UVD2vgQ1xsQYRRYpuNHw8iVeFYnkqU6aGYK7F8eh3i qPXq4IgExSIV06Opy2qvne1hK1KWxSQQBBnVnm+03AjH5jXsWKh8CU6Jz2vo8FQ9ho ZM/80riztecAQF3cXnwdSW4b2YiNgkhGkBDJ4a6pZbBCs2/GdLrK45uUsTVqJvHXo0 +SQdoFTrUXEQNgQ6HeX1VIvRjD+8z8Lnm5ugEYH8nxeDipErcJ/X8frRY9QYGMbSIG pncVgrrHG7PKI2lzn74O8AbGu3kN19FTqdnre0QUBI8M4ScuP5InHDsYpfUt60ZeUf FwkSq44NXU4Jw== To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Sep 2020 00:06:42 +0530 Message-Id: <20200924183642.7674-3-email@uajain.com> In-Reply-To: <20200924183642.7674-1-email@uajain.com> References: <20200924183642.7674-1-email@uajain.com> Mime-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] android: jpeg: exif: Set timezone information 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 specification defines three timezone related tags namely, OffsetTime, OffsetTimeOriginal and OffsetTimeDigitized. However, these are not supported by libexif (as of v0.6.21) hence, carry the tags' positional values in our implementation until we get this support from libexif itself. Since these tags were introduced in EXIF specification v2.31, set the exif version number explicitly too. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/android/jpeg/exif.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index a5674b3..32cf897 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -13,6 +13,16 @@ using namespace libcamera; LOG_DEFINE_CATEGORY(EXIF) +/* + * List of EXIF tags that we set directly because they are not supported + * by libexif version 0.6.21. + */ +enum class _ExifTag { + OFFSET_TIME = 0x9010, + OFFSET_TIME_ORIGINAL = 0x9011, + OFFSET_TIME_DIGITIZED = 0x9012, +}; + /* * The Exif class should be instantiated and specific properties set * through the exposed public API. @@ -51,6 +61,9 @@ Exif::Exif() */ exif_data_set_byte_order(data_, EXIF_BYTE_ORDER_INTEL); + setString(EXIF_IFD_EXIF, EXIF_TAG_EXIF_VERSION, + EXIF_FORMAT_UNDEFINED, "0231"); + /* Create the mandatory EXIF fields with default data. */ exif_data_fix(data_); } @@ -197,6 +210,22 @@ void Exif::setTimestamp(time_t timestamp) setString(EXIF_IFD_0, EXIF_TAG_DATE_TIME, EXIF_FORMAT_ASCII, ts); setString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL, EXIF_FORMAT_ASCII, ts); setString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_DIGITIZED, EXIF_FORMAT_ASCII, ts); + + /* Query and set timezone information if available. */ + int r = strftime(str, sizeof(str), "%z", &tm); + if (r > 0) { + std::string tz(str); + tz.insert(3, 1, ':'); + setString(EXIF_IFD_EXIF, + static_cast(_ExifTag::OFFSET_TIME), + EXIF_FORMAT_ASCII, tz); + setString(EXIF_IFD_EXIF, + static_cast(_ExifTag::OFFSET_TIME_ORIGINAL), + EXIF_FORMAT_ASCII, tz); + setString(EXIF_IFD_EXIF, + static_cast(_ExifTag::OFFSET_TIME_DIGITIZED), + EXIF_FORMAT_ASCII, tz); + } } void Exif::setOrientation(int orientation)