Repository navigation
LR-IMP-FORMATS: decode packed 12-bit Sony ARW (DSLR-A900) from its exact 1.5 bytes per pixel strip - #573
LR-IMP-FORMATS: decode packed 12-bit Sony ARW (DSLR-A900) from its exact 1.5 bytes per pixel strip#573radialmonster wants to merge 1 commit into
Conversation
|
Note for review: @AlexChambers' #575 (stacked on #542) adds one decryptor for the |
|
Thank you @radialmonster! Requiring the exact 1.5-bytes-per-pixel strip size is a nice tight check for the A900. It can't land as it stands: #575 (SR2SubIFD white balance and black level) and #580 (16:9 crop on pre-crop-tag bodies) landed in #657, and both change Please join our Discord if you haven't already: https://discord.gg/artcraft |
…act 1.5 bytes per pixel strip Compression 32767 with BitsPerSample 12 and one strip of exactly width x height x 1.5 bytes is plain packed 12-bit data: two pixels per three bytes, least-significant-bit first (measured on the DSLR-A900 sample by same-colour neighbour smoothness, 12x smoother than the other orders). RGGB per the file's pattern tag (checked against the camera JPEG), black 128, crop = FullImageSize centred in the frame (on even offsets). White balance: the hard-coded maker-note block at offset 188 is gone. The SR2SubIFD WB_RGGBLevels read since storytold#575 give 2688/1024/1024/1516 on the CC0 sample, i.e. 2.625 / 1.0 / 1.480, identical to the block's values, so the existing chain covers the A900. Rebased onto main after storytold#575/storytold#580 (storytold#657): keeps main's default_crop signature and recorded_size_crop; the A900 centring is applied afterwards by centred_in_frame. RENDER_CACHE_VERSION 37 -> 41 (other branches take 38-40; adjust at merge).
|
@echelon rebased onto main, and you were right about the white balance:
|
20d7d9e to
4945d27
Compare
|
Thank you @radialmonster! The A900 decoder landed in #692, from the maintainer merge on this branch (20d7d9e):
Please join our Discord if you haven't already: https://discord.gg/artcraft |
…ultCrop helper side by side (merge put the flag on the wrong function) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…plicates Synchronize Folder: import suspected duplicates on request (upstream storytold#2034)
TL;DR: Sony DSLR-A900 raw files are plain packed 12-bit data (two pixels per three bytes), not a compressed format. This PR decodes them instead of showing the embedded preview. Item 6 of #535. The A850 is not covered by any measurement: there is no A850 sample in the test archive.
Change
crates/raw/src/vendor/arw.rs: a Sony ARW with Compression 32767, BitsPerSample 12, one strip and an even width is read as packed 12-bit data when the strip is exactly width x height x 1.5 bytes. Two pixels are stored in three bytes, least-significant-bit first:b0 | (b1 & 0xf) << 8andb1 >> 4 | b2 << 4. Any other strip size still returns the existingUnsupported("... packed compressed variant ..."), so the A200/A230/A290/A350/A380/A390 behave as before.FullImageSizewindow centred in the frame (the file has no crop tags), as-shot white balance from a plain block in the maker note (read only when that block has the exact size seen in the sample and both green levels are unity).crates/engine/src/media.rs:RENDER_CACHE_VERSION22 -> 24. Main is at 22 and other open PRs use 23, so 24 is the next free number here; it will need adjusting at merge.How the rule was established
Only from values measured in the sample file and LightCraft's own code (full record in the investigation log).
Results
CC0 sample from raw.pixls.us (id 5858). Left: camera JPEG; right: this change.
Tests
packed_12_bit_strip_of_one_and_a_half_bytes_per_pixel_decodes: hand-made TIFF bytes (an 8 x 4 image packed with a reference packer) decode to the exact samples in header and full mode, with RGGB, black 128 and 12 bits; the three bytes12 A3 45unpack to0x312and0x45A. It fails without the change.packed_12_bit_needs_the_exact_strip_size: strips one byte short, one byte over, or padded per row, and an odd width, stay Unsupported.a900_white_balance_block_is_read_only_when_it_matches: the measured block gives 2.625 / 1 / 1.480; a wrong size, a non-unity green or an absurd red gain is rejected.strip_larger_or_smaller_than_one_byte_per_pixel_is_the_packed_variantstill passes.Not covered
CI
cargo fmt --check: cleancargo clippy --workspace --all-targets -- -D warnings: cleancargo test --workspace --no-fail-fast(with the corpus): all pass exceptheadless::tests::browse_a_local_folderin ui-egui (a path-separator mismatch in a temp folder on the P: drive,P:\...againstP:/...; it fails the same way on unmodified main in this environment, and nothing in this change touches the UI)cargo xtask parity,layers,assets,wasm: pass (parity prints a note that the summary indocs/parity.mdis stale; unrelated to this change)Update after review: rebased onto main. The as-shot white balance now comes from #575's SR2
WB_RGGBLevels, which gives the same values as the offset-188 block did, so that block is removed.RENDER_CACHE_VERSIONis 41.