forge
Explore
Log in

Don't you dare go Hollow

wip(av1): dkey lane snapshot at the turn cap (orchestrator)

Browse files at this commit

8c864700ca1cb797bbef6732245ccedb331a06c7Ahmet Kaan GümüşParent: edaf368
crates/ec-av1/src/decode.rsmodified+80 -0
@@ -15718,6 +15718,19 @@ fn decode_leaf_split4(
1571815718 neighbours.above[leaf_mi.1 + cell][2] = v_state;
1571915719 }
1572015720 }
15721+ // lane-dkey: a sub-8x8 leaf can never use palette (`av1_allow_palette`
15722+ // needs BLOCK_8X8 and up), and libaom's mi grid says so -- its
15723+ // `palette_size` is 0 in every one of these mi cells, so the NEXT block's
15724+ // `av1_get_palette_mode_ctx` and colour cache read 0 here. This decoder
15725+ // only ever WROTE palette state from the >=8x8 readers, so an 8x8 palette
15726+ // block above a 4x4 group left its size/colours standing in the mi-granular
15727+ // bands: the block below the group read `palette_y_mode` off CDF row 1
15728+ // where libaom reads row 0 (class [[cdf-row-held-constant]]), decoded a
15729+ // palette libaom never coded, and then skipped the `use_filter_intra`
15730+ // symbol that a palette block has none of -- one symbol short, tile
15731+ // desynced. Publishing the group's own zeros is the clear.
15732+ neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
15733+ neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
1572115734 Ok((leaf_modes[2], leaf_modes[1]))
1572215735 }
1572315736
@@ -16078,6 +16091,19 @@ fn decode_leaf_rect8(
1607816091 neighbours.above[leaf_mi.1 + cell][2] = v_state;
1607916092 }
1608016093 }
16094+ // lane-dkey (same clear as `decode_leaf_split4`): a sub-8x8 leaf can never use palette (`av1_allow_palette`
16095+ // needs BLOCK_8X8 and up), and libaom's mi grid says so -- its
16096+ // `palette_size` is 0 in every one of these mi cells, so the NEXT block's
16097+ // `av1_get_palette_mode_ctx` and colour cache read 0 here. This decoder
16098+ // only ever WROTE palette state from the >=8x8 readers, so an 8x8 palette
16099+ // block above a 4x4 group left its size/colours standing in the mi-granular
16100+ // bands: the block below the group read `palette_y_mode` off CDF row 1
16101+ // where libaom reads row 0 (class [[cdf-row-held-constant]]), decoded a
16102+ // palette libaom never coded, and then skipped the `use_filter_intra`
16103+ // symbol that a palette block has none of -- one symbol short, tile
16104+ // desynced. Publishing the group's own zeros is the clear.
16105+ neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
16106+ neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
1608116107 // `(below_mode, right_mode)`: the sub-block a neighbour below sees is the
1608216108 // bottom one (the second under HORZ, the left one under VERT), the one a
1608316109 // neighbour to the right sees is the top-right (the second under VERT).
@@ -29588,6 +29614,15 @@ fn decode_inter_block(
2958829614 write_h / MI,
2958929615 skip,
2959029616 );
29617+ // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has
29618+ // `palette_size == 0` in libaom's mi grid, so the next block's
29619+ // `av1_get_palette_mode_ctx`/colour cache must read 0 across this
29620+ // footprint. Only the >=8x8 intra readers published palette state, so a
29621+ // palette block's size/colours stayed standing in the mi-granular bands
29622+ // and a later intra block read `palette_y_mode` off the wrong CDF row
29623+ // (class [[cdf-row-held-constant]]).
29624+ neighbours.record_palette_y_rect((rmi, cmi), write_w, write_h, 0, [0u16; 8]);
29625+ neighbours.record_palette_uv_rect((rmi, cmi), write_w, write_h, 0, [0u16; 8]);
2959129626 neighbours.fill_lf_grid_rect(
2959229627 (rmi, cmi),
2959329628 write_w / MI,
@@ -30072,6 +30107,15 @@ fn decode_inter_sub8_split4(
3007230107 // var-tx context instead of leaving whatever the previous block left.
3007330108 set_txfm_ctxs(neighbours, lmi, B4, 1, 1, false);
3007430109 neighbours.fill_skip_grid_rect(lmi, 1, 1, skip);
30110+ // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has
30111+ // `palette_size == 0` in libaom's mi grid, so the next block's
30112+ // `av1_get_palette_mode_ctx`/colour cache must read 0 across this
30113+ // footprint. Only the >=8x8 intra readers published palette state, so a
30114+ // palette block's size/colours stayed standing in the mi-granular bands
30115+ // and a later intra block read `palette_y_mode` off the wrong CDF row
30116+ // (class [[cdf-row-held-constant]]).
30117+ neighbours.record_palette_y_rect(lmi, MI, MI, 0, [0u16; 8]);
30118+ neighbours.record_palette_uv_rect(lmi, MI, MI, 0, [0u16; 8]);
3007530119 neighbours.fill_lf_grid_rect(lmi, 1, 1, B4 as u8, B4 as u8, ref_frame.max(LAST_FRAME), fctx);
3007630120 last_skip = skip;
3007730121 }
@@ -30529,6 +30573,15 @@ fn decode_intra_sub8_leaf(
3052930573 }
3053030574 let (tx_w, tx_h) = if split { (4, 4) } else { (bw, bh) };
3053130575 neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip);
30576+ // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has
30577+ // `palette_size == 0` in libaom's mi grid, so the next block's
30578+ // `av1_get_palette_mode_ctx`/colour cache must read 0 across this
30579+ // footprint. Only the >=8x8 intra readers published palette state, so a
30580+ // palette block's size/colours stayed standing in the mi-granular bands
30581+ // and a later intra block read `palette_y_mode` off the wrong CDF row
30582+ // (class [[cdf-row-held-constant]]).
30583+ neighbours.record_palette_y_rect(lmi, w_mi * MI, h_mi * MI, 0, [0u16; 8]);
30584+ neighbours.record_palette_uv_rect(lmi, w_mi * MI, h_mi * MI, 0, [0u16; 8]);
3053230585 neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, tx_w as u8, tx_h as u8, 0, fctx);
3053330586 // `set_txfm_ctxs(tx_size, n4_w, n4_h, skip && is_inter == 0, xd)`: an
3053430587 // intra block of an inter frame publishes its TRANSFORM dims, never its
@@ -31142,6 +31195,15 @@ fn decode_inter_sub8_rect2(
3114231195 neighbours.record_mode_mi(rmi, cmi, w_mi, h_mi, DC_PRED);
3114331196 neighbours.record_inter_rect_mi(lmi, w_mi, h_mi, skip, true, ref_frame, resolved_filter, false);
3114431197 neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip);
31198+ // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has
31199+ // `palette_size == 0` in libaom's mi grid, so the next block's
31200+ // `av1_get_palette_mode_ctx`/colour cache must read 0 across this
31201+ // footprint. Only the >=8x8 intra readers published palette state, so a
31202+ // palette block's size/colours stayed standing in the mi-granular bands
31203+ // and a later intra block read `palette_y_mode` off the wrong CDF row
31204+ // (class [[cdf-row-held-constant]]).
31205+ neighbours.record_palette_y_rect(lmi, w_mi * MI, h_mi * MI, 0, [0u16; 8]);
31206+ neighbours.record_palette_uv_rect(lmi, w_mi * MI, h_mi * MI, 0, [0u16; 8]);
3114531207 last_skip = skip;
3114631208 }
3114731209 // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded
@@ -32244,6 +32306,15 @@ fn decode_inter_block8(
3224432306 // dlist excludes it (3 luma samples on a 192x128 inter frame).
3224532307 hit!(INTER8_SKIP_BAND_HITS);
3224632308 neighbours.fill_skip_grid(leaf_mi, 2, skip);
32309+ // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has
32310+ // `palette_size == 0` in libaom's mi grid, so the next block's
32311+ // `av1_get_palette_mode_ctx`/colour cache must read 0 across this
32312+ // footprint. Only the >=8x8 intra readers published palette state, so a
32313+ // palette block's size/colours stayed standing in the mi-granular bands
32314+ // and a later intra block read `palette_y_mode` off the wrong CDF row
32315+ // (class [[cdf-row-held-constant]]).
32316+ neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
32317+ neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
3224732318 // lane-sub8x4 r2: `split8` is this leaf's OWN var-tx split, so
3224832319 // the deblock grid must publish the TX_4X4 leaves' width the
3224932320 // same way the fall-through arm below does (libaom
@@ -33441,6 +33512,15 @@ fn decode_inter_block8(
3344133512 // gate failed on an instrumentation gap, with the band written either way.
3344233513 hit!(INTER8_SKIP_BAND_HITS);
3344333514 neighbours.fill_skip_grid(leaf_mi, 2, skip);
33515+ // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has
33516+ // `palette_size == 0` in libaom's mi grid, so the next block's
33517+ // `av1_get_palette_mode_ctx`/colour cache must read 0 across this
33518+ // footprint. Only the >=8x8 intra readers published palette state, so a
33519+ // palette block's size/colours stayed standing in the mi-granular bands
33520+ // and a later intra block read `palette_y_mode` off the wrong CDF row
33521+ // (class [[cdf-row-held-constant]]).
33522+ neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
33523+ neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]);
3344433524 neighbours.fill_lf_grid(
3344533525 leaf_mi,
3344633526 2,
crates/ec-av1/src/encode.rsmodified+28 -0
@@ -13302,6 +13302,34 @@ mod tests {
1330213302 );
1330313303 let stream = std::fs::read(&obu).expect("reference stream");
1330413304 let decoded = ffmpeg_decode_sequence(&stream, width, height, source.len());
13305+ // lane-dkey: every reference point must also decode through OUR
13306+ // decoder, sample-exact against ffmpeg's decode of the same bytes.
13307+ // A BD table computed off streams we cannot read is a table about
13308+ // an encoder we cannot check; this is the assertion that would
13309+ // have caught the `force_integer_mv` defect (its stream decoded to
13310+ // 25 dB garbage while this gate stayed green) and the crf-5 key
13311+ // frame desync. A failure names the encoder, the point's flags and
13312+ // the first differing frame/plane/sample.
13313+ match crate::stream::decode_stream(&stream) {
13314+ Ok(ours) => {
13315+ assert_eq!(
13316+ ours.len(),
13317+ decoded.len(),
13318+ "{encoder} {params:?}: our decoder returned {} shown frames, ffmpeg {}",
13319+ ours.len(),
13320+ decoded.len(),
13321+ );
13322+ for (f, (o, d)) in ours.iter().zip(&decoded).enumerate() {
13323+ if let Some((plane, s, got, want)) = first_plane_mismatch(o, d) {
13324+ panic!(
13325+ "{encoder} {params:?} frame {f} plane {plane} sample {s}: our \
13326+ decoder decoded {got}, ffmpeg {want}"
13327+ );
13328+ }
13329+ }
13330+ }
13331+ Err(e) => panic!("{encoder} {params:?}: our decoder refused the stream ({e})"),
13332+ }
1330513333 let mean: f64 = decoded
1330613334 .iter()
1330713335 .zip(source)
crates/ec-av1/src/motion_field.rsmodified+5 -1
@@ -201,7 +201,11 @@ pub fn lower_mv_precision(
201201 _ => v - m,
202202 }
203203 };
204- return (round(mv.0), round(mv.1));
204+ let out = (round(mv.0), round(mv.1));
205+ if out != mv && crate::envflags::env_flag!("EC_TRACE_TPL") {
206+ eprintln!("EC_INTMV rounded {mv:?} -> {out:?}");
207+ }
208+ return out;
205209 }
206210 if allow_high_precision_mv {
207211 return mv;