Skip to content

Commit 1e79ca7

Browse files
Support of the new profile rext_tiles
1 parent b109215 commit 1e79ca7

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

libavcodec/hevc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ else
10061006
sh->num_entry_point_offsets = get_ue_golomb_long(gb);
10071007
print_cabac("num_entry_point_offsets", sh->num_entry_point_offsets);
10081008
if(s->pps->entropy_coding_sync_enabled_flag) {
1009-
if(sh->num_entry_point_offsets > s->sps->ctb_height || sh->num_entry_point_offsets < 0) {
1009+
if(sh->num_entry_point_offsets < 0) {
10101010
av_log(s->avctx, AV_LOG_ERROR,
10111011
"The number of entries %d is higher than the number of CTB rows %d \n",
10121012
sh->num_entry_point_offsets,
@@ -2650,6 +2650,7 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
26502650
}
26512651

26522652
ctb_addr_ts++;
2653+
s->HEVClc->ctb_tile_rs++;
26532654
ff_hevc_save_states(s, ctb_addr_ts);
26542655
ff_hevc_hls_filters(s, x_ctb, y_ctb, ctb_size);
26552656
}
@@ -2939,7 +2940,9 @@ static int hls_slice_data(HEVCContext *s, const uint8_t *nal, int length)
29392940
ff_reset_entries(s->avctx);
29402941
}
29412942
s->data = nal;
2943+
s->HEVClc->ctb_tile_rs = 0;
29422944
for (i = 1; i < s->threads_number; i++) {
2945+
s->sList[i]->HEVClc->ctb_tile_rs = 0;
29432946
s->sList[i]->HEVClc->first_qp_group = 1;
29442947
s->sList[i]->HEVClc->qp_y = s->sList[0]->HEVClc->qp_y;
29452948
memcpy(s->sList[i], s, sizeof(HEVCContext));

libavcodec/hevc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ typedef struct HEVCPPS {
837837
int *ctb_addr_rs_to_ts; ///< CtbAddrRSToTS
838838
int *ctb_addr_ts_to_rs; ///< CtbAddrTSToRS
839839
int *tile_id; ///< TileId
840+
int *tile_width; ///< TileWidth
840841
int *tile_pos_rs; ///< TilePosRS
841842
int *min_tb_addr_zs; ///< MinTbAddrZS
842843
int *min_tb_addr_zs_tab;///< MinTbAddrZS
@@ -1093,6 +1094,7 @@ typedef struct HEVCLocalContext {
10931094
uint8_t slice_or_tiles_left_boundary;
10941095
uint8_t slice_or_tiles_up_boundary;
10951096

1097+
int ctb_tile_rs;
10961098

10971099
} HEVCLocalContext;
10981100

libavcodec/hevc_cabac.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,9 @@ static const uint8_t diag_scan8x8_inv[8][8] = {
500500
void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts)
501501
{
502502
if (s->pps->entropy_coding_sync_enabled_flag &&
503-
(ctb_addr_ts % s->sps->ctb_width == 2 ||
504-
(s->sps->ctb_width == 2 &&
505-
ctb_addr_ts % s->sps->ctb_width == 0))) {
503+
(s->HEVClc->ctb_tile_rs % s->pps->tile_width[ctb_addr_ts-1] == 2 ||
504+
(s->pps->tile_width[ctb_addr_ts-1] == 2 &&
505+
s->HEVClc->ctb_tile_rs % s->pps->tile_width[ctb_addr_ts-1] == 0))) {
506506
memcpy(s->cabac_state, s->HEVClc->cabac_state, HEVC_CONTEXTS);
507507
}
508508
}
@@ -562,8 +562,8 @@ void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
562562

563563
if (!s->sh.first_slice_in_pic_flag &&
564564
s->pps->entropy_coding_sync_enabled_flag) {
565-
if (ctb_addr_ts % s->sps->ctb_width == 0) {
566-
if (s->sps->ctb_width == 1)
565+
if (s->HEVClc->ctb_tile_rs % s->pps->tile_width[ctb_addr_ts] == 0) {
566+
if (s->pps->tile_width[ctb_addr_ts] == 1)
567567
cabac_init_state(s);
568568
else if (s->sh.dependent_slice_segment_flag == 1)
569569
load_states(s);
@@ -572,24 +572,31 @@ void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
572572
} else {
573573
if (s->pps->tiles_enabled_flag &&
574574
s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1]) {
575+
576+
s->HEVClc->ctb_tile_rs = 0;
575577
if (s->threads_number == 1)
576578
cabac_reinit(s->HEVClc);
577579
else
578580
cabac_init_decoder(s);
579581
cabac_init_state(s);
580582
}
581583
if (s->pps->entropy_coding_sync_enabled_flag) {
582-
if (ctb_addr_ts % s->sps->ctb_width == 0) {
583-
get_cabac_terminate(&s->HEVClc->cc);
584-
if (s->threads_number == 1)
585-
cabac_reinit(s->HEVClc);
586-
else
587-
cabac_init_decoder(s);
584+
if (s->HEVClc->ctb_tile_rs % s->pps->tile_width[ctb_addr_ts] == 0) {
585+
if (!s->pps->tiles_enabled_flag ||
586+
(s->pps->tile_id[ctb_addr_ts] == s->pps->tile_id[ctb_addr_ts - 1])) {
587+
get_cabac_terminate(&s->HEVClc->cc);
588588

589-
if (s->sps->ctb_width == 1)
590-
cabac_init_state(s);
591-
else
592-
load_states(s);
589+
if (s->threads_number == 1)
590+
cabac_reinit(s->HEVClc);
591+
else
592+
cabac_init_decoder(s);
593+
594+
595+
if (s->pps->tile_width[ctb_addr_ts] == 1)
596+
cabac_init_state(s);
597+
else
598+
load_states(s);
599+
}
593600
}
594601
}
595602
}

libavcodec/hevc_ps.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,7 @@ static void hevc_pps_free(void *opaque, uint8_t *data)
20692069
av_freep(&pps->ctb_addr_ts_to_rs);
20702070
av_freep(&pps->tile_pos_rs);
20712071
av_freep(&pps->tile_id);
2072+
av_freep(&pps->tile_width);
20722073
av_freep(&pps->min_tb_addr_zs_tab);
20732074

20742075
av_freep(&pps);
@@ -2472,8 +2473,9 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
24722473
pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_ts_to_rs));
24732474
pps->tile_id = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_id));
24742475
pps->min_tb_addr_zs_tab = av_malloc_array((sps->tb_mask+2) * (sps->tb_mask+2), sizeof(*pps->min_tb_addr_zs_tab));
2476+
pps->tile_width = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_width));
24752477
if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||
2476-
!pps->tile_id || !pps->min_tb_addr_zs_tab) {
2478+
!pps->tile_id || !pps->min_tb_addr_zs_tab || !pps->tile_width) {
24772479
ret = AVERROR(ENOMEM);
24782480
goto err;
24792481
}
@@ -2514,8 +2516,10 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
25142516
for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++)
25152517
for (i = 0; i < pps->num_tile_columns; i++, tile_id++)
25162518
for (y = row_bd[j]; y < row_bd[j + 1]; y++)
2517-
for (x = col_bd[i]; x < col_bd[i + 1]; x++)
2519+
for (x = col_bd[i]; x < col_bd[i + 1]; x++) {
25182520
pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = tile_id;
2521+
pps->tile_width[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = pps->column_width[tile_id % pps->num_tile_columns];
2522+
}
25192523

25202524
pps->tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps->tile_pos_rs));
25212525
if (!pps->tile_pos_rs) {

0 commit comments

Comments
 (0)