X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;ds=sidebyside;f=nihav-indeo%2Fsrc%2Fcodecs%2Fivibr.rs;h=2169b6956280a30c8d26b18e19910eec90c12cf9;hb=78fb6560c73965d834b215fb0b49505ae5443288;hp=dd43afa1b389a23ae5fa2227d72c088a543ff681;hpb=08a1fab72215ea7716f51adf7008f85372e80c71;p=nihav.git diff --git a/nihav-indeo/src/codecs/ivibr.rs b/nihav-indeo/src/codecs/ivibr.rs index dd43afa..2169b69 100644 --- a/nihav-indeo/src/codecs/ivibr.rs +++ b/nihav-indeo/src/codecs/ivibr.rs @@ -171,6 +171,7 @@ fn read_trans_band_header(br: &mut BitReader, w: usize, h: usize, dst: &mut [i16 for i in 0..cb.len { cb.bits[i] = br.read(4)? as u8; } + cb = cb.init(); br.align(); let tile_start = br.tell(); @@ -227,7 +228,8 @@ let tile_end = tile_start + len * 8; Ok(()) } -fn decode_block8x8(br: &mut BitReader, blk_cb: &IVICodebook, rvmap: &RVMap, tables: &TxParams8x8, is_intra: bool, is_2d: bool, prev_dc: &mut i32, quant: u8, coeffs: &mut [i32; 64], transform: &TrFunc) -> DecoderResult<()> { +#[allow(clippy::cast_lossless)] +fn decode_block8x8(br: &mut BitReader, blk_cb: &IVICodebook, rvmap: &RVMap, tables: &TxParams8x8, is_intra: bool, is_2d: bool, prev_dc: &mut i32, quant: u8, coeffs: &mut [i32; 64], transform: TrFunc) -> DecoderResult<()> { let mut idx: isize = -1; let quant_mat = if is_intra { tables.quant_intra } else { tables.quant_inter }; while idx <= 64 { @@ -277,7 +279,8 @@ fn decode_block8x8(br: &mut BitReader, blk_cb: &IVICodebook, rvmap: &RVMap, tabl (transform)(coeffs); Ok(()) } -fn decode_block4x4(br: &mut BitReader, blk_cb: &IVICodebook, rvmap: &RVMap, tables: &TxParams4x4, is_intra: bool, is_2d: bool, prev_dc: &mut i32, quant: u8, coeffs: &mut [i32; 64], transform: &TrFunc) -> DecoderResult<()> { +#[allow(clippy::cast_lossless)] +fn decode_block4x4(br: &mut BitReader, blk_cb: &IVICodebook, rvmap: &RVMap, tables: &TxParams4x4, is_intra: bool, is_2d: bool, prev_dc: &mut i32, quant: u8, coeffs: &mut [i32; 64], transform: TrFunc) -> DecoderResult<()> { let mut idx: isize = -1; let quant_mat = if is_intra { tables.quant_intra } else { tables.quant_inter }; while idx <= 64 { @@ -481,7 +484,7 @@ pub struct IVIDecoder { bref: Option, bands: Vec, - tiles: Vec>, + tiles: Vec, num_tiles: [[usize; 4]; 4], tile_start: [[usize; 4]; 4], } @@ -538,7 +541,7 @@ impl IVIDecoder { while x < band_w { let cur_w = if x + tile_w <= band_w { tile_w } else { band_w - x }; let tile = IVITile::new(band_xoff + x, band_yoff + y, cur_w, cur_h); - self.tiles.push(NABufferRef::new(tile)); + self.tiles.push(tile); self.num_tiles[plane][band] += 1; tstart += 1; x += tile_w; @@ -574,7 +577,7 @@ impl IVIDecoder { }; for tile_no in tstart..tend { { - let mut tile = self.tiles[tile_no].clone(); + let tile = &mut self.tiles[tile_no]; let mb_w = (tile.w + mb_size - 1) / mb_size; let mb_h = (tile.h + mb_size - 1) / mb_size; tile.mb_w = mb_w; @@ -597,7 +600,6 @@ impl IVIDecoder { validate!(tile_end > br.tell()); validate!(tile_end <= br.tell() + (br.left() as usize)); { - let mut tile = self.tiles[tile_no].clone(); let ref_tile: Option<&IVITile>; let mv_scale; if (plane_no == 0) && (band_no == 0) { @@ -605,8 +607,10 @@ impl IVIDecoder { } else { mv_scale = (((self.bands[0].mb_size >> 3) as i8) - ((band.mb_size >> 3) as i8)) as u8; } + let (ref_tiles, cur_tiles) = self.tiles.split_at_mut(tile_no); + let tile = &mut cur_tiles[0]; if plane_no != 0 || band_no != 0 { - let rtile = &self.tiles[0]; + let rtile = &ref_tiles[0]; if (tile.mb_w != rtile.mb_w) || (tile.mb_h != rtile.mb_h) { ref_tile = None; } else { @@ -615,15 +619,14 @@ impl IVIDecoder { } else { ref_tile = None; } - dec.decode_mb_info(br, pic_hdr, &band, &mut tile, ref_tile, mv_scale)?; + dec.decode_mb_info(br, pic_hdr, &band, tile, ref_tile, mv_scale)?; } - self.decode_tile(br, &band, tile_no, &tr, &tr_dc)?; + self.decode_tile(br, &band, tile_no, tr, tr_dc)?; let skip_part = tile_end - br.tell(); br.skip(skip_part as u32)?; } else { { - let mut tile = self.tiles[tile_no].clone(); let ref_tile: Option<&IVITile>; let mv_scale; if (plane_no == 0) && (band_no == 0) { @@ -631,8 +634,10 @@ br.skip(skip_part as u32)?; } else { mv_scale = (((self.bands[0].mb_size >> 3) as i8) - ((band.mb_size >> 3) as i8)) as u8; } + let (ref_tiles, cur_tiles) = self.tiles.split_at_mut(tile_no); + let tile = &mut cur_tiles[0]; if plane_no != 0 || band_no != 0 { - let rtile = &self.tiles[0]; + let rtile = &ref_tiles[0]; if (tile.mb_w != rtile.mb_w) || (tile.mb_h != rtile.mb_h) { ref_tile = None; } else { @@ -660,17 +665,17 @@ br.skip(skip_part as u32)?; } } } - self.decode_tile(br, &band, tile_no, &tr, &tr_dc)?; + self.decode_tile(br, &band, tile_no, tr, tr_dc)?; } } self.bands[bidx] = band; br.align(); Ok(()) } - fn decode_tile(&mut self, br: &mut BitReader, band: &BandHeader, tile_no: usize, tr: &TrFunc, transform_dc: &TrFuncDC) -> DecoderResult<()> { + fn decode_tile(&mut self, br: &mut BitReader, band: &BandHeader, tile_no: usize, tr: TrFunc, transform_dc: TrFuncDC) -> DecoderResult<()> { let mut mb_idx = 0; let mut prev_dc: i32 = 0; - let mut tile = self.tiles[tile_no].clone(); + let tile = &mut self.tiles[tile_no]; let mut frame = self.frames[self.cur_frame].clone(); let stride = frame.plane_stride[band.plane_no]; @@ -895,7 +900,7 @@ br.skip(skip_part as u32)?; } match self.ftype { - IVIFrameType::Intra | IVIFrameType::Inter => { + IVIFrameType::Intra | IVIFrameType::Intra1 | IVIFrameType::Inter => { self.iref_1 = self.iref_0; self.iref_0 = self.cur_frame; self.scal_ref = self.cur_frame;