diff --git a/crates/app/src/export_ui.rs b/crates/app/src/export_ui.rs index ce5acde..b1eeead 100644 --- a/crates/app/src/export_ui.rs +++ b/crates/app/src/export_ui.rs @@ -663,6 +663,21 @@ pub(crate) fn export_settings( } } +/// The same settings with the budget taken out -- what the seat probe is asked +/// and keyed on ([`crate::Player::cache_export_seat`]). A bitrate does not +/// decide whether this machine has a VA-API seat or whether the picture's +/// packets can be copied; leaving it in the key meant every wheel notch on the +/// budget row invalidated the answer and opened a real VA-API encoder to ask it +/// again -- measured at ten opens for ten notches, 5-32 ms of GPU work each, +/// against the player's own decoder, which is the "freezes a little" this row +/// was reported for. +pub(crate) fn probe_settings(format: Format, audio_kbps: u32, seat: EncoderSeat) -> ExportSettings { + ExportSettings { + bitrate: None, + ..export_settings(0, format, audio_kbps, seat) + } +} + /// The budget's bounds, the engine's own (`engine::export`'s `MIN_BITRATE` /// and `MAX_EXPLICIT_BITRATE`): a number outside them would be written as a /// different one, so the lever and the field clamp to exactly these. diff --git a/crates/app/src/player/export.rs b/crates/app/src/player/export.rs index 3132679..b2db572 100644 --- a/crates/app/src/player/export.rs +++ b/crates/app/src/player/export.rs @@ -351,12 +351,7 @@ impl Player { let Some(session) = &self.session else { return; }; - let settings = export_settings( - self.budget_bps(), - self.format, - self.audio_kbps, - self.encoder_seat(), - ); + let settings = probe_settings(self.format, self.audio_kbps, self.encoder_seat()); if !self.export_open { return; } diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index 1e34668..83239fb 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -2066,3 +2066,32 @@ fn toggle_proxy_wakes_the_asked_phase_it_stops() { "a stop asked during Asked no longer sets the flag the header read polls" ); } + +/// A wheel notch on the budget must not re-ask the seat probe. The probe opens +/// a real VA-API encoder (ten opens for ten notches before this, 5-32 ms of GPU +/// work each, against the player's own decoder) and its answer -- GPU seat or +/// software, copy or encode -- does not depend on the bitrate at all. So the +/// settings it is keyed on carry no budget, and the budget still reaches the +/// export itself, which is the one place it changes a file. +#[test] +fn the_seat_probe_is_not_keyed_on_the_budget() { + let seat = EncoderSeat::default(); + let asked = crate::probe_settings(Format::Mp4, DEFAULT_AUDIO_KBPS, seat); + assert_eq!(asked.bitrate, None, "no budget is in the probe's question"); + // What still *is* a new question: the format the file is written in. + assert_ne!( + asked, + crate::probe_settings(Format::Av1, DEFAULT_AUDIO_KBPS, seat), + "a format change must re-probe" + ); + let cache = fn_body("cache_export_seat"); + assert!( + cache.contains("probe_settings(") && !cache.contains("budget_bps()"), + "the seat cache is keyed on the budget again" + ); + // ...and the number the wheel moves is still what the export is given. + assert!( + fn_body("start_export").contains("self.budget_bps()"), + "the export no longer writes at the budget on the row" + ); +}