Skip to content

Commit

Permalink
Show Existing Frames
Browse files Browse the repository at this point in the history
Every odd frame is a show_existing_frame.
  • Loading branch information
luctrudeau authored and tdaede committed Feb 8, 2018
1 parent a2d8fae commit becced1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/bin/rav1e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn main() {
break;
}
fi.number += 1;
fi.show_existing_frame = fi.number % 2 == 1;
if fi.number == files.limit {
break;
}
Expand Down
16 changes: 13 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct FrameInvariants {
pub sb_height: usize,
pub number: u64,
pub ftype: FrameType,
pub show_existing_frame: bool,
}

impl FrameInvariants {
Expand All @@ -99,7 +100,8 @@ impl FrameInvariants {
sb_width: (width+63)/64,
sb_height: (height+63)/64,
number: 0,
ftype: FrameType::KEY
ftype: FrameType::KEY,
show_existing_frame: false,
}
}
}
Expand Down Expand Up @@ -205,6 +207,12 @@ fn write_uncompressed_header(packet: &mut Write, sequence: &Sequence, fi: &Frame
let mut uch = BitWriter::<BE>::new(packet);
uch.write(2,2)?; // frame type
uch.write(2,sequence.profile)?; // profile 0
if fi.show_existing_frame {
uch.write_bit(true)?; // show_existing_frame=1
uch.write(3,0)?; // show last frame
uch.byte_align()?;
return Ok(());
}
uch.write_bit(false)?; // show_existing_frame=0
uch.write_bit(false)?; // keyframe
uch.write_bit(true)?; // show frame
Expand Down Expand Up @@ -367,8 +375,10 @@ fn encode_tile(fi: &FrameInvariants, fs: &mut FrameState) -> Vec<u8> {
fn encode_frame(sequence: &Sequence, fi: &FrameInvariants, fs: &mut FrameState) -> Vec<u8> {
let mut packet = Vec::new();
write_uncompressed_header(&mut packet, sequence, fi).unwrap();
let tile = encode_tile(fi, fs);
packet.write(&tile).unwrap();
if !fi.show_existing_frame {
let tile = encode_tile(fi, fs);
packet.write(&tile).unwrap();
}
packet
}

Expand Down

0 comments on commit becced1

Please sign in to comment.