diff --git a/src/picture.c b/src/picture.c index c126a64..3f010e5 100644 --- a/src/picture.c +++ b/src/picture.c @@ -321,6 +321,29 @@ VAStatus RequestBeginPicture(VADriverContextP context, VAContextID context_id, if (cap_slot == NULL) return VA_STATUS_ERROR_ALLOCATION_FAILED; surface_bind_slot(surface_object, cap_slot); + + /* + * iter8 Phase 7 IMP-1 experiment: env-gated CAPTURE buffer + * pre-zero. LIBVA_V4L2_ZERO_CAPTURE=1 wipes the slot's mmap'd + * region before kernel decode. Discriminates "kernel writes + * partial then aborts" from "kernel writes nothing and we + * see stale residue." + */ + { + static const char *zero_env = NULL; + static bool zero_env_checked = false; + if (!zero_env_checked) { + zero_env = getenv("LIBVA_V4L2_ZERO_CAPTURE"); + zero_env_checked = true; + } + if (zero_env != NULL && zero_env[0] == '1') { + unsigned int b; + for (b = 0; b < cap_slot->buffers_count; b++) + if (cap_slot->map[b] != NULL) + memset(cap_slot->map[b], 0, + cap_slot->map_lengths[b]); + } + } } /*