Commit 4003c39d authored by Frank Bossen's avatar Frank Bossen Committed by Thomas Daede

Make quantization offset depend on mode type

Use smaller rounding offset in inter blocks to produce more
zero coefficients
parent de7860f0
......@@ -73,7 +73,7 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
b.iter(|| {
for &mode in RAV1E_INTRA_MODES {
let sbo = SuperBlockOffset { x: sbx, y: sby };
fs.qc.update(fi.config.quantizer, tx_size);
fs.qc.update(fi.config.quantizer, tx_size, mode.is_intra());
for p in 1..3 {
for by in 0..8 {
for bx in 0..8 {
......
......@@ -1550,7 +1550,7 @@ pub fn write_tx_blocks(fi: &FrameInvariants, fs: &mut FrameState,
let PlaneConfig { xdec, ydec, .. } = fs.input.planes[1].cfg;
fs.qc.update(fi.config.quantizer, tx_size);
fs.qc.update(fi.config.quantizer, tx_size, luma_mode.is_intra());
for by in 0..bh {
for bx in 0..bw {
......@@ -1590,7 +1590,7 @@ pub fn write_tx_blocks(fi: &FrameInvariants, fs: &mut FrameState,
let partition_x = (bo.x & LOCAL_BLOCK_MASK) >> xdec << MI_SIZE_LOG2;
let partition_y = (bo.y & LOCAL_BLOCK_MASK) >> ydec << MI_SIZE_LOG2;
fs.qc.update(fi.config.quantizer, uv_tx_size);
fs.qc.update(fi.config.quantizer, uv_tx_size, chroma_mode.is_intra());
for p in 1..3 {
let sb_offset = bo.sb_offset().plane_offset(&fs.input.planes[p].cfg);
......@@ -1628,7 +1628,7 @@ pub fn write_tx_tree(fi: &FrameInvariants, fs: &mut FrameState, cw: &mut Context
let PlaneConfig { xdec, ydec, .. } = fs.input.planes[1].cfg;
fs.qc.update(fi.config.quantizer, tx_size);
fs.qc.update(fi.config.quantizer, tx_size, luma_mode.is_intra());
let po = bo.plane_offset(&fs.input.planes[0].cfg);
let has_coeff = encode_tx_block(fi, fs, cw, w, 0, &bo, luma_mode, tx_size, tx_type, bsize, &po, skip);
......@@ -1659,7 +1659,7 @@ pub fn write_tx_tree(fi: &FrameInvariants, fs: &mut FrameState, cw: &mut Context
let partition_x = (bo.x & LOCAL_BLOCK_MASK) >> xdec << MI_SIZE_LOG2;
let partition_y = (bo.y & LOCAL_BLOCK_MASK) >> ydec << MI_SIZE_LOG2;
fs.qc.update(fi.config.quantizer, uv_tx_size);
fs.qc.update(fi.config.quantizer, uv_tx_size, chroma_mode.is_intra());
for p in 1..3 {
let sb_offset = bo.sb_offset().plane_offset(&fs.input.planes[p].cfg);
......
......@@ -101,7 +101,7 @@ mod test {
}
impl QuantizationContext {
pub fn update(&mut self, qindex: usize, tx_size: TxSize) {
pub fn update(&mut self, qindex: usize, tx_size: TxSize, is_intra: bool) {
self.tx_scale = get_tx_scale(tx_size) as i32;
self.dc_quant = dc_q(qindex) as u32;
......@@ -110,8 +110,8 @@ impl QuantizationContext {
self.ac_quant = ac_q(qindex) as u32;
self.ac_mul_add = divu_gen(self.ac_quant);
self.dc_offset = self.dc_quant as i32 * 21 / 64;
self.ac_offset = self.ac_quant as i32 * 21 / 64;
self.dc_offset = self.dc_quant as i32 * (if is_intra {21} else {15}) / 64;
self.ac_offset = self.ac_quant as i32 * (if is_intra {21} else {15}) / 64;
}
#[inline]
......
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