From 0eca3ffc6bc42ed7097d215dd90162e7b8e69f3b Mon Sep 17 00:00:00 2001 From: claude-noether Date: Thu, 14 May 2026 15:00:31 +0000 Subject: [PATCH] iter29 DIAG: dump trailing 80 bytes of HEVC slice_data per slice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Env-gated via LIBVA_HEVC_DUMP_SLICE_TAIL=1. Goal: characterise the 40-byte inflation in libva's slice_data buffer vs ffmpeg-v4l2request (see iter27/28 close — HEVC frame 2+ divergence at byte 1382401). Dumps per slice: nal_unit_type, slice_data_size, slice_data_byte_offset, and the last 80 bytes of source_data for that slice. Lets us see if the trailing 40 bytes are (a) real entropy, (b) trailing zeros, (c) a next-NAL start code prefix, or (d) random memory. --- src/h265.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/h265.c b/src/h265.c index 17b6987..4655ecc 100644 --- a/src/h265.c +++ b/src/h265.c @@ -70,6 +70,7 @@ #include "surface.h" #include +#include #include #include @@ -613,6 +614,26 @@ int h265_set_controls(struct request_data *driver_data, cumulative_offset, &slice_params_array[i]); + /* iter29 DIAG: dump trailing 80 bytes of each HEVC slice. + * Set LIBVA_HEVC_DUMP_SLICE_TAIL=1 to enable. Goal: characterise + * the 40-byte inflation in ffmpeg-vaapi vs ffmpeg-v4l2request for + * frame 2+ slices (see iter27/28 close). */ + if (getenv("LIBVA_HEVC_DUMP_SLICE_TAIL")) { + uint32_t sz = slice->slice_data_size; + uint32_t boff = slice->slice_data_byte_offset; + uint8_t *p = (uint8_t *)surface_object->source_data + cumulative_offset; + uint32_t dump_n = sz < 80 ? sz : 80; + uint32_t start = sz - dump_n; + uint32_t k; + fprintf(stderr, "iter29 slice[%u] nut=%u size=%u boff=%u start_in_slice=%u tail80:", + i, slice_params_array[i].nal_unit_type, sz, boff, start); + for (k = 0; k < dump_n; k++) { + if ((k & 0xf) == 0) fprintf(stderr, "\n +%04x:", start + k); + fprintf(stderr, " %02x", p[start + k]); + } + fprintf(stderr, "\n"); + } + cumulative_offset += slice->slice_data_size; }