rv6: fix typo in transform
[nihav.git] / nihav-realmedia / src / codecs / rv60.rs
index ca04fb1f958373575b96711b556f5d92f6f8cd18..538560a246684edd5d2f15d034d69efd60263b00 100644 (file)
@@ -49,7 +49,9 @@ struct FrameHeader {
     osvquant:           u8,
     ts:                 u32,
     width:              usize,
+    awidth:             usize,
     height:             usize,
+    aheight:            usize,
     two_f_refs:         bool,
     qp_off_type:        u8,
     deblock:            bool,
@@ -78,6 +80,8 @@ impl FrameHeader {
         let width                                       = ((br.read(11)? as usize) + 1) * 4;
         let height                                      = ((br.read(11)? as usize) + 0) * 4;
         validate!(height > 0);
+        let awidth  = (width  + 15) & !15;
+        let aheight = (height + 15) & !15;
         let _some_flag                                  = br.read_bool()?;
         let two_f_refs;
         if ftype == FrameType::I {
@@ -110,8 +114,8 @@ impl FrameHeader {
         }
 
         Ok(FrameHeader {
-                profile, ftype, qp, osvquant, ts, width, height, two_f_refs, qp_off_type,
-                deblock, deblock_chroma,
+                profile, ftype, qp, osvquant, ts, width, height, awidth, aheight,
+                two_f_refs, qp_off_type, deblock, deblock_chroma,
             })
     }
     fn parse_slice_sizes(&self, br: &mut BitReader, sizes: &mut Vec<usize>) -> DecoderResult<()> {
@@ -716,10 +720,10 @@ println!(" left {} bits", br.left());
     }
     #[allow(clippy::cognitive_complexity)]
     fn decode_cb_tree(&mut self, buf: &mut NASimpleVideoFrame<u8>, hdr: &FrameHeader, br: &mut BitReader, xpos: usize, ypos: usize, log_size: u8) -> DecoderResult<()> {
-        if (xpos >= hdr.width) || (ypos >= hdr.height) { return Ok(()); }
+        if (xpos >= hdr.awidth) || (ypos >= hdr.aheight) { return Ok(()); }
 
         let size = 1 << log_size;
-        let split = (xpos + size > hdr.width) || (ypos + size > hdr.height) || (size > 8 && br.read_bool()?);
+        let split = (xpos + size > hdr.awidth) || (ypos + size > hdr.aheight) || (size > 8 && br.read_bool()?);
         self.cu_splits.push(split);
         if split {
             let hsize = size >> 1;
@@ -1486,7 +1490,7 @@ println!("???");
         self.blk_info.clear();
         self.blk_info.resize(self.blk_stride * (cu_h << 4), BlockInfo::default());
         if hdr.deblock {
-            self.dblk.reinit(hdr.width, hdr.height);
+            self.dblk.reinit(hdr.awidth, hdr.aheight);
         }
         let mut off = hsize + ((br.tell() >> 3) as usize);
         let mut dframe = NASimpleVideoFrame::from_video_buf(&mut buf).unwrap();
@@ -1579,17 +1583,17 @@ mod test {
         test_decoding("realmedia", "realvideo6", "assets/RV/RV60.rmhd", Some(1000), &dmx_reg, &dec_reg,
                       ExpectedTestResult::MD5Frames(vec![
                             [0x2b1f1807, 0x09edef33, 0x0e6c78c1, 0x3b3c8179],
-                            [0xea406850, 0x400802b8, 0xac106fb6, 0xe1e2e766],
+                            [0xc7d45c3b, 0x6a82ff3a, 0xaf49a7ea, 0x7cf9a533],
                             [0x2b1f1807, 0x09edef33, 0x0e6c78c1, 0x3b3c8179],
-                            [0xb04e2626, 0x976e16f5, 0xc41a7a78, 0x2d8765da],
-                            [0xf4f30d97, 0x7f2876eb, 0x265ffad4, 0x3542a7c4],
-                            [0x7fd46b65, 0x9e56b770, 0xffa13e3b, 0x73d47eb6],
-                            [0xa3ec74e1, 0xc33617ab, 0xb49c744b, 0x7d1c8127],
-                            [0x830d85c2, 0x1df398c3, 0x40f33a4f, 0x445d95b3],
-                            [0xa5471116, 0x9299e39f, 0x98da1680, 0x1aabeed5],
-                            [0xd89ef645, 0x66c684fe, 0x6d5e4207, 0x5e480550],
-                            [0xdf434d0c, 0xf0018799, 0x935aa650, 0xcfc702fc],
-                            [0x9770cae6, 0x8a7caa6a, 0x87b6438d, 0x7b161519],
-                            [0x9a2dfade, 0x3ff56dbe, 0x5fbc6999, 0x827770e9]]));
+                            [0x3db0f7ea, 0xbbf24a80, 0x54c0dd7c, 0xbdea881a],
+                            [0x24134118, 0xeece4c59, 0x3f319c04, 0xd04951fd],
+                            [0xe5f1a7a5, 0x204ab47b, 0x678277b3, 0x179f3007],
+                            [0x61fb5e14, 0x47cce437, 0xaeeed91f, 0x03f727aa],
+                            [0x46c71f20, 0x8e6ee603, 0xb68965ee, 0xf5bf3c45],
+                            [0xf87589a4, 0xd9cc9120, 0xff27a8e6, 0xc1cc1dd5],
+                            [0x12ea3288, 0x810b766b, 0x9a83ac11, 0x88f9996a],
+                            [0xe1a8020f, 0x972fadbb, 0x771f0f7e, 0x7a3a3e41],
+                            [0xed041308, 0x3112b04e, 0xcb39b23b, 0x5f73798c],
+                            [0xb0a2db76, 0x56dd7f97, 0x87e4f6d4, 0xe69ecfd8]]));
     }
 }