diff options
author | metamuffin <metamuffin@disroot.org> | 2023-03-09 22:48:33 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-03-09 22:48:33 +0100 |
commit | 680b08e6b9d64284b7992fb52a23e5f891291406 (patch) | |
tree | abe30a9f18be09ef931b4b6357d216f6ba982095 /bv1/codec/src/split.rs | |
parent | c45f80a14ecd00914eb1d4e8f628b74a713667ba (diff) | |
download | video-codec-experiments-680b08e6b9d64284b7992fb52a23e5f891291406.tar video-codec-experiments-680b08e6b9d64284b7992fb52a23e5f891291406.tar.bz2 video-codec-experiments-680b08e6b9d64284b7992fb52a23e5f891291406.tar.zst |
rename + readme
Diffstat (limited to 'bv1/codec/src/split.rs')
-rw-r--r-- | bv1/codec/src/split.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/bv1/codec/src/split.rs b/bv1/codec/src/split.rs new file mode 100644 index 0000000..c17179e --- /dev/null +++ b/bv1/codec/src/split.rs @@ -0,0 +1,42 @@ +use crate::{View, P2}; + +pub fn split(view: View) -> [View; 2] { + let s = view.size(); + if s.x > s.y { + let mid_x = (view.a.x + view.b.x) / 2; + [ + View { + a: view.a, + b: P2 { + x: mid_x, + y: view.b.y, + }, + }, + View { + a: P2 { + x: mid_x, + y: view.a.y, + }, + b: view.b, + }, + ] + } else { + let mid_y = (view.a.y + view.b.y) / 2; + [ + View { + a: view.a, + b: P2 { + x: view.b.x, + y: mid_y, + }, + }, + View { + a: P2 { + x: view.a.x, + y: mid_y, + }, + b: view.b, + }, + ] + } +} |