Commit b03f699a authored by Yushin Cho's avatar Yushin Cho Committed by Thomas Daede

[OBU] Assert fail in obu header if obu_extension is not zero

Also, add trailing bits for sequence OBU.
parent e0ad04c9
......@@ -50,7 +50,7 @@ fn main() {
fi.use_prev_frame_mvs = !(fi.intra_only || fi.error_resilient);
if !process_frame(
&sequence,
&mut sequence,
&fi,
&mut files.output_file,
&mut y4m_dec,
......
......@@ -50,7 +50,7 @@ fn main() {
match line.split_whitespace().next() {
Some("process_frame") => {
process_frame(
&sequence,
&mut sequence,
&fi,
&mut files.output_file,
&mut y4m_dec,
......
......@@ -157,7 +157,7 @@ impl Sequence {
use_128x128_superblock: false,
order_hint_bits_minus_1: 0,
force_screen_content_tools: 0,
force_integer_mv: 0,
force_integer_mv: 2,
still_picture: false,
reduced_still_picture_hdr: false,
monochrome: false,
......@@ -488,7 +488,8 @@ impl<'a> UncompressedHeader for BitWriter<'a, BE> {
size += 1;
if obu_extension != 0 {
self.write(8, obu_extension & 0xFF)?; size += 8;
assert!(false);
//self.write(8, obu_extension & 0xFF)?; size += 8;
}
size = (size + 7) / 8; // # of written bytes
......@@ -724,15 +725,17 @@ fn aom_uleb_size_in_bytes(mut value: u64) -> usize {
fn write_obus(packet: &mut Write, sequence: &mut Sequence,
fi: &FrameInvariants) -> Result<(), std::io::Error> {
let mut uch = BitWriter::<BE>::new(packet);
let obu_extension = 0 as u32;
uch.write_obu_header(OBU_Type::OBU_TEMPORAL_DELIMITER, 0);
uch.write_obu_header(OBU_Type::OBU_TEMPORAL_DELIMITER, obu_extension);
uch.write(8,0)?; // size of payload == 0, one byte
// write sequence header obu if KEY_FRAME, preceded by 4-byte size
if fi.frame_type == FrameType::KEY {
let obu_header_size = uch.write_obu_header(OBU_Type::OBU_SEQUENCE_HEADER, 0);
let obu_header_size = uch.write_obu_header(OBU_Type::OBU_SEQUENCE_HEADER, obu_extension);
let obu_payload_size = uch.write_sequence_header_obu(sequence, fi);
uch.byte_align()?;
// TODO: Looks like we need to write the length (i.e. obu_payload_size)
// btw obu_header and obu+payload (i.e. _sequence_header_obu)
......@@ -756,6 +759,7 @@ fn write_obus(packet: &mut Write, sequence: &mut Sequence,
write_obu_header(OBU_FRAME_HEADER, obu_extension_header, data);
obu_payload_size =
write_frame_header_obu(cpi, &saved_wb, data + obu_header_size, 1);
uch.byte_align()?;
const size_t length_field_size =
obu_memmove(obu_header_size, obu_payload_size, data);
......@@ -1313,7 +1317,7 @@ fn encode_tile(fi: &FrameInvariants, fs: &mut FrameState) -> Vec<u8> {
h
}
fn encode_frame(sequence: &Sequence, fi: &FrameInvariants, fs: &mut FrameState, last_rec: &Option<Frame>) -> Vec<u8> {
fn encode_frame(sequence: &mut Sequence, fi: &FrameInvariants, fs: &mut FrameState, last_rec: &Option<Frame>) -> Vec<u8> {
let mut packet = Vec::new();
write_uncompressed_header(&mut packet, sequence, fi).unwrap();
//write_obus(&mut packet, sequence, fi).unwrap();
......@@ -1332,7 +1336,7 @@ fn encode_frame(sequence: &Sequence, fi: &FrameInvariants, fs: &mut FrameState,
}
/// Encode and write a frame.
pub fn process_frame(sequence: &Sequence, fi: &FrameInvariants,
pub fn process_frame(sequence: &mut Sequence, fi: &FrameInvariants,
output_file: &mut Write,
y4m_dec: &mut y4m::Decoder<Box<Read>>,
y4m_enc: Option<&mut y4m::Encoder<Box<Write>>>,
......@@ -1379,7 +1383,7 @@ pub fn process_frame(sequence: &Sequence, fi: &FrameInvariants,
_ => panic! ("unknown input bit depth!"),
}
let packet = encode_frame(&sequence, &fi, &mut fs, &last_rec);
let packet = encode_frame(sequence, &fi, &mut fs, &last_rec);
write_ivf_frame(output_file, fi.number, packet.as_ref());
if let Some(mut y4m_enc) = y4m_enc {
let mut rec_y = vec![128 as u8; width*height];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment