{"id":8662,"url":"https://patchwork.libcamera.org/api/1.1/patches/8662/?format=json","web_url":"https://patchwork.libcamera.org/patch/8662/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20200706230240.2482100-3-kieran.bingham@ideasonboard.com>","date":"2020-07-06T23:02:34","name":"[libcamera-devel,v5,2/8] android: camera_device: Provide a toPixelFormat helper","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"2cf0e19395ee4fe1bc82a3c691e23411aa1719a5","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8662/mbox/","series":[{"id":1089,"url":"https://patchwork.libcamera.org/api/1.1/series/1089/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1089","date":"2020-07-06T23:02:32","name":"android: Multi-stream support","version":5,"mbox":"https://patchwork.libcamera.org/series/1089/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8662/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8662/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 B805ABD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Jul 2020 23:02:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6E9EC60E91;\n\tTue,  7 Jul 2020 01:02:49 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0577D60E2B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Jul 2020 01:02:46 +0200 (CEST)","from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net\n\t[86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0DB60D98;\n\tTue,  7 Jul 2020 01:02:45 +0200 (CEST)"],"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=\"loLZdm1/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594076565;\n\tbh=sMhLp06T6QO0sZZzIFLbIjnWFqMx2rxp+l/GxwKKhHU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=loLZdm1/Bd68mJZvhgnXsoe0u5IaUT4p/EgQWVBFWOtoIqi8lqOt33jntJ+B1SrIp\n\tXcU384M/Zae+oJ4n77KrQcQFi3DIV8q2erjcAskL0RMYDF7FAm4D6YaLHTpf9aK5/i\n\tNaFkV+q8WAWdSAwhsvMHevqOo+kbfC6zwlyBskLA=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Tue,  7 Jul 2020 00:02:34 +0100","Message-Id":"<20200706230240.2482100-3-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200706230240.2482100-1-kieran.bingham@ideasonboard.com>","References":"<20200706230240.2482100-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v5 2/8] android: camera_device: Provide a\n\ttoPixelFormat helper","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=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Rather than converting pixelformats through the map, and then\ndereferencing the iterator later, create a helper to explicitly return a\nPixelFormat type.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 28 ++++++++++++++++++++--------\n src/android/camera_device.h   |  1 +\n 2 files changed, 21 insertions(+), 8 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex f788c11e7254..b9031ff0c2a4 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -923,6 +923,19 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)\n \treturn requestTemplate->get();\n }\n \n+PixelFormat CameraDevice::toPixelFormat(int format)\n+{\n+\t/* Translate Android format code to libcamera pixel format. */\n+\tauto it = formatsMap_.find(format);\n+\tif (it == formatsMap_.end()) {\n+\t\tLOG(HAL, Error) << \"Requested format \" << utils::hex(format)\n+\t\t\t\t<< \" not supported\";\n+\t\treturn PixelFormat();\n+\t}\n+\n+\treturn it->second;\n+}\n+\n /*\n  * Inspect the stream_list to produce a list of StreamConfiguration to\n  * be use to configure the Camera.\n@@ -932,11 +945,14 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \tfor (unsigned int i = 0; i < stream_list->num_streams; ++i) {\n \t\tcamera3_stream_t *stream = stream_list->streams[i];\n \n+\t\tPixelFormat format = toPixelFormat(stream->format);\n+\n \t\tLOG(HAL, Info) << \"Stream #\" << i\n \t\t\t       << \", direction: \" << stream->stream_type\n \t\t\t       << \", width: \" << stream->width\n \t\t\t       << \", height: \" << stream->height\n-\t\t\t       << \", format: \" << utils::hex(stream->format);\n+\t\t\t       << \", format: \" << utils::hex(stream->format)\n+\t\t\t       << \" (\" << format.toString() << \")\";\n \t}\n \n \t/* Only one stream is supported. */\n@@ -947,13 +963,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \tcamera3_stream_t *camera3Stream = stream_list->streams[0];\n \n \t/* Translate Android format code to libcamera pixel format. */\n-\tauto it = formatsMap_.find(camera3Stream->format);\n-\tif (it == formatsMap_.end()) {\n-\t\tLOG(HAL, Error) << \"Requested format \"\n-\t\t\t\t<< utils::hex(camera3Stream->format)\n-\t\t\t\t<< \" not supported\";\n+\tPixelFormat format = toPixelFormat(camera3Stream->format);\n+\tif (!format.isValid())\n \t\treturn -EINVAL;\n-\t}\n \n \t/*\n \t * Hardcode viewfinder role, replacing the generated configuration\n@@ -969,7 +981,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \tStreamConfiguration *streamConfiguration = &config_->at(0);\n \tstreamConfiguration->size.width = camera3Stream->width;\n \tstreamConfiguration->size.height = camera3Stream->height;\n-\tstreamConfiguration->pixelFormat = it->second;\n+\tstreamConfiguration->pixelFormat = format;\n \n \tswitch (config_->validate()) {\n \tcase CameraConfiguration::Valid:\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex ed11410a5577..5bd6cf416156 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -72,6 +72,7 @@ private:\n \tstd::tuple<uint32_t, uint32_t> calculateStaticMetadataSize();\n \tvoid notifyShutter(uint32_t frameNumber, uint64_t timestamp);\n \tvoid notifyError(uint32_t frameNumber, camera3_stream_t *stream);\n+\tlibcamera::PixelFormat toPixelFormat(int format);\n \tstd::unique_ptr<CameraMetadata> getResultMetadata(int frame_number,\n \t\t\t\t\t\t\t  int64_t timestamp);\n \n","prefixes":["libcamera-devel","v5","2/8"]}