From patchwork Thu Sep 24 18:36:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 9796 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 5FE78C3B5B for ; Thu, 24 Sep 2020 18:37:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7B3EC62F4F; Thu, 24 Sep 2020 20:37:00 +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="OuYuaTmK"; 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 8CC3662F4F for ; Thu, 24 Sep 2020 20:36:58 +0200 (CEST) From: Umang Jain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail; t=1600972618; bh=v+T2p+UETjllPjGohbyeiUXogk8kOItTOBlRt9UXl50=; h=From:To:Cc:Subject:In-Reply-To:References; b=OuYuaTmKh33wP0DXmEfeGU1SeOpPFQ65K+4z1F2wba9qERVP32a5rg2zJD5SGgmxy aZkT8iZEYksVY4HFHnDPQkKYeNVATbD0HPWMkm9G9q+Wa9N6mPJrZ+np2n+HAGHmVS RzjYn3wH5l0HXkkqVHgEe/rv6Df1634ibJggHumuesRe/mDSlro8r1oSS6omA/Mf5s gSq0QzUhdgr9wycAOtHpsR3CS6r36uuqGOYjUI5DfdJ9Pp3n6bMBQKcNpox1dn1m2t 9bhinAxO5a6yC14fis0K+JoXzx4hJhRHFSffIKDn/bs6lOfiE25tpBgaPsFIBvgTfh r/wgZcIxX+xJA== To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Sep 2020 00:06:41 +0530 Message-Id: <20200924183642.7674-2-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 1/2] android: jpeg: exif: Pad extra byte only for ASCII format in setString() 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 standard states that EXIF_FORMAT_UNDEFINED shall not be terminated with NULL. The patch implements this particular detail and pad one extra byte for EXIF_FORMAT_ASCII to null-terminate strings. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/android/jpeg/exif.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index c0dbfcc..a5674b3 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -157,8 +157,9 @@ void Exif::setRational(ExifIfd ifd, ExifTag tag, ExifRational item) void Exif::setString(ExifIfd ifd, ExifTag tag, ExifFormat format, const std::string &item) { - /* Pad 1 extra byte for null-terminated string. */ - size_t length = item.length() + 1; + /* Pad 1 extra byte for null-terminated string in ASCII format. */ + size_t length = format == EXIF_FORMAT_ASCII ? + item.length() + 1 : item.length(); ExifEntry *entry = createEntry(ifd, tag, format, length, length); if (!entry) 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)