forge
Explore
Log in

Don't you dare go Hollow

wip(av1): OBMC decode round 1 -- CDF + header-bit plumbing, symbol NOT read yet

Browse files at this commit

0b6a5ba412b557b7c15989baebcf62fffcaa24d8Ahmet Kaan GümüşParent: 4d29711
Dying words (builder capped at 75 calls):
- COMPILES (warnings only). Landed: default_obmc_cdf transcribed
  (cdf.rs OBMC, 4 square bsizes 8/16/32/64 = BLOCK_SIZES_ALL
  3/6/9/12); Cdfs.obmc storage + reset + seed; decode_inter_block +
  decode_inter_frame_tile_with_cdfs take switchable_motion_mode /
  allow_warped_motion, threaded from header at stream.rs:382; the
  16x16 leaf call sites pass them; decode_inter_block8 (8x8 leaves)
  intentionally NOT wired (round 2 per plan).
- REMAINING: (1) read_motion_mode symbol read inside
  decode_inter_block -- placement per libaom decodemv.c:1575 region
  read order, AFTER compound/interp reads; eligibility =
  av1_count_overlappable_neighbors port (whole edge span, not one
  cell) + global-mv/bsize checks per motion_mode_allowed
  (reconinter.h); round-1 scope reads 2-sym obmc_cdf only
  (allow_warped_motion=0 streams). (2) OBMC prediction:
  av1_build_obmc_inter_predictors_sb port (above/left overlap
  predictors, av1_get_obmc_mask blend, luma + 4:2:0 chroma plane
  loop). (3) aomenc OBMC gate (--enable-obmc=1
  --enable-warped-motion=0 on base recipe) 10x + existing 4 gates
  10x + lib suite 3x. (4) warp-stream refusal accuracy check.
- Refuse-vs-desync verdict for pre-fix OBMC streams: NOT yet
  established by this round -- handoff must check before claiming.
