Commit 336a7d6a authored by David Michael Barr's avatar David Michael Barr

Allow sub-8x8 partitions with --tune=Psychovisual

First, tune cdef_dist_wxh_8x8 scaling:
Ensure ssim_boost >= 1 where svar < 4096 and dvar < 8192.
Fix the value of ssim_boost at (0, 4096) to 5/4.

Fall back to SSE for blocks where w < 8 or h < 8.
parent cbe84f4b
......@@ -578,15 +578,8 @@ impl FrameInvariants {
// Speed level decides the minimum partition size, i.e. higher speed --> larger min partition size,
// with exception that SBs on right or bottom frame borders split down to BLOCK_4X4.
// At speed = 0, RDO search is exhaustive.
let mut min_partition_size = config.speed_settings.min_block_size;
let min_partition_size = config.speed_settings.min_block_size;
if config.tune == Tune::Psychovisual {
if min_partition_size < BlockSize::BLOCK_8X8 {
// TODO: Display message that min partition size is enforced to 8x8
min_partition_size = BlockSize::BLOCK_8X8;
println!("If tune=Psychovisual is used, min partition size is enforced to 8x8");
}
}
let use_reduced_tx_set = config.speed_settings.reduced_tx_set;
let use_tx_domain_distortion = config.tune == Tune::Psnr && config.speed_settings.tx_domain_distortion;
......
......@@ -85,8 +85,8 @@ fn cdef_dist_wxh_8x8(
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 = (4033_f64 / 16_384_f64) * (svar + dvar + (16_384 << 2 * coeff_shift) as f64)
/ f64::sqrt((16_265_089 << 4 * coeff_shift) as f64 + svar * dvar);
(sse * ssim_boost + 0.5_f64) as u64
}
......@@ -177,13 +177,22 @@ fn compute_rd_cost(
h_y
)
} else if fi.config.tune == Tune::Psychovisual {
cdef_dist_wxh(
&fs.input.planes[0].slice(&po),
&fs.rec.planes[0].slice(&po),
w_y,
h_y,
fi.sequence.bit_depth
)
if w_y < 8 || h_y < 8 {
sse_wxh(
&fs.input.planes[0].slice(&po),
&fs.rec.planes[0].slice(&po),
w_y,
h_y
)
} else {
cdef_dist_wxh(
&fs.input.planes[0].slice(&po),
&fs.rec.planes[0].slice(&po),
w_y,
h_y,
fi.sequence.bit_depth
)
}
} else {
unimplemented!();
};
......
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