41 switch (
sps->bit_depth) {
62 "The following bit-depths are currently specified: 8, 10, 12 bits, "
63 "chroma_format_idc is %d, depth is %d\n",
64 r->sps_chroma_format_idc,
sps->bit_depth);
72 sps->hshift[0] =
sps->vshift[0] = 0;
73 sps->hshift[2] =
sps->hshift[1] =
desc->log2_chroma_w;
74 sps->vshift[2] =
sps->vshift[1] =
desc->log2_chroma_h;
76 sps->pixel_shift =
sps->bit_depth > 8;
85 sps->bit_depth =
r->sps_bitdepth_minus8 + 8;
86 sps->qp_bd_offset = 6 * (
sps->bit_depth - 8);
87 sps->log2_transform_range =
88 r->sps_extended_precision_flag ?
FFMAX(15,
FFMIN(20,
sps->bit_depth + 6)) : 15;
95 const int num_qp_tables =
r->sps_same_qp_table_for_chroma_flag ?
96 1 : (
r->sps_joint_cbcr_enabled_flag ? 3 : 2);
98 for (
int i = 0;
i < num_qp_tables;
i++) {
99 int num_points_in_qp_table;
102 int off =
sps->qp_bd_offset;
104 num_points_in_qp_table =
r->sps_num_points_in_qp_table_minus1[
i] + 1;
106 qp_out[0] = qp_in[0] =
r->sps_qp_table_start_minus26[
i] + 26;
107 for (
int j = 0; j < num_points_in_qp_table; j++ ) {
108 const uint8_t delta_qp_out = (
r->sps_delta_qp_in_val_minus1[
i][j] ^
r->sps_delta_qp_diff_val[
i][j]);
109 delta_qp_in[j] =
r->sps_delta_qp_in_val_minus1[
i][j] + 1;
112 if (qp_in[j] + delta_qp_in[j] > 63 || qp_out[j] + delta_qp_out > 63)
114 qp_in[j+1] = qp_in[j] + delta_qp_in[j];
115 qp_out[j+1] = qp_out[j] + delta_qp_out;
117 sps->chroma_qp_table[
i][qp_in[0] + off] = qp_out[0];
118 for (
int k = qp_in[0] - 1 + off; k >= 0; k--)
119 sps->chroma_qp_table[
i][k] =
av_clip(
sps->chroma_qp_table[
i][k+1]-1, -off, 63);
121 for (
int j = 0; j < num_points_in_qp_table; j++) {
122 int sh = delta_qp_in[j] >> 1;
123 for (
int k = qp_in[j] + 1 + off, m = 1; k <= qp_in[j+1] + off; k++, m++) {
124 sps->chroma_qp_table[
i][k] =
sps->chroma_qp_table[
i][qp_in[j] + off] +
125 ((qp_out[j+1] - qp_out[j]) * m + sh) / delta_qp_in[j];
128 for (
int k = qp_in[num_points_in_qp_table] + 1 + off; k <= 63 + off; k++)
129 sps->chroma_qp_table[
i][k] =
av_clip(
sps->chroma_qp_table[
i][k-1] + 1, -
sps->qp_bd_offset, 63);
131 if (
r->sps_same_qp_table_for_chroma_flag) {
132 memcpy(&
sps->chroma_qp_table[1], &
sps->chroma_qp_table[0],
sizeof(
sps->chroma_qp_table[0]));
133 memcpy(&
sps->chroma_qp_table[2], &
sps->chroma_qp_table[0],
sizeof(
sps->chroma_qp_table[0]));
141 sps->max_pic_order_cnt_lsb = 1 << (
sps->r->sps_log2_max_pic_order_cnt_lsb_minus4 + 4);
148 sps->max_num_merge_cand = 6 -
r->sps_six_minus_max_num_merge_cand;
149 sps->max_num_ibc_merge_cand = 6 -
r->sps_six_minus_max_num_ibc_merge_cand;
151 if (
sps->r->sps_gpm_enabled_flag) {
152 sps->max_num_gpm_merge_cand = 2;
153 if (
sps->max_num_merge_cand >= 3)
154 sps->max_num_gpm_merge_cand =
sps->max_num_merge_cand -
r->sps_max_num_merge_cand_minus_max_num_gpm_cand;
157 sps->log2_parallel_merge_level =
r->sps_log2_parallel_merge_level_minus2 + 2;
164 sps->ctb_log2_size_y =
r->sps_log2_ctu_size_minus5 + 5;
165 sps->ctb_size_y = 1 <<
sps->ctb_log2_size_y;
166 sps->min_cb_log2_size_y =
r->sps_log2_min_luma_coding_block_size_minus2 + 2;
167 sps->min_cb_size_y = 1 <<
sps->min_cb_log2_size_y;
168 sps->max_tb_size_y = 1 << (
r->sps_max_luma_transform_size_64_flag ? 6 : 5);
169 sps->max_ts_size = 1 << (
r->sps_log2_transform_skip_max_size_minus2 + 2);
176 if (
r->sps_ladf_enabled_flag) {
177 sps->num_ladf_intervals =
r->sps_num_ladf_intervals_minus2 + 2;
178 sps->ladf_interval_lower_bound[0] = 0;
179 for (
int i = 0;
i <
sps->num_ladf_intervals - 1;
i++) {
180 sps->ladf_interval_lower_bound[
i + 1] =
181 sps->ladf_interval_lower_bound[
i] +
r->sps_ladf_delta_threshold_minus1[
i] + 1;
186#define EXTENDED_SAR 255
227 c->has_b_frames = !!
r->sps_dpb_params.dpb_max_num_reorder_pics[
r->sps_max_sublayers_minus1];
228 if (
r->sps_vui_parameters_present_flag)
244 if (
r->sps_chroma_format_idc != 0) {
290 s->seq_decode = (
s->seq_decode + 1) & 0xff;
294 if (old_sps->
r == rsps || !memcmp(old_sps->
r, rsps,
sizeof(*old_sps->
r))) {
314 pps->chroma_qp_offset[
CB - 1] =
pps->r->pps_cb_qp_offset;
315 pps->chroma_qp_offset[
CR - 1] =
pps->r->pps_cr_qp_offset;
316 pps->chroma_qp_offset[
JCBCR - 1]=
pps->r->pps_joint_cbcr_qp_offset_value;
317 for (
int i = 0;
i < 6;
i++) {
318 pps->chroma_qp_offset_list[
i][
CB - 1] =
pps->r->pps_cb_qp_offset_list[
i];
319 pps->chroma_qp_offset_list[
i][
CR - 1] =
pps->r->pps_cr_qp_offset_list[
i];
320 pps->chroma_qp_offset_list[
i][
JCBCR - 1]=
pps->r->pps_joint_cbcr_qp_offset_list[
i];
328 pps->width =
r->pps_pic_width_in_luma_samples;
329 pps->height =
r->pps_pic_height_in_luma_samples;
333 pps->ctb_count =
pps->ctb_width *
pps->ctb_height;
335 pps->min_cb_width =
pps->width >>
sps->min_cb_log2_size_y;
336 pps->min_cb_height =
pps->height >>
sps->min_cb_log2_size_y;
357 if (!
pps->col_bd || !
pps->row_bd || !
pps->ctb_to_col_bd || !
pps->ctb_to_row_bd)
360 for (
int i = 0, j = 0;
i <
r->num_tile_columns;
i++) {
362 j +=
r->col_width_val[
i];
363 for (
int k =
pps->col_bd[
i]; k < j; k++)
364 pps->ctb_to_col_bd[k] =
pps->col_bd[
i];
366 pps->col_bd[
r->num_tile_columns] =
pps->ctb_to_col_bd[
pps->ctb_width] =
pps->ctb_width;
368 for (
int i = 0, j = 0;
i <
r->num_tile_rows;
i++) {
370 j +=
r->row_height_val[
i];
371 for (
int k =
pps->row_bd[
i]; k < j; k++)
372 pps->ctb_to_row_bd[k] =
pps->row_bd[
i];
374 pps->row_bd[
r->num_tile_rows] =
pps->ctb_to_row_bd[
pps->ctb_height] =
pps->ctb_height;
382 if (
r->pps_tile_idx_delta_present_flag) {
383 tile_idx +=
r->pps_tile_idx_delta_val[
i];
385 tile_idx +=
r->pps_slice_width_in_tiles_minus1[
i] + 1;
386 if (tile_idx %
r->num_tile_columns == 0)
387 tile_idx += (
r->pps_slice_height_in_tiles_minus1[
i]) *
r->num_tile_columns;
394 *tile_x = tile_idx %
pps->r->num_tile_columns;
395 *tile_y = tile_idx /
pps->r->num_tile_columns;
398static void ctu_xy(
int *rx,
int *ry,
const int tile_x,
const int tile_y,
const VVCPPS *
pps)
400 *rx =
pps->col_bd[tile_x];
401 *ry =
pps->row_bd[tile_y];
406 return pps->ctb_width * ry + rx;
410 const int w,
const int h)
413 for (
int y = 0; y <
h; y++) {
414 for (
int x = 0; x <
w; x++) {
415 if (*off >=
pps->ctb_count)
417 pps->ctb_addr_in_slice[*off] =
ctu_rs(rx + x, ry + y,
pps);
426 pps->num_ctus_in_slice[0] = 0;
427 for (
int j = 0; j <
pps->r->num_tile_rows; j++) {
428 for (
int i = 0;
i <
pps->r->num_tile_columns;
i++) {
430 pps->col_bd[
i],
pps->row_bd[j],
431 pps->r->col_width_val[
i],
pps->r->row_height_val[j]);
434 pps->num_ctus_in_slice[0] += ret;
441static void subpic_tiles(
int *tile_x,
int *tile_y,
int *tile_x_end,
int *tile_y_end,
444 const int rx =
sps->r->sps_subpic_ctu_top_left_x[
i];
445 const int ry =
sps->r->sps_subpic_ctu_top_left_y[
i];
447 *tile_x = *tile_y = 0;
449 while (
pps->col_bd[*tile_x] < rx)
452 while (
pps->row_bd[*tile_y] < ry)
455 *tile_x_end = (*tile_x);
456 *tile_y_end = (*tile_y);
458 while (
pps->col_bd[*tile_x_end] < rx +
sps->r->sps_subpic_width_minus1[
i] + 1)
461 while (
pps->row_bd[*tile_y_end] < ry +
sps->r->sps_subpic_height_minus1[
i] + 1)
468 sps->r->sps_subpic_ctu_top_left_x[
i],
sps->r->sps_subpic_ctu_top_left_y[
i],
469 sps->r->sps_subpic_width_minus1[
i] + 1,
sps->r->sps_subpic_height_minus1[
i] + 1);
473 pps->num_ctus_in_slice[
i] = ret;
478 const int i,
int *off)
480 for (
int ty = tile_y; ty < y_end; ty++) {
481 for (
int tx = tile_x; tx < x_end; tx++) {
483 pps->col_bd[tx],
pps->row_bd[ty],
484 pps->r->col_width_val[tx],
pps->r->row_height_val[ty]);
488 pps->num_ctus_in_slice[
i] += ret;
496 int tx, ty, x_end, y_end;
498 pps->slice_start_offset[
i] = *off;
499 pps->num_ctus_in_slice[
i] = 0;
502 if (ty + 1 == y_end &&
sps->r->sps_subpic_height_minus1[
i] + 1 <
pps->r->row_height_val[ty])
512 if (!
sps->r->sps_subpic_info_present_flag) {
517 for (
int i = 0;
i <
pps->r->pps_num_slices_in_pic_minus1 + 1;
i++) {
529 int rx, ry, ctu_y_end, tile_x, tile_y;
533 ctu_y_end = ry +
r->row_height_val[tile_y];
534 while (ry < ctu_y_end) {
536 pps->slice_start_offset[
i] = *off;
538 r->col_width_val[tile_x],
r->slice_height_in_ctus[
i]);
541 pps->num_ctus_in_slice[
i] = ret;
542 ry +=
r->slice_height_in_ctus[
i++];
551 int rx, ry, tile_x, tile_y;
554 pps->slice_start_offset[
i] = *off;
555 pps->num_ctus_in_slice[
i] = 0;
556 for (
int ty = tile_y; ty <= tile_y +
r->pps_slice_height_in_tiles_minus1[
i]; ty++) {
557 for (
int tx = tile_x; tx <= tile_x +
r->pps_slice_width_in_tiles_minus1[
i]; tx++) {
559 const int idx = ty *
r->num_tile_columns + tx;
560 if (tile_in_slice[idx])
562 tile_in_slice[idx] =
true;
565 r->col_width_val[tx],
r->row_height_val[ty]);
568 pps->num_ctus_in_slice[
i] += ret;
579 int tile_idx = 0, off = 0, ret;
581 if (
r->pps_single_slice_per_subpic_flag) {
585 for (
int i = 0;
i <
r->pps_num_slices_in_pic_minus1 + 1;
i++) {
586 if (!
r->pps_slice_width_in_tiles_minus1[
i] &&
587 !
r->pps_slice_height_in_tiles_minus1[
i]) {
588 if (tile_in_slice[tile_idx])
590 tile_in_slice[tile_idx] =
true;
603 for (
int i = 0;
i <
r->num_tiles_in_pic;
i++) {
604 if (!tile_in_slice[
i])
616 for (
int tile_y = 0; tile_y <
r->num_tile_rows; tile_y++) {
617 for (
int tile_x = 0; tile_x <
r->num_tile_columns; tile_x++) {
620 ret =
pps_add_ctus(
pps, &off, rx, ry,
r->col_width_val[tile_x],
r->row_height_val[tile_y]);
634 if (!
pps->ctb_addr_in_slice)
637 if (
pps->r->pps_rect_slice_flag)
651 if (
r->pps_ref_wraparound_enabled_flag)
652 pps->ref_wraparound_offset = (
pps->width /
sps->min_cb_size_y) -
r->pps_pic_width_minus_wraparound_offset;
665 pps->subpic_x[
i] = 0;
666 pps->subpic_y[
i] = 0;
667 pps->subpic_width[
i] =
pps->width;
668 pps->subpic_height[
i] =
pps->height;
736 if (old_pps && old_pps->
r == rpps)
779#define WEIGHT_TABLE(x) \
780 w->nb_weights[L##x] = r->num_weights_l##x; \
781 for (int i = 0; i < w->nb_weights[L##x]; i++) { \
782 w->weight_flag[L##x][LUMA][i] = r->luma_weight_l##x##_flag[i]; \
783 w->weight_flag[L##x][CHROMA][i] = r->chroma_weight_l##x##_flag[i]; \
784 w->weight[L##x][LUMA][i] = denom[LUMA] + r->delta_luma_weight_l##x[i]; \
785 w->offset[L##x][LUMA][i] = r->luma_offset_l##x[i]; \
786 for (int j = CB; j <= CR; j++) { \
787 w->weight[L##x][j][i] = denom[CHROMA] + r->delta_chroma_weight_l##x[i][j - 1]; \
788 w->offset[L##x][j][i] = 128 + r->delta_chroma_offset_l##x[i][j - 1]; \
789 w->offset[L##x][j][i] -= (128 * w->weight[L##x][j][i]) >> w->log2_denom[CHROMA]; \
790 w->offset[L##x][j][i] = av_clip_intp2(w->offset[L##x][j][i], 7); \
798 w->log2_denom[
LUMA] =
r->luma_log2_weight_denom;
799 w->log2_denom[
CHROMA] =
w->log2_denom[
LUMA] +
r->delta_chroma_log2_weight_denom;
809 const int max_poc_lsb = 1 << (
sps->sps_log2_max_pic_order_cnt_lsb_minus4 + 4);
810 const int prev_poc_lsb = poc_tid0 % max_poc_lsb;
811 const int prev_poc_msb = poc_tid0 - prev_poc_lsb;
812 const int poc_lsb =
ph->ph_pic_order_cnt_lsb;
815 if (
ph->ph_poc_msb_cycle_present_flag) {
816 poc_msb =
ph->ph_poc_msb_cycle_val * max_poc_lsb;
817 }
else if (is_clvss) {
820 if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
821 poc_msb = prev_poc_msb + max_poc_lsb;
822 else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 2)
823 poc_msb = prev_poc_msb - max_poc_lsb;
825 poc_msb = prev_poc_msb;
828 return poc_msb + poc_lsb;
832 uint16_t *pivot1, uint16_t *pivot2, uint16_t *
scale_coeff,
const int idx,
const int max)
834 const int lut_sample =
846 const int off = 1 << (
shift - 1);
851 int i, delta_crs, sum_cw = 0;
861 memset(cw, 0,
sizeof(cw));
873 input_pivot[
i] =
i * org_cw;
881 inv_scale_coeff[
i] = 0;
884 const int cw_plus_d = cw[
i] + delta_crs;
885 if (cw_plus_d < (org_cw >> 3) || cw_plus_d > ((org_cw << 3) - 1))
887 inv_scale_coeff[
i] = org_cw * (1 << 11) / cw[
i];
913 inv_scale_coeff,
i,
max);
926 if (
sps->sps_affine_enabled_flag)
927 return 5 -
sps->sps_five_minus_max_num_subblock_merge_cand;
928 return sps->sps_sbtmvp_enabled_flag &&
ph->ph_temporal_mvp_enabled_flag;
931static int ph_vb_pos(uint16_t *vbs, uint8_t *num_vbs,
const uint16_t *pos_minus_1,
const uint8_t num_pos, uint16_t
max,
const int ctb_size_y)
934 for (
int i = 0;
i < num_pos;
i++) {
935 if (pos_minus_1[
i] >
max)
938 vbs[
i] = (pos_minus_1[
i] + 1) << 3;
941 if (
i && vbs[
i] < vbs[
i - 1] + ctb_size_y)
949#define VBF(f) (sps->sps_virtual_boundaries_present_flag ? sps->sps_##f : ph->r->ph_##f)
950#define VBFS(c, d) VBF(virtual_boundary_pos_##c##_minus1), VBF(num_##d##_virtual_boundaries)
954 const int ctb_size_y = 1 << (
sps->sps_log2_ctu_size_minus5 + 5);
957 if (!
sps->sps_virtual_boundaries_enabled_flag)
960 ret =
ph_vb_pos(
ph->vb_pos_x, &
ph->num_ver_vbs,
VBFS(x, ver),
pps->pps_pic_width_in_luma_samples, ctb_size_y);
964 ret =
ph_vb_pos(
ph->vb_pos_y, &
ph->num_hor_vbs,
VBFS(y, hor),
pps->pps_pic_height_in_luma_samples, ctb_size_y);
978 if (
pps->pps_wp_info_in_ph_flag)
989 const int poc_tid0,
const int is_clvss)
1026 if (
ph->ph_explicit_scaling_list_enabled_flag)
1029 if (
ph->ph_lmcs_enabled_flag) {
1044 s->no_output_before_recovery_flag = 1;
1046 s->no_output_before_recovery_flag =
s->last_eos;
1054 const uint32_t recovery_poc_cnt =
ph->r->ph_recovery_poc_cnt;
1058 if (recovery_poc < INT_MIN || recovery_poc > INT_MAX) {
1059 av_log(
s->avctx,
AV_LOG_ERROR,
"Recovery point POC out of range: %"PRId64
".\n", recovery_poc);
1063 if (recovery_poc_cnt > max_recovery_poc_cnt) {
1066 "ph_recovery_poc_cnt out of range: %"PRIu32
1067 ", expected [0, %"PRIu32
"].\n", recovery_poc_cnt, max_recovery_poc_cnt);
1072 if (
s->no_output_before_recovery_flag)
1073 s->gdr_recovery_point_poc = recovery_poc;
1076 if (
s->no_output_before_recovery_flag) {
1131 const uint8_t *
abs,
const uint8_t *sign,
const int size)
1133 for (
int i = 0;
i <
size;
i++)
1138 const uint8_t *mapped_abs,
const uint8_t *sign)
1141 int c = mapped_abs[
i];
1143 c = (1 - 2 * sign[
i]) * (1 << (
c - 1));
1150 if (!
aps->alf_luma_filter_signal_flag)
1154 const int ref =
aps->alf_luma_coeff_delta_idx[
i];
1155 const uint8_t *
abs =
aps->alf_luma_coeff_abs[
ref];
1156 const uint8_t *sign =
aps->alf_luma_coeff_sign[
ref];
1166 if (!
aps->alf_chroma_filter_signal_flag)
1171 const uint8_t *
abs =
aps->alf_chroma_coeff_abs[
i];
1172 const uint8_t *sign =
aps->alf_chroma_coeff_sign[
i];
1183 {
aps->alf_cc_cb_mapped_coeff_abs,
aps->alf_cc_cr_mapped_coeff_abs };
1185 {
aps->alf_cc_cb_coeff_sign,
aps->alf_cc_cr_coeff_sign };
1186 const int signaled[] = {
aps->alf_cc_cb_filter_signal_flag,
aps->alf_cc_cr_filter_signal_flag};
1191 for (
int idx = 0; idx < 2; idx++) {
1192 if (signaled[idx]) {
1240 for (
int id = 0;
id <
SL_MAX_ID;
id++) {
1242 const int log2_size =
av_log2(matrix_size);
1243 const int list_size = matrix_size * matrix_size;
1245 const uint8_t *
pred;
1250 if (!
aps->scaling_list_copy_mode_flag[
id]) {
1256 for (
int i = 0;
i < list_size;
i++) {
1261 next_coef +=
aps->scaling_list_delta_coef[
id][
i];
1269 if (!
aps->scaling_list_copy_mode_flag[
id] && !
aps->scaling_list_pred_mode_flag[
id]) {
1271 }
else if (!
aps->scaling_list_pred_id_delta[
id]) {
1274 const int ref_id =
id -
aps->scaling_list_pred_id_delta[
id];
1285 if (!
aps->scaling_list_copy_mode_flag[
id] && !
aps->scaling_list_pred_mode_flag[
id])
1287 else if (!
aps->scaling_list_pred_id_delta[
id])
1291 for (
int i = 0;
i < list_size;
i++) {
1294 const int off = y * matrix_size + x;
1321 switch (
aps->aps_params_type) {
1349 if (!alf_aps_chroma)
1373 if (
pps->r->pps_rect_slice_flag) {
1374 int pic_level_slice_idx = slice_address;
1376 pic_level_slice_idx +=
pps->r->num_slices_in_subpic[j];
1380 int tile_x = slice_address %
pps->r->num_tile_columns;
1381 int tile_y = slice_address /
pps->r->num_tile_columns;
1382 const int slice_start_ctb =
pps->row_bd[tile_y] *
pps->ctb_width +
pps->col_bd[tile_x] *
pps->r->row_height_val[tile_y];
1388 tile_x = tile_idx %
pps->r->num_tile_columns;
1389 tile_y = tile_idx /
pps->r->num_tile_columns;
1402 const int init_qp =
pps->pps_init_qp_minus26 + 26;
1404 if (!
pps->pps_qp_delta_info_in_ph_flag)
1414 if (!
pps->pps_wp_info_in_ph_flag &&
1415 ((
pps->pps_weighted_pred_flag &&
IS_P(rsh)) ||
1416 (
pps->pps_weighted_bipred_flag &&
IS_B(rsh))))
1424 if (!
r->sh_deblocking_filter_disabled_flag) {
1436 const int min_cb_log2_size_y =
sps->sps_log2_min_luma_coding_block_size_minus2 + 2;
1437 int min_qt_log2_size_y[2];
1440 min_qt_log2_size_y[
LUMA] = (min_cb_log2_size_y +
ph->ph_log2_diff_min_qt_min_cb_intra_slice_luma);
1441 min_qt_log2_size_y[
CHROMA] = (min_cb_log2_size_y +
ph->ph_log2_diff_min_qt_min_cb_intra_slice_chroma);
1443 sh->
max_bt_size[
LUMA] = 1 << (min_qt_log2_size_y[
LUMA] +
ph->ph_log2_diff_max_bt_min_qt_intra_slice_luma);
1446 sh->
max_tt_size[
LUMA] = 1 << (min_qt_log2_size_y[
LUMA] +
ph->ph_log2_diff_max_tt_min_qt_intra_slice_luma);
1456 min_qt_log2_size_y[
i] = (min_cb_log2_size_y +
ph->ph_log2_diff_min_qt_min_cb_inter_slice);
1457 sh->
max_bt_size[
i] = 1 << (min_qt_log2_size_y[
i] +
ph->ph_log2_diff_max_bt_min_qt_inter_slice);
1458 sh->
max_tt_size[
i] = 1 << (min_qt_log2_size_y[
i] +
ph->ph_log2_diff_max_tt_min_qt_inter_slice);
1472 if (
sps->sps_entry_point_offsets_present_flag) {
1478 if (
pps->ctb_to_row_bd[ctb_addr_y] !=
pps->ctb_to_row_bd[pre_ctb_addr_y] ||
1479 pps->ctb_to_col_bd[ctb_addr_x] !=
pps->ctb_to_col_bd[pre_ctb_addr_x] ||
1480 (ctb_addr_y != pre_ctb_addr_y &&
sps->sps_entropy_coding_sync_enabled_flag)) {
1519 if (!fps->
sps || !fps->
pps)
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
#define i(width, name, range_min, range_max)
static int FUNC scaling_list(CodedBitstreamContext *ctx, RWContext *rw, H264RawScalingList *current, int size_of_scaling_list)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
static int FUNC aps(CodedBitstreamContext *ctx, RWContext *rw, H266RawAPS *current, int prefix)
#define AV_CEIL_RSHIFT(a, b)
static const uint16_t fc[]
#define MIN_TU_LOG2
MinTbLog2SizeY.
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const AVRational ff_h2645_pixel_aspect[]
static void pps_free(AVRefStructOpaque unused, void *obj)
static av_always_inline int scale_coeff(const TransformBlock *tb, int coeff, const int scale, const int scale_m, const int log2_transform_range)
static int shift(int a, int b)
@ VVC_MAX_POINTS_IN_QP_TABLE
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
const char * av_color_space_name(enum AVColorSpace space)
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV420P10
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GRAY12
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_YUV444P10
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
void av_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
static void * av_refstruct_allocz(size_t size)
Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL)
static void * av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj))
A wrapper around av_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
#define FF_ARRAY_ELEMS(a)
static const float pred[4]
main external API structure.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).
Coded bitstream unit structure.
void * content_ref
If content is reference counted, a RefStruct reference backing content.
uint8_t lmcs_delta_abs_crs
uint8_t lmcs_delta_sign_crs_flag
uint8_t lmcs_delta_sign_cw_flag[16]
uint16_t lmcs_delta_abs_cw[16]
uint8_t lmcs_delta_max_bin_idx
uint8_t pps_seq_parameter_set_id
uint8_t pps_pic_parameter_set_id
uint8_t sps_subpic_treated_as_pic_flag[VVC_MAX_SLICES]
uint16_t sps_subpic_ctu_top_left_x[VVC_MAX_SLICES]
uint16_t sps_subpic_ctu_top_left_y[VVC_MAX_SLICES]
uint16_t sps_subpic_height_minus1[VVC_MAX_SLICES]
uint16_t sps_subpic_width_minus1[VVC_MAX_SLICES]
uint16_t sps_num_subpics_minus1
uint8_t sps_seq_parameter_set_id
uint8_t sps_log2_ctu_size_minus5
uint8_t sps_ccalf_enabled_flag
void * ph_ref
RefStruct reference backing referred-to PH above.
H266RawPictureHeader * ph
H266RawPPS * pps
RefStruct reference to referred-to PPS.
H266RawSPS * sps
RefStruct reference to referred-to SPS.
uint8_t vui_aspect_ratio_idc
uint8_t vui_full_range_flag
uint8_t vui_aspect_ratio_info_present_flag
uint8_t vui_transfer_characteristics
uint8_t vui_colour_primaries
uint8_t vui_matrix_coeffs
uint8_t vui_colour_description_present_flag
void * ref
RefStruct reference, backing slice data.
int16_t cc_coeff[2][ALF_NUM_FILTERS_CC][ALF_NUM_COEFF_CC]
uint8_t num_chroma_filters
uint8_t chroma_clip_idx[ALF_NUM_FILTERS_CHROMA][ALF_NUM_COEFF_CHROMA]
int16_t chroma_coeff[ALF_NUM_FILTERS_CHROMA][ALF_NUM_COEFF_CHROMA]
uint8_t luma_clip_idx[ALF_NUM_FILTERS_LUMA][ALF_NUM_COEFF_LUMA]
int16_t luma_coeff[ALF_NUM_FILTERS_LUMA][ALF_NUM_COEFF_LUMA]
uint8_t num_cc_filters[2]
alf_cc_cb_filters_signalled_minus1 + 1, alf_cc_cr_filters_signalled_minus1 + 1
const VVCScalingList * sl
RefStruct reference.
const VVCALF * alf_list[VVC_MAX_ALF_COUNT]
RefStruct reference.
const VVCSPS * sps
RefStruct reference.
const VVCPPS * pps
RefStruct reference.
uint16_t chroma_scale_coeff[LMCS_MAX_BIN_SIZE]
uint16_t pivot[LMCS_MAX_BIN_SIZE+1]
uint16_t u16[LMCS_MAX_LUT_SIZE]
for high bit-depth
union VVCLMCS::@035044274352311120333102212047116003126167015367 fwd_lut
uint8_t u8[LMCS_MAX_LUT_SIZE]
union VVCLMCS::@035044274352311120333102212047116003126167015367 inv_lut
void * rref
RefStruct reference, backing ph above.
const H266RawPictureHeader * r
const H266RawPPS * r
RefStruct reference.
const VVCSPS * sps_list[VVC_MAX_SPS_COUNT]
RefStruct reference.
const VVCALF * alf_list[VVC_MAX_ALF_COUNT]
RefStruct reference.
const VVCPPS * pps_list[VVC_MAX_PPS_COUNT]
RefStruct reference.
const H266RawAPS * lmcs_list[VVC_MAX_LMCS_COUNT]
RefStruct reference.
const VVCScalingList * scaling_list[VVC_MAX_SL_COUNT]
RefStruct reference.
uint8_t max_tt_size[2]
MaxTtSizeY, MaxTtSizeC.
uint8_t min_qt_size[2]
MinQtSizeY, MinQtSizeC.
uint8_t cu_qp_delta_subdiv
CuQpDeltaSubdiv.
const H266RawSliceHeader * r
RefStruct reference.
uint32_t entry_point_start_ctu[VVC_MAX_ENTRY_POINTS]
entry point start in ctu_addr
const uint32_t * ctb_addr_in_curr_slice
CtbAddrInCurrSlice.
int8_t slice_qp_y
SliceQpY.
uint32_t num_ctus_in_curr_slice
NumCtusInCurrSlice.
uint8_t max_mtt_depth[2]
MaxMttDepthY, MaxMttDepthC.
uint8_t max_bt_size[2]
MaxBtSizeY, MaxBtSizeC.
uint8_t cu_chroma_qp_offset_subdiv
CuChromaQpOffsetSubdiv.
const H266RawSPS * r
RefStruct reference.
uint32_t max_pic_order_cnt_lsb
MaxPicOrderCntLsb.
uint8_t scaling_matrix_rec[SL_MAX_ID][SL_MAX_MATRIX_SIZE *SL_MAX_MATRIX_SIZE]
ScalingMatrixRec.
uint8_t scaling_matrix_dc_rec[SL_MAX_ID - SL_START_16x16]
ScalingMatrixDcRec[refId − 14].
static int ref[MAX_W *MAX_W]
RefStruct is an API for creating reference-counted objects with minimal overhead.
static const double coeff[2][5]
const uint8_t ff_vvc_scaling_pred_16[8 *8]
const uint8_t ff_vvc_scaling_pred_8[8 *8]
const int ff_vvc_scaling_list0[8 *8]
const uint8_t ff_vvc_diag_scan_y[5][5][16 *16]
const uint8_t ff_vvc_diag_scan_x[5][5][16 *16]
static int ctu_rs(const int rx, const int ry, const VVCPPS *pps)
static int ph_vb_pos(uint16_t *vbs, uint8_t *num_vbs, const uint16_t *pos_minus_1, const uint8_t num_pos, uint16_t max, const int ctb_size_y)
static const VVCSPS * sps_alloc(const H266RawSPS *rsps, AVCodecContext *c)
static void alf_chroma(VVCALF *alf, const H266RawAPS *aps)
static void sh_partition_constraints(VVCSH *sh, const H266RawSPS *sps, const H266RawPictureHeader *ph)
static void alf_derive(VVCALF *alf, const H266RawAPS *aps)
static void sh_deblock_offsets(VVCSH *sh)
static int pps_single_slice_per_subpic(VVCPPS *pps, const VVCSPS *sps, int *off)
static int ph_max_num_subblock_merge_cand(const H266RawSPS *sps, const H266RawPictureHeader *ph)
int ff_vvc_decode_aps(VVCParamSets *ps, const CodedBitstreamUnit *unit)
static int sps_bit_depth(VVCSPS *sps, void *log_ctx)
static int pps_add_ctus(VVCPPS *pps, int *off, const int rx, const int ry, const int w, const int h)
static void alf_free(AVRefStructOpaque unused, void *obj)
static void sh_inter(VVCSH *sh, const H266RawSPS *sps, const H266RawPPS *pps)
static int pps_multi_tiles_slice(VVCPPS *pps, const int tile_idx, const int i, int *off, bool *tile_in_slice)
static const VVCPPS * pps_alloc(const H266RawPPS *rpps, const VVCSPS *sps)
int ff_vvc_decode_frame_ps(struct VVCFrameContext *fc, struct VVCContext *s)
void ff_vvc_ps_uninit(VVCParamSets *ps)
static void sps_partition_constraints(VVCSPS *sps)
static int decode_frame_ps(VVCFrameParamSets *fps, const VVCParamSets *ps, const SliceContext *sc, const int poc_tid0, const int is_clvss, const VVCContext *s)
static int ph_vb(VVCPH *ph, const H266RawSPS *sps, const H266RawPPS *pps)
static int sh_derive(VVCSH *sh, const VVCFrameParamSets *fps)
static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS *rlmcs, const H266RawSPS *sps)
static void alf_cc(VVCALF *alf, const H266RawAPS *aps)
static int pps_single_slice_picture(VVCPPS *pps, int *off)
static int sh_slice_address(VVCSH *sh, const H266RawSPS *sps, const VVCPPS *pps)
static void alf_coeff(int16_t *coeff, const uint8_t *abs, const uint8_t *sign, const int size)
void ff_vvc_frame_ps_free(VVCFrameParamSets *fps)
static int pps_subpic_slice(VVCPPS *pps, const VVCSPS *sps, const int i, int *off)
static int sps_derive(VVCSPS *sps, AVCodecContext *c)
static int decode_recovery_poc(VVCContext *s, const VVCFrameParamSets *fps)
static void alf_coeff_cc(int16_t *coeff, const uint8_t *mapped_abs, const uint8_t *sign)
static void tile_xy(int *tile_x, int *tile_y, const int tile_idx, const VVCPPS *pps)
static int is_luma_list(const int id)
static int derive_matrix_size(const int id)
static int decode_sps(VVCParamSets *ps, AVCodecContext *c, const H266RawSPS *rsps, int is_clvss)
static void pred_weight_table(PredWeightTable *w, const H266RawPredWeightTable *r)
static void pps_ref_wraparound_offset(VVCPPS *pps, const VVCSPS *sps)
static int aps_decode_alf(const VVCALF **alf, const H266RawAPS *aps)
static void alf_luma(VVCALF *alf, const H266RawAPS *aps)
static int decode_ps(VVCParamSets *ps, AVCodecContext *c, const SliceContext *sc, int is_clvss)
static void ctu_xy(int *rx, int *ry, const int tile_x, const int tile_y, const VVCPPS *pps)
static void pps_subpic(VVCPPS *pps, const VVCSPS *sps)
static int sh_alf_aps(const VVCSH *sh, const VVCFrameParamSets *fps)
static void sh_qp_y(VVCSH *sh, const H266RawPPS *pps, const H266RawPictureHeader *ph)
static void pps_free(AVRefStructOpaque opaque, void *obj)
static int next_tile_idx(int tile_idx, const int i, const H266RawPPS *r)
static int pps_derive(VVCPPS *pps, const VVCSPS *sps)
static int ph_derive(VVCPH *ph, const H266RawSPS *sps, const H266RawPPS *pps, const int poc_tid0, const int is_clvss)
static void pps_width_height(VVCPPS *pps, const VVCSPS *sps)
static void pps_chroma_qp_offset(VVCPPS *pps)
static int sps_chroma_qp_table(VVCSPS *sps)
static int sh_entry_points(VVCSH *sh, const H266RawSPS *sps, const VVCPPS *pps)
static int decode_ph(VVCFrameParamSets *fps, const H266RawPictureHeader *rph, void *rph_ref, const int poc_tid0, const int is_clvss)
static void sps_inter(VVCSPS *sps)
static int pps_one_tile_slices(VVCPPS *pps, const int tile_idx, int i, int *off)
static void sps_free(AVRefStructOpaque opaque, void *obj)
static void sps_vui(AVCodecContext *c, const H266RawVUI *vui)
static int pps_subpic_less_than_one_tile_slice(VVCPPS *pps, const VVCSPS *sps, const int i, const int tx, const int ty, int *off)
static int ph_compute_poc(const H266RawPictureHeader *ph, const H266RawSPS *sps, const int poc_tid0, const int is_clvss)
static void sps_ladf(VVCSPS *sps)
static int pps_bd(VVCPPS *pps)
static int pps_subpic_one_or_more_tiles_slice(VVCPPS *pps, const int tile_x, const int tile_y, const int x_end, const int y_end, const int i, int *off)
static int decode_pps(VVCParamSets *ps, const H266RawPPS *rpps)
static int pps_slice_map(VVCPPS *pps, const VVCSPS *sps)
static void subpic_tiles(int *tile_x, int *tile_y, int *tile_x_end, int *tile_y_end, const VVCSPS *sps, const VVCPPS *pps, const int i)
static void scaling_derive(VVCScalingList *sl, const H266RawAPS *aps)
static void sps_export_stream_params(AVCodecContext *c, const VVCSPS *sps)
static av_always_inline uint16_t lmcs_derive_lut_sample(uint16_t sample, uint16_t *pivot1, uint16_t *pivot2, uint16_t *scale_coeff, const int idx, const int max)
int ff_vvc_decode_sh(VVCSH *sh, const VVCFrameParamSets *fps, const CodedBitstreamUnit *unit)
static int aps_decode_scaling(const VVCScalingList **scaling, const H266RawAPS *aps)
static int pps_no_rect_slice(VVCPPS *pps)
static int pps_rect_slice(VVCPPS *pps, const VVCSPS *sps)
static void decode_recovery_flag(VVCContext *s)
static void sps_poc(VVCSPS *sps)
static int sps_map_pixel_format(VVCSPS *sps, void *log_ctx)
#define SL_MAX_MATRIX_SIZE
#define GDR_IS_RECOVERED(s)
#define ALF_NUM_COEFF_LUMA
#define GDR_SET_RECOVERED(s)
#define LMCS_MAX_BIT_DEPTH
#define LMCS_MAX_BIN_SIZE
#define ALF_NUM_FILTERS_LUMA
#define ALF_NUM_COEFF_CHROMA