enforce stricter lints, drop discarded results properly
This commit is contained in:
+19
-19
@@ -154,13 +154,13 @@ impl TonemapPipeline {
|
||||
StructureByteStride: 0,
|
||||
};
|
||||
let vb_init = D3D11_SUBRESOURCE_DATA {
|
||||
pSysMem: verts.as_ptr() as *const _,
|
||||
pSysMem: verts.as_ptr() as *const std::ffi::c_void,
|
||||
SysMemPitch: 0,
|
||||
SysMemSlicePitch: 0,
|
||||
};
|
||||
let mut vertex_buffer = None;
|
||||
unsafe {
|
||||
device.CreateBuffer(&vb_desc as *const _, Some(&vb_init as *const _), Some(&mut vertex_buffer))?;
|
||||
device.CreateBuffer(&vb_desc, Some(&vb_init), Some(&mut vertex_buffer))?;
|
||||
}
|
||||
let vertex_buffer = vertex_buffer.ok_or_else(|| anyhow!("CreateBuffer vb returned null"))?;
|
||||
|
||||
@@ -349,8 +349,8 @@ impl TonemapPipeline {
|
||||
context.RSSetScissorRects(Some(&[windows::Win32::Foundation::RECT {
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: self.width as i32,
|
||||
bottom: self.height as i32,
|
||||
right: self.width.cast_signed(),
|
||||
bottom: self.height.cast_signed(),
|
||||
}]));
|
||||
context.Draw(3, 0);
|
||||
|
||||
@@ -395,8 +395,8 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
|
||||
if let Some(c) = setup.crop {
|
||||
let x = c.x.max(0);
|
||||
let y = c.y.max(0);
|
||||
let w = c.width.min(setup.width.saturating_sub(x as u32));
|
||||
let h = c.height.min(setup.height.saturating_sub(y as u32));
|
||||
let w = c.width.min(setup.width.saturating_sub(x.cast_unsigned()));
|
||||
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 {
|
||||
@@ -496,7 +496,7 @@ impl Drop for CaptureHandler {
|
||||
fn drop(&mut self) {
|
||||
drop(self.stdin.take());
|
||||
if let Some(mut child) = self.child.take() {
|
||||
let _ = child.wait();
|
||||
drop(child.wait());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -578,8 +578,8 @@ pub fn start(
|
||||
// Use the center of the capture region to determine which monitor to capture.
|
||||
// If the region spans monitors, we pick the one containing the center.
|
||||
let monitor = if let Some(ref c) = crop {
|
||||
let cx = c.x.saturating_add(c.width as i32 / 2);
|
||||
let cy = c.y.saturating_add(c.height as i32 / 2);
|
||||
let cx = c.x.saturating_add(c.width.cast_signed() / 2);
|
||||
let cy = c.y.saturating_add(c.height.cast_signed() / 2);
|
||||
tracing::info!("capture center=({cx}, {cy}), selecting monitor");
|
||||
monitor_at_point(cx, cy).unwrap_or_else(|_| {
|
||||
tracing::warn!("no monitor at ({cx}, {cy}), falling back to primary");
|
||||
@@ -655,8 +655,8 @@ fn compute_output_dims(
|
||||
) -> (u32, u32) {
|
||||
let (raw_w, raw_h) = match crop {
|
||||
Some(c) => {
|
||||
let x = c.x.max(0) as u32;
|
||||
let y = c.y.max(0) as u32;
|
||||
let x = c.x.max(0).cast_unsigned();
|
||||
let y = c.y.max(0).cast_unsigned();
|
||||
(
|
||||
c.width.min(monitor_w.saturating_sub(x)),
|
||||
c.height.min(monitor_h.saturating_sub(y)),
|
||||
@@ -666,8 +666,8 @@ fn compute_output_dims(
|
||||
};
|
||||
let cap = width_limit.unwrap_or(u32::MAX);
|
||||
if raw_w > cap {
|
||||
let scale = cap as f64 / raw_w as f64;
|
||||
let nh = (raw_h as f64 * scale).round() as u32;
|
||||
let scale = f64::from(cap) / f64::from(raw_w);
|
||||
let nh = (f64::from(raw_h) * scale).round() as u32;
|
||||
(cap, (nh / 2) * 2)
|
||||
} else {
|
||||
((raw_w / 2) * 2, (raw_h / 2) * 2)
|
||||
@@ -676,7 +676,7 @@ fn compute_output_dims(
|
||||
|
||||
impl CaptureSession {
|
||||
pub fn stop(self) -> Result<PathBuf> {
|
||||
let _ = self.control.stop();
|
||||
drop(self.control.stop());
|
||||
let meta = std::fs::metadata(&self.output_path)
|
||||
.with_context(|| format!("checking output file {}", self.output_path.display()))?;
|
||||
if meta.len() == 0 {
|
||||
@@ -748,11 +748,11 @@ pub fn fix_intermediate_fps(
|
||||
.context("stream-copy timestamp fix")?;
|
||||
if copy_status.success() && output.is_file() {
|
||||
tracing::debug!("capture fix: stream copy with -itsscale succeeded, no re-encode");
|
||||
let _ = std::fs::remove_file(input);
|
||||
drop(std::fs::remove_file(input));
|
||||
return Ok(());
|
||||
}
|
||||
tracing::warn!("capture fix: -itsscale copy failed, falling back to re-encode");
|
||||
let _ = std::fs::remove_file(output);
|
||||
drop(std::fs::remove_file(output));
|
||||
|
||||
// Fallback: re-encode with scaled PTS to fix timing.
|
||||
// CRF 18 is visually lossless; preset veryfast keeps stop/pause/resume snappy.
|
||||
@@ -774,10 +774,10 @@ pub fn fix_intermediate_fps(
|
||||
.context("re-encoding with corrected timestamps")?;
|
||||
|
||||
if status.success() {
|
||||
let _ = std::fs::remove_file(input);
|
||||
drop(std::fs::remove_file(input));
|
||||
} else {
|
||||
tracing::warn!("capture fix: re-encode failed, keeping original");
|
||||
let _ = rename_or_copy(input, output);
|
||||
drop(rename_or_copy(input, output));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -796,7 +796,7 @@ fn capture_timing(frame_count: u64, elapsed_secs: f64, pipe_fps: u32) -> Option<
|
||||
return None;
|
||||
}
|
||||
let actual_fps = frame_count as f64 / elapsed_secs;
|
||||
Some((actual_fps, pipe_fps as f64 / actual_fps))
|
||||
Some((actual_fps, f64::from(pipe_fps) / actual_fps))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user