The loop-restoration coefficient reference must reset at every tile
Browse files at this commitf546cd0cd99786bc63507a4f768113bbd9da361cParent: 32b53ec- fix
- the loop-restoration coefficient reference must reset at every tile
2 changed files +35 -25
- crates/ec-av1/src/decode.rs +22 -8
- crates/ec-av1/src/stream.rs +13 -17
crates/ec-av1/src/decode.rsmodified+22 -8
| @@ -16399,10 +16399,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 16399 | mi_rows as usize, | 16399 | mi_rows as usize, |
| 16400 | ); | 16400 | ); |
| 16401 | let mut lr_grid = crate::restoration::RestorationGrid::new(lr, frame_width, frame_height); | 16401 | let mut lr_grid = crate::restoration::RestorationGrid::new(lr, frame_width, frame_height); |
| 16402 | - let mut lr_reference = [( | ||
| 16403 | - crate::restoration::WienerInfo::default(), | ||
| 16404 | - crate::restoration::SgrprojInfo::default(), | ||
| 16405 | - ); 3]; | ||
| 16406 | 16402 | ||
| 16407 | // lane-tiles r2: each tile gets its own fresh `SymbolDecoder` over its | 16403 | // lane-tiles r2: each tile gets its own fresh `SymbolDecoder` over its |
| 16408 | // own byte range and its own fresh copy of the frame's initial CDFs | 16404 | // own byte range and its own fresh copy of the frame's initial CDFs |
| @@ -16430,6 +16426,17 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 16430 | let (sb_r0, sb_r1) = ((mi_row0 / SB_MI).min(sb_rows), mi_row1.div_ceil(SB_MI).min(sb_rows)); | 16426 | let (sb_r0, sb_r1) = ((mi_row0 / SB_MI).min(sb_rows), mi_row1.div_ceil(SB_MI).min(sb_rows)); |
| 16431 | let (sb_c0, sb_c1) = ((mi_col0 / SB_MI).min(sb_cols), mi_col1.div_ceil(SB_MI).min(sb_cols)); | 16427 | let (sb_c0, sb_c1) = ((mi_col0 / SB_MI).min(sb_cols), mi_col1.div_ceil(SB_MI).min(sb_cols)); |
| 16432 | 16428 | ||
| 16429 | + // lane-t900 r19: spec 5.11.2 `decode_tile` resets `RefLrWiener` / | ||
| 16430 | + // `RefSgrXqd` to the midpoint filter at the top of EVERY tile, not | ||
| 16431 | + // once per frame. Carried across a tile boundary, the loop-restoration | ||
| 16432 | + // coefficients of the next tile decode off the previous tile's | ||
| 16433 | + // reference -- same symbol count, so entropy and reconstruction stay | ||
| 16434 | + // exact and only the filtered pixels of every tile after the first | ||
| 16435 | + // are wrong. | ||
| 16436 | + let mut lr_reference = [( | ||
| 16437 | + crate::restoration::WienerInfo::default(), | ||
| 16438 | + crate::restoration::SgrprojInfo::default(), | ||
| 16439 | + ); 3]; | ||
| 16433 | let mut cdfs = base_cdfs.clone(); | 16440 | let mut cdfs = base_cdfs.clone(); |
| 16434 | // spec `decode_tile`: `CurrentQIndex` resets to the frame's own | 16441 | // spec `decode_tile`: `CurrentQIndex` resets to the frame's own |
| 16435 | // `base_q_idx` at the top of every tile, not once per frame. | 16442 | // `base_q_idx` at the top of every tile, not once per frame. |
| @@ -27435,10 +27442,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 27435 | ); | 27442 | ); |
| 27436 | let mut grid = MiGrid::new(mi_cols as usize, mi_rows as usize); | 27443 | let mut grid = MiGrid::new(mi_cols as usize, mi_rows as usize); |
| 27437 | let mut lr_grid = crate::restoration::RestorationGrid::new(lr, frame_width, frame_height); | 27444 | let mut lr_grid = crate::restoration::RestorationGrid::new(lr, frame_width, frame_height); |
| 27438 | - let mut lr_reference = [( | ||
| 27439 | - crate::restoration::WienerInfo::default(), | ||
| 27440 | - crate::restoration::SgrprojInfo::default(), | ||
| 27441 | - ); 3]; | ||
| 27442 | 27445 | ||
| 27443 | // lane-tiles r6: mirrors decode_key_frame_tile_with_cdfs's own per-tile | 27446 | // lane-tiles r6: mirrors decode_key_frame_tile_with_cdfs's own per-tile |
| 27444 | // loop (spec 5.11.2 decode_tile / 7.20 exit_symbol) -- each tile gets | 27447 | // loop (spec 5.11.2 decode_tile / 7.20 exit_symbol) -- each tile gets |
| @@ -27460,6 +27463,17 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 27460 | (mi_col0 / SB_MI).min(sb_cols), | 27463 | (mi_col0 / SB_MI).min(sb_cols), |
| 27461 | mi_col1.div_ceil(SB_MI).min(sb_cols), | 27464 | mi_col1.div_ceil(SB_MI).min(sb_cols), |
| 27462 | ); | 27465 | ); |
| 27466 | + // lane-t900 r19: spec 5.11.2 `decode_tile` resets `RefLrWiener` / | ||
| 27467 | + // `RefSgrXqd` to the midpoint filter at the top of EVERY tile, not | ||
| 27468 | + // once per frame. Carried across a tile boundary, the loop-restoration | ||
| 27469 | + // coefficients of the next tile decode off the previous tile's | ||
| 27470 | + // reference -- same symbol count, so entropy and reconstruction stay | ||
| 27471 | + // exact and only the filtered pixels of every tile after the first | ||
| 27472 | + // are wrong. | ||
| 27473 | + let mut lr_reference = [( | ||
| 27474 | + crate::restoration::WienerInfo::default(), | ||
| 27475 | + crate::restoration::SgrprojInfo::default(), | ||
| 27476 | + ); 3]; | ||
| 27463 | let mut cdfs = base_cdfs.clone(); | 27477 | let mut cdfs = base_cdfs.clone(); |
| 27464 | CURRENT_Q_IDX.with(|c| c.set(i32::from(base_q_idx))); | 27478 | CURRENT_Q_IDX.with(|c| c.set(i32::from(base_q_idx))); |
| 27465 | QUANT_DELTAS.with(|c| c.set(deltas)); | 27479 | QUANT_DELTAS.with(|c| c.set(deltas)); |
crates/ec-av1/src/stream.rsmodified+13 -17
| @@ -28608,24 +28608,20 @@ mod tests { | |||
| 28608 | ); | 28608 | ); |
| 28609 | } | 28609 | } |
| 28610 | 28610 | ||
| 28611 | - /// OPEN DEFECT (lane-tiles r11), which is why this arm is `#[ignore]`d | 28611 | + /// lane-t900 r19, the defect this arm exists for, now FIXED: spec 5.11.2 |
| 28612 | - /// rather than deleted or quietly reseeded: at seed 42 this recipe | 28612 | + /// `decode_tile` resets `RefLrWiener`/`RefSgrXqd` (the running |
| 28613 | - /// mismatches ffmpeg from frame 4 on, in one 32x32 block at | 28613 | + /// loop-restoration coefficient reference) to the midpoint filter at the |
| 28614 | - /// x[224..255] y[32..63] (measured with `--loopfilter-control=0`, which | 28614 | + /// top of EVERY tile; `decode.rs` declared that state once per frame, so |
| 28615 | - /// removes the deblock spreading; with deblocking on the region grows to | 28615 | + /// every tile after the first decoded its Wiener/Sgrproj coefficients off |
| 28616 | - /// x[221..255] y[30..69] and crosses the tile row boundary at y=64), and | 28616 | + /// the previous tile's reference. The symbol COUNT is unchanged, so |
| 28617 | - /// the error then propagates through inter prediction to 12 of 16 frames. | 28617 | + /// entropy and reconstruction stayed byte-exact and only the filtered |
| 28618 | - /// Ablations that did NOT remove it: `--enable-restoration=0`, | 28618 | + /// pixels moved -- at seed 44 frame 0 (the key frame) the whole right tile |
| 28619 | - /// `--enable-cdef=0`, `--loopfilter-control=0`. It is seed-specific | 28619 | + /// column, luma x[128..255] y[0..91], 1330 samples off by at most 2, with |
| 28620 | - /// (seeds 47 and 48 decode 16/16 exact with two tile rows) and its | 28620 | + /// chroma exact. Ladder that named it: `EC_AV1_PREFILT_DUMP` exact, |
| 28621 | - /// tile attribution is UNPROVEN: the single-tile control at seed 42 | 28621 | + /// `EC_AV1_POSTDEBLOCK_DUMP` exact, `EC_AV1_POSTCDEF_DUMP` exact (that |
| 28622 | - /// re-encodes to different partitions and refuses on | 28622 | + /// last rung added to the oracle's `decodeframe.c` in this round), so the |
| 28623 | - /// "an inter SB-level partition type other than SPLIT", so no | 28623 | + /// only remaining stage was loop restoration. |
| 28624 | - /// same-content one-tile comparison exists. Reproducer: | ||
| 28625 | - /// `EC_AV1_GATE_DUMP=<path> cargo test -p ec-av1 --lib | ||
| 28626 | - /// a_real_aomenc_multi_tile_inter_stream -- --ignored`. | ||
| 28627 | #[test] | 28624 | #[test] |
| 28628 | - #[ignore = "open defect: seed-42 32x32 block at x[224..255] y[32..63] mismatches; tile attribution unproven"] | ||
| 28629 | fn a_real_aomenc_multi_tile_inter_stream_decodes_pixel_exact() { | 28625 | fn a_real_aomenc_multi_tile_inter_stream_decodes_pixel_exact() { |
| 28630 | run_multi_tile_gate( | 28626 | run_multi_tile_gate( |
| 28631 | "a_real_aomenc_multi_tile_inter_stream_decodes_pixel_exact", | 28627 | "a_real_aomenc_multi_tile_inter_stream_decodes_pixel_exact", |