Intra 16x4/4x16 strips in an inter 1:4 partition and the un-split 64x32/32x64 corner transform unit, both refusals narrowed behind one film gate
Browse files at this commitddc57141be8a5612e034354fca1796349f351d4fParent: 90b0b04- feat
- intra 16x4/4x16 strips in an inter 1:4 partition and the un-split 64x32/32x64 corner transform unit, both refusals narrowed behind one film gate
3 changed files +134 -19
- crates/ec-av1/fixtures/reelb_rect64_intra16x4_witness.obu +0 -0
- crates/ec-av1/src/decode.rs +21 -16
- crates/ec-av1/src/stream.rs +113 -3
crates/ec-av1/fixtures/reelb_rect64_intra16x4_witness.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+21 -16
| @@ -6894,14 +6894,14 @@ fn decode_rect_split( | |||
| 6894 | // the coded unit is the 32x32 corner [`decode_block_rect64`]'s own | 6894 | // the coded unit is the 32x32 corner [`decode_block_rect64`]'s own |
| 6895 | // depth-0 arm already reads on the key-frame path. | 6895 | // depth-0 arm already reads on the key-frame path. |
| 6896 | // | 6896 | // |
| 6897 | - // NO WITNESS YET (r1, measured): on both 10-bit 3840x1608 film cuts | 6897 | + // lane-sub8x4 r3: WITNESS FOUND, so this is no longer behind |
| 6898 | - // this arm fires (16x 64x32 + 2x 32x64 / 2x 32x64) but the SAME frame | 6898 | + // `EC_RECT64_SPLIT`. r1's "no witness" was true only while the |
| 6899 | - // then stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | 6899 | + // sub-8x8 intra leaves still refused: with those lifted (r2) the |
| 6900 | - // rectangular residual coding", so no frame containing it ever | 6900 | + // first 50 frame OBUs of the 10-bit 3840x1608 stream's head decode |
| 6901 | - // finishes and no pixel comparison is possible. A refusal is lifted | 6901 | + // all 33 frames pixel-exact against ffmpeg while this arm fires 90x |
| 6902 | - // only with a gate (COMMON charter), so the arm stays behind | 6902 | + // 64x32 + 5x 32x64 -- pinned as `fixtures/reelb_rect64_intra16x4_witness.obu` |
| 6903 | - // `EC_RECT64_SPLIT=1` and the refusal below is still the default. | 6903 | + // and gated by `a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact`. |
| 6904 | - (64, 32) | (32, 64) if std::env::var_os("EC_RECT64_SPLIT").is_some() => None, | 6904 | + (64, 32) | (32, 64) => None, |
| 6905 | _ => { | 6905 | _ => { |
| 6906 | return Err(unsupported(format!( | 6906 | return Err(unsupported(format!( |
| 6907 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \ | 6907 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \ |
| @@ -21893,15 +21893,20 @@ fn decode_inter_block( | |||
| 21893 | // footprint), so an INTRA 16x4 / 4x16 strip inside a 1:4 partition is | 21893 | // footprint), so an INTRA 16x4 / 4x16 strip inside a 1:4 partition is |
| 21894 | // refused by name rather than decoded with a 8x2 chroma transform | 21894 | // refused by name rather than decoded with a 8x2 chroma transform |
| 21895 | // libaom never coded. | 21895 | // libaom never coded. |
| 21896 | - // lane-intra16x4 r1: the strip DECODES (through the key frame's own | 21896 | + // lane-intra16x4 r1: the strip DECODES through the key frame's own |
| 21897 | - // per-strip body, [`decode_rect4_16_strip`]) only under | 21897 | + // per-strip body, [`decode_rect4_16_strip`]. |
| 21898 | - // `EC_INTRA16X4_DECODE`. It is not pixel-proven yet -- the r1 gate is | 21898 | + // lane-sub8x4 r3: pixel-proven, so `EC_INTRA16X4_DECODE` is gone. r1 |
| 21899 | - // RED (`a_real_aomenc_inter_sequence_with_intra_16x4_strips_...`, | 21899 | + // and r2 found no witness because every firing film frame ALSO carried |
| 21900 | - // #[ignore]d with its measurement), so the refusal STAYS the default | 21900 | + // a sub-8x8 intra block, which refused until r2 lifted it; on this tip |
| 21901 | - // behaviour and the env switch is what the film probes use to measure | 21901 | + // the first 50 frame OBUs of the 10-bit 3840x1608 stream's head decode |
| 21902 | - // the next wall. Class `refusal-lifted-without-a-gate`. | 21902 | + // all 33 frames pixel-exact while this arm fires 31x 16x4 + 17x 4x16 |
| 21903 | + // (23 of them chroma-paired). Pinned as | ||
| 21904 | + // `fixtures/reelb_rect64_intra16x4_witness.obu`, gated by | ||
| 21905 | + // `a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact`. | ||
| 21906 | + // The refusal below is NARROWED, not deleted: it still stands for a | ||
| 21907 | + // 16x4/4x16 strip with no chroma-pair record and for every other | ||
| 21908 | + // sub-8 shape. | ||
| 21903 | let strip16 = strip_chroma | 21909 | let strip16 = strip_chroma |
| 21904 | - .filter(|_| std::env::var_os("EC_INTRA16X4_DECODE").is_some()) | ||
| 21905 | .filter(|_| write_w.min(write_h) == 4 && write_w.max(write_h) == 16) | 21910 | .filter(|_| write_w.min(write_h) == 4 && write_w.max(write_h) == 16) |
| 21906 | .map(|s| (s.horz, s.has_chroma)); | 21911 | .map(|s| (s.horz, s.has_chroma)); |
| 21907 | if write_w.min(write_h) < 8 && strip16.is_none() { | 21912 | if write_w.min(write_h) < 8 && strip16.is_none() { |
crates/ec-av1/src/stream.rsmodified+113 -3
| @@ -29864,8 +29864,11 @@ mod tests { | |||
| 29864 | /// here)". The moment TX_64X32/TX_32X64 luma coefficient tables land, drop | 29864 | /// here)". The moment TX_64X32/TX_32X64 luma coefficient tables land, drop |
| 29865 | /// the `#[ignore]` -- everything else this gate needs (the reader, the | 29865 | /// the `#[ignore]` -- everything else this gate needs (the reader, the |
| 29866 | /// counter, the two-frame pixel compare) is in place and runs. | 29866 | /// counter, the two-frame pixel compare) is in place and runs. |
| 29867 | + /// | ||
| 29868 | + /// lane-sub8x4 r3: un-`#[ignore]`d. The sibling refusal it waited on (the | ||
| 29869 | + /// un-split TX_64X32/TX_32X64 corner unit) is lifted in this round, so the | ||
| 29870 | + /// frame this gate exists for now finishes. | ||
| 29867 | #[test] | 29871 | #[test] |
| 29868 | - #[ignore = "blocked on a SIBLING refusal, not on this lane: the film frame that carries the intra 1:4 strips (16x64=3) stops at \"a split intra strip whose transform unit is 64x32 (no luma coefficient tables for that shape here)\" -- un-ignore when the 64x32/32x64 luma coefficient tables land"] | ||
| 29869 | fn a_10bit_film_inter_frame_with_intra_1to4_strips_decodes_pixel_exact() { | 29872 | fn a_10bit_film_inter_frame_with_intra_1to4_strips_decodes_pixel_exact() { |
| 29870 | const NAME: &str = "a_10bit_film_inter_frame_with_intra_1to4_strips_decodes_pixel_exact"; | 29873 | const NAME: &str = "a_10bit_film_inter_frame_with_intra_1to4_strips_decodes_pixel_exact"; |
| 29871 | if !have_ffmpeg() { | 29874 | if !have_ffmpeg() { |
| @@ -29893,15 +29896,122 @@ mod tests { | |||
| 29893 | now.2 - before.2, | 29896 | now.2 - before.2, |
| 29894 | now.3 - before.3 | 29897 | now.3 - before.3 |
| 29895 | ); | 29898 | ); |
| 29896 | - assert_eq!(frames.len(), 2, "{NAME}: key frame + one inter frame"); | 29899 | + // lane-sub8x4 r3, MEASURED when this gate first RAN: the fixture has |
| 29900 | + // TWO frame OBUs but only ONE SHOWN frame -- a raw | ||
| 29901 | + // `ffmpeg -i <fixture> -pix_fmt yuv420p10le -f rawvideo` writes exactly | ||
| 29902 | + // 18524160 bytes, one 3840x1608 10-bit frame, so the second is a | ||
| 29903 | + // no-show frame and `frames.len() == 2` was never true. The compare is | ||
| 29904 | + // not vacuous: ffmpeg's own frame count is asserted equal to ours. | ||
| 29905 | + assert_eq!(frames.len(), 1, "{NAME}: one shown frame (the second frame OBU is a no-show)"); | ||
| 29906 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | ||
| 29907 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()); | ||
| 29908 | + assert_eq!( | ||
| 29909 | + ffmpeg_frames.len(), | ||
| 29910 | + frames.len(), | ||
| 29911 | + "{NAME}: ffmpeg returned {} frames, we decoded {}", | ||
| 29912 | + ffmpeg_frames.len(), | ||
| 29913 | + frames.len() | ||
| 29914 | + ); | ||
| 29915 | + for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 29916 | + assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg"); | ||
| 29917 | + assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg"); | ||
| 29918 | + assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg"); | ||
| 29919 | + } | ||
| 29920 | + eprintln!("{NAME}: {fired} intra 1:4 strips in an inter frame, the shown frame pixel-exact"); | ||
| 29921 | + } | ||
| 29922 | + | ||
| 29923 | + /// lane-sub8x4 r3: the FILM witness that lifts BOTH the intra 16x4/4x16 | ||
| 29924 | + /// strip inside an inter 16x16-level 1:4 partition and the un-split | ||
| 29925 | + /// TX_64X32/TX_32X64 corner unit of a split intra strip. | ||
| 29926 | + /// | ||
| 29927 | + /// `crates/ec-av1/fixtures/reelb_rect64_intra16x4_witness.obu`, 23472 bytes, | ||
| 29928 | + /// sha256 `c9e721088766163b9dbeb9fa8dd8b257ff0ec7f9157fc350de4d3c33cd9ec4e4`: | ||
| 29929 | + /// the first 50 frame-carrying OBUs of `ffmpeg -ss 0 -t 2 -i <3840x1608 | ||
| 29930 | + /// 10-bit AV1 HDR10 mkv> -c:v copy -f obu`, cut twice from independent | ||
| 29931 | + /// ffmpeg runs that hashed identically. 33 decode-order frames. | ||
| 29932 | + /// | ||
| 29933 | + /// MEASURED, and why no earlier round had this: r1/r2 of two lanes | ||
| 29934 | + /// reported "no firing witness exists" because every film frame that fires | ||
| 29935 | + /// these two arms ALSO carries a sub-8x8 intra leaf, which refused until | ||
| 29936 | + /// this lane's r2 lifted it. On that tip the whole 33-frame prefix decodes | ||
| 29937 | + /// with no refusal and matches ffmpeg on every plane of every frame, while | ||
| 29938 | + /// both arms fire: `intra16x4_in_inter` 16x4=31 4x16=17 chroma_ref=23 and | ||
| 29939 | + /// `rect64_corner_tu` 64x32=90 32x64=5. (The full 48-frame 2 s segment | ||
| 29940 | + /// diverges at decode-order frame 36, which is a separate wall; the | ||
| 29941 | + /// fixture is the exact prefix, not a truncation chosen to hide it.) | ||
| 29942 | + /// | ||
| 29943 | + /// Both refusal strings stay in `refusal_inventory` because both are | ||
| 29944 | + /// NARROWED, not deleted: "a split intra strip whose transform unit is | ||
| 29945 | + /// {tx_w}x{tx_h}" still stands for every shape other than 64x32/32x64, and | ||
| 29946 | + /// "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition" | ||
| 29947 | + /// still stands for a strip with no chroma-pair record. | ||
| 29948 | + #[test] | ||
| 29949 | + fn a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact() { | ||
| 29950 | + const NAME: &str = | ||
| 29951 | + "a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact"; | ||
| 29952 | + if !have_ffmpeg() { | ||
| 29953 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 29954 | + return; | ||
| 29955 | + } | ||
| 29956 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 29957 | + .join("fixtures/reelb_rect64_intra16x4_witness.obu"); | ||
| 29958 | + let stream = std::fs::read(&path) | ||
| 29959 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | ||
| 29960 | + let (width, height) = (3840usize, 1608usize); | ||
| 29961 | + let before16 = crate::decode::intra16x4_in_inter_hits(); | ||
| 29962 | + let before64 = ( | ||
| 29963 | + crate::decode::rect64_corner_tu_hits(0), | ||
| 29964 | + crate::decode::rect64_corner_tu_hits(1), | ||
| 29965 | + ); | ||
| 29966 | + let frames = match decode_stream(&stream) { | ||
| 29967 | + Ok(frames) => frames, | ||
| 29968 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | ||
| 29969 | + }; | ||
| 29970 | + let now16 = crate::decode::intra16x4_in_inter_hits(); | ||
| 29971 | + let fired16 = ( | ||
| 29972 | + now16.0 - before16.0, | ||
| 29973 | + now16.1 - before16.1, | ||
| 29974 | + now16.2 - before16.2, | ||
| 29975 | + ); | ||
| 29976 | + let fired64 = ( | ||
| 29977 | + crate::decode::rect64_corner_tu_hits(0) - before64.0, | ||
| 29978 | + crate::decode::rect64_corner_tu_hits(1) - before64.1, | ||
| 29979 | + ); | ||
| 29980 | + // Hard counter asserts: neither lift may rest on a stream that stopped | ||
| 29981 | + // carrying its shape (class `tool-disabled-in-every-gate`). | ||
| 29982 | + assert!( | ||
| 29983 | + fired16.0 > 0 && fired16.1 > 0 && fired16.2 > 0, | ||
| 29984 | + "{NAME}: the intra 16x4/4x16 strip arm did not fire (16x4={} 4x16={} chroma_ref={})", | ||
| 29985 | + fired16.0, | ||
| 29986 | + fired16.1, | ||
| 29987 | + fired16.2 | ||
| 29988 | + ); | ||
| 29989 | + assert!( | ||
| 29990 | + fired64.0 > 0 && fired64.1 > 0, | ||
| 29991 | + "{NAME}: the un-split TX_64X32/TX_32X64 corner arm did not fire (64x32={} 32x64={})", | ||
| 29992 | + fired64.0, | ||
| 29993 | + fired64.1 | ||
| 29994 | + ); | ||
| 29995 | + assert_eq!(frames.len(), 33, "{NAME}: 33 decode-order frames"); | ||
| 29897 | assert_eq!((frames[0].width, frames[0].height), (width, height)); | 29996 | assert_eq!((frames[0].width, frames[0].height), (width, height)); |
| 29898 | let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()); | 29997 | let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()); |
| 29998 | + assert_eq!( | ||
| 29999 | + ffmpeg_frames.len(), | ||
| 30000 | + frames.len(), | ||
| 30001 | + "{NAME}: ffmpeg returned {} frames, we decoded {}", | ||
| 30002 | + ffmpeg_frames.len(), | ||
| 30003 | + frames.len() | ||
| 30004 | + ); | ||
| 29899 | for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 30005 | for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 29900 | assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg"); | 30006 | assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg"); |
| 29901 | assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg"); | 30007 | assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg"); |
| 29902 | assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg"); | 30008 | assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg"); |
| 29903 | } | 30009 | } |
| 29904 | - eprintln!("{NAME}: {fired} intra 1:4 strips in an inter frame, both frames pixel-exact"); | 30010 | + eprintln!( |
| 30011 | + "{NAME}: 33 frames pixel-exact, intra16x4_in_inter 16x4={} 4x16={} chroma_ref={}, \ | ||
| 30012 | + rect64_corner_tu 64x32={} 32x64={}", | ||
| 30013 | + fired16.0, fired16.1, fired16.2, fired64.0, fired64.1 | ||
| 30014 | + ); | ||
| 29905 | } | 30015 | } |
| 29906 | 30016 | ||
| 29907 | 30017 | ||