crates/ec-av1/src/cdf.rsmodified+13 -0
@@ -1205,6 +1205,19 @@ pub const SINGLE_REF: [[[u16; 3]; 6]; 3] = [
12051205 /// least 8x8 both dims (`is_comp_ref_allowed`) -- lane-av1comp.
12061206 pub const SKIP_MODE: [[u16; 3]; 3] = [[32621, 32768, 0], [20708, 32768, 0], [8127, 32768, 0]];
12071207
1208+/// `default_obmc_cdf` (spec 9.4): `use_obmc`, by square bsize (`BLOCK_8X8`,
1209+/// `BLOCK_16X16`, `BLOCK_32X32`, `BLOCK_64X64` -- `BLOCK_SIZES_ALL` indices
1210+/// 3/6/9/12, the only sizes this decoder ever codes). Read only once
1211+/// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers
1212+/// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 1
1213+/// never reaches the three-way `motion_mode_cdf`, see `decode.rs`.
1214+pub const OBMC: [[u16; 3]; 4] = [
1215+ [10437, 32768, 0],
1216+ [17432, 32768, 0],
1217+ [25817, 32768, 0],
1218+ [30128, 32768, 0],
1219+];
1220+
12081221 /// `Default_Comp_Mode_Cdf` (spec 9.4, `default_comp_inter_cdf`): whether an
12091222 /// inter block reads `SINGLE_REFERENCE` or `COMPOUND_REFERENCE` -- only
12101223 /// reached once `read_ref_frames` knows the frame's `reference_select`
crates/ec-av1/src/cdf_state.rsmodified+11 -0
@@ -318,6 +318,15 @@ pub(crate) struct Cdfs {
318318 /// Whether a block reads `skip_mode` (lane-av1comp, spec 5.11.29's
319319 /// `skip_mode`), indexed by `av1_get_skip_mode_context`.
320320 pub skip_mode: [[u16; 3]; 3],
321+ /// `use_obmc` (spec 5.11.24's `read_motion_mode`, the `OBMC_CAUSAL`-vs-
322+ /// `SIMPLE_TRANSLATION` two-symbol alphabet libaom's `obmc_cdf` reads
323+ /// whenever `motion_mode_allowed` can't offer `WARPED_CAUSAL` --
324+ /// lane-motionmode round 1 only reaches this arm, never the three-way
325+ /// `motion_mode_cdf`), indexed by this block's own square bsize: 0 =
326+ /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64`
327+ /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 --
328+ /// this decoder only ever codes those four square sizes).
329+ pub obmc: [[u16; 3]; 4],
321330 /// Which of the eight `INTER_COMPOUND_MODES` a `COMPOUND_REFERENCE`
322331 /// block takes (lane-av1comp, spec 5.11.24's `compound_mode`).
323332 pub inter_compound_mode: [[u16; 9]; 8],
@@ -548,6 +557,7 @@ impl Cdfs {
548557 reset3(&mut self.single_ref);
549558 reset2(&mut self.comp_mode);
550559 reset2(&mut self.skip_mode);
560+ reset2(&mut self.obmc);
551561 reset2(&mut self.inter_compound_mode);
552562 reset2(&mut self.comp_ref_type);
553563 reset3(&mut self.uni_comp_ref);
@@ -988,6 +998,7 @@ impl Cdfs {
988998 comp_ref: cdf::COMP_REF,
989999 comp_bwdref: cdf::COMP_BWDREF,
9901000 skip_mode: cdf::SKIP_MODE,
1001+ obmc: cdf::OBMC,
9911002 comp_group_idx: cdf::COMP_GROUP_IDX,
9921003 compound_idx: cdf::COMPOUND_IDX,
9931004 y_mode: cdf::Y_MODE,
crates/ec-av1/src/decode.rsmodified+18 -0
@@ -4306,6 +4306,10 @@ fn decode_inter_block(
43064306 // `compound_idx` read (libaom `decodemv.c` 1604-1619, 1382-1384, 1509).
43074307 skip_mode_present: bool,
43084308 skip_mode_frame: [u8; 2],
4309+ // lane-motionmode round 1: this frame header's own `is_motion_mode_switchable`/
4310+ // `allow_warped_motion` bits (spec 5.11.24's `read_motion_mode`).
4311+ switchable_motion_mode: bool,
4312+ allow_warped_motion: bool,
43094313 ) -> Result<()> {
43104314 let (r, c) = at;
43114315 let (px, py) = (c * SUB, r * SUB);
@@ -6207,6 +6211,8 @@ pub fn decode_inter_frame_tile(
62076211 false,
62086212 [0; 2],
62096213 true,
6214+ false,
6215+ false,
62106216 )
62116217 .map(|(picture, _, _)| picture)
62126218 }
@@ -6257,6 +6263,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
62576263 // `Set1` coefficient tables at 16x16/8x8 rather than the reduced
62586264 // 2-symbol ones -- see [`TxbSet::Luma16InterSet1`]/[`TxbSet::Luma8InterSet1`]).
62596265 reduced_tx_set: bool,
6266+ // lane-motionmode round 1: this frame header's own `is_motion_mode_switchable`/
6267+ // `allow_warped_motion` bits, threaded to every `decode_inter_block` call
6268+ // below (spec 5.11.24's `read_motion_mode`) -- `decode_inter_block8`'s 8x8
6269+ // leaves do not read this symbol yet (round 2).
6270+ switchable_motion_mode: bool,
6271+ allow_warped_motion: bool,
62606272 ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> {
62616273 let tpl_frame = tpl_field.map(|field| TplFrameArgs {
62626274 field,
@@ -6461,6 +6473,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
64616473 ref_order_hints,
64626474 skip_mode_present,
64636475 skip_mode_frame,
6476+ switchable_motion_mode,
6477+ allow_warped_motion,
64646478 )?;
64656479 }
64666480 PARTITION_SPLIT => {
@@ -6531,6 +6545,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
65316545 ref_order_hints,
65326546 skip_mode_present,
65336547 skip_mode_frame,
6548+ switchable_motion_mode,
6549+ allow_warped_motion,
65346550 )?;
65356551 } else {
65366552 let ctx16 = neighbours.partition_ctx(at16, SUB);
@@ -7373,6 +7389,8 @@ mod tests {
73737389 [0; 7],
73747390 false,
73757391 [0; 2],
7392+ false,
7393+ false,
73767394 )
73777395 .unwrap();
73787396
crates/ec-av1/src/stream.rsmodified+2 -0
@@ -379,6 +379,8 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
379379 header.skip_mode_present,
380380 header.skip_mode_frame,
381381 header.reduced_tx_set,
382+ header.is_motion_mode_switchable,
383+ header.allow_warped_motion,
382384 )?
383385 };
384386 // Spec 7.20: `disable_frame_end_update_cdf` stores the frame's