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; }