Patch Detail
Show a patch.
GET /api/1.1/patches/3916/?format=api
{ "id": 3916, "url": "https://patchwork.libcamera.org/api/1.1/patches/3916/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3916/", "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": "<20200604133503.14689-3-jacopo@jmondi.org>", "date": "2020-06-04T13:35:01", "name": "[libcamera-devel,v2,2/4] android: camera_device: Calculate metadata size", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "e31a7674d666df41dad947601c7d66188ac46c2f", "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/3916/mbox/", "series": [ { "id": 951, "url": "https://patchwork.libcamera.org/api/1.1/series/951/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=951", "date": "2020-06-04T13:34:59", "name": "android: Implement format translation", "version": 2, "mbox": "https://patchwork.libcamera.org/series/951/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3916/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3916/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 828F5611AB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 4 Jun 2020 15:31:47 +0200 (CEST)", "from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 10E3E1C0005;\n\tThu, 4 Jun 2020 13:31:46 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 4 Jun 2020 15:35:01 +0200", "Message-Id": "<20200604133503.14689-3-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.26.2", "In-Reply-To": "<20200604133503.14689-1-jacopo@jmondi.org>", "References": "<20200604133503.14689-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 2/4] 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": "Thu, 04 Jun 2020 13:31:48 -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 0c462f53c9cc..1f438f0e265d 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@@ -362,6 +363,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@@ -375,12 +399,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 d31b7233e795..18a5f77f9ce5 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 initializeFormats();\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", "v2", "2/4" ] }