32 16, 16, 16, 16, 17, 18, 21, 24,
33 16, 16, 16, 16, 17, 19, 22, 25,
34 16, 16, 17, 18, 20, 22, 25, 29,
35 16, 16, 18, 21, 24, 27, 31, 36,
36 17, 17, 20, 24, 30, 35, 41, 47,
37 18, 19, 22, 27, 35, 44, 54, 65,
38 21, 22, 25, 31, 41, 54, 70, 88,
39 24, 25, 29, 36, 47, 65, 88, 115
43 16, 16, 16, 16, 17, 18, 20, 24,
44 16, 16, 16, 17, 18, 20, 24, 25,
45 16, 16, 17, 18, 20, 24, 25, 28,
46 16, 17, 18, 20, 24, 25, 28, 33,
47 17, 18, 20, 24, 25, 28, 33, 41,
48 18, 20, 24, 25, 28, 33, 41, 54,
49 20, 24, 25, 28, 33, 41, 54, 71,
50 24, 25, 28, 33, 41, 54, 71, 91
83 if (
s->pps_list[
id] &&
s->pps == (
const HEVCPPS*)
s->pps_list[
id]->data)
91 if (
s->sps_list[
id]) {
92 if (
s->sps == (
const HEVCSPS*)
s->sps_list[
id]->data)
97 if (
s->pps_list[
i] && ((
HEVCPPS*)
s->pps_list[
i]->data)->sps_id ==
id)
108 if (
s->vps_list[
id]) {
109 if (
s->vps == (
const HEVCVPS*)
s->vps_list[
id]->data)
113 if (
s->sps_list[
i] && ((
HEVCSPS*)
s->sps_list[
i]->data)->vps_id ==
id)
129 if (rps !=
sps->st_rps &&
sps->nb_st_rps)
135 unsigned abs_delta_rps;
139 if (is_slice_header) {
141 if (delta_idx >
sps->nb_st_rps) {
143 "Invalid value of delta_idx in slice header RPS: %d > %d.\n",
144 delta_idx,
sps->nb_st_rps);
147 rps_ridx = &
sps->st_rps[
sps->nb_st_rps - delta_idx];
150 rps_ridx = &
sps->st_rps[rps -
sps->st_rps - 1];
154 if (abs_delta_rps < 1 || abs_delta_rps > 32768) {
156 "Invalid value of abs_delta_rps: %d\n",
160 delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
167 if (used || use_delta_flag) {
168 if (i < rps_ridx->num_delta_pocs)
169 delta_poc = delta_rps + rps_ridx->
delta_poc[
i];
171 delta_poc = delta_rps;
183 "Invalid num_delta_pocs: %d\n", k);
195 for (k =
i - 1; k >= 0; k--) {
197 if (delta_poc <
tmp) {
221 unsigned int prev, nb_positive_pics;
236 if (delta_poc < 1 || delta_poc > 32768) {
238 "Invalid value of delta_poc: %d\n",
247 for (
i = 0;
i < nb_positive_pics;
i++) {
249 if (delta_poc < 1 || delta_poc > 32768) {
251 "Invalid value of delta_poc: %d\n",
287 for (
i = 0;
i < 32;
i++) {
290 if (
ptl->profile_idc == 0 &&
i > 0 &&
ptl->profile_compatibility_flag[
i])
291 ptl->profile_idc =
i;
306 PTL *
ptl,
int max_num_sub_layers)
310 get_bits_left(gb) < 8 + (8*2 * (max_num_sub_layers - 1 > 0))) {
317 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
322 if (max_num_sub_layers - 1> 0)
323 for (
i = max_num_sub_layers - 1;
i < 8;
i++)
325 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
329 "PTL information for sublayer %i too short\n",
i);
335 "Not enough data for sublayer %i level_idc\n",
i);
346 int subpic_params_present)
350 for (
i = 0;
i < nb_cpb;
i++) {
354 if (subpic_params_present) {
365 int nal_params_present = 0, vcl_params_present = 0;
366 int subpic_params_present = 0;
369 if (common_inf_present) {
373 if (nal_params_present || vcl_params_present) {
376 if (subpic_params_present) {
386 if (subpic_params_present)
395 for (
i = 0;
i < max_sublayers;
i++) {
397 unsigned int nb_cpb = 1;
410 if (nb_cpb < 1 || nb_cpb > 32) {
416 if (nal_params_present)
418 if (vcl_params_present)
440 if (nal_size >
sizeof(
vps->data)) {
443 nal_size,
sizeof(
vps->data));
444 vps->data_size =
sizeof(
vps->data);
446 vps->data_size = nal_size;
472 vps->vps_max_sub_layers);
479 vps->vps_sub_layer_ordering_info_present_flag =
get_bits1(gb);
481 i =
vps->vps_sub_layer_ordering_info_present_flag ? 0 :
vps->vps_max_sub_layers - 1;
482 for (;
i <
vps->vps_max_sub_layers;
i++) {
489 vps->vps_max_dec_pic_buffering[
i] - 1);
492 if (
vps->vps_num_reorder_pics[
i] >
vps->vps_max_dec_pic_buffering[
i] - 1) {
494 vps->vps_num_reorder_pics[
i]);
502 if (
vps->vps_num_layer_sets < 1 ||
vps->vps_num_layer_sets > 1024 ||
508 for (
i = 1;
i <
vps->vps_num_layer_sets;
i++)
509 for (j = 0; j <=
vps->vps_max_layer_id; j++)
513 if (
vps->vps_timing_info_present_flag) {
516 vps->vps_poc_proportional_to_timing_flag =
get_bits1(gb);
517 if (
vps->vps_poc_proportional_to_timing_flag)
520 if (
vps->vps_num_hrd_parameters > (
unsigned)
vps->vps_num_layer_sets) {
522 "vps_num_hrd_parameters %d is invalid\n",
vps->vps_num_hrd_parameters);
525 for (
i = 0;
i <
vps->vps_num_hrd_parameters;
i++) {
526 int common_inf_present = 1;
561 VUI backup_vui, *vui = &
sps->vui;
563 int sar_present, alt = 0;
572 else if (sar_idx == 255) {
577 "Unknown SAR index: %u.\n", sar_idx);
604 switch (
sps->pix_fmt) {
630 memcpy(&backup, gb,
sizeof(backup));
631 memcpy(&backup_vui, vui,
sizeof(backup_vui));
646 if (apply_defdispwin &&
649 "discarding vui default display window, "
650 "original values are l:%u r:%u t:%u b:%u\n",
671 "Strange VUI timing information, retrying...\n");
672 memcpy(vui, &backup_vui,
sizeof(backup_vui));
673 memcpy(gb, &backup,
sizeof(backup));
695 "Strange VUI bitstream restriction information, retrying"
696 " from timing information...\n");
697 memcpy(vui, &backup_vui,
sizeof(backup_vui));
698 memcpy(gb, &backup,
sizeof(backup));
715 "Overread in VUI, retrying from timing information...\n");
716 memcpy(vui, &backup_vui,
sizeof(backup_vui));
717 memcpy(gb, &backup,
sizeof(backup));
727 for (matrixId = 0; matrixId < 6; matrixId++) {
729 memset(sl->
sl[0][matrixId], 16, 16);
730 sl->
sl_dc[0][matrixId] = 16;
731 sl->
sl_dc[1][matrixId] = 16;
755 uint8_t scaling_list_pred_mode_flag;
756 int32_t scaling_list_dc_coef[2][6];
757 int size_id, matrix_id, pos;
760 for (size_id = 0; size_id < 4; size_id++)
761 for (matrix_id = 0; matrix_id < 6; matrix_id += ((size_id == 3) ? 3 : 1)) {
762 scaling_list_pred_mode_flag =
get_bits1(gb);
763 if (!scaling_list_pred_mode_flag) {
769 delta *= (size_id == 3) ? 3 : 1;
770 if (matrix_id <
delta) {
772 "Invalid delta in scaling list data: %d.\n",
delta);
776 memcpy(sl->
sl[size_id][matrix_id],
777 sl->
sl[size_id][matrix_id -
delta],
778 size_id > 0 ? 64 : 16);
780 sl->
sl_dc[size_id - 2][matrix_id] = sl->
sl_dc[size_id - 2][matrix_id -
delta];
783 int next_coef, coef_num;
784 int32_t scaling_list_delta_coef;
787 coef_num =
FFMIN(64, 1 << (4 + (size_id << 1)));
790 if (scaling_list_coeff_minus8 < -7 ||
791 scaling_list_coeff_minus8 > 247)
793 scaling_list_dc_coef[size_id - 2][matrix_id] = scaling_list_coeff_minus8 + 8;
794 next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
795 sl->
sl_dc[size_id - 2][matrix_id] = next_coef;
797 for (
i = 0;
i < coef_num;
i++) {
806 next_coef = (next_coef + 256
U + scaling_list_delta_coef) % 256;
807 sl->
sl[size_id][matrix_id][pos] = next_coef;
812 if (
sps->chroma_format_idc == 3) {
813 for (
i = 0;
i < 64;
i++) {
814 sl->
sl[3][1][
i] = sl->
sl[2][1][
i];
815 sl->
sl[3][2][
i] = sl->
sl[2][2][
i];
816 sl->
sl[3][4][
i] = sl->
sl[2][4][
i];
817 sl->
sl[3][5][
i] = sl->
sl[2][5][
i];
832 switch (
sps->bit_depth) {
859 "The following bit-depths are currently specified: 8, 9, 10 and 12 bits, "
860 "chroma_format_idc is %d, depth is %d\n",
861 sps->chroma_format_idc,
sps->bit_depth);
869 sps->hshift[0] =
sps->vshift[0] = 0;
870 sps->hshift[2] =
sps->hshift[1] =
desc->log2_chroma_w;
871 sps->vshift[2] =
sps->vshift[1] =
desc->log2_chroma_h;
873 sps->pixel_shift =
sps->bit_depth > 8;
883 int log2_diff_max_min_transform_block_size;
884 int bit_depth_chroma,
start, vui_present, sublayer_ordering_info;
895 if (vps_list && !vps_list[
sps->vps_id]) {
904 sps->max_sub_layers);
920 if (
sps->chroma_format_idc > 3
U) {
925 if (
sps->chroma_format_idc == 3)
928 if (
sps->separate_colour_plane_flag)
929 sps->chroma_format_idc = 0;
934 sps->height, 0, avctx)) < 0)
947 "discarding sps conformance window, "
948 "original values are l:%u r:%u t:%u b:%u\n",
949 sps->pic_conf_win.left_offset,
950 sps->pic_conf_win.right_offset,
951 sps->pic_conf_win.top_offset,
952 sps->pic_conf_win.bottom_offset);
954 sps->pic_conf_win.left_offset =
955 sps->pic_conf_win.right_offset =
956 sps->pic_conf_win.top_offset =
957 sps->pic_conf_win.bottom_offset = 0;
959 sps->output_window =
sps->pic_conf_win;
964 if (
sps->chroma_format_idc && bit_depth_chroma !=
sps->bit_depth) {
966 "Luma bit depth (%d) is different from chroma bit depth (%d), "
967 "this is unsupported.\n",
968 sps->bit_depth, bit_depth_chroma);
971 sps->bit_depth_chroma = bit_depth_chroma;
978 if (
sps->log2_max_poc_lsb > 16) {
980 sps->log2_max_poc_lsb - 4);
985 start = sublayer_ordering_info ? 0 :
sps->max_sub_layers - 1;
992 sps->temporal_layer[
i].max_dec_pic_buffering - 1
U);
995 if (
sps->temporal_layer[
i].num_reorder_pics >
sps->temporal_layer[
i].max_dec_pic_buffering - 1) {
997 sps->temporal_layer[
i].num_reorder_pics);
1002 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[
i].num_reorder_pics + 1;
1006 if (!sublayer_ordering_info) {
1008 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[
start].max_dec_pic_buffering;
1009 sps->temporal_layer[
i].num_reorder_pics =
sps->temporal_layer[
start].num_reorder_pics;
1010 sps->temporal_layer[
i].max_latency_increase =
sps->temporal_layer[
start].max_latency_increase;
1018 sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size +
1019 sps->log2_min_tb_size;
1021 if (
sps->log2_min_cb_size < 3 ||
sps->log2_min_cb_size > 30) {
1026 if (
sps->log2_diff_max_min_coding_block_size > 30) {
1027 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);
1031 if (
sps->log2_min_tb_size >=
sps->log2_min_cb_size ||
sps->log2_min_tb_size < 2) {
1036 if (log2_diff_max_min_transform_block_size < 0 || log2_diff_max_min_transform_block_size > 30) {
1037 av_log(avctx,
AV_LOG_ERROR,
"Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size);
1045 if (
sps->scaling_list_enable_flag) {
1059 if (
sps->pcm_enabled_flag) {
1063 sps->pcm.log2_max_pcm_cb_size =
sps->pcm.log2_min_pcm_cb_size +
1065 if (
FFMAX(
sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma) >
sps->bit_depth) {
1067 "PCM bit depth (%d, %d) is greater than normal bit depth (%d)\n",
1068 sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma,
sps->bit_depth);
1081 for (
i = 0;
i <
sps->nb_st_rps;
i++) {
1088 if (
sps->long_term_ref_pics_present_flag) {
1092 sps->num_long_term_ref_pics_sps);
1095 for (
i = 0;
i <
sps->num_long_term_ref_pics_sps;
i++) {
1102 sps->sps_strong_intra_smoothing_enable_flag =
get_bits1(gb);
1111 if (
sps->sps_range_extension_flag) {
1112 sps->transform_skip_rotation_enabled_flag =
get_bits1(gb);
1113 sps->transform_skip_context_enabled_flag =
get_bits1(gb);
1118 sps->extended_precision_processing_flag =
get_bits1(gb);
1119 if (
sps->extended_precision_processing_flag)
1121 "extended_precision_processing_flag not yet implemented\n");
1124 sps->high_precision_offsets_enabled_flag =
get_bits1(gb);
1125 if (
sps->high_precision_offsets_enabled_flag)
1127 "high_precision_offsets_enabled_flag not yet implemented\n");
1129 sps->persistent_rice_adaptation_enabled_flag =
get_bits1(gb);
1131 sps->cabac_bypass_alignment_enabled_flag =
get_bits1(gb);
1132 if (
sps->cabac_bypass_alignment_enabled_flag)
1134 "cabac_bypass_alignment_enabled_flag not yet implemented\n");
1137 if (apply_defdispwin) {
1138 sps->output_window.left_offset +=
sps->vui.def_disp_win.left_offset;
1139 sps->output_window.right_offset +=
sps->vui.def_disp_win.right_offset;
1140 sps->output_window.top_offset +=
sps->vui.def_disp_win.top_offset;
1141 sps->output_window.bottom_offset +=
sps->vui.def_disp_win.bottom_offset;
1144 ow = &
sps->output_window;
1155 "Displaying the whole video surface.\n");
1156 memset(ow, 0,
sizeof(*ow));
1157 memset(&
sps->pic_conf_win, 0,
sizeof(
sps->pic_conf_win));
1161 sps->log2_ctb_size =
sps->log2_min_cb_size +
1162 sps->log2_diff_max_min_coding_block_size;
1163 sps->log2_min_pu_size =
sps->log2_min_cb_size - 1;
1169 if (
sps->log2_ctb_size < 4) {
1172 "log2_ctb_size %d differs from the bounds of any known profile\n",
1173 sps->log2_ctb_size);
1178 sps->ctb_width = (
sps->width + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1179 sps->ctb_height = (
sps->height + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1180 sps->ctb_size =
sps->ctb_width *
sps->ctb_height;
1182 sps->min_cb_width =
sps->width >>
sps->log2_min_cb_size;
1183 sps->min_cb_height =
sps->height >>
sps->log2_min_cb_size;
1184 sps->min_tb_width =
sps->width >>
sps->log2_min_tb_size;
1185 sps->min_tb_height =
sps->height >>
sps->log2_min_tb_size;
1186 sps->min_pu_width =
sps->width >>
sps->log2_min_pu_size;
1187 sps->min_pu_height =
sps->height >>
sps->log2_min_pu_size;
1188 sps->tb_mask = (1 << (
sps->log2_ctb_size -
sps->log2_min_tb_size)) - 1;
1190 sps->qp_bd_offset = 6 * (
sps->bit_depth - 8);
1192 if (av_mod_uintp2(
sps->width,
sps->log2_min_cb_size) ||
1193 av_mod_uintp2(
sps->height,
sps->log2_min_cb_size)) {
1198 if (
sps->max_transform_hierarchy_depth_inter >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1199 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_inter out of range: %d\n",
1200 sps->max_transform_hierarchy_depth_inter);
1203 if (
sps->max_transform_hierarchy_depth_intra >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1204 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_intra out of range: %d\n",
1205 sps->max_transform_hierarchy_depth_intra);
1208 if (
sps->log2_max_trafo_size >
FFMIN(
sps->log2_ctb_size, 5)) {
1210 "max transform block size out of range: %d\n",
1211 sps->log2_max_trafo_size);
1229 unsigned int sps_id;
1240 if (nal_size >
sizeof(
sps->data)) {
1243 nal_size,
sizeof(
sps->data));
1244 sps->data_size =
sizeof(
sps->data);
1246 sps->data_size = nal_size;
1260 "Parsed SPS: id %d; coded wxh: %dx%d; "
1261 "cropped wxh: %dx%d; pix_fmt: %s.\n",
1262 sps_id,
sps->width,
sps->height,
1263 sps->width - (
sps->output_window.left_offset +
sps->output_window.right_offset),
1264 sps->height - (
sps->output_window.top_offset +
sps->output_window.bottom_offset),
1304 if (
pps->transform_skip_enabled_flag) {
1307 pps->cross_component_prediction_enabled_flag =
get_bits1(gb);
1308 pps->chroma_qp_offset_list_enabled_flag =
get_bits1(gb);
1309 if (
pps->chroma_qp_offset_list_enabled_flag) {
1312 if (
pps->chroma_qp_offset_list_len_minus1 > 5) {
1314 "chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
1317 for (
i = 0;
i <=
pps->chroma_qp_offset_list_len_minus1;
i++) {
1319 if (
pps->cb_qp_offset_list[
i]) {
1321 "cb_qp_offset_list not tested yet.\n");
1324 if (
pps->cr_qp_offset_list[
i]) {
1326 "cb_qp_offset_list not tested yet.\n");
1333 if (
pps->log2_sao_offset_scale_luma >
FFMAX(
sps->bit_depth - 10, 0)
1334 ||
pps->log2_sao_offset_scale_chroma >
FFMAX(
sps->bit_depth_chroma - 10, 0)
1345 int pic_area_in_ctbs;
1346 int i, j, x, y, ctb_addr_rs, tile_id;
1352 if (!
pps->col_bd || !
pps->row_bd || !
pps->col_idxX)
1355 if (
pps->uniform_spacing_flag) {
1356 if (!
pps->column_width) {
1360 if (!
pps->column_width || !
pps->row_height)
1363 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1364 pps->column_width[
i] = ((
i + 1) *
sps->ctb_width) /
pps->num_tile_columns -
1365 (
i *
sps->ctb_width) /
pps->num_tile_columns;
1368 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1369 pps->row_height[
i] = ((
i + 1) *
sps->ctb_height) /
pps->num_tile_rows -
1370 (
i *
sps->ctb_height) /
pps->num_tile_rows;
1375 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1376 pps->col_bd[
i + 1] =
pps->col_bd[
i] +
pps->column_width[
i];
1379 for (
i = 0;
i <
pps->num_tile_rows;
i++)
1380 pps->row_bd[
i + 1] =
pps->row_bd[
i] +
pps->row_height[
i];
1382 for (
i = 0, j = 0;
i <
sps->ctb_width;
i++) {
1383 if (
i >
pps->col_bd[j])
1385 pps->col_idxX[
i] = j;
1391 pic_area_in_ctbs =
sps->ctb_width *
sps->ctb_height;
1397 if (!
pps->ctb_addr_rs_to_ts || !
pps->ctb_addr_ts_to_rs ||
1398 !
pps->tile_id || !
pps->min_tb_addr_zs_tab) {
1402 for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
1403 int tb_x = ctb_addr_rs %
sps->ctb_width;
1404 int tb_y = ctb_addr_rs /
sps->ctb_width;
1409 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1410 if (tb_x < pps->col_bd[
i + 1]) {
1416 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1417 if (tb_y < pps->row_bd[
i + 1]) {
1423 for (
i = 0;
i < tile_x;
i++)
1424 val +=
pps->row_height[tile_y] *
pps->column_width[
i];
1425 for (
i = 0;
i < tile_y;
i++)
1428 val += (tb_y -
pps->row_bd[tile_y]) *
pps->column_width[tile_x] +
1429 tb_x -
pps->col_bd[tile_x];
1431 pps->ctb_addr_rs_to_ts[ctb_addr_rs] =
val;
1432 pps->ctb_addr_ts_to_rs[
val] = ctb_addr_rs;
1435 for (j = 0, tile_id = 0; j <
pps->num_tile_rows; j++)
1436 for (
i = 0;
i <
pps->num_tile_columns;
i++, tile_id++)
1437 for (y =
pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
1438 for (x =
pps->col_bd[
i]; x < pps->col_bd[
i + 1]; x++)
1439 pps->tile_id[
pps->ctb_addr_rs_to_ts[y *
sps->ctb_width + x]] = tile_id;
1442 if (!
pps->tile_pos_rs)
1445 for (j = 0; j <
pps->num_tile_rows; j++)
1446 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1447 pps->tile_pos_rs[j *
pps->num_tile_columns +
i] =
1448 pps->row_bd[j] *
sps->ctb_width +
pps->col_bd[
i];
1450 log2_diff =
sps->log2_ctb_size -
sps->log2_min_tb_size;
1451 pps->min_tb_addr_zs = &
pps->min_tb_addr_zs_tab[1*(
sps->tb_mask+2)+1];
1452 for (y = 0; y <
sps->tb_mask+2; y++) {
1453 pps->min_tb_addr_zs_tab[y*(
sps->tb_mask+2)] = -1;
1454 pps->min_tb_addr_zs_tab[y] = -1;
1456 for (y = 0; y <
sps->tb_mask+1; y++) {
1457 for (x = 0; x <
sps->tb_mask+1; x++) {
1458 int tb_x = x >> log2_diff;
1459 int tb_y = y >> log2_diff;
1460 int rs =
sps->ctb_width * tb_y + tb_x;
1461 int val =
pps->ctb_addr_rs_to_ts[rs] << (log2_diff * 2);
1462 for (
i = 0;
i < log2_diff;
i++) {
1464 val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
1466 pps->min_tb_addr_zs[y * (
sps->tb_mask+2) + x] =
val;
1478 unsigned int pps_id = 0;
1480 unsigned log2_parallel_merge_level_minus2;
1498 if (nal_size >
sizeof(
pps->data)) {
1501 nal_size,
sizeof(
pps->data));
1502 pps->data_size =
sizeof(
pps->data);
1504 pps->data_size = nal_size;
1509 pps->loop_filter_across_tiles_enabled_flag = 1;
1510 pps->num_tile_columns = 1;
1511 pps->num_tile_rows = 1;
1512 pps->uniform_spacing_flag = 1;
1513 pps->disable_dbf = 0;
1514 pps->beta_offset = 0;
1516 pps->log2_max_transform_skip_block_size = 2;
1538 pps->dependent_slice_segments_enabled_flag =
get_bits1(gb);
1540 pps->num_extra_slice_header_bits =
get_bits(gb, 3);
1555 pps->diff_cu_qp_delta_depth = 0;
1556 if (
pps->cu_qp_delta_enabled_flag)
1559 if (
pps->diff_cu_qp_delta_depth < 0 ||
1560 pps->diff_cu_qp_delta_depth >
sps->log2_diff_max_min_coding_block_size) {
1562 pps->diff_cu_qp_delta_depth);
1568 if (
pps->cb_qp_offset < -12 ||
pps->cb_qp_offset > 12) {
1575 if (
pps->cr_qp_offset < -12 ||
pps->cr_qp_offset > 12) {
1581 pps->pic_slice_level_chroma_qp_offsets_present_flag =
get_bits1(gb);
1590 if (
pps->tiles_enabled_flag) {
1594 if (num_tile_columns_minus1 < 0 ||
1595 num_tile_columns_minus1 >=
sps->ctb_width) {
1597 num_tile_columns_minus1);
1601 if (num_tile_rows_minus1 < 0 ||
1602 num_tile_rows_minus1 >=
sps->ctb_height) {
1604 num_tile_rows_minus1);
1608 pps->num_tile_columns = num_tile_columns_minus1 + 1;
1609 pps->num_tile_rows = num_tile_rows_minus1 + 1;
1613 if (!
pps->column_width || !
pps->row_height) {
1619 if (!
pps->uniform_spacing_flag) {
1621 for (
i = 0;
i <
pps->num_tile_columns - 1;
i++) {
1623 sum +=
pps->column_width[
i];
1625 if (sum >=
sps->ctb_width) {
1630 pps->column_width[
pps->num_tile_columns - 1] =
sps->ctb_width - sum;
1633 for (
i = 0;
i <
pps->num_tile_rows - 1;
i++) {
1635 sum +=
pps->row_height[
i];
1637 if (sum >=
sps->ctb_height) {
1642 pps->row_height[
pps->num_tile_rows - 1] =
sps->ctb_height - sum;
1644 pps->loop_filter_across_tiles_enabled_flag =
get_bits1(gb);
1647 pps->seq_loop_filter_across_slices_enabled_flag =
get_bits1(gb);
1649 pps->deblocking_filter_control_present_flag =
get_bits1(gb);
1650 if (
pps->deblocking_filter_control_present_flag) {
1651 pps->deblocking_filter_override_enabled_flag =
get_bits1(gb);
1653 if (!
pps->disable_dbf) {
1656 if (beta_offset_div2 < -6 || beta_offset_div2 > 6) {
1662 if (tc_offset_div2 < -6 || tc_offset_div2 > 6) {
1668 pps->beta_offset = 2 * beta_offset_div2;
1669 pps->tc_offset = 2 * tc_offset_div2;
1674 if (
pps->scaling_list_data_present_flag) {
1682 if (log2_parallel_merge_level_minus2 >
sps->log2_ctb_size) {
1684 log2_parallel_merge_level_minus2);
1688 pps->log2_parallel_merge_level = log2_parallel_merge_level_minus2 + 2;
1690 pps->slice_header_extension_present_flag =
get_bits1(gb);
1739 int max_poc_lsb = 1 <<
sps->log2_max_poc_lsb;
1740 int prev_poc_lsb = pocTid0 % max_poc_lsb;
1741 int prev_poc_msb = pocTid0 - prev_poc_lsb;
1744 if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
1745 poc_msb = prev_poc_msb + max_poc_lsb;
1746 else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 2)
1747 poc_msb = prev_poc_msb - max_poc_lsb;
1749 poc_msb = prev_poc_msb;
1757 return poc_msb + poc_lsb;