From 3548209a46deba2956756fa7180b03f11ed7c5b2 Mon Sep 17 00:00:00 2001 From: David Michael Barr Date: Mon, 11 May 2020 18:39:42 +0900 Subject: [PATCH 1/2] Enable CDEF filter for 4:2:2 Add missing logic to map CDEF direction for chroma planes. AWCY results on derf-720p-422 at the default speed show a 9.9% decrease in encoding speed: PSNR | PSNR Cb | PSNR Cr | PSNR HVS | SSIM | MS SSIM | CIEDE 2000 -2.5572 | 0.4582 | -1.0744 | -2.0057 | -0.1799 | -1.0506 | -2.9736 --- src/cdef.rs | 8 +++++++- src/encoder.rs | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cdef.rs b/src/cdef.rs index 8f6d7636d2..6f4b1c5708 100644 --- a/src/cdef.rs +++ b/src/cdef.rs @@ -521,6 +521,8 @@ pub fn cdef_filter_superblock( let local_pri_strength; let local_sec_strength; let mut local_damping: i32 = cdef_damping + coeff_shift; + // See `Cdef_Uv_Dir` constant lookup table in Section 7.15.1 + // let local_dir = if p == 0 { local_pri_strength = adjust_strength(cdef_pri_y_strength << coeff_shift, var); @@ -535,7 +537,11 @@ pub fn cdef_filter_superblock( local_sec_strength = cdef_sec_uv_strength << coeff_shift; local_damping -= 1; if cdef_pri_uv_strength != 0 { - dir as usize + if xdec != ydec { + [7, 0, 2, 4, 5, 6, 6, 6][dir as usize] + } else { + dir as usize + } } else { 0 } diff --git a/src/encoder.rs b/src/encoder.rs index 3a1011043e..c02d93167f 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -242,9 +242,7 @@ impl Sequence { enable_ref_frame_mvs: false, enable_warped_motion: false, enable_superres: false, - enable_cdef: config.speed_settings.cdef - && config.chroma_sampling != ChromaSampling::Cs422 - && enable_restoration_filters, + enable_cdef: config.speed_settings.cdef && enable_restoration_filters, enable_restoration: config.speed_settings.lrf && config.chroma_sampling != ChromaSampling::Cs422 && enable_restoration_filters, From 127f92b80c445a058c7266bc434267c97d639ddf Mon Sep 17 00:00:00 2001 From: David Michael Barr Date: Mon, 11 May 2020 23:14:00 +0900 Subject: [PATCH 2/2] Enable restoration filter for 4:2:2 AWCY results on derf-720p-422 at the default speed show a 28% decrease in encoding speed: PSNR | PSNR Cb | PSNR Cr | PSNR HVS | SSIM | MS SSIM | CIEDE 2000 -1.4957 | -1.2369 | -0.5441 | -1.0947 | -0.9361 | -0.7724 | -2.1054 --- src/encoder.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index c02d93167f..b4b0c8dd9c 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -244,7 +244,6 @@ impl Sequence { enable_superres: false, enable_cdef: config.speed_settings.cdef && enable_restoration_filters, enable_restoration: config.speed_settings.lrf - && config.chroma_sampling != ChromaSampling::Cs422 && enable_restoration_filters, enable_large_lru: true, enable_delayed_loopfilter_rdo: true,