diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..be664f6 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,30 @@ +name: 🐧 Linux +on: + push: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + linux-cli: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Install basic libraries + run: sudo apt update || true; sudo apt install git -y + + - name: Clone rawloader and multicache + run: | + - git clone https://github.com/pedrocr/rawloader.git ../rawloader/ + - git clone https://github.com/pedrocr/multicache.git ../multicache/ + + - name: Setup rust version + run: rustup default stable + + - name: Build + run: cargo build + + - name: Test + run: cargo test diff --git a/Cargo.toml b/Cargo.toml index d2b52ec..d2fc344 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,16 +15,16 @@ lazy_static = "1" rayon = "1" serde = "1" serde_derive = "1" -serde_yaml = "0.8" +serde_yaml = "0.9.33" bincode = "1" blake3 = "1" log = "0.4" num-traits = "0.2" -image = "0.24" +image = { version = "0.25", default-features = false, features = ["jpeg"] } -[dependencies.rawloader] -version = "0.37" -path = "../rawloader" +[dependencies.rawler] +version = "0.6" +#path = "../rawloader" [dependencies.multicache] version = "0.6.0" diff --git a/src/bin/converter.rs b/src/bin/converter.rs index 9e357f0..3542367 100644 --- a/src/bin/converter.rs +++ b/src/bin/converter.rs @@ -2,10 +2,10 @@ use std::env; use std::fs::File; use std::io::BufWriter; //use std::time::Instant; -use image::ColorType; +use image::ExtendedColorType; extern crate imagepipe; -extern crate rawloader; +extern crate rawler; extern crate image; fn usage() { @@ -67,6 +67,6 @@ fn main() { let mut jpg_encoder = image::codecs::jpeg::JpegEncoder::new_with_quality(&mut f, 90); jpg_encoder - .encode(&decoded.data, decoded.width as u32, decoded.height as u32, ColorType::Rgb8) + .encode(&decoded.data, decoded.width as u32, decoded.height as u32, ExtendedColorType::Rgb8) .expect("Encoding image in JPEG format failed."); } diff --git a/src/lib.rs b/src/lib.rs index c574f07..b793131 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ #[macro_use] extern crate serde_derive; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; -extern crate rawloader; extern crate image; mod buffer; diff --git a/src/opbasics.rs b/src/opbasics.rs index 6f1fc96..5012d5f 100644 --- a/src/opbasics.rs +++ b/src/opbasics.rs @@ -2,6 +2,6 @@ pub use crate::buffer::*; pub use crate::pipeline::*; pub use crate::hasher::*; pub use crate::color_conversions::*; -pub use rawloader::{RawImage, CFA, Orientation, RawImageData}; +pub use rawler::{RawImage, CFA, Orientation, RawImageData}; pub use std::sync::Arc; pub use std::cmp; diff --git a/src/ops/demosaic.rs b/src/ops/demosaic.rs index 19520cf..56d9e2d 100644 --- a/src/ops/demosaic.rs +++ b/src/ops/demosaic.rs @@ -10,7 +10,8 @@ impl OpDemosaic { match img { ImageSource::Raw(img) => { OpDemosaic{ - cfa: img.cropped_cfa().to_string(), + // TODO change to CFA::shift() + cfa: img.camera.cfa.to_string(), } }, ImageSource::Other(_) => { diff --git a/src/ops/gofloat.rs b/src/ops/gofloat.rs index 4c8db0a..91e50c8 100644 --- a/src/ops/gofloat.rs +++ b/src/ops/gofloat.rs @@ -20,14 +20,36 @@ impl OpGoFloat { match img { ImageSource::Raw(img) => { // Calculate the resulting width/height and top-left corner after crops + let black_level_array: [u16; 4] = img.camera.blacklevel.clone().map(|e| { + [*e.get(0).unwrap_or(&0) as u16, + *e.get(1).unwrap_or(&0)as u16, + *e.get(2).unwrap_or(&0)as u16, + *e.get(3).unwrap_or(&0)as u16] + }).unwrap_or([0u16; 4]); + + let white_level_array: [u16; 4] = img.camera.whitelevel.clone().map(|e| { + [*e.get(0).unwrap_or(&0) as u16, + *e.get(1).unwrap_or(&0)as u16, + *e.get(2).unwrap_or(&0)as u16, + *e.get(3).unwrap_or(&0)as u16] + }).unwrap_or([0u16; 4]); + + let _rect = img.crop_area.unwrap_or_default(); + + // Nothing works :( + OpGoFloat{ - crop_top: img.crops[0], - crop_right: img.crops[1], - crop_bottom: img.crops[2], - crop_left: img.crops[3], - is_cfa: img.cfa.is_valid(), - blacklevels: from_int4(img.blacklevels), - whitelevels: from_int4(img.whitelevels), + // crop_top: rect.y() + rect.height(), + // crop_right: rect.x() + rect.width(), + // crop_bottom: rect.y(), + // crop_left: rect.x(), + crop_top: 0, + crop_right: 0, + crop_bottom: 0, + crop_left: 0, + is_cfa: img.camera.cfa.is_valid(), + blacklevels: from_int4(black_level_array), + whitelevels: from_int4(white_level_array), } }, ImageSource::Other(_) => { diff --git a/src/pipeline.rs b/src/pipeline.rs index db9602a..4dccb40 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -1,7 +1,6 @@ use crate::ops::*; use crate::opbasics::*; -extern crate rawloader; extern crate multicache; use self::multicache::MultiCache; extern crate serde; @@ -261,7 +260,7 @@ impl Pipeline { pub fn new_from_file>(path: P) -> Result { do_timing!("total new_from_file()", { - if let Ok(img) = do_timing!(" rawloader", rawloader::decode_file(&path)) { + if let Ok(img) = do_timing!(" rawler", rawler::decode_file(&path)) { Self::new_from_source(ImageSource::Raw(img)) } else if let Ok(img) = do_timing!(" image::open", image::open(&path)) { Self::new_from_source(ImageSource::Other(img)) diff --git a/src/scaling.rs b/src/scaling.rs index 899c2da..3e5c40f 100644 --- a/src/scaling.rs +++ b/src/scaling.rs @@ -1,6 +1,6 @@ use crate::buffer::*; use crate::pipeline::{SRGBImage, SRGBImage16}; -use rawloader::CFA; +use rawler::CFA; use num_traits::cast::AsPrimitive; use rayon::prelude::*; use std::cmp;