diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-06-05 09:01:16 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-09-06 13:59:29 +0200 |
commit | e8baf2fb977b2827eaaf6b61cd6c1362c0925694 (patch) | |
tree | fbb2e9266505fba2144b8a2a8ea613dff2bfc3bd | |
parent | d5188adba82eaf979acf98fe2642de5c84a91fcb (diff) | |
download | ffmpeg-e8baf2fb977b2827eaaf6b61cd6c1362c0925694.tar.gz |
lavc/hevcdec: move HEVCContext.qp_y_tab to HEVCLayerContext
-rw-r--r-- | libavcodec/hevc/filter.c | 34 | ||||
-rw-r--r-- | libavcodec/hevc/hevcdec.c | 17 | ||||
-rw-r--r-- | libavcodec/hevc/hevcdec.h | 6 |
3 files changed, 31 insertions, 26 deletions
diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c index 14afb147b9..ad655a2b36 100644 --- a/libavcodec/hevc/filter.c +++ b/libavcodec/hevc/filter.c @@ -75,6 +75,7 @@ static int chroma_tc(const HEVCPPS *pps, const HEVCSPS *sps, } static int get_qPy_pred(HEVCLocalContext *lc, const HEVCContext *s, + const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int xBase, int yBase, int log2_cb_size) { @@ -104,13 +105,13 @@ static int get_qPy_pred(HEVCLocalContext *lc, const HEVCContext *s, if (availableA == 0) qPy_a = qPy_pred; else - qPy_a = s->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width]; + qPy_a = l->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width]; // qPy_b if (availableB == 0) qPy_b = qPy_pred; else - qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width]; + qPy_b = l->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width]; av_assert2(qPy_a >= -sps->qp_bd_offset && qPy_a < 52); av_assert2(qPy_b >= -sps->qp_bd_offset && qPy_b < 52); @@ -118,12 +119,13 @@ static int get_qPy_pred(HEVCLocalContext *lc, const HEVCContext *s, return (qPy_a + qPy_b + 1) >> 1; } -void ff_hevc_set_qPy(HEVCLocalContext *lc, const HEVCPPS *pps, +void ff_hevc_set_qPy(HEVCLocalContext *lc, + const HEVCLayerContext *l, const HEVCPPS *pps, int xBase, int yBase, int log2_cb_size) { const HEVCSPS *const sps = pps->sps; const HEVCContext *const s = lc->parent; - int qp_y = get_qPy_pred(lc, s, pps, sps, xBase, yBase, log2_cb_size); + int qp_y = get_qPy_pred(lc, s, l, pps, sps, xBase, yBase, log2_cb_size); if (lc->tu.cu_qp_delta != 0) { int off = sps->qp_bd_offset; @@ -550,8 +552,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext * const int bs0 = s->vertical_bs[(x + y * l->bs_width) >> 2]; const int bs1 = s->vertical_bs[(x + (y + 4) * l->bs_width) >> 2]; if (bs0 || bs1) { - const int qp = (get_qPy(sps, s->qp_y_tab, x - 1, y) + - get_qPy(sps, s->qp_y_tab, x, y) + 1) >> 1; + const int qp = (get_qPy(sps, l->qp_y_tab, x - 1, y) + + get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; @@ -579,8 +581,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext * const int bs0 = s->horizontal_bs[( x + y * l->bs_width) >> 2]; const int bs1 = s->horizontal_bs[((x + 4) + y * l->bs_width) >> 2]; if (bs0 || bs1) { - const int qp = (get_qPy(sps, s->qp_y_tab, x, y - 1) + - get_qPy(sps, s->qp_y_tab, x, y) + 1) >> 1; + const int qp = (get_qPy(sps, l->qp_y_tab, x, y - 1) + + get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset; beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset; @@ -615,10 +617,10 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext * const int bs1 = s->vertical_bs[(x + (y + (4 * v)) * l->bs_width) >> 2]; if ((bs0 == 2) || (bs1 == 2)) { - const int qp0 = (get_qPy(sps, s->qp_y_tab, x - 1, y) + - get_qPy(sps, s->qp_y_tab, x, y) + 1) >> 1; - const int qp1 = (get_qPy(sps, s->qp_y_tab, x - 1, y + (4 * v)) + - get_qPy(sps, s->qp_y_tab, x, y + (4 * v)) + 1) >> 1; + const int qp0 = (get_qPy(sps, l->qp_y_tab, x - 1, y) + + get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; + const int qp1 = (get_qPy(sps, l->qp_y_tab, x - 1, y + (4 * v)) + + get_qPy(sps, l->qp_y_tab, x, y + (4 * v)) + 1) >> 1; c_tc[0] = (bs0 == 2) ? chroma_tc(pps, sps, qp0, chroma, tc_offset) : 0; c_tc[1] = (bs1 == 2) ? chroma_tc(pps, sps, qp1, chroma, tc_offset) : 0; @@ -648,10 +650,10 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext * const int bs0 = s->horizontal_bs[( x + y * l->bs_width) >> 2]; const int bs1 = s->horizontal_bs[((x + 4 * h) + y * l->bs_width) >> 2]; if ((bs0 == 2) || (bs1 == 2)) { - const int qp0 = bs0 == 2 ? (get_qPy(sps, s->qp_y_tab, x, y - 1) + - get_qPy(sps, s->qp_y_tab, x, y) + 1) >> 1 : 0; - const int qp1 = bs1 == 2 ? (get_qPy(sps, s->qp_y_tab, x + (4 * h), y - 1) + - get_qPy(sps, s->qp_y_tab, x + (4 * h), y) + 1) >> 1 : 0; + const int qp0 = bs0 == 2 ? (get_qPy(sps, l->qp_y_tab, x, y - 1) + + get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1 : 0; + const int qp1 = bs1 == 2 ? (get_qPy(sps, l->qp_y_tab, x + (4 * h), y - 1) + + get_qPy(sps, l->qp_y_tab, x + (4 * h), y) + 1) >> 1 : 0; c_tc[0] = bs0 == 2 ? chroma_tc(pps, sps, qp0, chroma, tc_offset) : 0; c_tc[1] = bs1 == 2 ? chroma_tc(pps, sps, qp1, chroma, cur_tc_offset) : 0; diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index 3561a3a3ad..fd5da54fb1 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -78,7 +78,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) av_freep(&l->cbf_luma); av_freep(&l->is_pcm); - av_freep(&s->qp_y_tab); + av_freep(&l->qp_y_tab); av_freep(&l->tab_slice_address); av_freep(&l->filter_slice_edges); @@ -122,9 +122,9 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s l->filter_slice_edges = av_mallocz(ctb_count); l->tab_slice_address = av_malloc_array(pic_size_in_ctb, sizeof(*l->tab_slice_address)); - s->qp_y_tab = av_malloc_array(pic_size_in_ctb, - sizeof(*s->qp_y_tab)); - if (!s->qp_y_tab || !l->filter_slice_edges || !l->tab_slice_address) + l->qp_y_tab = av_malloc_array(pic_size_in_ctb, + sizeof(*l->qp_y_tab)); + if (!l->qp_y_tab || !l->filter_slice_edges || !l->tab_slice_address) goto fail; s->horizontal_bs = av_calloc(l->bs_width, l->bs_height); @@ -1090,6 +1090,7 @@ static int hls_cross_component_pred(HEVCLocalContext *lc, int idx) } static int hls_transform_unit(HEVCLocalContext *lc, + const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, @@ -1133,7 +1134,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, return AVERROR_INVALIDDATA; } - ff_hevc_set_qPy(lc, pps, cb_xBase, cb_yBase, log2_cb_size); + ff_hevc_set_qPy(lc, l, pps, cb_xBase, cb_yBase, log2_cb_size); } if (s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma && @@ -1418,7 +1419,7 @@ do { cbf_luma = ff_hevc_cbf_luma_decode(lc, trafo_depth); } - ret = hls_transform_unit(lc, pps, sps, + ret = hls_transform_unit(lc, l, pps, sps, x0, y0, xBase, yBase, cb_xBase, cb_yBase, log2_cb_size, log2_trafo_size, blk_idx, cbf_luma, cbf_cb, cbf_cr); @@ -2374,11 +2375,11 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, } if (pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) - ff_hevc_set_qPy(lc, pps, x0, y0, log2_cb_size); + ff_hevc_set_qPy(lc, l, pps, x0, y0, log2_cb_size); x = y_cb * min_cb_width + x_cb; for (y = 0; y < length; y++) { - memset(&s->qp_y_tab[x], lc->qp_y, length); + memset(&l->qp_y_tab[x], lc->qp_y, length); x += min_cb_width; } diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index b69b039655..6eb63c1b6c 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -460,6 +460,8 @@ typedef struct HEVCLayerContext { uint8_t *filter_slice_edges; int32_t *tab_slice_address; + + int8_t *qp_y_tab; } HEVCLayerContext; typedef struct HEVCContext { @@ -511,7 +513,6 @@ typedef struct HEVCContext { VideoDSPContext vdsp; BswapDSPContext bdsp; H274FilmGrainDatabase h274db; - int8_t *qp_y_tab; uint8_t *horizontal_bs; uint8_t *vertical_bs; @@ -658,7 +659,8 @@ void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCLayerContext *l, void ff_hevc_hls_filters(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x_ctb, int y_ctb, int ctb_size); -void ff_hevc_set_qPy(HEVCLocalContext *lc, const HEVCPPS *pps, +void ff_hevc_set_qPy(HEVCLocalContext *lc, + const HEVCLayerContext *l, const HEVCPPS *pps, int xBase, int yBase, int log2_cb_size); void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, |