diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index fc53c539..d012e0d7 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -21,7 +21,7 @@ //! too). Anything outside that refuses with [`Error::unsupported`] rather than //! silently miscoding. -use ec_av1_syntax::{CdefParams, LoopFilterParams}; +use ec_av1_syntax::{CdefParams, LoopFilterParams, LoopRestorationParams}; use ec_core::{Error, Result}; use crate::cdf; @@ -4458,6 +4458,7 @@ pub fn decode_key_frame_tile( false, cdef, loop_filter, + &LoopRestorationParams::default(), None, tx_select, reduced_tx_set, @@ -4486,6 +4487,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( enable_edge_filter: bool, cdef: &CdefParams, loop_filter: &LoopFilterParams, + lr: &LoopRestorationParams, initial_cdfs: Option, tx_select: bool, reduced_tx_set: bool, @@ -4543,10 +4545,25 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( mi_cols as usize, mi_rows as usize, ); + let mut lr_grid = crate::restoration::RestorationGrid::new(lr, frame_width, frame_height); + let mut lr_reference = [( + crate::restoration::WienerInfo::default(), + crate::restoration::SgrprojInfo::default(), + ); 3]; for sb_r in 0..sb_rows { neighbours.start_row(); for sb_c in 0..sb_cols { + crate::restoration::read_lr( + &mut dec, + &mut cdfs, + lr, + &mut lr_grid, + &mut lr_reference, + sb_r * SB_MI, + sb_c * SB_MI, + SB_MI, + ); let at = (sb_r as usize * 4, sb_c as usize * 4); let ctx = neighbours.partition_ctx(at, SB); let (has_cols, has_rows) = ( @@ -9055,6 +9072,7 @@ pub fn decode_inter_frame_tile( other_refs, cdef, loop_filter, + &LoopRestorationParams::default(), None, allow_high_precision_mv, force_integer_mv, @@ -9096,6 +9114,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( other_refs: [Option<&Picture>; 8], cdef: &CdefParams, loop_filter: &LoopFilterParams, + lr: &LoopRestorationParams, initial_cdfs: Option, allow_high_precision_mv: bool, force_integer_mv: bool, @@ -9271,10 +9290,25 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( mi_rows as usize, ); let mut grid = MiGrid::new(mi_cols as usize, mi_rows as usize); + let mut lr_grid = crate::restoration::RestorationGrid::new(lr, frame_width, frame_height); + let mut lr_reference = [( + crate::restoration::WienerInfo::default(), + crate::restoration::SgrprojInfo::default(), + ); 3]; for sb_r in 0..sb_rows { neighbours.start_row(); for sb_c in 0..sb_cols { + crate::restoration::read_lr( + &mut dec, + &mut cdfs, + lr, + &mut lr_grid, + &mut lr_reference, + sb_r * SB_MI, + sb_c * SB_MI, + SB_MI, + ); let sb_at = (sb_r as usize * 4, sb_c as usize * 4); let sb_ctx = neighbours.partition_ctx(sb_at, SB); let (has_cols, has_rows) = ( diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 20ff033d..419b6dd9 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -191,10 +191,15 @@ pub fn decode_stream(data: &[u8]) -> Result> { // silent-desync shape as the refusals above. Traced live 2026-08-27: // an aomenc inter frame with `Sgrproj` on the V plane desynced the // partition walk into out-of-alphabet garbage. + // lane-lr r2: the per-superblock `read_lr`/`read_lr_unit` symbols are + // now read (`crate::restoration`) and no longer desync the partition + // walk -- the refusal narrows to its true remaining gap: decoded + // Wiener/SGR filters are stored per unit but never applied to + // pixels. if header.loop_restoration.uses_lr { return Err(Error::unsupported( "AV1 decode_stream", - "a frame with loop restoration enabled (this decoder never reads the per-unit lr symbols)", + "a frame with loop restoration enabled (the per-unit lr symbols are read but the Wiener/self-guided filters are not yet applied to pixels)", )); } // `decode_inter_block`/`decode_inter_block8`'s `GLOBALMV` arm (spec @@ -370,6 +375,7 @@ pub fn decode_stream(data: &[u8]) -> Result> { enable_edge_filter, &header.cdef, &header.loop_filter, + &header.loop_restoration, initial_cdfs, header.tx_mode == TxMode::Select, header.reduced_tx_set, @@ -437,6 +443,7 @@ pub fn decode_stream(data: &[u8]) -> Result> { other_refs, &header.cdef, &header.loop_filter, + &header.loop_restoration, initial_cdfs, header.allow_high_precision_mv, header.force_integer_mv,