forge
Explore
Log in

Don't you dare go Hollow

Inter frames' intra blocks inherited a stale enable_intra_edge_filter

Browse files at this commit

d1585d00bff858538a919b803b25f557524eb35cAhmet Kaan GümüşParent: 62aad8f
  • fix
    • inter frames' intra blocks inherited a stale enable_intra_edge_filter
Show full message
fix(av1): inter frames' intra blocks inherited a stale enable_intra_edge_filter

ENABLE_EDGE_FILTER is a thread-local set only by decode_key_frame_tile_with_cdfs;
decode_inter_frame_tile never set it, so an inter frame's intra blocks read
whatever the last key frame decoded on that thread left behind. Within one
stream that is inert (its own key frame sets it first), but it makes decode
impure across streams sharing a thread -- a real contamination path, and the
shape that produces a suite-only flake.

decode_stream now sets it from the sequence header for every stream, covering
inter frames. Also teaches build-aom-oracle.sh to reconfigure a build tree that
was configured under a different path instead of failing to regenerate.
crates/ec-av1/src/decode.rsmodified+14 -0
@@ -391,6 +391,20 @@ thread_local! {
391 static ENABLE_EDGE_FILTER: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };391 static ENABLE_EDGE_FILTER: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
392 }392 }
393 393
394+/// Set [`ENABLE_EDGE_FILTER`] for this thread.
395+///
396+/// `decode_key_frame_tile_with_cdfs` sets it, but `decode_inter_frame_tile`
397+/// never did -- so an inter frame's intra blocks read whatever value the last
398+/// key frame decoded ON THIS THREAD left behind. Inside one stream that is
399+/// harmless (its own key frame sets it first), but a caller that decodes an
400+/// inter frame directly, or a test harness running several streams on one
401+/// thread, inherits a foreign sequence's bit: decode stops being a pure
402+/// function of the bitstream. `decode_stream` now calls this once per stream
403+/// from the sequence header, which covers every frame including inter ones.
404+pub(crate) fn set_enable_edge_filter(value: bool) {
405+ ENABLE_EDGE_FILTER.with(|f| f.set(value));
406+}
407+
394 /// Current value of [`ANGLE_DELTA_HITS`].408 /// Current value of [`ANGLE_DELTA_HITS`].
395 pub(crate) fn angle_delta_hits() -> usize {409 pub(crate) fn angle_delta_hits() -> usize {
396 ANGLE_DELTA_HITS.load(std::sync::atomic::Ordering::Relaxed)410 ANGLE_DELTA_HITS.load(std::sync::atomic::Ordering::Relaxed)
crates/ec-av1/src/stream.rsmodified+5 -0
@@ -249,6 +249,11 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
249 let enable_edge_filter = parser249 let enable_edge_filter = parser
250 .sequence_header()250 .sequence_header()
251 .is_some_and(|seq| seq.enable_intra_edge_filter);251 .is_some_and(|seq| seq.enable_intra_edge_filter);
252+ // Inter frames' intra blocks read this through a thread-local that only
253+ // the key-frame tile path used to set; without this call a stream whose
254+ // inter frames are decoded on a thread that previously decoded a
255+ // different sequence would inherit that sequence's bit.
256+ crate::decode::set_enable_edge_filter(enable_edge_filter);
252 // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits.257 // lane-av1comp: `comp_group_idx`/`compound_idx`'s own gating bits.
253 let enable_masked_compound = parser258 let enable_masked_compound = parser
254 .sequence_header()259 .sequence_header()
scripts/build-aom-oracle.shmodified+13 -0
@@ -22,6 +22,19 @@ if [ ! -d "$SRC/.git" ]; then
22 git clone --depth 1 --branch "$VERSION" https://aomedia.googlesource.com/aom "$SRC"22 git clone --depth 1 --branch "$VERSION" https://aomedia.googlesource.com/aom "$SRC"
23 fi23 fi
24 24
25+# A cmake build tree bakes in its own absolute path and its source's, so a
26+# build dir that was produced elsewhere and then moved cannot regenerate
27+# (`ninja: error: rebuilding build.ninja`) -- which silently costs you the
28+# ability to re-instrument aomdec later. Never stage a build under one name
29+# and rename it; configure it where it will live. If the cache disagrees with
30+# where we are now, drop it and reconfigure in place.
31+if [ -f "$BUILD/CMakeCache.txt" ] &&
32+ ! grep -q "^CMAKE_HOME_DIRECTORY:INTERNAL=$SRC$" "$BUILD/CMakeCache.txt"; then
33+ echo "build tree was configured for a different path -- reconfiguring in place" >&2
34+ rm -f "$BUILD/CMakeCache.txt"
35+ rm -rf "$BUILD/CMakeFiles"
36+fi
37+
25 CPU_ARGS=()38 CPU_ARGS=()
26 if [ -n "${AOM_TARGET_CPU:-}" ]; then39 if [ -n "${AOM_TARGET_CPU:-}" ]; then
27 CPU_ARGS=(-DAOM_TARGET_CPU="$AOM_TARGET_CPU")40 CPU_ARGS=(-DAOM_TARGET_CPU="$AOM_TARGET_CPU")