From: Esther Zilberberg <esty5664@gmail.com>
To: linux-media@vger.kernel.org
Cc: nicolas@ndufresne.ca, Esther Zilberberg <esty5664@gmail.com>
Subject: [PATCH v4l-utils v2] v4l2-tracer: retrace: support all mplane planes
Date: Mon, 13 Apr 2026 09:46:39 +0000 [thread overview]
Message-ID: <20260413094639.8615-1-esty5664@gmail.com> (raw)
For V4L2_BUF_TYPE_*_MPLANE buffers, retrace_v4l2_buffer()
only restored the first plane from the JSON trace.
Restore all planes by iterating over the "planes" array and
reconstructing each struct v4l2_plane entry, assigning them
into a properly allocated array.
This ensures consistency with trace output and prevents
incorrect buffer reconstruction for multiplanar formats.
Signed-off-by: Esther Zilberberg <esty5664@gmail.com>
---
v1 -> v2:
- allocate planes as a single array and populate it directly
- change retrace_v4l2_plane() to fill a provided struct instead of allocating one
- fix indentation to use tabs instead of spaces
- add blank lines between scopes for readability
---
utils/v4l2-tracer/retrace.cpp | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp
index 010936c0..f4e4d3c7 100644
--- a/utils/v4l2-tracer/retrace.cpp
+++ b/utils/v4l2-tracer/retrace.cpp
@@ -199,10 +199,8 @@ void retrace_vidioc_reqbufs(int fd_retrace, json_object *ioctl_args)
free(ptr);
}
-struct v4l2_plane *retrace_v4l2_plane(json_object *plane_obj, __u32 memory)
+void retrace_v4l2_plane(json_object *plane_obj, __u32 memory, struct v4l2_plane *ptr)
{
- struct v4l2_plane *ptr = (struct v4l2_plane *) calloc(1, sizeof(v4l2_plane));
-
json_object *bytesused_obj;
json_object_object_get_ex(plane_obj, "bytesused", &bytesused_obj);
ptr->bytesused = (__u32) json_object_get_int64(bytesused_obj);
@@ -222,8 +220,6 @@ struct v4l2_plane *retrace_v4l2_plane(json_object *plane_obj, __u32 memory)
json_object *data_offset_obj;
json_object_object_get_ex(plane_obj, "data_offset", &data_offset_obj);
ptr->data_offset = (__u32) json_object_get_int64(data_offset_obj);
-
- return ptr;
}
struct v4l2_buffer *retrace_v4l2_buffer(json_object *ioctl_args)
@@ -284,9 +280,20 @@ struct v4l2_buffer *retrace_v4l2_buffer(json_object *ioctl_args)
buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
json_object *planes_obj;
json_object_object_get_ex(m_obj, "planes", &planes_obj);
- /* TODO add planes > 0 */
- json_object *plane_obj = json_object_array_get_idx(planes_obj, 0);
- buf->m.planes = retrace_v4l2_plane(plane_obj, buf->memory);
+ buf->m.planes = (struct v4l2_plane *) calloc(buf->length, sizeof(struct v4l2_plane));
+
+ if (buf->m.planes == nullptr) {
+ line_info("\n\tMemory allocation failed.");
+ free(buf);
+ return nullptr;
+ }
+
+ for (__u32 i = 0; i < buf->length; i++) {
+ json_object *plane_obj = json_object_array_get_idx(planes_obj, i);
+ if (plane_obj == nullptr)
+ break;
+ retrace_v4l2_plane(plane_obj, buf->memory, &buf->m.planes[i]);
+ }
}
if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE ||
--
2.43.0
next reply other threads:[~2026-04-13 9:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 9:46 Esther Zilberberg [this message]
2026-04-23 8:43 ` [PATCH v4l-utils v2] v4l2-tracer: retrace: support all mplane planes Esther Zilberberg
2026-04-23 13:29 ` Nicolas Dufresne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260413094639.8615-1-esty5664@gmail.com \
--to=esty5664@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=nicolas@ndufresne.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox