- 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:
1 parent
851c39d827
commit
52b42890d6
34 files changed
+2851
-364
No files matched your search
@@ -368,6 +368,197 @@ pub fn EmojiFont::has(self : EmojiFont, text : String) -> Bool raise EmojiFontEr
|
||||
gs.length() == 1 && self.glyph_png(gs[0]) is Some(_)
|
||||
}
|
||||
|
||||
///| Whether `cp` is an emoji skin tone modifier (Fitzpatrick Type-1-2 through Type-6).
|
||||
fn is_skin_tone(cp : Int) -> Bool {
|
||||
cp >= 0x1F3FB && cp <= 0x1F3FF
|
||||
}
|
||||
|
||||
///| Whether `text` contains any code point >= U+203C (covering emoji, keycap combining
|
||||
/// enclosing keycap U+20E3, and variation selector U+FE0F).
|
||||
pub fn text_may_have_emoji(text : String) -> Bool {
|
||||
for ch in text {
|
||||
if ch.to_int() >= 0x203C {
|
||||
return true
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
///| Default-ignorable emoji joiner / variation selectors (U+FE0E, U+FE0F, U+200D).
|
||||
pub fn is_ignorable_emoji_mod(cp : Int) -> Bool {
|
||||
cp == 0xFE0E || cp == 0xFE0F || cp == 0x200D
|
||||
}
|
||||
|
||||
///| Whether a non-ASCII code point >= U+203C sits in a Unicode block that can start an emoji.
|
||||
fn may_start_emoji_non_ascii(cp : Int) -> Bool {
|
||||
(cp >= 0x203C && cp <= 0x21AA) ||
|
||||
(cp >= 0x2300 && cp <= 0x27BF) ||
|
||||
(cp >= 0x2934 && cp <= 0x2935) ||
|
||||
(cp >= 0x2B00 && cp <= 0x2BFF) ||
|
||||
cp == 0x3030 ||
|
||||
cp == 0x303D ||
|
||||
cp == 0x3297 ||
|
||||
cp == 0x3299 ||
|
||||
(cp >= 0x1F000 && cp <= 0x1FBFF)
|
||||
}
|
||||
|
||||
///| Exclusive end index of the maximal candidate emoji cluster starting at `chars[start]`,
|
||||
/// or `start` when `chars[start]` cannot start an emoji sequence.
|
||||
pub fn candidate_end(chars : Array[Char], start : Int) -> Int {
|
||||
let n = chars.length()
|
||||
if start < 0 || start >= n {
|
||||
return start
|
||||
}
|
||||
let cp = chars[start].to_int()
|
||||
if is_ignorable_emoji_mod(cp) || cp == 0x20E3 {
|
||||
return start
|
||||
}
|
||||
if cp < 0x80 {
|
||||
// ASCII can only start a keycap emoji (#️⃣, *️⃣, 0️⃣..9️⃣).
|
||||
let is_keycap = cp == 0x23 || cp == 0x2A || (cp >= 0x30 && cp <= 0x39)
|
||||
if !is_keycap {
|
||||
return start
|
||||
}
|
||||
if start + 1 < n && chars[start + 1].to_int() == 0x20E3 {
|
||||
return start + 2
|
||||
}
|
||||
if start + 2 < n && chars[start + 1].to_int() == 0xFE0F && chars[start + 2].to_int() == 0x20E3 {
|
||||
return start + 3
|
||||
}
|
||||
return start
|
||||
}
|
||||
if cp < 0x203C {
|
||||
// Only ©️ / ®️ with explicit emoji presentation selector.
|
||||
if (cp == 0xA9 || cp == 0xAE) && start + 1 < n && chars[start + 1].to_int() == 0xFE0F {
|
||||
return start + 2
|
||||
}
|
||||
return start
|
||||
}
|
||||
if !may_start_emoji_non_ascii(cp) {
|
||||
return start
|
||||
}
|
||||
if cp >= 0x1F1E6 && cp <= 0x1F1FF {
|
||||
if start + 1 < n {
|
||||
let next = chars[start + 1].to_int()
|
||||
if next >= 0x1F1E6 && next <= 0x1F1FF {
|
||||
return start + 2
|
||||
}
|
||||
}
|
||||
return start + 1
|
||||
}
|
||||
let limit = if start + 16 < n { start + 16 } else { n }
|
||||
if cp == 0x1F3F4 && start + 1 < limit {
|
||||
let first_tag = chars[start + 1].to_int()
|
||||
if first_tag >= 0xE0020 && first_tag <= 0xE007E {
|
||||
let mut j = start + 1
|
||||
while j < limit - 1 {
|
||||
let t = chars[j].to_int()
|
||||
if t >= 0xE0020 && t <= 0xE007E {
|
||||
j = j + 1
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if j < limit && chars[j].to_int() == 0xE007F {
|
||||
return j + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut i = start + 1
|
||||
if i < limit && chars[i].to_int() == 0xFE0F {
|
||||
i = i + 1
|
||||
}
|
||||
if i < limit && is_skin_tone(chars[i].to_int()) {
|
||||
i = i + 1
|
||||
}
|
||||
while i + 1 < limit && chars[i].to_int() == 0x200D {
|
||||
let next = chars[i + 1].to_int()
|
||||
if next < 0x80 || is_ignorable_emoji_mod(next) || next == 0x20E3 {
|
||||
break
|
||||
}
|
||||
i = i + 2
|
||||
if i < limit && chars[i].to_int() == 0xFE0F {
|
||||
i = i + 1
|
||||
}
|
||||
if i < limit && is_skin_tone(chars[i].to_int()) {
|
||||
i = i + 1
|
||||
}
|
||||
}
|
||||
i
|
||||
}
|
||||
|
||||
///| Match the longest emoji sequence starting at `chars[start]` accepted by `has_emoji`.
|
||||
/// Respects U+FE0E text presentation and keeps bare BMP symbols monochrome when `has_text_glyph`
|
||||
/// reports the text font has them.
|
||||
pub fn match_with(
|
||||
chars : Array[Char],
|
||||
start : Int,
|
||||
has_text_glyph : (Int) -> Bool,
|
||||
has_emoji : (String) -> Bool,
|
||||
) -> (Int, String)? {
|
||||
let max_end = candidate_end(chars, start)
|
||||
if max_end <= start {
|
||||
return None
|
||||
}
|
||||
let cp = chars[start].to_int()
|
||||
if start + 1 < chars.length() && chars[start + 1].to_int() == 0xFE0E && has_text_glyph(cp) {
|
||||
return None
|
||||
}
|
||||
let mut end = max_end
|
||||
while end > start {
|
||||
if chars[end - 1].to_int() == 0x200D {
|
||||
end = end - 1
|
||||
continue
|
||||
}
|
||||
if cp < 0x80 && chars[end - 1].to_int() != 0x20E3 {
|
||||
end = end - 1
|
||||
continue
|
||||
}
|
||||
if end == start + 1 && cp < 0x1F000 && has_text_glyph(cp) {
|
||||
return None
|
||||
}
|
||||
let sb = StringBuilder::new()
|
||||
for k = start; k < end; k = k + 1 {
|
||||
sb.write_char(chars[k])
|
||||
}
|
||||
let sub = sb.to_string()
|
||||
if has_emoji(sub) {
|
||||
return Some((end, sub))
|
||||
}
|
||||
end = end - 1
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
///| Match the longest emoji sequence starting at `chars[start]` that this font can draw.
|
||||
pub fn EmojiFont::match_at(
|
||||
self : EmojiFont,
|
||||
chars : Array[Char],
|
||||
start : Int,
|
||||
has_text_glyph : (Int) -> Bool,
|
||||
) -> (Int, String)? raise EmojiFontError {
|
||||
if start < 0 || start >= chars.length() {
|
||||
return None
|
||||
}
|
||||
let cp = chars[start].to_int()
|
||||
if cp >= 0x80 && self.glyph(cp) == 0 {
|
||||
return None
|
||||
}
|
||||
let mut err : EmojiFontError? = None
|
||||
let res = match_with(chars, start, has_text_glyph, s => {
|
||||
try self.has(s) catch {
|
||||
e => {
|
||||
err = Some(e)
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
match err {
|
||||
Some(e) => raise e
|
||||
None => res
|
||||
}
|
||||
}
|
||||
|
||||
///| The picture for `text`, `px` x `px` (the bitmap scaled to fit and centred), straight RGBA.
|
||||
/// None when the font has no single picture for it.
|
||||
pub fn EmojiFont::picture(self : EmojiFont, text : String, px : Int) -> @renderer.Pixmap? raise EmojiFontError {
|
||||
@@ -515,3 +706,26 @@ pub fn EmojiSource::image(self : EmojiSource, text : String, px : Int, put : (@r
|
||||
self.images.set(key, h)
|
||||
h
|
||||
}
|
||||
|
||||
///| Match the longest emoji sequence starting at `chars[start]` using the open font.
|
||||
/// Opens the font lazily on first use; does not retry a failed open on every text draw call.
|
||||
pub fn EmojiSource::match_at(
|
||||
self : EmojiSource,
|
||||
chars : Array[Char],
|
||||
start : Int,
|
||||
has_text_glyph : (Int) -> Bool,
|
||||
) -> (Int, String)? {
|
||||
if self.state is None {
|
||||
ignore(self.font())
|
||||
}
|
||||
match self.state {
|
||||
Some(Ok((_, f))) =>
|
||||
try f.match_at(chars, start, has_text_glyph) catch {
|
||||
EmojiFontError(why) => {
|
||||
@sys.log("emoji: can't match inline emoji: " + why)
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user