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(
3793 LAST_FRAME => (ref_y, ref_u, ref_v),3793 LAST_FRAME => (ref_y, ref_u, ref_v),
3794 _ => {3794 _ => {
3795 return Err(unsupported(3795 return Err(unsupported(
3796- "a reference frame other than LAST_FRAME (round 7: GOLDEN_FRAME's decode \3796+ "a reference frame other than LAST_FRAME (round 8: GOLDEN_FRAME's decode \
3797- path exists but is masked -- a narrow +-1 MC residue on a dual-axis \3797+ path exists but is masked -- unmasking it with a switchable_interp \
3798- subpel GOLDEN block, isolated to pre-deblock this round, keeps real \3798+ ref_frame-gated context fix still produces a real frame-0 (intra \
3799- GOLDEN streams from pixel-exact)",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)",
3800 ));3807 ));
3801 }3808 }
3802 };3809 };
@@ -3873,14 +3880,32 @@ fn decode_inter_block(
3873 };3880 };
3874 (mv, false)3881 (mv, false)
3875 };3882 };
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+ };
3876 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(3901 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
3877 dec,3902 dec,
3878 cdfs,3903 cdfs,
3879 interp_fixed,3904 interp_fixed,
3880 enable_dual_filter,3905 enable_dual_filter,
3881 is_globalmv,3906 is_globalmv,
3882- neighbours.above_filter[c],3907+ above_filter_ctx,
3883- neighbours.left_filter[r],3908+ left_filter_ctx,
3884 );3909 );
3885 block_filter = resolved_filter;3910 block_filter = resolved_filter;
3886 globalmv_for_lf = is_globalmv;3911 globalmv_for_lf = is_globalmv;
crates/ec-av1/src/stream.rsmodified+12 -0
@@ -2042,6 +2042,18 @@ mod tests {
2042 }2042 }
2043 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);2043 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
2044 assert_eq!(frames.len(), frame_count);2044 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+ }
2045 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {2057 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
2046 assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})");2058 assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})");
2047 assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})");2059 assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})");