[FFmpeg-devel] [PATCH 13/42] lavc/hevcdec: move HEVCContext.tab_ct_depth to HEVCLayerContext

Anton Khirnov anton at khirnov.net
Tue Aug 27 18:04:53 EEST 2024


---
 libavcodec/hevc/cabac.c   |  8 ++++----
 libavcodec/hevc/hevcdec.c | 11 ++++++-----
 libavcodec/hevc/hevcdec.h |  6 +++---
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c
index 12d477b2bd..892dd1c215 100644
--- a/libavcodec/hevc/cabac.c
+++ b/libavcodec/hevc/cabac.c
@@ -636,10 +636,10 @@ int ff_hevc_pred_mode_decode(HEVCLocalContext *lc)
     return GET_CABAC(PRED_MODE_FLAG_OFFSET);
 }
 
-int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *sps,
+int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, uint8_t *tab_ct_depth,
+                                          const HEVCSPS *sps,
                                           int ct_depth, int x0, int y0)
 {
-    const HEVCContext *const s = lc->parent;
     int inc = 0, depth_left = 0, depth_top = 0;
     int x0b  = av_zero_extend(x0, sps->log2_ctb_size);
     int y0b  = av_zero_extend(y0, sps->log2_ctb_size);
@@ -647,9 +647,9 @@ int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *s
     int y_cb = y0 >> sps->log2_min_cb_size;
 
     if (lc->ctb_left_flag || x0b)
-        depth_left = s->tab_ct_depth[(y_cb)     * sps->min_cb_width + x_cb - 1];
+        depth_left = tab_ct_depth[(y_cb)     * sps->min_cb_width + x_cb - 1];
     if (lc->ctb_up_flag || y0b)
-        depth_top  = s->tab_ct_depth[(y_cb - 1) * sps->min_cb_width + x_cb];
+        depth_top  = tab_ct_depth[(y_cb - 1) * sps->min_cb_width + x_cb];
 
     inc += (depth_left > ct_depth);
     inc += (depth_top  > ct_depth);
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 2e620d8c4a..8f0f761ee5 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -72,7 +72,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l)
     av_freep(&l->deblock);
 
     av_freep(&l->skip_flag);
-    av_freep(&s->tab_ct_depth);
+    av_freep(&l->tab_ct_depth);
 
     av_freep(&s->tab_ipm);
     av_freep(&s->cbf_luma);
@@ -109,8 +109,8 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s
         goto fail;
 
     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 (!l->skip_flag || !s->tab_ct_depth)
+    l->tab_ct_depth = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
+    if (!l->skip_flag || !l->tab_ct_depth)
         goto fail;
 
     s->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height);
@@ -2383,7 +2383,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
         lc->qPy_pred = lc->qp_y;
     }
 
-    set_ct_depth(sps, s->tab_ct_depth, x0, y0, log2_cb_size, lc->ct_depth);
+    set_ct_depth(sps, l->tab_ct_depth, x0, y0, log2_cb_size, lc->ct_depth);
 
     return 0;
 }
@@ -2403,7 +2403,8 @@ static int hls_coding_quadtree(HEVCLocalContext *lc,
     if (x0 + cb_size <= sps->width  &&
         y0 + cb_size <= sps->height &&
         log2_cb_size > sps->log2_min_cb_size) {
-        split_cu = ff_hevc_split_coding_unit_flag_decode(lc, sps, cb_depth, x0, y0);
+        split_cu = ff_hevc_split_coding_unit_flag_decode(lc, l->tab_ct_depth,
+                                                         sps, cb_depth, x0, y0);
     } else {
         split_cu = (log2_cb_size > sps->log2_min_cb_size);
     }
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 1d8b6daf8b..59c8587787 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -449,6 +449,7 @@ typedef struct HEVCLayerContext {
 
     //  CU
     uint8_t                *skip_flag;
+    uint8_t                *tab_ct_depth;
 } HEVCLayerContext;
 
 typedef struct HEVCContext {
@@ -506,8 +507,6 @@ typedef struct HEVCContext {
 
     int32_t *tab_slice_address;
 
-    //  CU
-    uint8_t *tab_ct_depth;
     // PU
     uint8_t *tab_ipm;
 
@@ -584,7 +583,8 @@ int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc);
 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 ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, uint8_t *tab_ct_depth,
+                                          const HEVCSPS *sps,
                                           int ct_depth, int x0, int y0);
 int ff_hevc_part_mode_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int log2_cb_size);
 int ff_hevc_pcm_flag_decode(HEVCLocalContext *lc);
-- 
2.43.0



More information about the ffmpeg-devel mailing list