Skip to content

Commit

Permalink
encoder: Add missing trailing bits byte at the end of metadata obu
Browse files Browse the repository at this point in the history
Adjust ObuMetaType.size() to return the payload size only.
Fix xiph#977.
  • Loading branch information
kodawah committed Feb 13, 2019
1 parent e3c0eab commit 48c183b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> {
// since it is fixed (depending on the metadata)
{
let mut coded_payload_length = [0 as u8; 8];
let leb_size = aom_uleb_encode(obu_meta_type.size(), &mut coded_payload_length);
let leb_size = aom_uleb_encode(obu_meta_type.size() + 2, &mut coded_payload_length);
for i in 0..leb_size {
self.write(8, coded_payload_length[i]).unwrap();
}
Expand Down Expand Up @@ -1026,6 +1026,10 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> {
_ => {}
}

// trailing bits (1 byte)
self.write_bit(true)?;
self.byte_align()?;

Ok(())
}

Expand Down Expand Up @@ -1747,8 +1751,8 @@ impl ObuMetaType {
fn size(&self) -> u64 {
use self::ObuMetaType::*;
match self {
OBU_META_HDR_CLL => 5,
OBU_META_HDR_MDCV => 25,
OBU_META_HDR_CLL => 4,
OBU_META_HDR_MDCV => 24,
_ => 0,
}
}
Expand Down

0 comments on commit 48c183b

Please sign in to comment.