X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-duck%2Fsrc%2Fcodecs%2Fvp56.rs;h=5abea84f07a22fcc62567db91db0f09d2bb50a35;hb=HEAD;hp=807756a495687533836950daa513237d528c2c14;hpb=8dd7f6798f3efb78b5b09dd71229a28c66099d4b;p=nihav.git diff --git a/nihav-duck/src/codecs/vp56.rs b/nihav-duck/src/codecs/vp56.rs index 807756a..5abea84 100644 --- a/nihav-duck/src/codecs/vp56.rs +++ b/nihav-duck/src/codecs/vp56.rs @@ -486,7 +486,7 @@ impl VP56Decoder { let hdr = br.parse_header(&mut bc)?; validate!((hdr.offset as usize) < aoffset); //XXX: take alpha 3 byte offset into account? - if hdr.mb_w != 0 { + if hdr.mb_w != 0 && (usize::from(hdr.mb_w) != self.mb_w || usize::from(hdr.mb_h) != self.mb_h) { self.set_dimensions((hdr.mb_w as usize) * 16, (hdr.mb_h as usize) * 16); } let fmt = if !self.has_alpha { @@ -531,9 +531,7 @@ impl VP56Decoder { std::mem::swap(&mut self.models, &mut self.amodels); let ret = self.decode_planes(br, &mut dframe, &mut bc, &ahdr, asrc, true); std::mem::swap(&mut self.models, &mut self.amodels); - if let Err(err) = ret { - return Err(err); - } + ret?; match (hdr.is_golden, ahdr.is_golden) { (true, true) => { self.shuf.add_golden_frame(buf.clone()); }, (true, false) => { @@ -633,7 +631,7 @@ impl VP56Decoder { self.fstate.last_idx = [24; 4]; for mb_x in 0..self.mb_w { self.fstate.mb_x = mb_x; - self.decode_mb(dframe, bc, &mut cr, br, &hdr, alpha)?; + self.decode_mb(dframe, bc, &mut cr, br, hdr, alpha)?; self.dc_pred.next_mb(); } self.dc_pred.update_row(); @@ -699,16 +697,16 @@ impl VP56Decoder { let sum = u32::from(prob_xmitted[mode * 2]) + u32::from(prob_xmitted[mode * 2 + 1]); mdl.probs[9] = 255 - rescale_mb_mode_prob(u32::from(prob_xmitted[mode * 2 + 1]), sum); - let inter_mv0_weight = (cnt[0] as u32) + (cnt[2] as u32); - let inter_mv1_weight = (cnt[3] as u32) + (cnt[4] as u32); - let gold_mv0_weight = (cnt[5] as u32) + (cnt[6] as u32); - let gold_mv1_weight = (cnt[8] as u32) + (cnt[9] as u32); - let mix_weight = (cnt[1] as u32) + (cnt[7] as u32); + let inter_mv0_weight = cnt[0] + cnt[2]; + let inter_mv1_weight = cnt[3] + cnt[4]; + let gold_mv0_weight = cnt[5] + cnt[6]; + let gold_mv1_weight = cnt[8] + cnt[9]; + let mix_weight = cnt[1] + cnt[7]; mdl.probs[0] = 1 + rescale_mb_mode_prob(inter_mv0_weight + inter_mv1_weight, total); mdl.probs[1] = 1 + rescale_mb_mode_prob(inter_mv0_weight, inter_mv0_weight + inter_mv1_weight); mdl.probs[2] = 1 + rescale_mb_mode_prob(mix_weight, mix_weight + gold_mv0_weight + gold_mv1_weight); - mdl.probs[3] = 1 + rescale_mb_mode_prob(cnt[0] as u32, inter_mv0_weight); - mdl.probs[4] = 1 + rescale_mb_mode_prob(cnt[3] as u32, inter_mv1_weight); + mdl.probs[3] = 1 + rescale_mb_mode_prob(cnt[0], inter_mv0_weight); + mdl.probs[4] = 1 + rescale_mb_mode_prob(cnt[3], inter_mv1_weight); mdl.probs[5] = 1 + rescale_mb_mode_prob(cnt[1], mix_weight); mdl.probs[6] = 1 + rescale_mb_mode_prob(gold_mv0_weight, gold_mv0_weight + gold_mv1_weight); mdl.probs[7] = 1 + rescale_mb_mode_prob(cnt[5], gold_mv0_weight);