X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-duck%2Fsrc%2Fcodecs%2Fvp5.rs;h=179227adb4d64464176e537e106ac9f52bd01c6a;hb=7d57ae2f680d7a1eba7af2ee831f305b2f0f9324;hp=d13ffabfbd1376af8db95b38a1fa472a28cf511d;hpb=f9be4e750dccff762b9a3d894faec50ffdb59233;p=nihav.git diff --git a/nihav-duck/src/codecs/vp5.rs b/nihav-duck/src/codecs/vp5.rs index d13ffab..179227a 100644 --- a/nihav-duck/src/codecs/vp5.rs +++ b/nihav-duck/src/codecs/vp5.rs @@ -1,5 +1,6 @@ use nihav_core::codecs::*; use nihav_core::io::bitreader::*; +use nihav_codec_support::codecs::{MV, ZIGZAG}; use super::vpcommon::*; use super::vp56::*; @@ -32,7 +33,7 @@ impl VP56Parser for VP5BR { validate!((hdr.disp_w <= hdr.mb_w) && (hdr.disp_h <= hdr.mb_h)); hdr.scale = bc.read_bits(2) as u8; } - + Ok(hdr) } fn decode_mv(&self, bc: &mut BoolCoder, model: &VP56MVModel) -> i16 { @@ -192,7 +193,7 @@ impl VP56Parser for VP5BR { if idx > 0 { coeffs[ZIGZAG[idx]] *= fstate.ac_quant; } - + idx += 1; if idx >= 64 { break; @@ -219,11 +220,16 @@ impl VP56Parser for VP5BR { } fn mc_block(&self, dst: &mut NASimpleVideoFrame, mc_buf: NAVideoBufferRef, src: NAVideoBufferRef, plane: usize, x: usize, y: usize, mv: MV, loop_str: i16) { let (sx, sy, mx, my) = if (plane != 1) && (plane != 2) { - (mv.x / 2, mv.y / 2, mv.x & 1, mv.y & 1) + (mv.x >> 1, mv.y >> 1, mv.x & 1, mv.y & 1) + } else { + (mv.x >> 2, mv.y >> 2, if (mv.x & 3) != 0 { 1 } else { 0 }, if (mv.y & 3) != 0 { 1 } else { 0 }) + }; + let mode1 = (mx as usize) + (my as usize) * 2; + let mode = if (mode1 == 3) && (mv.x ^ mv.y < 0) { + 4 } else { - (mv.x / 4, mv.y / 4, (mv.x >> 1) & 1, (mv.y >> 1) & 1) + mode1 }; - let mode = (mx as usize) + (my as usize) * 2; vp_copy_block(dst, src, plane, x, y, sx, sy, 0, 1, loop_str, mode, VP3_INTERP_FUNCS, mc_buf); } @@ -272,7 +278,13 @@ impl NADecoder for VP5Decoder { } } -pub fn get_decoder() -> Box { +impl NAOptionHandler for VP5Decoder { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } +} + +pub fn get_decoder() -> Box { Box::new(VP5Decoder::new()) } @@ -280,9 +292,9 @@ pub fn get_decoder() -> Box { mod test { use nihav_core::codecs::RegisteredDecoders; use nihav_core::demuxers::RegisteredDemuxers; - use nihav_core::test::dec_video::*; - use crate::codecs::duck_register_all_codecs; - use nihav_commonfmt::demuxers::generic_register_all_demuxers; + use nihav_codec_support::test::dec_video::*; + use crate::duck_register_all_codecs; + use nihav_commonfmt::generic_register_all_demuxers; #[test] fn test_vp5() { @@ -293,8 +305,8 @@ mod test { let file = "assets/Duck/Cell-140.vp5"; //let file = "assets/Duck/Chocolat-500.vp5"; - test_file_decoding("avi", file, Some(13), true, false, None/*Some("vp5")*/, &dmx_reg, &dec_reg); -//panic!("end"); + test_decoding("avi", "vp5", file, Some(96), &dmx_reg, &dec_reg, + ExpectedTestResult::MD5([0x9ad78b0f, 0xed988ead, 0x88ed2ea9, 0xcdb75cdf])); } }