34 16, 16, 16, 16, 17, 18, 21, 24,
35 16, 16, 16, 16, 17, 19, 22, 25,
36 16, 16, 17, 18, 20, 22, 25, 29,
37 16, 16, 18, 21, 24, 27, 31, 36,
38 17, 17, 20, 24, 30, 35, 41, 47,
39 18, 19, 22, 27, 35, 44, 54, 65,
40 21, 22, 25, 31, 41, 54, 70, 88,
41 24, 25, 29, 36, 47, 65, 88, 115
45 16, 16, 16, 16, 17, 18, 20, 24,
46 16, 16, 16, 17, 18, 20, 24, 25,
47 16, 16, 17, 18, 20, 24, 25, 28,
48 16, 17, 18, 20, 24, 25, 28, 33,
49 17, 18, 20, 24, 25, 28, 33, 41,
50 18, 20, 24, 25, 28, 33, 41, 54,
51 20, 24, 25, 28, 33, 41, 54, 71,
52 24, 25, 28, 33, 41, 54, 71, 91
65 if (
s->pps ==
s->pps_list[
id])
73 if (
s->sps_list[
id]) {
74 if (
s->sps ==
s->sps_list[
id])
79 if (
s->pps_list[
i] &&
s->pps_list[
i]->sps_id ==
id)
90 if (
s->vps_list[
id]) {
91 if (
s->vps ==
s->vps_list[
id])
95 if (
s->sps_list[
i] &&
s->sps_list[
i]->vps_id ==
id)
111 if (rps !=
sps->st_rps &&
sps->nb_st_rps)
118 if (is_slice_header) {
122 "Invalid value of delta_idx in slice header RPS: %d > %d.\n",
129 rps_ridx = &
sps->st_rps[rps -
sps->st_rps - 1];
135 "Invalid value of abs_delta_rps: %d\n",
148 if (i < rps_ridx->num_delta_pocs)
149 delta_poc = delta_rps + rps_ridx->
delta_poc[
i];
151 delta_poc = delta_rps;
161 "Invalid num_delta_pocs: %d\n", k);
173 for (k =
i - 1; k >= 0; k--) {
175 if (delta_poc <
tmp) {
199 unsigned int prev, nb_positive_pics;
214 if (delta_poc < 1 || delta_poc > 32768) {
216 "Invalid value of delta_poc: %d\n",
225 for (
i = 0;
i < nb_positive_pics;
i++) {
227 if (delta_poc < 1 || delta_poc > 32768) {
229 "Invalid value of delta_poc: %d\n",
267 for (
i = 0;
i < 32;
i++) {
270 if (
ptl->profile_idc == 0 &&
i > 0 &&
ptl->profile_compatibility_flag[
i])
271 ptl->profile_idc =
i;
278 #define check_profile_idc(idc) \
279 ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]
314 #undef check_profile_idc
320 PTL *
ptl,
int max_num_sub_layers)
324 get_bits_left(gb) < 8 + (8*2 * (max_num_sub_layers - 1 > 0))) {
331 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
336 if (max_num_sub_layers - 1> 0)
337 for (
i = max_num_sub_layers - 1;
i < 8;
i++)
339 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
343 "PTL information for sublayer %i too short\n",
i);
349 "Not enough data for sublayer %i level_idc\n",
i);
364 for (
i = 0;
i < nb_cpb;
i++) {
368 if (subpic_params_present) {
380 if (common_inf_present) {
407 for (
int i = 0;
i < max_sublayers;
i++) {
421 if (cpb_cnt_minus1 > 31) {
455 if (nal_size >
sizeof(
vps->data)) {
458 nal_size,
sizeof(
vps->data));
459 vps->data_size =
sizeof(
vps->data);
461 vps->data_size = nal_size;
483 vps->vps_max_sub_layers);
490 vps->vps_sub_layer_ordering_info_present_flag =
get_bits1(gb);
492 i =
vps->vps_sub_layer_ordering_info_present_flag ? 0 :
vps->vps_max_sub_layers - 1;
493 for (;
i <
vps->vps_max_sub_layers;
i++) {
500 vps->vps_max_dec_pic_buffering[
i] - 1);
503 if (
vps->vps_num_reorder_pics[
i] >
vps->vps_max_dec_pic_buffering[
i] - 1) {
505 vps->vps_num_reorder_pics[
i]);
513 if (
vps->vps_num_layer_sets < 1 ||
vps->vps_num_layer_sets > 1024 ||
519 for (
i = 1;
i <
vps->vps_num_layer_sets;
i++)
520 for (j = 0; j <=
vps->vps_max_layer_id; j++)
524 if (
vps->vps_timing_info_present_flag) {
527 vps->vps_poc_proportional_to_timing_flag =
get_bits1(gb);
528 if (
vps->vps_poc_proportional_to_timing_flag)
531 if (
vps->vps_num_hrd_parameters > (
unsigned)
vps->vps_num_layer_sets) {
533 "vps_num_hrd_parameters %d is invalid\n",
vps->vps_num_hrd_parameters);
536 for (
i = 0;
i <
vps->vps_num_hrd_parameters;
i++) {
537 int common_inf_present = 1;
543 vps->vps_max_sub_layers);
573 VUI backup_vui, *vui = &
sps->vui;
584 switch (
sps->pix_fmt) {
604 memcpy(&backup, gb,
sizeof(backup));
605 memcpy(&backup_vui, vui,
sizeof(backup_vui));
620 if (apply_defdispwin &&
623 "discarding vui default display window, "
624 "original values are l:%u r:%u t:%u b:%u\n",
645 "Strange VUI timing information, retrying...\n");
646 memcpy(vui, &backup_vui,
sizeof(backup_vui));
647 memcpy(gb, &backup,
sizeof(backup));
669 "Strange VUI bitstream restriction information, retrying"
670 " from timing information...\n");
671 memcpy(vui, &backup_vui,
sizeof(backup_vui));
672 memcpy(gb, &backup,
sizeof(backup));
689 "Overread in VUI, retrying from timing information...\n");
690 memcpy(vui, &backup_vui,
sizeof(backup_vui));
691 memcpy(gb, &backup,
sizeof(backup));
701 for (matrixId = 0; matrixId < 6; matrixId++) {
703 memset(sl->
sl[0][matrixId], 16, 16);
704 sl->
sl_dc[0][matrixId] = 16;
705 sl->
sl_dc[1][matrixId] = 16;
730 uint8_t scaling_list_pred_mode_flag;
731 uint8_t scaling_list_dc_coef[2][6];
732 int size_id, matrix_id,
pos;
735 for (size_id = 0; size_id < 4; size_id++)
736 for (matrix_id = 0; matrix_id < 6; matrix_id += ((size_id == 3) ? 3 : 1)) {
737 scaling_list_pred_mode_flag =
get_bits1(gb);
738 if (!scaling_list_pred_mode_flag) {
744 delta *= (size_id == 3) ? 3 : 1;
745 if (matrix_id <
delta) {
747 "Invalid delta in scaling list data: %d.\n",
delta);
751 memcpy(sl->
sl[size_id][matrix_id],
752 sl->
sl[size_id][matrix_id -
delta],
753 size_id > 0 ? 64 : 16);
755 sl->
sl_dc[size_id - 2][matrix_id] = sl->
sl_dc[size_id - 2][matrix_id -
delta];
758 int next_coef, coef_num;
759 int32_t scaling_list_delta_coef;
762 coef_num =
FFMIN(64, 1 << (4 + (size_id << 1)));
765 if (scaling_list_coeff_minus8 < -7 ||
766 scaling_list_coeff_minus8 > 247)
768 scaling_list_dc_coef[size_id - 2][matrix_id] = scaling_list_coeff_minus8 + 8;
769 next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
770 sl->
sl_dc[size_id - 2][matrix_id] = next_coef;
772 for (
i = 0;
i < coef_num;
i++) {
781 next_coef = (next_coef + 256
U + scaling_list_delta_coef) % 256;
782 sl->
sl[size_id][matrix_id][
pos] = next_coef;
787 if (
sps->chroma_format_idc == 3) {
788 for (
i = 0;
i < 64;
i++) {
789 sl->
sl[3][1][
i] = sl->
sl[2][1][
i];
790 sl->
sl[3][2][
i] = sl->
sl[2][2][
i];
791 sl->
sl[3][4][
i] = sl->
sl[2][4][
i];
792 sl->
sl[3][5][
i] = sl->
sl[2][5][
i];
807 switch (
sps->bit_depth) {
834 "The following bit-depths are currently specified: 8, 9, 10 and 12 bits, "
835 "chroma_format_idc is %d, depth is %d\n",
836 sps->chroma_format_idc,
sps->bit_depth);
844 sps->hshift[0] =
sps->vshift[0] = 0;
845 sps->hshift[2] =
sps->hshift[1] =
desc->log2_chroma_w;
846 sps->vshift[2] =
sps->vshift[1] =
desc->log2_chroma_h;
848 sps->pixel_shift =
sps->bit_depth > 8;
854 int apply_defdispwin,
const HEVCVPS *
const *vps_list,
859 int bit_depth_chroma, start, num_comps;
866 if (vps_list && !vps_list[
sps->vps_id]) {
875 sps->max_sub_layers);
891 if (
sps->chroma_format_idc > 3
U) {
896 if (
sps->chroma_format_idc == 3)
899 if (
sps->separate_colour_plane_flag)
900 sps->chroma_format_idc = 0;
905 sps->height, 0, avctx)) < 0)
909 if (
sps->conformance_window_flag) {
919 "discarding sps conformance window, "
920 "original values are l:%u r:%u t:%u b:%u\n",
921 sps->pic_conf_win.left_offset,
922 sps->pic_conf_win.right_offset,
923 sps->pic_conf_win.top_offset,
924 sps->pic_conf_win.bottom_offset);
926 sps->pic_conf_win.left_offset =
927 sps->pic_conf_win.right_offset =
928 sps->pic_conf_win.top_offset =
929 sps->pic_conf_win.bottom_offset = 0;
931 sps->output_window =
sps->pic_conf_win;
935 if (
sps->bit_depth > 16) {
941 if (bit_depth_chroma > 16) {
946 if (
sps->chroma_format_idc && bit_depth_chroma !=
sps->bit_depth) {
948 "Luma bit depth (%d) is different from chroma bit depth (%d), "
949 "this is unsupported.\n",
950 sps->bit_depth, bit_depth_chroma);
953 sps->bit_depth_chroma = bit_depth_chroma;
960 if (
sps->log2_max_poc_lsb > 16) {
962 sps->log2_max_poc_lsb - 4);
967 start =
sps->sublayer_ordering_info_flag ? 0 :
sps->max_sub_layers - 1;
968 for (
i = start;
i <
sps->max_sub_layers;
i++) {
974 sps->temporal_layer[
i].max_dec_pic_buffering - 1
U);
977 if (
sps->temporal_layer[
i].num_reorder_pics >
sps->temporal_layer[
i].max_dec_pic_buffering - 1) {
979 sps->temporal_layer[
i].num_reorder_pics);
984 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[
i].num_reorder_pics + 1;
988 if (!
sps->sublayer_ordering_info_flag) {
989 for (
i = 0;
i < start;
i++) {
990 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[start].max_dec_pic_buffering;
991 sps->temporal_layer[
i].num_reorder_pics =
sps->temporal_layer[start].num_reorder_pics;
992 sps->temporal_layer[
i].max_latency_increase =
sps->temporal_layer[start].max_latency_increase;
1000 sps->log2_max_trafo_size =
sps->log2_diff_max_min_transform_block_size +
1001 sps->log2_min_tb_size;
1003 if (
sps->log2_min_cb_size < 3 ||
sps->log2_min_cb_size > 30) {
1008 if (
sps->log2_diff_max_min_coding_block_size > 30) {
1009 av_log(avctx,
AV_LOG_ERROR,
"Invalid value %d for log2_diff_max_min_coding_block_size",
sps->log2_diff_max_min_coding_block_size);
1013 if (
sps->log2_min_tb_size >=
sps->log2_min_cb_size ||
sps->log2_min_tb_size < 2) {
1018 if (
sps->log2_diff_max_min_transform_block_size > 30) {
1019 av_log(avctx,
AV_LOG_ERROR,
"Invalid value %d for log2_diff_max_min_transform_block_size",
1020 sps->log2_diff_max_min_transform_block_size);
1028 if (
sps->scaling_list_enable_flag) {
1042 if (
sps->pcm_enabled_flag) {
1046 sps->pcm.log2_max_pcm_cb_size =
sps->pcm.log2_min_pcm_cb_size +
1048 if (
FFMAX(
sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma) >
sps->bit_depth) {
1050 "PCM bit depth (%d, %d) is greater than normal bit depth (%d)\n",
1051 sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma,
sps->bit_depth);
1064 for (
i = 0;
i <
sps->nb_st_rps;
i++) {
1071 if (
sps->long_term_ref_pics_present_flag) {
1075 sps->num_long_term_ref_pics_sps);
1078 for (
i = 0;
i <
sps->num_long_term_ref_pics_sps;
i++) {
1085 sps->sps_strong_intra_smoothing_enable_flag =
get_bits1(gb);
1088 if (
sps->vui_present)
1092 if (
sps->sps_extension_present_flag) {
1099 if (
sps->sps_range_extension_flag) {
1100 sps->transform_skip_rotation_enabled_flag =
get_bits1(gb);
1101 sps->transform_skip_context_enabled_flag =
get_bits1(gb);
1106 sps->extended_precision_processing_flag =
get_bits1(gb);
1107 if (
sps->extended_precision_processing_flag)
1109 "extended_precision_processing_flag not yet implemented\n");
1112 sps->high_precision_offsets_enabled_flag =
get_bits1(gb);
1113 if (
sps->high_precision_offsets_enabled_flag)
1115 "high_precision_offsets_enabled_flag not yet implemented\n");
1117 sps->persistent_rice_adaptation_enabled_flag =
get_bits1(gb);
1119 sps->cabac_bypass_alignment_enabled_flag =
get_bits1(gb);
1120 if (
sps->cabac_bypass_alignment_enabled_flag)
1122 "cabac_bypass_alignment_enabled_flag not yet implemented\n");
1125 if (
sps->sps_multilayer_extension_flag) {
1128 "sps_multilayer_extension_flag not yet implemented\n");
1131 if (
sps->sps_3d_extension_flag) {
1132 for (
i = 0;
i <= 1;
i++) {
1152 "sps_3d_extension_flag not yet implemented\n");
1155 if (
sps->sps_scc_extension_flag) {
1158 if (
sps->palette_mode_enabled_flag) {
1161 sps->sps_palette_predictor_initializers_present_flag =
get_bits1(gb);
1163 if (
sps->sps_palette_predictor_initializers_present_flag) {
1167 "sps_num_palette_predictor_initializers out of range: %u\n",
1168 sps->sps_num_palette_predictor_initializers);
1171 num_comps = !
sps->chroma_format_idc ? 1 : 3;
1174 for (
i = 0;
i <
sps->sps_num_palette_predictor_initializers;
i++)
1179 sps->motion_vector_resolution_control_idc =
get_bits(gb, 2);
1180 sps->intra_boundary_filtering_disabled_flag =
get_bits1(gb);
1183 if (apply_defdispwin) {
1184 sps->output_window.left_offset +=
sps->vui.def_disp_win.left_offset;
1185 sps->output_window.right_offset +=
sps->vui.def_disp_win.right_offset;
1186 sps->output_window.top_offset +=
sps->vui.def_disp_win.top_offset;
1187 sps->output_window.bottom_offset +=
sps->vui.def_disp_win.bottom_offset;
1190 ow = &
sps->output_window;
1201 "Displaying the whole video surface.\n");
1202 memset(ow, 0,
sizeof(*ow));
1203 memset(&
sps->pic_conf_win, 0,
sizeof(
sps->pic_conf_win));
1207 sps->log2_ctb_size =
sps->log2_min_cb_size +
1208 sps->log2_diff_max_min_coding_block_size;
1209 sps->log2_min_pu_size =
sps->log2_min_cb_size - 1;
1215 if (
sps->log2_ctb_size < 4) {
1218 "log2_ctb_size %d differs from the bounds of any known profile\n",
1219 sps->log2_ctb_size);
1224 sps->ctb_width = (
sps->width + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1225 sps->ctb_height = (
sps->height + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1226 sps->ctb_size =
sps->ctb_width *
sps->ctb_height;
1228 sps->min_cb_width =
sps->width >>
sps->log2_min_cb_size;
1229 sps->min_cb_height =
sps->height >>
sps->log2_min_cb_size;
1230 sps->min_tb_width =
sps->width >>
sps->log2_min_tb_size;
1231 sps->min_tb_height =
sps->height >>
sps->log2_min_tb_size;
1232 sps->min_pu_width =
sps->width >>
sps->log2_min_pu_size;
1233 sps->min_pu_height =
sps->height >>
sps->log2_min_pu_size;
1234 sps->tb_mask = (1 << (
sps->log2_ctb_size -
sps->log2_min_tb_size)) - 1;
1236 sps->qp_bd_offset = 6 * (
sps->bit_depth - 8);
1244 if (
sps->max_transform_hierarchy_depth_inter >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1245 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_inter out of range: %d\n",
1246 sps->max_transform_hierarchy_depth_inter);
1249 if (
sps->max_transform_hierarchy_depth_intra >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1250 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_intra out of range: %d\n",
1251 sps->max_transform_hierarchy_depth_intra);
1254 if (
sps->log2_max_trafo_size >
FFMIN(
sps->log2_ctb_size, 5)) {
1256 "max transform block size out of range: %d\n",
1257 sps->log2_max_trafo_size);
1274 unsigned int sps_id;
1284 if (nal_size >
sizeof(
sps->data)) {
1287 nal_size,
sizeof(
sps->data));
1288 sps->data_size =
sizeof(
sps->data);
1290 sps->data_size = nal_size;
1304 "Parsed SPS: id %d; coded wxh: %dx%d; "
1305 "cropped wxh: %dx%d; pix_fmt: %s.\n",
1306 sps_id,
sps->width,
sps->height,
1307 sps->width - (
sps->output_window.left_offset +
sps->output_window.right_offset),
1308 sps->height - (
sps->output_window.top_offset +
sps->output_window.bottom_offset),
1343 int idx_y,
int idx_cb,
int idx_cr,
int inp_length)
1345 unsigned int split_octant_flag, part_num_y, coded_res_flag, res_coeff_q, res_coeff_r;
1348 part_num_y = 1 <<
pps->cm_y_part_num_log2;
1350 split_octant_flag = inp_depth <
pps->cm_octant_depth ?
get_bits1(gb) : 0;
1352 if (split_octant_flag)
1353 for (
int k = 0; k < 2; k++)
1354 for (
int m = 0; m < 2; m++)
1355 for (
int n = 0; n < 2; n++)
1357 idx_y + part_num_y * k * inp_length / 2,
1358 idx_cb + m * inp_length / 2,
1359 idx_cr + n * inp_length / 2,
1362 for (
int i = 0;
i < part_num_y;
i++) {
1363 for (
int j = 0; j < 4; j++) {
1366 for (
int c = 0;
c < 3;
c++) {
1368 cm_res_bits =
FFMAX(0, 10 +
pps->luma_bit_depth_cm_input -
1369 pps->luma_bit_depth_cm_output -
1370 pps->cm_res_quant_bits -
pps->cm_delta_flc_bits);
1371 res_coeff_r = cm_res_bits ?
get_bits(gb, cm_res_bits) : 0;
1372 if (res_coeff_q || res_coeff_r)
1382 if (
pps->num_cm_ref_layers > 62) {
1384 "num_cm_ref_layers_minus1 shall be in the range [0, 61].\n");
1387 for (
int i = 0;
i <
pps->num_cm_ref_layers;
i++)
1401 if (
pps->cm_octant_depth == 1) {
1416 if (
pps->pps_infer_scaling_list_flag)
1417 pps->pps_scaling_list_ref_layer_id =
get_bits(gb, 6);
1420 if (
pps->num_ref_loc_offsets >
vps->vps_max_layers - 1)
1423 for (
int i = 0;
i <
pps->num_ref_loc_offsets;
i++) {
1425 pps->scaled_ref_layer_offset_present_flag[
i] =
get_bits1(gb);
1426 if (
pps->scaled_ref_layer_offset_present_flag[
i]) {
1434 if (
pps->ref_region_offset_present_flag[
i]) {
1442 if (
pps->resample_phase_set_present_flag[
i]) {
1451 if (
pps->colour_mapping_enabled_flag) {
1462 unsigned int num_val_delta_dlt, max_diff = 0;
1463 int min_diff_minus1 = -1;
1466 num_val_delta_dlt =
get_bits(gb,
pps->pps_bit_depth_for_depth_layers_minus8 + 8);
1467 if (num_val_delta_dlt) {
1468 if (num_val_delta_dlt > 1)
1469 max_diff =
get_bits(gb,
pps->pps_bit_depth_for_depth_layers_minus8 + 8);
1470 if (num_val_delta_dlt > 2 && max_diff) {
1474 if (max_diff > (min_diff_minus1 + 1))
1475 for (
int k = 1; k < num_val_delta_dlt; k++) {
1476 len =
av_log2(max_diff - (min_diff_minus1 + 1)) + 1;
1485 unsigned int pps_depth_layers_minus1;
1488 pps_depth_layers_minus1 =
get_bits(gb, 6);
1489 pps->pps_bit_depth_for_depth_layers_minus8 =
get_bits(gb, 4);
1490 for (
int i = 0;
i <= pps_depth_layers_minus1;
i++) {
1494 for (
int j = 0; j <= ((1 << (
pps->pps_bit_depth_for_depth_layers_minus8 + 8)) - 1); j++)
1509 if (
pps->transform_skip_enabled_flag) {
1512 pps->cross_component_prediction_enabled_flag =
get_bits1(gb);
1513 pps->chroma_qp_offset_list_enabled_flag =
get_bits1(gb);
1514 if (
pps->chroma_qp_offset_list_enabled_flag) {
1517 if (
pps->chroma_qp_offset_list_len_minus1 > 5) {
1519 "chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
1522 for (
int i = 0;
i <=
pps->chroma_qp_offset_list_len_minus1;
i++) {
1524 if (
pps->cb_qp_offset_list[
i]) {
1526 "cb_qp_offset_list not tested yet.\n");
1529 if (
pps->cr_qp_offset_list[
i]) {
1531 "cb_qp_offset_list not tested yet.\n");
1538 if (
pps->log2_sao_offset_scale_luma >
FFMAX(
sps->bit_depth - 10, 0)
1539 ||
pps->log2_sao_offset_scale_chroma >
FFMAX(
sps->bit_depth_chroma - 10, 0)
1552 if (
pps->residual_adaptive_colour_transform_enabled_flag =
get_bits1(gb)) {
1553 pps->pps_slice_act_qp_offsets_present_flag =
get_bits1(gb);
1558 #define CHECK_QP_OFFSET(name) (pps->pps_act_ ## name ## _qp_offset <= -12 || \
1559 pps->pps_act_ ## name ## _qp_offset >= 12)
1561 #undef CHECK_QP_OFFSET
1564 "PpsActQpOffsetY/Cb/Cr shall be in the range of [-12, 12].\n");
1569 if (
pps->pps_palette_predictor_initializers_present_flag =
get_bits1(gb)) {
1571 if (
pps->pps_num_palette_predictor_initializers > 0) {
1574 "pps_num_palette_predictor_initializers out of range: %u\n",
1575 pps->pps_num_palette_predictor_initializers);
1580 if (
pps->luma_bit_depth_entry !=
sps->bit_depth)
1582 if (!
pps->monochrome_palette_flag) {
1584 if (
pps->chroma_bit_depth_entry !=
sps->bit_depth_chroma)
1588 num_comps =
pps->monochrome_palette_flag ? 1 : 3;
1591 for (
int i = 0;
i <
pps->pps_num_palette_predictor_initializers;
i++)
1604 int pic_area_in_ctbs;
1605 int i, j, x, y, ctb_addr_rs, tile_id;
1611 if (!
pps->col_bd || !
pps->row_bd || !
pps->col_idxX)
1614 if (
pps->uniform_spacing_flag) {
1615 if (!
pps->column_width) {
1619 if (!
pps->column_width || !
pps->row_height)
1622 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1623 pps->column_width[
i] = ((
i + 1) *
sps->ctb_width) /
pps->num_tile_columns -
1624 (
i *
sps->ctb_width) /
pps->num_tile_columns;
1627 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1628 pps->row_height[
i] = ((
i + 1) *
sps->ctb_height) /
pps->num_tile_rows -
1629 (
i *
sps->ctb_height) /
pps->num_tile_rows;
1634 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1635 pps->col_bd[
i + 1] =
pps->col_bd[
i] +
pps->column_width[
i];
1638 for (
i = 0;
i <
pps->num_tile_rows;
i++)
1639 pps->row_bd[
i + 1] =
pps->row_bd[
i] +
pps->row_height[
i];
1641 for (
i = 0, j = 0;
i <
sps->ctb_width;
i++) {
1642 if (
i >
pps->col_bd[j])
1644 pps->col_idxX[
i] = j;
1650 pic_area_in_ctbs =
sps->ctb_width *
sps->ctb_height;
1656 if (!
pps->ctb_addr_rs_to_ts || !
pps->ctb_addr_ts_to_rs ||
1657 !
pps->tile_id || !
pps->min_tb_addr_zs_tab) {
1661 for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
1662 int tb_x = ctb_addr_rs %
sps->ctb_width;
1663 int tb_y = ctb_addr_rs /
sps->ctb_width;
1668 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1669 if (tb_x < pps->col_bd[
i + 1]) {
1675 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1676 if (tb_y < pps->row_bd[
i + 1]) {
1682 for (
i = 0;
i < tile_x;
i++)
1683 val +=
pps->row_height[tile_y] *
pps->column_width[
i];
1684 for (
i = 0;
i < tile_y;
i++)
1687 val += (tb_y -
pps->row_bd[tile_y]) *
pps->column_width[tile_x] +
1688 tb_x -
pps->col_bd[tile_x];
1690 pps->ctb_addr_rs_to_ts[ctb_addr_rs] =
val;
1691 pps->ctb_addr_ts_to_rs[
val] = ctb_addr_rs;
1694 for (j = 0, tile_id = 0; j <
pps->num_tile_rows; j++)
1695 for (
i = 0;
i <
pps->num_tile_columns;
i++, tile_id++)
1696 for (y =
pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
1697 for (x =
pps->col_bd[
i]; x < pps->col_bd[
i + 1]; x++)
1698 pps->tile_id[
pps->ctb_addr_rs_to_ts[y *
sps->ctb_width + x]] = tile_id;
1701 if (!
pps->tile_pos_rs)
1704 for (j = 0; j <
pps->num_tile_rows; j++)
1705 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1706 pps->tile_pos_rs[j *
pps->num_tile_columns +
i] =
1707 pps->row_bd[j] *
sps->ctb_width +
pps->col_bd[
i];
1709 log2_diff =
sps->log2_ctb_size -
sps->log2_min_tb_size;
1710 pps->min_tb_addr_zs = &
pps->min_tb_addr_zs_tab[1*(
sps->tb_mask+2)+1];
1711 for (y = 0; y <
sps->tb_mask+2; y++) {
1712 pps->min_tb_addr_zs_tab[y*(
sps->tb_mask+2)] = -1;
1713 pps->min_tb_addr_zs_tab[y] = -1;
1715 for (y = 0; y <
sps->tb_mask+1; y++) {
1716 for (x = 0; x <
sps->tb_mask+1; x++) {
1717 int tb_x = x >> log2_diff;
1718 int tb_y = y >> log2_diff;
1719 int rs =
sps->ctb_width * tb_y + tb_x;
1720 int val =
pps->ctb_addr_rs_to_ts[rs] << (log2_diff * 2);
1721 for (
i = 0;
i < log2_diff;
i++) {
1723 val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
1725 pps->min_tb_addr_zs[y * (
sps->tb_mask+2) + x] =
val;
1738 unsigned int pps_id = 0;
1740 unsigned log2_parallel_merge_level_minus2;
1750 if (nal_size >
sizeof(
pps->data)) {
1753 nal_size,
sizeof(
pps->data));
1754 pps->data_size =
sizeof(
pps->data);
1756 pps->data_size = nal_size;
1761 pps->loop_filter_across_tiles_enabled_flag = 1;
1762 pps->num_tile_columns = 1;
1763 pps->num_tile_rows = 1;
1764 pps->uniform_spacing_flag = 1;
1765 pps->disable_dbf = 0;
1766 pps->beta_offset = 0;
1768 pps->log2_max_transform_skip_block_size = 2;
1791 pps->dependent_slice_segments_enabled_flag =
get_bits1(gb);
1793 pps->num_extra_slice_header_bits =
get_bits(gb, 3);
1804 pps->num_ref_idx_l0_default_active,
pps->num_ref_idx_l1_default_active);
1814 pps->diff_cu_qp_delta_depth = 0;
1815 if (
pps->cu_qp_delta_enabled_flag)
1818 if (
pps->diff_cu_qp_delta_depth < 0 ||
1819 pps->diff_cu_qp_delta_depth >
sps->log2_diff_max_min_coding_block_size) {
1821 pps->diff_cu_qp_delta_depth);
1827 if (
pps->cb_qp_offset < -12 ||
pps->cb_qp_offset > 12) {
1834 if (
pps->cr_qp_offset < -12 ||
pps->cr_qp_offset > 12) {
1840 pps->pic_slice_level_chroma_qp_offsets_present_flag =
get_bits1(gb);
1849 if (
pps->tiles_enabled_flag) {
1853 if (num_tile_columns_minus1 < 0 ||
1854 num_tile_columns_minus1 >=
sps->ctb_width) {
1856 num_tile_columns_minus1);
1860 if (num_tile_rows_minus1 < 0 ||
1861 num_tile_rows_minus1 >=
sps->ctb_height) {
1863 num_tile_rows_minus1);
1867 pps->num_tile_columns = num_tile_columns_minus1 + 1;
1868 pps->num_tile_rows = num_tile_rows_minus1 + 1;
1872 if (!
pps->column_width || !
pps->row_height) {
1878 if (!
pps->uniform_spacing_flag) {
1880 for (
i = 0;
i <
pps->num_tile_columns - 1;
i++) {
1882 sum +=
pps->column_width[
i];
1884 if (sum >=
sps->ctb_width) {
1889 pps->column_width[
pps->num_tile_columns - 1] =
sps->ctb_width - sum;
1892 for (
i = 0;
i <
pps->num_tile_rows - 1;
i++) {
1894 sum +=
pps->row_height[
i];
1896 if (sum >=
sps->ctb_height) {
1901 pps->row_height[
pps->num_tile_rows - 1] =
sps->ctb_height - sum;
1903 pps->loop_filter_across_tiles_enabled_flag =
get_bits1(gb);
1906 pps->seq_loop_filter_across_slices_enabled_flag =
get_bits1(gb);
1908 pps->deblocking_filter_control_present_flag =
get_bits1(gb);
1909 if (
pps->deblocking_filter_control_present_flag) {
1910 pps->deblocking_filter_override_enabled_flag =
get_bits1(gb);
1912 if (!
pps->disable_dbf) {
1915 if (beta_offset_div2 < -6 || beta_offset_div2 > 6) {
1921 if (tc_offset_div2 < -6 || tc_offset_div2 > 6) {
1927 pps->beta_offset = 2 * beta_offset_div2;
1928 pps->tc_offset = 2 * tc_offset_div2;
1933 if (
pps->scaling_list_data_present_flag) {
1941 if (log2_parallel_merge_level_minus2 >
sps->log2_ctb_size) {
1943 log2_parallel_merge_level_minus2);
1947 pps->log2_parallel_merge_level = log2_parallel_merge_level_minus2 + 2;
1949 pps->slice_header_extension_present_flag =
get_bits1(gb);
1952 if (
pps->pps_extension_present_flag) {
1964 if (
pps->pps_multilayer_extension_flag) {
1969 if (
pps->pps_3d_extension_flag) {
1974 if (
pps->pps_scc_extension_flag) {
2017 int max_poc_lsb = 1 <<
sps->log2_max_poc_lsb;
2018 int prev_poc_lsb = pocTid0 % max_poc_lsb;
2019 int prev_poc_msb = pocTid0 - prev_poc_lsb;
2022 if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
2023 poc_msb = prev_poc_msb + max_poc_lsb;
2024 else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 2)
2025 poc_msb = prev_poc_msb - max_poc_lsb;
2027 poc_msb = prev_poc_msb;
2035 return poc_msb + poc_lsb;