forge
Explore
Log in

Don't you dare go Hollow

The key 64x64 intra root only on a superblock-aligned frame

Browse files at this commit

ce9278900cb70915332d2501651bb38756fbb0c8Ahmet Kaan GümüşParent: 7a807af
  • fix
    • the key 64x64 intra root only on a superblock-aligned frame
Show full message
fix(av1): the key 64x64 intra root only on a superblock-aligned frame

A 248x152 frame -- bottom-right superblock cut on both axes -- desyncs that
corner's CHROMA three ways once the frame carries whole 64 roots elsewhere
(luma stays exact). Named corner-cut with the trace as its upgrade path.

The filter-intra decode fixture carries a step edge now: its smooth field was
coded as four whole 64x64 roots, which are too big for filter intra, so the
gate went blind to the feature it pins. The witness asserts the per-FRAME mode
count instead of the process-global counter.
crates/ec-av1/src/decode.rsmodified+9 -1
@@ -38691,9 +38691,17 @@ mod tests {
38691 let mut picture = crate::encode::Picture::grey(width, height);38691 let mut picture = crate::encode::Picture::grey(width, height);
38692 for row in 0..height {38692 for row in 0..height {
38693 for col in 0..width {38693 for col in 0..width {
38694+ // lane-i64: the smooth field alone is now coded as four whole
38695+ // 64x64 intra roots, which are too big for filter intra (the
38696+ // tool stops at 32x32) -- so the fixture carries a hard step
38697+ // through the middle of every superblock, which no 64x64
38698+ // prediction fits and which sends the quadrants back to the
38699+ // sizes the recursive modes are offered at.
38700+ let step = if (row % 64) > 40 && (col % 64) > 24 { 55.0 } else { 0.0 };
38694 let v = 128.038701 let v = 128.0
38695 + 60.0 * ((row as f64) / 9.0).sin() * ((col as f64) / 11.0).cos()38702 + 60.0 * ((row as f64) / 9.0).sin() * ((col as f64) / 11.0).cos()
38696- + 8.0 * ((row + col) as f64 / 3.0).sin();38703+ + 8.0 * ((row + col) as f64 / 3.0).sin()
38704+ + step;
38697 picture.y[row * width + col] = v.clamp(0.0, 255.0) as u16;38705 picture.y[row * width + col] = v.clamp(0.0, 255.0) as u16;
38698 }38706 }
38699 }38707 }
crates/ec-av1/src/encode.rsmodified+26 -2
@@ -6620,7 +6620,23 @@ pub(crate) fn encode_key_frame_inner(
6620 // intrabc is refused outright ([`I64_ROOT`]) because the quadrant6620 // intrabc is refused outright ([`I64_ROOT`]) because the quadrant
6621 // searches below carry DV state a discarded trial would desync.6621 // searches below carry DV state a discarded trial would desync.
6622 let (x64, y64) = (sb_col * SUPERBLOCK, sb_row * SUPERBLOCK);6622 let (x64, y64) = (sb_col * SUPERBLOCK, sb_row * SUPERBLOCK);
6623+ // corner-cut, ceiling named: only a frame whose true size is a
6624+ // WHOLE number of superblocks is offered the root at all.
6625+ // MEASURED (lane-i64): on a 248x152 frame -- whose bottom-right
6626+ // superblock is cut on BOTH axes -- a frame carrying whole 64
6627+ // roots elsewhere desyncs that corner's CHROMA three ways (our
6628+ // writer's reconstruction, our decoder and ffmpeg all disagree,
6629+ // luma stays exact), i.e. a defect in the whole-64 chroma
6630+ // neighbour publication that only the doubly-cut tail block
6631+ // reads (class `last-block-desync-reads-as-reconstruction`).
6632+ // Every clip on the BD gates, and every real film/screen source,
6633+ // is superblock aligned, so nothing measured is withheld.
6634+ // Ceiling: trace the corner block's chroma `txb_skip`/dc context
6635+ // against aomdec and lift this line.
6636+ let aligned = header.mi_cols % crate::tile::SB_MI == 0
6637+ && header.mi_rows % crate::tile::SB_MI == 0;
6623 let sb64_legal = i64_root()6638 let sb64_legal = i64_root()
6639+ && aligned
6624 && ibc.is_none()6640 && ibc.is_none()
6625 && sb_row * 2 + 1 < rows6641 && sb_row * 2 + 1 < rows
6626 && sb_col * 2 + 1 < cols6642 && sb_col * 2 + 1 < cols
@@ -11092,7 +11108,15 @@ mod tests {
11092 let _ = take_i64_root_hits();11108 let _ = take_i64_root_hits();
11093 let encoded = encode_key_frame_with_ctx(&picture, 120, 0.5, fctx).unwrap();11109 let encoded = encode_key_frame_with_ctx(&picture, 120, 0.5, fctx).unwrap();
11094 let [roots, offered] = take_i64_root_hits();11110 let [roots, offered] = take_i64_root_hits();
11095- assert_eq!(offered, 12, "every superblock is inside the frame");11111+ // The counters are process-global, so another test encoding in
11112+ // parallel can only ADD to them -- the per-FRAME fact is the mode
11113+ // list, which carries one entry per coded block and so exactly 12
11114+ // when every superblock was coded as one 64x64 intra block.
11115+ assert_eq!(
11116+ encoded.modes.len(),
11117+ 12,
11118+ "not every superblock was coded as one 64x64 intra block"
11119+ );
11096 assert!(11120 assert!(
11097 roots >= 8,11121 roots >= 8,
11098 "a smooth-gradient key frame coded only {roots} whole 64x64 intra roots of 12"11122 "a smooth-gradient key frame coded only {roots} whole 64x64 intra roots of 12"
@@ -11129,7 +11153,7 @@ mod tests {
11129 eprintln!("SKIP ffmpeg_decodes_exactly_what_the_encoder_reconstructed: no ffmpeg");11153 eprintln!("SKIP ffmpeg_decodes_exactly_what_the_encoder_reconstructed: no ffmpeg");
11130 return;11154 return;
11131 }11155 }
11132- for &(width, height) in &[(64usize, 64usize), (96, 64), (160, 96), (32, 48)] {11156+ for &(width, height) in &[(64usize, 64usize), (96, 64), (160, 96), (32, 48), (248, 152)] {
11133 let picture = test_card(width, height);11157 let picture = test_card(width, height);
11134 let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap();11158 let encoded = encode_key_frame_with_ctx(&picture, 100, 0.5, fctx).unwrap();
11135 let decoded = ffmpeg_decode(&encoded.stream, width, height);11159 let decoded = ffmpeg_decode(&encoded.stream, width, height);
lanes/i64/bin-r3added+0 -0

Binary file changed