aboutsummaryrefslogtreecommitdiff
path: root/evc/src/codec
diff options
context:
space:
mode:
Diffstat (limited to 'evc/src/codec')
-rw-r--r--evc/src/codec/compress.rs9
-rw-r--r--evc/src/codec/decode.rs7
-rw-r--r--evc/src/codec/encode/mod.rs4
3 files changed, 9 insertions, 11 deletions
diff --git a/evc/src/codec/compress.rs b/evc/src/codec/compress.rs
index 688f04b..09d1f29 100644
--- a/evc/src/codec/compress.rs
+++ b/evc/src/codec/compress.rs
@@ -65,17 +65,20 @@ pub fn lit_compress(w: usize, h: usize, pixels: &[Pixel]) -> Vec<u8> {
norm_dct_channel(w, h, &mut ch);
for i in 0..w * h {
- out.push(unsafe { std::mem::transmute(ch[i] as i8) });
+ out.extend(unsafe { std::mem::transmute::<_, [u8; 4]>(ch[i]) });
}
}
out
}
+
pub fn lit_decompress(compressed: &[u8], mut target: View<&mut Frame>) {
let (w, h) = (target.size.x as usize, target.size.y as usize);
for ci in 0..3 {
let mut ch = compressed[ci * w * h..(ci + 1) * w * h]
- .iter()
- .map(|v| unsafe { std::mem::transmute::<_, i8>(*v) } as f32)
+ .chunks_exact(4)
+ .map(|v| unsafe {
+ std::mem::transmute::<_, f32>(TryInto::<[u8; 4]>::try_into(v).unwrap())
+ })
.collect::<Vec<_>>();
norm_idct_channel(w, h, &mut ch);
for y in 0..h {
diff --git a/evc/src/codec/decode.rs b/evc/src/codec/decode.rs
index bb2aadf..b1f6a3d 100644
--- a/evc/src/codec/decode.rs
+++ b/evc/src/codec/decode.rs
@@ -3,9 +3,7 @@ use crate::{
block::Block, frame::Frame, helpers::threading::both_par, refsampler::Sampler, view::View,
};
-pub struct DecodeConfig {
- pub max_threads: usize,
-}
+pub struct DecodeConfig {}
pub fn decode_block(
block: &Block,
@@ -24,10 +22,9 @@ pub fn decode_block(
unsafe { std::mem::transmute::<_, [View<&'static Frame>; 2]>(prev.split()) };
let config = unsafe { std::mem::transmute::<_, &'static DecodeConfig>(config) };
- both_par(
+ rayon::join(
move || decode_block(a, at, ap, config),
move || decode_block(b, bt, bp, config),
- config.max_threads,
);
}
Block::CompressedLiteral(data) => {
diff --git a/evc/src/codec/encode/mod.rs b/evc/src/codec/encode/mod.rs
index 8b7b342..43607aa 100644
--- a/evc/src/codec/encode/mod.rs
+++ b/evc/src/codec/encode/mod.rs
@@ -15,7 +15,6 @@ pub struct EncodeConfig {
pub ref_thres: f64,
pub max_diff_area: isize,
pub min_block_size: isize,
- pub max_threads: usize,
pub weight_factor: f64,
pub do_translate: bool,
@@ -72,10 +71,9 @@ pub fn encode_block(view: View<&Frame>, prev: View<&Frame>, config: &EncodeConfi
// only bother to do multithreading, when the block is big.
let ((ad, a), (bd, b)) = if view.area() > 100 {
- both_par(
+ rayon::join(
|| encode_block(av, ap, config),
|| encode_block(bv, bp, config),
- config.max_threads,
)
} else {
(encode_block(av, ap, config), encode_block(bv, bp, config))