X-Git-Url: https://git.nihav.org/?p=nihav.git;a=blobdiff_plain;f=nihav-duck%2Fsrc%2Fcodecs%2Fvp56.rs;h=d0a991f32869c6d0175c6966dc0316bace200a58;hp=c626be82ac7d9e08c986a25442b1f70076ae2de6;hb=1fdbd53e295c3876df7602cc5c5397730711ed24;hpb=3f67638d8b7e163be9579e99a05f672f2ec4f144 diff --git a/nihav-duck/src/codecs/vp56.rs b/nihav-duck/src/codecs/vp56.rs index c626be8..d0a991f 100644 --- a/nihav-duck/src/codecs/vp56.rs +++ b/nihav-duck/src/codecs/vp56.rs @@ -1,4 +1,5 @@ use nihav_core::codecs::*; +use nihav_core::data::GenericCache; use nihav_core::io::bitreader::*; use super::vpcommon::*; @@ -295,44 +296,6 @@ impl FrameState { } } -pub struct GenericCache { - pub height: usize, - pub stride: usize, - pub xpos: usize, - pub data: Vec, - pub default: T, -} - -impl GenericCache { - fn new(height: usize, stride: usize, default: T) -> Self { - let mut ret = Self { - stride, - height, - xpos: 0, - data: Vec::with_capacity((height + 1) * stride), - default, - }; - ret.reset(); - ret - } - fn full_size(&self) -> usize { self.stride * (self.height + 1) } - fn reset(&mut self) { - self.data.truncate(0); - let size = self.full_size(); - self.data.resize(size, self.default); - self.xpos = self.stride + 1; - } - fn update_row(&mut self) { - for i in 0..self.stride { - self.data[i] = self.data[self.height * self.stride + i]; - } - self.data.truncate(self.stride); - let size = self.full_size(); - self.data.resize(size, self.default); - self.xpos = self.stride + 1; - } -} - pub struct VP56Decoder { version: u8, has_alpha: bool,