mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 12:44:11 -10:00
- raea-sys-shots: raea-sys-frame's cuts between cameras as a crate of their own (frame re-exports it as shots), so frame's new Cut fits under the crate limit; runtime/scene's paint_cut joins cam_keyed's prefixes. - sdk/video controls.ts: a composition's controls out of registry.tsx (under 500 lines), each kind documented. - raea-runtime-segments in tools/layers.toml; vendor/bevy_solari's compaction-queue fix marked raea:. - sdk/cloud: a farm job's GPU kind is `card` (a prop names what it picks, not the processor); the farm's query is unchanged. - Copies folded: io-media's backend() is backend_unsigned wrapped by the signer; paint's cut colours read by one closure; foliage's one smoothstep, a triangle's bounds in one pass, a cell's pixels as one range; segments' video track found once in its tests and its shortest segment set where it's used; the Solari switch through raea_io_home::env_on; kimodo's package record a path like its others; a few one-liners written directly. tools/dupes.max names the six left, which match by shape only (trait forwards, foliage's own FNV and stream).
71 lines
2.5 KiB
Rust
71 lines
2.5 KiB
Rust
//! Where a video splits: at every cut the timeline knows (an outermost Sequence's start, a camera the engine cut to),
|
|
//! never inside a shot. The frames' side finds them as each frame is made; the encoder's side starts a segment at one,
|
|
//! unless the segment it's in is shorter than the minimum, so a shot under it goes on in the segment it started in.
|
|
|
|
use std::collections::BTreeSet;
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
/// The cuts a render has found, shared between the thread that makes its frames and the encoder's.
|
|
#[derive(Clone, Debug, Default)]
|
|
pub struct Cuts(Arc<Mutex<BTreeSet<i64>>>);
|
|
|
|
impl Cuts {
|
|
/// Frame `f`'s cuts: one when an outermost Sequence starts there (`starts`: each one's start frame, as
|
|
/// raea_runtime_react::scene::shot_starts reads them) or the 3D's camera cut there (`camera`); frame 0 is no cut.
|
|
pub fn find(&self, f: i64, starts: impl IntoIterator<Item = i64>, camera: bool) {
|
|
if f > 0 && (camera || starts.into_iter().any(|s| s == f)) {
|
|
self.mark(f);
|
|
}
|
|
}
|
|
|
|
pub fn mark(&self, f: i64) {
|
|
self.0.lock().unwrap().insert(f);
|
|
}
|
|
|
|
/// Whether frame `f` starts a shot.
|
|
pub fn at(&self, f: i64) -> bool {
|
|
self.0.lock().unwrap().contains(&f)
|
|
}
|
|
|
|
pub fn all(&self) -> Vec<i64> {
|
|
self.0.lock().unwrap().iter().copied().collect()
|
|
}
|
|
|
|
/// Whether frame `f` starts a segment after one of `len` frames: at a cut, once that one has `min`.
|
|
pub fn starts(&self, f: i64, len: usize, min: usize) -> bool {
|
|
len >= min && self.at(f)
|
|
}
|
|
}
|
|
|
|
|
|
/// The segments a run of `n` frames makes with these cuts: each one's first frame and length.
|
|
pub fn segments(n: usize, cuts: &Cuts, min: usize) -> Vec<(usize, usize)> {
|
|
let mut out: Vec<(usize, usize)> = Vec::new();
|
|
for i in 0..n {
|
|
match out.last_mut() {
|
|
Some((_, len)) if !cuts.starts(i as i64, *len, min) => *len += 1,
|
|
_ => out.push((i, 1)),
|
|
}
|
|
}
|
|
out
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn a_cut_starts_a_segment_unless_the_one_before_is_short() {
|
|
let c = Cuts::default();
|
|
c.find(0, [0], true);
|
|
c.find(40, [0, 40], false);
|
|
c.find(50, [], true);
|
|
c.find(70, [10], false);
|
|
assert_eq!(c.all(), vec![40, 50]);
|
|
// 0..40 is long enough, 40..50 isn't: the cut at 50 is passed over
|
|
assert_eq!(segments(90, &c, 30), vec![(0, 40), (40, 50)]);
|
|
assert_eq!(segments(90, &c, 5), vec![(0, 40), (40, 10), (50, 40)]);
|
|
assert_eq!(segments(30, &Cuts::default(), 30), vec![(0, 30)]);
|
|
}
|
|
}
|