Skip to content
Snippets Groups Projects
Commit 34c6cc9a authored by Michael Bebenita's avatar Michael Bebenita
Browse files

Format and disable cdef dist until we wire up the tune config param.

parent 71e29b68
No related branches found
No related tags found
No related merge requests found
......@@ -85,11 +85,7 @@ impl<'a> PlaneSlice<'a> {
}
pub fn subslice(&'a self, xo: usize, yo: usize) -> PlaneSlice<'a> {
PlaneSlice {
plane: self.plane,
x: self.x+xo,
y: self.y+yo
}
PlaneSlice { plane: self.plane, x: self.x + xo, y: self.y + yo }
}
/// A slice starting i pixels above the current one.
......
......@@ -19,13 +19,13 @@ use plane::*;
use predict::{RAV1E_INTRA_MODES, RAV1E_INTRA_MODES_MINIMAL};
use quantize::dc_q;
use std;
use std::f64;
use std::vec::Vec;
use write_tx_blocks;
use BlockSize;
use FrameInvariants;
use FrameState;
use FrameType;
use std::f64;
#[derive(Clone)]
pub struct RDOOutput {
......@@ -43,6 +43,7 @@ pub struct RDOPartitionOutput {
pub skip: bool
}
#[allow(unused)]
fn cdef_dist_wxh_8x8(src1: &PlaneSlice, src2: &PlaneSlice) -> u64 {
//TODO: Handle high bit-depth here by setting coeff_shift
let coeff_shift = 0;
......@@ -57,24 +58,31 @@ fn cdef_dist_wxh_8x8(src1: &PlaneSlice, src2: &PlaneSlice) -> u64 {
let d = src2.p(i, j) as i32;
sum_s += s;
sum_d += d;
sum_s2 += (s*s) as i64;
sum_d2 += (d*d) as i64;
sum_sd += (s*d) as i64;
sum_s2 += (s * s) as i64;
sum_d2 += (d * d) as i64;
sum_sd += (s * d) as i64;
}
}
let svar = (sum_s2 - ((sum_s as i64 * sum_s as i64 + 32) >> 6)) as f64;
let dvar = (sum_d2 - ((sum_d as i64 * sum_d as i64 + 32) >> 6)) as f64;
let sse = (sum_d2 + sum_s2 - 2 * sum_sd) as f64;
//The two constants were tuned for CDEF, but can probably be better tuned for use in general RDO
let ssim_boost = 0.5_f64 * (svar + dvar + (400 << 2 * coeff_shift) as f64) / f64::sqrt((20000 << 4 * coeff_shift) as f64 + svar * dvar);
let ssim_boost = 0.5_f64 * (svar + dvar + (400 << 2 * coeff_shift) as f64)
/ f64::sqrt((20000 << 4 * coeff_shift) as f64 + svar * dvar);
(sse * ssim_boost + 0.5_f64) as u64
}
fn cdef_dist_wxh(src1: &PlaneSlice, src2: &PlaneSlice, w: usize, h: usize) -> u64 {
#[allow(unused)]
fn cdef_dist_wxh(
src1: &PlaneSlice, src2: &PlaneSlice, w: usize, h: usize
) -> u64 {
let mut sum: u64 = 0;
for j in 0..h/8 {
for i in 0..w/8 {
sum += cdef_dist_wxh_8x8(&src1.subslice(i*8, j*8), &src2.subslice(i*8, j*8))
for j in 0..h / 8 {
for i in 0..w / 8 {
sum += cdef_dist_wxh_8x8(
&src1.subslice(i * 8, j * 8),
&src2.subslice(i * 8, j * 8)
)
}
}
sum
......@@ -109,7 +117,7 @@ fn compute_rd_cost(
// Compute distortion
let po = bo.plane_offset(&fs.input.planes[0].cfg);
let mut distortion = cdef_dist_wxh(
let mut distortion = sse_wxh(
&fs.input.planes[0].slice(&po),
&fs.rec.planes[0].slice(&po),
w_y,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment