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
570 return GET_CABAC(CU_TRANSQUANT_BYPASS_FLAG_OFFSET);570 return GET_CABAC(CU_TRANSQUANT_BYPASS_FLAG_OFFSET);
571}571}
572 572
573int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0,573int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag,
574 int x_cb, int y_cb, int min_cb_width)574 int x0, int y0, int x_cb, int y_cb, int min_cb_width)
575{575{
576 const HEVCContext *const s = lc->parent;
577 int inc = 0;576 int inc = 0;
578 577
579 if (lc->ctb_left_flag || x0)578 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);
581 if (lc->ctb_up_flag || y0)580 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);
583 582
584 return GET_CABAC(SKIP_FLAG_OFFSET + inc);583 return GET_CABAC(SKIP_FLAG_OFFSET + inc);
585}584}
libavcodec/hevc/hevcdec.c+29−27
@@ -71,7 +71,7 @@ static void pic_arrays_free(HEVCContext *s, HEVCLayerContext *l) · 70 unmodified lines
71 av_freep(&l->sao);71 av_freep(&l->sao);
72 av_freep(&l->deblock);72 av_freep(&l->deblock);
73 73
74 av_freep(&s->skip_flag);74 av_freep(&l->skip_flag);
75 av_freep(&s->tab_ct_depth);75 av_freep(&s->tab_ct_depth);
76 76
77 av_freep(&s->tab_ipm);77 av_freep(&s->tab_ipm);
@@ -108,9 +108,9 @@ static int pic_arrays_init(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *s · 30 unmodified lines
108 if (!l->sao || !l->deblock)108 if (!l->sao || !l->deblock)
109 goto fail;109 goto fail;
110 110
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);
112 s->tab_ct_depth = av_malloc_array(sps->min_cb_height, sps->min_cb_width);112 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)
114 goto fail;114 goto fail;
115 115
116 s->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height);116 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
1882}1882}
1883 1883
1884static void hls_prediction_unit(HEVCLocalContext *lc,1884static void hls_prediction_unit(HEVCLocalContext *lc,
1885 const HEVCLayerContext *l,
1885 const HEVCPPS *pps, const HEVCSPS *sps,1886 const HEVCPPS *pps, const HEVCSPS *sps,
1886 int x0, int y0, int nPbW, int nPbH,1887 int x0, int y0, int nPbW, int nPbH,
1887 int log2_cb_size, int partIdx, int idx)1888 int log2_cb_size, int partIdx, int idx)
@@ -1909,7 +1910,7 @@ static void hls_prediction_unit(HEVCLocalContext *lc, · 21 unmodified lines
1909 int x_pu, y_pu;1910 int x_pu, y_pu;
1910 int i, j;1911 int i, j;
1911 1912
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);
1913 1914
1914 if (!skip_flag)1915 if (!skip_flag)
1915 lc->pu.merge_flag = ff_hevc_merge_flag_decode(lc);1916 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
2221 lc->cu.part_mode = PART_2Nx2N;2222 lc->cu.part_mode = PART_2Nx2N;
2222 lc->cu.intra_split_flag = 0;2223 lc->cu.intra_split_flag = 0;
2223 2224
2224 SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0;2225 SAMPLE_CTB(l->skip_flag, x_cb, y_cb) = 0;
2225 for (x = 0; x < 4; x++)2226 for (x = 0; x < 4; x++)
2226 lc->pu.intra_pred_mode[x] = 1;2227 lc->pu.intra_pred_mode[x] = 1;
2227 if (pps->transquant_bypass_enable_flag) {2228 if (pps->transquant_bypass_enable_flag) {
@@ -2234,25 +2235,26 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, · 6 unmodified lines
2234 if (s->sh.slice_type != HEVC_SLICE_I) {2235 if (s->sh.slice_type != HEVC_SLICE_I) {
2235 const int x0b = av_zero_extend(x0, sps->log2_ctb_size);2236 const int x0b = av_zero_extend(x0, sps->log2_ctb_size);
2236 const int y0b = av_zero_extend(y0, sps->log2_ctb_size);2237 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,
2238 min_cb_width);2240 min_cb_width);
2239 2241
2240 x = y_cb * min_cb_width + x_cb;2242 x = y_cb * min_cb_width + x_cb;
2241 for (y = 0; y < length; y++) {2243 for (y = 0; y < length; y++) {
2242 memset(&s->skip_flag[x], skip_flag, length);2244 memset(&l->skip_flag[x], skip_flag, length);
2243 x += min_cb_width;2245 x += min_cb_width;
2244 }2246 }
2245 lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER;2247 lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER;
2246 } else {2248 } else {
2247 x = y_cb * min_cb_width + x_cb;2249 x = y_cb * min_cb_width + x_cb;
2248 for (y = 0; y < length; y++) {2250 for (y = 0; y < length; y++) {
2249 memset(&s->skip_flag[x], 0, length);2251 memset(&l->skip_flag[x], 0, length);
2250 x += min_cb_width;2252 x += min_cb_width;
2251 }2253 }
2252 }2254 }
2253 2255
2254 if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) {2256 if (SAMPLE_CTB(l->skip_flag, x_cb, y_cb)) {
2255 hls_prediction_unit(lc, pps, sps,2257 hls_prediction_unit(lc, l, pps, sps,
2256 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);2258 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2257 intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);2259 intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
2258 2260
@@ -2291,53 +2293,53 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, · 32 unmodified lines
2291 intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);2293 intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
2292 switch (lc->cu.part_mode) {2294 switch (lc->cu.part_mode) {
2293 case PART_2Nx2N:2295 case PART_2Nx2N:
2294 hls_prediction_unit(lc, pps, sps,2296 hls_prediction_unit(lc, l, pps, sps,
2295 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);2297 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2296 break;2298 break;
2297 case PART_2NxN:2299 case PART_2NxN:
2298 hls_prediction_unit(lc, pps, sps,2300 hls_prediction_unit(lc, l, pps, sps,
2299 x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx);2301 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,
2301 x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);2303 x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
2302 break;2304 break;
2303 case PART_Nx2N:2305 case PART_Nx2N:
2304 hls_prediction_unit(lc, pps, sps,2306 hls_prediction_unit(lc, l, pps, sps,
2305 x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1);2307 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,
2307 x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);2309 x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2308 break;2310 break;
2309 case PART_2NxnU:2311 case PART_2NxnU:
2310 hls_prediction_unit(lc, pps, sps,2312 hls_prediction_unit(lc, l, pps, sps,
2311 x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx);2313 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,
2313 x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);2315 x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2314 break;2316 break;
2315 case PART_2NxnD:2317 case PART_2NxnD:
2316 hls_prediction_unit(lc, pps, sps,2318 hls_prediction_unit(lc, l, pps, sps,
2317 x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx);2319 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,
2319 x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);2321 x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2320 break;2322 break;
2321 case PART_nLx2N:2323 case PART_nLx2N:
2322 hls_prediction_unit(lc, pps, sps,2324 hls_prediction_unit(lc, l, pps, sps,
2323 x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2);2325 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,
2325 x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);2327 x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2326 break;2328 break;
2327 case PART_nRx2N:2329 case PART_nRx2N:
2328 hls_prediction_unit(lc, pps, sps,2330 hls_prediction_unit(lc, l, pps, sps,
2329 x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2);2331 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,
2331 x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);2333 x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2332 break;2334 break;
2333 case PART_NxN:2335 case PART_NxN:
2334 hls_prediction_unit(lc, pps, sps,2336 hls_prediction_unit(lc, l, pps, sps,
2335 x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1);2337 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,
2337 x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);2339 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,
2339 x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);2341 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,
2341 x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);2343 x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2342 break;2344 break;
2343 }2345 }
libavcodec/hevc/hevcdec.h+5−3
@@ -446,6 +446,9 @@ typedef struct HEVCLayerContext { · 445 unmodified lines
446 446
447 SAOParams *sao;447 SAOParams *sao;
448 DBParams *deblock;448 DBParams *deblock;
449
450 // CU
451 uint8_t *skip_flag;
449} HEVCLayerContext;452} HEVCLayerContext;
450 453
451typedef struct HEVCContext {454typedef struct HEVCContext {
@@ -504,7 +507,6 @@ typedef struct HEVCContext { · 52 unmodified lines
504 int32_t *tab_slice_address;507 int32_t *tab_slice_address;
505 508
506 // CU509 // CU
507 uint8_t *skip_flag;
508 uint8_t *tab_ct_depth;510 uint8_t *tab_ct_depth;
509 // PU511 // PU
510 uint8_t *tab_ipm;512 uint8_t *tab_ipm;
@@ -579,8 +581,8 @@ int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc); · 68 unmodified lines
579int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc);581int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc);
580int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc);582int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc);
581int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc);583int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc);
582int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0,584int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag,
583 int x_cb, int y_cb, int min_cb_width);585 int x0, int y0, int x_cb, int y_cb, int min_cb_width);
584int ff_hevc_pred_mode_decode(HEVCLocalContext *lc);586int ff_hevc_pred_mode_decode(HEVCLocalContext *lc);
585int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *sps,587int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *sps,
586 int ct_depth, int x0, int y0);588 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