{"id":11532,"url":"https://patchwork.libcamera.org/api/patches/11532/?format=json","web_url":"https://patchwork.libcamera.org/patch/11532/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210309085235.106691-2-paul.elder@ideasonboard.com>","date":"2021-03-09T08:52:32","name":"[libcamera-devel,v2,1/4] android: jpeg: exif: Fix and expand setRational","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"21c777a5011c824e7b534c92dac827302b5951d9","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11532/mbox/","series":[{"id":1776,"url":"https://patchwork.libcamera.org/api/series/1776/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1776","date":"2021-03-09T08:52:31","name":"android: jpeg: exif: Fix GPS altitude","version":2,"mbox":"https://patchwork.libcamera.org/series/1776/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11532/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11532/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A1A7BBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Mar 2021 08:52:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4DDF968AA4;\n\tTue,  9 Mar 2021 09:52:50 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ADC0D68A9C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Mar 2021 09:52:48 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 52174E9;\n\tTue,  9 Mar 2021 09:52:46 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"YtXTgkCs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1615279968;\n\tbh=wjkwOVoxdfkJ39hk4Ydbh+ClyuFqckZZ7/MZlKLT//c=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=YtXTgkCs8J9OP+DQyuG2ND/n8J/GFtMUPybw1bLzqs/VSCkdOqbBKDMz6xa4QH7qR\n\tki0J0q085fa7DrsggWzO/ySof71fNAHMTxv9CcJppaRg7tyNVF8UzynA51dAULgp7g\n\tiU8BfNCayMH8O9mXyVS/ARICtW56WttANIsjz+64=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  9 Mar 2021 17:52:32 +0900","Message-Id":"<20210309085235.106691-2-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20210309085235.106691-1-paul.elder@ideasonboard.com>","References":"<20210309085235.106691-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 1/4] android: jpeg: exif: Fix and\n\texpand setRational","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"setRational was not working properly for EXIF tags in the GPS IFD due to\nlibexif not supporting those tags in exif_entry_initialize().  Manually\nspecify the size of the EXIF entry to fix this. While at it, add support\nfor setting multiple rationals, as that is a common use case for\nrational EXIF tags.\n\nAs Rational types are no longer initialized by libexif directly, the\nEXIF_TAG_{X,Y}_RESOLUTION exif tags will not have their default values\npopulated.\n\nThis allows the GPS altitude to be set properly, and is part of the fix\nto allow the following CTS test to pass:\n- android.hardware.cts.CameraTest#testJpegExif\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nChanges in v2:\n- use span instead of size + array\n- expand commit message\n---\n src/android/jpeg/exif.cpp | 15 +++++++++++++--\n src/android/jpeg/exif.h   |  2 ++\n 2 files changed, 15 insertions(+), 2 deletions(-)","diff":"diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp\nindex fdd46070..929ac542 100644\n--- a/src/android/jpeg/exif.cpp\n+++ b/src/android/jpeg/exif.cpp\n@@ -14,6 +14,8 @@\n #include <tuple>\n #include <uchar.h>\n \n+#include <libcamera/span.h>\n+\n #include \"libcamera/internal/log.h\"\n #include \"libcamera/internal/utils.h\"\n \n@@ -187,11 +189,20 @@ void Exif::setLong(ExifIfd ifd, ExifTag tag, uint32_t item)\n \n void Exif::setRational(ExifIfd ifd, ExifTag tag, ExifRational item)\n {\n-\tExifEntry *entry = createEntry(ifd, tag);\n+\tsetRational(ifd, tag, Span<const ExifRational>{ &item, 1 });\n+}\n+\n+void Exif::setRational(ExifIfd ifd, ExifTag tag, Span<const ExifRational> items)\n+{\n+\tExifEntry *entry = createEntry(ifd, tag, EXIF_FORMAT_RATIONAL,\n+\t\t\t\t       items.size(),\n+\t\t\t\t       items.size() * sizeof(ExifRational));\n \tif (!entry)\n \t\treturn;\n \n-\texif_set_rational(entry->data, order_, item);\n+\tfor (size_t i = 0; i < items.size(); i++)\n+\t\texif_set_rational(entry->data + i * sizeof(ExifRational),\n+\t\t\t\t  order_, items[i]);\n \texif_entry_unref(entry);\n }\n \ndiff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h\nindex b0d61402..8aa1b123 100644\n--- a/src/android/jpeg/exif.h\n+++ b/src/android/jpeg/exif.h\n@@ -89,6 +89,8 @@ private:\n \t\t       const std::string &item,\n \t\t       StringEncoding encoding = NoEncoding);\n \tvoid setRational(ExifIfd ifd, ExifTag tag, ExifRational item);\n+\tvoid setRational(ExifIfd ifd, ExifTag tag,\n+\t\t\t libcamera::Span<const ExifRational> items);\n \n \tstd::tuple<int, int, int> degreesToDMS(double decimalDegrees);\n \tvoid setGPSDMS(ExifIfd ifd, ExifTag tag, int deg, int min, int sec);\n","prefixes":["libcamera-devel","v2","1/4"]}