Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

refactor: the Scopes pane and its GPU counting are gone

Jareer616d8fa0c202
diff --git a/src/crates/concat-host/src/preview.rs b/src/crates/concat-host/src/preview.rs
index 31fc9b5c..ab36f685 100644
--- a/src/crates/concat-host/src/preview.rs
+++ b/src/crates/concat-host/src/preview.rs
@@ -81,11 +81,6 @@ struct PlanEntry {
#[cfg(feature = "gpu")]
pub use concat_render::wgpu;
-/// The scopes the monitor counts as it draws; see
-/// [`Monitor::texture_of_scoped`].
-#[cfg(feature = "gpu")]
-pub use concat_render::scopes;
-
impl Default for Monitor {
fn default() -> Self {
Self::new()
@@ -199,20 +194,6 @@ impl Monitor {
&self,
sources: &concat_export::PreviewSources,
spec: FrameSpec,
- ) -> Result<wgpu::Texture, String> {
- self.texture_of_scoped(sources, spec, None)
- }
-
- /// [`Monitor::texture_of`], with `scope` counted from the frame's light
- /// as it is drawn - a packaged transition's frame goes uncounted - for
- /// [`Monitor::take_scope`] to hand over once its counts are back. The
- /// same one thread, for the same reason.
- #[cfg(feature = "gpu")]
- pub fn texture_of_scoped(
- &self,
- sources: &concat_export::PreviewSources,
- spec: FrameSpec,
- scope: Option<concat_render::ScopeKind>,
) -> Result<wgpu::Texture, String> {
let gpu = self
.gpu
@@ -236,20 +217,13 @@ impl Monitor {
));
plan.output = sources.plan().output;
return gpu
- .render_texture_scoped(&plan, scope)
+ .render_texture(&plan)
.ok_or_else(|| "the GPU device was lost".to_owned());
}
- gpu.render_texture_scoped(sources.plan(), scope)
+ gpu.render_texture(sources.plan())
.ok_or_else(|| "the GPU device was lost".to_owned())
}
- /// The last scope [`Monitor::texture_of_scoped`] counted, once its
- /// counts are back; never waits. From the device's thread.
- #[cfg(feature = "gpu")]
- pub fn take_scope(&self) -> Option<concat_render::ScopeData> {
- self.gpu.as_ref()?.lock().ok()?.take_scope()
- }
-
/// The plan for this clip list at this size and rate: the kept one
/// when it was built for the same list - the same allocation, or an
/// equal one - and a fresh one otherwise, kept in its place.
diff --git a/src/crates/concat-render/src/gpu.rs b/src/crates/concat-render/src/gpu.rs
index 669748a0..2cf1f6f2 100644
--- a/src/crates/concat-render/src/gpu.rs
+++ b/src/crates/concat-render/src/gpu.rs
@@ -29,7 +29,6 @@
//! monitor with no copy anywhere.
use std::collections::HashMap;
-use std::sync::Arc;
use concat_core::frame::Frame;
use concat_core::shader::{Lut, RevealMap, ShaderPass, TransitionPass};
@@ -311,102 +310,6 @@ fn to_sdr(nits: vec3<f32>) -> vec3<f32> {
}
"#;
-/// The scopes' counting (see `crate::scopes`): every pixel of the working
-/// canvas, its light as it stands, added to the bins of the scope asked
-/// for. A level is the display encoding on an SDR timeline and PQ's signal
-/// for the nits on an HDR one; `TONE_MAP` is appended for `pq_signal`.
-const SCOPE_SHADER: &str = r#"
-struct Scope {
- kind: u32,
- hdr: u32,
- width: u32,
- height: u32,
-}
-
-@group(0) @binding(0) var picture: texture_2d<f32>;
-@group(0) @binding(1) var<storage, read_write> bins: array<atomic<u32>>;
-@group(0) @binding(2) var<uniform> scope: Scope;
-
-const COLUMNS: u32 = 256u;
-const LEVELS: u32 = 256u;
-const LUMA: vec3<f32> = vec3<f32>(0.2126, 0.7152, 0.0722);
-
-fn encoded(light: vec3<f32>) -> vec3<f32> {
- if (scope.hdr == 1u) {
- let nits = max(light, vec3<f32>(0.0)) * 203.0;
- return vec3<f32>(pq_signal(nits.r), pq_signal(nits.g), pq_signal(nits.b));
- }
- return pow(clamp(light, vec3<f32>(0.0), vec3<f32>(1.0)), vec3<f32>(1.0 / 2.4));
-}
-
-// Luma as the scale reads it: of the encoded values on SDR (Y'), of the
-// light itself in nits on HDR.
-fn luma_of(light: vec3<f32>, e: vec3<f32>) -> f32 {
- if (scope.hdr == 1u) {
- return pq_signal(max(dot(light, LUMA), 0.0) * 203.0);
- }
- return dot(e, LUMA);
-}
-
-fn level_of(value: f32) -> u32 {
- return min(u32(clamp(value, 0.0, 1.0) * f32(LEVELS - 1u) + 0.5), LEVELS - 1u);
-}
-
-@compute @workgroup_size(16, 16)
-fn scope_main(@builtin(global_invocation_id) id: vec3<u32>) {
- if (id.x >= scope.width || id.y >= scope.height) {
- return;
- }
- let light = textureLoad(picture, vec2<i32>(id.xy), 0).rgb;
- let e = encoded(light);
- let column = min(id.x * COLUMNS / scope.width, COLUMNS - 1u);
- switch scope.kind {
- case 0u: {
- atomicAdd(&bins[column * LEVELS + level_of(luma_of(light, e))], 1u);
- }
- case 1u: {
- atomicAdd(&bins[column * LEVELS + level_of(e.r)], 1u);
- atomicAdd(&bins[(COLUMNS + column) * LEVELS + level_of(e.g)], 1u);
- atomicAdd(&bins[(2u * COLUMNS + column) * LEVELS + level_of(e.b)], 1u);
- }
- case 2u: {
- let y = dot(e, LUMA);
- let cb = (e.b - y) / 1.8556;
- let cr = (e.r - y) / 1.5748;
- atomicAdd(&bins[level_of(0.5 - cr) * LEVELS + level_of(cb + 0.5)], 1u);
- }
- default: {
- atomicAdd(&bins[level_of(e.r)], 1u);
- atomicAdd(&bins[LEVELS + level_of(e.g)], 1u);
- atomicAdd(&bins[2u * LEVELS + level_of(e.b)], 1u);
- atomicAdd(&bins[3u * LEVELS + level_of(luma_of(light, e))], 1u);
- }
- }
-}
-"#;
-
-/// The scopes' pipeline and buffers, made on first use: the bins the
-/// shader counts into, and a buffer they are copied to and read back from
-/// without the window waiting on it.
-struct ScopeGpu {
- pipeline: wgpu::ComputePipeline,
- layout: wgpu::BindGroupLayout,
- bins: wgpu::Buffer,
- readback: wgpu::Buffer,
- uniform: wgpu::Buffer,
- /// A count on its way back.
- pending: Option<PendingScope>,
-}
-
-/// A scope's counts on their way back: what they are of, and whether they
-/// have landed in the readback buffer.
-struct PendingScope {
- kind: crate::scopes::ScopeKind,
- hdr: bool,
- size: (u32, u32),
- landed: Arc<std::sync::atomic::AtomicBool>,
-}
-
/// A deep frame (sixteen bits a channel, Rec. 2020, its source's own signal)
/// copied into the working space: the upload of an HDR or wide-gamut clip.
/// One entry a signal (`concat_core::frame::Signal`): the transfer undone
@@ -642,8 +545,6 @@ pub struct WgpuCompositor {
/// The readback target an HDR frame is resolved into: sixteen-bit
/// integers, eight bytes a pixel.
deep_target: Option<Target>,
- /// The scopes' counting, made the first time a scope is asked for.
- scope: Option<ScopeGpu>,
/// The eight-bit textures frames are written into on their way to the
/// pool, one a size, each with its bind group.
staging: HashMap<(u32, u32), (wgpu::Texture, wgpu::BindGroup)>,
@@ -1218,7 +1119,6 @@ impl WgpuCompositor {
hdr_pipelines,
deliver_hdr: false,
deep_target: None,
- scope: None,
staging: HashMap::new(),
deep_pipelines,
deep_layout,
@@ -1603,18 +1503,6 @@ impl WgpuCompositor {
/// is dead; the caller then falls back to [`Compositor::render`] on a
/// CPU compositor.
pub fn render_texture(&mut self, plan: &FramePlan) -> Option<wgpu::Texture> {
- self.render_texture_scoped(plan, None)
- }
-
- /// [`WgpuCompositor::render_texture`], and `scope` counted from the
- /// frame's light in the same submission - unless the last count is
- /// still on its way back, when this frame goes uncounted rather than
- /// wait for it. [`WgpuCompositor::take_scope`] hands the counts over.
- pub fn render_texture_scoped(
- &mut self,
- plan: &FramePlan,
- scope: Option<crate::scopes::ScopeKind>,
- ) -> Option<wgpu::Texture> {
if self.dead {
return None;
}
@@ -1625,215 +1513,11 @@ impl WgpuCompositor {
let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
let mut encoder = self.encode(&canvas_view, &canvas_texture, &draws, wgpu::Color::BLACK);
self.resolve(&mut encoder, (plan.width, plan.height), canvas, &view);
- let counted = scope.and_then(|kind| {
- self.count_scope(&mut encoder, &canvas_view, kind, (plan.width, plan.height))
- });
self.queue.submit([encoder.finish()]);
- if let Some(size) = counted {
- self.read_scope(size);
- }
self.retire();
Some(texture)
}
- /// Records `kind` counted over `canvas`, `size` pixels, and its copy
- /// into the readback buffer: the size of the copy when it was recorded,
- /// none while a count is still on its way back.
- fn count_scope(
- &mut self,
- encoder: &mut wgpu::CommandEncoder,
- canvas: &wgpu::TextureView,
- kind: crate::scopes::ScopeKind,
- size: (u32, u32),
- ) -> Option<u64> {
- if self
- .scope
- .as_ref()
- .is_some_and(|scope| scope.pending.is_some())
- {
- return None;
- }
- let hdr = self.output != concat_core::frame::Signal::Sdr;
- let scope = self.scope.get_or_insert_with(|| {
- let largest = (crate::scopes::ScopeKind::Parade.bins() * 4) as u64;
- let module = self
- .device
- .create_shader_module(wgpu::ShaderModuleDescriptor {
- label: Some("concat scopes"),
- source: wgpu::ShaderSource::Wgsl(format!("{SCOPE_SHADER}{TONE_MAP}").into()),
- });
- let layout = self
- .device
- .create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
- label: Some("concat scopes"),
- entries: &[
- wgpu::BindGroupLayoutEntry {
- binding: 0,
- visibility: wgpu::ShaderStages::COMPUTE,
- ty: wgpu::BindingType::Texture {
- sample_type: wgpu::TextureSampleType::Float { filterable: false },
- view_dimension: wgpu::TextureViewDimension::D2,
- multisampled: false,
- },
- count: None,
- },
- wgpu::BindGroupLayoutEntry {
- binding: 1,
- visibility: wgpu::ShaderStages::COMPUTE,
- ty: wgpu::BindingType::Buffer {
- ty: wgpu::BufferBindingType::Storage { read_only: false },
- has_dynamic_offset: false,
- min_binding_size: None,
- },
- count: None,
- },
- wgpu::BindGroupLayoutEntry {
- binding: 2,
- visibility: wgpu::ShaderStages::COMPUTE,
- ty: wgpu::BindingType::Buffer {
- ty: wgpu::BufferBindingType::Uniform,
- has_dynamic_offset: false,
- min_binding_size: None,
- },
- count: None,
- },
- ],
- });
- let pipeline_layout =
- self.device
- .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
- label: Some("concat scopes"),
- bind_group_layouts: &[Some(&layout)],
- immediate_size: 0,
- });
- let pipeline = self
- .device
- .create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
- label: Some("concat scopes"),
- layout: Some(&pipeline_layout),
- module: &module,
- entry_point: Some("scope_main"),
- compilation_options: Default::default(),
- cache: None,
- });
- let buffer = |label, usage| {
- self.device.create_buffer(&wgpu::BufferDescriptor {
- label: Some(label),
- size: largest,
- usage,
- mapped_at_creation: false,
- })
- };
- ScopeGpu {
- pipeline,
- layout,
- bins: buffer(
- "concat scope bins",
- wgpu::BufferUsages::STORAGE
- | wgpu::BufferUsages::COPY_SRC
- | wgpu::BufferUsages::COPY_DST,
- ),
- readback: buffer(
- "concat scope readback",
- wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST,
- ),
- uniform: self.device.create_buffer(&wgpu::BufferDescriptor {
- label: Some("concat scope"),
- size: 16,
- usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
- mapped_at_creation: false,
- }),
- pending: None,
- }
- });
- let bytes = (kind.bins() * 4) as u64;
- let words = [kind.index(), u32::from(hdr), size.0, size.1];
- let uniform: Vec<u8> = words.iter().flat_map(|word| word.to_le_bytes()).collect();
- self.queue.write_buffer(&scope.uniform, 0, &uniform);
- let group = self.device.create_bind_group(&wgpu::BindGroupDescriptor {
- label: Some("concat scopes"),
- layout: &scope.layout,
- entries: &[
- wgpu::BindGroupEntry {
- binding: 0,
- resource: wgpu::BindingResource::TextureView(canvas),
- },
- wgpu::BindGroupEntry {
- binding: 1,
- resource: scope.bins.as_entire_binding(),
- },
- wgpu::BindGroupEntry {
- binding: 2,
- resource: scope.uniform.as_entire_binding(),
- },
- ],
- });
- encoder.clear_buffer(&scope.bins, 0, Some(bytes));
- {
- let mut pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor {
- label: Some("concat scopes"),
- timestamp_writes: None,
- });
- pass.set_pipeline(&scope.pipeline);
- pass.set_bind_group(0, &group, &[]);
- pass.dispatch_workgroups(size.0.div_ceil(16), size.1.div_ceil(16), 1);
- }
- encoder.copy_buffer_to_buffer(&scope.bins, 0, &scope.readback, 0, bytes);
- scope.pending = Some(PendingScope {
- kind,
- hdr,
- size,
- landed: Arc::new(std::sync::atomic::AtomicBool::new(false)),
- });
- Some(bytes)
- }
-
- /// Asks for the counts just submitted to be mapped, without waiting.
- fn read_scope(&mut self, bytes: u64) {
- let Some(scope) = self.scope.as_ref() else {
- return;
- };
- let Some(pending) = scope.pending.as_ref() else {
- return;
- };
- let landed = Arc::clone(&pending.landed);
- scope
- .readback
- .slice(..bytes)
- .map_async(wgpu::MapMode::Read, move |result| {
- if result.is_ok() {
- landed.store(true, std::sync::atomic::Ordering::Release);
- }
- });
- }
-
- /// The last scope counted, once its counts have come back; none while
- /// they are on their way, or when nothing was asked for. Never waits.
- pub fn take_scope(&mut self) -> Option<crate::scopes::ScopeData> {
- let _ = self.device.poll(wgpu::PollType::Poll);
- let scope = self.scope.as_mut()?;
- let pending = scope.pending.as_ref()?;
- if !pending.landed.load(std::sync::atomic::Ordering::Acquire) {
- return None;
- }
- let (kind, hdr, size) = (pending.kind, pending.hdr, pending.size);
- let bytes = (kind.bins() * 4) as u64;
- let counts = {
- let data = scope.readback.slice(..bytes).get_mapped_range().ok()?;
- data.chunks_exact(4)
- .map(|word| u32::from_le_bytes([word[0], word[1], word[2], word[3]]))
- .collect()
- };
- scope.readback.unmap();
- scope.pending = None;
- Some(crate::scopes::ScopeData {
- kind,
- hdr,
- size,
- counts,
- })
- }
-
/// Runs `pass` once over a sixteen-pixel-square picture and waits at
/// most `timeout` for the device: what a community package has to
/// survive before it is enabled. A pass the driver refuses is an
diff --git a/src/crates/concat-render/src/gpu/tests.rs b/src/crates/concat-render/src/gpu/tests.rs
index ea959cc6..7a831b1e 100644
--- a/src/crates/concat-render/src/gpu/tests.rs
+++ b/src/crates/concat-render/src/gpu/tests.rs
@@ -995,94 +995,6 @@ fn an_hdr_timeline_is_delivered_as_its_signal() {
assert_eq!(sdr.depth(), Depth::Eight, "an SDR timeline stays SDR");
}
-/// `kind` counted over `plan` as the monitor draws it, once the counts
-/// have come back.
-fn scoped(gpu: &mut WgpuCompositor, plan: &FramePlan, kind: crate::ScopeKind) -> crate::ScopeData {
- gpu.render_texture_scoped(plan, Some(kind)).expect("draws");
- for _ in 0..200 {
- if let Some(data) = gpu.take_scope() {
- return data;
- }
- let _ = gpu.device.poll(wgpu::PollType::wait_indefinitely());
- }
- panic!("the scope never came back");
-}
-
-/// The scopes count the monitor's picture where it is drawn: a flat grey
-/// is one level in every column it covers, at its display level on an SDR
-/// timeline; an HDR timeline's HLG peak sits at 1000 nits on PQ's scale;
-/// a histogram counts every pixel once a channel; pure red falls where the
-/// vectorscope's red target is.
-#[test]
-fn the_scopes_count_the_picture() {
- use crate::ScopeKind;
- use crate::scopes::{COLUMNS, LEVELS};
- use concat_core::frame::Signal;
- let Some(mut gpu) = gpu() else { return };
- let (width, height) = (64u32, 32u32);
- let grey = plan(
- width,
- height,
- vec![layer(solid(width, height, [128, 128, 128, 255]))],
- );
- let waveform = scoped(&mut gpu, &grey, ScopeKind::Waveform);
- assert_eq!(waveform.counts.iter().sum::<u32>(), width * height);
- let level = |counts: &[u32]| counts.iter().position(|count| *count > 0);
- for column in (0..COLUMNS).step_by((COLUMNS / width) as usize) {
- let start = (column * LEVELS) as usize;
- assert_eq!(
- level(&waveform.counts[start..start + LEVELS as usize]),
- Some(128),
- "column {column}"
- );
- assert_eq!(waveform.counts[start + 128], height);
- }
-
- let peak = FramePlan {
- output: Signal::Hlg,
- ..plan(
- width,
- height,
- vec![layer(deep(width, height, 1.0, Signal::Hlg))],
- )
- };
- let hdr = scoped(&mut gpu, &peak, ScopeKind::Waveform);
- assert!(hdr.hdr);
- let at = level(&hdr.counts[..LEVELS as usize]).expect("counted");
- let want = (crate::scopes::pq(1000.0) * 255.0).round() as usize;
- assert!(
- at.abs_diff(want) <= 1,
- "the HLG peak at level {at}, not {want}"
- );
-
- let histogram = scoped(&mut gpu, &grey, ScopeKind::Histogram);
- for channel in 0..4 {
- let start = channel * LEVELS as usize;
- assert_eq!(
- histogram.counts[start..start + LEVELS as usize]
- .iter()
- .sum::<u32>(),
- width * height,
- "channel {channel}"
- );
- }
-
- let red = plan(
- width,
- height,
- vec![layer(solid(width, height, [255, 0, 0, 255]))],
- );
- let vectorscope = scoped(&mut gpu, &red, ScopeKind::Vectorscope);
- let at = vectorscope
- .counts
- .iter()
- .position(|count| *count > 0)
- .expect("counted");
- let cb = (0.0 - 0.2126) / 1.8556 + 0.5f32;
- assert_eq!(at as u32 % LEVELS, (cb * 255.0 + 0.5) as u32, "Cb of red");
- assert_eq!(at as u32 / LEVELS, 0, "Cr of red, at the top");
-}
-
/// A pass of a format 2 package - the scene-linear contract - with `body`
/// as its shader and no knobs, at `intensity`.
fn scene_linear(id: &str, body: &str, intensity: f32) -> ShaderPass {
diff --git a/src/crates/concat-render/src/lib.rs b/src/crates/concat-render/src/lib.rs
index a44c0e05..109e09e4 100644
--- a/src/crates/concat-render/src/lib.rs
+++ b/src/crates/concat-render/src/lib.rs
@@ -24,7 +24,6 @@ pub mod metrics;
pub mod plan;
#[cfg(test)]
mod reference;
-pub mod scopes;
#[cfg(test)]
mod transitions;
@@ -37,6 +36,5 @@ pub use plan::{
};
#[cfg(test)]
pub(crate) use reference::CpuCompositor;
-pub use scopes::{ScopeData, ScopeKind};
/// The wgpu the compositor is built on, for callers that share its device.
pub use wgpu;
diff --git a/src/crates/concat-render/src/scopes.rs b/src/crates/concat-render/src/scopes.rs
deleted file mode 100644
index 00d5e90a..00000000
--- a/src/crates/concat-render/src/scopes.rs
+++ /dev/null
@@ -1,363 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-or-later
-// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
-
-//! The scopes: what the monitor's picture holds, counted on the GPU from
-//! the working space - its light before anything is clipped - and drawn
-//! here from the counts.
-//!
-//! On an SDR timeline a level is the display encoding, 0 to 100 %, as a
-//! Rec. 709 waveform reads. On an HDR one it is the light in nits on PQ's
-//! scale, so 100 nits, SDR white at 203 and a 1000-nit highlight each have
-//! their place however far apart they are (`WgpuCompositor::render_texture_scoped`
-//! counts; [`ScopeData::draw`] draws).
-
-/// Which scope.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum ScopeKind {
- /// Luma across the picture: a column of levels for each column of it.
- Waveform,
- /// Red, green and blue as three waveforms side by side.
- Parade,
- /// The colour of every pixel as a point on the Cb-Cr plane.
- Vectorscope,
- /// How many pixels hold each level, a curve a channel.
- Histogram,
-}
-
-/// The levels a waveform, a parade or a histogram tells apart, and the side
-/// of the vectorscope's plane.
-pub const LEVELS: u32 = 256;
-
-/// The columns a waveform counts the picture in, and a parade each channel.
-pub const COLUMNS: u32 = 256;
-
-impl ScopeKind {
- /// Every kind, in the order the pane offers them.
- pub const ALL: [ScopeKind; 4] = [
- ScopeKind::Waveform,
- ScopeKind::Parade,
- ScopeKind::Vectorscope,
- ScopeKind::Histogram,
- ];
-
- /// How many counts the scope takes.
- pub const fn bins(self) -> usize {
- (match self {
- ScopeKind::Waveform => COLUMNS * LEVELS,
- ScopeKind::Parade => 3 * COLUMNS * LEVELS,
- ScopeKind::Vectorscope => LEVELS * LEVELS,
- ScopeKind::Histogram => 4 * LEVELS,
- }) as usize
- }
-
- /// The number the counting shader switches on.
- pub(crate) const fn index(self) -> u32 {
- match self {
- ScopeKind::Waveform => 0,
- ScopeKind::Parade => 1,
- ScopeKind::Vectorscope => 2,
- ScopeKind::Histogram => 3,
- }
- }
-}
-
-/// One frame's counts for a scope.
-#[derive(Clone, Debug, PartialEq)]
-pub struct ScopeData {
- /// Which scope the counts are for.
- pub kind: ScopeKind,
- /// The timeline is HDR: a level is nits on PQ's scale, not the
- /// display encoding.
- pub hdr: bool,
- /// The picture counted, in pixels.
- pub size: (u32, u32),
- /// The counts, laid out as the kind says: a waveform column by column,
- /// each `LEVELS` from black up; a parade the same for red, green and
- /// blue in turn; a vectorscope row by row from Cr's top; a histogram
- /// red, green, blue and luma.
- pub counts: Vec<u32>,
-}
-
-impl ScopeData {
- /// The scope as a picture: its width, its height, and RGBA, eight bits
- /// a channel, opaque, black where nothing fell.
- pub fn draw(&self) -> (u32, u32, Vec<u8>) {
- let pixels = (self.size.0 * self.size.1).max(1) as f32;
- match self.kind {
- ScopeKind::Waveform => {
- let mut image = Image::new(COLUMNS, LEVELS);
- self.traces(&mut image, 0, 0, [0.62, 1.0, 0.70], pixels);
- image.finish()
- }
- ScopeKind::Parade => {
- let mut image = Image::new(3 * COLUMNS, LEVELS);
- for (channel, tint) in [[1.0, 0.36, 0.36], [0.36, 1.0, 0.46], [0.42, 0.56, 1.0]]
- .into_iter()
- .enumerate()
- {
- self.traces(
- &mut image,
- channel * (COLUMNS * LEVELS) as usize,
- channel as u32 * COLUMNS,
- tint,
- pixels,
- );
- }
- image.finish()
- }
- ScopeKind::Vectorscope => {
- let mut image = Image::new(LEVELS, LEVELS);
- // A point the square root of its share: a field of one
- // colour is a bright spot, a scatter of many still shows.
- let scale = (LEVELS * LEVELS) as f32 / 256.0 / pixels;
- for (at, count) in self.counts.iter().enumerate() {
- let level = ((*count as f32 * scale).sqrt()).min(1.0);
- let (x, y) = (at as u32 % LEVELS, at as u32 / LEVELS);
- image.add(x, y, [level * 0.9, level, level * 0.9]);
- }
- for target in TARGETS {
- let (x, y) = plane(target);
- image.square(x, y, 3, [0.55, 0.42, 0.20]);
- }
- image.cross(LEVELS / 2, LEVELS / 2, [0.35, 0.35, 0.35]);
- image.finish()
- }
- ScopeKind::Histogram => {
- const HEIGHT: u32 = 128;
- let mut image = Image::new(LEVELS, HEIGHT);
- // Scaled to the tallest bar short of the two ends, where a
- // clipped or a black picture piles up and would flatten the
- // rest.
- let tallest = (0..4)
- .flat_map(|channel| {
- let start = channel * LEVELS as usize;
- self.counts[start + 1..start + LEVELS as usize - 1]
- .iter()
- .copied()
- })
- .max()
- .unwrap_or(0)
- .max(1) as f32;
- for (channel, tint) in [[0.9, 0.25, 0.25], [0.25, 0.85, 0.35], [0.30, 0.45, 1.0]]
- .into_iter()
- .enumerate()
- {
- for level in 0..LEVELS {
- let count = self.counts[channel * LEVELS as usize + level as usize];
- let bar = ((count as f32 / tallest).min(1.0) * HEIGHT as f32) as u32;
- for y in HEIGHT - bar..HEIGHT {
- image.add(level, y, tint.map(|c| c * 0.6));
- }
- }
- }
- let mut previous: Option<u32> = None;
- for level in 0..LEVELS {
- let count = self.counts[3 * LEVELS as usize + level as usize];
- let top = HEIGHT
- - 1
- - ((count as f32 / tallest).min(1.0) * (HEIGHT - 1) as f32) as u32;
- let from = previous.unwrap_or(top);
- for y in from.min(top)..=from.max(top) {
- image.set(level, y, [0.9, 0.9, 0.9]);
- }
- previous = Some(top);
- }
- image.finish()
- }
- }
- }
-
- /// A waveform's columns from `start` in the counts, drawn from `left`
- /// in the image in `tint`: each level as bright as the square root of
- /// the share of its column it holds.
- fn traces(&self, image: &mut Image, start: usize, left: u32, tint: [f32; 3], pixels: f32) {
- let per_column = (pixels / COLUMNS as f32).max(1.0);
- let scale = LEVELS as f32 / 24.0 / per_column;
- for column in 0..COLUMNS {
- for level in 0..LEVELS {
- let count = self.counts[start + (column * LEVELS + level) as usize];
- if count == 0 {
- continue;
- }
- let bright = ((count as f32 * scale).sqrt()).clamp(0.12, 1.0);
- image.add(left + column, LEVELS - 1 - level, tint.map(|c| c * bright));
- }
- }
- }
-}
-
-/// The colours of 75 % bars, which a vectorscope's targets mark: red,
-/// magenta, blue, cyan, green, yellow, as display-encoded RGB.
-const TARGETS: [[f32; 3]; 6] = [
- [0.75, 0.0, 0.0],
- [0.75, 0.0, 0.75],
- [0.0, 0.0, 0.75],
- [0.0, 0.75, 0.75],
- [0.0, 0.75, 0.0],
- [0.75, 0.75, 0.0],
-];
-
-/// Where an encoded colour falls on the vectorscope's plane, as the
-/// counting shader places it.
-fn plane(rgb: [f32; 3]) -> (u32, u32) {
- let y = 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2];
- let cb = (rgb[2] - y) / 1.8556;
- let cr = (rgb[0] - y) / 1.5748;
- (level_of(cb + 0.5), level_of(0.5 - cr))
-}
-
-/// The level a value `0..1` counts under, as the shader rounds it.
-fn level_of(value: f32) -> u32 {
- ((value.clamp(0.0, 1.0) * (LEVELS - 1) as f32 + 0.5) as u32).min(LEVELS - 1)
-}
-
-/// SMPTE ST 2084's signal for `nits`: where a level sits on an HDR scope.
-pub fn pq(nits: f64) -> f64 {
- let (m1, m2) = (0.159_301_757_812_5, 78.843_75);
- let (c1, c2, c3) = (0.835_937_5, 18.851_562_5, 18.687_5);
- let y = (nits / 10_000.0).clamp(0.0, 1.0).powf(m1);
- ((c1 + c2 * y) / (1.0 + c3 * y)).powf(m2)
-}
-
-/// The scale's marks: where each sits, `0..1` from the bottom of a
-/// waveform or a parade or from the left of a histogram, and what it
-/// reads - a share of the display level on an SDR timeline, nits on an
-/// HDR one. None on a vectorscope, whose targets are drawn in it.
-pub fn marks(kind: ScopeKind, hdr: bool) -> Vec<(f32, String)> {
- if kind == ScopeKind::Vectorscope {
- return Vec::new();
- }
- if hdr {
- [0.0, 1.0, 10.0, 100.0, 203.0, 1000.0, 4000.0]
- .into_iter()
- .map(|nits| (pq(nits) as f32, format!("{nits}")))
- .collect()
- } else {
- [0, 25, 50, 75, 100]
- .into_iter()
- .map(|share| (share as f32 / 100.0, format!("{share}")))
- .collect()
- }
-}
-
-/// An RGB picture being drawn, in floats, added to where traces cross.
-struct Image {
- width: u32,
- height: u32,
- pixels: Vec<[f32; 3]>,
-}
-
-impl Image {
- fn new(width: u32, height: u32) -> Self {
- Image {
- width,
- height,
- pixels: vec![[0.0; 3]; (width * height) as usize],
- }
- }
-
- fn add(&mut self, x: u32, y: u32, rgb: [f32; 3]) {
- if x < self.width && y < self.height {
- let pixel = &mut self.pixels[(y * self.width + x) as usize];
- for (into, value) in pixel.iter_mut().zip(rgb) {
- *into += value;
- }
- }
- }
-
- fn set(&mut self, x: u32, y: u32, rgb: [f32; 3]) {
- if x < self.width && y < self.height {
- self.pixels[(y * self.width + x) as usize] = rgb;
- }
- }
-
- /// The outline of a square `2 * half + 1` across about `(x, y)`.
- fn square(&mut self, x: u32, y: u32, half: u32, rgb: [f32; 3]) {
- let (left, right) = (x.saturating_sub(half), x + half);
- let (top, bottom) = (y.saturating_sub(half), y + half);
- for across in left..=right {
- self.add(across, top, rgb);
- self.add(across, bottom, rgb);
- }
- for down in top..=bottom {
- self.add(left, down, rgb);
- self.add(right, down, rgb);
- }
- }
-
- /// A small cross at `(x, y)`: the middle of the plane, colour none.
- fn cross(&mut self, x: u32, y: u32, rgb: [f32; 3]) {
- for offset in 0..9 {
- self.add(x + offset - 4, y, rgb);
- self.add(x, y + offset - 4, rgb);
- }
- }
-
- fn finish(self) -> (u32, u32, Vec<u8>) {
- let bytes = self
- .pixels
- .iter()
- .flat_map(|[r, g, b]| {
- let byte = |value: f32| (value.clamp(0.0, 1.0) * 255.0).round() as u8;
- [byte(*r), byte(*g), byte(*b), 255]
- })
- .collect();
- (self.width, self.height, bytes)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- /// A waveform of a flat picture is one line across at its level; a
- /// parade is three; every kind draws at its own size, opaque.
- #[test]
- fn a_flat_picture_draws_a_line() {
- let mut counts = vec![0u32; ScopeKind::Waveform.bins()];
- for column in 0..COLUMNS {
- counts[(column * LEVELS + 128) as usize] = 100;
- }
- let waveform = ScopeData {
- kind: ScopeKind::Waveform,
- hdr: false,
- size: (256, 100),
- counts,
- };
- let (width, height, pixels) = waveform.draw();
- assert_eq!((width, height), (COLUMNS, LEVELS));
- let at = |x: u32, y: u32| pixels[((y * width + x) * 4 + 1) as usize];
- assert!(at(10, LEVELS - 1 - 128) > 200, "the line is bright");
- assert_eq!(at(10, 10), 0, "the rest is black");
- assert!(pixels.chunks_exact(4).all(|pixel| pixel[3] == 255));
- for kind in ScopeKind::ALL {
- let data = ScopeData {
- kind,
- hdr: true,
- size: (64, 36),
- counts: vec![3; kind.bins()],
- };
- let (width, height, pixels) = data.draw();
- assert_eq!(pixels.len(), (width * height * 4) as usize, "{kind:?}");
- }
- }
-
- /// The marks read the display level on SDR and nits on HDR, where SDR
- /// white sits at 58 % of PQ's scale and a 1000-nit highlight at 75 %.
- #[test]
- fn the_scale_reads_shares_or_nits() {
- let sdr = marks(ScopeKind::Waveform, false);
- assert_eq!(sdr.first(), Some(&(0.0, "0".to_owned())));
- assert_eq!(sdr.last(), Some(&(1.0, "100".to_owned())));
- let hdr = marks(ScopeKind::Parade, true);
- let at = |label: &str| {
- hdr.iter()
- .find(|(_, text)| text == label)
- .map(|(at, _)| *at)
- };
- assert!((at("203").expect("SDR white") - 0.5807).abs() < 0.001);
- assert!((at("1000").expect("a highlight") - 0.7518).abs() < 0.001);
- assert!(marks(ScopeKind::Vectorscope, true).is_empty());
- assert_eq!(plane([0.5, 0.5, 0.5]), (level_of(0.5), level_of(0.5)));
- }
-}
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index d811aa27..d2f510ed 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "Fehlende Medien",
"relink.relinkAll": "Alle neu verknüpfen…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "Histogramm",
- "scopes.nits": "Nits",
- "scopes.parade": "Parade",
- "scopes.scopes": "Scopes",
- "scopes.vectorscope": "Vektorskop",
- "scopes.waiting": "Die Scopes lesen das Bild des Monitors: abspielen oder scrubben, um es zu messen.",
- "scopes.waveform": "Wellenform",
"settings.about": "Über",
"settings.accent": "Akzent",
"settings.address": "Adresse",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index fcb73748..808c57c8 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "Missing Media",
"relink.relinkAll": "Relink All…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "Histogram",
- "scopes.nits": "nits",
- "scopes.parade": "Parade",
- "scopes.scopes": "Scopes",
- "scopes.vectorscope": "Vectorscope",
- "scopes.waiting": "The scopes read the monitor's picture: play or scrub to count it.",
- "scopes.waveform": "Waveform",
"settings.about": "About",
"settings.accent": "Accent",
"settings.address": "Address",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index a220fa9b..5de4dbeb 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "Medios faltantes",
"relink.relinkAll": "Vincular todo…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "Histograma",
- "scopes.nits": "nits",
- "scopes.parade": "Parade",
- "scopes.scopes": "Scopes",
- "scopes.vectorscope": "Vectorscopio",
- "scopes.waiting": "Los scopes leen la imagen del monitor: reproduce o arrastra para medirla.",
- "scopes.waveform": "Forma de onda",
"settings.about": "Acerca de",
"settings.accent": "Acento",
"settings.address": "Dirección",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index b0fe4210..b3110165 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "رسانه گمشده",
"relink.relinkAll": "پیوند مجدد همه…",
"relink.selectFolderContainingMedia": "پوشه حاوی فایل رسانه‌ایها را انتخاب کنید",
- "scopes.histogram": "هیستوگرام",
- "scopes.nits": "نیت",
- "scopes.parade": "پاراد",
- "scopes.scopes": "اسکوپ‌ها",
- "scopes.vectorscope": "وکتوراسکوپ",
- "scopes.waiting": "اسکوپ‌ها تصویر مانیتور را می‌خوانند: برای اندازه‌گیری، پخش کنید یا جابه‌جا شوید.",
- "scopes.waveform": "شکل موج",
"settings.about": "درباره",
"settings.accent": "رنگ تأکید",
"settings.address": "آدرس",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index bb45730e..8ab9f326 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "Médias manquants",
"relink.relinkAll": "Tout relier…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "Histogramme",
- "scopes.nits": "nits",
- "scopes.parade": "Parade",
- "scopes.scopes": "Scopes",
- "scopes.vectorscope": "Vectorscope",
- "scopes.waiting": "Les scopes lisent l'image du moniteur : lisez ou déplacez la tête de lecture pour la mesurer.",
- "scopes.waveform": "Forme d'onde",
"settings.about": "À propos",
"settings.accent": "Accent",
"settings.address": "Adresse",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index f86600bc..3da7afa7 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "Nedostajući mediji",
"relink.relinkAll": "Ponovno poveži sve…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "Histogram",
- "scopes.nits": "nita",
- "scopes.parade": "Parada",
- "scopes.scopes": "Mjerači",
- "scopes.vectorscope": "Vektorskop",
- "scopes.waiting": "Mjerači čitaju sliku monitora: reproducirajte ili pomičite da je izmjere.",
- "scopes.waveform": "Valni oblik",
"settings.about": "O programu",
"settings.accent": "Naglasak",
"settings.address": "Adresa",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index e8792bfe..3680454f 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "Media mancanti",
"relink.relinkAll": "Ricollega tutto…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "Istogramma",
- "scopes.nits": "nit",
- "scopes.parade": "Parade",
- "scopes.scopes": "Scope",
- "scopes.vectorscope": "Vettorscopio",
- "scopes.waiting": "Gli scope leggono l'immagine del monitor: riproduci o scorri per misurarla.",
- "scopes.waveform": "Forma d'onda",
"settings.about": "Informazioni",
"settings.accent": "Accento",
"settings.address": "Indirizzo",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 4714bb0b..587a5ca9 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "メディアが見つかりません",
"relink.relinkAll": "すべて再リンク…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "ヒストグラム",
- "scopes.nits": "nit",
- "scopes.parade": "パレード",
- "scopes.scopes": "スコープ",
- "scopes.vectorscope": "ベクトルスコープ",
- "scopes.waiting": "スコープはモニターの映像を読み取ります。再生かスクラブで計測されます。",
- "scopes.waveform": "波形",
"settings.about": "情報",
"settings.accent": "アクセント",
"settings.address": "アドレス",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index f8e6ea15..3a5350ee 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "미디어 없음",
"relink.relinkAll": "모두 다시 연결…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "히스토그램",
- "scopes.nits": "니트",
- "scopes.parade": "퍼레이드",
- "scopes.scopes": "스코프",
- "scopes.vectorscope": "벡터스코프",
- "scopes.waiting": "스코프는 모니터 화면을 읽습니다. 재생하거나 스크럽하면 측정됩니다.",
- "scopes.waveform": "파형",
"settings.about": "정보",
"settings.accent": "강조색",
"settings.address": "주소",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index 02aff3cf..a2bf6bd2 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "Mídia ausente",
"relink.relinkAll": "Vincular tudo…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "Histograma",
- "scopes.nits": "nits",
- "scopes.parade": "Parade",
- "scopes.scopes": "Scopes",
- "scopes.vectorscope": "Vetorscópio",
- "scopes.waiting": "Os scopes leem a imagem do monitor: reproduza ou arraste para medi-la.",
- "scopes.waveform": "Forma de onda",
"settings.about": "Sobre",
"settings.accent": "Destaque",
"settings.address": "Endereço",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index cec2ec06..fb4b2215 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "Отсутствующие медиафайлы",
"relink.relinkAll": "Привязать все…",
"relink.selectFolderContainingMedia": "Выберите папку с медиафайлами",
- "scopes.histogram": "Гистограмма",
- "scopes.nits": "нит",
- "scopes.parade": "Парад",
- "scopes.scopes": "Скопы",
- "scopes.vectorscope": "Вектороскоп",
- "scopes.waiting": "Скопы читают изображение монитора: запустите или прокрутите, чтобы измерить.",
- "scopes.waveform": "Осциллограмма",
"settings.about": "О программе",
"settings.accent": "Акцент",
"settings.address": "Адрес",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 93379129..7ebe6110 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "Eksik medya",
"relink.relinkAll": "Tümünü yeniden bağla…",
"relink.selectFolderContainingMedia": "Select folder containing media files",
- "scopes.histogram": "Histogram",
- "scopes.nits": "nit",
- "scopes.parade": "Parade",
- "scopes.scopes": "Skoplar",
- "scopes.vectorscope": "Vektörskop",
- "scopes.waiting": "Skoplar monitörün görüntüsünü okur: ölçmek için oynatın veya kaydırın.",
- "scopes.waveform": "Dalga formu",
"settings.about": "Hakkında",
"settings.accent": "Vurgu",
"settings.address": "Adres",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 4b637c47..6ae69747 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "媒体缺失",
"relink.relinkAll": "全部重新链接…",
"relink.selectFolderContainingMedia": "选择包含媒体文件的文件夹",
- "scopes.histogram": "直方图",
- "scopes.nits": "尼特",
- "scopes.parade": "RGB 分量",
- "scopes.scopes": "示波器",
- "scopes.vectorscope": "矢量示波器",
- "scopes.waiting": "示波器读取监视器的画面:播放或拖动时进行测量。",
- "scopes.waveform": "波形图",
"settings.about": "关于",
"settings.accent": "强调色",
"settings.address": "地址",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index cee03da1..cb84db54 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -707,13 +707,6 @@
"relink.missingMedia": "媒體遺失",
"relink.relinkAll": "全部重新連結…",
"relink.selectFolderContainingMedia": "選取包含媒體檔案的資料夾",
- "scopes.histogram": "直方圖",
- "scopes.nits": "尼特",
- "scopes.parade": "RGB 分量",
- "scopes.scopes": "示波器",
- "scopes.vectorscope": "向量示波器",
- "scopes.waiting": "示波器讀取監看器的畫面:播放或拖曳時進行測量。",
- "scopes.waveform": "波形圖",
"settings.about": "關於",
"settings.accent": "強調色",
"settings.address": "位址",
diff --git a/src/crates/concat/src/dock.rs b/src/crates/concat/src/dock.rs
index d6a59106..01481a75 100644
--- a/src/crates/concat/src/dock.rs
+++ b/src/crates/concat/src/dock.rs
@@ -34,14 +34,6 @@ impl Dock {
Box::new(Dock::Leaf(kind))
}
- /// Whether any seat shows `kind`.
- pub fn holds(&self, kind: PaneKind) -> bool {
- match self {
- Dock::Leaf(leaf) => *leaf == kind,
- Dock::Split { first, second, .. } => first.holds(kind) || second.holds(kind),
- }
- }
-
/// The node a path names, following each step into the first branch or the
/// second. A path that runs past a leaf stops there, which cannot happen
/// for a path this module produced.
@@ -325,19 +317,3 @@ pub fn nearest_row(heights: &[f32], y: f32) -> i32 {
}
best
}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- /// A kind is on screen when any seat shows it, however deep the split.
- #[test]
- fn a_dock_knows_what_it_shows() {
- let mut dock = default_dock();
- assert!(dock.holds(PaneKind::Preview));
- assert!(!dock.holds(PaneKind::Scopes));
- let path = dock.leaf_path(0).expect("a first seat");
- dock.split_leaf(&path, PaneKind::Scopes, DockSide::Right);
- assert!(dock.holds(PaneKind::Scopes));
- }
-}
diff --git a/src/crates/concat/src/host.rs b/src/crates/concat/src/host.rs
index 0be6b1d0..ac2c7098 100644
--- a/src/crates/concat/src/host.rs
+++ b/src/crates/concat/src/host.rs
@@ -248,7 +248,7 @@ pub fn spawn_frame<T: Send + 'static>(
},
move |studio, app, models| {
if studio.playing && !toasted.load(Ordering::Relaxed) {
- studio.publish_frame(app, models);
+ studio.publish_frame(app);
} else {
studio.publish(app, models);
}
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index 7c9bee63..8c0abd09 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -256,8 +256,6 @@ pub fn run() -> Result<(), slint::PlatformError> {
editor.set_visual_wheels(ModelRc::from(models.visual_wheels.clone()));
editor.set_visual_curves(ModelRc::from(models.visual_curves.clone()));
editor.set_visual_colours(ModelRc::from(models.visual_colours.clone()));
- app.global::<Scopes>()
- .set_marks(ModelRc::from(models.scope_marks.clone()));
app.global::<Keyframes>()
.set_rows(ModelRc::from(models.key_rows.clone()));
app.global::<KeyEditor>()
@@ -1119,10 +1117,6 @@ pub fn run() -> Result<(), slint::PlatformError> {
editor.on_quality_changed(on_window!(|state, index: i32| {
state.handle(Msg::Monitor(MonitorMsg::QualityChanged(index)));
}));
- app.global::<Scopes>()
- .on_kind_changed(on_window!(|state, index: i32| {
- state.handle(Msg::Monitor(MonitorMsg::ScopeKind(index)));
- }));
editor.on_play_toggled(on_window!(|state| {
state.play_toggle();
}));
diff --git a/src/crates/concat/src/panes/mod.rs b/src/crates/concat/src/panes/mod.rs
index f9dc7aca..13d16385 100644
--- a/src/crates/concat/src/panes/mod.rs
+++ b/src/crates/concat/src/panes/mod.rs
@@ -69,7 +69,7 @@ pub fn activity(msg: &Msg) -> Option<Activity> {
use timeline::TimelineMsg;
match msg {
- Msg::Monitor(MonitorMsg::Frame(..) | MonitorMsg::Request | MonitorMsg::ScopePoll)
+ Msg::Monitor(MonitorMsg::Frame(..) | MonitorMsg::Request)
| Msg::Timeline(
TimelineMsg::Hovered(_)
| TimelineMsg::HoverEnded
diff --git a/src/crates/concat/src/panes/monitor.rs b/src/crates/concat/src/panes/monitor.rs
index 4f126c6d..8dded292 100644
--- a/src/crates/concat/src/panes/monitor.rs
+++ b/src/crates/concat/src/panes/monitor.rs
@@ -19,14 +19,13 @@
use std::collections::HashMap;
use std::sync::Arc;
-use concat_host::preview::{FrameSpec, scopes};
+use concat_host::preview::FrameSpec;
use concat_project::model::Project;
-use crate::host::{on_ui, spawn_detached, spawn_frame};
+use crate::host::{spawn_detached, spawn_frame};
use crate::i18n::tf;
use crate::panes::Msg;
use crate::studio::Studio;
-use crate::ui::{PaneKind, ScopeMarkData};
/// Everything that can happen to the monitor.
pub enum MonitorMsg {
@@ -40,11 +39,6 @@ pub enum MonitorMsg {
Opened,
/// The project closed: nothing to show.
Closed,
- /// The Scopes pane's control: 0 waveform, 1 parade, 2 vectorscope,
- /// 3 histogram.
- ScopeKind(i32),
- /// Look again for the scope counted with the last frame.
- ScopePoll,
}
impl std::fmt::Debug for MonitorMsg {
@@ -63,8 +57,6 @@ impl std::fmt::Debug for MonitorMsg {
Self::QualityChanged(index) => write!(f, "QualityChanged({index})"),
Self::Opened => write!(f, "Opened"),
Self::Closed => write!(f, "Closed"),
- Self::ScopeKind(index) => write!(f, "ScopeKind({index})"),
- Self::ScopePoll => write!(f, "ScopePoll"),
}
}
}
@@ -95,13 +87,6 @@ pub struct MonitorPane {
/// it does not - and the trade is the window's, not the document's,
/// so it is remembered here and not saved.
quality: HashMap<String, usize>,
- /// The scope the Scopes pane shows, by its control's index.
- pub scope_kind: usize,
- /// The last scope drawn: the picture, its scale's marks, and whether
- /// its timeline was HDR.
- pub scope: Option<(slint::Image, Vec<ScopeMarkData>, bool)>,
- /// Looks left for a scope's counts on their way back.
- scope_polls: u32,
/// When the request out now was sent.
asked: Option<std::time::Instant>,
/// How the frames of the current playback arrived.
@@ -154,36 +139,6 @@ impl Cadence {
}
impl MonitorPane {
- /// The scope counted with the last frame, drawn once its counts are
- /// back; until then, a look again in a few milliseconds, a few dozen
- /// times at most. The window never waits on the device for it.
- fn poll_scope(&mut self, studio: &mut Studio) {
- match studio.host.monitor.take_scope() {
- Some(data) => {
- self.scope_polls = 0;
- let (width, height, pixels) = data.draw();
- let buffer = slint::SharedPixelBuffer::<slint::Rgba8Pixel>::clone_from_slice(
- &pixels, width, height,
- );
- let marks = scopes::marks(data.kind, data.hdr)
- .into_iter()
- .map(|(at, label)| ScopeMarkData {
- at,
- label: label.into(),
- })
- .collect();
- self.scope = Some((slint::Image::from_rgba8(buffer), marks, data.hdr));
- }
- None if self.scope_polls > 0 => {
- self.scope_polls -= 1;
- slint::Timer::single_shot(std::time::Duration::from_millis(8), || {
- on_ui(|studio, _, _| studio.handle(Msg::Monitor(MonitorMsg::ScopePoll)));
- });
- }
- None => {}
- }
- }
-
/// Applies one message. The studio is the rest of the window; while
/// this runs the studio's copy of the pane is a blank it must not read.
pub fn update(&mut self, msg: MonitorMsg, studio: &mut Studio) {
@@ -199,12 +154,6 @@ impl MonitorPane {
} else if !spec.moving {
self.cadence.report(fps);
}
- // A Scopes pane on screen has the frame counted as it is
- // drawn.
- let scope = studio
- .dock
- .holds(PaneKind::Scopes)
- .then(|| scopes::ScopeKind::ALL[self.scope_kind.min(3)]);
let picture = match result {
// Drawn here and not on the worker: this is the event
// loop, the one thread the window's renderer submits
@@ -213,7 +162,7 @@ impl MonitorPane {
Ok(Picture::Sources(sources)) => studio
.host
.monitor
- .texture_of_scoped(&sources, spec, scope)
+ .texture_of(&sources, spec)
.and_then(|texture| {
slint::Image::try_from(texture)
.map_err(|error| format!("preview texture: {error}"))
@@ -237,20 +186,10 @@ impl MonitorPane {
}
}
}
- if scope.is_some() {
- self.scope_polls = 60;
- self.poll_scope(studio);
- }
if self.wanted {
self.request(studio);
}
}
- MonitorMsg::ScopeKind(index) => {
- self.scope_kind = (index.max(0) as usize).min(3);
- self.scope = None;
- self.request(studio);
- }
- MonitorMsg::ScopePoll => self.poll_scope(studio),
MonitorMsg::QualityChanged(index) => {
let id = studio.project().active_timeline_id.clone();
self.quality.insert(id, (index.max(0) as usize).min(2));
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 764e9a39..2786afed 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -576,8 +576,6 @@ pub struct Models {
pub visual_curves: Rc<VecModel<CurveGroupData>>,
/// The picture's chain's colour knobs, a row each.
pub visual_colours: Rc<VecModel<ColourKnobData>>,
- /// The Scopes pane's scale.
- pub scope_marks: Rc<VecModel<ScopeMarkData>>,
/// A link's wheels and curves, and a curve's points, by the link - -1
/// the colour panel - and the curve's key: kept like the rest, so a
/// wheel or a point being dragged is not dropped when it is published
@@ -648,7 +646,6 @@ impl Models {
adjust_curves: Rc::new(VecModel::default()),
visual_wheels: Rc::new(VecModel::default()),
visual_colours: Rc::new(VecModel::default()),
- scope_marks: Rc::new(VecModel::default()),
visual_curves: Rc::new(VecModel::default()),
link_wheels: RefCell::new(HashMap::new()),
link_curves: RefCell::new(HashMap::new()),
@@ -7449,22 +7446,11 @@ impl Studio {
}
}
- /// The monitor's picture and the scope counted from it, alone: what a
- /// frame arriving during playback changes.
- pub fn publish_frame(&self, app: &App, models: &Models) {
+ /// The monitor's picture alone: what a frame arriving during playback
+ /// changes.
+ pub fn publish_frame(&self, app: &App) {
app.global::<Editor>()
.set_preview_frame(self.monitor.image.clone());
- let scopes = app.global::<Scopes>();
- scopes.set_kind(self.monitor.scope_kind as i32);
- match &self.monitor.scope {
- Some((picture, marks, hdr)) => {
- scopes.set_picture(picture.clone());
- sync(&models.scope_marks, marks.clone());
- scopes.set_hdr(*hdr);
- scopes.set_ready(true);
- }
- None => scopes.set_ready(false),
- }
}
/// The timeline and the readouts that follow it: what runs on every
@@ -7589,7 +7575,7 @@ impl Studio {
editor.set_preview_duration(self.duration());
editor.set_playhead_free(!self.prefs.playhead_stops_at_end);
editor.set_playing(self.playing);
- self.publish_frame(app, models);
+ self.publish_frame(app);
sync(&models.stage, self.stage_items());
sync(&models.guides, self.stage_guides.clone());
let (path, width, erase) = self.stroke_overlay();
diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slint
index d03c7d46..71e81522 100644
--- a/src/crates/concat/ui/app.slint
+++ b/src/crates/concat/ui/app.slint
@@ -49,7 +49,6 @@ import {
// Re-exported so main.rs can reach the globals and the struct.
import { KeyEditor, KeyMarkData, KeyRowData } from "workspace/keyframes-pane.slint";
-import { ScopeMarkData, Scopes } from "workspace/scopes-pane.slint";
export {
Curves, Fmt, Focus, Payload, Theme, Bezier, Editor, I18n,
@@ -57,7 +56,7 @@ export {
DockDivider, DockSide, PaneKind, SeatBox,
EffectData, MediaFilter, MediaItemData, MediaKind, TextPresetData,
ClipData, ClipField, ClipKeyData, ClipKind, ClipTextField, DropData, Keyframes,
- KeyEditor, KeyMarkData, KeyRowData, ScopeMarkData, Scopes,
+ KeyEditor, KeyMarkData, KeyRowData,
SelectedClipData, SelectedTransitionData, StageGuideData, StageItemData, TextAlignment, TimelineTabData,
TimelineTool, TrackData, TrackSize, MenuItemData, MenuRow, ExportData, ExportPhase, ModelData, SettingsData,
ChipOption, RecentProjectData, StartData, SystemFactData, ToastData, ProjectSheetData,
diff --git a/src/crates/concat/ui/workspace/pane-switcher.slint b/src/crates/concat/ui/workspace/pane-switcher.slint
index 79bb1f0d..88c0f8d9 100644
--- a/src/crates/concat/ui/workspace/pane-switcher.slint
+++ b/src/crates/concat/ui/workspace/pane-switcher.slint
@@ -39,8 +39,6 @@ export enum PaneKind {
timeline,
/// the selected clip's keys: a dopesheet and a curve editor
keyframes,
- /// the monitor's picture as waveform, parade, vectorscope, histogram
- scopes,
}
export global Panes {
@@ -62,7 +60,6 @@ export global Panes {
: kind == PaneKind.preview ? I18n.t("common.preview")
: kind == PaneKind.inspector ? I18n.t("paneSwitcher.inspector")
: kind == PaneKind.keyframes ? I18n.t("common.keyframes")
- : kind == PaneKind.scopes ? I18n.t("scopes.scopes")
: I18n.t("paneSwitcher.timeline");
}
@@ -74,7 +71,6 @@ export global Panes {
: kind == PaneKind.preview ? "preview"
: kind == PaneKind.inspector ? "inspector"
: kind == PaneKind.keyframes ? "keyframes"
- : kind == PaneKind.scopes ? "scopes"
: "timeline";
}
@@ -87,7 +83,6 @@ export global Panes {
: kind == PaneKind.preview ? Glyph.image
: kind == PaneKind.inspector ? Glyph.settings
: kind == PaneKind.keyframes ? Glyph.keyframe
- : kind == PaneKind.scopes ? Glyph.waveform
: Glyph.rows;
}
}
@@ -399,11 +394,6 @@ export component PaneSwitcher inherits Rectangle {
current: root.kind == PaneKind.keyframes;
chosen => { menu.close(); root.picked(PaneKind.keyframes); }
}
- SwitchRow {
- kind: PaneKind.scopes;
- current: root.kind == PaneKind.scopes;
- chosen => { menu.close(); root.picked(PaneKind.scopes); }
- }
SwitchRow {
kind: PaneKind.timeline;
current: root.kind == PaneKind.timeline;
@@ -507,10 +497,6 @@ export component AddPaneButton inherits Rectangle {
kind: PaneKind.keyframes;
chosen => { menu.close(); root.added(PaneKind.keyframes); }
}
- SwitchRow {
- kind: PaneKind.scopes;
- chosen => { menu.close(); root.added(PaneKind.scopes); }
- }
SwitchRow {
kind: PaneKind.timeline;
chosen => { menu.close(); root.added(PaneKind.timeline); }
diff --git a/src/crates/concat/ui/workspace/scopes-pane.slint b/src/crates/concat/ui/workspace/scopes-pane.slint
deleted file mode 100644
index 273f00db..00000000
--- a/src/crates/concat/ui/workspace/scopes-pane.slint
+++ /dev/null
@@ -1,176 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-or-later
-// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
-
-// The Scopes pane: the monitor's picture as a colourist reads it. A
-// waveform (luma across the picture), a parade (red, green and blue side
-// by side), a vectorscope (every pixel's colour on the Cb-Cr plane, with
-// the 75 % bars' targets) or a histogram - counted on the GPU from the
-// frame's light before anything is clipped, and drawn by Rust. The scale
-// is the display level on an SDR timeline, and nits on PQ's scale on an
-// HDR one, so SDR white and a 1000-nit highlight each have their line.
-
-import { I18n } from "../i18n.slint";
-import { Theme } from "../theme/theme.slint";
-import { SegmentedControl } from "../primitives/segmented-control.slint";
-import { Pane, PaneHeader } from "pane.slint";
-import { PaneKind, PaneSwitcher } from "pane-switcher.slint";
-
-/// One mark of the scale: where it sits, `0..1` from the bottom of a
-/// waveform or a parade or from the left of a histogram, and what it reads.
-export struct ScopeMarkData {
- at: float,
- label: string,
-}
-
-/// The scope in view, published by Rust as the monitor draws.
-export global Scopes {
- in property <image> picture;
- in property <[ScopeMarkData]> marks;
- /// 0 the waveform, 1 the parade, 2 the vectorscope, 3 the histogram.
- in-out property <int> kind: 0;
- /// The timeline is HDR: the marks read nits.
- in property <bool> hdr;
- /// A scope has been counted since the pane opened.
- in property <bool> ready;
- callback kind-changed(kind: int);
-}
-
-export component ScopesPane inherits Pane {
- in property <int> pane-seat;
- in property <bool> pane-removable;
- callback pane-picked(kind: PaneKind);
- callback pane-removed();
-
- VerticalLayout {
- PaneHeader {
- title: I18n.t("scopes.scopes");
-
- VerticalLayout {
- alignment: center;
- PaneSwitcher {
- kind: PaneKind.scopes;
- seat: root.pane-seat;
- removable: root.pane-removable;
- picked(kind) => { root.pane-picked(kind); }
- removed => { root.pane-removed(); }
- }
- }
- }
-
- // Which scope, and what its scale reads.
- Rectangle {
- height: 40px;
-
- Rectangle {
- x: 0;
- y: parent.height - 1px;
- width: parent.width;
- height: 1px;
- background: Theme.line;
- }
-
- HorizontalLayout {
- padding-left: Theme.pad;
- padding-right: Theme.pad;
- spacing: 8px;
-
- VerticalLayout {
- alignment: center;
- SegmentedControl {
- options: [
- I18n.t("scopes.waveform"),
- I18n.t("scopes.parade"),
- I18n.t("scopes.vectorscope"),
- I18n.t("scopes.histogram"),
- ];
- current: Scopes.kind;
- changed(index) => { Scopes.kind-changed(index); }
- }
- }
-
- Text {
- horizontal-stretch: 0;
- text: Scopes.kind == 2 ? "" : Scopes.hdr ? I18n.t("scopes.nits") : "%";
- color: Theme.fg-dim;
- font-size: Theme.fs-sm;
- vertical-alignment: center;
- }
- }
- }
-
- // The scope, black, with its scale over it. A vectorscope keeps its
- // plane square in the middle; the others fill the pane.
- body := Rectangle {
- background: #000000;
- clip: true;
-
- property <bool> square: Scopes.kind == 2;
- property <length> side: Math.min(self.width, self.height) - 16px;
-
- scope := Rectangle {
- x: body.square ? (body.width - body.side) / 2 : 32px;
- y: body.square ? (body.height - body.side) / 2 : 8px;
- width: body.square ? body.side : body.width - 40px;
- height: body.square ? body.side : body.height - (Scopes.kind == 3 ? 28px : 16px);
-
- Image {
- width: parent.width;
- height: parent.height;
- source: Scopes.picture;
- image-fit: fill;
- }
-
- // A waveform's and a parade's marks are levels across.
- if Scopes.kind < 2: Rectangle {
- for mark in Scopes.marks: Rectangle {
- y: (1 - mark.at) * scope.height;
- width: scope.width;
- height: 1px;
- background: #ffffff26;
-
- Text {
- x: -30px;
- y: -7px;
- width: 26px;
- text: mark.label;
- color: Theme.fg-dim;
- font-size: Theme.fs-xs;
- horizontal-alignment: right;
- }
- }
- }
-
- // A histogram's are levels along.
- if Scopes.kind == 3: Rectangle {
- for mark in Scopes.marks: Rectangle {
- x: mark.at * scope.width;
- width: 1px;
- height: scope.height;
- background: #ffffff26;
-
- Text {
- x: -20px;
- y: scope.height + 4px;
- width: 40px;
- text: mark.label;
- color: Theme.fg-dim;
- font-size: Theme.fs-xs;
- horizontal-alignment: center;
- }
- }
- }
- }
-
- if !Scopes.ready: Text {
- width: parent.width;
- height: parent.height;
- text: I18n.t("scopes.waiting");
- color: Theme.fg-dim;
- font-size: Theme.fs;
- horizontal-alignment: center;
- vertical-alignment: center;
- wrap: word-wrap;
- }
- }
- }
-}
diff --git a/src/crates/concat/ui/workspace/seat.slint b/src/crates/concat/ui/workspace/seat.slint
index d672d2d6..dd904fc9 100644
--- a/src/crates/concat/ui/workspace/seat.slint
+++ b/src/crates/concat/ui/workspace/seat.slint
@@ -11,7 +11,6 @@ import { MediaPane } from "media-pane.slint";
import { PreviewPane } from "preview-pane.slint";
import { TimelinePane } from "timeline-pane.slint";
import { KeyframesPane } from "keyframes-pane.slint";
-import { ScopesPane } from "scopes-pane.slint";
// One box of the workspace, showing whichever view its `kind` names.
//
@@ -314,18 +313,6 @@ export component Seat inherits Rectangle {
}
}
- if root.kind == PaneKind.scopes: ScopesPane {
- x: 0;
- y: 0;
- width: root.width;
- height: root.height;
-
- pane-picked(kind) => { root.picked(kind); }
- pane-seat: root.index;
- pane-removable: Editor.seats.length > 1;
- pane-removed => { root.removed(); }
- }
-
if root.kind == PaneKind.keyframes: KeyframesPane {
x: 0;
y: 0;