From ccd9f3159d19ee512015a265ad43f674fcbb4b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Mon, 7 Oct 2024 19:16:42 +0200 Subject: [PATCH 1/4] Update Image --- .github/workflows/linux.yml | 30 ++++++++++++++++++++++++++++++ Cargo.toml | 4 ++-- src/bin/converter.rs | 4 ++-- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/linux.yml 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..e949f1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,12 +15,12 @@ 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 = "0.25" [dependencies.rawloader] version = "0.37" diff --git a/src/bin/converter.rs b/src/bin/converter.rs index 9e357f0..e9a9be6 100644 --- a/src/bin/converter.rs +++ b/src/bin/converter.rs @@ -2,7 +2,7 @@ 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; @@ -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."); } From ffd98574a4f88ecbaef5627ae2d69621229624f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Mon, 7 Oct 2024 19:48:19 +0200 Subject: [PATCH 2/4] Decrease needed image features(heavy to compile) --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e949f1f..9b56f05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ bincode = "1" blake3 = "1" log = "0.4" num-traits = "0.2" -image = "0.25" +image = { version = "0.25", default-features = false, features = ["jpeg"] } [dependencies.rawloader] version = "0.37" From 84ba2c332ee29a393970b0c0446f641ce921ea03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Mon, 7 Oct 2024 20:06:56 +0200 Subject: [PATCH 3/4] Replace rawloader with rawler --- Cargo.toml | 6 +++--- src/bin/converter.rs | 2 +- src/lib.rs | 1 - src/opbasics.rs | 2 +- src/ops/gofloat.rs | 28 +++++++++++++++++++++------- src/pipeline.rs | 3 +-- src/scaling.rs | 2 +- 7 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9b56f05..d2fc344 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,9 +22,9 @@ log = "0.4" num-traits = "0.2" 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 e9a9be6..3542367 100644 --- a/src/bin/converter.rs +++ b/src/bin/converter.rs @@ -5,7 +5,7 @@ use std::io::BufWriter; use image::ExtendedColorType; extern crate imagepipe; -extern crate rawloader; +extern crate rawler; extern crate image; fn usage() { 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/gofloat.rs b/src/ops/gofloat.rs index 4c8db0a..a2a3212 100644 --- a/src/ops/gofloat.rs +++ b/src/ops/gofloat.rs @@ -20,14 +20,28 @@ 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([0 as u16; 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([0 as u16; 4]); + 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: img.camera.crop_area.map(|e|e[0]).unwrap_or(0), + crop_right: img.camera.crop_area.map(|e|e[1]).unwrap_or(0), + crop_bottom: img.camera.crop_area.map(|e|e[2]).unwrap_or(0), + crop_left: img.camera.crop_area.map(|e|e[3]).unwrap_or(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; From 069bd54a121b155af68f4f15d16c488d5a015485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Wed, 9 Oct 2024 18:19:32 +0200 Subject: [PATCH 4/4] Not works --- src/ops/demosaic.rs | 3 ++- src/ops/gofloat.rs | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) 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 a2a3212..91e50c8 100644 --- a/src/ops/gofloat.rs +++ b/src/ops/gofloat.rs @@ -25,20 +25,28 @@ impl OpGoFloat { *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([0 as u16; 4]); + }).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([0 as u16; 4]); + }).unwrap_or([0u16; 4]); + + let _rect = img.crop_area.unwrap_or_default(); + + // Nothing works :( OpGoFloat{ - crop_top: img.camera.crop_area.map(|e|e[0]).unwrap_or(0), - crop_right: img.camera.crop_area.map(|e|e[1]).unwrap_or(0), - crop_bottom: img.camera.crop_area.map(|e|e[2]).unwrap_or(0), - crop_left: img.camera.crop_area.map(|e|e[3]).unwrap_or(0), + // 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),