Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[rust][mobile][locker] Drop redundant comments

laurenspriemf1c90f8f73b7
diff --git a/mobile/apps/locker/lib/ui/pages/scanner/scan_quad_overlay.dart b/mobile/apps/locker/lib/ui/pages/scanner/scan_quad_overlay.dart
index 2ac2710b4c..2ae90b957f 100644
--- a/mobile/apps/locker/lib/ui/pages/scanner/scan_quad_overlay.dart
+++ b/mobile/apps/locker/lib/ui/pages/scanner/scan_quad_overlay.dart
@@ -8,9 +8,6 @@ class ScanQuadOverlay extends StatefulWidget {
static const double _smoothing = 0.15;
- /// The lerp only approaches its target, so without a floor the ticker
- /// repaints forever. A twentieth of a mask pixel is far below one screen
- /// pixel.
static const double _settled = 0.05;
final ScanQuad? quad;
diff --git a/mobile/apps/locker/lib/ui/pages/scanner/scanner_crop_page.dart b/mobile/apps/locker/lib/ui/pages/scanner/scanner_crop_page.dart
index fd4bdd4139..570ba5719c 100644
--- a/mobile/apps/locker/lib/ui/pages/scanner/scanner_crop_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/scanner/scanner_crop_page.dart
@@ -25,8 +25,6 @@ class ScannerCropPage extends StatefulWidget {
class _ScannerCropPageState extends State<ScannerCropPage> {
static const double _handleRadius = 22;
- /// A crop smaller than this cannot be a document, and the pipeline cannot
- /// produce a usable page from it.
static const double _minAreaFraction = 0.01;
Uint8List? _sourceBytes;
diff --git a/rust/crates/ml/src/cv/image.rs b/rust/crates/ml/src/cv/image.rs
index 9d8797222e..9e21ad97b3 100644
--- a/rust/crates/ml/src/cv/image.rs
+++ b/rust/crates/ml/src/cv/image.rs
@@ -77,7 +77,6 @@ impl ImageU8 {
}
}
-/// Elementwise map, parallel once the buffer is large enough to pay for it.
fn map_vec<T: Copy + Sync, U: Send>(src: &[T], f: impl Fn(T) -> U + Send + Sync) -> Vec<U> {
if src.len() >= PARALLEL_MIN_ELEMS {
src.par_iter().map(|&v| f(v)).collect()
@@ -166,7 +165,6 @@ impl ImageF32 {
}
}
- /// Fused map-and-quantise: skips the intermediate float image.
pub(crate) fn map_to_u8(&self, f: impl Fn(f32) -> f32 + Send + Sync) -> ImageU8 {
ImageU8 {
width: self.width,
diff --git a/rust/crates/ml/src/cv/mod.rs b/rust/crates/ml/src/cv/mod.rs
index ca329a6d3b..94de859379 100644
--- a/rust/crates/ml/src/cv/mod.rs
+++ b/rust/crates/ml/src/cv/mod.rs
@@ -37,8 +37,6 @@ pub(crate) use structuring::ellipse_kernel;
pub(crate) use transform::rotate_u8;
pub(crate) use warp::warp_perspective;
-/// One answer for every elementwise op: below this many samples, threading
-/// costs more than it saves.
pub(crate) const PARALLEL_MIN_ELEMS: usize = 200_000;
const PIXELS_PER_CHUNK: usize = 65_536;
diff --git a/rust/crates/ml/src/scan/color.rs b/rust/crates/ml/src/scan/color.rs
index d73aac454b..85e3100c1a 100644
--- a/rust/crates/ml/src/scan/color.rs
+++ b/rust/crates/ml/src/scan/color.rs
@@ -58,7 +58,6 @@ pub(crate) fn auto_color_mode(img: &ImageU8, mask: &Mask, quad: &Quad) -> OpResu
})
}
-/// Distance from the neutral axis in Lab's biased 0..255 encoding.
fn chroma(a: &ImageU8, b: &ImageU8) -> OpResult<ImageF32> {
let data = a
.data
diff --git a/rust/crates/ml/src/scan/mask.rs b/rust/crates/ml/src/scan/mask.rs
index e43e08e687..0bdf8160df 100644
--- a/rust/crates/ml/src/scan/mask.rs
+++ b/rust/crates/ml/src/scan/mask.rs
@@ -2,9 +2,6 @@ use super::OpResult;
use crate::cv;
use crate::cv::image::ImageU8;
-/// The segmentation probabilities, kept at full precision: the detection
-/// threshold sweep and the quad scoring both need the model's confidence, not
-/// just its argmax.
pub(crate) struct Mask {
pub width: i32,
pub height: i32,
diff --git a/rust/crates/ml/src/scan/postprocess.rs b/rust/crates/ml/src/scan/postprocess.rs
index 00487c0552..6d0cc8d2fd 100644
--- a/rust/crates/ml/src/scan/postprocess.rs
+++ b/rust/crates/ml/src/scan/postprocess.rs
@@ -11,8 +11,6 @@ pub(crate) fn enhance_captured_image(img: &ImageU8, color_mode: ColorMode) -> Op
}
}
-/// The min-then-max scalar pair the enhancement chains used to end with,
-/// including its NaN behaviour (NaN clamps to 255, not to 0).
fn clamp_255(v: f32) -> f32 {
let v = if v < 255.0 { v } else { 255.0 };
if v > 0.0 { v } else { 0.0 }
@@ -209,8 +207,6 @@ fn enhance_grayscale_image(img: &ImageU8) -> OpResult<ImageU8> {
}
}
- // A mode pinned at white means the retinex pass blew out the page; fall
- // back to a plain percentile stretch of the original grey.
let stretched8u = if mode_val >= 254 {
let g_low = cv::percentile_f32(&gray_f, 0.01)? as f64;
let g_high = cv::percentile_f32(&gray_f, 0.99)? as f64;
diff --git a/rust/crates/ml/src/scan/segmentation.rs b/rust/crates/ml/src/scan/segmentation.rs
index d869e1783f..7182e9b8af 100644
--- a/rust/crates/ml/src/scan/segmentation.rs
+++ b/rust/crates/ml/src/scan/segmentation.rs
@@ -46,9 +46,6 @@ impl Segmenter {
bgr.channels
));
}
- // Resize first: the channel swap is per-pixel, so doing it after the
- // downscale costs 256x256 instead of a full-resolution pass, and it
- // folds into the tensor fill below.
let resized = cv::resize_u8(bgr, MASK_SIDE, MASK_SIDE, cv::Interp::Bilinear)?;
let mut input = vec![0.0f32; resized.data.len()];
diff --git a/rust/crates/ml/src/scan/yuv.rs b/rust/crates/ml/src/scan/yuv.rs
index c72caf670a..d75d8740df 100644
--- a/rust/crates/ml/src/scan/yuv.rs
+++ b/rust/crates/ml/src/scan/yuv.rs
@@ -127,8 +127,6 @@ pub(crate) fn yuv420_to_bgr(
ImageU8::new(width, height, 3, out)
}
-/// Camera frames arrive strided; convert straight to BGR so the live path
-/// materialises one full-resolution buffer instead of three.
pub(crate) fn bgra_to_bgr(
bgra: &[u8],
row_stride: i32,