History

lavc/hevcdec: move HEVCContext.skip_flag to HEVCLayerContext

Anton Khirnov committed 2 years ago

Commit 1ca4c2a1 parent ed2d25e3 files · +38 −35Browse files

Unified · Split

3 files
  1. libavcodec/hevc/cabac.c +4 −5
  2. libavcodec/hevc/hevcdec.c +29 −27
  3. libavcodec/hevc/hevcdec.h +5 −3
libavcodec/hevc/cabac.c+4−5
@@ -570,16 +570,15 @@ int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc) · 569 unmodified lines
570570 return GET_CABAC(CU_TRANSQUANT_BYPASS_FLAG_OFFSET);
571571 }
572572
573−int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0,
574− int x_cb, int y_cb, int min_cb_width)
573+int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag,
574+ int x0, int y0, int x_cb, int y_cb, int min_cb_width)
575575 {
576− const HEVCContext *const s = lc->parent;
577576 int inc = 0;
578577
579578 if (lc->ctb_left_flag || x0)
580− inc = !!SAMPLE_CTB(s->skip_flag, x_cb - 1, y_cb);
579+ inc = !!SAMPLE_CTB(skip_flag, x_cb - 1, y_cb);
581580 if (lc->ctb_up_flag || y0)
582− inc += !!SAMPLE_CTB(s->skip_flag, x_cb, y_cb - 1);
581+ inc += !!SAMPLE_CTB(skip_flag, x_cb, y_cb - 1);
583582
584583 return GET_CABAC(SKIP_FLAG_OFFSET + inc);
585584 }
libavcodec/hevc/hevcdec.c+29−27
@@ -71,7 +71,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) · 70 unmodified lines
7171 av_freep(&l->sao);
7272 av_freep(&l->deblock);
7373
74− av_freep(&s->skip_flag);
74+ av_freep(&l->skip_flag);
7575 av_freep(&s->tab_ct_depth);
7676
7777 av_freep(&s->tab_ipm);
@@ -108,9 +108,9 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s · 30 unmodified lines
108108 if (!l->sao || !l->deblock)
109109 goto fail;
110110
111− s->skip_flag = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
111+ l->skip_flag = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
112112 s->tab_ct_depth = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
113− if (!s->skip_flag || !s->tab_ct_depth)
113+ if (!l->skip_flag || !s->tab_ct_depth)
114114 goto fail;
115115
116116 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, · 1765 unmodified lines
18821882 }
18831883
18841884 static void hls_prediction_unit(HEVCLocalContext *lc,
1885+ const HEVCLayerContext *l,
18851886 const HEVCPPS *pps, const HEVCSPS *sps,
18861887 int x0, int y0, int nPbW, int nPbH,
18871888 int log2_cb_size, int partIdx, int idx)
@@ -1909,7 +1910,7 @@ static void hls_prediction_unit(HEVCLocalContext *lc, · 21 unmodified lines
19091910 int x_pu, y_pu;
19101911 int i, j;
19111912
1912− int skip_flag = SAMPLE_CTB(s->skip_flag, x_cb, y_cb);
1913+ int skip_flag = SAMPLE_CTB(l->skip_flag, x_cb, y_cb);
19131914
19141915 if (!skip_flag)
19151916 lc->pu.merge_flag = ff_hevc_merge_flag_decode(lc);
@@ -2221,7 +2222,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, · 305 unmodified lines
22212222 lc->cu.part_mode = PART_2Nx2N;
22222223 lc->cu.intra_split_flag = 0;
22232224
2224− SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0;
2225+ SAMPLE_CTB(l->skip_flag, x_cb, y_cb) = 0;
22252226 for (x = 0; x < 4; x++)
22262227 lc->pu.intra_pred_mode[x] = 1;
22272228 if (pps->transquant_bypass_enable_flag) {
@@ -2234,25 +2235,26 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, · 6 unmodified lines
22342235 if (s->sh.slice_type != HEVC_SLICE_I) {
22352236 const int x0b = av_zero_extend(x0, sps->log2_ctb_size);
22362237 const int y0b = av_zero_extend(y0, sps->log2_ctb_size);
2237− uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, x0b, y0b, x_cb, y_cb,
2238+ uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, l->skip_flag,
2239+ x0b, y0b, x_cb, y_cb,
22382240 min_cb_width);
22392241
22402242 x = y_cb * min_cb_width + x_cb;
22412243 for (y = 0; y < length; y++) {
2242− memset(&s->skip_flag[x], skip_flag, length);
2244+ memset(&l->skip_flag[x], skip_flag, length);
22432245 x += min_cb_width;
22442246 }
22452247 lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER;
22462248 } else {
22472249 x = y_cb * min_cb_width + x_cb;
22482250 for (y = 0; y < length; y++) {
2249− memset(&s->skip_flag[x], 0, length);
2251+ memset(&l->skip_flag[x], 0, length);
22502252 x += min_cb_width;
22512253 }
22522254 }
22532255
2254− if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) {
2255− hls_prediction_unit(lc, pps, sps,
2256+ if (SAMPLE_CTB(l->skip_flag, x_cb, y_cb)) {
2257+ hls_prediction_unit(lc, l, pps, sps,
22562258 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
22572259 intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
22582260
@@ -2291,53 +2293,53 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, · 32 unmodified lines
22912293 intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
22922294 switch (lc->cu.part_mode) {
22932295 case PART_2Nx2N:
2294− hls_prediction_unit(lc, pps, sps,
2296+ hls_prediction_unit(lc, l, pps, sps,
22952297 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
22962298 break;
22972299 case PART_2NxN:
2298− hls_prediction_unit(lc, pps, sps,
2300+ hls_prediction_unit(lc, l, pps, sps,
22992301 x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx);
2300− hls_prediction_unit(lc, pps, sps,
2302+ hls_prediction_unit(lc, l, pps, sps,
23012303 x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
23022304 break;
23032305 case PART_Nx2N:
2304− hls_prediction_unit(lc, pps, sps,
2306+ hls_prediction_unit(lc, l, pps, sps,
23052307 x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1);
2306− hls_prediction_unit(lc, pps, sps,
2308+ hls_prediction_unit(lc, l, pps, sps,
23072309 x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
23082310 break;
23092311 case PART_2NxnU:
2310− hls_prediction_unit(lc, pps, sps,
2312+ hls_prediction_unit(lc, l, pps, sps,
23112313 x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx);
2312− hls_prediction_unit(lc, pps, sps,
2314+ hls_prediction_unit(lc, l, pps, sps,
23132315 x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
23142316 break;
23152317 case PART_2NxnD:
2316− hls_prediction_unit(lc, pps, sps,
2318+ hls_prediction_unit(lc, l, pps, sps,
23172319 x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx);
2318− hls_prediction_unit(lc, pps, sps,
2320+ hls_prediction_unit(lc, l, pps, sps,
23192321 x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
23202322 break;
23212323 case PART_nLx2N:
2322− hls_prediction_unit(lc, pps, sps,
2324+ hls_prediction_unit(lc, l, pps, sps,
23232325 x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2);
2324− hls_prediction_unit(lc, pps, sps,
2326+ hls_prediction_unit(lc, l, pps, sps,
23252327 x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
23262328 break;
23272329 case PART_nRx2N:
2328− hls_prediction_unit(lc, pps, sps,
2330+ hls_prediction_unit(lc, l, pps, sps,
23292331 x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2);
2330− hls_prediction_unit(lc, pps, sps,
2332+ hls_prediction_unit(lc, l, pps, sps,
23312333 x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
23322334 break;
23332335 case PART_NxN:
2334− hls_prediction_unit(lc, pps, sps,
2336+ hls_prediction_unit(lc, l, pps, sps,
23352337 x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1);
2336− hls_prediction_unit(lc, pps, sps,
2338+ hls_prediction_unit(lc, l, pps, sps,
23372339 x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2338− hls_prediction_unit(lc, pps, sps,
2340+ hls_prediction_unit(lc, l, pps, sps,
23392341 x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2340− hls_prediction_unit(lc, pps, sps,
2342+ hls_prediction_unit(lc, l, pps, sps,
23412343 x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
23422344 break;
23432345 }
libavcodec/hevc/hevcdec.h+5−3
@@ -446,6 +446,9 @@ typedef struct HEVCLayerContext { · 445 unmodified lines
446446
447447 SAOParams *sao;
448448 DBParams *deblock;
449+
450+ // CU
451+ uint8_t *skip_flag;
449452 } HEVCLayerContext;
450453
451454 typedef struct HEVCContext {
@@ -504,7 +507,6 @@ typedef struct HEVCContext { · 52 unmodified lines
504507 int32_t *tab_slice_address;
505508
506509 // CU
507− uint8_t *skip_flag;
508510 uint8_t *tab_ct_depth;
509511 // PU
510512 uint8_t *tab_ipm;
@@ -579,8 +581,8 @@ int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc); · 68 unmodified lines
579581 int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc);
580582 int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc);
581583 int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc);
582−int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0,
583− int x_cb, int y_cb, int min_cb_width);
584+int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag,
585+ int x0, int y0, int x_cb, int y_cb, int min_cb_width);
584586 int ff_hevc_pred_mode_decode(HEVCLocalContext *lc);
585587 int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *sps,
586588 int ct_depth, int x0, int y0);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t