Commit fbf7ff49 authored by Thomas Daede's avatar Thomas Daede Committed by Thomas Daede

Write temporal delimiters only at the beginning of a packet.

Fixes #954
parent 4d653d39
......@@ -339,6 +339,9 @@ impl Config {
aom_dsp_rtcd();
}
// initialize with temporal delimiter
let packet_data = TEMPORAL_DELIMITER.to_vec();
Context {
frame_count: 0,
limit: 0,
......@@ -347,7 +350,7 @@ impl Config {
frame_q: BTreeMap::new(),
frame_data: BTreeMap::new(),
keyframes: BTreeSet::new(),
packet_data: Vec::new(),
packet_data,
segment_start_idx: 0,
segment_start_frame: 0,
keyframe_detector: SceneChangeDetector::new(self.enc.bit_depth),
......@@ -598,7 +601,13 @@ impl Context {
let mut fs = FrameState::new(fi);
let data = encode_frame(fi, &mut fs);
let sef_data = encode_frame(fi, &mut fs);
self.packet_data.extend(sef_data);
let data = self.packet_data.clone();
self.packet_data.clear();
if write_temporal_delimiter(&mut self.packet_data).is_err() {
return Err(EncoderStatus::Failure);
};
let rec = if fi.show_frame { Some(fs.rec) } else { None };
let mut psnr = None;
......@@ -640,6 +649,9 @@ impl Context {
if fi.show_frame {
let data = self.packet_data.clone();
self.packet_data.clear();
if write_temporal_delimiter(&mut self.packet_data).is_err() {
return Err(EncoderStatus::Failure);
}
let mut psnr = None;
if self.config.enc.show_psnr {
......
......@@ -41,6 +41,8 @@ pub struct Frame {
pub planes: [Plane; 3]
}
pub static TEMPORAL_DELIMITER: [u8; 2] = [0x12, 0x00];
const FRAME_MARGIN: usize = 16 + SUBPEL_FILTER_SIZE;
impl Frame {
......@@ -1740,19 +1742,19 @@ fn aom_uleb_encode(mut value: u64, coded_value: &mut [u8]) -> usize {
leb_size
}
pub fn write_temporal_delimiter(
packet: &mut dyn io::Write
) -> io::Result<()> {
packet.write(&TEMPORAL_DELIMITER)?;
Ok(())
}
fn write_obus(
packet: &mut dyn io::Write, fi: &mut FrameInvariants, fs: &FrameState
) -> io::Result<()> {
let obu_extension = 0 as u32;
let mut buf1 = Vec::new();
{
let mut bw1 = BitWriter::endian(&mut buf1, BigEndian);
bw1.write_obu_header(OBU_Type::OBU_TEMPORAL_DELIMITER, obu_extension)?;
bw1.write(8, 0)?; // size of payload == 0, one byte
}
packet.write_all(&buf1).unwrap();
buf1.clear();
// write sequence header obu if KEY_FRAME, preceded by 4-byte size
if fi.frame_type == FrameType::KEY {
......
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