From patchwork Thu Sep 24 09:06:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 9779 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 BCDEDC3B5C for ; Thu, 24 Sep 2020 09:06:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6AA9762FDE; Thu, 24 Sep 2020 11:06:39 +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="h7C329b3"; 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 A6F1D60362 for ; Thu, 24 Sep 2020 11:06:37 +0200 (CEST) From: Umang Jain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail; t=1600938397; bh=v3/00sM72yfMrjWxZ7NM1fmCDiJmsO6fMfzTCF/6bkI=; h=From:To:Cc:Subject; b=h7C329b3WDpIvwUP03kwdNvNvLcKjfTCfHUVVw5wfjlOMvmHknzCjjJoHJqEB7RwB dG25jlQNlDJqvnDS0jJHyMY//2VE+ZXzM30TJu1jJVKmUHD2Xk7MWjTcP0Efu1vf+3 IsE06Y4/eWMHug39z0KjE6NVOWQRdtHPu3iHsGPoktawZLMZS931JzwDxtutTpBelX llyKk+bOIu61KPd2QFUo6saWJXFpeAc2SrkJAX+0tNCmQ7tivn328V3QUBXIo75MU8 N46YJq4s8OcNp+i4hBDpImSI8KlIR8sFYNk+tHsXLtPZcEHi2mzD1uBEepNEuOMR9C zu96nS2iEmq0A== To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Sep 2020 14:36:31 +0530 Message-Id: <20200924090631.18473-1-email@uajain.com> Mime-Version: 1.0 Subject: [libcamera-devel] [PATCH] 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 --- 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 c0dbfcc..df38765 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 _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_); } @@ -196,6 +209,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)