From 34c6cc9aae3cc2bbd02d37eee97fc5fff65f6dc5 Mon Sep 17 00:00:00 2001 From: Michael Bebenita <mbebenita@gmail.com> Date: Wed, 18 Jul 2018 00:19:11 -0400 Subject: [PATCH] Format and disable cdef dist until we wire up the tune config param. --- src/plane.rs | 6 +----- src/rdo.rs | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/plane.rs b/src/plane.rs index 4b7d7a0f..3c30dddc 100644 --- a/src/plane.rs +++ b/src/plane.rs @@ -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. diff --git a/src/rdo.rs b/src/rdo.rs index 3f94ab14..3f47c9a9 100644 --- a/src/rdo.rs +++ b/src/rdo.rs @@ -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, -- GitLab