chore(i18n): finish translating code comments and scripts to English
CI / Format and clippy (push) Successful in 1m57s
CI / Dependency audit (push) Successful in 13s
CI / Check desktop app (Linux) (push) Successful in 3m54s
CI / Tests (Linux) (push) Failing after 7m25s
Release / Create release (push) Successful in 6s
Release / CLI (linux-aarch64) (push) Successful in 1m48s
Release / CLI (linux-x86_64) (push) Successful in 2m39s
Release / Desktop app (linux-aarch64) (push) Successful in 10m9s
Release / Desktop app (linux-x86_64) (push) Successful in 12m20s
Release / Desktop app (windows) (push) Successful in 7m32s
Release / Build latest.json (push) Successful in 5s
CI / Format and clippy (push) Successful in 1m57s
CI / Dependency audit (push) Successful in 13s
CI / Check desktop app (Linux) (push) Successful in 3m54s
CI / Tests (Linux) (push) Failing after 7m25s
Release / Create release (push) Successful in 6s
Release / CLI (linux-aarch64) (push) Successful in 1m48s
Release / CLI (linux-x86_64) (push) Successful in 2m39s
Release / Desktop app (linux-aarch64) (push) Successful in 10m9s
Release / Desktop app (linux-x86_64) (push) Successful in 12m20s
Release / Desktop app (windows) (push) Successful in 7m32s
Release / Build latest.json (push) Successful in 5s
Completes the English-only standardization for code, comments, scripts and CI templates (UI/CLI-facing strings stay bilingual pt-BR/en, untouched). Covers the remaining crates/, apps/gui/ui/ and apps/gui/src-tauri/ comments, .gitea/ workflow and template comments, .githooks/ hooks, and the scripts/ source comments for the files already renamed in a prior commit (check.sh, generate-logo.py, install-hooks.sh). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VAyr8d7HuAdUGB6aA5xmDD
This commit is contained in:
1 parent
da212e6926
commit
6328220c60
129 files changed
+1961
-1834
No files matched your search
@@ -1,13 +1,13 @@
|
||||
//! Decodificador de entropia de JPEG sequencial (Huffman, 8 bits), sem IDCT.
|
||||
//! Baseline sequential JPEG Huffman entropy decoder (8-bit), plus lightweight IDCT.
|
||||
//!
|
||||
//! Serve para validar se os bytes de um JPEG são realmente contínuos e para reconstruir arquivos
|
||||
//! fragmentados: o fluxo é decodificado MCU a MCU, guardando o DC de luminância (uma miniatura
|
||||
//! 1/8 da imagem) e pontos de retomada. Depois de uma quebra os bytes viram lixo, e a
|
||||
//! descontinuidade do DC (ou um erro de código) denuncia onde.
|
||||
//! Validates whether a JPEG stream is contiguous and assists in reassembling fragmented
|
||||
//! JPEGs: decodes MCU by MCU, tracking luminance DC values (a 1/8th thumbnail) and
|
||||
//! decoder checkpoints. After a fragmentation break, foreign clusters cause either
|
||||
//! a Huffman/marker error or a sharp luminance discontinuity.
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct Huff {
|
||||
// decodificação canônica
|
||||
// canonical Huffman decoding tables
|
||||
mincode: [i32; 17],
|
||||
maxcode: [i32; 18],
|
||||
valptr: [i32; 17],
|
||||
@@ -54,9 +54,9 @@ pub struct Header {
|
||||
pub restart: u32,
|
||||
pub mcus_x: u32,
|
||||
pub mcus_y: u32,
|
||||
/// Onde começam os dados entropy-coded (depois do SOS).
|
||||
/// Byte offset where entropy-coded scan data begins (immediately after SOS).
|
||||
pub scan_start: usize,
|
||||
/// Tabelas de quantização (ordem zigzag).
|
||||
/// Quantization tables (in zigzag order).
|
||||
pub qt: [[u16; 64]; 4],
|
||||
dc: [Option<Huff>; 4],
|
||||
ac: [Option<Huff>; 4],
|
||||
@@ -68,7 +68,7 @@ impl Header {
|
||||
}
|
||||
}
|
||||
|
||||
/// Lê os segmentos até o SOS. `None` se não for JPEG sequencial suportado.
|
||||
/// Parses JPEG marker segments up to SOS. Returns `None` if not a supported baseline JPEG.
|
||||
pub fn parse_header(d: &[u8]) -> Option<Header> {
|
||||
if d.len() < 4 || d[0] != 0xFF || d[1] != 0xD8 {
|
||||
return None;
|
||||
@@ -119,7 +119,7 @@ pub fn parse_header(d: &[u8]) -> Option<Header> {
|
||||
.collect();
|
||||
sof = Some((w, h, comps));
|
||||
}
|
||||
0xC2 | 0xC3 | 0xC5..=0xC7 | 0xC9..=0xCB | 0xCD..=0xCF => return None, // progressivo, aritmético etc.
|
||||
0xC2 | 0xC3 | 0xC5..=0xC7 | 0xC9..=0xCB | 0xCD..=0xCF => return None, // progressive, arithmetic coding, etc.
|
||||
0xC4 => {
|
||||
let mut q = 0;
|
||||
while q + 17 <= seg.len() {
|
||||
@@ -167,7 +167,7 @@ pub fn parse_header(d: &[u8]) -> Option<Header> {
|
||||
let (w, h, comps) = sof?;
|
||||
let ns = *seg.first()? as usize;
|
||||
if ns != comps.len() || seg.len() < 1 + ns * 2 + 3 {
|
||||
return None; // varredura não intercalada
|
||||
return None; // non-interleaved scan
|
||||
}
|
||||
let mut cs = vec![];
|
||||
for i in 0..ns {
|
||||
@@ -212,20 +212,20 @@ pub fn parse_header(d: &[u8]) -> Option<Header> {
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Stop {
|
||||
/// Todos os MCUs foram decodificados.
|
||||
/// All MCUs in the frame were decoded.
|
||||
Done,
|
||||
/// Marcador inesperado (inclusive EOI) na posição dada.
|
||||
/// Unexpected marker (including early EOI) at the given byte offset.
|
||||
Marker(u8, usize),
|
||||
/// Código inválido ou coeficiente fora do limite.
|
||||
/// Invalid Huffman code or DCT coefficient index out of bounds.
|
||||
Error(usize),
|
||||
/// Faltam bytes.
|
||||
/// Truncated bitstream (ran out of input bytes).
|
||||
Truncated,
|
||||
}
|
||||
|
||||
/// Estado completo do decodificador num limite de byte, para retomar com outros dados.
|
||||
/// Complete entropy decoder snapshot at a byte boundary, allowing resumption on candidate fragments.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct State {
|
||||
/// Próximo byte a buscar no fluxo.
|
||||
/// Next byte offset to read from the entropy stream.
|
||||
pub pos: usize,
|
||||
bitbuf: u32,
|
||||
bitcnt: u32,
|
||||
@@ -236,7 +236,7 @@ pub struct State {
|
||||
}
|
||||
|
||||
impl State {
|
||||
/// Último DC de luminância (preditor) no ponto de retomada.
|
||||
/// Last luminance DC predictor value at this checkpoint.
|
||||
pub fn luma_pred(&self) -> i32 {
|
||||
self.pred[0]
|
||||
}
|
||||
@@ -254,9 +254,9 @@ impl State {
|
||||
}
|
||||
|
||||
pub struct Decoded {
|
||||
/// DC de luminância (absoluto) por MCU decodificado.
|
||||
/// Absolute luminance DC coefficient for each decoded MCU.
|
||||
pub dc: Vec<i32>,
|
||||
/// Estados guardados em intervalos (para retomada): (MCU, estado ao fim dele).
|
||||
/// Periodic decoder checkpoints for resumption: `(mcu_index, state_after_mcu)`.
|
||||
pub snaps: Vec<State>,
|
||||
pub stop: Stop,
|
||||
pub state: State,
|
||||
@@ -341,13 +341,13 @@ fn extend(v: u32, t: u32) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Decodifica até `max_mcus` MCUs a partir de `state`, sobre `data` (fluxo bruto com FF00).
|
||||
/// `snap_every` > 0 guarda estados a cada tantos bytes consumidos.
|
||||
/// Decodes up to `max_mcus` MCUs starting from `state` over `data` (raw byte-stuffed stream).
|
||||
/// When `snap_every > 0`, records a resumption snapshot every `snap_every` consumed bytes.
|
||||
pub fn decode(h: &Header, data: &[u8], state: State, max_mcus: u32, snap_every: usize) -> Decoded {
|
||||
decode_hook(h, data, state, max_mcus, snap_every, None)
|
||||
}
|
||||
|
||||
/// Como `decode`, mas entrega os coeficientes (zigzag) dos blocos de luminância de cada MCU.
|
||||
/// Like `decode`, but also invokes `on_luma` with the zigzag DCT coefficients of each MCU's luma blocks.
|
||||
pub fn decode_hook(
|
||||
h: &Header,
|
||||
data: &[u8],
|
||||
@@ -369,9 +369,9 @@ pub fn decode_hook(
|
||||
let mut stop = Stop::Done;
|
||||
let mut decoded = 0u32;
|
||||
'mcu: while b.st.mcu < total && decoded < max_mcus {
|
||||
// Marcador de reinício entre MCUs.
|
||||
// Expected restart marker between MCUs.
|
||||
if h.restart > 0 && b.st.mcus_since_rst == h.restart {
|
||||
// descarta bits de preenchimento e espera RSTn
|
||||
// discard byte-align padding bits and verify RSTn marker
|
||||
b.st.bitbuf = 0;
|
||||
b.st.bitcnt = 0;
|
||||
let p = b.st.pos;
|
||||
@@ -486,8 +486,8 @@ fn fail(b: &Bits, data: &[u8]) -> Stop {
|
||||
}
|
||||
}
|
||||
|
||||
/// Primeiro MCU suspeito: janela de `win` MCUs cuja diferença média de DC é anormalmente alta.
|
||||
/// Devolve o índice do MCU onde a janela começa.
|
||||
/// Detects the first suspicious MCU where a sliding window of `win` MCUs exhibits an abnormally
|
||||
/// high mean DC jump. Returns the starting MCU index of that window.
|
||||
pub fn first_discontinuity(h: &Header, dc: &[i32]) -> Option<usize> {
|
||||
let mx = h.mcus_x as usize;
|
||||
let d: Vec<f64> = (0..dc.len())
|
||||
@@ -505,7 +505,7 @@ pub fn first_discontinuity(h: &Header, dc: &[i32]) -> Option<usize> {
|
||||
if d.len() < win * 2 {
|
||||
return None;
|
||||
}
|
||||
// Referência: mediana das diferenças vistas até aqui (histograma, robusta a bordas).
|
||||
// Baseline reference: running median of row-to-row DC differences (robust to sharp edges).
|
||||
let mut hist = vec![0u32; 2048];
|
||||
let mut seen = 0u32;
|
||||
let mut sum: f64 = d[..win].iter().sum();
|
||||
@@ -529,7 +529,7 @@ pub fn first_discontinuity(h: &Header, dc: &[i32]) -> Option<usize> {
|
||||
return Some(i + 1 - win);
|
||||
}
|
||||
}
|
||||
// Só entra na referência o que ainda parece normal.
|
||||
// Only update the baseline histogram with rows that still look normal.
|
||||
if i < win * 3 || d[i] < 300.0 {
|
||||
hist[(d[i] as usize).min(2047)] += 1;
|
||||
seen += 1;
|
||||
@@ -566,7 +566,7 @@ fn cos_table() -> &'static [[f32; 8]; 8] {
|
||||
})
|
||||
}
|
||||
|
||||
/// IDCT de um bloco (coeficientes em zigzag, quantizados) para 8x8 pixels de luminância.
|
||||
/// Dequantizes and runs an 8x8 IDCT on a zigzag coefficient block into 8x8 luma pixels.
|
||||
pub fn idct_block(coef: &[i32; 64], qt: &[u16; 64]) -> [u8; 64] {
|
||||
let mut f = [[0f32; 8]; 8];
|
||||
for z in 0..64 {
|
||||
@@ -574,7 +574,7 @@ pub fn idct_block(coef: &[i32; 64], qt: &[u16; 64]) -> [u8; 64] {
|
||||
f[n / 8][n % 8] = (coef[z] * qt[z] as i32) as f32;
|
||||
}
|
||||
let t = cos_table();
|
||||
// linhas
|
||||
// rows
|
||||
let mut tmp = [[0f32; 8]; 8];
|
||||
for v in 0..8 {
|
||||
for x in 0..8 {
|
||||
@@ -598,7 +598,7 @@ pub fn idct_block(coef: &[i32; 64], qt: &[u16; 64]) -> [u8; 64] {
|
||||
out
|
||||
}
|
||||
|
||||
/// Luminância de um MCU (blocos `h` x `v` da primeira componente) como imagem (8h x 8v).
|
||||
/// Renders the luma blocks (`h` x `v`) of a single MCU into an `8h x 8v` pixel tile.
|
||||
pub fn mcu_luma(h: &Header, blocks: &[[i32; 64]]) -> Vec<u8> {
|
||||
let c = &h.comps[0];
|
||||
let (bw, bh) = (c.h as usize, c.v as usize);
|
||||
@@ -615,7 +615,7 @@ pub fn mcu_luma(h: &Header, blocks: &[[i32; 64]]) -> Vec<u8> {
|
||||
out
|
||||
}
|
||||
|
||||
/// Plano de luminância do que já foi decodificado.
|
||||
/// Luma pixel plane of the decoded image prefix.
|
||||
pub struct Plane {
|
||||
pub w: usize,
|
||||
pub h: usize,
|
||||
@@ -648,7 +648,7 @@ impl Plane {
|
||||
}
|
||||
}
|
||||
|
||||
/// Decodifica e preenche o plano com as luminâncias.
|
||||
/// Decodes `data` from `state` and renders the luma plane.
|
||||
pub fn decode_plane(
|
||||
h: &Header,
|
||||
data: &[u8],
|
||||
|
||||
Reference in new issue
Block a user