From b49ce089d11d54c32c4bd6d1db20490266e8c773 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 12 Nov 2022 17:24:15 +0100 Subject: [PATCH] arxel-vid: support 2-pixel tiles --- nihav-game/src/codecs/arxel_vid.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/nihav-game/src/codecs/arxel_vid.rs b/nihav-game/src/codecs/arxel_vid.rs index c97512a..d705c82 100644 --- a/nihav-game/src/codecs/arxel_vid.rs +++ b/nihav-game/src/codecs/arxel_vid.rs @@ -71,21 +71,21 @@ impl NADecoder for ArxelVideoDecoder { validate!(height == vinfo.get_height()); br.seek(SeekFrom::Start(part2_off + (HEADER_SIZE as u64)))?; + let tile_w = if tile_size == 2 { 2 } else { 4 }; + let tsize = tile_w * BPP; + match tile_size { - 2 => { - return Err(DecoderError::NotImplemented); - }, - 4 => { - br.read_buf(&mut self.tiles[..16])?; + 2 | 4 => { + br.read_buf(&mut self.tiles[..tsize])?; let off = br.tell() as usize; let mut bir = BitReader::new(&src[off..], BitReaderMode::BE); for tile in 1..num_tiles { - for i in 0..16 { - self.tiles[tile * 16 + i] = self.tiles[tile * 16 + i - 16]; + for i in 0..tsize { + self.tiles[tile * tsize + i] = self.tiles[tile * tsize + i - tsize]; } let bits = bir.read(3)? as u8 + 1; validate!(bits < 8); - for el in self.tiles[tile * 16..][..16].iter_mut() { + for el in self.tiles[tile * tsize..][..tsize].iter_mut() { let mut delta = bir.read(bits)? as i16; if delta != 0 && bir.read_bool()? { delta = -delta; @@ -95,7 +95,7 @@ impl NADecoder for ArxelVideoDecoder { } }, _ => { - validate!(tile_size > 0); + validate!(tile_size == num_tiles * tsize); br.read_buf(&mut self.tiles[..tile_size])?; }, }; @@ -108,8 +108,6 @@ impl NADecoder for ArxelVideoDecoder { let dst = data.as_mut_slice(); let mut br = BitReader::new(&src[HEADER_SIZE..], BitReaderMode::BE); - let tile_w = 4; - let tsize = tile_w * BPP; let idx_bits = if num_tiles < 0x400 { 10 } else if num_tiles < 0x800 { 11 } else { 12 }; for y in (0..height).step_by(2) { for x in (0..width).step_by(tile_w) { -- 2.39.5