lavc/hevcdec: move HEVCContext.is_pcm to HEVCLayerContext

This commit is contained in:
Anton Khirnov 2024-06-05 09:01:16 +02:00
parent 0704559932
commit 463a85c5a1
3 changed files with 30 additions and 33 deletions

View File

@ -223,7 +223,7 @@ static void copy_CTB_to_hv(const HEVCContext *s, const HEVCSPS *sps,
copy_vert(s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 1) * h + y) << sh), src + ((width - 1) << sh), sh, height, 1 << sh, stride_src);
}
static void restore_tqb_pixels(const HEVCContext *s,
static void restore_tqb_pixels(const HEVCLayerContext *l,
const HEVCPPS *pps, const HEVCSPS *sps,
uint8_t *src1, const uint8_t *dst1,
ptrdiff_t stride_src, ptrdiff_t stride_dst,
@ -242,7 +242,7 @@ static void restore_tqb_pixels(const HEVCContext *s,
int len = (min_pu_size >> hshift) << sps->pixel_shift;
for (y = y_min; y < y_max; y++) {
for (x = x_min; x < x_max; x++) {
if (s->is_pcm[y * sps->min_pu_width + x]) {
if (l->is_pcm[y * sps->min_pu_width + x]) {
int n;
uint8_t *src = src1 +
(((y << sps->log2_min_pu_size) - y0) >> vshift) * stride_src +
@ -351,7 +351,7 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCLayerContext *l,
s->hevcdsp.sao_band_filter[tab](src, dst, stride_src, stride_dst,
sao->offset_val[c_idx], sao->band_position[c_idx],
width, height);
restore_tqb_pixels(s, pps, sps, src, dst, stride_src, stride_dst,
restore_tqb_pixels(l, pps, sps, src, dst, stride_src, stride_dst,
x, y, width, height, c_idx);
} else {
s->hevcdsp.sao_band_filter[tab](src, src, stride_src, stride_src,
@ -466,7 +466,7 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCLayerContext *l,
vert_edge,
horiz_edge,
diag_edge);
restore_tqb_pixels(s, pps, sps, src, dst, stride_src, stride_dst,
restore_tqb_pixels(l, pps, sps, src, dst, stride_src, stride_dst,
x, y, width, height, c_idx);
sao->type_idx[c_idx] = SAO_APPLIED;
break;
@ -559,10 +559,10 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext *
tc[1] = bs1 ? TC_CALC(qp, bs1) : 0;
src = &data[LUMA][y * linesize[LUMA] + (x << sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(sps, s->is_pcm, x - 1, y);
no_p[1] = get_pcm(sps, s->is_pcm, x - 1, y + 4);
no_q[0] = get_pcm(sps, s->is_pcm, x, y);
no_q[1] = get_pcm(sps, s->is_pcm, x, y + 4);
no_p[0] = get_pcm(sps, l->is_pcm, x - 1, y);
no_p[1] = get_pcm(sps, l->is_pcm, x - 1, y + 4);
no_q[0] = get_pcm(sps, l->is_pcm, x, y);
no_q[1] = get_pcm(sps, l->is_pcm, x, y + 4);
s->hevcdsp.hevc_v_loop_filter_luma_c(src, linesize[LUMA],
beta, tc, no_p, no_q);
} else
@ -590,10 +590,10 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext *
tc[1] = bs1 ? TC_CALC(qp, bs1) : 0;
src = &data[LUMA][y * linesize[LUMA] + (x << sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(sps, s->is_pcm, x, y - 1);
no_p[1] = get_pcm(sps, s->is_pcm, x + 4, y - 1);
no_q[0] = get_pcm(sps, s->is_pcm, x, y);
no_q[1] = get_pcm(sps, s->is_pcm, x + 4, y);
no_p[0] = get_pcm(sps, l->is_pcm, x, y - 1);
no_p[1] = get_pcm(sps, l->is_pcm, x + 4, y - 1);
no_q[0] = get_pcm(sps, l->is_pcm, x, y);
no_q[1] = get_pcm(sps, l->is_pcm, x + 4, y);
s->hevcdsp.hevc_h_loop_filter_luma_c(src, linesize[LUMA],
beta, tc, no_p, no_q);
} else
@ -624,10 +624,10 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext *
c_tc[1] = (bs1 == 2) ? chroma_tc(pps, sps, qp1, chroma, tc_offset) : 0;
src = &data[chroma][(y >> sps->vshift[chroma]) * linesize[chroma] + ((x >> sps->hshift[chroma]) << sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(sps, s->is_pcm, x - 1, y);
no_p[1] = get_pcm(sps, s->is_pcm, x - 1, y + (4 * v));
no_q[0] = get_pcm(sps, s->is_pcm, x, y);
no_q[1] = get_pcm(sps, s->is_pcm, x, y + (4 * v));
no_p[0] = get_pcm(sps, l->is_pcm, x - 1, y);
no_p[1] = get_pcm(sps, l->is_pcm, x - 1, y + (4 * v));
no_q[0] = get_pcm(sps, l->is_pcm, x, y);
no_q[1] = get_pcm(sps, l->is_pcm, x, y + (4 * v));
s->hevcdsp.hevc_v_loop_filter_chroma_c(src, linesize[chroma],
c_tc, no_p, no_q);
} else
@ -657,10 +657,10 @@ static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext *
c_tc[1] = bs1 == 2 ? chroma_tc(pps, sps, qp1, chroma, cur_tc_offset) : 0;
src = &data[chroma][(y >> sps->vshift[1]) * linesize[chroma] + ((x >> sps->hshift[1]) << sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(sps, s->is_pcm, x, y - 1);
no_p[1] = get_pcm(sps, s->is_pcm, x + (4 * h), y - 1);
no_q[0] = get_pcm(sps, s->is_pcm, x, y);
no_q[1] = get_pcm(sps, s->is_pcm, x + (4 * h), y);
no_p[0] = get_pcm(sps, l->is_pcm, x, y - 1);
no_p[1] = get_pcm(sps, l->is_pcm, x + (4 * h), y - 1);
no_q[0] = get_pcm(sps, l->is_pcm, x, y);
no_q[1] = get_pcm(sps, l->is_pcm, x + (4 * h), y);
s->hevcdsp.hevc_h_loop_filter_chroma_c(src, linesize[chroma],
c_tc, no_p, no_q);
} else

View File

@ -76,7 +76,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l)
av_freep(&l->tab_ipm);
av_freep(&l->cbf_luma);
av_freep(&s->is_pcm);
av_freep(&l->is_pcm);
av_freep(&s->qp_y_tab);
av_freep(&s->tab_slice_address);
@ -115,8 +115,8 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s
l->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height);
l->tab_ipm = av_mallocz(min_pu_size);
s->is_pcm = av_malloc_array(sps->min_pu_width + 1, sps->min_pu_height + 1);
if (!l->tab_ipm || !l->cbf_luma || !s->is_pcm)
l->is_pcm = av_malloc_array(sps->min_pu_width + 1, sps->min_pu_height + 1);
if (!l->tab_ipm || !l->cbf_luma || !l->is_pcm)
goto fail;
s->filter_slice_edges = av_mallocz(ctb_count);
@ -1300,7 +1300,7 @@ static int hls_transform_unit(HEVCLocalContext *lc,
return 0;
}
static void set_deblocking_bypass(const HEVCContext *s, const HEVCSPS *sps,
static void set_deblocking_bypass(uint8_t *is_pcm, const HEVCSPS *sps,
int x0, int y0, int log2_cb_size)
{
int cb_size = 1 << log2_cb_size;
@ -1313,7 +1313,7 @@ static void set_deblocking_bypass(const HEVCContext *s, const HEVCSPS *sps,
for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
s->is_pcm[i + j * min_pu_width] = 2;
is_pcm[i + j * min_pu_width] = 2;
}
static int hls_transform_tree(HEVCLocalContext *lc,
@ -1438,7 +1438,7 @@ do {
ff_hevc_deblocking_boundary_strengths(lc, l, pps, x0, y0, log2_trafo_size);
if (pps->transquant_bypass_enable_flag &&
lc->cu.cu_transquant_bypass_flag)
set_deblocking_bypass(s, sps, x0, y0, log2_trafo_size);
set_deblocking_bypass(l->is_pcm, sps, x0, y0, log2_trafo_size);
}
}
return 0;
@ -2232,7 +2232,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
if (pps->transquant_bypass_enable_flag) {
lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(lc);
if (lc->cu.cu_transquant_bypass_flag)
set_deblocking_bypass(s, sps, x0, y0, log2_cb_size);
set_deblocking_bypass(l->is_pcm, sps, x0, y0, log2_cb_size);
} else
lc->cu.cu_transquant_bypass_flag = 0;
@ -2286,7 +2286,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
intra_prediction_unit_default_value(lc, l, sps, x0, y0, log2_cb_size);
ret = hls_pcm_sample(lc, l, pps, x0, y0, log2_cb_size);
if (sps->pcm_loop_filter_disabled)
set_deblocking_bypass(s, sps, x0, y0, log2_cb_size);
set_deblocking_bypass(l->is_pcm, sps, x0, y0, log2_cb_size);
if (ret < 0)
return ret;
@ -2956,7 +2956,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(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(l->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));
if (IS_IDR(s))

View File

@ -454,6 +454,7 @@ typedef struct HEVCLayerContext {
// PU
uint8_t *cbf_luma; // cbf_luma of colocated TU
uint8_t *tab_ipm;
uint8_t *is_pcm;
} HEVCLayerContext;
typedef struct HEVCContext {
@ -511,10 +512,6 @@ typedef struct HEVCContext {
int32_t *tab_slice_address;
// PU
uint8_t *is_pcm;
// CTB-level flags affecting loop filter operation
uint8_t *filter_slice_edges;