Merge storytold main into next (17 Nov sync)

storytold main 83cb1133dd (291 commits) into the integration head bab1a99b85; 47 conflicted files.

- Domain test files (metafile, prepress, pdf plates, settings store, heif, media-testkit, atomic): tests next cut stay cut; tests new on main are kept, as trials where the crate's test target runs trials.
- atomic: main's group-bits test and Faulty::set_group go to src/tests.rs. audio: main's GSM and SBC oracles join tests/main.rs. cms constructors, pdf knockout_backdrop and testing_pdf join their crates' one test binary; timeline's preflight tests become src/preflight_tests.rs trials.
- update: main's changes to detect, install (linux, macos) and the tests land in next's split modules. The app's own offer is inspected on a thread of its own, picked up by tick's polling; settle_for_tests settles offers too. Later on a ready update drops the close it asked for. updater_pin_tests.rs stays deleted; its new pin test is in tests/it/update.rs.
- craft-color: main added a different crate at crates/color (the colour tags of compositor and display frames); it is next's craft-color module `tags`, re-exported at the root.
- Old crates/ui (combo, docking, testing, README) and keymap's ui/view.rs stay deleted; main's new crates/ui/src/testing files are dropped with them.
- New crates in the craft facade: ai, control, dds, frame, ipc, media-source, palette, press-print, score, ssip. testkit and xtask are listed outside it.
- Cargo.lock: the union of both locks, resolved by cargo metadata. Workflow: main's nextest Windows leg, with next's --keep-going clippy.
This commit is contained in:
aiongg
2026-11-17 12:44:52 +00:00
581 changed files with 77998 additions and 3002 deletions
+35 -4
View File
@@ -43,6 +43,21 @@ pub fn decode(data: &[u8], max: usize) -> Step {
pub fn encode(data: &[u8]) -> Vec<u8> {
let mut out = Vec::with_capacity(data.len() + data.len() / 128 + 2);
encode_packets(data, &mut out, 2);
out.push(128);
out
}
/// Append a TIFF PackBits row without an end-of-data marker.
///
/// Runs of three or more bytes use repeat packets; pairs remain in literal packets.
/// Existing output is retained, permitting rows to be appended directly to a strip.
/// PostScript callers can append their own EOD byte after the final row.
pub fn encode_packbits_into(data: &[u8], out: &mut Vec<u8>) {
encode_packets(data, out, 3);
}
fn encode_packets(data: &[u8], out: &mut Vec<u8>, repeat_min: usize) {
let n = data.len();
let mut i = 0;
while i < n {
@@ -50,7 +65,7 @@ pub fn encode(data: &[u8]) -> Vec<u8> {
while i + run < n && run < 128 && data[i + run] == data[i] {
run += 1;
}
if run >= 2 {
if run >= repeat_min {
out.push((257 - run) as u8);
out.push(data[i]);
i += run;
@@ -59,15 +74,14 @@ pub fn encode(data: &[u8]) -> Vec<u8> {
// Literal: extend until a repeat begins or 128 bytes.
let start = i;
let mut j = i + 1;
while j < n && j - start < 128 && !(j + 1 < n && data[j] == data[j + 1]) {
while j < n && j - start < 128 && !data.get(j..).and_then(|rest| rest.get(..repeat_min)).is_some_and(|run| run.iter().all(|b| *b == data[j]))
{
j += 1;
}
out.push((j - start - 1) as u8);
out.extend_from_slice(&data[start..j]);
i = j;
}
out.push(128);
out
}
#[cfg(test)]
@@ -114,4 +128,21 @@ mod tests {
assert_eq!((e[0], e[129]), (127, 71));
assert_eq!(dec(&e).unwrap(), lit);
}
#[test]
fn packbits_appends_rows_without_eod_and_keeps_pairs_literal() {
let mut out = vec![42];
encode_packbits_into(b"aabbccc", &mut out);
assert_eq!(out, [42, 3, b'a', b'a', b'b', b'b', 254, b'c']);
let before = out.clone();
encode_packbits_into(b"", &mut out);
assert_eq!(out, before);
assert_eq!(encode(b"aa"), [255, b'a', 128]);
for n in [1, 2, 3, 127, 128, 129, 255, 256, 300] {
for row in [vec![7; n], (0..n).map(|i| (i % 251) as u8).collect()] {
let mut encoded = Vec::new();
encode_packbits_into(&row, &mut encoded);
assert_eq!(decode(&encoded, n).map_err(|failure| failure.error).unwrap(), row);
}
}
}
}