aboutsummaryrefslogtreecommitdiff
path: root/lvc/src/encode.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lvc/src/encode.rs')
-rw-r--r--lvc/src/encode.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/lvc/src/encode.rs b/lvc/src/encode.rs
index 5df803b..935aaba 100644
--- a/lvc/src/encode.rs
+++ b/lvc/src/encode.rs
@@ -1,18 +1,20 @@
use crate::diff::diff;
-use crate::impls::ToArray;
use crate::split::split;
use crate::{Block, Frame, Ref, View};
-pub fn encode(last_frame: &Frame, frame: &Frame, view: View) -> Block {
- if view.size().area() > 1024 {
+pub struct EncodeConfig {
+ pub threshold: u32,
+ pub max_block_size: usize,
+}
+
+pub fn encode(last_frame: &Frame, frame: &Frame, view: View, config: &EncodeConfig) -> Block {
+ if view.size().area() > config.max_block_size {
let [av, bv] = split(view);
- return Block::Split(
- rayon::join(
- || Box::new(encode(last_frame, frame, av)),
- || Box::new(encode(last_frame, frame, bv)),
- )
- .to_array(),
+ let (ab, bb) = rayon::join(
+ || Box::new(encode(last_frame, frame, av, config)),
+ || Box::new(encode(last_frame, frame, bv, config)),
);
+ return Block::Split(ab, bb);
}
let mut r = Ref::default();
@@ -30,7 +32,7 @@ pub fn encode(last_frame: &Frame, frame: &Frame, view: View) -> Block {
}
}
- if d < 10000 {
+ if d < config.threshold {
return Block::Ref(r);
} else {
Block::Lit(frame.export(view))