* [PATCH v4l-utils v2] v4l2-tracer: retrace: support all mplane planes
@ 2026-04-13 9:46 Esther Zilberberg
2026-04-23 8:43 ` Esther Zilberberg
2026-04-23 13:29 ` Nicolas Dufresne
0 siblings, 2 replies; 3+ messages in thread
From: Esther Zilberberg @ 2026-04-13 9:46 UTC (permalink / raw)
To: linux-media; +Cc: nicolas, Esther Zilberberg
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4l-utils v2] v4l2-tracer: retrace: support all mplane planes
2026-04-13 9:46 [PATCH v4l-utils v2] v4l2-tracer: retrace: support all mplane planes Esther Zilberberg
@ 2026-04-23 8:43 ` Esther Zilberberg
2026-04-23 13:29 ` Nicolas Dufresne
1 sibling, 0 replies; 3+ messages in thread
From: Esther Zilberberg @ 2026-04-23 8:43 UTC (permalink / raw)
To: linux-media; +Cc: nicolas
On Mon, Apr 13, 2026 at 12:47 PM Esther Zilberberg <esty5664@gmail.com> wrote:
>
> 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
>
Hi,
Gentle reminder to review the patch below.
Thanks,
Esther
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4l-utils v2] v4l2-tracer: retrace: support all mplane planes
2026-04-13 9:46 [PATCH v4l-utils v2] v4l2-tracer: retrace: support all mplane planes Esther Zilberberg
2026-04-23 8:43 ` Esther Zilberberg
@ 2026-04-23 13:29 ` Nicolas Dufresne
1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Dufresne @ 2026-04-23 13:29 UTC (permalink / raw)
To: Esther Zilberberg, linux-media
[-- Attachment #1: Type: text/plain, Size: 3125 bytes --]
Le lundi 13 avril 2026 à 09:46 +0000, Esther Zilberberg a écrit :
> 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>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.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 ||
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-23 13:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13 9:46 [PATCH v4l-utils v2] v4l2-tracer: retrace: support all mplane planes Esther Zilberberg
2026-04-23 8:43 ` Esther Zilberberg
2026-04-23 13:29 ` Nicolas Dufresne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox