Commit b94ad9a9 authored by Monty's avatar Monty Committed by Monty Montgomery

First cut code for loop deblocking filter

No RDO as yet, but the deblocking filter and parameter infrastructure are
full implemented, functional and tested.
parent 982d16c3
......@@ -16,6 +16,7 @@ ignore = [
# "src/ec.rs", # Clean
"src/lib.rs", # Did not clean yet to avoid conflicts with open PRs.
"src/cdef.rs", # Did not try to clean yet.
"src/deblock.rs", # Did not try to clean yet.
# "src/partition.rs", # Clean
# "src/plane.rs", # Clean
# "src/predict.rs", # Clean
......
......@@ -72,8 +72,8 @@ const TX_SETS_INTER: usize = 4;
const MAX_REF_MV_STACK_SIZE: usize = 8;
pub const REF_CAT_LEVEL: u32 = 640;
const FRAME_LF_COUNT: usize = 4;
const MAX_LOOP_FILTER: usize = 63;
pub const FRAME_LF_COUNT: usize = 4;
pub const MAX_LOOP_FILTER: usize = 63;
const DELTA_LF_SMALL: u32 = 3;
const DELTA_LF_PROBS: usize = DELTA_LF_SMALL as usize;
......
This diff is collapsed.
......@@ -8,6 +8,7 @@ use rdo::*;
use ec::*;
use std::fmt;
use util::*;
use deblock::*;
use cdef::*;
use bitstream_io::{BE, LE, BitWriter};
......@@ -246,13 +247,11 @@ impl FrameState {
#[derive(Copy, Clone, Debug)]
pub struct DeblockState {
pub levels: [u8; PLANES+1],
pub levels: [u8; PLANES+1], // Y vertical edges, Y horizontal, U, V
pub sharpness: u8,
pub deltas_enabled: bool,
pub delta_updates_enabled: bool,
pub ref_deltas_enabled: bool,
pub ref_deltas: [i8; REF_FRAMES],
pub mode_deltas_enabled: bool,
pub mode_deltas: [i8; 2],
pub block_deltas_enabled: bool,
pub block_delta_shift: u8,
......@@ -262,13 +261,11 @@ pub struct DeblockState {
impl Default for DeblockState {
fn default() -> Self {
DeblockState {
levels: [0; PLANES+1],
levels: [8,8,4,4],
sharpness: 0,
deltas_enabled: false,
deltas_enabled: false, // requires delta_q_enabled
delta_updates_enabled: false,
ref_deltas_enabled: false,
ref_deltas: [1, 0, 0, 0, 0, -1, -1, -1],
mode_deltas_enabled: false,
mode_deltas: [0, 0],
block_deltas_enabled: false,
block_delta_shift: 0,
......@@ -1006,7 +1003,7 @@ impl<'a> UncompressedHeader for BitWriter<'a, BE> {
assert!(fi.deblock.levels[3] < 64);
self.write(6, fi.deblock.levels[3])?; // loop deblocking filter level 3
}
self.write(3,0)?; // deblocking filter sharpness
self.write(3,fi.deblock.sharpness)?; // deblocking filter sharpness
self.write_bit(fi.deblock.deltas_enabled)?; // loop deblocking filter deltas enabled
if fi.deblock.deltas_enabled {
self.write_bit(fi.deblock.delta_updates_enabled)?; // deltas updates enabled
......@@ -1905,6 +1902,10 @@ fn encode_tile(sequence: &mut Sequence, fi: &FrameInvariants, fs: &mut FrameStat
}
}
/* TODO: Don't apply if lossless */
if fi.deblock.levels[0] != 0 || fi.deblock.levels[1] != 0 {
deblock_filter_frame(fi, &mut fs.rec, &mut cw.bc, bit_depth);
}
/* TODO: Don't apply if lossless */
if sequence.enable_cdef {
cdef_filter_frame(fi, &mut fs.rec, &mut cw.bc, bit_depth);
}
......
......@@ -27,6 +27,7 @@ pub mod predict;
pub mod rdo;
#[macro_use]
pub mod util;
pub mod deblock;
pub mod cdef;
pub mod encoder;
pub mod me;
......
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