{"id":9379,"url":"https://patchwork.libcamera.org/api/patches/9379/?format=json","web_url":"https://patchwork.libcamera.org/patch/9379/","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":"<20200824204646.16866-4-email@uajain.com>","date":"2020-08-24T20:46:55","name":"[libcamera-devel,3/3] android: Support initial set of EXIF metadata tags","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"b32461784a3008b316e4378147063697e9894a1f","submitter":{"id":1,"url":"https://patchwork.libcamera.org/api/people/1/?format=json","name":"Umang Jain","email":"email@uajain.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9379/mbox/","series":[{"id":1240,"url":"https://patchwork.libcamera.org/api/series/1240/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1240","date":"2020-08-24T20:46:53","name":"Initial EXIF metadata support","version":1,"mbox":"https://patchwork.libcamera.org/series/1240/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9379/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9379/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 C961FBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Aug 2020 20:46:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 96C76616B1;\n\tMon, 24 Aug 2020 22:46:59 +0200 (CEST)","from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BF8036170D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Aug 2020 22:46:56 +0200 (CEST)","by filterdrecv-p3iad2-56dbc8bd54-l59qx with SMTP id\n\tfilterdrecv-p3iad2-56dbc8bd54-l59qx-19-5F44273F-13\n\t2020-08-24 20:46:55.37874524 +0000 UTC m=+17350.726504245","from mail.uajain.com (unknown)\n\tby ismtpd0007p1hnd1.sendgrid.net (SG) with ESMTP id\n\t8QH9Ia16Sci7ACwjKjgQcQ for <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Aug 2020 20:46:55.011 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"Jxmu8Zua\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com;\n\th=from:subject:in-reply-to:references:mime-version:to:cc:\n\tcontent-transfer-encoding:content-type;\n\ts=s1; bh=YE4ixvv5qRUxZRpkzwRMQjRGzw1v2wLVdDrVfoglVxU=;\n\tb=Jxmu8ZuahkLGINPfdBtt59EJd4FiXmBKz0IvNmEF331Is+Bvb9uwfFjKGjYXaiEdoqVJ\n\ticKVJ9H++77+NjBPnbGE48S6JgKQ2U/SyypHAOGvg8NCuhAoJwbbyBjbY7ZcMbpfh7j4S1\n\tsdB6Au7EHTPhXgIYQUeMSgPsb1jT1v97M=","From":"Umang Jain <email@uajain.com>","Date":"Mon, 24 Aug 2020 20:46:55 +0000 (UTC)","Message-Id":"<20200824204646.16866-4-email@uajain.com>","In-Reply-To":"<20200824204646.16866-1-email@uajain.com>","References":"<20200824204646.16866-1-email@uajain.com>","Mime-Version":"1.0","X-SG-EID":"1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcZj5z9XHfwy1Ge6f/0y1LYyVXr4TmHaUM1xCQSxitCYfrtK45qesLCVSSmeChF10FbpdTiZRXDISHkwM5Ty/eOSQHFDEHh2zvkwNkeclaO6aO/tSQy6EZ/e1UnnUWa2cgNyPSFnvUzWTDMOMBqZr5pRhmahjoirHSXYJgZORMmLZVQcHJ9vikeaeC9hgLIPMe8kHhHHEFCDiVm4MQTH7z3g==","To":"libcamera-devel@lists.libcamera.org","Subject":"[libcamera-devel] [PATCH 3/3] android: Support initial set of EXIF\n\tmetadata tags","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":"Support a initial set of  EXIF metadata tags namely:\nMake, Model, Height, Width, Orientation and Timestamp.\nEach tag is set by a convenient high level helper API\ndefined in exif.h.\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n src/android/camera_device.cpp        |  8 +++++++\n src/android/jpeg/encoder_libjpeg.cpp | 12 ++++++++++\n src/android/jpeg/exif.cpp            | 34 ++++++++++++++++++++++++++++\n src/android/jpeg/exif.h              |  8 +++++++\n 4 files changed, 62 insertions(+)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex bc5690e..fcf378a 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1435,6 +1435,14 @@ void CameraDevice::requestComplete(Request *request)\n \t\t}\n \n \t\tExif exif;\n+\t\t/*\n+\t\t * \\todo Discuss setMake String, maybe vendor ID?\n+\t\t * KB suggested to leave it to \"libcamera\" for now.\n+\t\t * setModel should use the 'model' property of the camera.\n+\t\t */\n+\t\texif.setMake(\"Libcamera\");\n+\t\texif.setModel(\"cameraModel\");\n+\t\texif.setOrientation(orientation_);\n \n \t\tint jpeg_size = encoder->encode(buffer, mapped.maps()[0], &exif);\n \t\tif (jpeg_size < 0) {\ndiff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp\nindex 0cd93b6..f84def9 100644\n--- a/src/android/jpeg/encoder_libjpeg.cpp\n+++ b/src/android/jpeg/encoder_libjpeg.cpp\n@@ -213,7 +213,19 @@ int EncoderLibJpeg::encode(const FrameBuffer *source,\n \telse\n \t\tcompressRGB(&frame);\n \n+\texif->setWidth(compress_.image_width);\n+\texif->setHeight(compress_.image_height);\n+\texif->setTimestamp(source->metadata().timestamp);\n+\n+\tSpan<uint8_t> exif_data = exif->generate();\n+\n \tjpeg_finish_compress(&compress_);\n \n+\tif (exif->size())\n+\t\t/* Store Exif data in the JPEG_APP1 data block. */\n+\t\tjpeg_write_marker(&compress_, JPEG_APP0 + 1,\n+\t\t\t\t  static_cast<const JOCTET *>(exif_data.data()),\n+\t\t\t\t  exif_data.size());\n+\n \treturn size;\n }\ndiff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp\nindex f6a9f5c..b7591d5 100644\n--- a/src/android/jpeg/exif.cpp\n+++ b/src/android/jpeg/exif.cpp\n@@ -160,6 +160,40 @@ int Exif::setString(ExifIfd ifd, ExifTag tag, ExifFormat format, const std::stri\n \treturn 0;\n }\n \n+int Exif::setHeight(uint16_t height)\n+{\n+\tsetShort(EXIF_IFD_0, EXIF_TAG_IMAGE_LENGTH, height);\n+\tsetLong(EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION, height);\n+\n+\treturn 0;\n+}\n+\n+int Exif::setWidth(uint16_t width)\n+{\n+\tsetShort(EXIF_IFD_0, EXIF_TAG_IMAGE_WIDTH, width);\n+\tsetLong(EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION, width);\n+\n+\treturn 0;\n+}\n+\n+int Exif::setTimestamp(const time_t timestamp)\n+{\n+\tstd::string ts(std::ctime(&timestamp));\n+\tint ret = setString(EXIF_IFD_0, EXIF_TAG_DATE_TIME, EXIF_FORMAT_ASCII, ts);\n+\tif(ret < 0)\n+\t\treturn ret;\n+\n+\tret = setString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL, EXIF_FORMAT_ASCII, ts);\n+\tif(ret < 0)\n+\t\treturn ret;\n+\n+\tret = setString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_DIGITIZED, EXIF_FORMAT_ASCII, ts);\n+\tif(ret < 0)\n+\t\treturn ret;\n+\n+\treturn ret;\n+}\n+\n Span<uint8_t> Exif::generate()\n {\n \tif (exif_data_) {\ndiff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h\nindex 7df83c7..6a8f5f5 100644\n--- a/src/android/jpeg/exif.h\n+++ b/src/android/jpeg/exif.h\n@@ -11,6 +11,7 @@\n \n #include <libcamera/span.h>\n \n+#include <ctime>\n #include <string>\n \n class Exif\n@@ -24,6 +25,13 @@ public:\n \tint setString(ExifIfd ifd, ExifTag tag, ExifFormat format, const std::string &item);\n \tint setRational(ExifIfd ifd, ExifTag tag, uint32_t numerator, uint32_t denominator);\n \n+\tint setHeight(uint16_t height);\n+\tint setMake(const std::string &make) { return setString(EXIF_IFD_0, EXIF_TAG_MAKE, EXIF_FORMAT_ASCII, make); }\n+\tint setModel(const std::string &model) { return setString(EXIF_IFD_0, EXIF_TAG_MODEL, EXIF_FORMAT_ASCII, model); }\n+\tint setOrientation(int orientation) { return setShort(EXIF_IFD_0, EXIF_TAG_ORIENTATION, orientation); }\n+\tint setTimestamp(const time_t timestamp);\n+\tint setWidth(uint16_t width);\n+\n \tlibcamera::Span<uint8_t> generate();\n \tunsigned char *data() const { return exif_data_; }\n \tunsigned int size() const { return size_; }\n","prefixes":["libcamera-devel","3/3"]}