return values instead of wrapping them in needless results

This commit is contained in:
2026-09-21 01:26:53 +03:00
parent b2dd93fb09
commit e6e0d5b2b4
4 changed files with 26 additions and 24 deletions
+10 -13
View File
@@ -45,13 +45,13 @@ const MAX_ENCODE_WIDTH: u32 = 3840;
const AUTO_ENCODE_WIDTH: u32 = 1920;
const FALLBACK_REFRESH_HZ: u32 = 60;
/// Returns the cap to apply to the encode width, or None for native res.
/// The cap to apply to the encode width in pixels.
/// Auto keeps the historic 1920 cap so nothing changes for existing users;
/// Full records at native res up to `MAX_ENCODE_WIDTH` (3840).
fn encode_width_limit(quality: CaptureQuality) -> Option<u32> {
fn encode_width_limit(quality: CaptureQuality) -> u32 {
match quality {
CaptureQuality::Auto => Some(AUTO_ENCODE_WIDTH),
CaptureQuality::Full => Some(MAX_ENCODE_WIDTH),
CaptureQuality::Auto => AUTO_ENCODE_WIDTH,
CaptureQuality::Full => MAX_ENCODE_WIDTH,
}
}
@@ -63,7 +63,7 @@ pub(crate) struct CaptureSetup {
pub height: u32,
pub crop: Option<CaptureRect>,
pub pipe_fps: u32,
pub encode_width_limit: Option<u32>,
pub encode_width_limit: u32,
pub frame_counter: Arc<std::sync::atomic::AtomicU64>,
}
@@ -453,12 +453,9 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
let h = c.height.min(setup.height.saturating_sub(y.cast_unsigned()));
filter_parts.push(format!("crop={w}:{h}:{x}:{y}"));
}
if let Some(limit) = setup.encode_width_limit {
if setup.width > limit {
filter_parts.push(format!("scale={limit}:-2"));
} else {
filter_parts.push("scale=trunc(iw/2)*2:trunc(ih/2)*2".to_string());
}
let limit = setup.encode_width_limit;
if setup.width > limit {
filter_parts.push(format!("scale={limit}:-2"));
} else {
filter_parts.push("scale=trunc(iw/2)*2:trunc(ih/2)*2".to_string());
}
@@ -716,7 +713,7 @@ fn compute_output_dims(
monitor_w: u32,
monitor_h: u32,
crop: Option<CaptureRect>,
width_limit: Option<u32>,
width_limit: u32,
) -> (u32, u32) {
let (raw_w, raw_h) = match crop {
Some(c) => {
@@ -729,7 +726,7 @@ fn compute_output_dims(
}
None => (monitor_w, monitor_h),
};
let cap = width_limit.unwrap_or(u32::MAX);
let cap = width_limit;
if raw_w > cap {
let scale = f64::from(cap) / f64::from(raw_w);
let nh = crate::encode::round_u32(f64::from(raw_h) * scale);