Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test(rendering): model-based fuzzing of decoder request decisions

Richie McIlroy940ade25936e
diff --git a/crates/rendering/src/decoder/mod.rs b/crates/rendering/src/decoder/mod.rs
index 170507f30..1f3b33adb 100644
--- a/crates/rendering/src/decoder/mod.rs
+++ b/crates/rendering/src/decoder/mod.rs
@@ -22,6 +22,8 @@ mod ffmpeg;
mod frame_converter;
#[cfg(target_os = "windows")]
mod media_foundation;
+#[cfg(test)]
+mod model;
#[cfg(target_os = "macos")]
pub mod multi_position;
diff --git a/crates/rendering/src/decoder/model/expectations.rs b/crates/rendering/src/decoder/model/expectations.rs
new file mode 100644
index 000000000..b1842ee5c
--- /dev/null
+++ b/crates/rendering/src/decoder/model/expectations.rs
@@ -0,0 +1,195 @@
+use std::collections::{BTreeMap, BTreeSet};
+
+/// One strict expected failure: `case` failing with `class`, on exactly the
+/// listed seed indices (or on at least one seed when `seeds` is absent).
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct Xfail {
+ pub case: String,
+ pub class: String,
+ pub reason: String,
+ pub link: String,
+ pub seeds: Option<BTreeSet<u64>>,
+}
+
+fn parse_seeds(text: &str, line: usize) -> BTreeSet<u64> {
+ let mut seeds = BTreeSet::new();
+ for item in text.split_whitespace() {
+ let parse = |value: &str| {
+ value
+ .parse::<u64>()
+ .unwrap_or_else(|_| panic!("expectations line {line}: bad seed {value}"))
+ };
+ match item.split_once('-') {
+ Some((first, last)) => seeds.extend(parse(first)..=parse(last)),
+ None => {
+ seeds.insert(parse(item));
+ }
+ }
+ }
+ seeds
+}
+
+pub fn format_seeds(seeds: &BTreeSet<u64>) -> String {
+ let mut runs: Vec<(u64, u64)> = Vec::new();
+ for &seed in seeds {
+ match runs.last_mut() {
+ Some((_, last)) if *last + 1 == seed => *last = seed,
+ _ => runs.push((seed, seed)),
+ }
+ }
+ runs.iter()
+ .map(|&(first, last)| match last - first {
+ 0 => first.to_string(),
+ 1 => format!("{first} {last}"),
+ _ => format!("{first}-{last}"),
+ })
+ .collect::<Vec<_>>()
+ .join(" ")
+}
+
+/// Reads the `[[xfail]]` tables of the shared expectations format: string
+/// values only, one `key = "value"` per line, `#` comments.
+pub fn parse(text: &str) -> Vec<Xfail> {
+ let mut entries = Vec::new();
+ let mut current: Option<Xfail> = None;
+ for (number, line) in text.lines().enumerate() {
+ let number = number + 1;
+ let line = line.trim();
+ if line.is_empty() || line.starts_with('#') {
+ continue;
+ }
+ if line == "[[xfail]]" {
+ entries.extend(current.take());
+ current = Some(Xfail {
+ case: String::new(),
+ class: String::new(),
+ reason: String::new(),
+ link: String::new(),
+ seeds: None,
+ });
+ continue;
+ }
+ let (key, value) = line
+ .split_once('=')
+ .unwrap_or_else(|| panic!("expectations line {number}: expected key = value"));
+ let value = value
+ .trim()
+ .strip_prefix('"')
+ .and_then(|value| value.strip_suffix('"'))
+ .unwrap_or_else(|| panic!("expectations line {number}: values are quoted"))
+ .to_string();
+ let entry = current
+ .as_mut()
+ .unwrap_or_else(|| panic!("expectations line {number}: outside [[xfail]]"));
+ match key.trim() {
+ "case" => entry.case = value,
+ "class" => entry.class = value,
+ "reason" => entry.reason = value,
+ "link" => entry.link = value,
+ "seeds" => entry.seeds = Some(parse_seeds(&value, number)),
+ other => panic!("expectations line {number}: unknown key {other}"),
+ }
+ }
+ entries.extend(current);
+ for entry in &entries {
+ assert!(
+ !entry.case.is_empty() && !entry.class.is_empty() && !entry.reason.is_empty(),
+ "every xfail needs case, class and reason: {entry:?}"
+ );
+ }
+ entries
+}
+
+pub struct Verdict {
+ /// (case, class, seeds) failing without a matching xfail.
+ pub unexpected: Vec<(String, String, BTreeSet<u64>)>,
+ /// Xfails whose failure did not happen, with the seeds that passed.
+ pub unexpected_passes: Vec<(Xfail, BTreeSet<u64>)>,
+}
+
+/// Compares observed failures with the xfails for the cases that ran.
+/// Strict both ways: an xfail whose failure did not happen is an error too.
+pub fn judge(
+ xfails: &[Xfail],
+ ran: &BTreeSet<String>,
+ observed: &BTreeMap<(String, String), BTreeSet<u64>>,
+) -> Verdict {
+ let mut unexpected = Vec::new();
+ for ((case, class), seeds) in observed {
+ let entry = xfails
+ .iter()
+ .find(|xfail| &xfail.case == case && &xfail.class == class);
+ let uncovered: BTreeSet<u64> = match entry.and_then(|entry| entry.seeds.as_ref()) {
+ Some(expected) => seeds.difference(expected).copied().collect(),
+ None if entry.is_some() => BTreeSet::new(),
+ None => seeds.clone(),
+ };
+ if !uncovered.is_empty() {
+ unexpected.push((case.clone(), class.clone(), uncovered));
+ }
+ }
+
+ let mut unexpected_passes = Vec::new();
+ for xfail in xfails.iter().filter(|xfail| ran.contains(&xfail.case)) {
+ let seen = observed.get(&(xfail.case.clone(), xfail.class.clone()));
+ let passed: BTreeSet<u64> = match (&xfail.seeds, seen) {
+ (Some(expected), Some(seen)) => expected.difference(seen).copied().collect(),
+ (Some(expected), None) => expected.clone(),
+ (None, Some(_)) => BTreeSet::new(),
+ (None, None) => BTreeSet::from([u64::MAX]),
+ };
+ if !passed.is_empty() {
+ unexpected_passes.push((xfail.clone(), passed));
+ }
+ }
+ Verdict {
+ unexpected,
+ unexpected_passes,
+ }
+}
+
+/// Writes the expectations that would make `observed` pass, keeping the
+/// reason and link of existing entries for the same (case, class).
+pub fn bless(xfails: &[Xfail], observed: &BTreeMap<(String, String), BTreeSet<u64>>) -> String {
+ let mut text = String::new();
+ for ((case, class), seeds) in observed {
+ let known = xfails
+ .iter()
+ .find(|xfail| &xfail.case == case && &xfail.class == class);
+ text.push_str(&format!(
+ "[[xfail]]\ncase = \"{case}\"\nclass = \"{class}\"\nseeds = \"{}\"\nreason = \"{}\"\nlink = \"{}\"\n\n",
+ format_seeds(seeds),
+ known.map_or("TODO", |xfail| xfail.reason.as_str()),
+ known.map_or("", |xfail| xfail.link.as_str()),
+ ));
+ }
+ text
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn seed_lists_round_trip() {
+ let seeds = parse_seeds("0 2 3 5-9 12", 1);
+ assert_eq!(seeds, BTreeSet::from([0, 2, 3, 5, 6, 7, 8, 9, 12]));
+ assert_eq!(format_seeds(&seeds), "0 2 3 5-9 12");
+ }
+
+ #[test]
+ fn strict_in_both_directions() {
+ let xfails =
+ parse("[[xfail]]\ncase = \"a\"\nclass = \"stale\"\nseeds = \"1 2\"\nreason = \"r\"\n");
+ let ran = BTreeSet::from(["a".to_string()]);
+ let observed = BTreeMap::from([(
+ ("a".to_string(), "stale".to_string()),
+ BTreeSet::from([2, 3]),
+ )]);
+ let verdict = judge(&xfails, &ran, &observed);
+ assert_eq!(verdict.unexpected.len(), 1);
+ assert_eq!(verdict.unexpected[0].2, BTreeSet::from([3]));
+ assert_eq!(verdict.unexpected_passes.len(), 1);
+ assert_eq!(verdict.unexpected_passes[0].1, BTreeSet::from([1]));
+ }
+}
diff --git a/crates/rendering/src/decoder/model/expectations.toml b/crates/rendering/src/decoder/model/expectations.toml
new file mode 100644
index 000000000..d3e42a30b
--- /dev/null
+++ b/crates/rendering/src/decoder/model/expectations.toml
@@ -0,0 +1,1001 @@
+# Strict expected failures for the decoder model tests
+# (cap-rendering decoder::model: `cargo test -p cap-rendering --lib decoder::model`).
+#
+# Format, shared with the engine verification suite:
+# [[xfail]]
+# case = "<case id as printed by the suite>"
+# class = "<future | stale | grid-rounding | overread | resets | dropped | fallback | unidentified>"
+# seeds = "<seed indices that fail, ranges allowed: 0 3 5-9>" (optional; absent = any seed)
+# reason = "<what is wrong>"
+# link = "<PR or issue that fixes it; empty when no fix exists yet>"
+#
+# Every listed seed must still fail with that class: a seed that passes fails
+# the run with "remove this xfail", so fixes stay locked in. Any failure not
+# listed here fails the run. After a deliberate change, regenerate the seed
+# lists with CAP_DECODER_MODEL_BLESS=<path prefix> (writes <prefix>.avf.toml
+# and <prefix>.ffmpeg.toml; reasons and links of existing entries are kept)
+# and review the difference.
+#
+# Entries below were recorded on origin/main 5705ee851. "NEW:" marks bugs the
+# model found that no open PR fixes.
+
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/random-seeks/playback"
+class = "future"
+seeds = "0 7 16 49"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future; aVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2595 https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/random-seeks/playback"
+class = "grid-rounding"
+seeds = "8 50"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future; aVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2595 https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/random-seeks/playback"
+class = "overread"
+seeds = "1 2 4 5 7-17 19-25 27-29 31-40 42-44 46-52 54 56 58 59"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future; aVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2595 https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/random-seeks/playback"
+class = "stale"
+seeds = "1 3 6 8 10 15 18-20 24 26 28-30 47 50 52-54 57-59"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future; aVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2595 https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/sequential/export"
+class = "future"
+seeds = "0 1 4 6 8 9 11-13 15-18 20 22 23 25-28"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/sequential/export"
+class = "grid-rounding"
+seeds = "0"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/sequential/export"
+class = "overread"
+seeds = "0-29"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/sequential/playback"
+class = "future"
+seeds = "1 4 10 11 14 17 19 24 25 27"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/sequential/playback"
+class = "overread"
+seeds = "0-4 6-29"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/camera-fast/sequential/playback"
+class = "resets"
+seeds = "8 28"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/camera/sequential/export"
+class = "future"
+seeds = "0-2"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/camera/sequential/export"
+class = "overread"
+seeds = "0-3"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/camera/sequential/playback"
+class = "future"
+seeds = "2 3"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/camera/sequential/playback"
+class = "overread"
+seeds = "0 2 3"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/keyframe-seeks/playback"
+class = "future"
+seeds = "10 42 59 85 87 205 214 219 232 234 240 250 258 260"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/keyframe-seeks/playback"
+class = "grid-rounding"
+seeds = "25 32 42 55 73 76 81 88 94 113 122 124 132 152 160 185 228 229 243 280 290"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/keyframe-seeks/playback"
+class = "stale"
+seeds = "1-3 6-9 11 13 15-22 25 27 28 32-35 37 38 40 41 43-51 53-55 58 65 66 68-73 75 76 79 81 83 84 86 88-92 94-96 100-103 106-114 116-122 124-129 131-133 136-140 142 145-147 149 150 153 154 156 157 160 162 164 169-173 175 176 178-181 185-188 191 196 197 201 204 206-210 212 218 221-231 233 235-239 241-244 246-249 251-257 262 264 265 267 268 270-275 277 278 280-284 287 289-291 293 295-299"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/random-seeks/playback"
+class = "future"
+seeds = "52 221"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/random-seeks/playback"
+class = "grid-rounding"
+seeds = "10 26 190 208 212 218 238 271 274"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/random-seeks/playback"
+class = "overread"
+seeds = "54 79 146 184 190 197"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/random-seeks/playback"
+class = "stale"
+seeds = "0 2 6 8 10 11 14 15 19-27 29-36 38 41-43 45-48 50 55 57 58 62 64 67 69-71 74-77 80 82-87 91-93 95-97 99 100 102 107 110-112 114 115 118-124 126 127 129 131-133 136 138 140 141 143-148 150 151 154 155 157-161 163 165-167 169 170 172 174-176 179-181 183 185 188-193 196 201-203 205 207 212 214-216 218 220 224-226 229-236 238 240-243 245 248-251 254-259 261 262 264 269 271 272 274 275 277 281-283 286 291 296 299"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/scrub/playback"
+class = "overread"
+seeds = "41 89 96"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/scrub/playback"
+class = "stale"
+seeds = "1 2 5 7-9 13-15 17 19 22-24 27-29 34 36 37 40 43 48 53 55 56 58 59 61 62 65 66 70-73 76 78-81 83 84 86-88 91 93 99-101 105-107 109 110 113 115 120 123 128 129 131-137 142-144 148 149 151 152 154 155 157-160 162 166-169 171 173-175 177 180-182 184 185 189 190 196-199"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/sequential/playback"
+class = "stale"
+seeds = "23 115"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/tail/export"
+class = "stale"
+seeds = "1 7 54 60 69"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/tail/playback"
+class = "stale"
+seeds = "12 34 40 73 93"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/timeline/export"
+class = "grid-rounding"
+seeds = "16 28 45 57 93 128 137"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/timeline/export"
+class = "overread"
+seeds = "56 131"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/timeline/export"
+class = "stale"
+seeds = "2 7-12 14-17 19 23 24 26 28 30-33 35-40 42 44 45 47 49 52-55 57 58 60-63 66 69-71 75 76 81-83 86 88 90 93-95 97 98 101-103 106 108 112 113 117-119 121 122 125 126 128-130 132-134 137 142 143 147 148"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/transition/export"
+class = "future"
+seeds = "17 51 64"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/transition/export"
+class = "grid-rounding"
+seeds = "16 32"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/transition/export"
+class = "stale"
+seeds = "0 5 6 8 10 12 16 19 22-25 28 33 38 40 42 48 50 56 59 61 65 66 68 73 75 78 79"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/transition/playback"
+class = "future"
+seeds = "45"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/transition/playback"
+class = "grid-rounding"
+seeds = "40"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/cfr/transition/playback"
+class = "stale"
+seeds = "4 6 8 11 14-16 20 21 23 25 29 35 36 41 42 58 60 64 66 68-70 73 74 76"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/dense/random-seeks/playback"
+class = "future"
+seeds = "132"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/dense/random-seeks/playback"
+class = "stale"
+seeds = "0 1 3 5 9 13 15 18 25 28 30 32 34 36 37 39 43-47 49 51 53 56-59 61 62 64-66 69 73 74 76 79-82 87 89 91 96 97 100-102 105 107 109 110 114 115 117-119 122 126 127 131 134-140 143 149"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/halfgrid/back-into-old-gap/export"
+class = "overread"
+seeds = "18 30 54 55"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/halfgrid/back-into-old-gap/export"
+class = "stale"
+seeds = "2 3 8 15 17 19 20 22 30 37 39 42-45 50 54 55 59"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/halfgrid/back-into-old-gap/playback"
+class = "future"
+seeds = "30 33 38"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/halfgrid/back-into-old-gap/playback"
+class = "grid-rounding"
+seeds = "7"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/halfgrid/back-into-old-gap/playback"
+class = "overread"
+seeds = "7 37 55"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/halfgrid/back-into-old-gap/playback"
+class = "stale"
+seeds = "2 4 7 18 20 22-27 29 34 36 37 39 41 42 45 47 55 58 59"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/late-start/random-seeks/playback"
+class = "future"
+seeds = "36 40 61 67 79"
+reason = "AVAssetReader requests before a late-starting stream's first frame read the reader one frame further ahead per request, and seeks into the stream start show the wrong frame"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/late-start/random-seeks/playback"
+class = "grid-rounding"
+seeds = "12 31 37 43"
+reason = "AVAssetReader requests before a late-starting stream's first frame read the reader one frame further ahead per request, and seeks into the stream start show the wrong frame"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/late-start/random-seeks/playback"
+class = "overread"
+seeds = "0-7 10 13 16-21 23-29 32-37 39 40 42 44-49 51-60 64-75 77-79"
+reason = "AVAssetReader requests before a late-starting stream's first frame read the reader one frame further ahead per request, and seeks into the stream start show the wrong frame"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/late-start/random-seeks/playback"
+class = "stale"
+seeds = "4 8 11-16 18 22 24 26-28 31 32 37-39 41-44 47 50 57 62-64 74"
+reason = "AVAssetReader requests before a late-starting stream's first frame read the reader one frame further ahead per request, and seeks into the stream start show the wrong frame"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/late-start/sequential/playback"
+class = "future"
+seeds = "2 5 20 21 23 24 28 38 41-43 45 52 55 57 63 72 77 78"
+reason = "AVAssetReader requests before a late-starting stream's first frame read the reader one frame further ahead per request, and seeks into the stream start show the wrong frame"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/late-start/sequential/playback"
+class = "overread"
+seeds = "0-2 5-10 14 15 19-29 31 32 34 37 38 40-47 49 51-59 66 70-78"
+reason = "AVAssetReader requests before a late-starting stream's first frame read the reader one frame further ahead per request, and seeks into the stream start show the wrong frame"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/late-start/sequential/playback"
+class = "resets"
+seeds = "29 75"
+reason = "AVAssetReader requests before a late-starting stream's first frame read the reader one frame further ahead per request, and seeks into the stream start show the wrong frame"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/late-start/sequential/playback"
+class = "stale"
+seeds = "50 60 64 79"
+reason = "AVAssetReader requests before a late-starting stream's first frame read the reader one frame further ahead per request, and seeks into the stream start show the wrong frame"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/syn/edlist/export"
+class = "future"
+seeds = "0-7"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/syn/edlist/export"
+class = "overread"
+seeds = "0-7"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/syn/edlist/playback"
+class = "future"
+seeds = "2"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/syn/edlist/playback"
+class = "overread"
+seeds = "0-7"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/keyframe-seeks/playback"
+class = "future"
+seeds = "28 51 53 56 59-61 63 86"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/keyframe-seeks/playback"
+class = "grid-rounding"
+seeds = "5 25 27 32 48 52 56 65 76 86 90 98"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/keyframe-seeks/playback"
+class = "overread"
+seeds = "65 76 86 98"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/keyframe-seeks/playback"
+class = "stale"
+seeds = "0-3 6 7 9 10 12-22 24-26 29-37 39-42 44-50 52 54 55 57 58 62 64-76 78-85 87-91 93-97 99"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/random-seeks/playback"
+class = "future"
+seeds = "7 17 23 76 84 97 100 105 109 114 115 119 135 136 148 174"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/random-seeks/playback"
+class = "grid-rounding"
+seeds = "77 87 114 133 156"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/random-seeks/playback"
+class = "overread"
+seeds = "58 171 180 192"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/random-seeks/playback"
+class = "stale"
+seeds = "5 6 10-12 18 20-22 24 25 31 35 36 41-44 48-50 58 61 63 66 69 72-75 77 79 81-83 86 87 89 90 96 99 101-104 107 110 112 116 120 122 123 125-127 131 132 137 142 143 146 151 153 156 157 159 162 163 165 171 172 176 179-181 189 191-194"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/scrub/playback"
+class = "future"
+seeds = "6 47 68 94"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/scrub/playback"
+class = "overread"
+seeds = "28 36 48 66 77 114"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/scrub/playback"
+class = "stale"
+seeds = "1 2 7 9 10 12 14 16 17 21-26 29 30 34 37 40 41 43-45 49 50 53 54 56-58 61 62 65 66 69 70 72-74 77-92 97 100-104 108-110 113 114 116 118 119"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/sequential/export"
+class = "stale"
+seeds = "34 40 73 99"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/sequential/playback"
+class = "stale"
+seeds = "6 15 22 29 49 69 85"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/timeline/export"
+class = "future"
+seeds = "13 44 59"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/timeline/export"
+class = "grid-rounding"
+seeds = "43 77 91 93 96"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/timeline/export"
+class = "overread"
+seeds = "59"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/timeline/export"
+class = "stale"
+seeds = "12 15 17 18 20 23 27 31 34 37 43 50 51 54 61 72 73 76 77 82 85 86 90 91 93 96 102 103 108 112 115"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/transition/playback"
+class = "future"
+seeds = "5 14 15 17 20 22 23 27 28 30 31 33 36 40 43 48 51 54 63-65 76-78"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/transition/playback"
+class = "grid-rounding"
+seeds = "8"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/avf/vfr/transition/playback"
+class = "stale"
+seeds = "0 4 10 11 13 16 18 29 35 37 39 41 42 44 47 50 56-60 62 67-70 74 79"
+reason = "AVAssetReader seeks: the reader starts on the keyframe time rounded to 10 ms, so it can return the previous GOP's last frame under the keyframe's number, and a reused pooled reader answers from frames cached by an earlier, unrelated seek"
+link = "https://github.com/CapSoftware/Cap/pull/2603"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/random-seeks/playback"
+class = "future"
+seeds = "7"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/random-seeks/playback"
+class = "grid-rounding"
+seeds = "2 11-13 20 23 26 33 47"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/random-seeks/playback"
+class = "overread"
+seeds = "0-4 6 8-12 14-16 18 19 22-32 34-51 54-59"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/random-seeks/playback"
+class = "stale"
+seeds = "47"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/sequential/export"
+class = "grid-rounding"
+seeds = "3 6 28"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/sequential/export"
+class = "overread"
+seeds = "0-29"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/sequential/export"
+class = "stale"
+seeds = "0 3-6 11 15 22 27-29"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/sequential/playback"
+class = "grid-rounding"
+seeds = "2 6 24"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/sequential/playback"
+class = "overread"
+seeds = "0-8 10-14 16 17 19-21 23-29"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera-fast/sequential/playback"
+class = "stale"
+seeds = "0 2 6 11 24"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera/sequential/export"
+class = "grid-rounding"
+seeds = "1"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera/sequential/export"
+class = "overread"
+seeds = "0-3"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera/sequential/export"
+class = "stale"
+seeds = "0-3"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera/sequential/playback"
+class = "grid-rounding"
+seeds = "2 3"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera/sequential/playback"
+class = "overread"
+seeds = "2 3"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/camera/sequential/playback"
+class = "stale"
+seeds = "2 3"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/keyframe-seeks/playback"
+class = "future"
+seeds = "1 4 6 17 18 20 23 41 42 48 50 53 63 65 101 108 115 118 119 122 124 130 136 140 142 147 149-151 154 161 167 188 192 199-201 203 209 212 216 219 223 235 237 245 248 250 261 263 268 270 271 275 285 288 290 291"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/keyframe-seeks/playback"
+class = "grid-rounding"
+seeds = "2 6 9 12 17 19 23 27 28 30 31 33 38 39 41 42 46 50 52 54 56 60 61 65 68 71 72 74 75 79 82-84 86 90 92 93 96 98 99 101-104 106-108 110 111 119 122 124 125 129 131 133 135 137 138 140 141 143 145 148-150 152 156 164 165 168-172 177-179 181-183 186 189-192 194 195 197-199 203 205 206 209-211 222 227 236 241 243 250 253 256 258 265 266 273 274 283 284 287 290 294 295 297"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/keyframe-seeks/playback"
+class = "overread"
+seeds = "2 11 14 27 29 30 33 38 39 50 52 54 56 59-61 67 68 71 74 82 83 86 90 92 93 96 98 99 102-104 106 108 110 113 119 126 129 131 133 135 137 139 144 145 148 152 156 162 164 165 168 169 171 177-179 181 182 185 186 189 190 197 198 205 222 229 236 243 247 258 260 266 274 287 295"
+reason = "NEW: after a backward request served from the FFmpeg decoder's cache, the reader is left far ahead and the next request reads past the frame it needs"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/keyframe-seeks/playback"
+class = "stale"
+seeds = "0 2 5 7 8 12 14-16 19 26 27 29-31 33 37-39 46 47 51 52 54 56 59-62 67-72 74 80 82 83 86 88 90-93 95 96 98-100 102-104 106 110-113 117 121 125-127 129 131 133 135 137-139 144 145 148 152 153 155 156 162 164 165 168-173 175 177-179 181-183 186 189 190 196-198 202 204 205 207 208 210 211 215 222 225-227 229 230 234 236 238-241 243 244 247 253-256 258-260 265 269 274 278 286 287 292 294 295 297 299"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/random-seeks/playback"
+class = "future"
+seeds = "60"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/random-seeks/playback"
+class = "grid-rounding"
+seeds = "13 31 40 52 57 61 63 69 74 80 93 117 120 126 140 153 166 180 182 188 196 251 258 276 299"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/random-seeks/playback"
+class = "overread"
+seeds = "3 9 13 64 95 101 106 140 148 163 187 204 227 287 299"
+reason = "NEW: after a backward request served from the FFmpeg decoder's cache, the reader is left far ahead and the next request reads past the frame it needs"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/random-seeks/playback"
+class = "stale"
+seeds = "0 4 10-13 16 18 20 25 27 30 32 42 43 50 55 61 62 67 73 82 89 100 108 126 128 129 134 137-140 146-148 151 164 166 171 173 174 178-181 184 198 207 217 220 228 232 233 243 246 247 250 254 258 262 267 273 279 281 285 289 290 297"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/scrub/playback"
+class = "grid-rounding"
+seeds = "30 62 63 84 106 122 126 143 176 187"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/scrub/playback"
+class = "overread"
+seeds = "0 3 13 21 31 33-35 39 44 50 51 54 67 75 84 86 97 103 104 106 108 109 111 115 118 119 122 123 134 138-140 144 147 158-161 165 168 170 176 180 185 186 197"
+reason = "NEW: after a backward request served from the FFmpeg decoder's cache, the reader is left far ahead and the next request reads past the frame it needs"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/scrub/playback"
+class = "stale"
+seeds = "0 1 3 4 7 8 11 13-22 26 27 33 35-43 46 49-56 58 60 63 64 66-68 70-75 77 78 80-86 88 90-95 97-101 104-110 113-115 117-119 121-125 127 128 131-135 137 139 141 142 144 145 147-152 154 155 157 160-165 167 168 170 173-177 179-181 183 185-189 191-194 197-199"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/tail/export"
+class = "grid-rounding"
+seeds = "26"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/timeline/export"
+class = "future"
+seeds = "29 50"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/timeline/export"
+class = "grid-rounding"
+seeds = "16 26 32 50 65 75 95 102 133 145"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/timeline/export"
+class = "overread"
+seeds = "53 66 103 107 132"
+reason = "NEW: after a backward request served from the FFmpeg decoder's cache, the reader is left far ahead and the next request reads past the frame it needs"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/timeline/export"
+class = "stale"
+seeds = "12 35 42 43 64 133 135"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/transition/export"
+class = "future"
+seeds = "6 66"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/transition/export"
+class = "grid-rounding"
+seeds = "5-7 38 41 45 53 56 61 62 72"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/transition/export"
+class = "stale"
+seeds = "0-2 4 5 7 15 19 22-26 29 33-36 38 40 41 52 55 60 62 67 73-75 79"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/transition/playback"
+class = "future"
+seeds = "69"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/transition/playback"
+class = "grid-rounding"
+seeds = "9 19 29 42 51 58 64 65"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/cfr/transition/playback"
+class = "stale"
+seeds = "3 6 7 9 14 20 21 25 27 31 36 37 39 43-45 50 53 54 57 59 61 64-66 70 77"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/dense/random-seeks/playback"
+class = "future"
+seeds = "90 121"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/dense/random-seeks/playback"
+class = "grid-rounding"
+seeds = "1 7 15 21 25 32 35 36 45 47 48 55 64 70 82 86 90 91 100 103 114 115 121 126 147"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/dense/random-seeks/playback"
+class = "overread"
+seeds = "33 86"
+reason = "NEW: after a backward request served from the FFmpeg decoder's cache, the reader is left far ahead and the next request reads past the frame it needs"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/dense/random-seeks/playback"
+class = "stale"
+seeds = "0 4 14 15 17 20 22 25 27 29 31-33 38 39 43 50 54 56 57 61 63 65 67 71 84 86 91-93 97 99 102 114 116 123 126 128 130 135 137 140 144"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/halfgrid/back-into-old-gap/export"
+class = "overread"
+seeds = "23 41"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/halfgrid/back-into-old-gap/playback"
+class = "overread"
+seeds = "20"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/syn/edlist/export"
+class = "overread"
+seeds = "0-7"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/syn/edlist/playback"
+class = "overread"
+seeds = "0-7"
+reason = "Camera runaway: when the pts-hole map is full it evicts the narrowest hole, so with two requests per source frame the reader reads one frame further ahead per hole until answers come from the future"
+link = "https://github.com/CapSoftware/Cap/pull/2595"
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/keyframe-seeks/playback"
+class = "future"
+seeds = "2 4 5 9 11 14 20-22 24-27 29 31 32 34 36 37 39-41 48 50 53-56 58 59 62-65 67 70 71 73 76 79 82 84 88 90 91 93-98"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/keyframe-seeks/playback"
+class = "grid-rounding"
+seeds = "1 3-5 8 9 11 15 16 18 23 25 27 29-31 41 43 44 47 50 51 56-62 66 70-72 74 75 79-87 89 92 96 97 99"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/keyframe-seeks/playback"
+class = "overread"
+seeds = "6 9 15 17 18 23 28 30 31 44 46 47 50 52 57 58 60 61 66 69 72 75 76 78 83 84 87 89 97 99"
+reason = "NEW: after a backward request served from the FFmpeg decoder's cache, the reader is left far ahead and the next request reads past the frame it needs"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/keyframe-seeks/playback"
+class = "stale"
+seeds = "1 3 7 8 10 12 13 15 17-19 23 28 30 42-44 46 47 51 52 57 60 61 66 68 69 72 75 78 81 83 86 87 89 99"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/random-seeks/playback"
+class = "future"
+seeds = "62"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/random-seeks/playback"
+class = "grid-rounding"
+seeds = "3 8 10 12 16 20 34 46 52 58 59 64 77 78 86 95 117 137 144 160 168 185 196"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/random-seeks/playback"
+class = "overread"
+seeds = "11 80 101 102 104 110 130 157 171 180"
+reason = "NEW: after a backward request served from the FFmpeg decoder's cache, the reader is left far ahead and the next request reads past the frame it needs"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/random-seeks/playback"
+class = "stale"
+seeds = "3 12 18 20 29 53 55 67 79 80 84 93 120 148 167 177"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/scrub/playback"
+class = "future"
+seeds = "114"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/scrub/playback"
+class = "grid-rounding"
+seeds = "23 30 46 48 78 87 114"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/scrub/playback"
+class = "overread"
+seeds = "2 4 10 15 19 23 25 28 38 53 54 59 69 75 80 88 91 95 98 107 110 114 119"
+reason = "NEW: after a backward request served from the FFmpeg decoder's cache, the reader is left far ahead and the next request reads past the frame it needs"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/scrub/playback"
+class = "stale"
+seeds = "0-2 7 8 12 15 17-19 21 23 33 34 36 37 43 45 46 49 53 54 56 59 66 67 69-72 75 80 81 86 88 91 95 101-103 105 107 108 110-112 119"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/sequential/playback"
+class = "grid-rounding"
+seeds = "25"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/timeline/export"
+class = "future"
+seeds = "25"
+reason = "NEW: the FFmpeg decoder seeks with the request time rounded to the stream tick, so a request a fraction of a tick before a keyframe lands on that keyframe and is answered with a later frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/timeline/export"
+class = "grid-rounding"
+seeds = "77 110"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/timeline/export"
+class = "overread"
+seeds = "0 20 47 56 62 88 107 110 119"
+reason = "NEW: after a backward request served from the FFmpeg decoder's cache, the reader is left far ahead and the next request reads past the frame it needs"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/timeline/export"
+class = "stale"
+seeds = "20 56 119"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/transition/playback"
+class = "grid-rounding"
+seeds = "15 16 19 20 28 33 34 43 47 48 56 59 62 68 70 77"
+reason = "NEW: the FFmpeg decoder seeks to the exact request time, so after a reset it answers with the frame on screen at that time even when its rounded grid label is after the request; sequential playback shows the previous frame for the same request"
+link = ""
+
+[[xfail]]
+case = "decoder-model/ffmpeg/vfr/transition/playback"
+class = "stale"
+seeds = "4-6 8 10 12 13 18 19 21 28 31 33 38 39 41 45-47 49 50 52 55 56 58 59 61 66 68 71 75-77 79"
+reason = "NEW: the FFmpeg decoder answers backward requests with a cached frame up to 2 grid frames older than the requested one, answers grid frames 0 to 2 with the first frame, and after a backward request served from the cache it reads forward from a reader that is still far ahead, answering with an older cached frame"
+link = ""
diff --git a/crates/rendering/src/decoder/model/generate.rs b/crates/rendering/src/decoder/model/generate.rs
new file mode 100644
index 000000000..1a00a6b68
--- /dev/null
+++ b/crates/rendering/src/decoder/model/generate.rs
@@ -0,0 +1,552 @@
+use cap_video_decode::scripted::{Script, ScriptFrame};
+
+use super::{Mode, Request};
+
+/// SplitMix64: small, fast and stable across platforms and Rust versions.
+pub struct Rng(u64);
+
+impl Rng {
+ pub fn new(seed: u64) -> Self {
+ Self(seed)
+ }
+
+ pub fn next_u64(&mut self) -> u64 {
+ self.0 = self.0.wrapping_add(0x9E37_79B9_7F4A_7C15);
+ let mut z = self.0;
+ z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9);
+ z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB);
+ z ^ (z >> 31)
+ }
+
+ pub fn below(&mut self, n: usize) -> usize {
+ (self.next_u64() % n.max(1) as u64) as usize
+ }
+
+ pub fn unit(&mut self) -> f64 {
+ (self.next_u64() >> 11) as f64 / (1u64 << 53) as f64
+ }
+
+ pub fn range(&mut self, low: f64, high: f64) -> f64 {
+ low + (high - low) * self.unit()
+ }
+
+ pub fn chance(&mut self, p: f64) -> bool {
+ self.unit() < p
+ }
+
+ pub fn pick<T: Copy>(&mut self, items: &[T]) -> T {
+ items[self.below(items.len())]
+ }
+}
+
+pub fn family_seed(family: &str, index: u64) -> u64 {
+ let mut hash = 0xCBF2_9CE4_8422_2325u64;
+ for byte in family.bytes() {
+ hash = (hash ^ byte as u64).wrapping_mul(0x0100_0000_01B3);
+ }
+ hash ^ index.wrapping_mul(0x9E37_79B9_7F4A_7C15)
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum SourceKind {
+ /// Constant rate with optional jitter, at or below the decoder rate.
+ Cfr,
+ /// Source faster than the decoder grid: several samples share a label.
+ Dense,
+ /// Low-light webcam: nominal 30 fps, delivers about 15 with jitter, long.
+ Camera,
+ /// Like `Camera` with many 3 and 4 frame gaps and a shorter duration.
+ CameraFast,
+ /// Screen recording with static holds of random length.
+ Vfr,
+ /// 30 fps screen read on a 60 fps grid (every gap is a pts hole) with long
+ /// holds early in the file.
+ HalfGrid,
+ /// The first sample starts well after zero.
+ LateStart,
+ /// The synthetic screen behind the #2595 backward-jump report: 60 fps
+ /// grid, gaps of 1 to 20 grid frames, a 10 s hold at 30 s and a 2.5 s
+ /// hold at 95 s, 120 s long.
+ Syn,
+}
+
+impl SourceKind {
+ pub fn name(self) -> &'static str {
+ match self {
+ Self::Cfr => "cfr",
+ Self::Dense => "dense",
+ Self::Camera => "camera",
+ Self::CameraFast => "camera-fast",
+ Self::Vfr => "vfr",
+ Self::HalfGrid => "halfgrid",
+ Self::LateStart => "late-start",
+ Self::Syn => "syn",
+ }
+ }
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum PatternKind {
+ Sequential,
+ Timeline,
+ Transition,
+ RandomSeeks,
+ KeyframeSeeks,
+ Scrub,
+ BackIntoOldGap,
+ Tail,
+ /// The editor list from the #2595 report: play 5 to 35 s, jump to 100 to
+ /// 110 s, jump back to 28 to 45 s, at 60 fps.
+ Edlist,
+}
+
+impl PatternKind {
+ pub fn name(self) -> &'static str {
+ match self {
+ Self::Sequential => "sequential",
+ Self::Timeline => "timeline",
+ Self::Transition => "transition",
+ Self::RandomSeeks => "random-seeks",
+ Self::KeyframeSeeks => "keyframe-seeks",
+ Self::Scrub => "scrub",
+ Self::BackIntoOldGap => "back-into-old-gap",
+ Self::Tail => "tail",
+ Self::Edlist => "edlist",
+ }
+ }
+}
+
+pub struct Source {
+ pub script: Script,
+ /// Decoder grid rate (the recording metadata fps).
+ pub fps: u32,
+ pub max_fallback_distance: u32,
+}
+
+const TIME_BASES: [i32; 6] = [600, 1000, 15360, 30000, 90000, 1_000_000];
+const GOPS: [usize; 7] = [1, 10, 30, 60, 120, 240, 600];
+
+fn script_from_times(rng: &mut Rng, times: &[f64], nominal_interval: f64) -> Script {
+ let den = rng.pick(&TIME_BASES);
+ let gop = rng.pick(&GOPS);
+ let key_after_gap = rng.chance(0.5);
+ script_with(rng, times, nominal_interval, den, gop, key_after_gap)
+}
+
+fn script_with(
+ rng: &mut Rng,
+ times: &[f64],
+ nominal_interval: f64,
+ den: i32,
+ gop: usize,
+ key_after_gap: bool,
+) -> Script {
+ let mut frames: Vec<ScriptFrame> = Vec::with_capacity(times.len());
+ let mut since_key = 0usize;
+ for (index, &time) in times.iter().enumerate() {
+ let mut pts = (time * den as f64).round() as i64;
+ if let Some(previous) = frames.last() {
+ pts = pts.max(previous.pts + 1);
+ }
+ let gap = index
+ .checked_sub(1)
+ .map_or(0.0, |previous| time - times[previous]);
+ let keyframe =
+ index == 0 || since_key + 1 >= gop || (key_after_gap && gap > 0.5 && rng.chance(0.7));
+ since_key = if keyframe { 0 } else { since_key + 1 };
+ frames.push(ScriptFrame { pts, keyframe });
+ }
+ Script {
+ time_base: (1, den),
+ frames,
+ last_duration: ((nominal_interval * den as f64).round() as i64).max(1),
+ }
+}
+
+fn steady_times(
+ rng: &mut Rng,
+ start: f64,
+ duration: f64,
+ interval: impl Fn(&mut Rng) -> f64,
+) -> Vec<f64> {
+ let mut times = Vec::new();
+ let mut time = start;
+ while time < start + duration {
+ times.push(time);
+ time += interval(rng).max(0.001);
+ }
+ times
+}
+
+pub fn source(rng: &mut Rng, kind: SourceKind) -> Source {
+ let screen = 4;
+ let camera = 2;
+ match kind {
+ SourceKind::Cfr => {
+ let (source_fps, fps) = rng.pick(&[(30.0, 30), (60.0, 60), (24.0, 30), (25.0, 30)]);
+ let jitter = rng.pick(&[0.0, 0.0, 0.1, 0.3]);
+ let duration = rng.range(2.0, 20.0);
+ let interval = 1.0 / source_fps;
+ let times = steady_times(rng, 0.0, duration, |rng| {
+ interval * (1.0 + jitter * rng.range(-1.0, 1.0))
+ });
+ Source {
+ script: script_from_times(rng, &times, interval),
+ fps,
+ max_fallback_distance: screen,
+ }
+ }
+ SourceKind::Dense => {
+ let source_fps = rng.pick(&[50.0, 60.0]);
+ let duration = rng.range(2.0, 15.0);
+ let interval = 1.0 / source_fps;
+ let times = steady_times(rng, 0.0, duration, |rng| {
+ interval * (1.0 + 0.1 * rng.range(-1.0, 1.0))
+ });
+ Source {
+ script: script_from_times(rng, &times, interval),
+ fps: 30,
+ max_fallback_distance: screen,
+ }
+ }
+ SourceKind::Camera | SourceKind::CameraFast => {
+ let (p1, p3, p4, duration) = if kind == SourceKind::Camera {
+ (
+ rng.range(0.0, 0.05),
+ rng.range(0.05, 0.15),
+ rng.range(0.0, 0.02),
+ rng.range(120.0, 200.0),
+ )
+ } else {
+ (
+ rng.range(0.0, 0.05),
+ rng.range(0.25, 0.45),
+ rng.range(0.02, 0.1),
+ rng.range(40.0, 80.0),
+ )
+ };
+ let times = steady_times(rng, 0.0, duration, |rng| {
+ let roll = rng.unit();
+ let frames = if roll < p1 {
+ 1.0
+ } else if roll < p1 + p3 {
+ 3.0
+ } else if roll < p1 + p3 + p4 {
+ 4.0
+ } else {
+ 2.0
+ };
+ (frames + rng.range(-0.15, 0.15)) / 30.0
+ });
+ Source {
+ script: script_from_times(rng, &times, 2.0 / 30.0),
+ fps: 30,
+ max_fallback_distance: camera,
+ }
+ }
+ SourceKind::Vfr => {
+ let fps = rng.pick(&[30, 60]);
+ let interval = if fps == 60 && rng.chance(0.5) {
+ 1.0 / 30.0
+ } else {
+ 1.0 / fps as f64
+ };
+ let hold_chance = rng.range(0.002, 0.02);
+ let duration = rng.range(10.0, 90.0);
+ let times = steady_times(rng, 0.0, duration, |rng| {
+ if rng.chance(hold_chance) {
+ let hold = rng.pick(&[0.1, 0.4, 1.0, 2.5, 5.0, 12.0]);
+ hold * rng.range(0.5, 1.5)
+ } else {
+ interval * (1.0 + 0.05 * rng.range(-1.0, 1.0))
+ }
+ });
+ Source {
+ script: script_from_times(rng, &times, interval),
+ fps,
+ max_fallback_distance: screen,
+ }
+ }
+ SourceKind::HalfGrid => {
+ let duration = rng.range(40.0, 120.0);
+ let hold_count = 1 + rng.below(3);
+ let mut holds: Vec<(f64, f64)> = (0..hold_count)
+ .map(|_| (rng.range(1.0, duration * 0.3), rng.range(2.0, 12.0)))
+ .collect();
+ holds.sort_by(|a, b| a.0.total_cmp(&b.0));
+ let mut times = Vec::new();
+ let mut time = 0.0;
+ let mut next_hold = 0;
+ while time < duration {
+ times.push(time);
+ if next_hold < holds.len() && time >= holds[next_hold].0 {
+ time += holds[next_hold].1;
+ next_hold += 1;
+ } else {
+ time += (1.0 + 0.05 * rng.range(-1.0, 1.0)) / 30.0;
+ }
+ }
+ Source {
+ script: script_from_times(rng, &times, 1.0 / 30.0),
+ fps: 60,
+ max_fallback_distance: screen,
+ }
+ }
+ SourceKind::Syn => {
+ let mut times = Vec::new();
+ let mut time = 0.0;
+ let holds = [(29.95, 10.08), (94.98, 2.53)];
+ let mut next_hold = 0;
+ while time < 120.0 {
+ times.push(time);
+ if next_hold < holds.len() && time >= holds[next_hold].0 {
+ time += holds[next_hold].1;
+ next_hold += 1;
+ continue;
+ }
+ let mut grid_frames = 1.0;
+ while grid_frames < 20.0 && rng.chance(0.64) {
+ grid_frames += 1.0;
+ }
+ time += grid_frames / 60.0;
+ }
+ let gop = 20 + rng.below(20);
+ Source {
+ script: script_with(rng, &times, 1.0 / 60.0, 600, gop, false),
+ fps: 60,
+ max_fallback_distance: screen,
+ }
+ }
+ SourceKind::LateStart => {
+ let start = rng.range(0.3, 4.0);
+ let interval = rng.pick(&[1.0 / 30.0, 2.0 / 30.0]);
+ let duration = rng.range(3.0, 15.0);
+ let times = steady_times(rng, start, duration, |rng| {
+ interval * (1.0 + 0.1 * rng.range(-1.0, 1.0))
+ });
+ Source {
+ script: script_from_times(rng, &times, interval),
+ fps: 30,
+ max_fallback_distance: camera,
+ }
+ }
+ }
+}
+
+fn secs(script: &Script, ticks: i64) -> f64 {
+ script.secs(ticks)
+}
+
+fn at(time: f64) -> f32 {
+ time as f32
+}
+
+struct Builder {
+ requests: Vec<Request>,
+ playback: bool,
+}
+
+impl Builder {
+ fn seek(&mut self, time: f64) {
+ self.requests.push(Request {
+ time: at(time.max(0.0)),
+ initial: self.playback,
+ });
+ }
+
+ fn play(&mut self, from: f64, frames: usize, out_fps: f64) {
+ for index in 0..frames {
+ self.requests.push(Request {
+ time: at((from + index as f64 / out_fps).max(0.0)),
+ initial: false,
+ });
+ }
+ }
+
+ fn seek_and_play(&mut self, from: f64, frames: usize, out_fps: f64) {
+ self.seek(from);
+ self.play(from + 1.0 / out_fps, frames, out_fps);
+ }
+}
+
+/// Source time requests for one sequence. Times stay inside the stream except
+/// for `Tail`, which plays past the last sample.
+pub fn requests(rng: &mut Rng, source: &Source, kind: PatternKind, mode: Mode) -> Vec<Request> {
+ let script = &source.script;
+ let end = secs(script, script.end_pts());
+ let first = secs(script, script.frames[0].pts);
+ let fps = source.fps as f64;
+ let out_fps = rng.pick(&[30.0, 60.0, 60.0]);
+ let mut builder = Builder {
+ requests: Vec::new(),
+ playback: mode == Mode::Playback,
+ };
+ let frames_until =
+ |from: f64, to: f64, out_fps: f64| ((to - from) * out_fps).floor().max(0.0) as usize;
+
+ match kind {
+ PatternKind::Sequential => {
+ let from = if mode == Mode::Playback && rng.chance(0.5) {
+ rng.range(0.0, end * 0.5)
+ } else {
+ 0.0
+ };
+ builder.seek(from);
+ builder.play(
+ from + 1.0 / out_fps,
+ frames_until(from + 1.0 / out_fps, end, out_fps),
+ out_fps,
+ );
+ }
+ PatternKind::Tail => {
+ let from = (end - rng.range(0.5, 3.0)).max(0.0);
+ builder.seek(from);
+ builder.play(
+ from,
+ frames_until(from, end + rng.range(0.2, 1.0), out_fps),
+ out_fps,
+ );
+ }
+ PatternKind::Timeline => {
+ for _ in 0..2 + rng.below(7) {
+ let start = rng.range(0.0, end);
+ let length = rng.range(0.2, 6.0).min(end - start);
+ let speed = rng.pick(&[0.5, 1.0, 1.0, 1.0, 1.5, 2.0]);
+ let count = (length / speed * out_fps).floor() as usize;
+ for index in 0..count {
+ builder.requests.push(Request {
+ time: at(start + index as f64 * speed / out_fps),
+ initial: false,
+ });
+ }
+ }
+ }
+ PatternKind::Transition => {
+ for _ in 0..1 + rng.below(3) {
+ let a = rng.range(0.0, end * 0.9);
+ let b = rng.range(0.0, end * 0.9);
+ let overlap = 10 + rng.below(50);
+ for index in 0..overlap {
+ let step = index as f64 / out_fps;
+ if a + step < end {
+ builder.requests.push(Request {
+ time: at(a + step),
+ initial: false,
+ });
+ }
+ if b + step < end {
+ builder.requests.push(Request {
+ time: at(b + step),
+ initial: false,
+ });
+ }
+ }
+ let after = b + overlap as f64 / out_fps;
+ if after < end {
+ builder.play(
+ after,
+ frames_until(after, end, out_fps).min(rng.below(60)),
+ out_fps,
+ );
+ }
+ }
+ }
+ PatternKind::RandomSeeks => {
+ for _ in 0..5 + rng.below(36) {
+ let from = rng.range(0.0, end);
+ let frames = frames_until(from, end, out_fps).min(rng.below(41));
+ builder.seek_and_play(from, frames, out_fps);
+ }
+ }
+ PatternKind::KeyframeSeeks => {
+ let keyframes: Vec<f64> = script
+ .frames
+ .iter()
+ .filter(|frame| frame.keyframe)
+ .map(|frame| secs(script, frame.pts))
+ .collect();
+ for _ in 0..10 + rng.below(51) {
+ let keyframe = rng.pick(&keyframes);
+ let from = match rng.below(4) {
+ 0 => keyframe,
+ 1 => (keyframe * fps).round() / fps,
+ 2 => ((keyframe * fps).round() + rng.pick(&[-1.0, 1.0])) / fps,
+ _ => keyframe + rng.range(-0.5, 0.5) / fps,
+ }
+ .clamp(0.0, end - 0.001);
+ let frames = frames_until(from, end, out_fps).min(rng.below(6));
+ builder.seek_and_play(from, frames, out_fps);
+ }
+ }
+ PatternKind::Scrub => {
+ let mut time = rng.range(0.0, end);
+ builder.seek(time);
+ for _ in 0..50 + rng.below(251) {
+ let magnitude = if rng.chance(0.6) {
+ rng.range(1.0, 6.0)
+ } else {
+ rng.range(6.0, 90.0)
+ };
+ let step = magnitude.round() / fps * if rng.chance(0.5) { 1.0 } else { -1.0 };
+ time = (time + step).clamp(0.0, end - 0.001);
+ if step.abs() * fps > 1.5 {
+ builder.seek(time);
+ } else {
+ builder.requests.push(Request {
+ time: at(time),
+ initial: false,
+ });
+ }
+ }
+ }
+ PatternKind::Edlist => {
+ for (from, to) in [(300, 2100), (6000, 6600), (1680, 2700)] {
+ for frame in from..to {
+ let time = frame as f64 / 60.0;
+ if time < end {
+ builder.requests.push(Request {
+ time: at(time),
+ initial: frame == from && mode == Mode::Playback,
+ });
+ }
+ }
+ }
+ }
+ PatternKind::BackIntoOldGap => {
+ let holds: Vec<(f64, f64)> = script
+ .frames
+ .windows(2)
+ .map(|pair| (secs(script, pair[0].pts), secs(script, pair[1].pts)))
+ .filter(|(start, next)| next - start > 1.5)
+ .collect();
+ let (hold_start, hold_end) =
+ holds.first().copied().unwrap_or((first, first + 1.0 / fps));
+ let mut position = 0.0;
+ for _ in 0..1 + rng.below(3) {
+ let target = (hold_end + rng.range(3.0, 30.0)).min(end - 0.01);
+ if target > position {
+ builder.seek(position);
+ builder.play(
+ position + 1.0 / out_fps,
+ frames_until(position + 1.0 / out_fps, target, out_fps),
+ out_fps,
+ );
+ position = target;
+ }
+ let inside = rng.range(hold_start, hold_end);
+ let frames = frames_until(inside, end, out_fps).min(30 + rng.below(90));
+ builder.seek_and_play(inside, frames, out_fps);
+ if rng.chance(0.5) {
+ position = inside + rng.range(0.0, 2.0);
+ }
+ }
+ }
+ }
+
+ if mode == Mode::Export {
+ for request in &mut builder.requests {
+ request.initial = false;
+ }
+ }
+ builder.requests
+}
diff --git a/crates/rendering/src/decoder/model/mod.rs b/crates/rendering/src/decoder/model/mod.rs
new file mode 100644
index 000000000..8ef157df6
--- /dev/null
+++ b/crates/rendering/src/decoder/model/mod.rs
@@ -0,0 +1,986 @@
+//! Model-based tests of the decoder request logic.
+//!
+//! The real decoders (AVAssetReader pool on macOS, FFmpeg everywhere) are
+//! spawned through `spawn_decoder` on scripted media
+//! (`cap_video_decode::scripted`): sample lists with exact presentation times
+//! and sync flags. Seeded request sequences (export and playback order, double
+//! requests at 60 fps over 30 fps grids, timelines with cuts, speed changes
+//! and backward jumps, transitions, random seeks, keyframe seeks, scrubs,
+//! jumps back into old pts holes, reads past the end) run against them, and
+//! every answer is checked against the reference rule below.
+//!
+//! Reference rule (the decoder contract documented next to `pts_to_frame`):
+//! a sample is labelled `round(fps * pts_seconds)` on the decoder grid, where
+//! FFmpeg measures pts from the stream start time and AVAssetReader from
+//! zero. A request for time `t` asks for grid index `floor(t * fps)`. The
+//! correct answer is the newest sample whose label is at or before that index
+//! (the frame on screen at `t`); when several samples share that label any of
+//! them is accepted. A request before the first sample is answered with the
+//! first sample.
+//!
+//! An answer that is not the grid frame but is the sample on screen at the
+//! exact request time is `grid-rounding`: correct for a seek straight to `t`,
+//! but different from what sequential playback shows for the same request.
+//! Other wrong answers are `future` or `stale` and end the sequence. Every
+//! request also checks that the reader did not decode past the sample after
+//! the answer (`overread`: the reader running ahead of the requests) and that
+//! reader starts and seeks stay within a budget of two per jump in the request
+//! stream (`resets`); these, like `grid-rounding`, are recorded once and the
+//! sequence continues. A request that gets no frame is `dropped`, and the
+//! macOS AVAssetReader decoder falling back to FFmpeg is `fallback`.
+//!
+//! Known failures are strict expected failures, per seed, in
+//! `expectations.toml`.
+//!
+//! Environment:
+//! - `CAP_DECODER_MODEL_SCALE`: multiplies every family's seed count.
+//! - `CAP_DECODER_MODEL_FILTER`: only run cases whose name contains this.
+//! - `CAP_DECODER_MODEL_CASE` + `CAP_DECODER_MODEL_SEED_INDEX`: replay one
+//! sequence and print every request.
+//! - `CAP_DECODER_MODEL_SHRINK`: `none`, `new` (default, unexpected failures
+//! only) or `all`.
+//! - `CAP_DECODER_MODEL_THREADS`: worker threads (at most 3 for
+//! AVAssetReader, 4 for FFmpeg).
+//! - `CAP_DECODER_MODEL_REPORT=<prefix>`: also write the report to
+//! `<prefix>.<decoder>.txt`; `CAP_DECODER_MODEL_SEEDS_OUT=<prefix>` writes
+//! every seed's outcome to `<prefix>.<decoder>.tsv`.
+//! - `CAP_DECODER_MODEL_BLESS=<prefix>`: write the expectations that match
+//! this run to `<prefix>.<decoder>.toml`.
+//!
+//! Wall-clock inputs of the decoders (the AVAssetReader idle timeout of
+//! 250 ms and the scrub detector's 100 ms cooldown) only matter when a
+//! request is delayed by that long, so outcomes are deterministic unless the
+//! machine stalls the test threads.
+
+mod expectations;
+mod generate;
+
+use std::{
+ collections::{BTreeMap, BTreeSet},
+ fmt::Write as _,
+ sync::{
+ Mutex,
+ atomic::{AtomicUsize, Ordering},
+ },
+ time::{Duration, Instant},
+};
+
+use cap_video_decode::scripted::{self, Script};
+
+use generate::{PatternKind, Rng, SourceKind};
+
+#[cfg(target_os = "macos")]
+use super::DecoderType;
+use super::spawn_decoder;
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum Decoder {
+ #[cfg_attr(not(target_os = "macos"), allow(dead_code))]
+ Avf,
+ Ffmpeg,
+}
+
+impl Decoder {
+ fn name(self) -> &'static str {
+ match self {
+ Self::Avf => "avf",
+ Self::Ffmpeg => "ffmpeg",
+ }
+ }
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum Mode {
+ /// `prefer_sequential_access`, like export.
+ Export,
+ /// Editor playback: seeks use the initial request path.
+ Playback,
+}
+
+impl Mode {
+ fn name(self) -> &'static str {
+ match self {
+ Self::Export => "export",
+ Self::Playback => "playback",
+ }
+ }
+}
+
+#[derive(Clone, Copy, Debug)]
+pub struct Request {
+ pub time: f32,
+ pub initial: bool,
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
+enum FailureClass {
+ GridRounding,
+ Future,
+ Stale,
+ Dropped,
+ Fallback,
+ Unidentified,
+ Overread,
+ Resets,
+}
+
+impl FailureClass {
+ fn name(self) -> &'static str {
+ match self {
+ Self::GridRounding => "grid-rounding",
+ Self::Future => "future",
+ Self::Stale => "stale",
+ Self::Dropped => "dropped",
+ Self::Fallback => "fallback",
+ Self::Unidentified => "unidentified",
+ Self::Overread => "overread",
+ Self::Resets => "resets",
+ }
+ }
+}
+
+#[derive(Clone, Debug)]
+struct Failure {
+ class: FailureClass,
+ request: usize,
+ detail: String,
+}
+
+#[derive(Clone)]
+struct Case {
+ name: String,
+ seed_index: u64,
+ seed: u64,
+ decoder: Decoder,
+ mode: Mode,
+ fps: u32,
+ max_fallback_distance: u32,
+ script: Script,
+ requests: Vec<Request>,
+}
+
+struct Outcome {
+ /// The first occurrence of each non-terminal class (`GridRounding`,
+ /// `Overread`, `Resets`), then at most one terminal failure that ended
+ /// the sequence.
+ failures: Vec<Failure>,
+ requests: usize,
+ starts: u64,
+}
+
+struct Oracle {
+ labels: Vec<u32>,
+ secs: Vec<f64>,
+ fps: u32,
+ decoder: Decoder,
+}
+
+fn label(pts: i64, time_base: (i32, i32), fps: u32) -> u32 {
+ (fps as f64 * ((pts as f64 * time_base.0 as f64) / time_base.1 as f64)).round() as u32
+}
+
+impl Oracle {
+ fn new(script: &Script, decoder: Decoder, fps: u32) -> Self {
+ let origin = match decoder {
+ Decoder::Avf => 0,
+ Decoder::Ffmpeg => script.frames[0].pts,
+ };
+ Self {
+ labels: script
+ .frames
+ .iter()
+ .map(|frame| label(frame.pts - origin, script.time_base, fps))
+ .collect(),
+ secs: script
+ .frames
+ .iter()
+ .map(|frame| script.secs(frame.pts - origin))
+ .collect(),
+ fps,
+ decoder,
+ }
+ }
+
+ /// The newest sample presented at or before `time`, ignoring the grid:
+ /// what a seek straight to `time` shows.
+ fn on_screen(&self, time: f32) -> usize {
+ let time = match self.decoder {
+ Decoder::Avf => time,
+ Decoder::Ffmpeg => time.max(0.0),
+ } as f64;
+ self.secs
+ .partition_point(|&secs| secs <= time)
+ .saturating_sub(1)
+ }
+
+ fn index(&self, time: f32) -> u32 {
+ let time = match self.decoder {
+ Decoder::Avf => time,
+ Decoder::Ffmpeg => time.max(0.0),
+ };
+ (time * self.fps as f32).floor() as u32
+ }
+
+ /// Inclusive range of acceptable sample indices for a request.
+ fn expect(&self, index: u32) -> (usize, usize) {
+ let after = self.labels.partition_point(|&label| label <= index);
+ let newest = after.saturating_sub(1);
+ let label = self.labels[newest];
+ let oldest = self.labels.partition_point(|&other| other < label);
+ (oldest, newest)
+ }
+
+ fn last_label(&self) -> u32 {
+ *self.labels.last().unwrap()
+ }
+}
+
+/// Records the first occurrence of a non-terminal failure class.
+fn note(failures: &mut Vec<Failure>, class: FailureClass, request: usize, detail: String) {
+ if !failures.iter().any(|failure| failure.class == class) {
+ failures.push(Failure {
+ class,
+ request,
+ detail,
+ });
+ }
+}
+
+fn frame_identity(frame: &crate::DecodedFrame) -> Option<u32> {
+ let data = frame.data();
+ scripted::frame_id(&data[..data.len().min(16)])
+}
+
+fn runtime() -> tokio::runtime::Runtime {
+ tokio::runtime::Builder::new_current_thread()
+ .enable_all()
+ .build()
+ .unwrap()
+}
+
+fn run_case(case: &Case, runtime: &tokio::runtime::Runtime, trace: bool) -> Outcome {
+ let registration = scripted::register(case.script.clone());
+ let oracle = Oracle::new(&case.script, case.decoder, case.fps);
+ let path = registration.path().to_path_buf();
+
+ runtime.block_on(async {
+ let mut failures: Vec<Failure> = Vec::new();
+ let fail = |mut failures: Vec<Failure>, class, request, detail: String| {
+ failures.push(Failure {
+ class,
+ request,
+ detail,
+ });
+ Outcome {
+ failures,
+ requests: request + 1,
+ starts: registration.reader_starts() + registration.seeks(),
+ }
+ };
+ let handle = match spawn_decoder(
+ "model",
+ path,
+ case.fps,
+ 0.0,
+ case.decoder == Decoder::Ffmpeg,
+ )
+ .await
+ {
+ Ok(handle) => handle.with_max_fallback_distance(case.max_fallback_distance),
+ Err(error) => {
+ return fail(
+ failures,
+ FailureClass::Dropped,
+ 0,
+ format!("spawn failed: {error}"),
+ );
+ }
+ };
+ if case.mode == Mode::Export {
+ handle.prefer_sequential_access();
+ }
+ let decoder_type = handle.decoder_type();
+ #[cfg(target_os = "macos")]
+ if case.decoder == Decoder::Avf {
+ assert_eq!(decoder_type, DecoderType::AVAssetReader);
+ }
+ registration.take_vended();
+
+ let mut previous: Option<(u32, usize)> = None;
+ let mut discontinuities = 0u64;
+ let mut past_end = 0u64;
+ for (position, request) in case.requests.iter().enumerate() {
+ let index = oracle.index(request.time);
+ let (oldest, newest) = oracle.expect(index);
+ if previous.is_none_or(|(previous_index, previous_sample)| {
+ index < previous_index
+ || index > previous_index + 2
+ || case.script.secs(case.script.frames[newest].pts)
+ - case.script.secs(case.script.frames[previous_sample].pts)
+ > LONG_HOLD_SECS
+ }) {
+ discontinuities += 1;
+ }
+ if index > oracle.last_label() {
+ past_end += 1;
+ }
+ previous = Some((index, newest));
+
+ let frame = if request.initial {
+ handle.get_frame_initial(request.time).await
+ } else {
+ handle.get_frame(request.time).await
+ };
+ let vended = registration.take_vended();
+ let starts = registration.reader_starts() + registration.seeks();
+ let describe = |got: Option<u32>| {
+ let mut text = format!(
+ "request {position}: t={:?} ({}) -> grid {index}, expected sample {}..={} (label {}), got {}",
+ request.time,
+ if request.initial { "initial" } else { "normal" },
+ oldest,
+ newest,
+ oracle.labels[newest],
+ got.map_or("nothing".to_string(), |got| format!(
+ "sample {got} (label {})",
+ oracle.labels.get(got as usize).copied().unwrap_or(u32::MAX)
+ )),
+ );
+ let shown: Vec<String> = vended.iter().take(12).map(u32::to_string).collect();
+ let _ = write!(
+ text,
+ "; vended [{}{}], reader starts+seeks {starts}",
+ shown.join(", "),
+ if vended.len() > 12 { ", ..." } else { "" }
+ );
+ text
+ };
+
+ if handle.decoder_type() != decoder_type {
+ return fail(
+ failures,
+ FailureClass::Fallback,
+ position,
+ format!("decoder switched to {}; {}", handle.decoder_type(), describe(None)),
+ );
+ }
+ let Some(frame) = frame else {
+ return fail(failures, FailureClass::Dropped, position, describe(None));
+ };
+ let Some(got) = frame_identity(&frame) else {
+ return fail(
+ failures,
+ FailureClass::Unidentified,
+ position,
+ describe(None),
+ );
+ };
+ if trace {
+ eprintln!("{}", describe(Some(got)));
+ }
+ let got_index = got as usize;
+ if !(oldest..=newest).contains(&got_index) {
+ if got_index == oracle.on_screen(request.time) {
+ note(
+ &mut failures,
+ FailureClass::GridRounding,
+ position,
+ describe(Some(got)),
+ );
+ } else if got_index > newest {
+ return fail(failures, FailureClass::Future, position, describe(Some(got)));
+ } else {
+ return fail(failures, FailureClass::Stale, position, describe(Some(got)));
+ }
+ }
+ if let Some(&furthest) = vended.iter().max()
+ && furthest as usize > newest.max(got_index) + 1
+ {
+ note(
+ &mut failures,
+ FailureClass::Overread,
+ position,
+ describe(Some(got)),
+ );
+ }
+ let allowed = 2 + 2 * discontinuities + past_end / 10;
+ if starts > allowed {
+ note(
+ &mut failures,
+ FailureClass::Resets,
+ position,
+ format!(
+ "{} (allowed {allowed} for {discontinuities} discontinuities)",
+ describe(Some(got))
+ ),
+ );
+ }
+ }
+ Outcome {
+ failures,
+ requests: case.requests.len(),
+ starts: registration.reader_starts() + registration.seeks(),
+ }
+ })
+}
+
+/// Sequential requests that cross a hold this long count as a jump: the
+/// AVAssetReader pool repositions a reader once a request is 5 s past it.
+const LONG_HOLD_SECS: f64 = 4.0;
+
+struct Family {
+ source: SourceKind,
+ pattern: PatternKind,
+ mode: Mode,
+ seeds: usize,
+ avf_only: bool,
+}
+
+const fn family(source: SourceKind, pattern: PatternKind, mode: Mode, seeds: usize) -> Family {
+ Family {
+ source,
+ pattern,
+ mode,
+ seeds,
+ avf_only: false,
+ }
+}
+
+const FAMILIES: &[Family] = {
+ use Mode::*;
+ use PatternKind::*;
+ use SourceKind::*;
+ &[
+ family(Cfr, Sequential, Export, 120),
+ family(Cfr, Sequential, Playback, 120),
+ family(Cfr, Timeline, Export, 150),
+ family(Cfr, Transition, Export, 80),
+ family(Cfr, Transition, Playback, 80),
+ family(Cfr, RandomSeeks, Playback, 300),
+ family(Cfr, KeyframeSeeks, Playback, 300),
+ family(Cfr, Scrub, Playback, 200),
+ family(Cfr, Tail, Export, 100),
+ family(Cfr, Tail, Playback, 100),
+ family(Dense, Sequential, Export, 60),
+ family(Dense, RandomSeeks, Playback, 150),
+ family(Camera, Sequential, Export, 4),
+ family(Camera, Sequential, Playback, 4),
+ family(CameraFast, Sequential, Export, 30),
+ family(CameraFast, Sequential, Playback, 30),
+ family(CameraFast, RandomSeeks, Playback, 60),
+ family(Vfr, Sequential, Export, 100),
+ family(Vfr, Sequential, Playback, 100),
+ family(Vfr, Timeline, Export, 120),
+ family(Vfr, RandomSeeks, Playback, 200),
+ family(Vfr, KeyframeSeeks, Playback, 100),
+ family(Vfr, Scrub, Playback, 120),
+ family(Vfr, Transition, Playback, 80),
+ family(HalfGrid, Sequential, Export, 20),
+ family(HalfGrid, BackIntoOldGap, Playback, 60),
+ family(HalfGrid, BackIntoOldGap, Export, 60),
+ family(Syn, Edlist, Playback, 8),
+ family(Syn, Edlist, Export, 8),
+ Family {
+ source: LateStart,
+ pattern: Sequential,
+ mode: Playback,
+ seeds: 80,
+ avf_only: true,
+ },
+ Family {
+ source: LateStart,
+ pattern: RandomSeeks,
+ mode: Playback,
+ seeds: 80,
+ avf_only: true,
+ },
+ ]
+};
+
+fn case_name(decoder: Decoder, family: &Family) -> String {
+ format!(
+ "decoder-model/{}/{}/{}/{}",
+ decoder.name(),
+ family.source.name(),
+ family.pattern.name(),
+ family.mode.name()
+ )
+}
+
+fn build_case(decoder: Decoder, family: &Family, seed_index: u64) -> Case {
+ let name = case_name(decoder, family);
+ let seed = generate::family_seed(&name, seed_index);
+ let mut rng = Rng::new(seed);
+ let source = generate::source(&mut rng, family.source);
+ let requests = generate::requests(&mut rng, &source, family.pattern, family.mode);
+ Case {
+ name,
+ seed_index,
+ seed,
+ decoder,
+ mode: family.mode,
+ fps: source.fps,
+ max_fallback_distance: source.max_fallback_distance,
+ script: source.script,
+ requests,
+ }
+}
+
+fn fails_with(case: &Case, class: FailureClass, runtime: &tokio::runtime::Runtime) -> bool {
+ run_case(case, runtime, false)
+ .failures
+ .iter()
+ .any(|failure| failure.class == class)
+}
+
+/// Delta-debugging over the request list, then trims the script tail.
+fn shrink(case: &Case, failure: &Failure, runtime: &tokio::runtime::Runtime) -> Case {
+ let deadline = Instant::now() + Duration::from_secs(20);
+ let class = failure.class;
+ let mut best = case.clone();
+ best.requests.truncate(failure.request + 1);
+
+ let mut chunks = 2usize;
+ while best.requests.len() >= 2 && Instant::now() < deadline {
+ let size = best.requests.len().div_ceil(chunks);
+ let mut reduced = false;
+ for start in (0..best.requests.len()).step_by(size) {
+ let mut candidate = best.clone();
+ candidate
+ .requests
+ .drain(start..(start + size).min(candidate.requests.len()));
+ if !candidate.requests.is_empty() && fails_with(&candidate, class, runtime) {
+ best = candidate;
+ chunks = (chunks - 1).max(2);
+ reduced = true;
+ break;
+ }
+ if Instant::now() >= deadline {
+ break;
+ }
+ }
+ if !reduced {
+ if chunks >= best.requests.len() {
+ break;
+ }
+ chunks = (chunks * 2).min(best.requests.len());
+ }
+ }
+
+ let oracle = Oracle::new(&best.script, best.decoder, best.fps);
+ let needed = best
+ .requests
+ .iter()
+ .map(|request| oracle.expect(oracle.index(request.time)).1 + 2)
+ .max()
+ .unwrap_or(1);
+ if needed < best.script.frames.len() {
+ let mut candidate = best.clone();
+ candidate.script.frames.truncate(needed);
+ if fails_with(&candidate, class, runtime) {
+ best = candidate;
+ }
+ }
+ best
+}
+
+fn describe_script(script: &Script) -> String {
+ let mut runs: Vec<(i64, usize)> = Vec::new();
+ for pair in script.frames.windows(2) {
+ let delta = pair[1].pts - pair[0].pts;
+ match runs.last_mut() {
+ Some((last, count)) if *last == delta => *count += 1,
+ _ => runs.push((delta, 1)),
+ }
+ }
+ let deltas: Vec<String> = runs
+ .iter()
+ .map(|(delta, count)| {
+ if *count == 1 {
+ delta.to_string()
+ } else {
+ format!("{delta}x{count}")
+ }
+ })
+ .collect();
+ let keyframes: Vec<String> = script
+ .frames
+ .iter()
+ .enumerate()
+ .filter(|(_, frame)| frame.keyframe)
+ .map(|(index, _)| index.to_string())
+ .collect();
+ format!(
+ "time_base {}/{}, {} samples, first pts {}, pts deltas [{}], sync samples [{}], last duration {}",
+ script.time_base.0,
+ script.time_base.1,
+ script.frames.len(),
+ script.frames[0].pts,
+ deltas.join(" "),
+ keyframes.join(" "),
+ script.last_duration
+ )
+}
+
+fn describe_requests(requests: &[Request]) -> String {
+ requests
+ .iter()
+ .map(|request| {
+ if request.initial {
+ format!("{:?}i", request.time)
+ } else {
+ format!("{:?}", request.time)
+ }
+ })
+ .collect::<Vec<_>>()
+ .join(" ")
+}
+
+struct FamilyResult {
+ name: String,
+ seeds: usize,
+ requests: usize,
+ starts: u64,
+ elapsed: Duration,
+ failures: Vec<(Case, Failure)>,
+ outcomes: Vec<(u64, Vec<(FailureClass, usize)>)>,
+}
+
+fn env_usize(name: &str) -> Option<usize> {
+ std::env::var(name)
+ .ok()
+ .and_then(|value| value.parse().ok())
+}
+
+fn run_suite(decoder: Decoder) {
+ let filter = std::env::var("CAP_DECODER_MODEL_FILTER").ok();
+ let scale: f64 = std::env::var("CAP_DECODER_MODEL_SCALE")
+ .ok()
+ .and_then(|value| value.parse().ok())
+ .unwrap_or(1.0);
+
+ if let (Ok(name), Some(seed_index)) = (
+ std::env::var("CAP_DECODER_MODEL_CASE"),
+ env_usize("CAP_DECODER_MODEL_SEED_INDEX"),
+ ) {
+ let Some(family) = FAMILIES
+ .iter()
+ .find(|family| case_name(decoder, family) == name)
+ else {
+ return;
+ };
+ let case = build_case(decoder, family, seed_index as u64);
+ eprintln!(
+ "replaying {} seed index {} (seed {:#x}): {}",
+ case.name,
+ seed_index,
+ case.seed,
+ describe_script(&case.script)
+ );
+ let outcome = run_case(&case, &runtime(), true);
+ for failure in &outcome.failures {
+ eprintln!("{} {}", failure.class.name(), failure.detail);
+ }
+ assert!(outcome.failures.is_empty());
+ return;
+ }
+
+ let families: Vec<&Family> = FAMILIES
+ .iter()
+ .filter(|family| decoder == Decoder::Avf || !family.avf_only)
+ .filter(|family| {
+ filter
+ .as_ref()
+ .is_none_or(|filter| case_name(decoder, family).contains(filter.as_str()))
+ })
+ .collect();
+ let jobs: Vec<(usize, u64)> = families
+ .iter()
+ .enumerate()
+ .flat_map(|(family_index, family)| {
+ let seeds = ((family.seeds as f64 * scale).ceil() as u64).max(1);
+ (0..seeds).map(move |seed| (family_index, seed))
+ })
+ .collect();
+
+ let started = Instant::now();
+ let next = AtomicUsize::new(0);
+ let results = Mutex::new(
+ families
+ .iter()
+ .map(|family| FamilyResult {
+ name: case_name(decoder, family),
+ seeds: 0,
+ requests: 0,
+ starts: 0,
+ elapsed: Duration::ZERO,
+ failures: Vec::new(),
+ outcomes: Vec::new(),
+ })
+ .collect::<Vec<_>>(),
+ );
+ // AVAssetReader pools share 16 reader permits per process and grow to 5
+ // readers each, so more than 3 concurrent sequences would let one
+ // sequence's pool growth depend on another's and make outcomes vary.
+ let max_threads = match decoder {
+ Decoder::Avf => 3,
+ Decoder::Ffmpeg => 4,
+ };
+ let threads = env_usize("CAP_DECODER_MODEL_THREADS")
+ .unwrap_or_else(|| {
+ std::thread::available_parallelism()
+ .map(usize::from)
+ .unwrap_or(2)
+ })
+ .clamp(1, max_threads);
+ std::thread::scope(|scope| {
+ for _ in 0..threads {
+ scope.spawn(|| {
+ let runtime = runtime();
+ loop {
+ let job = next.fetch_add(1, Ordering::Relaxed);
+ let Some(&(family_index, seed_index)) = jobs.get(job) else {
+ break;
+ };
+ let case = build_case(decoder, families[family_index], seed_index);
+ let case_started = Instant::now();
+ let outcome = run_case(&case, &runtime, false);
+ let mut results = results.lock().unwrap();
+ let result = &mut results[family_index];
+ result.seeds += 1;
+ result.requests += outcome.requests;
+ result.starts += outcome.starts;
+ result.elapsed += case_started.elapsed();
+ result.outcomes.push((
+ seed_index,
+ outcome
+ .failures
+ .iter()
+ .map(|failure| (failure.class, failure.request))
+ .collect(),
+ ));
+ for failure in outcome.failures {
+ result.failures.push((case.clone(), failure));
+ }
+ }
+ });
+ }
+ });
+ let mut results = results.into_inner().unwrap();
+ for result in &mut results {
+ result
+ .failures
+ .sort_by_key(|(case, failure)| (failure.class, case.seed_index));
+ }
+
+ if let Ok(path) = std::env::var("CAP_DECODER_MODEL_SEEDS_OUT") {
+ let mut lines = String::new();
+ for result in &mut results {
+ result.outcomes.sort_by_key(|(seed_index, _)| *seed_index);
+ for (seed_index, outcome) in &result.outcomes {
+ let _ = writeln!(
+ lines,
+ "{}\t{}\t{}",
+ result.name,
+ seed_index,
+ if outcome.is_empty() {
+ "ok".to_string()
+ } else {
+ outcome
+ .iter()
+ .map(|(class, request)| format!("{} {}", class.name(), request))
+ .collect::<Vec<_>>()
+ .join(", ")
+ }
+ );
+ }
+ }
+ let _ = std::fs::write(format!("{path}.{}.tsv", decoder.name()), lines);
+ }
+
+ let xfails = expectations::parse(include_str!("expectations.toml"));
+ let ran: BTreeSet<String> = results.iter().map(|result| result.name.clone()).collect();
+ let mut observed: BTreeMap<(String, String), BTreeSet<u64>> = BTreeMap::new();
+ for result in &results {
+ for (case, failure) in &result.failures {
+ observed
+ .entry((result.name.clone(), failure.class.name().to_string()))
+ .or_default()
+ .insert(case.seed_index);
+ }
+ }
+ let verdict = expectations::judge(&xfails, &ran, &observed);
+ let unexpected: BTreeSet<(String, String, u64)> = verdict
+ .unexpected
+ .iter()
+ .flat_map(|(case, class, seeds)| {
+ seeds
+ .iter()
+ .map(move |&seed| (case.clone(), class.clone(), seed))
+ })
+ .collect();
+
+ let mut report = String::new();
+ let total_requests: usize = results.iter().map(|result| result.requests).sum();
+ let total_seeds: usize = results.iter().map(|result| result.seeds).sum();
+ let _ = writeln!(
+ report,
+ "{} decoder model: {} sequences, {} requests, {:.1} s wall on {} threads",
+ decoder.name(),
+ total_seeds,
+ total_requests,
+ started.elapsed().as_secs_f64(),
+ threads
+ );
+ for result in &results {
+ let mut classes: BTreeMap<FailureClass, (usize, usize)> = BTreeMap::new();
+ for (case, failure) in &result.failures {
+ let counts = classes.entry(failure.class).or_default();
+ counts.0 += 1;
+ if unexpected.contains(&(
+ result.name.clone(),
+ failure.class.name().to_string(),
+ case.seed_index,
+ )) {
+ counts.1 += 1;
+ }
+ }
+ let summary = if classes.is_empty() {
+ "ok".to_string()
+ } else {
+ classes
+ .iter()
+ .map(|(class, (count, new))| {
+ let status = if *new == 0 {
+ "xfail".to_string()
+ } else {
+ format!("{new} NEW")
+ };
+ format!("{} {}/{} ({status})", class.name(), count, result.seeds)
+ })
+ .collect::<Vec<_>>()
+ .join(", ")
+ };
+ let _ = writeln!(
+ report,
+ " {:<58} seeds {:>4} requests {:>7} starts {:>6} {:>6.1}s {}",
+ result.name,
+ result.seeds,
+ result.requests,
+ result.starts,
+ result.elapsed.as_secs_f64(),
+ summary
+ );
+ }
+
+ let shrink_mode = std::env::var("CAP_DECODER_MODEL_SHRINK").unwrap_or_else(|_| "new".into());
+ let runtime = runtime();
+ for result in &results {
+ let mut shown: BTreeMap<FailureClass, bool> = BTreeMap::new();
+ for (case, failure) in &result.failures {
+ let is_new = unexpected.contains(&(
+ result.name.clone(),
+ failure.class.name().to_string(),
+ case.seed_index,
+ ));
+ match shown.get(&failure.class) {
+ Some(true) => continue,
+ Some(false) if !is_new => continue,
+ _ => {}
+ }
+ shown.insert(failure.class, is_new);
+ let _ = writeln!(
+ report,
+ "\n{} {} {}: seed index {} (seed {:#x}), first failure at request {} of {}\n {}",
+ if is_new { "FAIL" } else { "xfail" },
+ result.name,
+ failure.class.name(),
+ case.seed_index,
+ case.seed,
+ failure.request,
+ case.requests.len(),
+ failure.detail
+ );
+ let _ = writeln!(
+ report,
+ " replay: CAP_DECODER_MODEL_CASE={} CAP_DECODER_MODEL_SEED_INDEX={}",
+ result.name, case.seed_index
+ );
+ let wants_shrink = match shrink_mode.as_str() {
+ "all" => true,
+ "none" => false,
+ _ => is_new,
+ };
+ if wants_shrink {
+ let minimal = shrink(case, failure, &runtime);
+ let outcome = run_case(&minimal, &runtime, false);
+ let _ = writeln!(
+ report,
+ " minimal repro: fps {}, max fallback {}, mode {}\n script: {}\n requests ({}): {}\n {}",
+ minimal.fps,
+ minimal.max_fallback_distance,
+ minimal.mode.name(),
+ describe_script(&minimal.script),
+ minimal.requests.len(),
+ describe_requests(&minimal.requests),
+ outcome
+ .failures
+ .iter()
+ .find(|found| found.class == failure.class)
+ .map_or("(did not reproduce)".to_string(), |found| found
+ .detail
+ .clone())
+ );
+ }
+ }
+ }
+
+ for (case, class, seeds) in &verdict.unexpected {
+ let _ = writeln!(
+ report,
+ "\nUNEXPECTED FAILURE {case} {class} on seed indices {}",
+ expectations::format_seeds(seeds)
+ );
+ }
+ for (xfail, seeds) in &verdict.unexpected_passes {
+ let _ = writeln!(
+ report,
+ "\nUNEXPECTED PASS {} {} ({}): remove this xfail{}",
+ xfail.case,
+ xfail.class,
+ xfail.reason,
+ if seeds.contains(&u64::MAX) {
+ String::new()
+ } else {
+ format!(" for seed indices {}", expectations::format_seeds(seeds))
+ }
+ );
+ }
+ eprintln!("{report}");
+ if let Ok(path) = std::env::var("CAP_DECODER_MODEL_REPORT") {
+ let _ = std::fs::write(format!("{path}.{}.txt", decoder.name()), report.as_bytes());
+ }
+ if let Ok(path) = std::env::var("CAP_DECODER_MODEL_BLESS") {
+ let _ = std::fs::write(
+ format!("{path}.{}.toml", decoder.name()),
+ expectations::bless(&xfails, &observed),
+ );
+ }
+ assert!(
+ verdict.unexpected.is_empty() && verdict.unexpected_passes.is_empty(),
+ "decoder model: {} unexpected failures, {} unexpected passes (see report above)",
+ verdict.unexpected.len(),
+ verdict.unexpected_passes.len()
+ );
+}
+
+#[cfg(target_os = "macos")]
+#[test]
+fn avassetreader_answers_match_the_reference_model() {
+ run_suite(Decoder::Avf);
+}
+
+#[test]
+fn ffmpeg_answers_match_the_reference_model() {
+ run_suite(Decoder::Ffmpeg);
+}