lavc/hevcdec: move HEVCContext.skip_flag to HEVCLayerContext

release/7.1
Anton Khirnov 8 months ago
parent ed2d25e7f0
commit 1ca4c2a96d
  1. 9
      libavcodec/hevc/cabac.c
  2. 56
      libavcodec/hevc/hevcdec.c
  3. 8
      libavcodec/hevc/hevcdec.h

@ -570,16 +570,15 @@ int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc)
return GET_CABAC(CU_TRANSQUANT_BYPASS_FLAG_OFFSET); return GET_CABAC(CU_TRANSQUANT_BYPASS_FLAG_OFFSET);
} }
int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0, int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag,
int x_cb, int y_cb, int min_cb_width) int x0, int y0, int x_cb, int y_cb, int min_cb_width)
{ {
const HEVCContext *const s = lc->parent;
int inc = 0; int inc = 0;
if (lc->ctb_left_flag || x0) if (lc->ctb_left_flag || x0)
inc = !!SAMPLE_CTB(s->skip_flag, x_cb - 1, y_cb); inc = !!SAMPLE_CTB(skip_flag, x_cb - 1, y_cb);
if (lc->ctb_up_flag || y0) if (lc->ctb_up_flag || y0)
inc += !!SAMPLE_CTB(s->skip_flag, x_cb, y_cb - 1); inc += !!SAMPLE_CTB(skip_flag, x_cb, y_cb - 1);
return GET_CABAC(SKIP_FLAG_OFFSET + inc); return GET_CABAC(SKIP_FLAG_OFFSET + inc);
} }

