forge
Explore
Log in

Don't you dare go Hollow

wip(av1): loop restoration CDF tables (restore_wiener/sgrproj/switchable)

Browse files at this commit

ed590d6cc5459b4d4f6d5e418a2300756c4f482eAhmet Kaan GümüşParent: d3d4001
libaom entropymode.c default_{wiener,sgrproj,switchable}_restore_cdf,
copied exactly. Wired into Cdfs struct, defaults, and counter reset
(reset1, unindexed like intrabc). Not read from the bitstream yet --
next step wires read_lr/read_lr_unit into the superblock walk.
crates/ec-av1/src/cdf.rsmodified+10 -0
@@ -419,6 +419,16 @@ pub const PALETTE_UV_MODE: [[u16; 3]; 2] = [[32461, 32768, 0], [21488, 32768, 0]
419419 /// `default_intrabc_cdf` (entropymode.c): the `use_intrabc` flag on an
420420 /// intra frame with `allow_intrabc` set.
421421 pub const INTRABC: [u16; 3] = [30531, 32768, 0];
422+/// `default_wiener_restore_cdf` (entropymode.c): a `RESTORE_WIENER`-plane
423+/// LR unit's own `use_wiener` flag (spec 5.11.57 `read_lr_unit`).
424+pub const RESTORE_WIENER: [u16; 3] = [11570, 32768, 0];
425+/// `default_sgrproj_restore_cdf`: a `RESTORE_SGRPROJ`-plane LR unit's own
426+/// `use_sgrproj` flag.
427+pub const RESTORE_SGRPROJ: [u16; 3] = [16855, 32768, 0];
428+/// `default_switchable_restore_cdf`: a `RESTORE_SWITCHABLE`-plane LR unit's
429+/// own `restoration_type` (3-way: `RESTORE_NONE`/`RESTORE_WIENER`/
430+/// `RESTORE_SGRPROJ`).
431+pub const RESTORE_SWITCHABLE: [u16; 4] = [9413, 22581, 32768, 0];
422432
423433 /// `default_tx_size_cdf[0]` (entropymode.c): an 8x8 block's `tx_depth` flag
424434 /// (`TX8` vs `TX4`), indexed by `tx_size_context` (0..=2).
crates/ec-av1/src/cdf_state.rsmodified+15 -0
@@ -433,6 +433,15 @@ pub(crate) struct Cdfs {
433433 pub palette_uv_size: [[u16; 8]; 7],
434434 /// The `use_intrabc` flag -- see [`cdf::INTRABC`].
435435 pub intrabc: [u16; 3],
436+ /// A `RESTORE_WIENER`-plane LR unit's `use_wiener` flag -- see
437+ /// [`cdf::RESTORE_WIENER`].
438+ pub restore_wiener: [u16; 3],
439+ /// A `RESTORE_SGRPROJ`-plane LR unit's `use_sgrproj` flag -- see
440+ /// [`cdf::RESTORE_SGRPROJ`].
441+ pub restore_sgrproj: [u16; 3],
442+ /// A `RESTORE_SWITCHABLE`-plane LR unit's `restoration_type` -- see
443+ /// [`cdf::RESTORE_SWITCHABLE`].
444+ pub restore_switchable: [u16; 4],
436445 }
437446
438447 /// One motion vector component's adapting state (spec 9.4's `Default_Mv_*`,
@@ -654,6 +663,9 @@ impl Cdfs {
654663 reset2(&mut self.palette_uv_mode);
655664 reset2(&mut self.palette_uv_size);
656665 reset1(&mut self.intrabc);
666+ reset1(&mut self.restore_wiener);
667+ reset1(&mut self.restore_sgrproj);
668+ reset1(&mut self.restore_switchable);
657669 }
658670
659671 /// The defaults a key frame starts from (spec 8.4, `init_coeff_cdfs` and
@@ -1114,6 +1126,9 @@ impl Cdfs {
11141126 palette_uv_mode: cdf::PALETTE_UV_MODE,
11151127 palette_uv_size: cdf::PALETTE_UV_SIZE,
11161128 intrabc: cdf::INTRABC,
1129+ restore_wiener: cdf::RESTORE_WIENER,
1130+ restore_sgrproj: cdf::RESTORE_SGRPROJ,
1131+ restore_switchable: cdf::RESTORE_SWITCHABLE,
11171132 }
11181133 }
11191134