forge
Explore
Log in

Don't you dare go Hollow

wip(av1): r6 -- sweep clean, class sweep clean, CURRENT_OP scaffolding removed

Browse files at this commit

a3b0b8a9aa87fb39b8bc94105c3ce2e4963f1c5dAhmet Kaan GümüşParent: 2b9615f
Sweep: both wide gates (reference_select, compound_references) 10/10
green, all pixel-exact, no defect found. Old pins re-verified: av1blend-
r1-mismatch.obu 24/24 MATCH (already closed by r6/r7's ref_ctx fix, not
a new result); cdfflake-stream-seed45.bin still mismatches at frame 2
(359/4096 luma, worst delta 6) -- unrelated cdf-forwarding defect, NOT
closed by the mvstack fix.

Charter's "comp_group_idx==0 refusal" premise did not match HEAD
8f08e06: only a comp_group_idx==1 (wedge/diffwtd) refusal exists, which
is a genuinely-unsupported blend type the charter itself says must stay
masked. No comp_group_idx==0/compound_idx refusal exists anywhere in
decode.rs -- that path is already live and unmasked, and the sweep
confirms it is currently defect-free. Nothing to unmask.

Class sweep (neighbour votes all its fields): every remaining site
(single_ref/comp_ref/comp_bwdref/uni_comp_ref ctx family,
reference_mode_ctx, comp_reference_type_ctx, get_comp_group_idx_context,
get_comp_index_context, switchable_interp_ctx, the either-ref filter_ctx
checks) already threads both compound slots correctly -- verified
against mvstack.rs/decode.rs source, no new bug found.

Cleanup (partial, budget-bound): removed msac.rs's EC_RNG trace block
and the CURRENT_OP thread_local plus all 102 call sites in decode.rs
that set it. tile.rs's separate, older EC_RNG trace (lane-av1truesize,
still load-bearing for the encoder side) is untouched -- out of this
lane's scope. Still owed: EC_AV1_SREF_DUMP/EC_AV1_COMPIDX_DUMP/
EC_AV1_COMPOUND_DEBUG/BITPOS_BLK_START blocks, r17_dump/
R17_DUMP_FRAME_IDX (EC_AV1_PREFILT/POSTFILT_DUMP), and scratch_* #[ignore]
tests beyond the two pin-repro tools -- next round.

