Camera: C ISP pipeline, contrast autofocus, and VFR video
CI / test (push) Canceled after 0s

- Add chandra-camera-isp.c (C/OpenMP) for Quad-Bayer unpack, CCM, and tone mapping, with a NumPy fallback when it is not built
- Add non-blocking contrast-detection VCM autofocus, with lens subdev discovery on the sensor's I2C bus
- Tune Quad-Bayer AE: a video-mode vblank cap, damped steps, and full analog gain before extending blanking
- Record variable-frame-rate video through a streaming Matroska muxer, and count dropped frames
- Ship libcamera IPA tuning files for imx376, imx519, and uncalibrated sensors
- Map camera buffers by fd and sync them with dma-buf ioctls
This commit is contained in:
nandi committed 2026-11-28 19:25:43 -08:00
1 parent 851c39d827
commit 52b42890d6
34 files changed
+2851 -364

No files matched your search

+59 -13
View File
@@ -85,6 +85,9 @@ fn font_load(slot : Int, path : String) -> Bool {
///|
extern "C" fn rs_font_has(slot : Int) -> Int = "rs_font_has"
///|
extern "C" fn rs_font_has_glyph(slot : Int, cp : Int) -> Int = "rs_font_has_glyph"
///|
#borrow(info)
extern "C" fn rs_glyph_info(
@@ -361,6 +364,12 @@ fn advance(slot : Int, cp : Int, size : Int) -> Int {
glyph_info[4]
}
///|
priv enum WasmTextPiece {
WasmGlyph(Int)
WasmEmoji(String)
}
///|
fn draw_text(l : @wt.Val, ox : Int, oy : Int) -> Unit {
let text = l.field("text").to_string()
@@ -376,13 +385,40 @@ fn draw_text(l : @wt.Val, ox : Int, oy : Int) -> Unit {
Some(f) => f
None => return // no face loaded: nothing to draw with
}
let (cap_slot, _) = match pick_face(false, mono) {
Some(f) => f
None => return
}
let extra = if embolden { 1 } else { 0 }
let cps : Array[Int] = []
let epx = @renderer.inline_emoji_px(size)
let pieces : Array[WasmTextPiece] = []
let mut total_w = 0
for ch in text {
let cp = ch.to_int()
cps.push(cp)
total_w += advance(slot, cp, size) + extra
if !@emoji.text_may_have_emoji(text) {
for ch in text {
let cp = ch.to_int()
pieces.push(WasmGlyph(cp))
total_w += advance(slot, cp, size) + extra
}
} else {
let chars = text.to_array()
let mut i = 0
while i < chars.length() {
match emoji_source.match_at(chars, i, cp => rs_font_has_glyph(slot, cp) != 0) {
Some((next, seq)) => {
pieces.push(WasmEmoji(seq))
total_w += epx
i = next
}
None => {
let cp = chars[i].to_int()
if !@emoji.is_ignorable_emoji_mod(cp) {
pieces.push(WasmGlyph(cp))
total_w += advance(slot, cp, size) + extra
}
i = i + 1
}
}
}
}
let x = l.field("x").to_int() + ox
let start_x = match l.field("align").to_int() {
@@ -391,19 +427,29 @@ fn draw_text(l : @wt.Val, ox : Int, oy : Int) -> Unit {
_ => x
}
// `y` is the vertical centre of the text; centre the capital height ('H') on it.
let (cap_slot, _) = match pick_face(false, mono) {
Some(f) => f
None => return
}
rs_glyph_info(cap_slot, 72, size, glyph_info)
let baseline = l.field("y").to_int() + oy + -glyph_info[3] / 2
let cy = l.field("y").to_int() + oy
let baseline = cy + -glyph_info[3] / 2
let r = col.field("r").to_int()
let g = col.field("g").to_int()
let b = col.field("b").to_int()
let mut pen = start_x
for cp in cps {
rs_draw_glyph(slot, cp, size, pen, baseline, r, g, b, ca, extra)
pen += advance(slot, cp, size) + extra
for piece in pieces {
match piece {
WasmGlyph(cp) => {
rs_draw_glyph(slot, cp, size, pen, baseline, r, g, b, ca, extra)
pen += advance(slot, cp, size) + extra
}
WasmEmoji(seq) => {
if epx > 0 {
let h = emoji_image(seq, epx)
if h != 0U {
rs_draw_image(h.reinterpret_as_int(), pen, cy - epx / 2, epx, epx)
}
}
pen += epx
}
}
}
}
+6
View File
@@ -33,6 +33,7 @@
int32_t mp_font_load(int32_t slot, moonbit_bytes_t path_bytes);
void mp_font_metrics(int32_t slot, int32_t cp, int32_t size, int32_t *info);
void mp_font_bitmap(int32_t slot, int32_t cp, int32_t size, int32_t w, int32_t h, moonbit_bytes_t buf);
int32_t mp_font_has_glyph(int32_t slot, int32_t cp);
/* ------------------------------------------------------------------ canvas */
@@ -315,6 +316,11 @@ void rs_font_loaded(int32_t slot) {
int32_t rs_font_has(int32_t slot) { return slot >= 0 && slot < 4 && font_loaded[slot]; }
int32_t rs_font_has_glyph(int32_t slot, int32_t cp) {
if (slot < 0 || slot >= 4 || !font_loaded[slot]) return 0;
return mp_font_has_glyph(slot, cp);
}
/* Metrics into info: width, height, xoff, yoff, advance. */
void rs_glyph_info(int32_t slot, int32_t cp, int32_t size, int32_t *info) {
Glyph *g = glyph(slot, cp, size);