Commit 9f2b2beb14 for aom
commit 9f2b2beb14ade7b4592cbc79621fcb2e00ebdeb5
Author: Ihor Buhaiov <freedbrt@gmail.com>
Date: Mon Oct 12 13:03:58 2026 +0200
rtc: Signal one CDEF strength when both are 0
With skip_cdef_sb on, av1_pick_cdef_from_qp() signals two CDEF
strengths: the one picked from q, and 0 for the blocks that skip CDEF.
When the strength picked from q is 0 too, the second entry adds
nothing, but the frame still sets cdef_bits to 1. Every 64x64 unit with
coded residual then spends a bit on its strength index, and the decoder
runs CDEF over the whole frame, because it only skips CDEF when
cdef_bits is 0 and the first strengths are 0.
This is the usual case for screen content at speed 11 at low and medium
q. On two 2560x1440 screen recordings at qindex 32 to 52, every frame
had both strengths at 0.
Signal a single strength of 0 instead. The decoded frames stay the
same. On those recordings the stream is 0.07% to 0.18% smaller, and
the libaom decoder skips CDEF. Its CPU time drops by 1% to 4.5% in 7 of
8 runs (4:2:0 and 4:4:4, 1 and 4 encoder threads) and rises 0.7% in the
eighth.
Change-Id: I4ffcd85e15483ff5040176794e01f755f890ab51
diff --git a/av1/encoder/pickcdef.c b/av1/encoder/pickcdef.c
index ed6db25c04..29f9928a96 100644
--- a/av1/encoder/pickcdef.c
+++ b/av1/encoder/pickcdef.c
@@ -813,11 +813,15 @@ void av1_pick_cdef_from_qp(AV1_COMMON *const cm, int skip_cdef,
: predicted_uv_f1 * CDEF_SEC_STRENGTHS + predicted_uv_f2;
// mbmi->cdef_strength is already set in the encoding stage. We don't need to
- // set it again here.
+ // set it again here, unless the first strength is 0 too.
if (skip_cdef) {
cdef_info->cdef_strengths[1] = 0;
cdef_info->cdef_uv_strengths[1] = 0;
- return;
+ if (cdef_info->cdef_strengths[0] || cdef_info->cdef_uv_strengths[0]) return;
+ // Both strengths are 0, so signal only one. This saves the per block
+ // strength index and lets the decoder skip CDEF for the frame.
+ cdef_info->cdef_bits = 0;
+ cdef_info->nb_cdef_strengths = 1;
}
const CommonModeInfoParams *const mi_params = &cm->mi_params;