Commit 70005e35 authored by Yushin Cho's avatar Yushin Cho Committed by Yushin Cho

Update frame_pmvs[] as soon as better MVs are available for topdown parition

parent b4633a96
......@@ -1555,7 +1555,7 @@ pub fn encode_block_with_modes<T: Pixel>(
fn encode_partition_bottomup<T: Pixel>(
fi: &FrameInvariants<T>, fs: &mut FrameState<T>, cw: &mut ContextWriter,
w_pre_cdef: &mut dyn Writer, w_post_cdef: &mut dyn Writer, bsize: BlockSize,
bo: BlockOffset, pmvs: &[[Option<MotionVector>; REF_FRAMES]; 5],
bo: BlockOffset, pmvs: &mut [[Option<MotionVector>; REF_FRAMES]; 5],
ref_rd_cost: f64
) -> (RDOOutput) {
let rdo_type = RDOType::PixelDistRealRate;
......@@ -1605,7 +1605,7 @@ fn encode_partition_bottomup<T: Pixel>(
} else {
((bo.x & 32) >> 5) + ((bo.y & 32) >> 4) + 1
};
let spmvs = &pmvs[pmv_idx];
let spmvs = &mut pmvs[pmv_idx];
let mode_decision = rdo_mode_decision(fi, fs, cw, bsize, bo, spmvs);
......@@ -1772,7 +1772,7 @@ fn encode_partition_topdown<T: Pixel>(
fi: &FrameInvariants<T>, fs: &mut FrameState<T>,
cw: &mut ContextWriter, w_pre_cdef: &mut dyn Writer, w_post_cdef: &mut dyn Writer,
bsize: BlockSize, bo: BlockOffset, block_output: &Option<RDOOutput>,
pmvs: &[[Option<MotionVector>; REF_FRAMES]; 5]
pmvs: &mut [[Option<MotionVector>; REF_FRAMES]; 5]
) {
if bo.x >= cw.bc.blocks.cols || bo.y >= cw.bc.blocks.rows {
......@@ -1850,7 +1850,7 @@ fn encode_partition_topdown<T: Pixel>(
} else {
((bo.x & 32) >> 5) + ((bo.y & 32) >> 4) + 1
};
let spmvs = &pmvs[pmv_idx];
let spmvs = &mut pmvs[pmv_idx];
// Make a prediction mode decision for blocks encoded with no rdo_partition_decision call (e.g. edges)
rdo_mode_decision(fi, fs, cw, bsize, bo, spmvs)
......@@ -2194,12 +2194,12 @@ fn encode_tile<T: Pixel>(
if fi.config.speed_settings.encode_bottomup {
encode_partition_bottomup(fi, fs, &mut cw,
&mut w_pre_cdef, &mut w_post_cdef,
BlockSize::BLOCK_64X64, bo, &pmvs, std::f64::MAX);
BlockSize::BLOCK_64X64, bo, &mut pmvs, std::f64::MAX);
}
else {
encode_partition_topdown(fi, fs, &mut cw,
&mut w_pre_cdef, &mut w_post_cdef,
BlockSize::BLOCK_64X64, bo, &None, &pmvs);
BlockSize::BLOCK_64X64, bo, &None, &mut pmvs);
}
// CDEF has to be decided before loop restoration, but coded after.
......
......@@ -456,7 +456,7 @@ impl Default for EncodingSettings {
pub fn rdo_mode_decision<T: Pixel>(
fi: &FrameInvariants<T>, fs: &mut FrameState<T>,
cw: &mut ContextWriter, bsize: BlockSize, bo: BlockOffset,
pmvs: &[Option<MotionVector>]
pmvs: &mut [Option<MotionVector>]
) -> RDOPartitionOutput {
let mut best = EncodingSettings::default();
......@@ -525,9 +525,13 @@ pub fn rdo_mode_decision<T: Pixel>(
let ref_slot = ref_slot_set[i] as usize;
let cmv = pmvs[ref_slot].unwrap();
let b_me = motion_estimation(fi, fs, bsize, bo, ref_frames[0], cmv, pmv);
if !fi.config.speed_settings.encode_bottomup &&
(bsize == BlockSize::BLOCK_32X32 || bsize == BlockSize::BLOCK_64X64) {
pmvs[ref_slot] = Some(b_me);
};
mvs_from_me.push([
b_me,
MotionVector::default()
......@@ -1101,7 +1105,7 @@ pub fn rdo_partition_decision<T: Pixel>(
fi: &FrameInvariants<T>, fs: &mut FrameState<T>,
cw: &mut ContextWriter, w_pre_cdef: &mut dyn Writer, w_post_cdef: &mut dyn Writer,
bsize: BlockSize, bo: BlockOffset,
cached_block: &RDOOutput, pmvs: &[[Option<MotionVector>; REF_FRAMES]; 5],
cached_block: &RDOOutput, pmvs: &mut [[Option<MotionVector>; REF_FRAMES]; 5],
partition_types: &[PartitionType], rdo_type: RDOType
) -> RDOOutput {
let mut best_partition = cached_block.part_type;
......@@ -1133,7 +1137,7 @@ pub fn rdo_partition_decision<T: Pixel>(
((bo.x & 32) >> 5) + ((bo.y & 32) >> 4) + 1
};
let spmvs = &pmvs[pmv_idx];
let spmvs = &mut pmvs[pmv_idx];
let mode_decision = rdo_mode_decision(fi, fs, cw, bsize, bo, spmvs);
child_modes.push(mode_decision);
......@@ -1181,7 +1185,7 @@ pub fn rdo_partition_decision<T: Pixel>(
for (&offset, pmv_idx) in partitions.iter().zip(pmv_idxs) {
let mode_decision =
rdo_mode_decision(fi, fs, cw, subsize, offset,
&pmvs[pmv_idx]);
&mut pmvs[pmv_idx]);
rd_cost_sum += mode_decision.rd_cost;
......
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