Patch Detail
Show a patch.
GET /api/1.1/patches/3946/?format=api
{ "id": 3946, "url": "https://patchwork.libcamera.org/api/1.1/patches/3946/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3946/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200605141002.49119-3-jacopo@jmondi.org>", "date": "2020-06-05T14:09:56", "name": "[libcamera-devel,v3,2/8] android: camera_device: Calculate metadata size", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "849a97bba0526765bdbc0471d75bd33cfbf7b6d1", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3946/mbox/", "series": [ { "id": 958, "url": "https://patchwork.libcamera.org/api/1.1/series/958/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=958", "date": "2020-06-05T14:09:54", "name": "android: Build stream configuration map", "version": 3, "mbox": "https://patchwork.libcamera.org/series/958/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3946/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3946/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C70E661375\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 5 Jun 2020 16:07:07 +0200 (CEST)", "from localhost.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 39CE72000D;\n\tFri, 5 Jun 2020 14:07:07 +0000 (UTC)" ], "X-Originating-IP": "93.34.118.233", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 5 Jun 2020 16:09:56 +0200", "Message-Id": "<20200605141002.49119-3-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200605141002.49119-1-jacopo@jmondi.org>", "References": "<20200605141002.49119-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 2/8] android: camera_device: Calculate\n\tmetadata size", "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>", "X-List-Received-Date": "Fri, 05 Jun 2020 14:07:08 -0000" }, "content": "As we move to have more and more dynamically generated static metadata\nentries, the size of the metadata buffer has to be calculated\ndynamically inspecting the information collected from the camera.\n\nProvide a method to perform metadata buffers size calculation and\nuse it when generating camera static metadata.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 34 ++++++++++++++++++++++++++++------\n src/android/camera_device.h | 2 ++\n 2 files changed, 30 insertions(+), 6 deletions(-)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex cb9e4a6bc15b..c65295a32f3f 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -8,6 +8,7 @@\n #include \"camera_device.h\"\n #include \"camera_ops.h\"\n \n+#include <tuple>\n #include <vector>\n \n #include <libcamera/controls.h>\n@@ -368,6 +369,29 @@ void CameraDevice::setCallbacks(const camera3_callback_ops_t *callbacks)\n \tcallbacks_ = callbacks;\n }\n \n+std::tuple<uint32_t, uint32_t> CameraDevice::calculateStaticMetadataSize()\n+{\n+\t/*\n+\t * \\todo Keep this in sync with the actual number of entries.\n+\t * Currently: 50 entries, 647 bytes of static metadata\n+\t */\n+\tuint32_t numEntries = 50;\n+\tuint32_t byteSize = 647;\n+\n+\t/*\n+\t * Calculate space occupation in bytes for dynamically built metadata\n+\t * entries.\n+\t *\n+\t * Each stream configuration entry requires 52 bytes:\n+\t * 4 32bits integers for ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS\n+\t * 1 32bits integer for ANDROID_SCALER_AVAILABLE_FORMATS\n+\t * 4 64bits integers for ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS\n+\t */\n+\tbyteSize += streamConfigurations_.size() * 52;\n+\n+\treturn { numEntries, byteSize };\n+}\n+\n /*\n * Return static information for the camera.\n */\n@@ -381,12 +405,10 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \t * example application, but a real camera implementation will require\n \t * more.\n \t */\n-\n-\t/*\n-\t * \\todo Keep this in sync with the actual number of entries.\n-\t * Currently: 50 entries, 666 bytes\n-\t */\n-\tstaticMetadata_ = new CameraMetadata(50, 700);\n+\tuint32_t numEntries;\n+\tuint32_t byteSize;\n+\tstd::tie(numEntries, byteSize) = calculateStaticMetadataSize();\n+\tstaticMetadata_ = new CameraMetadata(numEntries, byteSize);\n \tif (!staticMetadata_->isValid()) {\n \t\tLOG(HAL, Error) << \"Failed to allocate static metadata\";\n \t\tdelete staticMetadata_;\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 4e8911da5770..ed11410a5577 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -9,6 +9,7 @@\n \n #include <map>\n #include <memory>\n+#include <tuple>\n #include <vector>\n \n #include <hardware/camera3.h>\n@@ -68,6 +69,7 @@ private:\n \t};\n \n \tint initializeStreamConfigurations();\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 \tstd::unique_ptr<CameraMetadata> getResultMetadata(int frame_number,\n", "prefixes": [ "libcamera-devel", "v3", "2/8" ] }