Put the RAW decoder behind a Decoder trait
FR-RAW-2 says a second decoder may be added for broader camera coverage without changing callers, and D2 names LibRaw as that second decoder. Nothing tested the claim: dr_decode was one decoder reached through free functions, so adding another would have meant editing every caller at the moment there was most pressure not to. Decoder is an object-safe trait over bytes: header_bytes, metadata, orientation, locate_preview, preview and decode. Rawler implements it by delegating to the existing free functions, so behaviour is unchanged, and dr_decode::default() hands it out as a &'static dyn Decoder, which is what the places that start work will name. JPEG recognition, decoding and completeness checks stay free functions: they are not a RAW decoder's to vary. Nothing in the trait takes a path or a SourceRef; the decoder states how much of a file it needs and where its preview sits, and the caller's storage fetches that.
This commit is contained in:
@@ -11,14 +11,20 @@
|
||||
//!
|
||||
//! Fusing them would force a full decode where a header read suffices, which
|
||||
//! is exactly why Lightroom stalls ~2 s per image during culling.
|
||||
//!
|
||||
//! Callers reach these through the [`Decoder`] trait rather than by name, so a
|
||||
//! second decoder can be put behind them without changing any of them
|
||||
//! (FR-RAW-2). [`Rawler`] is the one that ships; [`default`] hands it out.
|
||||
|
||||
pub mod base_curve;
|
||||
mod decoder;
|
||||
mod error;
|
||||
mod locate;
|
||||
mod preview;
|
||||
pub mod profile;
|
||||
|
||||
pub use base_curve::BaseCurve;
|
||||
pub use decoder::{default, Decoder, Rawler};
|
||||
pub use error::DecodeError;
|
||||
pub use locate::{
|
||||
defects, is_complete_jpeg, jpeg_metadata, locate_preview, tiff_metadata, BadLine, BadPixel,
|
||||
|
||||
Reference in New Issue
Block a user