[FFmpeg-devel] [PATCH 20/42] lavc/hevcdec: move HEVCContext.{horizontal, vertical}_bs to HEVCLayerContext
Anton Khirnov
anton at khirnov.net
Tue Aug 27 18:05:00 EEST 2024
---
libavcodec/hevc/filter.c | 24 ++++++++++++------------
libavcodec/hevc/hevcdec.c | 14 +++++++-------
libavcodec/hevc/hevcdec.h | 5 +++--
3 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c
index ad655a2b36..db82f2319f 100644
--- a/libavcodec/hevc/filter.c
+++ b/libavcodec/hevc/filter.c
@@ -549,8 +549,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext *
for (y = y0; y < y_end; y += 8) {
// vertical filtering luma
for (x = x0 ? x0 : 8; x < x_end; x += 8) {
- 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];
+ const int bs0 = l->vertical_bs[(x + y * l->bs_width) >> 2];
+ const int bs1 = l->vertical_bs[(x + (y + 4) * l->bs_width) >> 2];
if (bs0 || bs1) {
const int qp = (get_qPy(sps, l->qp_y_tab, x - 1, y) +
get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1;
@@ -578,8 +578,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext *
// horizontal filtering luma
for (x = x0 ? x0 - 8 : 0; x < x_end2; x += 8) {
- 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];
+ const int bs0 = l->horizontal_bs[( x + y * l->bs_width) >> 2];
+ const int bs1 = l->horizontal_bs[((x + 4) + y * l->bs_width) >> 2];
if (bs0 || bs1) {
const int qp = (get_qPy(sps, l->qp_y_tab, x, y - 1) +
get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1;
@@ -613,8 +613,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext *
// vertical filtering chroma
for (y = y0; y < y_end; y += (8 * v)) {
for (x = x0 ? x0 : 8 * h; x < x_end; x += (8 * h)) {
- const int bs0 = s->vertical_bs[(x + y * l->bs_width) >> 2];
- const int bs1 = s->vertical_bs[(x + (y + (4 * v)) * l->bs_width) >> 2];
+ const int bs0 = l->vertical_bs[(x + y * l->bs_width) >> 2];
+ const int bs1 = l->vertical_bs[(x + (y + (4 * v)) * l->bs_width) >> 2];
if ((bs0 == 2) || (bs1 == 2)) {
const int qp0 = (get_qPy(sps, l->qp_y_tab, x - 1, y) +
@@ -647,8 +647,8 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext *
if (x_end != sps->width)
x_end2 = x_end - 8 * h;
for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) {
- 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];
+ const int bs0 = l->horizontal_bs[( x + y * l->bs_width) >> 2];
+ const int bs1 = l->horizontal_bs[((x + 4 * h) + y * l->bs_width) >> 2];
if ((bs0 == 2) || (bs1 == 2)) {
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;
@@ -788,7 +788,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer
bs = 1;
else
bs = boundary_strength(s, curr, top, rpl_top);
- s->horizontal_bs[((x0 + i) + y0 * l->bs_width) >> 2] = bs;
+ l->horizontal_bs[((x0 + i) + y0 * l->bs_width) >> 2] = bs;
}
}
@@ -826,7 +826,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer
bs = 1;
else
bs = boundary_strength(s, curr, left, rpl_left);
- s->vertical_bs[(x0 + (y0 + i) * l->bs_width) >> 2] = bs;
+ l->vertical_bs[(x0 + (y0 + i) * l->bs_width) >> 2] = bs;
}
}
@@ -844,7 +844,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer
const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
bs = boundary_strength(s, curr, top, rpl);
- s->horizontal_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs;
+ l->horizontal_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs;
}
}
@@ -859,7 +859,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer
const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
bs = boundary_strength(s, curr, left, rpl);
- s->vertical_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs;
+ l->vertical_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs;
}
}
}
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index fd5da54fb1..2e31928e99 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -82,8 +82,8 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l)
av_freep(&l->tab_slice_address);
av_freep(&l->filter_slice_edges);
- av_freep(&s->horizontal_bs);
- av_freep(&s->vertical_bs);
+ av_freep(&l->horizontal_bs);
+ av_freep(&l->vertical_bs);
ff_refstruct_pool_uninit(&s->tab_mvf_pool);
ff_refstruct_pool_uninit(&s->rpl_tab_pool);
@@ -127,9 +127,9 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s
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);
- s->vertical_bs = av_calloc(l->bs_width, l->bs_height);
- if (!s->horizontal_bs || !s->vertical_bs)
+ l->horizontal_bs = av_calloc(l->bs_width, l->bs_height);
+ l->vertical_bs = av_calloc(l->bs_width, l->bs_height);
+ if (!l->horizontal_bs || !l->vertical_bs)
goto fail;
s->tab_mvf_pool = ff_refstruct_pool_alloc(min_pu_size * sizeof(MvField), 0);
@@ -2956,8 +2956,8 @@ static int hevc_frame_start(HEVCContext *s, HEVCLayerContext *l)
new_sequence = 1;
}
- memset(s->horizontal_bs, 0, l->bs_width * l->bs_height);
- memset(s->vertical_bs, 0, l->bs_width * l->bs_height);
+ memset(l->horizontal_bs, 0, l->bs_width * l->bs_height);
+ memset(l->vertical_bs, 0, l->bs_width * l->bs_height);
memset(l->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height);
memset(l->is_pcm, 0, (sps->min_pu_width + 1) * (sps->min_pu_height + 1));
memset(l->tab_slice_address, -1, pic_size_in_ctb * sizeof(*l->tab_slice_address));
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 6eb63c1b6c..426b7968b0 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -462,6 +462,9 @@ typedef struct HEVCLayerContext {
int32_t *tab_slice_address;
int8_t *qp_y_tab;
+
+ uint8_t *horizontal_bs;
+ uint8_t *vertical_bs;
} HEVCLayerContext;
typedef struct HEVCContext {
@@ -513,8 +516,6 @@ typedef struct HEVCContext {
VideoDSPContext vdsp;
BswapDSPContext bdsp;
H274FilmGrainDatabase h274db;
- uint8_t *horizontal_bs;
- uint8_t *vertical_bs;
/** used on BE to byteswap the lines for checksumming */
uint8_t *checksum_buf;
--
2.43.0
More information about the ffmpeg-devel
mailing list