Commit 8a59a709 authored by Monty's avatar Monty Committed by Monty Montgomery

Add configuration of loop filter according to quantizer

Inplement an ~ direct copy of libaom's LPF_PICK_FROM_Q deblocking
filter configuration.  This is not real RDO, but should be superior to
the current flat configuration.

The libaom code also mentions the magic numbers almost certainly need a
new regression fit.
parent 018971a0
......@@ -12,6 +12,7 @@
use std::cmp;
use context::*;
use plane::*;
use quantize::*;
use partition::*;
use partition::PredictionMode::*;
use util::clamp;
......@@ -485,3 +486,37 @@ pub fn deblock_filter_frame(fi: &FrameInvariants, fs: &mut FrameState,
deblock_plane(fi, &fs.deblock, &mut fs.rec.planes[p], p, bc, bit_depth);
}
}
pub fn deblock_filter_optimize(fi: &FrameInvariants, fs: &mut FrameState,
_bc: &mut BlockContext, bit_depth: usize) {
let q = ac_q(fi.base_q_idx, bit_depth) as i32;
let level = clamp (match bit_depth {
8 => {
if fi.frame_type == FrameType::KEY {
q * 17563 - 421574 + (1<<18>>1) >> 18
} else {
q * 6017 + 650707 + (1<<18>>1) >> 18
}
}
10 => {
if fi.frame_type == FrameType::KEY {
(q * 20723 + 4060632 + (1<<20>>1) >> 20) - 4
} else {
q * 20723 + 4060632 + (1<<20>>1) >> 20
}
}
12 => {
if fi.frame_type == FrameType::KEY {
(q * 20723 + 16242526 + (1<<22>>1) >> 22) - 4
} else {
q * 20723 + 16242526 + (1<<22>>1) >> 22
}
}
_ => {assert!(false); 0}
}, 0, MAX_LOOP_FILTER as i32) as u8;
fs.deblock.levels[0] = level;
fs.deblock.levels[1] = level;
fs.deblock.levels[2] = level;
fs.deblock.levels[3] = level;
}
......@@ -1925,6 +1925,7 @@ fn encode_tile(sequence: &mut Sequence, fi: &FrameInvariants, fs: &mut FrameStat
}
}
/* TODO: Don't apply if lossless */
deblock_filter_optimize(fi, fs, &mut cw.bc, bit_depth);
if fs.deblock.levels[0] != 0 || fs.deblock.levels[1] != 0 {
deblock_filter_frame(fi, fs, &mut cw.bc, bit_depth);
}
......
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