The settings page shows the HDR reference the file declared
Browse files at this commite88fbc827e6ad0aa043ee2a598b38227bcb87d7cParent: bdb07d9- feat
- the settings page shows the HDR reference the file declared
3 changed files +158 -10
- crates/app/src/tests/layout.rs +33 -0
- crates/app/src/ui/settings_stance.rs +89 -9
- crates/engine/src/playback.rs +36 -1
crates/app/src/tests/layout.rsmodified+33 -0
| @@ -2272,3 +2272,36 @@ fn settings_project_rows_have_no_bare_noun_placeholder() { | ||
| 2272 | 2272 | ); |
| 2273 | 2273 | } |
| 2274 | 2274 | } |
| 2275 | + | |
| 2276 | +/// The HDR reference rows must read the file's own declared numbers off | |
| 2277 | +/// [`engine::colorspace::ContentLight`] -- not invent a monitor override the | |
| 2278 | +/// engine has nowhere to persist -- and must fall back to the page's one | |
| 2279 | +/// established empty state (a bare `—` in `INK4`, [`row_ink`]/[`row_static`]'s | |
| 2280 | +/// own idiom) rather than a second placeholder idiom. No `TestAppContext` | |
| 2281 | +/// here either, so this is the same source-scan the guard above it is. | |
| 2282 | +#[test] | |
| 2283 | +fn hdr_reference_rows_read_content_light_and_use_the_established_empty_state() { | |
| 2284 | + let source = src_text("ui/settings_stance.rs"); | |
| 2285 | + let project_start = source.find("fn project_section(").expect("the project section"); | |
| 2286 | + let editor_start = source.find("fn editor_section(").expect("the editor section"); | |
| 2287 | + let project_body = &source[project_start..editor_start]; | |
| 2288 | + | |
| 2289 | + assert!(project_body.contains("settings-hdr-reference"), "the HDR reference row is missing"); | |
| 2290 | + assert!(project_body.contains("settings-content-light"), "the content-light row is missing"); | |
| 2291 | + | |
| 2292 | + // Reads the real declared numbers, not an invented default or a fixed | |
| 2293 | + // string standing in for one. | |
| 2294 | + for field in ["mastering_max", "max_cll", "max_fall"] { | |
| 2295 | + assert!(project_body.contains(field), "the HDR reference rows do not read ContentLight::{field}"); | |
| 2296 | + } | |
| 2297 | + | |
| 2298 | + // No override field exists on the engine side to write one into, so the | |
| 2299 | + // row must never claim a picker/opener the way every other PROJECT row | |
| 2300 | + // does -- it is built with `row_static`, not `row`/`row_ink`. | |
| 2301 | + assert!(project_body.contains("row_static(\n \"settings-hdr-reference\""), "the HDR reference row must be read-only (row_static), not a picker"); | |
| 2302 | + assert!(project_body.contains("row_static(\n \"settings-content-light\""), "the content-light row must be read-only (row_static), not a picker"); | |
| 2303 | + | |
| 2304 | + // The established empty state: a bare "—" reused, never a second idiom | |
| 2305 | + // ("N/A", "None", "Unknown"...) invented for the same absence. | |
| 2306 | + assert!(project_body.contains("\"—\".to_string()"), "the HDR reference rows must reuse the page's own empty-state dash"); | |
| 2307 | +} |
crates/app/src/ui/settings_stance.rsmodified+89 -9
| @@ -21,16 +21,20 @@ | ||
| 21 | 21 | //! Values apply live through those same doors; there is no Apply button here |
| 22 | 22 | //! to be inconsistent with the rest of the room. |
| 23 | 23 | //! |
| 24 | -//! Seams left for other builders (this task's scope boundary): the HDR | |
| 25 | -//! mastering-display target row (a monitor fact, not in `inspector.rs`'s own | |
| 26 | -//! project section yet) has no row here either -- it plugs into | |
| 27 | -//! `project_section` below, beside the tonemap row it is the pair of. A | |
| 28 | -//! finer fps/sample-rate/tone picker is the same builder's to extend; this | |
| 29 | -//! page only ever asks for [`Pick::Fps`]/[`Pick::SampleRate`]/[`Pick::Tone`] | |
| 24 | +//! Seams left for other builders (this task's scope boundary): a finer | |
| 25 | +//! fps/sample-rate/tone picker is the same builder's to extend; this page | |
| 26 | +//! only ever asks for [`Pick::Fps`]/[`Pick::SampleRate`]/[`Pick::Tone`] | |
| 30 | 27 | //! exactly as `inspector.rs`'s legacy panel already does. |
| 28 | +//! | |
| 29 | +//! The HDR reference numbers beside the tonemap row (`HDR reference` and | |
| 30 | +//! `Content light`) are the *file's* declared light level | |
| 31 | +//! ([`engine::colorspace::ContentLight`]), not a monitor fact -- read-only, | |
| 32 | +//! since nothing in [`engine::project::Project`] holds a place to persist an | |
| 33 | +//! override into. | |
| 31 | 34 | |
| 32 | 35 | use crate::*; |
| 33 | 36 | use crate::ui::type_scale; |
| 37 | +use engine::colorspace::ContentLight; | |
| 34 | 38 | |
| 35 | 39 | /// A 9px uppercase Archivo section head, `ink3` -- [`dock_stance::section_head`]'s |
| 36 | 40 | /// exact shape, repeated rather than imported across a `pub(crate)` seam for |
| @@ -110,6 +114,51 @@ fn row_ink( | ||
| 110 | 114 | ) |
| 111 | 115 | } |
| 112 | 116 | |
| 117 | +/// [`row_ink`] with no opener: a readout rather than a picker, for a value | |
| 118 | +/// this editor cannot set because nothing behind it can hold a pick -- | |
| 119 | +/// [`engine::playback::PlaybackSession`] has no field to persist one into. | |
| 120 | +/// No `cursor_pointer`, no hover paint, no click: the row must not read as a | |
| 121 | +/// button that does nothing when pressed. The hint still names where the | |
| 122 | +/// number came from, since a reader who wants that detail should get it from | |
| 123 | +/// the same door every other row's hint answers from. | |
| 124 | +fn row_static( | |
| 125 | + id: &'static str, | |
| 126 | + label_text: &'static str, | |
| 127 | + value: impl Into<SharedString>, | |
| 128 | + hint: &'static str, | |
| 129 | + value_ink: u32, | |
| 130 | +) -> impl IntoElement { | |
| 131 | + let value: SharedString = value.into(); | |
| 132 | + let hint: SharedString = hint.into(); | |
| 133 | + let label_style = type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM); | |
| 134 | + let value_style = type_scale::mono(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM); | |
| 135 | + div() | |
| 136 | + .id(id) | |
| 137 | + .flex_none() | |
| 138 | + .flex() | |
| 139 | + .items_center() | |
| 140 | + .justify_between() | |
| 141 | + .h(px(CONTROL_H)) | |
| 142 | + .px(px(8.)) | |
| 143 | + .rounded(px(3.)) | |
| 144 | + .tooltip(move |_, cx| cx.new(|_| Tip(hint.clone())).into()) | |
| 145 | + .child( | |
| 146 | + div() | |
| 147 | + .font(label_style.font) | |
| 148 | + .text_size(label_style.size) | |
| 149 | + .text_color(rgb(INK2())) | |
| 150 | + .child(label_text), | |
| 151 | + ) | |
| 152 | + .child( | |
| 153 | + div() | |
| 154 | + .flex_none() | |
| 155 | + .font(value_style.font) | |
| 156 | + .text_size(value_style.size) | |
| 157 | + .text_color(rgb(value_ink)) | |
| 158 | + .child(value), | |
| 159 | + ) | |
| 160 | +} | |
| 161 | + | |
| 113 | 162 | /// PROJECT: the canvas every clip is composed onto, the rate it is cut at, |
| 114 | 163 | /// the HDR rendition it is watched in, and the mix everything sums into -- |
| 115 | 164 | /// [`inspector.rs`]'s own four-plus-Mix list, ported rather than |
| @@ -140,6 +189,23 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | ||
| 140 | 189 | Some(session) => (format!("HDR {}", tone_label(session.tone())), INK1()), |
| 141 | 190 | None => ("—".to_string(), INK4()), |
| 142 | 191 | }; |
| 192 | + // The reference row's own numbers: what source 0's file actually declared | |
| 193 | + // ([`engine::colorspace::ContentLight`], read at open by | |
| 194 | + // [`engine::playback::PlaybackSession::content_light`]) -- read-only, | |
| 195 | + // since nothing in [`engine::project::Project`] holds an override to | |
| 196 | + // persist one into. `—` for a project with no session, and for a session | |
| 197 | + // whose file is SDR or simply declared nothing (most files declare | |
| 198 | + // nothing here at all). | |
| 199 | + let light = player.session.as_ref().map_or(ContentLight::default(), engine::playback::PlaybackSession::content_light); | |
| 200 | + let (master_val, master_ink) = match (&player.session, light.mastering_max) { | |
| 201 | + (Some(_), Some(nits)) => (format!("{nits:.0} nits"), INK1()), | |
| 202 | + _ => ("—".to_string(), INK4()), | |
| 203 | + }; | |
| 204 | + let (content_val, content_ink) = match (&player.session, light.max_cll, light.max_fall) { | |
| 205 | + (Some(_), Some(cll), Some(fall)) => (format!("{cll:.0}/{fall:.0} nits"), INK1()), | |
| 206 | + (Some(_), Some(cll), None) => (format!("{cll:.0} nits"), INK1()), | |
| 207 | + _ => ("—".to_string(), INK4()), | |
| 208 | + }; | |
| 143 | 209 | div() |
| 144 | 210 | .flex_none() |
| 145 | 211 | .flex() |
| @@ -172,9 +238,6 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | ||
| 172 | 238 | player, |
| 173 | 239 | cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::SampleRate, event.position(), cx)), |
| 174 | 240 | )) |
| 175 | - // hook: the mastering-display target (a monitor peak-nits fact, not | |
| 176 | - // yet in `inspector.rs`'s own project section) is this row's pair -- | |
| 177 | - // another builder's row, plugged in right here once it exists. | |
| 178 | 241 | .child(row_ink( |
| 179 | 242 | "settings-tonemap", |
| 180 | 243 | "HDR tonemap", |
| @@ -184,6 +247,23 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | ||
| 184 | 247 | cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Tone, event.position(), cx)), |
| 185 | 248 | tone_ink, |
| 186 | 249 | )) |
| 250 | + // The tonemap row's pair: what the file actually declared, read-only | |
| 251 | + // ([`row_static`] -- there is nowhere in the project to persist a | |
| 252 | + // pick even if this page offered one). | |
| 253 | + .child(row_static( | |
| 254 | + "settings-hdr-reference", | |
| 255 | + "HDR reference", | |
| 256 | + master_val, | |
| 257 | + "the mastering display's own peak white, in cd/m^2, as the grade declared it -- what a 'Reference' tonemap targets before it ever looks at this film's own pixels", | |
| 258 | + master_ink, | |
| 259 | + )) | |
| 260 | + .child(row_static( | |
| 261 | + "settings-content-light", | |
| 262 | + "Content light", | |
| 263 | + content_val, | |
| 264 | + "MaxCLL/MaxFALL: the brightest single pixel and the brightest frame average measured in the finished encode -- what a 'Reference' tonemap actually rolls off from when the file declares it, ahead of the mastering peak above", | |
| 265 | + content_ink, | |
| 266 | + )) | |
| 187 | 267 | .child(row( |
| 188 | 268 | "settings-mix", |
| 189 | 269 | "Mix", |
crates/engine/src/playback.rsmodified+36 -1
| @@ -22,7 +22,7 @@ use crate::ao::AoSession; | ||
| 22 | 22 | use crate::audio::{AudioChunk, AudioSession}; |
| 23 | 23 | use crate::clock::{ClockSource, PlaybackClock}; |
| 24 | 24 | use crate::color::ColorParams; |
| 25 | -use crate::colorspace::ColorDescription; | |
| 25 | +use crate::colorspace::{ColorDescription, ContentLight}; | |
| 26 | 26 | use crate::decode::{Backend, BackendCell, DecodeSession, Frame, Worker}; |
| 27 | 27 | use crate::demux::{Codec, Demuxer, VideoMeta}; |
| 28 | 28 | use crate::eq::EqParams; |
| @@ -312,6 +312,13 @@ pub struct PlaybackSession { | ||
| 312 | 312 | /// `resolution` line makes it after that. Every clip is composed onto it, so |
| 313 | 313 | /// a file of another size is a placed picture rather than a refusal. |
| 314 | 314 | meta: VideoMeta, |
| 315 | + /// What source 0's own file declared about how bright it gets | |
| 316 | + /// ([`crate::colorspace::ContentLight`]) -- MaxCLL/MaxFALL and the | |
| 317 | + /// mastering display's peak/black, read once at open exactly as `native` | |
| 318 | + /// is, since the value is a property of the file and never changes under | |
| 319 | + /// a running session. [`ContentLight::default()`] (every field `None`) | |
| 320 | + /// for an SDR file and for a song or a still, neither of which is graded. | |
| 321 | + content_light: ContentLight, | |
| 315 | 322 | /// Source 0's own picture, kept from the open: the project resolution |
| 316 | 323 | /// starts here, and a caller offering sizes to pick from needs the media's |
| 317 | 324 | /// own among them or a project moved off it could never come back. |
| @@ -585,8 +592,15 @@ impl PlaybackSession { | ||
| 585 | 592 | // first edit -- and the range opened above is exactly that clip's. |
| 586 | 593 | let project = Project::single(&path, meta.frame_count); |
| 587 | 594 | let span = project.composite_span_at(0); |
| 595 | + // A second, header-only open purely for the light level: `open_worker` | |
| 596 | + // above already read one to hand the decode thread its own, but never | |
| 597 | + // hands it back out. The same trade the audio header cache above this | |
| 598 | + // makes -- a second container open, paid once at open rather than never | |
| 599 | + // -- since nothing here decodes a single picture. | |
| 600 | + let content_light = Demuxer::open(&path).map(|(_, d)| d.light()).unwrap_or_default(); | |
| 588 | 601 | Ok(Self { |
| 589 | 602 | meta, |
| 603 | + content_light, | |
| 590 | 604 | native: (meta.width, meta.height), |
| 591 | 605 | native_fps: meta.frame_rate, |
| 592 | 606 | frames: stream.frames, |
| @@ -707,6 +721,7 @@ impl PlaybackSession { | ||
| 707 | 721 | let stream = DecodeSession::open_black(width, height, span.map_or(1, |s| s.len)); |
| 708 | 722 | Ok(Self { |
| 709 | 723 | meta, |
| 724 | + content_light: ContentLight::default(), | |
| 710 | 725 | native: (width, height), |
| 711 | 726 | native_fps: frame_rate, |
| 712 | 727 | frames: stream.frames, |
| @@ -803,6 +818,7 @@ impl PlaybackSession { | ||
| 803 | 818 | )?; |
| 804 | 819 | Ok(Self { |
| 805 | 820 | meta, |
| 821 | + content_light: ContentLight::default(), | |
| 806 | 822 | native: (meta.width, meta.height), |
| 807 | 823 | native_fps: IMAGE_ONLY_RATE, |
| 808 | 824 | frames: stream.frames, |
| @@ -897,6 +913,15 @@ impl PlaybackSession { | ||
| 897 | 913 | // ([`open_audio_only`](Self::open_audio_only)), and the placeholder |
| 898 | 914 | // black stream is superseded by the `seek` at the end of this function |
| 899 | 915 | // like every other worker opened here. |
| 916 | + // What source 0's own file declares about its light level, read the | |
| 917 | + // same way [`open_stream`](Self::open_stream) reads it for a fresh | |
| 918 | + // open: [`ContentLight::default()`] for a song or a still, neither of | |
| 919 | + // which is graded. | |
| 920 | + let content_light = if crate::is_audio(&first.path) || crate::is_image(&first.path) { | |
| 921 | + ContentLight::default() | |
| 922 | + } else { | |
| 923 | + Demuxer::open(&first.path).map(|(_, d)| d.light()).unwrap_or_default() | |
| 924 | + }; | |
| 900 | 925 | let (mut meta, stream) = match crate::is_audio(&first.path) { |
| 901 | 926 | true => { |
| 902 | 927 | let (width, height, canvas_fps) = AUDIO_ONLY_CANVAS; |
| @@ -1109,6 +1134,7 @@ impl PlaybackSession { | ||
| 1109 | 1134 | }; |
| 1110 | 1135 | let mut session = Self { |
| 1111 | 1136 | meta, |
| 1137 | + content_light, | |
| 1112 | 1138 | native, |
| 1113 | 1139 | native_fps, |
| 1114 | 1140 | frames: stream.frames, |
| @@ -2716,6 +2742,15 @@ impl PlaybackSession { | ||
| 2716 | 2742 | self.project.tone() |
| 2717 | 2743 | } |
| 2718 | 2744 | |
| 2745 | + /// What source 0's own file declared about how bright it gets | |
| 2746 | + /// ([`ContentLight`]): a property of the film, read once at open, and | |
| 2747 | + /// entirely absent (every field `None`) for an SDR file, a song or a | |
| 2748 | + /// still. Read-only -- the number a file carries, never a project setting | |
| 2749 | + /// a user can override, since nothing in [`Project`] holds one to persist. | |
| 2750 | + pub fn content_light(&self) -> ContentLight { | |
| 2751 | + self.content_light | |
| 2752 | + } | |
| 2753 | + | |
| 2719 | 2754 | /// Picks one. Rebuilds the **picture** where the playhead is, exactly as |
| 2720 | 2755 | /// [`set_resolution`](Self::set_resolution) does -- the frame on screen is |
| 2721 | 2756 | /// remapped at once, paused or playing, and the sound is not touched: a |