From patchwork Mon Mar 8 10:13:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11510 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 9756FBD1F1 for ; Mon, 8 Mar 2021 10:14:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 562F268A9C; Mon, 8 Mar 2021 11:14:10 +0100 (CET) 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="b/6nKtBV"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F15B68A99 for ; Mon, 8 Mar 2021 11:14:08 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9D5F38A3; Mon, 8 Mar 2021 11:14:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615198447; bh=6xfJtuj/oum/b10JoZZyGFiXQYYdF0o/iJE6ATxdV58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b/6nKtBVMHxR7s+TL5qTt/RyHnXSi2e6Ku6ZQzmsafJgzUQ6OAIReJFfdzjfLokfW ZwIealst9Fc7KH5WSUmrS3rMoeq93X4oMp1mtMF/bL/P0ihHCe9g57MhEYHBNIPg1v Fa7WTgT2oWwlekrzv0KbWUj8Uzy2/9DkeMw7ky00= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 19:13:53 +0900 Message-Id: <20210308101356.59333-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210308101356.59333-1-paul.elder@ideasonboard.com> References: <20210308101356.59333-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] android: jpeg: exif: Fix and expand setRational 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" setRational was not working properly for EXIF tags in the GPS IFD. Manually specify the size of the EXIF entry to fix this. While at it, add support for setting multiple rationals, as that is a common use case for rational EXIF tags. This allows the GPS altitude to be set properly, and is part of the fix to allow the following CTS test to pass: - android.hardware.cts.CameraTest#testJpegExif Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/android/jpeg/exif.cpp | 13 +++++++++++-- src/android/jpeg/exif.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index fdd46070..e5a3e448 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -187,11 +187,20 @@ void Exif::setLong(ExifIfd ifd, ExifTag tag, uint32_t item) void Exif::setRational(ExifIfd ifd, ExifTag tag, ExifRational item) { - ExifEntry *entry = createEntry(ifd, tag); + ExifRational items[] = { item }; + setRational(ifd, tag, 1, items); +} + +void Exif::setRational(ExifIfd ifd, ExifTag tag, uint32_t count, ExifRational items[]) +{ + ExifEntry *entry = createEntry(ifd, tag, EXIF_FORMAT_RATIONAL, + count, count * sizeof(ExifRational)); if (!entry) return; - exif_set_rational(entry->data, order_, item); + for (size_t i = 0; i < count; i++) + exif_set_rational(entry->data + i * sizeof(ExifRational), + order_, items[i]); exif_entry_unref(entry); } diff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h index b0d61402..e283d3fc 100644 --- a/src/android/jpeg/exif.h +++ b/src/android/jpeg/exif.h @@ -89,6 +89,8 @@ private: const std::string &item, StringEncoding encoding = NoEncoding); void setRational(ExifIfd ifd, ExifTag tag, ExifRational item); + void setRational(ExifIfd ifd, ExifTag tag, uint32_t count, + ExifRational items[]); std::tuple degreesToDMS(double decimalDegrees); void setGPSDMS(ExifIfd ifd, ExifTag tag, int deg, int min, int sec); From patchwork Mon Mar 8 10:13:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11511 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 F3B38BD1F1 for ; Mon, 8 Mar 2021 10:14:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A81F368AA1; Mon, 8 Mar 2021 11:14:11 +0100 (CET) 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="jHFGfEUv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 133E6602E6 for ; Mon, 8 Mar 2021 11:14:10 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 932988A3; Mon, 8 Mar 2021 11:14:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615198449; bh=RN7RRonhHrIGcZusbzCmJmzrhMEFMO94nSqppmD+HA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jHFGfEUvodTlIOaXMwev1lNGpJO3+a1nmjC1Lr3Q5l3bJ7GgzjtJRvTyztHVOhmoB EHJ5+UTMAa07t7qBUw1EgiKHBbKg5ngW6abGhDOlTUFFVikyyoCu0pEFqi71dn4skO voYfv+VwN9Kf1le0ctbp9O8WoqGOLAt/mCEpm19g= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 19:13:54 +0900 Message-Id: <20210308101356.59333-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210308101356.59333-1-paul.elder@ideasonboard.com> References: <20210308101356.59333-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] android: jpeg: exif: Simplify setGPSDateTimestamp and setGPSDMS 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" Now that setRational() supports setting multiple rational values, use that in setGPSDateTimestamp and setGPSDMS which previously set every rational manually. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/android/jpeg/exif.cpp | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index e5a3e448..c8b2f072 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -345,24 +345,13 @@ void Exif::setGPSDateTimestamp(time_t timestamp) EXIF_FORMAT_ASCII, tsStr); /* Set GPS_TIME_STAMP */ - ExifEntry *entry = - createEntry(EXIF_IFD_GPS, - static_cast(EXIF_TAG_GPS_TIME_STAMP), - EXIF_FORMAT_RATIONAL, 3, 3 * sizeof(ExifRational)); - if (!entry) - return; - ExifRational ts[] = { { static_cast(tm.tm_hour), 1 }, { static_cast(tm.tm_min), 1 }, { static_cast(tm.tm_sec), 1 }, }; - for (int i = 0; i < 3; i++) - exif_set_rational(entry->data + i * sizeof(ExifRational), - order_, ts[i]); - - exif_entry_unref(entry); + setRational(EXIF_IFD_GPS, static_cast(EXIF_TAG_GPS_TIME_STAMP), 3, ts); } std::tuple Exif::degreesToDMS(double decimalDegrees) @@ -376,22 +365,13 @@ std::tuple Exif::degreesToDMS(double decimalDegrees) void Exif::setGPSDMS(ExifIfd ifd, ExifTag tag, int deg, int min, int sec) { - ExifEntry *entry = createEntry(ifd, tag, EXIF_FORMAT_RATIONAL, 3, - 3 * sizeof(ExifRational)); - if (!entry) - return; - ExifRational coords[] = { { static_cast(deg), 1 }, { static_cast(min), 1 }, { static_cast(sec), 1 }, }; - for (int i = 0; i < 3; i++) - exif_set_rational(entry->data + i * sizeof(ExifRational), - order_, coords[i]); - - exif_entry_unref(entry); + setRational(ifd, tag, 3, coords); } /* From patchwork Mon Mar 8 10:13:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11512 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 B8FFEBD1F1 for ; Mon, 8 Mar 2021 10:14:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7257268AA3; Mon, 8 Mar 2021 11:14:13 +0100 (CET) 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="agZ/ZJfz"; 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 DD2A068AA3 for ; Mon, 8 Mar 2021 11:14:11 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6FC458A3; Mon, 8 Mar 2021 11:14:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615198451; bh=EAYWLFCLd/rHD1ON91T8EI4cyoKo2coOAuIYUO12rVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=agZ/ZJfzBj1twuI0MqPb0kQ2bfKweDYS0JYEAP4DWfA5ZlWcDUcICxg+NO8VS8+14 VHhwaS4HQqk/Dg+Ar5Ap4WT4UfypwZPZ3gwPUYtSYbyDaIcP2Dm4HVU6s9mrFqF0Nn MZH7zU2fLi4lgrPaK6vrr1ejMkB5isaRZ1n6HxCg= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 19:13:55 +0900 Message-Id: <20210308101356.59333-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210308101356.59333-1-paul.elder@ideasonboard.com> References: <20210308101356.59333-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] android: jpeg: exif: Fix setGPSLocation longitude 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" There was a copy-paste error that caused the latitude to be set twice and the longitude never. Fix this. This is part of the fix that allows the following CTS test to pass: - android.hardware.cts.CameraTest#testJpegExif Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/android/jpeg/exif.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index c8b2f072..5225d17f 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -392,7 +392,7 @@ void Exif::setGPSLocation(const double *coords) std::tie(deg, min, sec) = degreesToDMS(coords[1]); setString(EXIF_IFD_GPS, static_cast(EXIF_TAG_GPS_LONGITUDE_REF), EXIF_FORMAT_ASCII, deg >= 0 ? "E" : "W"); - setGPSDMS(EXIF_IFD_GPS, static_cast(EXIF_TAG_GPS_LATITUDE), + setGPSDMS(EXIF_IFD_GPS, static_cast(EXIF_TAG_GPS_LONGITUDE), std::abs(deg), min, sec); setByte(EXIF_IFD_GPS, static_cast(EXIF_TAG_GPS_ALTITUDE_REF), From patchwork Mon Mar 8 10:13:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11513 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 19796BD1F1 for ; Mon, 8 Mar 2021 10:14:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CA84068AA8; Mon, 8 Mar 2021 11:14:14 +0100 (CET) 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="tfnwfDaI"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CB48468A99 for ; Mon, 8 Mar 2021 11:14:13 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6270B8A3; Mon, 8 Mar 2021 11:14:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615198453; bh=/Fx8yyQSgzgGtv+B7QuSN2Qw6K+T90Wo0Sas2I6MEpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tfnwfDaI4smfYzks6zj6TMVEN66R+Qzy3YnYzK2CaZNZc5bmVAwMDvdZfoxPX02O9 zh374QSfYFgIdQHK1tuOuTZJaEyGNlkYTAX2S2hx+Pa+xbo7i0ffaSOFMioAZ5Ll6p qfKwWjnnnlfS1HVe54UADeuLZq9BHtkHotkD5rRQ= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 19:13:56 +0900 Message-Id: <20210308101356.59333-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210308101356.59333-1-paul.elder@ideasonboard.com> References: <20210308101356.59333-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] android: jpeg: exif: change GPS method from UNDEFINED format to ASCII 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" According to the EXIF specification, the GPS method should be UNDEFINED, and the first 8 bytes will designate the type. However, CTS expects the GPS method to be ASCII. Change the format to ASCII to appease CTS. This is part of the fix that allows the following CTS test to pass: - android.hardware.cts.CameraTest#testJpegExif Signed-off-by: Paul Elder --- src/android/jpeg/exif.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index 5225d17f..83e6faba 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -404,7 +404,7 @@ void Exif::setGPSLocation(const double *coords) void Exif::setGPSMethod(const std::string &method) { setString(EXIF_IFD_GPS, static_cast(EXIF_TAG_GPS_PROCESSING_METHOD), - EXIF_FORMAT_UNDEFINED, method, Unicode); + EXIF_FORMAT_ASCII, method); } void Exif::setOrientation(int orientation)