Format the face work with the workspace's own rustfmt

Not authored in this session. `cargo fmt --all` reformats every crate, so
running it while working on `dr-segment` picked up five files from the recent
face and library work that had been committed unformatted.

Committed on its own rather than swept into the change that happened to
produce it: the diff is pure whitespace, and mixed into a commit that alters
an algorithm it would be noise in exactly the place someone is trying to read
carefully. `cargo fmt --all -- --check` is a CI gate (tools/ci-local.sh), so
this had to land somewhere regardless.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-30 21:29:12 +02:00
co-authored by Claude Opus 5
parent 89c4ff1820
commit 710fcbc1bd
6 changed files with 65 additions and 69 deletions
+3 -9
View File
@@ -77,15 +77,9 @@ fn main() {
};
let (w, h) = (frame.width as usize, frame.height as usize);
let native = dr_ui::faces::index_native(
&mut detector,
&mut embedder,
&frame.rgba,
w,
h,
&options,
)
.unwrap_or_default();
let native =
dr_ui::faces::index_native(&mut detector, &mut embedder, &frame.rgba, w, h, &options)
.unwrap_or_default();
// The old path, reproduced exactly: one buffer at 1024, used for both
// detection and the crop.
+8 -7
View File
@@ -472,12 +472,7 @@ fn reduce_for_detection(rgba: &[u8], width: usize, height: usize) -> (usize, usi
///
/// Split out so the averaging can be tested at a size a test can reason about
/// by hand, rather than by building a 1600px fixture.
fn reduce_to(
rgba: &[u8],
width: usize,
height: usize,
target: usize,
) -> (usize, usize, Vec<f32>) {
fn reduce_to(rgba: &[u8], width: usize, height: usize, target: usize) -> (usize, usize, Vec<f32>) {
let long = width.max(height);
if long <= target {
// Already small enough; convert without resampling rather than round
@@ -1378,7 +1373,13 @@ mod tests {
// The failure this guards is silent: landmarks left in the detector's
// coordinates put every crop near the top-left corner of the frame,
// which produces faces that look like faces of something else.
let lm = [(10.0, 20.0), (30.0, 40.0), (50.0, 60.0), (70.0, 80.0), (90.0, 100.0)];
let lm = [
(10.0, 20.0),
(30.0, 40.0),
(50.0, 60.0),
(70.0, 80.0),
(90.0, 100.0),
];
let out = scale_landmarks(&lm, 4.0, 2.0);
assert_eq!(out[0], (40.0, 40.0));
assert_eq!(out[4], (360.0, 200.0));
+11 -16
View File
@@ -3027,7 +3027,6 @@ fn faces_unindexed(
Ok(rows)
}
/// Images whose faces have nothing left to be cut out of.
///
/// A face is stored normalised and drawn by cropping the proxy it was found on
@@ -3334,13 +3333,7 @@ pub fn spawn_face_sweep(
}
};
match index_one_native(
&gpu,
&mut detector,
&mut embedder,
&bytes,
&options,
) {
match index_one_native(&gpu, &mut detector, &mut embedder, &bytes, &options) {
Ok((faces, edge, proxy)) => {
// Before the detections, so a kill between the two
// leaves a proxy with no faces recorded -- which
@@ -3376,9 +3369,7 @@ pub fn spawn_face_sweep(
// or the user pressed Stop. Everything
// written so far stays written -- and
// everything borrowed is given back.
log::info!(
"face sweep: cancelled after {images} image(s)"
);
log::info!("face sweep: cancelled after {images} image(s)");
pool.release_all(&*backend).await;
return;
}
@@ -3447,10 +3438,7 @@ pub fn spawn_face_sweep(
/// because measuring what this pass is worth means rendering the same file two
/// ways and comparing the crops — see `examples/face_native.rs`. A tool that
/// had to reimplement the render would be measuring its own reimplementation.
pub fn render_native(
gpu: &dr_gpu::GpuContext,
bytes: &[u8],
) -> Result<dr_export::Frame, String> {
pub fn render_native(gpu: &dr_gpu::GpuContext, bytes: &[u8]) -> Result<dr_export::Frame, String> {
open_native(gpu, bytes)?.render_for_export(dr_types::ColourSpace::Srgb)
}
@@ -3503,7 +3491,14 @@ fn index_one_native(
embedder: &mut dr_face::Embedder,
bytes: &[u8],
options: &dr_face::DetectOptions,
) -> Result<(Vec<dr_catalog::faces::DetectedFace>, u32, Option<dr_thumbs::Thumbnail>), String> {
) -> Result<
(
Vec<dr_catalog::faces::DetectedFace>,
u32,
Option<dr_thumbs::Thumbnail>,
),
String,
> {
let mut session = open_native(gpu, bytes)?;
let frame = session.render_for_export(dr_types::ColourSpace::Srgb)?;