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] = [
1205 /// least 8x8 both dims (`is_comp_ref_allowed`) -- lane-av1comp.1205 /// least 8x8 both dims (`is_comp_ref_allowed`) -- lane-av1comp.
1206 pub const SKIP_MODE: [[u16; 3]; 3] = [[32621, 32768, 0], [20708, 32768, 0], [8127, 32768, 0]];1206 pub const SKIP_MODE: [[u16; 3]; 3] = [[32621, 32768, 0], [20708, 32768, 0], [8127, 32768, 0]];
1207 1207
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+
1208 /// `Default_Comp_Mode_Cdf` (spec 9.4, `default_comp_inter_cdf`): whether an1221 /// `Default_Comp_Mode_Cdf` (spec 9.4, `default_comp_inter_cdf`): whether an
1209 /// inter block reads `SINGLE_REFERENCE` or `COMPOUND_REFERENCE` -- only1222 /// inter block reads `SINGLE_REFERENCE` or `COMPOUND_REFERENCE` -- only
1210 /// reached once `read_ref_frames` knows the frame's `reference_select`1223 /// 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 {
318 /// Whether a block reads `skip_mode` (lane-av1comp, spec 5.11.29's318 /// Whether a block reads `skip_mode` (lane-av1comp, spec 5.11.29's
319 /// `skip_mode`), indexed by `av1_get_skip_mode_context`.319 /// `skip_mode`), indexed by `av1_get_skip_mode_context`.
320 pub skip_mode: [[u16; 3]; 3],320 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],
321 /// Which of the eight `INTER_COMPOUND_MODES` a `COMPOUND_REFERENCE`330 /// Which of the eight `INTER_COMPOUND_MODES` a `COMPOUND_REFERENCE`
322 /// block takes (lane-av1comp, spec 5.11.24's `compound_mode`).331 /// block takes (lane-av1comp, spec 5.11.24's `compound_mode`).
323 pub inter_compound_mode: [[u16; 9]; 8],332 pub inter_compound_mode: [[u16; 9]; 8],
@@ -548,6 +557,7 @@ impl Cdfs {
548 reset3(&mut self.single_ref);557 reset3(&mut self.single_ref);
549 reset2(&mut self.comp_mode);558 reset2(&mut self.comp_mode);
550 reset2(&mut self.skip_mode);559 reset2(&mut self.skip_mode);
560+ reset2(&mut self.obmc);
551 reset2(&mut self.inter_compound_mode);561 reset2(&mut self.inter_compound_mode);
552 reset2(&mut self.comp_ref_type);562 reset2(&mut self.comp_ref_type);
553 reset3(&mut self.uni_comp_ref);563 reset3(&mut self.uni_comp_ref);
@@ -988,6 +998,7 @@ impl Cdfs {
988 comp_ref: cdf::COMP_REF,998 comp_ref: cdf::COMP_REF,
989 comp_bwdref: cdf::COMP_BWDREF,999 comp_bwdref: cdf::COMP_BWDREF,
990 skip_mode: cdf::SKIP_MODE,1000 skip_mode: cdf::SKIP_MODE,
1001+ obmc: cdf::OBMC,
991 comp_group_idx: cdf::COMP_GROUP_IDX,1002 comp_group_idx: cdf::COMP_GROUP_IDX,
992 compound_idx: cdf::COMPOUND_IDX,1003 compound_idx: cdf::COMPOUND_IDX,
993 y_mode: cdf::Y_MODE,1004 y_mode: cdf::Y_MODE,
crates/ec-av1/src/decode.rsmodified+18 -0
@@ -4306,6 +4306,10 @@ fn decode_inter_block(
4306 // `compound_idx` read (libaom `decodemv.c` 1604-1619, 1382-1384, 1509).4306 // `compound_idx` read (libaom `decodemv.c` 1604-1619, 1382-1384, 1509).
4307 skip_mode_present: bool,4307 skip_mode_present: bool,
4308 skip_mode_frame: [u8; 2],4308 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,
4309 ) -> Result<()> {4313 ) -> Result<()> {
4310 let (r, c) = at;4314 let (r, c) = at;
4311 let (px, py) = (c * SUB, r * SUB);4315 let (px, py) = (c * SUB, r * SUB);
@@ -6207,6 +6211,8 @@ pub fn decode_inter_frame_tile(
6207 false,6211 false,
6208 [0; 2],6212 [0; 2],
6209 true,6213 true,
6214+ false,
6215+ false,
6210 )6216 )
6211 .map(|(picture, _, _)| picture)6217 .map(|(picture, _, _)| picture)
6212 }6218 }
@@ -6257,6 +6263,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
6257 // `Set1` coefficient tables at 16x16/8x8 rather than the reduced6263 // `Set1` coefficient tables at 16x16/8x8 rather than the reduced
6258 // 2-symbol ones -- see [`TxbSet::Luma16InterSet1`]/[`TxbSet::Luma8InterSet1`]).6264 // 2-symbol ones -- see [`TxbSet::Luma16InterSet1`]/[`TxbSet::Luma8InterSet1`]).
6259 reduced_tx_set: bool,6265 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,
6260 ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> {6272 ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> {
6261 let tpl_frame = tpl_field.map(|field| TplFrameArgs {6273 let tpl_frame = tpl_field.map(|field| TplFrameArgs {
6262 field,6274 field,
@@ -6461,6 +6473,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
6461 ref_order_hints,6473 ref_order_hints,
6462 skip_mode_present,6474 skip_mode_present,
6463 skip_mode_frame,6475 skip_mode_frame,
6476+ switchable_motion_mode,
6477+ allow_warped_motion,
6464 )?;6478 )?;
6465 }6479 }
6466 PARTITION_SPLIT => {6480 PARTITION_SPLIT => {
@@ -6531,6 +6545,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
6531 ref_order_hints,6545 ref_order_hints,
6532 skip_mode_present,6546 skip_mode_present,
6533 skip_mode_frame,6547 skip_mode_frame,
6548+ switchable_motion_mode,
6549+ allow_warped_motion,
6534 )?;6550 )?;
6535 } else {6551 } else {
6536 let ctx16 = neighbours.partition_ctx(at16, SUB);6552 let ctx16 = neighbours.partition_ctx(at16, SUB);
@@ -7373,6 +7389,8 @@ mod tests {
7373 [0; 7],7389 [0; 7],
7374 false,7390 false,
7375 [0; 2],7391 [0; 2],
7392+ false,
7393+ false,
7376 )7394 )
7377 .unwrap();7395 .unwrap();
7378 7396
crates/ec-av1/src/stream.rsmodified+2 -0
@@ -379,6 +379,8 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
379 header.skip_mode_present,379 header.skip_mode_present,
380 header.skip_mode_frame,380 header.skip_mode_frame,
381 header.reduced_tx_set,381 header.reduced_tx_set,
382+ header.is_motion_mode_switchable,
383+ header.allow_warped_motion,
382 )?384 )?
383 };385 };
384 // Spec 7.20: `disable_frame_end_update_cdf` stores the frame's386 // Spec 7.20: `disable_frame_end_update_cdf` stores the frame's