cargo test -p ec-av1 --lib: 214 passed/0 failed/19 ignored (individual
runs); one flaked FAILED in a full-suite run reproduced green in
isolation -- pre-existing aomenc-RD-nondeterminism flake class, not a
regression from this change.
crates/ec-av1/src/decode.rsmodified+0 -102
@@ -521,7 +521,6 @@ fn read_eob(dec: &mut SymbolDecoder, coding: &mut TxbTables, class: TxClass) ->
521521 (TxClass::TwoD, _) | (_, None) => coding.eob_pt,
522522 (_, Some(class1)) => class1,
523523 };
524- crate::msac::CURRENT_OP.with(|c| c.set("L524"));
525524 let group = dec.symbol(eob_pt) + 1;
526525 if trace {
527526 eprintln!("TRACE eob_pt value={group}");
@@ -529,7 +528,6 @@ fn read_eob(dec: &mut SymbolDecoder, coding: &mut TxbTables, class: TxClass) ->
529528 let bits = OFFSET_BITS[group];
530529 let mut offset = 0u32;
531530 if bits > 0 {
532- crate::msac::CURRENT_OP.with(|c| c.set("L531"));
533531 let top = dec.symbol(&mut coding.eob_extra[group - 3]) as u32;
534532 if trace {
535533 eprintln!("TRACE eob_extra ctx={} value={top}", group - 3);
@@ -592,7 +590,6 @@ fn read_coeffs(
592590 let trace = std::env::var_os("EC_AV1_TRACE").is_some();
593591 let side = coding.side;
594592 let mut grid = vec![0i32; side * side];
595- crate::msac::CURRENT_OP.with(|c| c.set("L593"));
596593 let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1;
597594 if trace {
598595 eprintln!("TRACE all_zero ctx={skip_ctx} value={}", all_zero as i32);
@@ -606,7 +603,6 @@ fn read_coeffs(
606603 // `TX_SET_INTRA_1`, 5 (6 slots) the reduced `TX_SET_INTRA_2` (the
607604 // inter sets we read share set 2's symbol order).
608605 let set1 = tx_type_cdf.len() == 8;
609- crate::msac::CURRENT_OP.with(|c| c.set("L606"));
610606 let t = dec.symbol(tx_type_cdf);
611607 if trace {
612608 eprintln!("TRACE tx_type value={t} set1={set1}");
@@ -640,7 +636,6 @@ fn read_coeffs(
640636 let (row, col) = (pos / side, pos % side);
641637 let level = if scan_idx == eob - 1 {
642638 let ctx = eob_coeff_ctx(scan_idx, side * side);
643- crate::msac::CURRENT_OP.with(|c| c.set("L639"));
644639 let v = dec.symbol(&mut coding.base_eob[ctx]) as i32 + 1;
645640 if trace {
646641 eprintln!(
@@ -650,7 +645,6 @@ fn read_coeffs(
650645 v
651646 } else {
652647 let ctx = base_ctx(&levels, side, row, col, class);
653- crate::msac::CURRENT_OP.with(|c| c.set("L648"));
654648 let v = dec.symbol(&mut coding.base[ctx]) as i32;
655649 if trace {
656650 eprintln!(
@@ -664,7 +658,6 @@ fn read_coeffs(
664658 let mut level = level;
665659 let mut sent = 0;
666660 loop {
667- crate::msac::CURRENT_OP.with(|c| c.set("L661"));
668661 let k = dec.symbol(&mut coding.br[ctx]) as i32;
669662 if trace {
670663 eprintln!(
@@ -690,7 +683,6 @@ fn read_coeffs(
690683 continue;
691684 }
692685 let negative = if pos == 0 {
693- crate::msac::CURRENT_OP.with(|c| c.set("L686"));
694686 let v = dec.symbol(&mut coding.dc_sign[sign_ctx]) == 1;
695687 if trace {
696688 eprintln!("TRACE dc_sign ctx={sign_ctx} value={}", v as i32);
@@ -1265,7 +1257,6 @@ fn filter_intra_size_class(side: usize) -> Option<usize> {
12651257 /// delta [`crate::intra::predict`] wants; bumps [`ANGLE_DELTA_HITS`] whenever
12661258 /// it lands away from zero, for gate tests to prove a real stream fired one.
12671259 fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 {
1268- crate::msac::CURRENT_OP.with(|c| c.set("L1260"));
12691260 let symbol = dec.symbol(cdf);
12701261 if symbol != ANGLE_DELTA_ZERO {
12711262 ANGLE_DELTA_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
@@ -1291,14 +1282,12 @@ fn read_intra_mode(
12911282 Option<usize>,
12921283 )> {
12931284 let trace = std::env::var_os("EC_AV1_TRACE").is_some();
1294- crate::msac::CURRENT_OP.with(|c| c.set("L1285"));
12951285 let skip = dec.symbol(&mut cdfs.skip[0]) != 0;
12961286 if trace {
12971287 eprintln!("TRACE skip value={}", skip as i32);
12981288 }
12991289 let above_ctx = INTRA_MODE_CTX[above_mode];
13001290 let left_ctx = INTRA_MODE_CTX[left_mode];
1301- crate::msac::CURRENT_OP.with(|c| c.set("L1291"));
13021291 let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]);
13031292 if trace {
13041293 eprintln!("TRACE y_mode ctx=({above_ctx},{left_ctx}) value={mode}");
@@ -1316,10 +1305,8 @@ fn read_intra_mode(
13161305 0
13171306 };
13181307 let uv_mode = if cfl {
1319- crate::msac::CURRENT_OP.with(|c| c.set("L1308"));
13201308 dec.symbol(&mut cdfs.uv_mode_cfl[mode])
13211309 } else {
1322- crate::msac::CURRENT_OP.with(|c| c.set("L1310"));
13231310 dec.symbol(&mut cdfs.uv_mode_no_cfl[mode])
13241311 };
13251312 if trace {
@@ -1363,7 +1350,6 @@ fn read_intra_mode(
13631350 && enable_filter_intra
13641351 && let Some(class) = filter_intra_size_class(side)
13651352 {
1366- crate::msac::CURRENT_OP.with(|c| c.set("L1353"));
13671353 let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[class]) != 0;
13681354 if trace {
13691355 eprintln!(
@@ -1373,7 +1359,6 @@ fn read_intra_mode(
13731359 }
13741360 if use_filter_intra {
13751361 FILTER_INTRA_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
1376- crate::msac::CURRENT_OP.with(|c| c.set("L1362"));
13771362 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
13781363 if trace {
13791364 eprintln!("TRACE filter_intra_mode value={fi_mode}");
@@ -1404,7 +1389,6 @@ const UV_CFL_PRED: usize = 13;
14041389 /// joint sign the same way. Returns each plane's final signed `alpha_q3`
14051390 /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0.
14061391 fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) {
1407- crate::msac::CURRENT_OP.with(|c| c.set("L1392"));
14081392 let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32;
14091393 let sign_u = ((joint_sign + 1) * 11) >> 5;
14101394 let sign_v = (joint_sign + 1) - 3 * sign_u;
@@ -1412,7 +1396,6 @@ fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) {
14121396 0
14131397 } else {
14141398 let ctx_u = (joint_sign + 1 - 3) as usize;
1415- crate::msac::CURRENT_OP.with(|c| c.set("L1399"));
14161399 let mag = dec.symbol(&mut cdfs.cfl_alpha[ctx_u]) as i32 + 1;
14171400 if sign_u == 2 { mag } else { -mag }
14181401 };
@@ -1420,7 +1403,6 @@ fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) {
14201403 0
14211404 } else {
14221405 let ctx_v = (sign_v * 3 + sign_u - 3) as usize;
1423- crate::msac::CURRENT_OP.with(|c| c.set("L1406"));
14241406 let mag = dec.symbol(&mut cdfs.cfl_alpha[ctx_v]) as i32 + 1;
14251407 if sign_v == 2 { mag } else { -mag }
14261408 };
@@ -2607,19 +2589,15 @@ fn read_tx_size(
26072589 let ctx = tx_size_context(n, at_mi, side);
26082590 let depth = match side {
26092591 8 => {
2610- crate::msac::CURRENT_OP.with(|c| c.set("L2591"));
26112592 dec.symbol(&mut cdfs.tx_size_cat0[ctx])
26122593 }
26132594 16 => {
2614- crate::msac::CURRENT_OP.with(|c| c.set("L2592"));
26152595 dec.symbol(&mut cdfs.tx_size_cat1[ctx])
26162596 }
26172597 32 => {
2618- crate::msac::CURRENT_OP.with(|c| c.set("L2593"));
26192598 dec.symbol(&mut cdfs.tx_size_cat2[ctx])
26202599 }
26212600 64 => {
2622- crate::msac::CURRENT_OP.with(|c| c.set("L2594"));
26232601 dec.symbol(&mut cdfs.tx_size_cat3[ctx])
26242602 }
26252603 _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"),
@@ -3330,7 +3308,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
33303308 // mirroring [`crate::tile::sb_coeff_key_frame_tile`]'s own
33313309 // three-way write exactly.
33323310 let part = if has_cols && has_rows {
3333- crate::msac::CURRENT_OP.with(|c| c.set("L3303"));
33343311 let p = dec.symbol(&mut cdfs.partition_w64[ctx]);
33353312 if std::env::var_os("EC_AV1_TRACE").is_some() {
33363313 eprintln!("TRACE partition_w64 ctx={ctx} value={p}");
@@ -3339,11 +3316,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
33393316 } else {
33403317 match (has_cols, has_rows) {
33413318 (true, false) => {
3342- crate::msac::CURRENT_OP.with(|c| c.set("L3311"));
33433319 dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));
33443320 }
33453321 (false, true) => {
3346- crate::msac::CURRENT_OP.with(|c| c.set("L3314"));
33473322 dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));
33483323 }
33493324 _ => {}
@@ -3390,7 +3365,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
33903365 has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows),
33913366 );
33923367 let part32 = if has_cols32 && has_rows32 {
3393- crate::msac::CURRENT_OP.with(|c| c.set("L3360"));
33943368 let p = dec.symbol(&mut cdfs.partition_w32[ctx32]);
33953369 if std::env::var_os("EC_AV1_TRACE").is_some() {
33963370 eprintln!(
@@ -3403,14 +3377,12 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
34033377 } else {
34043378 match (has_cols32, has_rows32) {
34053379 (true, false) => {
3406- crate::msac::CURRENT_OP.with(|c| c.set("L3372"));
34073380 dec.symbol_fixed(&gather(
34083381 &cdfs.partition_w32[ctx32],
34093382 VERT_ALIKE,
34103383 ));
34113384 }
34123385 (false, true) => {
3413- crate::msac::CURRENT_OP.with(|c| c.set("L3378"));
34143386 dec.symbol_fixed(&gather(
34153387 &cdfs.partition_w32[ctx32],
34163388 HORZ_ALIKE,
@@ -3463,7 +3435,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
34633435 let at16 = (sr, sc);
34643436 let ctx16 = neighbours.partition_ctx(at16, SUB);
34653437 if has_cols16 && has_rows16 {
3466- crate::msac::CURRENT_OP.with(|c| c.set("L3430"));
34673438 let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]);
34683439 if std::env::var_os("EC_AV1_TRACE").is_some() {
34693440 eprintln!(
@@ -3518,7 +3489,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
35183489 (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2);
35193490 let leaf_mi = (mr as usize, mc as usize);
35203491 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
3521- crate::msac::CURRENT_OP.with(|c| c.set("L3485"));
35223492 let part8 =
35233493 dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);
35243494 if std::env::var_os("EC_AV1_TRACE").is_some() {
@@ -3569,13 +3539,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
35693539 ));
35703540 }
35713541 if has_cols16 {
3572- crate::msac::CURRENT_OP.with(|c| c.set("L3534"));
35733542 dec.symbol_fixed(&gather(
35743543 &cdfs.partition_w16[ctx16],
35753544 VERT_ALIKE,
35763545 ));
35773546 } else {
3578- crate::msac::CURRENT_OP.with(|c| c.set("L3539"));
35793547 dec.symbol_fixed(&gather(
35803548 &cdfs.partition_w16[ctx16],
35813549 HORZ_ALIKE,
@@ -3591,7 +3559,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
35913559 for (mr, mc) in leaf_positions {
35923560 let leaf_mi = (mr as usize, mc as usize);
35933561 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
3594- crate::msac::CURRENT_OP.with(|c| c.set("L3554"));
35953562 let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);
35963563 if std::env::var_os("EC_AV1_TRACE").is_some() {
35973564 eprintln!(
@@ -3751,7 +3718,6 @@ fn resolve_interp_filter(
37513718 &cdfs.switchable_interp[ctx0][..3]
37523719 );
37533720 }
3754- crate::msac::CURRENT_OP.with(|c| c.set("L3713"));
37553721 let sym0 = dec.symbol(&mut cdfs.switchable_interp[ctx0]) as u8;
37563722 let sym1 = if enable_dual_filter {
37573723 let ctx1 = switchable_interp_ctx(above[1], left[1], 1, is_compound);
@@ -3761,7 +3727,6 @@ fn resolve_interp_filter(
37613727 &cdfs.switchable_interp[ctx1][..3]
37623728 );
37633729 }
3764- crate::msac::CURRENT_OP.with(|c| c.set("L3722"));
37653730 dec.symbol(&mut cdfs.switchable_interp[ctx1]) as u8
37663731 } else {
37673732 sym0
@@ -3811,21 +3776,16 @@ fn read_mv_component(
38113776 c: &mut MvComponentCdfs,
38123777 allow_high_precision_mv: bool,
38133778 ) -> i32 {
3814- crate::msac::CURRENT_OP.with(|c| c.set("L3771"));
38153779 let sign = dec.symbol(&mut c.sign);
3816- crate::msac::CURRENT_OP.with(|c| c.set("L3772"));
38173780 let class = dec.symbol(&mut c.class);
38183781 let local = if class == 0 {
3819- crate::msac::CURRENT_OP.with(|c| c.set("L3774"));
38203782 let bit = dec.symbol(&mut c.class0_bit);
3821- crate::msac::CURRENT_OP.with(|c| c.set("L3775"));
38223783 let fr = dec.symbol(&mut c.class0_fr[bit]);
38233784 // spec 5.11.32 `mv_class0_hp`: read only when the frame allows
38243785 // high-precision motion vectors, else implicitly 1 (the low bit
38253786 // stays at half-pel precision) -- this crate's own writer always
38263787 // leaves the flag off, but a foreign stream can set it per frame.
38273788 let hp = if allow_high_precision_mv {
3828- crate::msac::CURRENT_OP.with(|c| c.set("L3781"));
38293789 dec.symbol(&mut c.class0_hp)
38303790 } else {
38313791 1
@@ -3834,13 +3794,10 @@ fn read_mv_component(
38343794 } else {
38353795 let mut d = 0;
38363796 for i in 0..class {
3837- crate::msac::CURRENT_OP.with(|c| c.set("L3789"));
38383797 d |= dec.symbol(&mut c.bit[i]) << i;
38393798 }
3840- crate::msac::CURRENT_OP.with(|c| c.set("L3791"));
38413799 let fr = dec.symbol(&mut c.fr);
38423800 let hp = if allow_high_precision_mv {
3843- crate::msac::CURRENT_OP.with(|c| c.set("L3793"));
38443801 dec.symbol(&mut c.hp)
38453802 } else {
38463803 1
@@ -3860,7 +3817,6 @@ fn read_mv(
38603817 pred: (i32, i32),
38613818 allow_high_precision_mv: bool,
38623819 ) -> (i32, i32) {
3863- crate::msac::CURRENT_OP.with(|c| c.set("L3812"));
38643820 let joint = dec.symbol(mv_joint);
38653821 let mut diff = (0, 0);
38663822 if joint == 2 || joint == 3 {
@@ -3964,27 +3920,21 @@ fn read_single_ref(
39643920 ) -> i8 {
39653921 let above = (above_ref > 0).then_some(above_ref);
39663922 let left = (left_ref > 0).then_some(left_ref);
3967- crate::msac::CURRENT_OP.with(|c| c.set("L3915"));
39683923 let p1 = dec.symbol(&mut cdfs.single_ref[single_ref_p1_ctx(above, above_ref1, left, left_ref1)][0]);
39693924 let ref_frame = if p1 == 1 {
3970- crate::msac::CURRENT_OP.with(|c| c.set("L3917"));
39713925 let p2 = dec.symbol(&mut cdfs.single_ref[single_ref_p2_ctx(above, above_ref1, left, left_ref1)][1]);
39723926 if p2 == 1 {
39733927 ALTREF_FRAME
39743928 } else {
3975- crate::msac::CURRENT_OP.with(|c| c.set("L3921"));
39763929 let p6 = dec.symbol(&mut cdfs.single_ref[single_ref_p6_ctx(above, above_ref1, left, left_ref1)][5]);
39773930 if p6 == 1 { ALTREF2_FRAME } else { BWDREF_FRAME }
39783931 }
39793932 } else {
3980- crate::msac::CURRENT_OP.with(|c| c.set("L3925"));
39813933 let p3 = dec.symbol(&mut cdfs.single_ref[single_ref_p3_ctx(above, above_ref1, left, left_ref1)][2]);
39823934 if p3 == 1 {
3983- crate::msac::CURRENT_OP.with(|c| c.set("L3927"));
39843935 let p5 = dec.symbol(&mut cdfs.single_ref[single_ref_p5_ctx(above, above_ref1, left, left_ref1)][4]);
39853936 if p5 == 1 { GOLDEN_FRAME } else { LAST3_FRAME }
39863937 } else {
3987- crate::msac::CURRENT_OP.with(|c| c.set("L3930"));
39883938 let p4 = dec.symbol(&mut cdfs.single_ref[single_ref_p4_ctx(above, above_ref1, left, left_ref1)][3]);
39893939 if p4 == 1 { LAST2_FRAME } else { LAST_FRAME }
39903940 }
@@ -4106,7 +4056,6 @@ fn read_comp_mode(
41064056 left: Option<NeighbourRef>,
41074057 ) -> bool {
41084058 let ctx = reference_mode_ctx(above, left);
4109- crate::msac::CURRENT_OP.with(|c| c.set("L4051"));
41104059 let compound = dec.symbol(&mut cdfs.comp_mode[ctx]) == 1;
41114060 if compound {
41124061 COMP_MODE_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
@@ -4150,21 +4099,17 @@ fn read_compound_ref_frames(
41504099 let a1 = above.and_then(|n| n.ref1);
41514100 let l1 = left.and_then(|n| n.ref1);
41524101 let type_ctx = comp_reference_type_ctx(above, left);
4153- crate::msac::CURRENT_OP.with(|c| c.set("L4094"));
41544102 let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0;
41554103 if unidir {
41564104 // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_-
41574105 // uni_comp_ref_p is single_ref_p1's own forward/backward vote.
4158- crate::msac::CURRENT_OP.with(|c| c.set("L4098"));
41594106 let bit = dec.symbol(&mut cdfs.uni_comp_ref[single_ref_p1_ctx(a, a1, l, l1)][0]);
41604107 if bit == 1 {
41614108 (BWDREF_FRAME, ALTREF_FRAME)
41624109 } else {
4163- crate::msac::CURRENT_OP.with(|c| c.set("L4102"));
41644110 let p1 = dec.symbol(&mut cdfs.uni_comp_ref[uni_comp_ref_p1_ctx(a, a1, l, l1)][1]);
41654111 if p1 == 1 {
41664112 // uni_comp_ref_p2: LAST3 vs. GOLDEN, same vote as single_ref_p5.
4167- crate::msac::CURRENT_OP.with(|c| c.set("L4105"));
41684113 let p2 = dec.symbol(&mut cdfs.uni_comp_ref[single_ref_p5_ctx(a, a1, l, l1)][2]);
41694114 if p2 == 1 {
41704115 (LAST_FRAME, GOLDEN_FRAME)
@@ -4177,25 +4122,20 @@ fn read_compound_ref_frames(
41774122 }
41784123 } else {
41794124 // comp_ref (p0): LAST/LAST2 vs. LAST3/GOLDEN, same vote as single_ref_p3.
4180- crate::msac::CURRENT_OP.with(|c| c.set("L4117"));
41814125 let bit0 = dec.symbol(&mut cdfs.comp_ref[single_ref_p3_ctx(a, a1, l, l1)][0]);
41824126 let ref0 = if bit0 == 0 {
41834127 // comp_ref_p1: LAST vs. LAST2, same vote as single_ref_p4.
4184- crate::msac::CURRENT_OP.with(|c| c.set("L4120"));
41854128 let p1 = dec.symbol(&mut cdfs.comp_ref[single_ref_p4_ctx(a, a1, l, l1)][1]);
41864129 if p1 == 1 { LAST2_FRAME } else { LAST_FRAME }
41874130 } else {
41884131 // comp_ref_p2: LAST3 vs. GOLDEN, same vote as single_ref_p5.
4189- crate::msac::CURRENT_OP.with(|c| c.set("L4124"));
41904132 let p2 = dec.symbol(&mut cdfs.comp_ref[single_ref_p5_ctx(a, a1, l, l1)][2]);
41914133 if p2 == 1 { GOLDEN_FRAME } else { LAST3_FRAME }
41924134 };
41934135 // comp_bwdref (p0): BWDREF/ALTREF2 vs. ALTREF, same vote as single_ref_p2.
4194- crate::msac::CURRENT_OP.with(|c| c.set("L4128"));
41954136 let bit1 = dec.symbol(&mut cdfs.comp_bwdref[single_ref_p2_ctx(a, a1, l, l1)][0]);
41964137 let ref1 = if bit1 == 0 {
41974138 // comp_bwdref_p1: BWDREF vs. ALTREF2, same vote as single_ref_p6.
4198- crate::msac::CURRENT_OP.with(|c| c.set("L4131"));
41994139 let p1 = dec.symbol(&mut cdfs.comp_bwdref[single_ref_p6_ctx(a, a1, l, l1)][1]);
42004140 if p1 == 1 { ALTREF2_FRAME } else { BWDREF_FRAME }
42014141 } else {
@@ -4223,7 +4163,6 @@ fn read_inter_compound_mode(
42234163 ) -> u8 {
42244164 let ctx = cdf::COMPOUND_MODE_CTX_MAP[ref_mv_ctx >> 1][new_mv_ctx.min(4)];
42254165 COMPOUND_MODE_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
4226- crate::msac::CURRENT_OP.with(|c| c.set("L4158"));
42274166 dec.symbol(&mut cdfs.inter_compound_mode[ctx]) as u8
42284167 }
42294168
@@ -4259,7 +4198,6 @@ fn assign_compound_mv(
42594198 if mode == NEW_NEWMV {
42604199 let mut idx = 0usize;
42614200 while idx < 2 && comp_stack.entries.len() > idx + 1 {
4262- crate::msac::CURRENT_OP.with(|c| c.set("L4193"));
42634201 if dec.symbol(&mut cdfs.drl_mode[comp_stack.drl_ctx[idx]]) == 0 {
42644202 break;
42654203 }
@@ -4269,7 +4207,6 @@ fn assign_compound_mv(
42694207 } else if matches!(mode, NEAR_NEARMV | NEAR_NEWMV | NEW_NEARMV) {
42704208 let mut idx = 1usize;
42714209 while idx < 3 && comp_stack.entries.len() > idx + 1 {
4272- crate::msac::CURRENT_OP.with(|c| c.set("L4202"));
42734210 if dec.symbol(&mut cdfs.drl_mode[comp_stack.drl_ctx[idx]]) == 0 {
42744211 break;
42754212 }
@@ -4413,20 +4350,17 @@ fn decode_inter_block(
44134350 }
44144351 let skip_mode_ctx =
44154352 usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]);
4416- crate::msac::CURRENT_OP.with(|c| c.set("L4345"));
44174353 let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
44184354 if skip_mode {
44194355 SKIP_MODE_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
44204356 }
44214357
44224358 let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]);
4423- crate::msac::CURRENT_OP.with(|c| c.set("L4351"));
44244359 let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
44254360
44264361 let (has_above, has_left) = (r > 0, c > 0);
44274362 let (above_inter, left_inter) = (neighbours.above_inter[c], neighbours.left_inter[r]);
44284363 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
4429- crate::msac::CURRENT_OP.with(|c| c.set("L4356"));
44304364 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
44314365
44324366 let mode_for_tx;
@@ -4578,7 +4512,6 @@ fn decode_inter_block(
45784512 && enable_masked_compound
45794513 && is_any_masked_compound_used_here(side)
45804514 {
4581- crate::msac::CURRENT_OP.with(|c| c.set("L4507"));
45824515 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])
45834516 } else {
45844517 0
@@ -4803,7 +4736,6 @@ fn decode_inter_block(
48034736 cdfs.compound_idx[idx_ctx][0]
48044737 );
48054738 }
4806- crate::msac::CURRENT_OP.with(|c| c.set("L4731"));
48074739 let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]);
48084740 if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() {
48094741 eprintln!(
@@ -5112,7 +5044,6 @@ fn decode_inter_block(
51125044 sign_bias_table,
51135045 tpl,
51145046 );
5115- crate::msac::CURRENT_OP.with(|c| c.set("L5039"));
51165047 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
51175048 let mut is_globalmv = false;
51185049 let (mv, is_new_mv) = if !not_new {
@@ -5124,7 +5055,6 @@ fn decode_inter_block(
51245055 // -- entry 0 (`stack.pred_mv`) only when the loop never advances.
51255056 let mut idx = 0usize;
51265057 while idx < 2 && stack.entries.len() > idx + 1 {
5127- crate::msac::CURRENT_OP.with(|c| c.set("L5050"));
51285058 if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
51295059 break;
51305060 }
@@ -5142,7 +5072,6 @@ fn decode_inter_block(
51425072 true,
51435073 )
51445074 } else {
5145- crate::msac::CURRENT_OP.with(|c| c.set("L5067"));
51465075 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
51475076 is_globalmv = !not_zero;
51485077 let mv = if !not_zero {
@@ -5152,7 +5081,6 @@ fn decode_inter_block(
51525081 // model is refused before the tile decoder is ever called).
51535082 (0, 0)
51545083 } else {
5155- crate::msac::CURRENT_OP.with(|c| c.set("L5076"));
51565084 let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;
51575085 if nearest {
51585086 stack.nearest_mv
@@ -5165,7 +5093,6 @@ fn decode_inter_block(
51655093 // exactly the pair this index is choosing between.
51665094 let mut idx = 1usize;
51675095 while idx < 3 && stack.entries.len() > idx + 1 {
5168- crate::msac::CURRENT_OP.with(|c| c.set("L5088"));
51695096 if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
51705097 break;
51715098 }
@@ -5372,7 +5299,6 @@ fn decode_inter_block(
53725299 }
53735300 }
53745301 } else {
5375- crate::msac::CURRENT_OP.with(|c| c.set("L5294"));
53765302 let mode = dec.symbol(&mut cdfs.y_mode[size_group]);
53775303 if mode >= 13 {
53785304 return Err(unsupported(
@@ -5380,7 +5306,6 @@ fn decode_inter_block(
53805306 ));
53815307 }
53825308 if (V_PRED..=D67_PRED).contains(&mode) {
5383- crate::msac::CURRENT_OP.with(|c| c.set("L5301"));
53845309 let angle = dec.symbol(&mut cdfs.angle_delta[mode - V_PRED]);
53855310 if angle != ANGLE_DELTA_ZERO {
53865311 return Err(unsupported(
@@ -5388,7 +5313,6 @@ fn decode_inter_block(
53885313 ));
53895314 }
53905315 }
5391- crate::msac::CURRENT_OP.with(|c| c.set("L5308"));
53925316 let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);
53935317 let alpha = if uv_mode == DC_PRED {
53945318 None
@@ -5634,19 +5558,16 @@ fn decode_inter_block8(
56345558 }
56355559 let skip_mode_ctx =
56365560 usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]);
5637- crate::msac::CURRENT_OP.with(|c| c.set("L5553"));
56385561 let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
56395562 if skip_mode {
56405563 SKIP_MODE_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
56415564 }
56425565
56435566 let skip_ctx = usize::from(above_skip) + usize::from(left_skip);
5644- crate::msac::CURRENT_OP.with(|c| c.set("L5559"));
56455567 let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
56465568
56475569 let (has_above, has_left) = (leaf_mi.0 > 0, leaf_mi.1 > 0);
56485570 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
5649- crate::msac::CURRENT_OP.with(|c| c.set("L5563"));
56505571 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
56515572
56525573 let mode_for_tx;
@@ -5733,7 +5654,6 @@ fn decode_inter_block8(
57335654 && enable_masked_compound
57345655 && is_any_masked_compound_used_here(SIDE)
57355656 {
5736- crate::msac::CURRENT_OP.with(|c| c.set("L5649"));
57375657 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])
57385658 } else {
57395659 0
@@ -5768,7 +5688,6 @@ fn decode_inter_block8(
57685688 ref_order_hints[(ref0 - LAST_FRAME) as usize],
57695689 ref_order_hints[(ref1 - LAST_FRAME) as usize],
57705690 );
5771- crate::msac::CURRENT_OP.with(|c| c.set("L5683"));
57725691 let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]);
57735692 if idx == 1 {
57745693 (8, 8, 1u8)
@@ -5986,11 +5905,8 @@ fn decode_inter_block8(
59865905 }
59875906 }
59885907 let sr_ctx = single_ref_ctx(above_inter || left_inter);
5989- crate::msac::CURRENT_OP.with(|c| c.set("L5900"));
59905908 let p1 = dec.symbol(&mut cdfs.single_ref[sr_ctx][0]);
5991- crate::msac::CURRENT_OP.with(|c| c.set("L5901"));
59925909 let p3 = dec.symbol(&mut cdfs.single_ref[sr_ctx][2]);
5993- crate::msac::CURRENT_OP.with(|c| c.set("L5902"));
59945910 let p4 = dec.symbol(&mut cdfs.single_ref[sr_ctx][3]);
59955911 if (p1, p3, p4) != (0, 0, 0) {
59965912 return Err(unsupported(
@@ -6010,7 +5926,6 @@ fn decode_inter_block8(
60105926 mi_rows as usize,
60115927 );
60125928
6013- crate::msac::CURRENT_OP.with(|c| c.set("L5921"));
60145929 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
60155930 let (mv, is_new_mv) = if !not_new {
60165931 // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0):
@@ -6021,7 +5936,6 @@ fn decode_inter_block8(
60215936 // -- entry 0 (`stack.pred_mv`) only when the loop never advances.
60225937 let mut idx = 0usize;
60235938 while idx < 2 && stack.entries.len() > idx + 1 {
6024- crate::msac::CURRENT_OP.with(|c| c.set("L5931"));
60255939 if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
60265940 break;
60275941 }
@@ -6039,19 +5953,16 @@ fn decode_inter_block8(
60395953 true,
60405954 )
60415955 } else {
6042- crate::msac::CURRENT_OP.with(|c| c.set("L5948"));
60435956 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
60445957 if !not_zero {
60455958 return Err(unsupported("GLOBALMV (round 3)"));
60465959 }
6047- crate::msac::CURRENT_OP.with(|c| c.set("L5952"));
60485960 let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;
60495961 let mv = if nearest {
60505962 stack.nearest_mv
60515963 } else {
60525964 let mut idx = 1usize;
60535965 while idx < 3 && stack.entries.len() > idx + 1 {
6054- crate::msac::CURRENT_OP.with(|c| c.set("L5958"));
60555966 if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
60565967 break;
60575968 }
@@ -6185,7 +6096,6 @@ fn decode_inter_block8(
61856096 )?;
61866097 }
61876098 } else {
6188- crate::msac::CURRENT_OP.with(|c| c.set("L6091"));
61896099 let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]);
61906100 if mode >= 13 {
61916101 return Err(unsupported(
@@ -6193,7 +6103,6 @@ fn decode_inter_block8(
61936103 ));
61946104 }
61956105 if (V_PRED..=D67_PRED).contains(&mode) {
6196- crate::msac::CURRENT_OP.with(|c| c.set("L6098"));
61976106 let angle = dec.symbol(&mut cdfs.angle_delta[mode - V_PRED]);
61986107 if angle != ANGLE_DELTA_ZERO {
61996108 return Err(unsupported(
@@ -6201,7 +6110,6 @@ fn decode_inter_block8(
62016110 ));
62026111 }
62036112 }
6204- crate::msac::CURRENT_OP.with(|c| c.set("L6105"));
62056113 let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);
62066114 if uv_mode != DC_PRED {
62076115 return Err(unsupported(
@@ -6573,15 +6481,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
65736481 );
65746482 match (has_cols, has_rows) {
65756483 (true, true) => {
6576- crate::msac::CURRENT_OP.with(|c| c.set("L6476"));
65776484 dec.symbol(&mut cdfs.partition_w64[sb_ctx]);
65786485 }
65796486 (true, false) => {
6580- crate::msac::CURRENT_OP.with(|c| c.set("L6479"));
65816487 dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE));
65826488 }
65836489 (false, true) => {
6584- crate::msac::CURRENT_OP.with(|c| c.set("L6482"));
65856490 dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE));
65866491 }
65876492 (false, false) => {}
@@ -6599,16 +6504,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
65996504 has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows),
66006505 );
66016506 let part32 = if has_cols32 && has_rows32 {
6602- crate::msac::CURRENT_OP.with(|c| c.set("L6499"));
66036507 dec.symbol(&mut cdfs.partition_w32[ctx32])
66046508 } else {
66056509 match (has_cols32, has_rows32) {
66066510 (true, false) => {
6607- crate::msac::CURRENT_OP.with(|c| c.set("L6503"));
66086511 dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE));
66096512 }
66106513 (false, true) => {
6611- crate::msac::CURRENT_OP.with(|c| c.set("L6506"));
66126514 dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE));
66136515 }
66146516 _ => {}
@@ -6677,7 +6579,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
66776579 let at16 = (sr, sc);
66786580 if has_cols16 && has_rows16 {
66796581 let ctx16 = neighbours.partition_ctx(at16, SUB);
6680- crate::msac::CURRENT_OP.with(|c| c.set("L6574"));
66816582 let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]);
66826583 if part16 != PARTITION_NONE {
66836584 return Err(unsupported(
@@ -6726,13 +6627,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
67266627 } else {
67276628 let ctx16 = neighbours.partition_ctx(at16, SUB);
67286629 if has_cols16 {
6729- crate::msac::CURRENT_OP.with(|c| c.set("L6622"));
67306630 dec.symbol_fixed(&gather(
67316631 &cdfs.partition_w16[ctx16],
67326632 VERT_ALIKE,
67336633 ));
67346634 } else {
6735- crate::msac::CURRENT_OP.with(|c| c.set("L6627"));
67366635 dec.symbol_fixed(&gather(
67376636 &cdfs.partition_w16[ctx16],
67386637 HORZ_ALIKE,
@@ -6749,7 +6648,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
67496648 for (mr, mc) in leaf_positions {
67506649 let leaf_mi = (mr as usize, mc as usize);
67516650 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
6752- crate::msac::CURRENT_OP.with(|c| c.set("L6643"));
67536651 let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);
67546652 if part8 != PARTITION_NONE {
67556653 return Err(unsupported(
crates/ec-av1/src/msac.rsmodified+0 -17
@@ -19,12 +19,6 @@
1919 /// Probability precision dropped before the range multiply (spec `EC_PROB_SHIFT`).
2020 const EC_PROB_SHIFT: u32 = 6;
2121
22-thread_local! {
23- /// Debug-only tag naming the call site of the in-flight `symbol()` read,
24- /// for the `EC_RNG=1` trace (r5 scratch instrumentation). Set immediately
25- /// before each `dec.symbol()`/`symbol_fixed()` call in decode.rs.
26- pub static CURRENT_OP: std::cell::Cell<&'static str> = const { std::cell::Cell::new("?") };
27-}
2822 /// Minimum interval width reserved for every symbol (spec `EC_MIN_PROB`).
2923 const EC_MIN_PROB: u32 = 4;
3024 /// Total probability mass of a CDF (spec `1 << 15`).
@@ -306,7 +300,6 @@ impl<'a> SymbolDecoder<'a> {
306300 /// [`SymbolEncoder::symbol_fixed`].
307301 pub fn symbol_fixed(&mut self, cdf: &[u16]) -> usize {
308302 let nsyms = cdf.len() - 1;
309- let rng_before = self.range;
310303 let mut cur = self.range;
311304 let mut prev;
312305 let mut symbol = 0;
@@ -322,16 +315,6 @@ impl<'a> SymbolDecoder<'a> {
322315 }
323316 self.range = prev - cur;
324317 self.value -= cur;
325- if std::env::var_os("EC_RNG").is_some() {
326- use std::sync::atomic::{AtomicU64, Ordering};
327- static EC_RNG_N: AtomicU64 = AtomicU64::new(0);
328- let n = EC_RNG_N.fetch_add(1, Ordering::Relaxed);
329- let op = CURRENT_OP.with(|c| c.get());
330- eprintln!(
331- "EC_RNG n={n} op={op} rng_before={rng_before} rng_after={} nsyms={nsyms} symbol={symbol}",
332- self.range
333- );
334- }
335318
336319 // Renormalise back into `[2^15, 2^16)`, the same shift the encoder
337320 // applied when it narrowed to this symbol.