use nihav_core::codecs::*;
+use nihav_core::data::GenericCache;
use nihav_core::io::bitreader::*;
use super::vpcommon::*;
}
}
-pub struct GenericCache<T: Copy> {
- pub height: usize,
- pub stride: usize,
- pub xpos: usize,
- pub data: Vec<T>,
- pub default: T,
-}
-
-impl<T:Copy> GenericCache<T> {
- 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,
}
}
-pub const VP56_COEF_BASE: [i16; 6] = [ 5, 7, 11, 19, 35, 67 ];
pub fn expand_token_bc(bc: &mut BoolCoder, val_probs: &[u8; 11], token: u8, version: u8) -> i16 {
- const COEF_ADD_PROBS: [[u8; 12]; 6] = [
- [ 159, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
- [ 165, 145, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
- [ 173, 148, 140, 128, 0, 0, 0, 0, 0, 0, 0, 0 ],
- [ 176, 155, 140, 135, 128, 0, 0, 0, 0, 0, 0, 0 ],
- [ 180, 157, 141, 134, 130, 128, 0, 0, 0, 0, 0, 0 ],
- [ 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 128 ],
- ];
-
let mut sign = false;
let level;
if token < TOKEN_LARGE {
sign = bc.read_bool();
}
let mut add = 0i16;
- let add_probs = &COEF_ADD_PROBS[cat];
+ let add_probs = &VP56_COEF_ADD_PROBS[cat];
for prob in add_probs.iter() {
if *prob == 128 { break; }
add = (add << 1) | (bc.read_prob(*prob) as i16);
self.set_dimensions(vinfo.get_width(), vinfo.get_height());
Ok(())
}
+ pub fn flush(&mut self) {
+ self.shuf.clear();
+ }
pub fn decode_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], br: &mut dyn VP56Parser) -> DecoderResult<(NABufferType, FrameType)> {
let aoffset;
let mut bc;