let dptr = buf.get_data_mut().unwrap();
let buf = dptr.as_mut_slice();
for x in 0..8 {
- let a = buf[off - 2 * stride + x] as i16;
- let b = buf[off - 1 * stride + x] as i16;
- let c = buf[off + 0 * stride + x] as i16;
- let d = buf[off + 1 * stride + x] as i16;
+ let a = i16::from(buf[off - 2 * stride + x]);
+ let b = i16::from(buf[off - 1 * stride + x]);
+ let c = i16::from(buf[off + 0 * stride + x]);
+ let d = i16::from(buf[off + 1 * stride + x]);
let diff = (3 * (a - d) + 8 * (c - b)) / 16;
if (diff != 0) && (diff > -24) && (diff < 24) {
- let d1a = (diff.abs() - 2 * (diff.abs() - (strength as i16)).max(0)).max(0);
+ let d1a = (diff.abs() - 2 * (diff.abs() - i16::from(strength)).max(0)).max(0);
let d1 = if diff < 0 { -d1a } else { d1a };
buf[off - 1 * stride + x] = (b + d1).max(0).min(255) as u8;
let dptr = buf.get_data_mut().unwrap();
let buf = dptr.as_mut_slice();
for y in 0..8 {
- let a = buf[off - 2 + y * stride] as i16;
- let b = buf[off - 1 + y * stride] as i16;
- let c = buf[off + 0 + y * stride] as i16;
- let d = buf[off + 1 + y * stride] as i16;
+ let a = i16::from(buf[off - 2 + y * stride]);
+ let b = i16::from(buf[off - 1 + y * stride]);
+ let c = i16::from(buf[off + 0 + y * stride]);
+ let d = i16::from(buf[off + 1 + y * stride]);
let diff = (3 * (a - d) + 8 * (c - b)) / 16;
if (diff != 0) && (diff > -24) && (diff < 24) {
- let d1a = (diff.abs() - 2 * (diff.abs() - (strength as i16)).max(0)).max(0);
+ let d1a = (diff.abs() - 2 * (diff.abs() - i16::from(strength)).max(0)).max(0);
let d1 = if diff < 0 { -d1a } else { d1a };
buf[off - 1 + y * stride] = (b + d1).max(0).min(255) as u8;
blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_FUNCS);
blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS);
- blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS);
+ blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS);
}
fn copy_blocks8x8(&self, dst: &mut NAVideoBuffer<u8>, src: NAVideoBufferRef<u8>, xpos: usize, ypos: usize, mvs: &[MV; 4]) {
let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap();
blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_AVG_FUNCS);
blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS);
- blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS);
+ blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS);
}
fn avg_blocks8x8(&self, dst: &mut NAVideoBuffer<u8>, src: NAVideoBufferRef<u8>, xpos: usize, ypos: usize, mvs: &[MV; 4]) {
let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap();
let coded0 = cbpi.is_coded(mb_x, 0);
let coded1 = cbpi.is_coded(mb_x, 1);
let q = cbpi.get_q(mb_w + mb_x);
- let str = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
+ let strength = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
if mb_y != 0 {
- if coded0 && cbpi.is_coded_top(mb_x, 0) { deblock_hor(buf, 0, str, coff); }
- if coded1 && cbpi.is_coded_top(mb_x, 1) { deblock_hor(buf, 0, str, coff + 8); }
+ if coded0 && cbpi.is_coded_top(mb_x, 0) { deblock_hor(buf, 0, strength, coff); }
+ if coded1 && cbpi.is_coded_top(mb_x, 1) { deblock_hor(buf, 0, strength, coff + 8); }
}
let coff = off + 8 * stride;
if cbpi.is_coded(mb_x, 2) && coded0 { deblock_hor(buf, 0, q, coff); }
let ccur0 = cbpi.is_coded(mb_x, 0);
let ccur1 = cbpi.is_coded(mb_x, 1);
let q = cbpi.get_q(mb_w + mb_x);
- let str = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
+ let strength = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
if mb_y != 0 {
let coff = off - 8 * stride;
let qtop = cbpi.get_q(mb_x);
if leftt && ctop0 { deblock_ver(buf, 0, strtop, coff); }
if ctop0 && ctop1 { deblock_ver(buf, 0, strtop, coff + 8); }
}
- if leftc && ccur0 { deblock_ver(buf, 0, str, off); }
- if ccur0 && ccur1 { deblock_ver(buf, 0, str, off + 8); }
+ if leftc && ccur0 { deblock_ver(buf, 0, strength, off); }
+ if ccur0 && ccur1 { deblock_ver(buf, 0, strength, off + 8); }
leftt = ctop1;
leftc = ccur1;
off += 16;
let ctv = cbpi.is_coded_top(mb_x, 5);
let ccv = cbpi.is_coded(mb_x, 5);
let q = cbpi.get_q(mb_w + mb_x);
- let str = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
- if ctu && ccu { deblock_hor(buf, 1, str, offu + mb_x * 8); }
- if ctv && ccv { deblock_hor(buf, 2, str, offv + mb_x * 8); }
+ let strength = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
+ if ctu && ccu { deblock_hor(buf, 1, strength, offu + mb_x * 8); }
+ if ctv && ccv { deblock_hor(buf, 2, strength, offv + mb_x * 8); }
}
let mut leftu = false;
let mut leftv = false;
}
}
-fn check_marker<'a>(br: &mut BitReader<'a>) -> DecoderResult<()> {
+fn check_marker(br: &mut BitReader) -> DecoderResult<()> {
let mark = br.read(1)?;
validate!(mark == 1);
Ok(())
impl<'a> BlockDecoder for Intel263BR<'a> {
#[allow(unused_variables)]
+#[allow(clippy::unreadable_literal)]
fn decode_pichdr(&mut self) -> DecoderResult<PicInfo> {
let br = &mut self.br;
let syncw = br.read(22)?;
}
}
+impl NAOptionHandler for Intel263Decoder {
+ fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
+ fn set_options(&mut self, _options: &[NAOption]) { }
+ fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
+}
+
pub fn get_decoder() -> Box<dyn NADecoder + Send> {
Box::new(Intel263Decoder::new())
use nihav_core::codecs::RegisteredDecoders;
use nihav_core::demuxers::RegisteredDemuxers;
use nihav_codec_support::test::dec_video::*;
- use crate::indeo_register_all_codecs;
+ use crate::indeo_register_all_decoders;
use nihav_commonfmt::generic_register_all_demuxers;
#[test]
fn test_intel263() {
let mut dmx_reg = RegisteredDemuxers::new();
generic_register_all_demuxers(&mut dmx_reg);
let mut dec_reg = RegisteredDecoders::new();
- indeo_register_all_codecs(&mut dec_reg);
-
- test_file_decoding("avi", "assets/Indeo/neal73_saber.avi", Some(16), true, false, None/*Some("i263")*/, &dmx_reg, &dec_reg);
+ indeo_register_all_decoders(&mut dec_reg);
+
+ // sample: https://samples.mplayerhq.hu/A-codecs/IMC/neal73_saber.avi
+ test_decoding("avi", "intel263", "assets/Indeo/neal73_saber.avi", Some(16),
+ &dmx_reg, &dec_reg, ExpectedTestResult::MD5Frames(vec![
+ [0x698c4f70, 0xf727bfc1, 0x96e687e9, 0xc9e37073],
+ [0xd41d8cd9, 0x8f00b204, 0xe9800998, 0xecf8427e],
+ [0x95dfe457, 0xaaeeaca9, 0x9764c111, 0xdf055b1f],
+ [0xac1d708c, 0x8e34aa47, 0x240b8f0e, 0x797b052b],
+ [0x965fe621, 0xebb049da, 0x18345724, 0x748ea32f],
+ [0x126c7492, 0x54d7457f, 0x9968a723, 0x89629378],
+ [0x8c690125, 0x3de8da89, 0x6030b702, 0xbd3f09ab],
+ [0xa9d3f7c7, 0xdfa1795c, 0x7ed34e86, 0x58b7cc26],
+ [0xe500e50e, 0x2312197d, 0xb8e93f41, 0xe6890cd8],
+ [0x2e8d8f15, 0xaf1c84fe, 0x05fec093, 0x3c383abb],
+ [0x6a1def4b, 0xc3549acc, 0x9ed127be, 0x2872f751],
+ [0x36599508, 0xe169caf9, 0xcdf6af6b, 0x29d167b8],
+ [0xfe98869d, 0x2b16b94b, 0x97caaf72, 0xbf7cc0c1],
+ [0x9fbfaf0a, 0xfa4ce8fc, 0xdc038ab8, 0x649c1eaa],
+ [0x141749be, 0xfba7acd4, 0xd0372e02, 0x6b191bc5],
+ [0x99252b73, 0x2ce009d9, 0xf6753c1d, 0x31892a08],
+ [0xefe81436, 0x4ab365db, 0x57a0b058, 0x26a6ca02]]));
}
}