forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-av1golden6': switchable_interp ctx must ignore other-ref neighbours

Browse files at this commit

907cb780fb9626e37dcb52b5d0c1054d96775d49Ahmet Kaan GümüşParent: 360bf3b71a371f
crates/ec-av1/src/decode.rsmodified+31 -6
@@ -3793,10 +3793,17 @@ fn decode_inter_block(
37933793 LAST_FRAME => (ref_y, ref_u, ref_v),
37943794 _ => {
37953795 return Err(unsupported(
3796- "a reference frame other than LAST_FRAME (round 7: GOLDEN_FRAME's decode \
3797- path exists but is masked -- a narrow +-1 MC residue on a dual-axis \
3798- subpel GOLDEN block, isolated to pre-deblock this round, keeps real \
3799- GOLDEN streams from pixel-exact)",
3796+ "a reference frame other than LAST_FRAME (round 8: GOLDEN_FRAME's decode \
3797+ path exists but is masked -- unmasking it with a switchable_interp \
3798+ ref_frame-gated context fix still produces a real frame-0 (intra \
3799+ keyframe) luma mismatch against ffmpeg whenever GOLDEN_FRAME actually \
3800+ fires downstream in the same stream, reproduced twice live \
3801+ (seeds 57, 59; reproducing stream dumped to \
3802+ fixtures/golden6-mismatch.obu). Root cause is not \
3803+ the switchable_interp context (that gate is correct and kept) but \
3804+ something GOLDEN-adjacent that corrupts an unrelated earlier frame's \
3805+ comparison -- possibly frame-count/ordering divergence between our \
3806+ decoder and ffmpeg once aomenc's RD picks GOLDEN, unproven past that)",
38003807 ));
38013808 }
38023809 };
@@ -3873,14 +3880,32 @@ fn decode_inter_block(
38733880 };
38743881 (mv, false)
38753882 };
3883+ // spec `get_ref_filter_type`: a neighbour's own filter only feeds
3884+ // this block's switchable_interp context when that neighbour coded
3885+ // the SAME reference frame this block is about to read -- a
3886+ // different-ref neighbour reads as "no neighbour" ([3, 3], the
3887+ // sentinel `Neighbours::new` already seeds unset slots with),
3888+ // exactly like an intra neighbour. Without this gate, a GOLDEN_FRAME
3889+ // block next to a LAST_FRAME one inherits that neighbour's filter
3890+ // choice into its own context, corrupting the symbol it reads.
3891+ let above_filter_ctx = if neighbours.above_ref[c] == ref_frame {
3892+ neighbours.above_filter[c]
3893+ } else {
3894+ [3, 3]
3895+ };
3896+ let left_filter_ctx = if neighbours.left_ref[r] == ref_frame {
3897+ neighbours.left_filter[r]
3898+ } else {
3899+ [3, 3]
3900+ };
38763901 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
38773902 dec,
38783903 cdfs,
38793904 interp_fixed,
38803905 enable_dual_filter,
38813906 is_globalmv,
3882- neighbours.above_filter[c],
3883- neighbours.left_filter[r],
3907+ above_filter_ctx,
3908+ left_filter_ctx,
38843909 );
38853910 block_filter = resolved_filter;
38863911 globalmv_for_lf = is_globalmv;
crates/ec-av1/src/stream.rsmodified+12 -0
@@ -2042,6 +2042,18 @@ mod tests {
20422042 }
20432043 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
20442044 assert_eq!(frames.len(), frame_count);
2045+ // Same pin-on-mismatch pattern as the CDF forwarding gate above:
2046+ // env-gated, no cost on a normal run.
2047+ let mismatched = frames
2048+ .iter()
2049+ .zip(&ffmpeg_frames)
2050+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
2051+ if mismatched {
2052+ if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") {
2053+ std::fs::write(&path, &stream).expect("writing pinned stream");
2054+ eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}");
2055+ }
2056+ }
20452057 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
20462058 assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})");
20472059 assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})");