Skip to content

Commit 04a8e50

Browse files
committed
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
1 parent 3536019 commit 04a8e50

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/cdef.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@ pub fn cdef_filter_superblock<T: Pixel, U: Pixel>(
522522
let local_pri_strength;
523523
let local_sec_strength;
524524
let mut local_damping: i32 = cdef_damping + coeff_shift;
525+
// See `Cdef_Uv_Dir` constant lookup table in Section 7.15.1
526+
// <https://aomediacodec.github.io/av1-spec/#cdef-block-process>
525527
let local_dir = if p == 0 {
526528
local_pri_strength =
527529
adjust_strength(cdef_pri_y_strength << coeff_shift, var);
@@ -536,7 +538,11 @@ pub fn cdef_filter_superblock<T: Pixel, U: Pixel>(
536538
local_sec_strength = cdef_sec_uv_strength << coeff_shift;
537539
local_damping -= 1;
538540
if cdef_pri_uv_strength != 0 {
539-
dir as usize
541+
if xdec != ydec {
542+
[7, 0, 2, 4, 5, 6, 6, 6][dir as usize]
543+
} else {
544+
dir as usize
545+
}
540546
} else {
541547
0
542548
}

src/encoder.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@ impl Sequence {
246246
enable_ref_frame_mvs: false,
247247
enable_warped_motion: false,
248248
enable_superres: false,
249-
enable_cdef: config.speed_settings.cdef
250-
&& config.chroma_sampling != ChromaSampling::Cs422
251-
&& enable_restoration_filters,
249+
enable_cdef: config.speed_settings.cdef && enable_restoration_filters,
252250
enable_restoration: config.speed_settings.lrf
253251
&& config.chroma_sampling != ChromaSampling::Cs422
254252
&& enable_restoration_filters,

0 commit comments

Comments
 (0)