Commit 11393755 authored by fbossen's avatar fbossen Committed by Raphael Zumer

Add encoding of order_hint (#585)

* Add encoding of order_hint

For now a single bit is used for encoding order_hint

* Add intermediate variable

Add intermediate variable from which frame_type and order_hint are
derived
parent f371d12d
......@@ -112,7 +112,11 @@ impl Context {
deblock: Default::default(),
};
self.fi.frame_type = if self.fi.number % 30 == 0 {
let frame_number_in_segment = self.fi.number % 30;
self.fi.order_hint = frame_number_in_segment as u32;
self.fi.frame_type = if frame_number_in_segment == 0 {
FrameType::KEY
} else {
FrameType::INTER
......
......@@ -65,6 +65,7 @@ impl Frame {
#[derive(Debug, Clone)]
pub struct ReferenceFrame {
pub order_hint: u32,
pub frame: Frame,
pub cdfs: CDFContext
}
......@@ -225,7 +226,7 @@ impl Sequence {
enable_interintra_compound: false,
enable_masked_compound: false,
enable_dual_filter: false,
enable_order_hint: false,
enable_order_hint: true,
enable_jnt_comp: false,
enable_ref_frame_mvs: false,
enable_warped_motion: false,
......@@ -319,6 +320,7 @@ pub struct FrameInvariants {
pub w_in_b: usize,
pub h_in_b: usize,
pub number: u64,
pub order_hint: u32,
pub show_frame: bool,
pub showable_frame: bool,
pub error_resilient: bool,
......@@ -386,6 +388,7 @@ impl FrameInvariants {
w_in_b: 2 * width.align_power_of_two_and_shift(3), // MiCols, ((width+7)/8)<<3 >> MI_SIZE_LOG2
h_in_b: 2 * height.align_power_of_two_and_shift(3), // MiRows, ((height+7)/8)<<3 >> MI_SIZE_LOG2
number: 0,
order_hint: 0,
show_frame: true,
showable_frame: true,
error_resilient: false,
......@@ -781,8 +784,11 @@ impl<'a> UncompressedHeader for BitWriter<'a, BE> {
}
if seq.enable_order_hint {
assert!(false); // Not supported by rav1e yet!
let n = seq.order_hint_bits_minus_1 + 1;
let mask = (1 << n) - 1;
self.write(n, fi.order_hint & mask)?;
}
if fi.error_resilient || fi.intra_only {
} else {
self.write(PRIMARY_REF_BITS, fi.primary_ref_frame)?;
......@@ -844,7 +850,6 @@ impl<'a> UncompressedHeader for BitWriter<'a, BE> {
// Done by above
} else {
if seq.enable_order_hint {
assert!(false); // Not supported by rav1e yet!
self.write_bit(frame_refs_short_signaling)?;
if frame_refs_short_signaling {
assert!(false); // Not supported by rav1e yet!
......@@ -2064,7 +2069,7 @@ pub fn encode_frame(sequence: &mut Sequence, fi: &mut FrameInvariants, fs: &mut
}
pub fn update_rec_buffer(fi: &mut FrameInvariants, fs: FrameState) {
let rfs = Rc::new(ReferenceFrame { frame: fs.rec, cdfs: fs.cdfs } );
let rfs = Rc::new(ReferenceFrame { order_hint: fi.order_hint, frame: fs.rec, cdfs: fs.cdfs } );
for i in 0..(REF_FRAMES as usize) {
if (fi.refresh_frame_flags & (1 << i)) != 0 {
fi.rec_buffer.frames[i] = Some(Rc::clone(&rfs));
......
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