Files
nandi 52b42890d6
CI / test (push) Canceled after 0s
Camera: C ISP pipeline, contrast autofocus, and VFR video
- 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
2026-11-28 19:25:43 -08:00

123 lines
4.7 KiB
MoonBit
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
///| Chandra's own copy (scripts/fetch-emoji-font.sh; `just test` fetches it).
let test_font : String = @emoji.font_path
///|
fn open_font() -> @emoji.EmojiFont {
let data = @sys.read_file_bytes(test_font)
if data.length() == 0 {
abort("font_test needs Noto Color Emoji at " + test_font + ": run scripts/fetch-emoji-font.sh")
}
@emoji.EmojiFont::parse(data) catch {
e => abort("Noto Color Emoji didn't parse: " + Show::to_string(e))
}
}
///|
test "Noto Color Emoji: the same emoji as HarfBuzz finds" {
let f = open_font()
assert_eq(f.ppem, 109)
// Counted with HarfBuzz (uharfbuzz) on Noto Color Emoji 2.051: of the 1923 listed emoji the
// font draws 1914 (some Emoji 17/18 additions are missing), and 1650 skin tone variants.
let mut base = 0
let mut tones = 0
for e in @emoji.all() {
if f.has(e.text) {
base = base + 1
}
for t in e.tones {
if f.has(t) {
tones = tones + 1
}
}
}
assert_eq(base, 1914)
assert_eq(tones, 1650)
// Ligatures: a family, a keycap, a flag and a skin tone are one picture each.
for s in ["👨‍👩‍👧‍👦", "#️⃣", "🇩🇪", "👍🏽", "🏴‍☠️", "🏴󠁧󠁢󠁳󠁣󠁴󠁿"] {
assert_eq(f.shape(s).length(), 1)
assert_true(f.has(s))
}
// Text the font can't draw as one picture.
assert_false(f.has("ab"))
let cracking = @emoji.all().filter(e => e.name == "cracking face")[0]
assert_false(f.has(cracking.text)) // Emoji 18.0, newer than this font
}
///|
test "pictures are scaled to a square, centred, with transparent corners" {
let f = open_font()
let p = f.picture("😀", 32).unwrap()
assert_eq(p.width, 32)
assert_eq(p.height, 32)
// The corner is transparent, the middle of the face is opaque yellow.
assert_eq(p.data[3].to_int(), 0)
let o = (16 * 32 + 16) * 4
assert_eq(p.data[o + 3].to_int(), 255)
assert_true(p.data[o].to_int() > 200 && p.data[o + 1].to_int() > 150 && p.data[o + 2].to_int() < 100)
assert_true(f.picture("ab", 32) is None)
}
///|
test "a file that is not a colour emoji font is an error that says why" {
let msg = try {
ignore(@emoji.EmojiFont::parse(b"\x00\x01\x00\x00\x00\x00"))
"parsed"
} catch {
e => Show::to_string(e)
}
assert_true(msg.contains("no cmap table"))
assert_true(@emoji.missing_font_message("").contains("just install"))
}
///|
test "inline emoji matcher handles turtle, sequences, VS15/VS16, and BMP symbols" {
assert_false(@emoji.text_may_have_emoji("Regency 215-223 WiFi"))
assert_false(@emoji.text_may_have_emoji("Café • … — ©"))
assert_true(@emoji.text_may_have_emoji("🐢"))
assert_true(@emoji.text_may_have_emoji("Connected to 🐢 (72%)"))
assert_true(@emoji.text_may_have_emoji("#️⃣"))
assert_true(@emoji.text_may_have_emoji("©️"))
let f = open_font()
let all_have = fn(_cp : Int) { true }
let none_have = fn(_cp : Int) { false }
assert_eq(f.match_at("🐢".to_array(), 0, all_have), Some((1, "🐢")))
assert_eq(f.match_at("Connected to 🐢 (72%)".to_array(), 13, all_have), Some((14, "🐢")))
assert_eq(f.match_at("👍🏽!".to_array(), 0, all_have), Some((2, "👍🏽")))
assert_eq(f.match_at("#️⃣x".to_array(), 0, all_have), Some((3, "#️⃣")))
assert_eq(f.match_at("🇺🇸x".to_array(), 0, all_have), Some((2, "🇺🇸")))
assert_eq(f.match_at("👨‍👩‍👧‍👦x".to_array(), 0, all_have), Some((7, "👨‍👩‍👧‍👦")))
// Bare BMP symbols stay monochrome when the UI text font has them; VS16 switches to colour, VS15 keeps text.
assert_eq(f.match_at("▶".to_array(), 0, all_have), None)
assert_eq(f.match_at("▶️".to_array(), 0, all_have), Some((2, "▶️")))
assert_eq(f.match_at("▶\u{FE0E}".to_array(), 0, all_have), None)
assert_eq(f.match_at("☀".to_array(), 0, none_have), Some((1, "☀")))
// Non-emoji ASCII / CJK / unsupported Emoji 18.0 characters do not match.
assert_eq(f.match_at("#1".to_array(), 0, all_have), None)
assert_eq(f.match_at("日本語".to_array(), 0, none_have), None)
let cracking = @emoji.all().filter(e => e.name == "cracking face")[0]
assert_eq(f.match_at(cracking.text.to_array(), 0, none_have), None)
// Noto Color Emoji's turtle renders olive-green opaque pixels at inline size.
let p = f.picture("🐢", 16).unwrap()
assert_eq((p.width, p.height), (16, 16))
let mut green = 0
for i = 0; i < p.width * p.height; i = i + 1 {
let o = i * 4
let r = p.data[o].to_int()
let g = p.data[o + 1].to_int()
let b = p.data[o + 2].to_int()
let a = p.data[o + 3].to_int()
if a > 200 && g > r && g > b + 40 {
green = green + 1
}
}
assert_true(green > 10)
let src = @emoji.EmojiSource::new()
assert_eq(src.match_at("🐢".to_array(), 0, all_have), Some((1, "🐢")))
}