X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-qt%2Fsrc%2Fcodecs%2Fsvq1.rs;h=e36714571ac312ed26834a06e0197f501a6f2105;hb=886cde4847280b96e10d240c2f2d76abec121dc8;hp=c65e10d300390a0e97ced72d1893db8d160d089d;hpb=237cc1f9576ed23c7a2f9bb34b43e5d07e93f710;p=nihav.git diff --git a/nihav-qt/src/codecs/svq1.rs b/nihav-qt/src/codecs/svq1.rs index c65e10d..e367145 100644 --- a/nihav-qt/src/codecs/svq1.rs +++ b/nihav-qt/src/codecs/svq1.rs @@ -258,7 +258,7 @@ impl SVQ1Decoder { if fill != 0 { for line in dst[off..].chunks_mut(dstride).take(h) { for el in line.iter_mut().take(w) { - *el = (i16::from(*el) + fill).max(0).min(255) as u8; + *el = el.wrapping_add(fill as u8); } } } @@ -274,7 +274,7 @@ impl SVQ1Decoder { }; for (line, src) in dst[off..].chunks_mut(dstride).zip(src.chunks(w)) { for x in 0..w { - line[x] = (i16::from(line[x]) + i16::from(src[x])).max(0).min(255) as u8; + line[x] = line[x].wrapping_add(src[x] as u8); } } } @@ -291,7 +291,7 @@ impl SVQ1Decoder { ((self.width / 4 + 15) & !15, (self.height / 4 + 15) & !15) }; let mvstride = w / 8; - self.mvs.truncate(0); + self.mvs.clear(); self.mvs.resize(mvstride * (h / 8), ZERO_MV); let mut mv_idx = 0; @@ -504,6 +504,7 @@ mod test { let mut dec_reg = RegisteredDecoders::new(); qt_register_all_decoders(&mut dec_reg); + // sample: https://samples.mplayerhq.hu/A-codecs/ima-adpcm/adpcm-bug.mov test_decoding("mov", "sorenson-video", "assets/QT/adpcm-bug.mov", Some(6), &dmx_reg, &dec_reg, ExpectedTestResult::MD5Frames(vec![ [0x90c5eb74, 0xcb942d7d, 0x84c5e444, 0x7f1ba2c2], @@ -511,8 +512,8 @@ mod test { [0xa04e865b, 0xdbd65920, 0x4703d7dd, 0x962707a1], [0xe89c98bc, 0x356791bb, 0xfb6f7302, 0x2250ef05], [0x282ef2a7, 0x235541b4, 0x55055d99, 0x1a8d0b29], - [0x56328694, 0x27157f78, 0x4bc6ddda, 0x03dcde68], - [0x5a694576, 0xd2434aea, 0x6859d48c, 0x275e02c9]])); + [0x79c60bab, 0xe5a11a50, 0x5f9e800b, 0x12bce70d], + [0xe9a08fb7, 0x3b482a8b, 0x50e1560e, 0xd6d70287]])); } }