The last two NEVER_ON default-on tools -- forward keyframes and 10-bit interintra-wedge/one-sided compound
Browse files at this commit0ef28ca1edfda61419b8809dc91946d00782667aParent: df86cfc- test
- the last two NEVER_ON default-on tools -- forward keyframes and 10-bit interintra-wedge/one-sided compound
3 changed files +188 -21
- crates/ec-av1/src/decode.rs +21 -0
- crates/ec-av1/src/gate_coverage.rs +2 -19
- crates/ec-av1/src/stream.rs +165 -2
crates/ec-av1/src/decode.rsmodified+21 -0
| @@ -755,6 +755,27 @@ pub(crate) fn diffwtd_hits() -> usize { | ||
| 755 | 755 | DIFFWTD_HITS.with(|c| c.get()) |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | +// lane-defon r1: how many FORWARD KEYFRAMES were decoded -- a KEY frame coded | |
| 759 | +// with `show_frame == 0`, output later by a `show_existing_frame` header | |
| 760 | +// (aomenc `--enable-fwd-kf=1 --fwd-kf-dist=N`). Counted from | |
| 761 | +// `stream::decode_stream`, which is where the frame header is consumed; the | |
| 762 | +// gate's proof that the on-value really reached the bitstream rather than | |
| 763 | +// being dropped by the rate control. | |
| 764 | +thread_local! { | |
| 765 | + static FWD_KF_HITS: std::cell::Cell<usize> = | |
| 766 | + const { std::cell::Cell::new(0) }; | |
| 767 | +} | |
| 768 | + | |
| 769 | +/// Current value of [`FWD_KF_HITS`]. | |
| 770 | +pub(crate) fn fwd_kf_hits() -> usize { | |
| 771 | + FWD_KF_HITS.with(|c| c.get()) | |
| 772 | +} | |
| 773 | + | |
| 774 | +/// Records one decoded forward keyframe (see [`FWD_KF_HITS`]). | |
| 775 | +pub(crate) fn note_fwd_kf() { | |
| 776 | + FWD_KF_HITS.with(|c| c.set(c.get() + 1)); | |
| 777 | +} | |
| 778 | + | |
| 758 | 779 | // How many [`read_tx_size`] reads resolved a `tx_depth` strictly less than |
| 759 | 780 | // the block's own side, across every call on the current thread -- the same |
| 760 | 781 | // before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream |
crates/ec-av1/src/gate_coverage.rsmodified+2 -19
| @@ -236,31 +236,14 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ | ||
| 236 | 236 | /// OFF in every gate that names it (a hard hole -- no stream can carry it) or |
| 237 | 237 | /// merely defaulted (unknown, and unknown is not coverage). |
| 238 | 238 | #[cfg(test)] |
| 239 | -const NEVER_ON_8BIT: &[(&str, &str)] = &[ | |
| 240 | - ( | |
| 241 | - "enable-fwd-kf", | |
| 242 | - "on in no 8-bit gate: 12 pin =0, 33 default (aomenc's default is off), so forward keyframes are never coded -- lane-defon r1 left this one open: it needs --fwd-kf-dist plus a decoder counter for a KEY frame with show_frame == 0, neither of which exists yet", | |
| 243 | - ), | |
| 244 | -]; | |
| 239 | +const NEVER_ON_8BIT: &[(&str, &str)] = &[]; | |
| 245 | 240 | |
| 246 | 241 | /// [`DEFAULT_ON_TOOLS`] entries no 10-bit gate spells on, with the reason. |
| 247 | 242 | #[cfg(test)] |
| 248 | 243 | const NEVER_ON_10BIT: &[(&str, &str)] = &[ |
| 249 | 244 | ( |
| 250 | 245 | "enable-diff-wtd-comp", |
| 251 | - "on in no 10-bit gate: 1 pinned off, 14 defaulted -- lane-defon r1 closed the 8-bit hole on the masked-compound gate (diffwtd_hits), but that gate has no 10-bit sibling", | |
| 252 | - ), | |
| 253 | - ( | |
| 254 | - "enable-fwd-kf", | |
| 255 | - "hole at both depths, see the 8-bit list (3 pinned off, 12 defaulted)", | |
| 256 | - ), | |
| 257 | - ( | |
| 258 | - "enable-interintra-wedge", | |
| 259 | - "on in no 10-bit gate: 5 pin =0, 10 default -- wedge interintra masks are exercised at 8 bits only, the shape that cost lane-hbdinter two 10-bit-only defects", | |
| 260 | - ), | |
| 261 | - ( | |
| 262 | - "enable-onesided-comp", | |
| 263 | - "on in no 10-bit gate: 5 pinned off, 10 defaulted -- lane-defon r1 closed the 8-bit hole on the interintra gate (uni_comp_hits); the 10-bit compound gates pin it off", | |
| 246 | + "on in no 10-bit gate: 1 pinned off, 14 defaulted -- lane-defon r1 closed the 8-bit hole on the masked-compound gate (diffwtd_hits) and added a 10-bit one-sided-compound gate, but the 10-bit fixture source is `gradients`, whose smooth content never wins a difference-weighted mask (measured 8/8 pixel-exact, diffwtd_hits == 0); it needs a mandelbrot fixture in ten_bit_tool_gate", | |
| 264 | 247 | ), |
| 265 | 248 | ( |
| 266 | 249 | "multi-tile", |
crates/ec-av1/src/stream.rsmodified+165 -2
| @@ -789,6 +789,13 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 789 | 789 | order_hint_slots[i] = header.order_hint; |
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | + // lane-defon r1: a forward keyframe (aomenc `--enable-fwd-kf`) is a | |
| 793 | + // KEY frame coded with `show_frame == 0`, output later by a | |
| 794 | + // `show_existing_frame` header -- counted only once its tiles have | |
| 795 | + // decoded, so the gate's assert covers decoded-and-compared frames. | |
| 796 | + if header.frame_type == FrameType::Key && !header.show_frame { | |
| 797 | + decode::note_fwd_kf(); | |
| 798 | + } | |
| 792 | 799 | if header.show_frame { |
| 793 | 800 | let output = if header.film_grain.apply_grain { |
| 794 | 801 | let mc_identity = parser |
| @@ -1888,6 +1895,14 @@ mod tests { | ||
| 1888 | 1895 | let input_depth_arg = format!("--input-bit-depth={bit_depth}"); |
| 1889 | 1896 | let mut child = Command::new(aomenc_path()) |
| 1890 | 1897 | .args([ |
| 1898 | + // lane-defon r1: the repo's only gate that decodes hidden | |
| 1899 | + // frames is also the only place a FORWARD KEYFRAME can be | |
| 1900 | + // proven -- a KEY frame with `show_frame == 0`, which is | |
| 1901 | + // exactly the shape this gate already compares in decode | |
| 1902 | + // order. On-values go before the base list (aomenc keeps | |
| 1903 | + // the FIRST occurrence of a repeated flag). | |
| 1904 | + "--enable-fwd-kf=1", | |
| 1905 | + "--fwd-kf-dist=8", | |
| 1891 | 1906 | "--codec=av1", |
| 1892 | 1907 | "--passes=1", |
| 1893 | 1908 | "--end-usage=q", |
| @@ -1953,17 +1968,28 @@ mod tests { | ||
| 1953 | 1968 | String::from_utf8_lossy(&out.stderr) |
| 1954 | 1969 | ); |
| 1955 | 1970 | let stream = out.stdout; |
| 1971 | + let fwd_kf_before = crate::decode::fwd_kf_hits(); | |
| 1956 | 1972 | let (total, hidden) = |
| 1957 | 1973 | decode_all_frames_vs_oracle(&stream, &format!("altref-hidden-{bit_depth}bit")); |
| 1974 | + let fwd_kf = crate::decode::fwd_kf_hits() - fwd_kf_before; | |
| 1958 | 1975 | assert!( |
| 1959 | 1976 | hidden >= 2, |
| 1960 | 1977 | "{NAME}: the {bit_depth}-bit recipe produced only {hidden} hidden frame(s) of \ |
| 1961 | 1978 | {total} decoded -- the gate would be vacuous (class \ |
| 1962 | 1979 | gate-blind-to-hidden-frames)" |
| 1963 | 1980 | ); |
| 1981 | + // lane-defon r1: `--enable-fwd-kf=1` is spelled on this recipe, so | |
| 1982 | + // a KEY frame with `show_frame == 0` must actually have been | |
| 1983 | + // decoded -- otherwise the on-value proves nothing. | |
| 1984 | + assert!( | |
| 1985 | + fwd_kf > 0, | |
| 1986 | + "{NAME}: the {bit_depth}-bit recipe decoded {total} frames ({hidden} hidden) but \ | |
| 1987 | + zero forward keyframes -- --enable-fwd-kf=1 --fwd-kf-dist=8 never reached the \ | |
| 1988 | + bitstream" | |
| 1989 | + ); | |
| 1964 | 1990 | eprintln!( |
| 1965 | - "{NAME} {bit_depth}-bit: {total} frames decoded, {hidden} hidden, all \ | |
| 1966 | - pixel-exact vs the oracle in decode order" | |
| 1991 | + "{NAME} {bit_depth}-bit: {total} frames decoded, {hidden} hidden, {fwd_kf} \ | |
| 1992 | + forward keyframes, all pixel-exact vs the oracle in decode order" | |
| 1967 | 1993 | ); |
| 1968 | 1994 | } |
| 1969 | 1995 | } |
| @@ -7069,6 +7095,143 @@ mod tests { | ||
| 7069 | 7095 | } |
| 7070 | 7096 | } |
| 7071 | 7097 | |
| 7098 | + /// lane-defon r1: the 10-bit one-sided-compound hole -- | |
| 7099 | + /// `--enable-onesided-comp` was spelled on in no 10-bit gate (5 of the 15 | |
| 7100 | + /// pin it off, the rest default), so the UNIDIR_COMP_REFERENCE alphabet | |
| 7101 | + /// was proven at 8 bits only while both of his films are 10-bit 4:2:0. | |
| 7102 | + /// `--enable-diff-wtd-comp=1` is deliberately NOT spelled here (a flag a | |
| 7103 | + /// gate turns on without asserting it fired is coverage theatre, class | |
| 7104 | + /// gate-blind-to-feature): measured this round, the 10-bit `gradients` | |
| 7105 | + /// fixture decodes 8/8 pixel-exact with `diffwtd_hits == 0` -- smooth | |
| 7106 | + /// gradients never win | |
| 7107 | + /// a difference-weighted mask (the 8-bit gate needs `mandelbrot`'s hard | |
| 7108 | + /// diagonal edge, and [`ten_bit_tool_gate`] has no mandelbrot source), so | |
| 7109 | + /// hard-asserting it here would fail on encoder choice, not on a decoder | |
| 7110 | + /// defect. | |
| 7111 | + #[test] | |
| 7112 | + fn a_real_aomenc_10bit_stream_with_onesided_compound_decodes_pixel_exact() { | |
| 7113 | + const NAME: &str = "a_real_aomenc_10bit_stream_with_onesided_compound_decodes_pixel_exact"; | |
| 7114 | + let _gate_lock = lock_gate_counters(); | |
| 7115 | + if !have_ffmpeg() { | |
| 7116 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 7117 | + return; | |
| 7118 | + } | |
| 7119 | + if !have_aomenc() { | |
| 7120 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 7121 | + return; | |
| 7122 | + } | |
| 7123 | + ten_bit_tool_gate( | |
| 7124 | + NAME, | |
| 7125 | + 64, | |
| 7126 | + 64, | |
| 7127 | + 24, | |
| 7128 | + &[ | |
| 7129 | + "--enable-onesided-comp=1", | |
| 7130 | + "--enable-masked-comp=1", | |
| 7131 | + "--enable-dist-wtd-comp=0", | |
| 7132 | + "--cq-level=45", | |
| 7133 | + "--kf-max-dist=1000", | |
| 7134 | + "--auto-alt-ref=1", | |
| 7135 | + "--lag-in-frames=16", | |
| 7136 | + "--enable-fwd-kf=0", | |
| 7137 | + "--enable-order-hint=1", | |
| 7138 | + "--enable-global-motion=0", | |
| 7139 | + "--enable-warped-motion=1", | |
| 7140 | + "--enable-obmc=1", | |
| 7141 | + "--tune-content=default", | |
| 7142 | + "--enable-interintra-comp=0", | |
| 7143 | + "--enable-interintra-wedge=0", | |
| 7144 | + "--enable-smooth-interintra=0", | |
| 7145 | + "--enable-rect-partitions=0", | |
| 7146 | + "--enable-ab-partitions=0", | |
| 7147 | + "--enable-1to4-partitions=0", | |
| 7148 | + "--enable-filter-intra=0", | |
| 7149 | + "--enable-smooth-intra=0", | |
| 7150 | + "--enable-paeth-intra=0", | |
| 7151 | + "--enable-directional-intra=0", | |
| 7152 | + "--enable-angle-delta=0", | |
| 7153 | + "--enable-tx-size-search=0", | |
| 7154 | + "--enable-cdef=0", | |
| 7155 | + "--enable-restoration=0", | |
| 7156 | + "--max-partition-size=32", | |
| 7157 | + "--min-partition-size=32", | |
| 7158 | + "--enable-palette=0", | |
| 7159 | + "--enable-intrabc=0", | |
| 7160 | + "--enable-cfl-intra=0", | |
| 7161 | + "--enable-ref-frame-mvs=0", | |
| 7162 | + ], | |
| 7163 | + &[42, 43, 44, 45, 46, 47, 48, 49], | |
| 7164 | + &[("uni_comp_hits", crate::decode::uni_comp_hits as fn() -> usize)], | |
| 7165 | + ); | |
| 7166 | + } | |
| 7167 | + | |
| 7168 | + /// lane-defon r1: the 10-bit sibling of | |
| 7169 | + /// [`a_real_aomenc_stream_with_interintra_wedge_decodes_pixel_exact`] -- | |
| 7170 | + /// `--enable-interintra-wedge=1` was spelled on in no 10-bit gate (5 of | |
| 7171 | + /// the 15 pin it off), and his two films are 10-bit, so the 8-bit | |
| 7172 | + /// gate alone proves nothing about the streams that matter. Same tool | |
| 7173 | + /// set as the 8-bit recipe (`--enable-masked-comp=0` keeps inter blocks | |
| 7174 | + /// off the COMPOUND_WEDGE path, fixed 32x32 partitions), driven through | |
| 7175 | + /// [`ten_bit_tool_gate`], which hard-asserts `wii_hits` moved and | |
| 7176 | + /// compares every plane against ffmpeg's own 10-bit decode. | |
| 7177 | + #[test] | |
| 7178 | + fn a_real_aomenc_10bit_stream_with_interintra_wedge_decodes_pixel_exact() { | |
| 7179 | + const NAME: &str = "a_real_aomenc_10bit_stream_with_interintra_wedge_decodes_pixel_exact"; | |
| 7180 | + let _gate_lock = lock_gate_counters(); | |
| 7181 | + if !have_ffmpeg() { | |
| 7182 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 7183 | + return; | |
| 7184 | + } | |
| 7185 | + if !have_aomenc() { | |
| 7186 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 7187 | + return; | |
| 7188 | + } | |
| 7189 | + ten_bit_tool_gate( | |
| 7190 | + NAME, | |
| 7191 | + 64, | |
| 7192 | + 64, | |
| 7193 | + 24, | |
| 7194 | + &[ | |
| 7195 | + "--enable-interintra-wedge=1", | |
| 7196 | + "--enable-interintra-comp=1", | |
| 7197 | + "--enable-smooth-interintra=1", | |
| 7198 | + "--cq-level=45", | |
| 7199 | + "--kf-max-dist=1000", | |
| 7200 | + "--auto-alt-ref=1", | |
| 7201 | + "--lag-in-frames=16", | |
| 7202 | + "--enable-fwd-kf=0", | |
| 7203 | + "--enable-order-hint=1", | |
| 7204 | + "--enable-warped-motion=1", | |
| 7205 | + "--enable-obmc=1", | |
| 7206 | + "--tune-content=default", | |
| 7207 | + "--enable-masked-comp=0", | |
| 7208 | + "--enable-onesided-comp=0", | |
| 7209 | + "--enable-rect-partitions=0", | |
| 7210 | + "--enable-ab-partitions=0", | |
| 7211 | + "--enable-1to4-partitions=0", | |
| 7212 | + "--enable-filter-intra=0", | |
| 7213 | + "--enable-smooth-intra=0", | |
| 7214 | + "--enable-paeth-intra=0", | |
| 7215 | + "--enable-directional-intra=0", | |
| 7216 | + "--enable-angle-delta=0", | |
| 7217 | + "--enable-tx-size-search=0", | |
| 7218 | + "--enable-cdef=0", | |
| 7219 | + "--enable-restoration=0", | |
| 7220 | + "--max-partition-size=32", | |
| 7221 | + "--min-partition-size=32", | |
| 7222 | + "--enable-palette=0", | |
| 7223 | + "--enable-intrabc=0", | |
| 7224 | + "--enable-cfl-intra=0", | |
| 7225 | + "--enable-ref-frame-mvs=0", | |
| 7226 | + ], | |
| 7227 | + &[42, 43, 44, 45, 46, 47, 48, 49], | |
| 7228 | + &[ | |
| 7229 | + ("wii_hits", crate::decode::wii_hits as fn() -> usize), | |
| 7230 | + ("interintra_hits", crate::decode::interintra_hits as fn() -> usize), | |
| 7231 | + ], | |
| 7232 | + ); | |
| 7233 | + } | |
| 7234 | + | |
| 7072 | 7235 | /// lane-wii r2: `--enable-interintra-wedge=1` streams must DECODE |
| 7073 | 7236 | /// pixel-exact -- the wedge-interintra syntax (adapting `wedge_index` |
| 7074 | 7237 | /// CDF symbol, fixed sign 0) and the wedge mask blend are ported over |