Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rawler support #22

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/bin/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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.");
}
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/opbasics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 2 additions & 1 deletion src/ops/demosaic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) => {
Expand Down
36 changes: 29 additions & 7 deletions src/ops/gofloat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) => {
Expand Down
3 changes: 1 addition & 2 deletions src/pipeline.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::ops::*;
use crate::opbasics::*;

extern crate rawloader;
extern crate multicache;
use self::multicache::MultiCache;
extern crate serde;
Expand Down Expand Up @@ -261,7 +260,7 @@ impl Pipeline {

pub fn new_from_file<P: AsRef<Path>>(path: P) -> Result<Pipeline, String> {
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))
Expand Down
2 changes: 1 addition & 1 deletion src/scaling.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down