From 3609fbb42597e76607f16125d054259fec7523ee Mon Sep 17 00:00:00 2001 From: Markus Fritsche Date: Fri, 1 May 2026 12:00:00 +0000 Subject: [PATCH] DEBUG: hex-dump OUTPUT and CAPTURE buffer contents per frame Diagnostic-only patch (NOT for upstream). Hex-dumps: - First 32 bytes of OUTPUT buffer at QBUF time in picture.c::RequestEndPicture (i.e. what we feed the kernel) - First 32 bytes of CAPTURE Y-plane after DQBUF in surface.c::RequestSyncSurface (i.e. what kernel returned) Lets us see whether: - OUTPUT bitstream begins with valid ANNEX_B start code + NAL header byte (e.g. `00 00 01 65` for IDR slice) - CAPTURE Y-plane after decode contains varied luma data (working) vs. all-zeros / repeating pattern (kernel didn't write anything). Removed once Step 1 decode is verified working. Output goes via existing request_log() to stderr. Signed-off-by: Markus Fritsche --- src/picture.c | 22 ++++++++++++++++++++++ src/surface.c | 25 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/picture.c b/src/picture.c index 17913aa..a0c82a2 100644 --- a/src/picture.c +++ b/src/picture.c @@ -36,6 +36,7 @@ #include "mpeg2.h" #include +#include #include #include @@ -354,6 +355,27 @@ VAStatus RequestEndPicture(VADriverContextP context, VAContextID context_id) if (rc < 0) return VA_STATUS_ERROR_OPERATION_FAILED; + /* + * DEBUG INSTRUMENTATION (0010): hex-dump first 32 bytes of the + * OUTPUT buffer at the moment we hand it to the kernel. Helps + * pin down whether our bitstream prepend logic is correct. + * For a valid ANNEX_B IDR slice the dump should start + * 00 00 01 65 ... (00 00 01 = start code; 0x65 = nal_ref_idc=3, + * nal_unit_type=5 = IDR slice). Removed once Step 1 decode is + * verified working. + */ + { + const unsigned char *p = surface_object->source_data; + char hex[32 * 3 + 1] = { 0 }; + unsigned int i, n = surface_object->slices_size < 32 ? + surface_object->slices_size : 32; + for (i = 0; i < n; i++) + snprintf(hex + i * 3, 4, " %02x", p[i]); + request_log("OUTPUT[idx=%u, len=%u]:%s\n", + surface_object->source_index, + surface_object->slices_size, hex); + } + rc = v4l2_queue_buffer(driver_data->video_fd, request_fd, output_type, &surface_object->timestamp, surface_object->source_index, diff --git a/src/surface.c b/src/surface.c index 31cba3c..56d03bd 100644 --- a/src/surface.c +++ b/src/surface.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -364,6 +365,30 @@ VAStatus RequestSyncSurface(VADriverContextP context, VASurfaceID surface_id) goto error; } + /* + * DEBUG INSTRUMENTATION (0010): hex-dump first 32 bytes of the + * decoded CAPTURE Y-plane after DQBUF. If the kernel actually + * decoded the frame, these should reflect a real Y-luma pattern + * (varied bytes). All-zero or all-identical means no decode + * landed pixels in the buffer. Removed once Step 1 is verified. + */ + { + const unsigned char *p = + (unsigned char *)surface_object->destination_map[0]; + char hex[32 * 3 + 1] = { 0 }; + unsigned int i; + if (p == NULL) { + request_log("CAPTURE[idx=%u, plane0]: (NULL)\n", + surface_object->destination_index); + } else { + for (i = 0; i < 32; i++) + snprintf(hex + i * 3, 4, " %02x", p[i]); + request_log("CAPTURE[idx=%u, plane0]:%s\n", + surface_object->destination_index, + hex); + } + } + surface_object->status = VASurfaceDisplaying; status = VA_STATUS_SUCCESS;