LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
LRC-LIB-CATALOG-IMPORT: an ARW6 is described from the whole file, not a partial read
dev-null-undefined5bf455c45634
diff --git a/crates/raw/src/sparse.rs b/crates/raw/src/sparse.rsindex 14fa3c1f8..e5a8e787d 100644--- a/crates/raw/src/sparse.rs+++ b/crates/raw/src/sparse.rs@@ -13,9 +13,9 @@//! tracks (keeping the raw track's coding headers and quantization maps, and the timed-metadata//! track where Canon puts the as-shot white balance), a RAF's CFA strip (keeping its compression//! header) and a Panasonic RW2's raw data. Formats whose header probe reads samples (NEF: masked-//! columns; ORF: bit depth and CFA phase; PEF: dark borders) and anything else get-//! [`HeaderPlan::Whole`], as does a structure that is incomplete, inconsistent or keeps metadata-//! inside its sample data: the plan never guesses.+//! columns; ORF: bit depth and CFA phase; PEF: dark borders; ARW6, for its header plan only: the+//! start of every tile) and anything else get [`HeaderPlan::Whole`], as does a structure that is+//! incomplete, inconsistent or keeps metadata inside its sample data: the plan never guesses.use std::collections::HashSet;@@ -236,6 +236,8 @@ fn tiff_plan(bytes: &[u8], loaded: &Ranges, preview: bool) -> HeaderPlan {let chunks: Vec<(u64, u64)> = match ifd.image() {// a preview's strips are read when the preview is wanted: only the raw image is skippedOk(info) if preview && !matches!(info.photometric, t::photometric::CFA | t::photometric::LINEAR_RAW) => continue,+ // (Sony Compressed RAW 2: the header probe decodes the start of every tile; a preview reads none)+ Ok(info) if !preview && info.compression == 32766 => return HeaderPlan::Whole("an ARW6 header probe reads its tiles"),Ok(info) => info.chunks(len).iter().map(|c| (c.offset, c.len)).collect(),// a raw IFD without the tags a TIFF image needs (an older CR2's) still lists its stripsErr(_) => match (ifd.u64s(t::STRIP_OFFSETS), ifd.u64s(t::STRIP_BYTE_COUNTS)) {@@ -550,4 +552,17 @@ mod tests {raf[104..108].copy_from_slice(&1000u32.to_be_bytes());assert_eq!(run(&raf, 160, 0).0, HeaderPlan::Whole("RAF raw container"));}++ /// An ARW6 header probe reads every tile's headers and the first lines of its data, which lie in the strip a+ /// plan would skip: here the second tile, past a first one of bulk size.+ #[test]+ fn arw6_is_described_from_the_whole_file() {+ use crate::vendor::arw6_testenc::{Qis, arw6_file, one_tile_quantised};+ let (tile, _) = one_tile_quantised(64, 48, 0, Qis::REAL);+ let mut first = tile.clone();+ first.resize(BULK as usize, 0);+ let file = arw6_file(&[(0, 0, 64, 48, first), (64, 0, 64, 48, tile)], 128, 48);+ assert!(crate::probe_info(&file).is_ok());+ assert_eq!(run(&file, 16, 0).0, HeaderPlan::Whole("an ARW6 header probe reads its tiles"));+ }}