@ -71,7 +71,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l)
av_freep(&l->sao); av_freep(&l->sao);
av_freep(&l->deblock); av_freep(&l->deblock);
av_freep(&s->skip_flag); av_freep(&l->skip_flag);
av_freep(&s->tab_ct_depth); av_freep(&s->tab_ct_depth);
av_freep(&s->tab_ipm); av_freep(&s->tab_ipm);
@ -108,9 +108,9 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s
if (!l->sao || !l->deblock) if (!l->sao || !l->deblock)
goto fail; goto fail;
s->skip_flag = av_malloc_array(sps->min_cb_height, sps->min_cb_width); l->skip_flag = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
s->tab_ct_depth = av_malloc_array(sps->min_cb_height, sps->min_cb_width); s->tab_ct_depth = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
if (!s->skip_flag || !s->tab_ct_depth) if (!l->skip_flag || !s->tab_ct_depth)
goto fail; goto fail;
s->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height); s->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height);
@ -1882,6 +1882,7 @@ static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc,
} }
static void hls_prediction_unit(HEVCLocalContext *lc, static void hls_prediction_unit(HEVCLocalContext *lc,
const HEVCLayerContext *l,
const HEVCPPS *pps, const HEVCSPS *sps, const HEVCPPS *pps, const HEVCSPS *sps,
int x0, int y0, int nPbW, int nPbH, int x0, int y0, int nPbW, int nPbH,
int log2_cb_size, int partIdx, int idx) int log2_cb_size, int partIdx, int idx)
@ -1909,7 +1910,7 @@ static void hls_prediction_unit(HEVCLocalContext *lc,
int x_pu, y_pu; int x_pu, y_pu;
int i, j; int i, j;
int skip_flag = SAMPLE_CTB(s->skip_flag, x_cb, y_cb); int skip_flag = SAMPLE_CTB(l->skip_flag, x_cb, y_cb);
if (!skip_flag) if (!skip_flag)
lc->pu.merge_flag = ff_hevc_merge_flag_decode(lc); lc->pu.merge_flag = ff_hevc_merge_flag_decode(lc);
@ -2221,7 +2222,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
lc->cu.part_mode = PART_2Nx2N; lc->cu.part_mode = PART_2Nx2N;
lc->cu.intra_split_flag = 0; lc->cu.intra_split_flag = 0;
SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; SAMPLE_CTB(l->skip_flag, x_cb, y_cb) = 0;
for (x = 0; x < 4; x++) for (x = 0; x < 4; x++)
lc->pu.intra_pred_mode[x] = 1; lc->pu.intra_pred_mode[x] = 1;
if (pps->transquant_bypass_enable_flag) { if (pps->transquant_bypass_enable_flag) {
@ -2234,25 +2235,26 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
if (s->sh.slice_type != HEVC_SLICE_I) { if (s->sh.slice_type != HEVC_SLICE_I) {
const int x0b = av_zero_extend(x0, sps->log2_ctb_size); const int x0b = av_zero_extend(x0, sps->log2_ctb_size);
const int y0b = av_zero_extend(y0, sps->log2_ctb_size); const int y0b = av_zero_extend(y0, sps->log2_ctb_size);
uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, x0b, y0b, x_cb, y_cb, uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, l->skip_flag,
x0b, y0b, x_cb, y_cb,
min_cb_width); min_cb_width);
x = y_cb * min_cb_width + x_cb; x = y_cb * min_cb_width + x_cb;
for (y = 0; y < length; y++) { for (y = 0; y < length; y++) {
memset(&s->skip_flag[x], skip_flag, length); memset(&l->skip_flag[x], skip_flag, length);
x += min_cb_width; x += min_cb_width;
} }
lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER; lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER;
} else { } else {
x = y_cb * min_cb_width + x_cb; x = y_cb * min_cb_width + x_cb;
for (y = 0; y < length; y++) { for (y = 0; y < length; y++) {
memset(&s->skip_flag[x], 0, length); memset(&l->skip_flag[x], 0, length);
x += min_cb_width; x += min_cb_width;
} }
} }
if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) { if (SAMPLE_CTB(l->skip_flag, x_cb, y_cb)) {
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size); intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
@ -2291,53 +2293,53 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size); intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
switch (lc->cu.part_mode) { switch (lc->cu.part_mode) {
case PART_2Nx2N: case PART_2Nx2N:
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
break; break;
case PART_2NxN: case PART_2NxN:
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx); x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx);
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx); x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
break; break;
case PART_Nx2N: case PART_Nx2N:
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1); x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1);
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1); x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
break; break;
case PART_2NxnU: case PART_2NxnU:
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx); x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx);
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx); x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
break; break;
case PART_2NxnD: case PART_2NxnD:
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx); x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx);
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx); x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
break; break;
case PART_nLx2N: case PART_nLx2N:
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2); x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2);
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2); x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
break; break;
case PART_nRx2N: case PART_nRx2N:
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2); x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2);
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2); x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
break; break;
case PART_NxN: case PART_NxN:
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1); x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1);
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1); x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1); x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
hls_prediction_unit(lc, pps, sps, hls_prediction_unit(lc, l, pps, sps,
x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1); x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
break; break;
} }

@ -446,6 +446,9 @@ typedef struct HEVCLayerContext {
SAOParams *sao; SAOParams *sao;
DBParams *deblock; DBParams *deblock;
// CU
uint8_t *skip_flag;
} HEVCLayerContext; } HEVCLayerContext;
typedef struct HEVCContext { typedef struct HEVCContext {
@ -504,7 +507,6 @@ typedef struct HEVCContext {
int32_t *tab_slice_address; int32_t *tab_slice_address;
// CU // CU
uint8_t *skip_flag;
uint8_t *tab_ct_depth; uint8_t *tab_ct_depth;
// PU // PU
uint8_t *tab_ipm; uint8_t *tab_ipm;
@ -579,8 +581,8 @@ int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc);
int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc); int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc);
int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc); int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc);
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc); int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc);
int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0, int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag,
int x_cb, int y_cb, int min_cb_width); int x0, int y0, int x_cb, int y_cb, int min_cb_width);
int ff_hevc_pred_mode_decode(HEVCLocalContext *lc); int ff_hevc_pred_mode_decode(HEVCLocalContext *lc);
int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *sps,
int ct_depth, int x0, int y0); int ct_depth, int x0, int y0);

Loading…
Cancel
Save