Unverified Commit 6070c915 authored by Yushin Cho's avatar Yushin Cho Committed by GitHub

Don't do duplicate tx_type rdo with bottom-up partition rdo (#643)

- Don't do duplicate tx_type rdo with bottom-up partition rdo.
- Set tx_type  as DCT_DCT when skip==true during mode decision rdo.
- Add set_tx_size() if rdo_tx_size_type() is not called.
parent c6d16699
......@@ -1672,7 +1672,9 @@ fn encode_partition_bottomup(seq: &Sequence, fi: &FrameInvariants, fs: &mut Fram
pred_cfl_params: CFLParams::new(),
ref_frame: INTRA_FRAME,
mv: MotionVector { row: 0, col: 0},
skip: false
skip: false,
tx_size: TxSize::TX_4X4,
tx_type: TxType::DCT_DCT,
}; // Best decision that is not PARTITION_SPLIT
let hbs = bs >> 1; // Half the block size in blocks
......@@ -1701,14 +1703,17 @@ fn encode_partition_bottomup(seq: &Sequence, fi: &FrameInvariants, fs: &mut Fram
let mv = mode_decision.mv;
let skip = mode_decision.skip;
let mut cdef_coded = cw.bc.cdef_coded;
let (tx_size, tx_type) = (mode_decision.tx_size, mode_decision.tx_type);
debug_assert!((tx_size, tx_type) ==
rdo_tx_size_type(seq, fi, fs, cw, bsize, bo, mode_luma, ref_frame, mv, skip));
cw.bc.set_tx_size(bo, tx_size);
rd_cost = mode_decision.rd_cost + cost;
let mut mv_stack = Vec::new();
let mode_context = cw.find_mvrefs(bo, ref_frame, &mut mv_stack, bsize, false, fi);
let (tx_size, tx_type) =
rdo_tx_size_type(seq, fi, fs, cw, bsize, bo, mode_luma, ref_frame, mv, skip);
cdef_coded = encode_block_a(seq, cw, if cdef_coded {w_post_cdef} else {w_pre_cdef},
bsize, bo, skip);
encode_block_b(seq, fi, fs, cw, if cdef_coded {w_post_cdef} else {w_pre_cdef},
......@@ -1780,13 +1785,15 @@ fn encode_partition_bottomup(seq: &Sequence, fi: &FrameInvariants, fs: &mut Fram
let mv = best_decision.mv;
let skip = best_decision.skip;
let mut cdef_coded = cw.bc.cdef_coded;
let (tx_size, tx_type) = (best_decision.tx_size, best_decision.tx_type);
debug_assert!((tx_size, tx_type) ==
rdo_tx_size_type(seq, fi, fs, cw, bsize, bo, mode_luma, ref_frame, mv, skip));
cw.bc.set_tx_size(bo, tx_size);
let mut mv_stack = Vec::new();
let mode_context = cw.find_mvrefs(bo, ref_frame, &mut mv_stack, bsize, false, fi);
let (tx_size, tx_type) =
rdo_tx_size_type(seq, fi, fs, cw, bsize, bo, mode_luma, ref_frame, mv, skip);
cdef_coded = encode_block_a(seq, cw, if cdef_coded {w_post_cdef} else {w_pre_cdef},
bsize, bo, skip);
encode_block_b(seq, fi, fs, cw, if cdef_coded {w_post_cdef} else {w_pre_cdef},
......
......@@ -54,7 +54,9 @@ pub struct RDOPartitionOutput {
pub pred_cfl_params: CFLParams,
pub ref_frame: usize,
pub mv: MotionVector,
pub skip: bool
pub skip: bool,
pub tx_size: TxSize,
pub tx_type: TxType,
}
#[allow(unused)]
......@@ -344,7 +346,7 @@ pub fn rdo_mode_decision(
let luma_rdo = |luma_mode: PredictionMode, fs: &mut FrameState, cw: &mut ContextWriter, best: &mut EncodingSettings,
mv: MotionVector, ref_frame: usize, mode_set_chroma: &[PredictionMode], luma_mode_is_intra: bool,
mode_context: usize, mv_stack: &Vec<CandidateMV>| {
let (tx_size, tx_type) = rdo_tx_size_type(
let (tx_size, mut tx_type) = rdo_tx_size_type(
seq, fi, fs, cw, bsize, bo, luma_mode, ref_frame, mv, false,
);
......@@ -354,6 +356,8 @@ pub fn rdo_mode_decision(
let wr: &mut dyn Writer = &mut WriterCounter::new();
let tell = wr.tell_frac();
if skip { tx_type = TxType::DCT_DCT; };
encode_block_a(seq, cw, wr, bsize, bo, skip);
encode_block_b(
seq,
......@@ -537,7 +541,9 @@ pub fn rdo_mode_decision(
ref_frame: best.ref_frame,
mv: best.mv,
rd_cost: best.rd,
skip: best.skip
skip: best.skip,
tx_size: best.tx_size,
tx_type: best.tx_type,
}]
}
}
......
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