wip(lane-partab): HORZ_A/VERT_A/VERT_B INTER arms decode; PARTAB_HITS atomic; dedicated AB gate (7 exact, hits=6)
Browse files at this commitedca059640cdea81fb397fb4ef627c77ece64c1fParent: b3916342 changed files +179 -1
- crates/ec-av1/src/decode.rs +1 -1
- crates/ec-av1/src/stream.rs +178 -0
crates/ec-av1/src/decode.rsmodified+1 -1
| @@ -9085,7 +9085,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 9085 | 9085 | } |
| 9086 | 9086 | _ => { |
| 9087 | 9087 | return Err(unsupported(format!( |
| 9088 | - "a partition type this encoder never writes (value={part32})" | |
| 9088 | + "an INTER 32x32 partition type this encoder never writes (value={part32})" | |
| 9089 | 9089 | ))); |
| 9090 | 9090 | } |
| 9091 | 9091 | } |
crates/ec-av1/src/stream.rsmodified+178 -0
| @@ -3848,6 +3848,184 @@ mod tests { | ||
| 3848 | 3848 | ); |
| 3849 | 3849 | } |
| 3850 | 3850 | |
| 3851 | + /// lane-partab r1: `--enable-ab-partitions=1` (aomenc default-on) INTER | |
| 3852 | + /// streams must consume PARTITION_HORZ_A/VERT_A/VERT_B entropy-exact AND | |
| 3853 | + /// decode pixel-exact -- `partab_hits() > 0` is soft-skipped on a | |
| 3854 | + /// zero-hit run (aomenc RD may legitimately never pick an AB split in a | |
| 3855 | + /// small window, same sampling caveat as wedge/rect). The INTER AB | |
| 3856 | + /// refusal is FORBIDDEN (decode.rs names it "an INTER 32x32 partition | |
| 3857 | + /// ..."); intra-frame AB refusals stay accepted named refusals -- the | |
| 3858 | + /// intra dispatch is a later lane. Recipe = the free-partition gate's, | |
| 3859 | + /// which fires AB live (r1: partab_hits 6/2/4/3/1/5 over six | |
| 3860 | + /// 40-attempt runs). | |
| 3861 | + #[test] | |
| 3862 | + fn a_real_aomenc_stream_with_ab_partitions_decodes_pixel_exact() { | |
| 3863 | + const NAME: &str = "a_real_aomenc_stream_with_ab_partitions_decodes_pixel_exact"; | |
| 3864 | + let _gate_lock = lock_gate_counters(); | |
| 3865 | + if !have_ffmpeg() { | |
| 3866 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 3867 | + return; | |
| 3868 | + } | |
| 3869 | + if !have_aomenc() { | |
| 3870 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 3871 | + return; | |
| 3872 | + } | |
| 3873 | + let (width, height, frame_count) = (64usize, 64usize, 24usize); | |
| 3874 | + let mut named_refusals = 0u32; | |
| 3875 | + let mut matched = 0u32; | |
| 3876 | + let n_attempts: u32 = std::env::var("EC_RECTGATE_ATTEMPTS") | |
| 3877 | + .ok() | |
| 3878 | + .and_then(|s| s.parse().ok()) | |
| 3879 | + .unwrap_or(40); | |
| 3880 | + for attempt in 0..n_attempts { | |
| 3881 | + let seed = 42 + attempt; | |
| 3882 | + let duration = frame_count as f64 / 25.0; | |
| 3883 | + let source = | |
| 3884 | + format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 3885 | + let y4m = Command::new("ffmpeg") | |
| 3886 | + .args([ | |
| 3887 | + "-v", | |
| 3888 | + "error", | |
| 3889 | + "-f", | |
| 3890 | + "lavfi", | |
| 3891 | + "-i", | |
| 3892 | + &source, | |
| 3893 | + "-pix_fmt", | |
| 3894 | + "yuv420p", | |
| 3895 | + "-f", | |
| 3896 | + "yuv4mpegpipe", | |
| 3897 | + "-", | |
| 3898 | + ]) | |
| 3899 | + .stdin(Stdio::null()) | |
| 3900 | + .stdout(Stdio::piped()) | |
| 3901 | + .stderr(Stdio::piped()) | |
| 3902 | + .output() | |
| 3903 | + .expect("ffmpeg failed to run"); | |
| 3904 | + assert!( | |
| 3905 | + y4m.status.success(), | |
| 3906 | + "ffmpeg fixture: {}", | |
| 3907 | + String::from_utf8_lossy(&y4m.stderr) | |
| 3908 | + ); | |
| 3909 | + let args: Vec<&str> = vec![ | |
| 3910 | + "--codec=av1", | |
| 3911 | + "--passes=1", | |
| 3912 | + "--end-usage=q", | |
| 3913 | + "--cq-level=45", | |
| 3914 | + "--cpu-used=0", | |
| 3915 | + "--kf-max-dist=1000", | |
| 3916 | + "--threads=1", | |
| 3917 | + "--row-mt=0", | |
| 3918 | + "--auto-alt-ref=1", | |
| 3919 | + "--lag-in-frames=16", | |
| 3920 | + "--enable-fwd-kf=0", | |
| 3921 | + "--enable-order-hint=1", | |
| 3922 | + "--enable-warped-motion=1", | |
| 3923 | + "--enable-obmc=1", | |
| 3924 | + "--tune-content=default", | |
| 3925 | + "--enable-masked-comp=0", | |
| 3926 | + "--enable-interintra-comp=0", | |
| 3927 | + "--enable-onesided-comp=0", | |
| 3928 | + "--enable-interintra-wedge=0", | |
| 3929 | + "--enable-smooth-interintra=0", | |
| 3930 | + // lane-rect r2 recipe, kept byte-identical by lane-partab | |
| 3931 | + // r1: free partition search, 1to4 off, intra tools off. | |
| 3932 | + "--enable-rect-partitions=1", | |
| 3933 | + "--enable-ab-partitions=1", | |
| 3934 | + "--enable-1to4-partitions=0", | |
| 3935 | + "--enable-filter-intra=0", | |
| 3936 | + "--enable-smooth-intra=0", | |
| 3937 | + "--enable-paeth-intra=0", | |
| 3938 | + "--enable-directional-intra=0", | |
| 3939 | + "--enable-angle-delta=0", | |
| 3940 | + "--enable-tx-size-search=0", | |
| 3941 | + "--enable-cdef=0", | |
| 3942 | + "--enable-restoration=0", | |
| 3943 | + "--max-partition-size=32", | |
| 3944 | + "--min-partition-size=16", | |
| 3945 | + "--enable-palette=0", | |
| 3946 | + "--enable-intrabc=0", | |
| 3947 | + "--enable-cfl-intra=0", | |
| 3948 | + "--enable-ref-frame-mvs=0", | |
| 3949 | + "--obu", | |
| 3950 | + "-o", | |
| 3951 | + "-", | |
| 3952 | + "-", | |
| 3953 | + ]; | |
| 3954 | + let mut child = Command::new(aomenc_path()) | |
| 3955 | + .args(&args) | |
| 3956 | + .stdin(Stdio::piped()) | |
| 3957 | + .stdout(Stdio::piped()) | |
| 3958 | + .stderr(Stdio::piped()) | |
| 3959 | + .spawn() | |
| 3960 | + .expect("aomenc failed to start"); | |
| 3961 | + child | |
| 3962 | + .stdin | |
| 3963 | + .take() | |
| 3964 | + .expect("aomenc stdin") | |
| 3965 | + .write_all(&y4m.stdout) | |
| 3966 | + .expect("writing y4m to aomenc"); | |
| 3967 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 3968 | + assert!( | |
| 3969 | + out.status.success(), | |
| 3970 | + "aomenc refused the fixture: {}", | |
| 3971 | + String::from_utf8_lossy(&out.stderr) | |
| 3972 | + ); | |
| 3973 | + let stream = out.stdout; | |
| 3974 | + let frames = match decode_stream(&stream) { | |
| 3975 | + Err(e) => { | |
| 3976 | + let msg = e.to_string(); | |
| 3977 | + assert!( | |
| 3978 | + msg.contains("unsupported"), | |
| 3979 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | |
| 3980 | + ); | |
| 3981 | + for banned in ["warp", "obmc", "interintra"] { | |
| 3982 | + assert!( | |
| 3983 | + !msg.contains(banned), | |
| 3984 | + "{NAME} refused on {banned} (seed {seed}) -- that capability is \ | |
| 3985 | + ported and this recipe does not need it: {msg}" | |
| 3986 | + ); | |
| 3987 | + } | |
| 3988 | + for v in [4, 6, 7] { | |
| 3989 | + assert!( | |
| 3990 | + !msg.contains(&format!( | |
| 3991 | + "an INTER 32x32 partition type this encoder never writes \ | |
| 3992 | + (value={v})" | |
| 3993 | + )), | |
| 3994 | + "{NAME} refused an INTER AB partition (value={v}, seed {seed}) -- \ | |
| 3995 | + all three AB arms are ported, this refusal is forbidden: {msg}" | |
| 3996 | + ); | |
| 3997 | + } | |
| 3998 | + named_refusals += 1; | |
| 3999 | + eprintln!("seed {seed} refusal: {msg}"); | |
| 4000 | + continue; | |
| 4001 | + } | |
| 4002 | + Ok(frames) => frames, | |
| 4003 | + }; | |
| 4004 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | |
| 4005 | + assert_eq!(frames.len(), frame_count); | |
| 4006 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 4007 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | |
| 4008 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | |
| 4009 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | |
| 4010 | + } | |
| 4011 | + matched += 1; | |
| 4012 | + } | |
| 4013 | + assert!( | |
| 4014 | + matched > 0, | |
| 4015 | + "{NAME}: every attempt refused; the gate never decoded a stream" | |
| 4016 | + ); | |
| 4017 | + if crate::decode::partab_hits() == 0 { | |
| 4018 | + eprintln!( | |
| 4019 | + "{NAME}: SOFT-NOTE -- zero AB partitions fired this run \ | |
| 4020 | + ({matched} matches, {named_refusals} refusals); sampling, not a regression" | |
| 4021 | + ); | |
| 4022 | + } | |
| 4023 | + eprintln!( | |
| 4024 | + "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, partab_hits={}", | |
| 4025 | + crate::decode::partab_hits() | |
| 4026 | + ); | |
| 4027 | + } | |
| 4028 | + | |
| 3851 | 4029 | /// lane-maskcomp r2 / lane-wedge r3: `--enable-masked-comp=1` streams |
| 3852 | 4030 | /// must consume `compound_type`/`wedge_idx`/`wedge_sign`/`mask_type` |
| 3853 | 4031 | /// entropy-exact AND build the real blend, DIFFWTD or WEDGE -- |