From 59de042cf68a582bca30258f6726058173033541 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 5 Jun 2024 09:01:16 +0200 Subject: [PATCH] lavc/hevcdec: move HEVCContext.cbf_luma to HEVCLayerContext --- libavcodec/hevc/filter.c | 8 ++++---- libavcodec/hevc/hevcdec.c | 10 +++++----- libavcodec/hevc/hevcdec.h | 4 +++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c index 4d5ef631d7..379c488d78 100644 --- a/libavcodec/hevc/filter.c +++ b/libavcodec/hevc/filter.c @@ -777,8 +777,8 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer int x_tu = (x0 + i) >> log2_min_tu_size; const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; - uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu]; - uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu]; + uint8_t top_cbf_luma = l->cbf_luma[yp_tu * min_tu_width + x_tu]; + uint8_t curr_cbf_luma = l->cbf_luma[yq_tu * min_tu_width + x_tu]; if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA) bs = 2; @@ -815,8 +815,8 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer int y_tu = (y0 + i) >> log2_min_tu_size; const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; - uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu]; - uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu]; + uint8_t left_cbf_luma = l->cbf_luma[y_tu * min_tu_width + xp_tu]; + uint8_t curr_cbf_luma = l->cbf_luma[y_tu * min_tu_width + xq_tu]; if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA) bs = 2; diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index 8f0f761ee5..1887a44e3e 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -75,7 +75,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) av_freep(&l->tab_ct_depth); av_freep(&s->tab_ipm); - av_freep(&s->cbf_luma); + av_freep(&l->cbf_luma); av_freep(&s->is_pcm); av_freep(&s->qp_y_tab); @@ -113,10 +113,10 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s if (!l->skip_flag || !l->tab_ct_depth) goto fail; - s->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height); + l->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height); s->tab_ipm = av_mallocz(min_pu_size); s->is_pcm = av_malloc_array(sps->min_pu_width + 1, sps->min_pu_height + 1); - if (!s->tab_ipm || !s->cbf_luma || !s->is_pcm) + if (!s->tab_ipm || !l->cbf_luma || !s->is_pcm) goto fail; s->filter_slice_edges = av_mallocz(ctb_count); @@ -1431,7 +1431,7 @@ do { for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) { int x_tu = (x0 + j) >> log2_min_tu_size; int y_tu = (y0 + i) >> log2_min_tu_size; - s->cbf_luma[y_tu * min_tu_width + x_tu] = 1; + l->cbf_luma[y_tu * min_tu_width + x_tu] = 1; } } if (!s->sh.disable_deblocking_filter_flag) { @@ -2951,7 +2951,7 @@ static int hevc_frame_start(HEVCContext *s, HEVCLayerContext *l) memset(s->horizontal_bs, 0, l->bs_width * l->bs_height); memset(s->vertical_bs, 0, l->bs_width * l->bs_height); - memset(s->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height); + memset(l->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height); memset(s->is_pcm, 0, (sps->min_pu_width + 1) * (sps->min_pu_height + 1)); memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address)); diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index 59c8587787..ccea7a46e1 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -450,6 +450,9 @@ typedef struct HEVCLayerContext { // CU uint8_t *skip_flag; uint8_t *tab_ct_depth; + + // PU + uint8_t *cbf_luma; // cbf_luma of colocated TU } HEVCLayerContext; typedef struct HEVCContext { @@ -510,7 +513,6 @@ typedef struct HEVCContext { // PU uint8_t *tab_ipm; - uint8_t *cbf_luma; // cbf_luma of colocated TU uint8_t *is_pcm; // CTB-level flags affecting loop filter operation