This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit ea8ca20168f103733e10d90e2954d5f09f9a8a13
Author:     Charly Morgand-Poyac <[email protected]>
AuthorDate: Sun Jul 5 14:09:47 2026 +0200
Commit:     charlymp <[email protected]>
CommitDate: Sat Jul 11 14:23:12 2026 +0000

    lavc/hevcdec: skip the coefficient clear for DC-only blocks
    
    idct_dc reads coeffs[0] only and writes the whole block, so the
    clear before residual decoding is not needed on that path. Move it
    after the last significant coefficient position is known and compute
    col_limit once instead of at the transform call.
    
    Signed-off-by: Charly Morgand-Poyac <[email protected]>
---
 libavcodec/hevc/cabac.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c
index bb632ef990..fe637acbaa 100644
--- a/libavcodec/hevc/cabac.c
+++ b/libavcodec/hevc/cabac.c
@@ -999,6 +999,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, 
const HEVCPPS *pps,
     int greater1_ctx = 1;
 
     int num_last_subset;
+    int max_xy, col_limit, clear_rows;
     int x_cg_last_sig, y_cg_last_sig;
 
     const uint8_t *scan_x_cg, *scan_y_cg, *scan_x_off, *scan_y_off;
@@ -1022,8 +1023,6 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, 
const HEVCPPS *pps,
     int pred_mode_intra = (c_idx == 0) ? lc->tu.intra_pred_mode :
                                          lc->tu.intra_pred_mode_c;
 
-    memset(coeffs, 0, trafo_size * trafo_size * sizeof(int16_t));
-
     // Derive QP for dequant
     if (!lc->cu.cu_transquant_bypass_flag) {
         static const int qp_c[] = { 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 
36, 36, 37, 37 };
@@ -1176,6 +1175,25 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, 
const HEVCPPS *pps,
     num_coeff++;
     num_last_subset = (num_coeff - 1) >> 4;
 
+    max_xy = FFMAX(last_significant_coeff_x, last_significant_coeff_y);
+    col_limit = last_significant_coeff_x + last_significant_coeff_y + 4;
+    if (max_xy < 4)
+        col_limit = FFMIN(4, col_limit);
+    else if (max_xy < 8)
+        col_limit = FFMIN(8, col_limit);
+    else if (max_xy < 12)
+        col_limit = FFMIN(24, col_limit);
+
+    // idct_dc reads coeffs[0] only and writes the whole block: no clear needed
+    clear_rows = trafo_size;
+    if (!lc->cu.cu_transquant_bypass_flag && !transform_skip_flag &&
+        !(lc->cu.pred_mode == MODE_INTRA && c_idx == 0 && log2_trafo_size == 
2)) {
+        if (max_xy == 0)
+            clear_rows = 0;
+    }
+    if (clear_rows)
+        memset(coeffs, 0, clear_rows * trafo_size * sizeof(int16_t));
+
     for (i = num_last_subset; i >= 0; i--) {
         int n, m;
         int x_cg, y_cg, x_c, y_c, pos;
@@ -1480,19 +1498,10 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, 
const HEVCPPS *pps,
         } else if (lc->cu.pred_mode == MODE_INTRA && c_idx == 0 && 
log2_trafo_size == 2) {
             s->hevcdsp.transform_4x4_luma(coeffs);
         } else {
-            int max_xy = FFMAX(last_significant_coeff_x, 
last_significant_coeff_y);
             if (max_xy == 0)
                 s->hevcdsp.idct_dc[log2_trafo_size - 2](coeffs);
-            else {
-                int col_limit = last_significant_coeff_x + 
last_significant_coeff_y + 4;
-                if (max_xy < 4)
-                    col_limit = FFMIN(4, col_limit);
-                else if (max_xy < 8)
-                    col_limit = FFMIN(8, col_limit);
-                else if (max_xy < 12)
-                    col_limit = FFMIN(24, col_limit);
+            else
                 s->hevcdsp.idct[log2_trafo_size - 2](coeffs, col_limit);
-            }
         }
     }
     if (lc->tu.cross_pf) {

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to