aboutsummaryrefslogtreecommitdiff
path: root/evc/src/frame.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2022-12-17 18:01:51 +0100
committermetamuffin <metamuffin@disroot.org>2022-12-17 18:01:51 +0100
commit0a346b8372140b56bf65a6df1c00e2cd6c6cdf86 (patch)
treee52234d5904939323e19586128d8ac2d345e450e /evc/src/frame.rs
parent82eedf3594bf21c8b780580050a95f0bdb5fd667 (diff)
downloadvideo-codec-experiments-0a346b8372140b56bf65a6df1c00e2cd6c6cdf86.tar
video-codec-experiments-0a346b8372140b56bf65a6df1c00e2cd6c6cdf86.tar.bz2
video-codec-experiments-0a346b8372140b56bf65a6df1c00e2cd6c6cdf86.tar.zst
small optimizations and info binary
Diffstat (limited to 'evc/src/frame.rs')
-rw-r--r--evc/src/frame.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/evc/src/frame.rs b/evc/src/frame.rs
index 81fdf3b..78d0e73 100644
--- a/evc/src/frame.rs
+++ b/evc/src/frame.rs
@@ -63,11 +63,8 @@ impl Index<Vec2<isize>> for Frame {
type Output = Pixel;
#[inline]
fn index(&self, Vec2 { x, y }: Vec2<isize>) -> &Self::Output {
- if x >= 0 && y >= 0 && x < self.size.x && y < self.size.y {
- &self.buffer[(x + y * self.size.x) as usize]
- } else {
- &Pixel::BLACK
- }
+ &self.buffer
+ [(x.clamp(0, self.size.x - 1) + y.clamp(0, self.size.y - 1) * self.size.x) as usize]
}
}
impl IndexMut<Vec2<isize>> for Frame {