]> git.nihav.org Git - nihav.git/blobdiff - src/codecs/h263/mod.rs
h263: update num_mv2 in set_mv2()
[nihav.git] / src / codecs / h263 / mod.rs
index 094307c006effb115c6c3c3ef520978a1a085874..9973dc7e9050e0c35037cb19b92493dac0fd8f2e 100644 (file)
@@ -267,7 +267,8 @@ impl BlockInfo {
         if mvs.len() > 0 { self.skip = false; }
         let mut mv_arr: [MV; 2] = [ZERO_MV, ZERO_MV];
         for i in 0..mvs.len() { mv_arr[i] = mvs[i]; }
-        self.mv2    = mv_arr;
+        self.mv2     = mv_arr;
+        self.num_mv2 = mvs.len();
     }
     pub fn is_b_fwd(&self) -> bool { self.fwd }
     pub fn set_acpred(&mut self, acpred: ACPredMode) { self.acpred = acpred }
@@ -364,9 +365,9 @@ impl MV {
         }
     }
     fn b_sub(pvec: MV, fwdvec: MV, bvec: MV, trb: u16, trd: u16) -> Self {
-        let bscale = (trb as i16) - (trd as i16);
-        let x = if bvec.x != 0 { fwdvec.x - pvec.x } else if trd != 0 { bscale * pvec.x / (trd as i16) } else { 0 };
-        let y = if bvec.y != 0 { fwdvec.y - pvec.y } else if trd != 0 { bscale * pvec.y / (trd as i16) } else { 0 };
+        let bscale = (trb as i32) - (trd as i32);
+        let x = if bvec.x != 0 { fwdvec.x - pvec.x } else if trd != 0 { (bscale * (pvec.x as i32) / (trd as i32)) as i16 } else { 0 };
+        let y = if bvec.y != 0 { fwdvec.y - pvec.y } else if trd != 0 { (bscale * (pvec.y as i32) / (trd as i32)) as i16 } else { 0 };
         MV { x: x, y: y }
     }
 }