forge
Explore
Log in

Don't you dare go Hollow

wip(lane-partab): HORZ_A/VERT_A/VERT_B INTER dispatch arms decode (16x16 squares + 16x32/32x16 strips, PARTAB_HITS atomic); gate report prints partab_hits

Browse files at this commit

b39163462bbeed9cd382d181327745c1deff1ba2Ahmet Kaan GümüşParent: 35de25f
crates/ec-av1/src/decode.rsmodified+470 -0
@@ -44,7 +44,10 @@ const PARTITION_NONE: usize = 0;
44 const PARTITION_HORZ: usize = 1;44 const PARTITION_HORZ: usize = 1;
45 const PARTITION_VERT: usize = 2;45 const PARTITION_VERT: usize = 2;
46 const PARTITION_SPLIT: usize = 3;46 const PARTITION_SPLIT: usize = 3;
47+const PARTITION_HORZ_A: usize = 4;
47 const PARTITION_HORZ_B: usize = 5;48 const PARTITION_HORZ_B: usize = 5;
49+const PARTITION_VERT_A: usize = 6;
50+const PARTITION_VERT_B: usize = 7;
48 const SB_MI: u32 = 16;51 const SB_MI: u32 = 16;
49 const BLOCK_MI: u32 = 8;52 const BLOCK_MI: u32 = 8;
50 53
@@ -258,6 +261,18 @@ pub(crate) fn rect_partition_hits() -> usize {
258 RECT_PARTITION_HITS.load(std::sync::atomic::Ordering::Relaxed)261 RECT_PARTITION_HITS.load(std::sync::atomic::Ordering::Relaxed)
259 }262 }
260 263
264+/// lane-partab r1: how many 32x32 quadrants decoded an AB partition
265+/// (PARTITION_HORZ_A / VERT_A / VERT_B -- two 16x16 squares plus one
266+/// 16x32/32x16 strip). Like [`RECT_PARTITION_HITS`], this is the
267+/// free-partition gate's proof this round's arms actually fired.
268+static PARTAB_HITS: std::sync::atomic::AtomicUsize =
269+ std::sync::atomic::AtomicUsize::new(0);
270+
271+/// Current value of [`PARTAB_HITS`].
272+pub(crate) fn partab_hits() -> usize {
273+ PARTAB_HITS.load(std::sync::atomic::Ordering::Relaxed)
274+}
275+
261 /// How many [`read_inter_compound_mode`] reads actually happened276 /// How many [`read_inter_compound_mode`] reads actually happened
262 /// (lane-av1comp) -- proves a `COMPOUND_REFERENCE` block reached its own277 /// (lane-av1comp) -- proves a `COMPOUND_REFERENCE` block reached its own
263 /// `compound_mode` symbol (past `comp_mode`/`comp_ref` and the compound278 /// `compound_mode` symbol (past `comp_mode`/`comp_ref` and the compound
@@ -8613,6 +8628,461 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
8613 BLOCK,8628 BLOCK,
8614 )?;8629 )?;
8615 }8630 }
8631+ PARTITION_HORZ_A => {
8632+ // lane-partab r1: two 16x16 squares on top + a true
8633+ // 32x16 strip below (libaom decode_partition
8634+ // PARTITION_HORZ_A: TL, TR, bottom strip).
8635+ PARTAB_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
8636+ decode_inter_block(
8637+ &mut dec,
8638+ &mut cdfs,
8639+ &mut neighbours,
8640+ &mut grid,
8641+ at,
8642+ SUB,
8643+ mi_cols,
8644+ mi_rows,
8645+ &mut y,
8646+ &mut u,
8647+ &mut v,
8648+ &ref_y,
8649+ &ref_u,
8650+ &ref_v,
8651+ &ref_slots,
8652+ &sign_bias_table,
8653+ base_q_idx,
8654+ TxbSet::Luma16,
8655+ if reduced_tx_set {
8656+ TxbSet::Luma16Inter
8657+ } else {
8658+ TxbSet::Luma16InterSet1
8659+ },
8660+ TxbSet::Chroma8,
8661+ TX16,
8662+ TX8,
8663+ &scan16,
8664+ &scan8,
8665+ 2,
8666+ allow_high_precision_mv,
8667+ force_integer_mv,
8668+ interp_fixed,
8669+ enable_dual_filter,
8670+ tpl_frame.as_ref(),
8671+ reference_select,
8672+ enable_masked_compound,
8673+ enable_interintra_compound,
8674+ enable_jnt_comp,
8675+ order_hint_bits,
8676+ order_hint,
8677+ ref_order_hints,
8678+ skip_mode_present,
8679+ skip_mode_frame,
8680+ switchable_motion_mode,
8681+ allow_warped_motion,
8682+ false,
8683+ SUB,
8684+ SUB,
8685+ )?;
8686+ decode_inter_block(
8687+ &mut dec,
8688+ &mut cdfs,
8689+ &mut neighbours,
8690+ &mut grid,
8691+ (r32 as usize * 2, c32 as usize * 2 + 1),
8692+ SUB,
8693+ mi_cols,
8694+ mi_rows,
8695+ &mut y,
8696+ &mut u,
8697+ &mut v,
8698+ &ref_y,
8699+ &ref_u,
8700+ &ref_v,
8701+ &ref_slots,
8702+ &sign_bias_table,
8703+ base_q_idx,
8704+ TxbSet::Luma16,
8705+ if reduced_tx_set {
8706+ TxbSet::Luma16Inter
8707+ } else {
8708+ TxbSet::Luma16InterSet1
8709+ },
8710+ TxbSet::Chroma8,
8711+ TX16,
8712+ TX8,
8713+ &scan16,
8714+ &scan8,
8715+ 2,
8716+ allow_high_precision_mv,
8717+ force_integer_mv,
8718+ interp_fixed,
8719+ enable_dual_filter,
8720+ tpl_frame.as_ref(),
8721+ reference_select,
8722+ enable_masked_compound,
8723+ enable_interintra_compound,
8724+ enable_jnt_comp,
8725+ order_hint_bits,
8726+ order_hint,
8727+ ref_order_hints,
8728+ skip_mode_present,
8729+ skip_mode_frame,
8730+ switchable_motion_mode,
8731+ allow_warped_motion,
8732+ false,
8733+ SUB,
8734+ SUB,
8735+ )?;
8736+ decode_inter_block(
8737+ &mut dec,
8738+ &mut cdfs,
8739+ &mut neighbours,
8740+ &mut grid,
8741+ (r32 as usize * 2 + 1, c32 as usize * 2),
8742+ BLOCK,
8743+ mi_cols,
8744+ mi_rows,
8745+ &mut y,
8746+ &mut u,
8747+ &mut v,
8748+ &ref_y,
8749+ &ref_u,
8750+ &ref_v,
8751+ &ref_slots,
8752+ &sign_bias_table,
8753+ base_q_idx,
8754+ TxbSet::Luma32,
8755+ TxbSet::Luma32Inter,
8756+ TxbSet::Chroma16,
8757+ TX32,
8758+ TX16,
8759+ &scan32,
8760+ &scan16,
8761+ 3,
8762+ allow_high_precision_mv,
8763+ force_integer_mv,
8764+ interp_fixed,
8765+ enable_dual_filter,
8766+ tpl_frame.as_ref(),
8767+ reference_select,
8768+ enable_masked_compound,
8769+ enable_interintra_compound,
8770+ enable_jnt_comp,
8771+ order_hint_bits,
8772+ order_hint,
8773+ ref_order_hints,
8774+ skip_mode_present,
8775+ skip_mode_frame,
8776+ switchable_motion_mode,
8777+ allow_warped_motion,
8778+ true,
8779+ BLOCK,
8780+ SUB,
8781+ )?;
8782+ }
8783+ PARTITION_VERT_A => {
8784+ // lane-partab r1: mirror of PARTITION_HORZ_A with
8785+ // width/height swapped (TL, BL, right 16x32 strip).
8786+ PARTAB_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
8787+ decode_inter_block(
8788+ &mut dec,
8789+ &mut cdfs,
8790+ &mut neighbours,
8791+ &mut grid,
8792+ at,
8793+ SUB,
8794+ mi_cols,
8795+ mi_rows,
8796+ &mut y,
8797+ &mut u,
8798+ &mut v,
8799+ &ref_y,
8800+ &ref_u,
8801+ &ref_v,
8802+ &ref_slots,
8803+ &sign_bias_table,
8804+ base_q_idx,
8805+ TxbSet::Luma16,
8806+ if reduced_tx_set {
8807+ TxbSet::Luma16Inter
8808+ } else {
8809+ TxbSet::Luma16InterSet1
8810+ },
8811+ TxbSet::Chroma8,
8812+ TX16,
8813+ TX8,
8814+ &scan16,
8815+ &scan8,
8816+ 2,
8817+ allow_high_precision_mv,
8818+ force_integer_mv,
8819+ interp_fixed,
8820+ enable_dual_filter,
8821+ tpl_frame.as_ref(),
8822+ reference_select,
8823+ enable_masked_compound,
8824+ enable_interintra_compound,
8825+ enable_jnt_comp,
8826+ order_hint_bits,
8827+ order_hint,
8828+ ref_order_hints,
8829+ skip_mode_present,
8830+ skip_mode_frame,
8831+ switchable_motion_mode,
8832+ allow_warped_motion,
8833+ false,
8834+ SUB,
8835+ SUB,
8836+ )?;
8837+ decode_inter_block(
8838+ &mut dec,
8839+ &mut cdfs,
8840+ &mut neighbours,
8841+ &mut grid,
8842+ (r32 as usize * 2 + 1, c32 as usize * 2),
8843+ SUB,
8844+ mi_cols,
8845+ mi_rows,
8846+ &mut y,
8847+ &mut u,
8848+ &mut v,
8849+ &ref_y,
8850+ &ref_u,
8851+ &ref_v,
8852+ &ref_slots,
8853+ &sign_bias_table,
8854+ base_q_idx,
8855+ TxbSet::Luma16,
8856+ if reduced_tx_set {
8857+ TxbSet::Luma16Inter
8858+ } else {
8859+ TxbSet::Luma16InterSet1
8860+ },
8861+ TxbSet::Chroma8,
8862+ TX16,
8863+ TX8,
8864+ &scan16,
8865+ &scan8,
8866+ 2,
8867+ allow_high_precision_mv,
8868+ force_integer_mv,
8869+ interp_fixed,
8870+ enable_dual_filter,
8871+ tpl_frame.as_ref(),
8872+ reference_select,
8873+ enable_masked_compound,
8874+ enable_interintra_compound,
8875+ enable_jnt_comp,
8876+ order_hint_bits,
8877+ order_hint,
8878+ ref_order_hints,
8879+ skip_mode_present,
8880+ skip_mode_frame,
8881+ switchable_motion_mode,
8882+ allow_warped_motion,
8883+ false,
8884+ SUB,
8885+ SUB,
8886+ )?;
8887+ decode_inter_block(
8888+ &mut dec,
8889+ &mut cdfs,
8890+ &mut neighbours,
8891+ &mut grid,
8892+ (r32 as usize * 2, c32 as usize * 2 + 1),
8893+ BLOCK,
8894+ mi_cols,
8895+ mi_rows,
8896+ &mut y,
8897+ &mut u,
8898+ &mut v,
8899+ &ref_y,
8900+ &ref_u,
8901+ &ref_v,
8902+ &ref_slots,
8903+ &sign_bias_table,
8904+ base_q_idx,
8905+ TxbSet::Luma32,
8906+ TxbSet::Luma32Inter,
8907+ TxbSet::Chroma16,
8908+ TX32,
8909+ TX16,
8910+ &scan32,
8911+ &scan16,
8912+ 3,
8913+ allow_high_precision_mv,
8914+ force_integer_mv,
8915+ interp_fixed,
8916+ enable_dual_filter,
8917+ tpl_frame.as_ref(),
8918+ reference_select,
8919+ enable_masked_compound,
8920+ enable_interintra_compound,
8921+ enable_jnt_comp,
8922+ order_hint_bits,
8923+ order_hint,
8924+ ref_order_hints,
8925+ skip_mode_present,
8926+ skip_mode_frame,
8927+ switchable_motion_mode,
8928+ allow_warped_motion,
8929+ true,
8930+ SUB,
8931+ BLOCK,
8932+ )?;
8933+ }
8934+ PARTITION_VERT_B => {
8935+ // lane-partab r1: true 16x32 strip on the left + two
8936+ // 16x16 squares on the right (libaom decode_partition
8937+ // PARTITION_VERT_B: left strip, TR, BR).
8938+ PARTAB_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
8939+ decode_inter_block(
8940+ &mut dec,
8941+ &mut cdfs,
8942+ &mut neighbours,
8943+ &mut grid,
8944+ at,
8945+ BLOCK,
8946+ mi_cols,
8947+ mi_rows,
8948+ &mut y,
8949+ &mut u,
8950+ &mut v,
8951+ &ref_y,
8952+ &ref_u,
8953+ &ref_v,
8954+ &ref_slots,
8955+ &sign_bias_table,
8956+ base_q_idx,
8957+ TxbSet::Luma32,
8958+ TxbSet::Luma32Inter,
8959+ TxbSet::Chroma16,
8960+ TX32,
8961+ TX16,
8962+ &scan32,
8963+ &scan16,
8964+ 3,
8965+ allow_high_precision_mv,
8966+ force_integer_mv,
8967+ interp_fixed,
8968+ enable_dual_filter,
8969+ tpl_frame.as_ref(),
8970+ reference_select,
8971+ enable_masked_compound,
8972+ enable_interintra_compound,
8973+ enable_jnt_comp,
8974+ order_hint_bits,
8975+ order_hint,
8976+ ref_order_hints,
8977+ skip_mode_present,
8978+ skip_mode_frame,
8979+ switchable_motion_mode,
8980+ allow_warped_motion,
8981+ true,
8982+ SUB,
8983+ BLOCK,
8984+ )?;
8985+ decode_inter_block(
8986+ &mut dec,
8987+ &mut cdfs,
8988+ &mut neighbours,
8989+ &mut grid,
8990+ (r32 as usize * 2, c32 as usize * 2 + 1),
8991+ SUB,
8992+ mi_cols,
8993+ mi_rows,
8994+ &mut y,
8995+ &mut u,
8996+ &mut v,
8997+ &ref_y,
8998+ &ref_u,
8999+ &ref_v,
9000+ &ref_slots,
9001+ &sign_bias_table,
9002+ base_q_idx,
9003+ TxbSet::Luma16,
9004+ if reduced_tx_set {
9005+ TxbSet::Luma16Inter
9006+ } else {
9007+ TxbSet::Luma16InterSet1
9008+ },
9009+ TxbSet::Chroma8,
9010+ TX16,
9011+ TX8,
9012+ &scan16,
9013+ &scan8,
9014+ 2,
9015+ allow_high_precision_mv,
9016+ force_integer_mv,
9017+ interp_fixed,
9018+ enable_dual_filter,
9019+ tpl_frame.as_ref(),
9020+ reference_select,
9021+ enable_masked_compound,
9022+ enable_interintra_compound,
9023+ enable_jnt_comp,
9024+ order_hint_bits,
9025+ order_hint,
9026+ ref_order_hints,
9027+ skip_mode_present,
9028+ skip_mode_frame,
9029+ switchable_motion_mode,
9030+ allow_warped_motion,
9031+ false,
9032+ SUB,
9033+ SUB,
9034+ )?;
9035+ decode_inter_block(
9036+ &mut dec,
9037+ &mut cdfs,
9038+ &mut neighbours,
9039+ &mut grid,
9040+ (r32 as usize * 2 + 1, c32 as usize * 2 + 1),
9041+ SUB,
9042+ mi_cols,
9043+ mi_rows,
9044+ &mut y,
9045+ &mut u,
9046+ &mut v,
9047+ &ref_y,
9048+ &ref_u,
9049+ &ref_v,
9050+ &ref_slots,
9051+ &sign_bias_table,
9052+ base_q_idx,
9053+ TxbSet::Luma16,
9054+ if reduced_tx_set {
9055+ TxbSet::Luma16Inter
9056+ } else {
9057+ TxbSet::Luma16InterSet1
9058+ },
9059+ TxbSet::Chroma8,
9060+ TX16,
9061+ TX8,
9062+ &scan16,
9063+ &scan8,
9064+ 2,
9065+ allow_high_precision_mv,
9066+ force_integer_mv,
9067+ interp_fixed,
9068+ enable_dual_filter,
9069+ tpl_frame.as_ref(),
9070+ reference_select,
9071+ enable_masked_compound,
9072+ enable_interintra_compound,
9073+ enable_jnt_comp,
9074+ order_hint_bits,
9075+ order_hint,
9076+ ref_order_hints,
9077+ skip_mode_present,
9078+ skip_mode_frame,
9079+ switchable_motion_mode,
9080+ allow_warped_motion,
9081+ false,
9082+ SUB,
9083+ SUB,
9084+ )?;
9085+ }
8616 _ => {9086 _ => {
8617 return Err(unsupported(format!(9087 return Err(unsupported(format!(
8618 "a partition type this encoder never writes (value={part32})"9088 "a partition type this encoder never writes (value={part32})"
crates/ec-av1/src/stream.rsmodified+3 -2
@@ -3841,9 +3841,10 @@ mod tests {
3841 );3841 );
3842 }3842 }
3843 eprintln!(3843 eprintln!(
3844- "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, rect_partition_hits={} extended_partition_hits={}",3844+ "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, rect_partition_hits={} extended_partition_hits={} partab_hits={}",
3845 crate::decode::rect_partition_hits(),3845 crate::decode::rect_partition_hits(),
3846- crate::decode::extended_partition_hits()3846+ crate::decode::extended_partition_hits(),
3847+ crate::decode::partab_hits()
3847 );3848 );
3848 }3849 }
3849 3850
lanes/partab-r1.charter.mdadded+62 -0
@@ -0,0 +1,62 @@
1+# lane-partab r1 charter — AB partition arms (HORZ_A / VERT_A / VERT_B) decode
2+
3+## Where you are
4+Worktree /home/user/Documents/Code/Rust/edith_codecs-partab, branch lane-partab @ 6f4ca37.
5+Build/test ONLY: `env CARGO_TARGET_DIR=$HOME/.cache/cargo-target-partab cargo test -p ec-av1 --release --lib <name> -- --nocapture`
6+FOREGROUND, `nice -n 19`, `CARGO_BUILD_JOBS=4`. Never push; never touch other worktrees; fixtures/ is a symlink.
7+BUDGET: ~60 calls. Commit compiling WIP + report by call 45. Read ONLY what is named.
8+
9+## Facts you build on (verified this batch, do not re-derive)
10+- HORZ/VERT/HORZ_B already decode for real: 32x16/16x32 strips thread true
11+ write_w/write_h through mvstack (MiInfo.size_h), warp samples, OBMC, deblock
12+ tx_h_grid, and the motion_mode/obmc CDF rect rows (cdf.rs rows 4=BLOCK_16X32,
13+ 5=BLOCK_32X16). All sub-block sizes an AB partition produces (16x16, 32x16,
14+ 16x32) ALREADY decode.
15+- The INTER dispatch is decode.rs ~8013 `match part32 {` with arms
16+ NONE/HORZ/VERT/SPLIT/HORZ_B; the catch-all `_ =>` at ~8616 refuses
17+ HORZ_A(4)/VERT_A(6)/VERT_B(7)/HORZ_4(8)/VERT_4(9).
18+- Spec sub-block layout at a 32x32 area, mi origin (r,c) in 4x4 units of 8
19+ (i.e. `at = (r32*2, c32*2)` is 16px units — CHECK the existing arms' `at`
20+ arithmetic and copy it; lane-warp r5 once lost a round to `at` being 16px
21+ units, decode.rs:4858-9 comment):
22+ - HORZ_A: 16x16 at (r,c) + 16x16 at (r,c+16px) + 32x16 strip at (r+16px,c)
23+ - VERT_A: 16x16 at (r,c) + 16x16 at (r+16px,c) + 16x32 strip at (r,c+16px)
24+ - VERT_B: 16x32 strip at (r,c) + 16x16 at (r,c+16px) + 16x16 at (r+16px,c+16px)
25+ (verify each against /tmp/libaom-src/av1/common/enums.h + decodeframe.c
26+ decode_partition's PARTITION_HORZ_A/VERT_A/VERT_B cases — the A/B naming is
27+ easy to mirror-swap; libaom is the oracle.)
28+- decode_inter_block's trailing 3 args are (is_rect_strip: bool, write_w, write_h)
29+ in mi-of-16px units (SUB=16px class, BLOCK=32px class) — copy how the HORZ and
30+ VERT arms pass them for the strip + how SPLIT passes for 16x16 leaves.
31+- Partition CDF/ctx for the arms is already read correctly (VERT_ALIKE/
32+ HORZ_ALIKE gathers include values 4..9); ONLY the dispatch refuses.
33+
34+## Scope
35+1. decode.rs ~8013 match: add PARTITION_HORZ_A / PARTITION_VERT_A /
36+ PARTITION_VERT_B arms composing the SAME decode_inter_block calls the
37+ HORZ/VERT/SPLIT/HORZ_B arms already make (order = spec decode order).
38+ Declare consts PARTITION_HORZ_A=4, PARTITION_VERT_A=6, PARTITION_VERT_B=7
39+ next to PARTITION_HORZ_B. Mind per-arm neighbour/ctx recording: copy
40+ exactly what the existing arms do after each sub-block (record_* calls).
41+2. HORZ_4/VERT_4 and the INTRA-frame dispatch (~3624) stay refusing — do not
42+ touch them.
43+3. Gate ladder, in order:
44+ a. full 15-pin default list green (pins contain HORZ_B streams — regression
45+ canary): cargo test -p ec-av1 --release --lib pinned_warp -- --nocapture
46+ b. free-partition gate a_real_aomenc_stream_with_free_partitions_decodes_
47+ pixel_exact 6x with EC_AV1_GATE_DUMP self-pin
48+ (/tmp/claude-1000/partab-flake-N.obu). A mismatch = pin it, report the
49+ recon-diff location (EC_AV1_PREFILT_DUMP both sides), do NOT guess-fix.
50+ c. full lib suite.
51+4. If aomenc's free recipe never emits an AB partition (grep your decode for
52+ the arm actually firing — add a PARTAB_HITS atomic like WEDGE_HITS), find a
53+ recipe that does (aomenc --enable-ab-partitions=1 is default-on; try
54+ structured content / lower cq) and add a dedicated gate test that forbids
55+ the AB refusal string, soft-skipping on zero-hit runs like the maskcomp
56+ gate. Verified-but-unfired is reportable; unverified is not landable.
57+
58+## Done criteria
59+1. AB arms decode; hits proven fired at least once (atomic count in report);
60+ pins green; free gate 6/6; lib green.
61+2. Committed to lane-partab (wip commit after EVERY green milestone); REPORT
62+ lanes/partab-r1.report.md, verdict FIRST line, evidence per claim.