1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

lavc/hevcdec: move HEVCContext.{horizontal,vertical}_bs to HEVCLayerContext

This commit is contained in:
Anton Khirnov 2024-06-05 09:01:16 +02:00
parent e8baf2fb97
commit 4f87ff7666
3 changed files with 22 additions and 21 deletions

View File

@ -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;
}
}
}

View File

@ -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));

View File

@ -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;