Skip to content
Snippets Groups Projects

Some Cava optimization

Merged rarbore2 requested to merge cava_opt into main
2 files
+ 36
17
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -35,20 +35,6 @@ fn scale<row : usize, col : usize>(input : u8[CHAN, row, col]) -> f32[CHAN, row,
return res;
}
fn descale<row : usize, col : usize>(input : f32[CHAN, row, col]) -> u8[CHAN, row, col] {
let res : u8[CHAN, row, col];
for chan = 0 to CHAN {
for r = 0 to row {
for c = 0 to col {
res[chan, r, c] = min!::<f32>(max!::<f32>(input[chan, r, c] * 255, 0), 255) as u8;
}
}
}
return res;
}
fn demosaic<row : usize, col : usize>(input : f32[CHAN, row, col]) -> f32[CHAN, row, col] {
@res2 let res : f32[CHAN, row, col];
@@ -184,7 +170,7 @@ fn gamut<row : usize, col : usize, num_ctrl_pts : usize>(
fn tone_map<row : usize, col:usize>
(input : f32[CHAN, row, col], tone_map : f32[256, CHAN]) -> f32[CHAN, row, col] {
let result : f32[CHAN, row, col];
@res1 let result : f32[CHAN, row, col];
for chan = 0 to CHAN {
for r = 0 to row {
@@ -198,6 +184,20 @@ fn tone_map<row : usize, col:usize>
return result;
}
fn descale<row : usize, col : usize>(input : f32[CHAN, row, col]) -> u8[CHAN, row, col] {
@res2 let res : u8[CHAN, row, col];
for chan = 0 to CHAN {
for r = 0 to row {
for c = 0 to col {
res[chan, r, c] = min!::<f32>(max!::<f32>(input[chan, r, c] * 255, 0), 255) as u8;
}
}
}
return res;
}
#[entry]
fn cava<r, c, num_ctrl_pts : usize>(
input : u8[CHAN, r, c],
@@ -212,7 +212,7 @@ fn cava<r, c, num_ctrl_pts : usize>(
@fuse2 let denosd = denoise::<r, c>(demosc);
@fuse3 let transf = transform::<r, c>(denosd, TsTw);
@fuse4 let gamutd = gamut::<r, c, num_ctrl_pts>(transf, ctrl_pts, weights, coefs);
let tonemd = tone_map::<r, c>(gamutd, tonemap);
let dscald = descale::<r, c>(tonemd);
@fuse5 let tonemd = tone_map::<r, c>(gamutd, tonemap);
@fuse5 let dscald = descale::<r, c>(tonemd);
return dscald;
}
Loading