Patch Detail
Show a patch.
GET /api/1.1/patches/3864/?format=api
{ "id": 3864, "url": "https://patchwork.libcamera.org/api/1.1/patches/3864/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3864/", "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": "<20200526142237.407557-6-jacopo@jmondi.org>", "date": "2020-05-26T14:22:34", "name": "[libcamera-devel,5/8] android: camera_device: Calculate metadata size", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "f97b98f04b0692657f060a63fd31ee47fa6f7861", "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/3864/mbox/", "series": [ { "id": 930, "url": "https://patchwork.libcamera.org/api/1.1/series/930/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=930", "date": "2020-05-26T14:22:29", "name": "android: Implament format translation", "version": 1, "mbox": "https://patchwork.libcamera.org/series/930/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3864/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3864/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E43560E08\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 May 2020 16:19:27 +0200 (CEST)", "from localhost.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 1BE114000E;\n\tTue, 26 May 2020 14:19:26 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 26 May 2020 16:22:34 +0200", "Message-Id": "<20200526142237.407557-6-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.26.2", "In-Reply-To": "<20200526142237.407557-1-jacopo@jmondi.org>", "References": "<20200526142237.407557-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 5/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": "Tue, 26 May 2020 14:19:27 -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 | 42 ++++++++++++++++++++++++++++++-----\n src/android/camera_device.h | 2 ++\n 2 files changed, 38 insertions(+), 6 deletions(-)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 534bfb1df1ef..6cc377820210 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -331,6 +331,40 @@ void CameraDevice::setCallbacks(const camera3_callback_ops_t *callbacks)\n /*\n * Return static information for the camera.\n */\n+std::pair<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+\tstd::pair<uint32_t, uint32_t> metadataSize;\n+\tmetadataSize.first = 50;\n+\tmetadataSize.second = 647;\n+\n+\t/*\n+\t * Calculate space occupation in bytes for dynamically built metadata\n+\t * entries.\n+\t */\n+\n+\t/* std::forward_list does not provide a size() method :( */\n+\tfor (const auto &entry : streamConfigurations_) {\n+\t\t/* Just please the compiler, otherwise entry is not used. */\n+\t\tswitch (entry.androidScalerCode) {\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\t/*\n+\t\t * 4 32bits integers for ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS\n+\t\t * 1 32bits integer for ANDROID_SCALER_AVAILABLE_FORMATS\n+\t\t * 4 64bits integers for ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS\n+\t\t */\n+\t\tmetadataSize.second += 52;\n+\t}\n+\n+\treturn metadataSize;\n+}\n+\n const camera_metadata_t *CameraDevice::getStaticMetadata()\n {\n \tif (staticMetadata_)\n@@ -341,12 +375,8 @@ 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+\tconst std::pair<uint32_t, uint32_t> sizes = calculateStaticMetadataSize();\n+\tstaticMetadata_ = new CameraMetadata(sizes.first, sizes.second);\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 95bd39f590ab..f22a6e3e6c28 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -10,6 +10,7 @@\n #include <forward_list>\n #include <map>\n #include <memory>\n+#include <utility>\n \n #include <hardware/camera3.h>\n \n@@ -69,6 +70,7 @@ private:\n \t};\n \n \tint initializeFormats();\n+\tstd::pair<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", "5/8" ] }