[FFmpeg-cvslog] lavc/hevcdec: move HEVCContext.skip_flag to HEVCLayerContext

Anton Khirnov git at videolan.org
Fri Sep 6 15:25:46 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Jun  5 09:01:16 2024 +0200| [1ca4c2a96d50ca1d1f17fd4e1b8d7614b9678d4d] | committer: Anton Khirnov

lavc/hevcdec: move HEVCContext.skip_flag to HEVCLayerContext

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1ca4c2a96d50ca1d1f17fd4e1b8d7614b9678d4d
---

 libavcodec/hevc/cabac.c   |  9 ++++----
 libavcodec/hevc/hevcdec.c | 56 ++++++++++++++++++++++++-----------------------
 libavcodec/hevc/hevcdec.h |  8 ++++---
 3 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c
index 33f8241bb3..12d477b2bd 100644
--- a/libavcodec/hevc/cabac.c
+++ b/libavcodec/hevc/cabac.c
@@ -570,16 +570,15 @@ int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc)
     return GET_CABAC(CU_TRANSQUANT_BYPASS_FLAG_OFFSET);
 }
 
-int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0,
-                             int x_cb, int y_cb, int min_cb_width)
+int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag,
+                             int x0, int y0, int x_cb, int y_cb, int min_cb_width)
 {
-    const HEVCContext *const s = lc->parent;
     int inc = 0;
 
     if (lc->ctb_left_flag || x0)
-        inc = !!SAMPLE_CTB(s->skip_flag, x_cb - 1, y_cb);
+        inc = !!SAMPLE_CTB(skip_flag, x_cb - 1, y_cb);
     if (lc->ctb_up_flag || y0)
-        inc += !!SAMPLE_CTB(s->skip_flag, x_cb, y_cb - 1);
+        inc += !!SAMPLE_CTB(skip_flag, x_cb, y_cb - 1);
 
     return GET_CABAC(SKIP_FLAG_OFFSET + inc);
 }
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index a20e559353..2e620d8c4a 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -71,7 +71,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l)
     av_freep(&l->sao);
     av_freep(&l->deblock);
 
-    av_freep(&s->skip_flag);
+    av_freep(&l->skip_flag);
     av_freep(&s->tab_ct_depth);
 
     av_freep(&s->tab_ipm);
@@ -108,9 +108,9 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s
     if (!l->sao || !l->deblock)
         goto fail;
 
-    s->skip_flag    = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
+    l->skip_flag    = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
     s->tab_ct_depth = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
-    if (!s->skip_flag || !s->tab_ct_depth)
+    if (!l->skip_flag || !s->tab_ct_depth)
         goto fail;
 
     s->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height);
@@ -1882,6 +1882,7 @@ static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc,
 }
 
 static void hls_prediction_unit(HEVCLocalContext *lc,
+                                const HEVCLayerContext *l,
                                 const HEVCPPS *pps, const HEVCSPS *sps,
                                 int x0, int y0, int nPbW, int nPbH,
                                 int log2_cb_size, int partIdx, int idx)
@@ -1909,7 +1910,7 @@ static void hls_prediction_unit(HEVCLocalContext *lc,
     int x_pu, y_pu;
     int i, j;
 
-    int skip_flag = SAMPLE_CTB(s->skip_flag, x_cb, y_cb);
+    int skip_flag = SAMPLE_CTB(l->skip_flag, x_cb, y_cb);
 
     if (!skip_flag)
         lc->pu.merge_flag = ff_hevc_merge_flag_decode(lc);
@@ -2221,7 +2222,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
     lc->cu.part_mode        = PART_2Nx2N;
     lc->cu.intra_split_flag = 0;
 
-    SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0;
+    SAMPLE_CTB(l->skip_flag, x_cb, y_cb) = 0;
     for (x = 0; x < 4; x++)
         lc->pu.intra_pred_mode[x] = 1;
     if (pps->transquant_bypass_enable_flag) {
@@ -2234,25 +2235,26 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
     if (s->sh.slice_type != HEVC_SLICE_I) {
         const int x0b = av_zero_extend(x0, sps->log2_ctb_size);
         const int y0b = av_zero_extend(y0, sps->log2_ctb_size);
-        uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, x0b, y0b, x_cb, y_cb,
+        uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, l->skip_flag,
+                                                     x0b, y0b, x_cb, y_cb,
                                                      min_cb_width);
 
         x = y_cb * min_cb_width + x_cb;
         for (y = 0; y < length; y++) {
-            memset(&s->skip_flag[x], skip_flag, length);
+            memset(&l->skip_flag[x], skip_flag, length);
             x += min_cb_width;
         }
         lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER;
     } else {
         x = y_cb * min_cb_width + x_cb;
         for (y = 0; y < length; y++) {
-            memset(&s->skip_flag[x], 0, length);
+            memset(&l->skip_flag[x], 0, length);
             x += min_cb_width;
         }
     }
 
-    if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) {
-        hls_prediction_unit(lc, pps, sps,
+    if (SAMPLE_CTB(l->skip_flag, x_cb, y_cb)) {
+        hls_prediction_unit(lc, l, pps, sps,
                             x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
         intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
 
@@ -2291,53 +2293,53 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
             intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
             switch (lc->cu.part_mode) {
             case PART_2Nx2N:
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
                 break;
             case PART_2NxN:
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0, y0,               cb_size, cb_size / 2, log2_cb_size, 0, idx);
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
                 break;
             case PART_Nx2N:
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0,               y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1);
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
                 break;
             case PART_2NxnU:
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0, y0,               cb_size, cb_size     / 4, log2_cb_size, 0, idx);
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
                 break;
             case PART_2NxnD:
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0, y0,                   cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx);
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0, y0 + cb_size * 3 / 4, cb_size, cb_size     / 4, log2_cb_size, 1, idx);
                 break;
             case PART_nLx2N:
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0,               y0, cb_size     / 4, cb_size, log2_cb_size, 0, idx - 2);
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
                 break;
             case PART_nRx2N:
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0,                   y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2);
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0 + cb_size * 3 / 4, y0, cb_size     / 4, cb_size, log2_cb_size, 1, idx - 2);
                 break;
             case PART_NxN:
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0,               y0,               cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1);
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0 + cb_size / 2, y0,               cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0,               y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
-                hls_prediction_unit(lc, pps, sps,
+                hls_prediction_unit(lc, l, pps, sps,
                                     x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
                 break;
             }
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 22b34924d5..1d8b6daf8b 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -446,6 +446,9 @@ typedef struct HEVCLayerContext {
 
     SAOParams              *sao;
     DBParams               *deblock;
+
+    //  CU
+    uint8_t                *skip_flag;
 } HEVCLayerContext;
 
 typedef struct HEVCContext {
@@ -504,7 +507,6 @@ typedef struct HEVCContext {
     int32_t *tab_slice_address;
 
     //  CU
-    uint8_t *skip_flag;
     uint8_t *tab_ct_depth;
     // PU
     uint8_t *tab_ipm;
@@ -579,8 +581,8 @@ int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc);
 int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc);
 int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc);
 int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc);
-int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0,
-                             int x_cb, int y_cb, int min_cb_width);
+int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag,
+                             int x0, int y0, int x_cb, int y_cb, int min_cb_width);
 int ff_hevc_pred_mode_decode(HEVCLocalContext *lc);
 int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *sps,
                                           int ct_depth, int x0, int y0);



More information about the ffmpeg-cvslog mailing list