From 522fb6daa5358cca3e478d3726a303d598f485ee Mon Sep 17 00:00:00 2001 From: claude-noether Date: Thu, 14 May 2026 08:19:29 +0000 Subject: [PATCH] =?UTF-8?q?iter14=20=CE=B1-16:=20env-gated=20OUTPUT=20bits?= =?UTF-8?q?tream=20byte=20dump=20pre-QBUF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LIBVA_V4L2_DUMP_OUTPUT= writes source_data[0..slices_size] to /output_p_s_t.bin immediately before v4l2_queue_buffer OUTPUT. Discriminates whether libva writes the correct H.264/HEVC bitstream bytes (same as kdirect/input file). Off by default. Wrapped in static-cache env check. iter11+12+13 confirmed Bug 4/5 are not in S_EXT_CTRLS payload, not in kernel substrate (RFC v2), not in CPU cache visibility (α-17 sync ioctl works but inert). The remaining libva-side surface is the actual bitstream bytes the kernel reads. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/picture.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/picture.c b/src/picture.c index f72828b..9739f6f 100644 --- a/src/picture.c +++ b/src/picture.c @@ -488,6 +488,49 @@ VAStatus RequestEndPicture(VADriverContextP context, VAContextID context_id) if (rc != VA_STATUS_SUCCESS) return rc; + /* + * iter14 α-16: env-gated dump of OUTPUT bitstream bytes immediately + * before QBUF. LIBVA_V4L2_DUMP_OUTPUT= writes source_data[0.. + * slices_size] to /output___.bin. + * Discriminates whether libva writes the same H.264/HEVC slice bytes + * as kdirect — if YES, Bug 4/5 are not in the OUTPUT-side; if NO, + * narrow to which slice-write path produces the divergence. + * + * Off by default; no behavior change when env unset. + */ + { + static const char *dump_env = NULL; + static bool dump_env_checked = false; + if (!dump_env_checked) { + dump_env = getenv("LIBVA_V4L2_DUMP_OUTPUT"); + dump_env_checked = true; + } + if (dump_env != NULL && dump_env[0] != '\0' && + surface_object->source_data != NULL && + surface_object->slices_size > 0) { + char path[256]; + snprintf(path, sizeof(path), + "%s/output_p%d_s%u_t%llu.bin", + dump_env, (int)config_object->profile, + (unsigned int)surface_object->base.id, + (unsigned long long)context_object->timestamp_counter); + FILE *fp = fopen(path, "wb"); + if (fp != NULL) { + size_t w = fwrite(surface_object->source_data, + 1, surface_object->slices_size, + fp); + request_log("α-16: dumped %zu bytes to %s " + "(slices_count=%u)\n", + w, path, + surface_object->slices_count); + fclose(fp); + } else { + request_log("α-16: fopen(%s) failed: %s\n", + path, strerror(errno)); + } + } + } + rc = v4l2_queue_buffer(driver_data->video_fd, -1, capture_type, NULL, surface_object->destination_index, 0, surface_object->destination_buffers_count);