-use io::bitreader::*;
-use io::codebook::*;
-use formats;
+use crate::io::bitreader::*;
+use crate::io::codebook::*;
+use crate::formats;
use super::super::*;
use super::*;
use super::decoder::*;
gob_no: usize,
mb_w: usize,
is_pb: bool,
+ is_ipb: bool,
}
fn check_marker<'a>(br: &mut BitReader<'a>) -> DecoderResult<()> {
gob_no: 0,
mb_w: 0,
is_pb: false,
+ is_ipb: false,
}
}
Ok(MV::new(xval, yval))
}
-fn decode_b_info(br: &mut BitReader, is_pb: bool, is_intra: bool) -> DecoderResult<BBlockInfo> {
+fn decode_b_info(br: &mut BitReader, is_pb: bool, is_ipb: bool, is_intra: bool) -> DecoderResult<BBlockInfo> {
if is_pb { // as improved pb
- let pb_mv_add = if is_intra { 1 } else { 0 };
- if br.read_bool()?{
- if br.read_bool()? {
- let pb_mv_count = 1 - (br.read(1)? as usize);
- let cbpb = br.read(6)? as u8;
- Ok(BBlockInfo::new(true, cbpb, pb_mv_count + pb_mv_add, pb_mv_count == 1))
+ if is_ipb {
+ let pb_mv_add = if is_intra { 1 } else { 0 };
+ if br.read_bool()?{
+ if br.read_bool()? {
+ let pb_mv_count = 1 - (br.read(1)? as usize);
+ let cbpb = br.read(6)? as u8;
+ Ok(BBlockInfo::new(true, cbpb, pb_mv_count + pb_mv_add, pb_mv_count == 1))
+ } else {
+ Ok(BBlockInfo::new(true, 0, 1 + pb_mv_add, true))
+ }
} else {
- Ok(BBlockInfo::new(true, 0, 1 + pb_mv_add, true))
+ Ok(BBlockInfo::new(true, 0, pb_mv_add, false))
}
} else {
- Ok(BBlockInfo::new(true, 0, pb_mv_add, false))
+ let mvdb = br.read_bool()?;
+ let cbpb = if mvdb && br.read_bool()? { br.read(6)? as u8 } else { 0 };
+ Ok(BBlockInfo::new(true, cbpb, if mvdb { 1 } else { 0 }, false))
}
} else {
Ok(BBlockInfo::new(false, 0, 0, false))
let apm = br.read_bool()?;
self.is_pb = br.read_bool()?;
let deblock;
+ let pbplus;
if sfmt == 0b111 {
sfmt = br.read(3)?;
validate!((sfmt != 0b000) && (sfmt != 0b111));
br.read(2)?; // unknown flags
deblock = br.read_bool()?;
br.read(1)?; // unknown flag
- let pbplus = br.read_bool()?;
+ pbplus = br.read_bool()?;
br.read(5)?; // unknown flags
let marker = br.read(5)?;
validate!(marker == 1);
} else {
deblock = false;
+ pbplus = false;
}
+ self.is_ipb = pbplus;
let w; let h;
if sfmt == 0b110 {
let par = br.read(4)?;
if self.is_pb {
let trb = br.read(3)?;
let dbquant = br.read(2)?;
- pbinfo = Some(PBInfo::new(trb as u8, dbquant as u8));
+ pbinfo = Some(PBInfo::new(trb as u8, dbquant as u8, pbplus));
} else {
pbinfo = None;
}
let is_4x4 = (cbpc & 0x10) != 0;
if is_intra {
let mut mvec: Vec<MV> = Vec::new();
- let bbinfo = decode_b_info(br, self.is_pb, true)?;
+ let bbinfo = decode_b_info(br, self.is_pb, self.is_ipb, true)?;
let cbpy = br.read_cb(&self.tables.cbpy_cb)?;
let cbp = (cbpy << 2) | (cbpc & 3);
if dquant {
return Ok(binfo);
}
- let bbinfo = decode_b_info(br, self.is_pb, false)?;
+ let bbinfo = decode_b_info(br, self.is_pb, self.is_ipb, false)?;
let mut cbpy = br.read_cb(&self.tables.cbpy_cb)?;
// if /* !aiv && */(cbpc & 3) != 3 {
cbpy ^= 0xF;
#[cfg(test)]
mod test {
- use test::dec_video::test_file_decoding;
+ use crate::test::dec_video::test_file_decoding;
#[test]
fn test_intel263() {
test_file_decoding("avi", "assets/neal73_saber.avi", Some(16), true, false, None/*Some("i263")*/);