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;
298 #define check_profile_idc(idc) \
299 ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]
334 #undef check_profile_idc
340 PTL *
ptl,
int max_num_sub_layers)
344 get_bits_left(gb) < 8 + (8*2 * (max_num_sub_layers - 1 > 0))) {
351 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
356 if (max_num_sub_layers - 1> 0)
357 for (
i = max_num_sub_layers - 1;
i < 8;
i++)
359 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
363 "PTL information for sublayer %i too short\n",
i);
369 "Not enough data for sublayer %i level_idc\n",
i);
380 int subpic_params_present)
384 for (
i = 0;
i < nb_cpb;
i++) {
388 if (subpic_params_present) {
399 int nal_params_present = 0, vcl_params_present = 0;
400 int subpic_params_present = 0;
403 if (common_inf_present) {
407 if (nal_params_present || vcl_params_present) {
410 if (subpic_params_present) {
420 if (subpic_params_present)
429 for (
i = 0;
i < max_sublayers;
i++) {
431 unsigned int nb_cpb = 1;
444 if (nb_cpb < 1 || nb_cpb > 32) {
450 if (nal_params_present)
452 if (vcl_params_present)
474 if (nal_size >
sizeof(
vps->data)) {
477 nal_size,
sizeof(
vps->data));
478 vps->data_size =
sizeof(
vps->data);
480 vps->data_size = nal_size;
502 vps->vps_max_sub_layers);
509 vps->vps_sub_layer_ordering_info_present_flag =
get_bits1(gb);
511 i =
vps->vps_sub_layer_ordering_info_present_flag ? 0 :
vps->vps_max_sub_layers - 1;
512 for (;
i <
vps->vps_max_sub_layers;
i++) {
519 vps->vps_max_dec_pic_buffering[
i] - 1);
522 if (
vps->vps_num_reorder_pics[
i] >
vps->vps_max_dec_pic_buffering[
i] - 1) {
524 vps->vps_num_reorder_pics[
i]);
532 if (
vps->vps_num_layer_sets < 1 ||
vps->vps_num_layer_sets > 1024 ||
538 for (
i = 1;
i <
vps->vps_num_layer_sets;
i++)
539 for (j = 0; j <=
vps->vps_max_layer_id; j++)
543 if (
vps->vps_timing_info_present_flag) {
546 vps->vps_poc_proportional_to_timing_flag =
get_bits1(gb);
547 if (
vps->vps_poc_proportional_to_timing_flag)
550 if (
vps->vps_num_hrd_parameters > (
unsigned)
vps->vps_num_layer_sets) {
552 "vps_num_hrd_parameters %d is invalid\n",
vps->vps_num_hrd_parameters);
555 for (
i = 0;
i <
vps->vps_num_hrd_parameters;
i++) {
556 int common_inf_present = 1;
591 VUI backup_vui, *vui = &
sps->vui;
593 int sar_present, alt = 0;
602 else if (sar_idx == 255) {
607 "Unknown SAR index: %u.\n", sar_idx);
634 switch (
sps->pix_fmt) {
660 memcpy(&backup, gb,
sizeof(backup));
661 memcpy(&backup_vui, vui,
sizeof(backup_vui));
676 if (apply_defdispwin &&
679 "discarding vui default display window, "
680 "original values are l:%u r:%u t:%u b:%u\n",
701 "Strange VUI timing information, retrying...\n");
702 memcpy(vui, &backup_vui,
sizeof(backup_vui));
703 memcpy(gb, &backup,
sizeof(backup));
725 "Strange VUI bitstream restriction information, retrying"
726 " from timing information...\n");
727 memcpy(vui, &backup_vui,
sizeof(backup_vui));
728 memcpy(gb, &backup,
sizeof(backup));
745 "Overread in VUI, retrying from timing information...\n");
746 memcpy(vui, &backup_vui,
sizeof(backup_vui));
747 memcpy(gb, &backup,
sizeof(backup));
757 for (matrixId = 0; matrixId < 6; matrixId++) {
759 memset(sl->
sl[0][matrixId], 16, 16);
760 sl->
sl_dc[0][matrixId] = 16;
761 sl->
sl_dc[1][matrixId] = 16;
785 uint8_t scaling_list_pred_mode_flag;
786 uint8_t scaling_list_dc_coef[2][6];
787 int size_id, matrix_id,
pos;
790 for (size_id = 0; size_id < 4; size_id++)
791 for (matrix_id = 0; matrix_id < 6; matrix_id += ((size_id == 3) ? 3 : 1)) {
792 scaling_list_pred_mode_flag =
get_bits1(gb);
793 if (!scaling_list_pred_mode_flag) {
799 delta *= (size_id == 3) ? 3 : 1;
800 if (matrix_id <
delta) {
802 "Invalid delta in scaling list data: %d.\n",
delta);
806 memcpy(sl->
sl[size_id][matrix_id],
807 sl->
sl[size_id][matrix_id -
delta],
808 size_id > 0 ? 64 : 16);
810 sl->
sl_dc[size_id - 2][matrix_id] = sl->
sl_dc[size_id - 2][matrix_id -
delta];
813 int next_coef, coef_num;
814 int32_t scaling_list_delta_coef;
817 coef_num =
FFMIN(64, 1 << (4 + (size_id << 1)));
820 if (scaling_list_coeff_minus8 < -7 ||
821 scaling_list_coeff_minus8 > 247)
823 scaling_list_dc_coef[size_id - 2][matrix_id] = scaling_list_coeff_minus8 + 8;
824 next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
825 sl->
sl_dc[size_id - 2][matrix_id] = next_coef;
827 for (
i = 0;
i < coef_num;
i++) {
836 next_coef = (next_coef + 256
U + scaling_list_delta_coef) % 256;
837 sl->
sl[size_id][matrix_id][
pos] = next_coef;
842 if (
sps->chroma_format_idc == 3) {
843 for (
i = 0;
i < 64;
i++) {
844 sl->
sl[3][1][
i] = sl->
sl[2][1][
i];
845 sl->
sl[3][2][
i] = sl->
sl[2][2][
i];
846 sl->
sl[3][4][
i] = sl->
sl[2][4][
i];
847 sl->
sl[3][5][
i] = sl->
sl[2][5][
i];
862 switch (
sps->bit_depth) {
889 "The following bit-depths are currently specified: 8, 9, 10 and 12 bits, "
890 "chroma_format_idc is %d, depth is %d\n",
891 sps->chroma_format_idc,
sps->bit_depth);
899 sps->hshift[0] =
sps->vshift[0] = 0;
900 sps->hshift[2] =
sps->hshift[1] =
desc->log2_chroma_w;
901 sps->vshift[2] =
sps->vshift[1] =
desc->log2_chroma_h;
903 sps->pixel_shift =
sps->bit_depth > 8;
913 int log2_diff_max_min_transform_block_size;
914 int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
921 if (vps_list && !vps_list[
sps->vps_id]) {
930 sps->max_sub_layers);
946 if (
sps->chroma_format_idc > 3
U) {
951 if (
sps->chroma_format_idc == 3)
954 if (
sps->separate_colour_plane_flag)
955 sps->chroma_format_idc = 0;
960 sps->height, 0, avctx)) < 0)
973 "discarding sps conformance window, "
974 "original values are l:%u r:%u t:%u b:%u\n",
975 sps->pic_conf_win.left_offset,
976 sps->pic_conf_win.right_offset,
977 sps->pic_conf_win.top_offset,
978 sps->pic_conf_win.bottom_offset);
980 sps->pic_conf_win.left_offset =
981 sps->pic_conf_win.right_offset =
982 sps->pic_conf_win.top_offset =
983 sps->pic_conf_win.bottom_offset = 0;
985 sps->output_window =
sps->pic_conf_win;
990 if (
sps->chroma_format_idc && bit_depth_chroma !=
sps->bit_depth) {
992 "Luma bit depth (%d) is different from chroma bit depth (%d), "
993 "this is unsupported.\n",
994 sps->bit_depth, bit_depth_chroma);
997 sps->bit_depth_chroma = bit_depth_chroma;
1004 if (
sps->log2_max_poc_lsb > 16) {
1006 sps->log2_max_poc_lsb - 4);
1011 start = sublayer_ordering_info ? 0 :
sps->max_sub_layers - 1;
1012 for (
i = start;
i <
sps->max_sub_layers;
i++) {
1018 sps->temporal_layer[
i].max_dec_pic_buffering - 1
U);
1021 if (
sps->temporal_layer[
i].num_reorder_pics >
sps->temporal_layer[
i].max_dec_pic_buffering - 1) {
1023 sps->temporal_layer[
i].num_reorder_pics);
1028 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[
i].num_reorder_pics + 1;
1032 if (!sublayer_ordering_info) {
1033 for (
i = 0;
i < start;
i++) {
1034 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[start].max_dec_pic_buffering;
1035 sps->temporal_layer[
i].num_reorder_pics =
sps->temporal_layer[start].num_reorder_pics;
1036 sps->temporal_layer[
i].max_latency_increase =
sps->temporal_layer[start].max_latency_increase;
1044 sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size +
1045 sps->log2_min_tb_size;
1047 if (
sps->log2_min_cb_size < 3 ||
sps->log2_min_cb_size > 30) {
1052 if (
sps->log2_diff_max_min_coding_block_size > 30) {
1053 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);
1057 if (
sps->log2_min_tb_size >=
sps->log2_min_cb_size ||
sps->log2_min_tb_size < 2) {
1062 if (log2_diff_max_min_transform_block_size < 0 || log2_diff_max_min_transform_block_size > 30) {
1063 av_log(avctx,
AV_LOG_ERROR,
"Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size);
1071 if (
sps->scaling_list_enable_flag) {
1085 if (
sps->pcm_enabled_flag) {
1089 sps->pcm.log2_max_pcm_cb_size =
sps->pcm.log2_min_pcm_cb_size +
1091 if (
FFMAX(
sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma) >
sps->bit_depth) {
1093 "PCM bit depth (%d, %d) is greater than normal bit depth (%d)\n",
1094 sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma,
sps->bit_depth);
1107 for (
i = 0;
i <
sps->nb_st_rps;
i++) {
1114 if (
sps->long_term_ref_pics_present_flag) {
1118 sps->num_long_term_ref_pics_sps);
1121 for (
i = 0;
i <
sps->num_long_term_ref_pics_sps;
i++) {
1128 sps->sps_strong_intra_smoothing_enable_flag =
get_bits1(gb);
1137 if (
sps->sps_range_extension_flag) {
1138 sps->transform_skip_rotation_enabled_flag =
get_bits1(gb);
1139 sps->transform_skip_context_enabled_flag =
get_bits1(gb);
1144 sps->extended_precision_processing_flag =
get_bits1(gb);
1145 if (
sps->extended_precision_processing_flag)
1147 "extended_precision_processing_flag not yet implemented\n");
1150 sps->high_precision_offsets_enabled_flag =
get_bits1(gb);
1151 if (
sps->high_precision_offsets_enabled_flag)
1153 "high_precision_offsets_enabled_flag not yet implemented\n");
1155 sps->persistent_rice_adaptation_enabled_flag =
get_bits1(gb);
1157 sps->cabac_bypass_alignment_enabled_flag =
get_bits1(gb);
1158 if (
sps->cabac_bypass_alignment_enabled_flag)
1160 "cabac_bypass_alignment_enabled_flag not yet implemented\n");
1163 if (apply_defdispwin) {
1164 sps->output_window.left_offset +=
sps->vui.def_disp_win.left_offset;
1165 sps->output_window.right_offset +=
sps->vui.def_disp_win.right_offset;
1166 sps->output_window.top_offset +=
sps->vui.def_disp_win.top_offset;
1167 sps->output_window.bottom_offset +=
sps->vui.def_disp_win.bottom_offset;
1170 ow = &
sps->output_window;
1181 "Displaying the whole video surface.\n");
1182 memset(ow, 0,
sizeof(*ow));
1183 memset(&
sps->pic_conf_win, 0,
sizeof(
sps->pic_conf_win));
1187 sps->log2_ctb_size =
sps->log2_min_cb_size +
1188 sps->log2_diff_max_min_coding_block_size;
1189 sps->log2_min_pu_size =
sps->log2_min_cb_size - 1;
1195 if (
sps->log2_ctb_size < 4) {
1198 "log2_ctb_size %d differs from the bounds of any known profile\n",
1199 sps->log2_ctb_size);
1204 sps->ctb_width = (
sps->width + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1205 sps->ctb_height = (
sps->height + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1206 sps->ctb_size =
sps->ctb_width *
sps->ctb_height;
1208 sps->min_cb_width =
sps->width >>
sps->log2_min_cb_size;
1209 sps->min_cb_height =
sps->height >>
sps->log2_min_cb_size;
1210 sps->min_tb_width =
sps->width >>
sps->log2_min_tb_size;
1211 sps->min_tb_height =
sps->height >>
sps->log2_min_tb_size;
1212 sps->min_pu_width =
sps->width >>
sps->log2_min_pu_size;
1213 sps->min_pu_height =
sps->height >>
sps->log2_min_pu_size;
1214 sps->tb_mask = (1 << (
sps->log2_ctb_size -
sps->log2_min_tb_size)) - 1;
1216 sps->qp_bd_offset = 6 * (
sps->bit_depth - 8);
1224 if (
sps->max_transform_hierarchy_depth_inter >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1225 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_inter out of range: %d\n",
1226 sps->max_transform_hierarchy_depth_inter);
1229 if (
sps->max_transform_hierarchy_depth_intra >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1230 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_intra out of range: %d\n",
1231 sps->max_transform_hierarchy_depth_intra);
1234 if (
sps->log2_max_trafo_size >
FFMIN(
sps->log2_ctb_size, 5)) {
1236 "max transform block size out of range: %d\n",
1237 sps->log2_max_trafo_size);
1255 unsigned int sps_id;
1266 if (nal_size >
sizeof(
sps->data)) {
1269 nal_size,
sizeof(
sps->data));
1270 sps->data_size =
sizeof(
sps->data);
1272 sps->data_size = nal_size;
1286 "Parsed SPS: id %d; coded wxh: %dx%d; "
1287 "cropped wxh: %dx%d; pix_fmt: %s.\n",
1288 sps_id,
sps->width,
sps->height,
1289 sps->width - (
sps->output_window.left_offset +
sps->output_window.right_offset),
1290 sps->height - (
sps->output_window.top_offset +
sps->output_window.bottom_offset),
1330 if (
pps->transform_skip_enabled_flag) {
1333 pps->cross_component_prediction_enabled_flag =
get_bits1(gb);
1334 pps->chroma_qp_offset_list_enabled_flag =
get_bits1(gb);
1335 if (
pps->chroma_qp_offset_list_enabled_flag) {
1338 if (
pps->chroma_qp_offset_list_len_minus1 > 5) {
1340 "chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
1343 for (
i = 0;
i <=
pps->chroma_qp_offset_list_len_minus1;
i++) {
1345 if (
pps->cb_qp_offset_list[
i]) {
1347 "cb_qp_offset_list not tested yet.\n");
1350 if (
pps->cr_qp_offset_list[
i]) {
1352 "cb_qp_offset_list not tested yet.\n");
1359 if (
pps->log2_sao_offset_scale_luma >
FFMAX(
sps->bit_depth - 10, 0)
1360 ||
pps->log2_sao_offset_scale_chroma >
FFMAX(
sps->bit_depth_chroma - 10, 0)
1371 int pic_area_in_ctbs;
1372 int i, j, x, y, ctb_addr_rs, tile_id;
1378 if (!
pps->col_bd || !
pps->row_bd || !
pps->col_idxX)
1381 if (
pps->uniform_spacing_flag) {
1382 if (!
pps->column_width) {
1386 if (!
pps->column_width || !
pps->row_height)
1389 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1390 pps->column_width[
i] = ((
i + 1) *
sps->ctb_width) /
pps->num_tile_columns -
1391 (
i *
sps->ctb_width) /
pps->num_tile_columns;
1394 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1395 pps->row_height[
i] = ((
i + 1) *
sps->ctb_height) /
pps->num_tile_rows -
1396 (
i *
sps->ctb_height) /
pps->num_tile_rows;
1401 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1402 pps->col_bd[
i + 1] =
pps->col_bd[
i] +
pps->column_width[
i];
1405 for (
i = 0;
i <
pps->num_tile_rows;
i++)
1406 pps->row_bd[
i + 1] =
pps->row_bd[
i] +
pps->row_height[
i];
1408 for (
i = 0, j = 0;
i <
sps->ctb_width;
i++) {
1409 if (
i >
pps->col_bd[j])
1411 pps->col_idxX[
i] = j;
1417 pic_area_in_ctbs =
sps->ctb_width *
sps->ctb_height;
1423 if (!
pps->ctb_addr_rs_to_ts || !
pps->ctb_addr_ts_to_rs ||
1424 !
pps->tile_id || !
pps->min_tb_addr_zs_tab) {
1428 for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
1429 int tb_x = ctb_addr_rs %
sps->ctb_width;
1430 int tb_y = ctb_addr_rs /
sps->ctb_width;
1435 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1436 if (tb_x < pps->col_bd[
i + 1]) {
1442 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1443 if (tb_y < pps->row_bd[
i + 1]) {
1449 for (
i = 0;
i < tile_x;
i++)
1450 val +=
pps->row_height[tile_y] *
pps->column_width[
i];
1451 for (
i = 0;
i < tile_y;
i++)
1454 val += (tb_y -
pps->row_bd[tile_y]) *
pps->column_width[tile_x] +
1455 tb_x -
pps->col_bd[tile_x];
1457 pps->ctb_addr_rs_to_ts[ctb_addr_rs] =
val;
1458 pps->ctb_addr_ts_to_rs[
val] = ctb_addr_rs;
1461 for (j = 0, tile_id = 0; j <
pps->num_tile_rows; j++)
1462 for (
i = 0;
i <
pps->num_tile_columns;
i++, tile_id++)
1463 for (y =
pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
1464 for (x =
pps->col_bd[
i]; x < pps->col_bd[
i + 1]; x++)
1465 pps->tile_id[
pps->ctb_addr_rs_to_ts[y *
sps->ctb_width + x]] = tile_id;
1468 if (!
pps->tile_pos_rs)
1471 for (j = 0; j <
pps->num_tile_rows; j++)
1472 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1473 pps->tile_pos_rs[j *
pps->num_tile_columns +
i] =
1474 pps->row_bd[j] *
sps->ctb_width +
pps->col_bd[
i];
1476 log2_diff =
sps->log2_ctb_size -
sps->log2_min_tb_size;
1477 pps->min_tb_addr_zs = &
pps->min_tb_addr_zs_tab[1*(
sps->tb_mask+2)+1];
1478 for (y = 0; y <
sps->tb_mask+2; y++) {
1479 pps->min_tb_addr_zs_tab[y*(
sps->tb_mask+2)] = -1;
1480 pps->min_tb_addr_zs_tab[y] = -1;
1482 for (y = 0; y <
sps->tb_mask+1; y++) {
1483 for (x = 0; x <
sps->tb_mask+1; x++) {
1484 int tb_x = x >> log2_diff;
1485 int tb_y = y >> log2_diff;
1486 int rs =
sps->ctb_width * tb_y + tb_x;
1487 int val =
pps->ctb_addr_rs_to_ts[rs] << (log2_diff * 2);
1488 for (
i = 0;
i < log2_diff;
i++) {
1490 val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
1492 pps->min_tb_addr_zs[y * (
sps->tb_mask+2) + x] =
val;
1504 unsigned int pps_id = 0;
1506 unsigned log2_parallel_merge_level_minus2;
1524 if (nal_size >
sizeof(
pps->data)) {
1527 nal_size,
sizeof(
pps->data));
1528 pps->data_size =
sizeof(
pps->data);
1530 pps->data_size = nal_size;
1535 pps->loop_filter_across_tiles_enabled_flag = 1;
1536 pps->num_tile_columns = 1;
1537 pps->num_tile_rows = 1;
1538 pps->uniform_spacing_flag = 1;
1539 pps->disable_dbf = 0;
1540 pps->beta_offset = 0;
1542 pps->log2_max_transform_skip_block_size = 2;
1564 pps->dependent_slice_segments_enabled_flag =
get_bits1(gb);
1566 pps->num_extra_slice_header_bits =
get_bits(gb, 3);
1581 pps->diff_cu_qp_delta_depth = 0;
1582 if (
pps->cu_qp_delta_enabled_flag)
1585 if (
pps->diff_cu_qp_delta_depth < 0 ||
1586 pps->diff_cu_qp_delta_depth >
sps->log2_diff_max_min_coding_block_size) {
1588 pps->diff_cu_qp_delta_depth);
1594 if (
pps->cb_qp_offset < -12 ||
pps->cb_qp_offset > 12) {
1601 if (
pps->cr_qp_offset < -12 ||
pps->cr_qp_offset > 12) {
1607 pps->pic_slice_level_chroma_qp_offsets_present_flag =
get_bits1(gb);
1616 if (
pps->tiles_enabled_flag) {
1620 if (num_tile_columns_minus1 < 0 ||
1621 num_tile_columns_minus1 >=
sps->ctb_width) {
1623 num_tile_columns_minus1);
1627 if (num_tile_rows_minus1 < 0 ||
1628 num_tile_rows_minus1 >=
sps->ctb_height) {
1630 num_tile_rows_minus1);
1634 pps->num_tile_columns = num_tile_columns_minus1 + 1;
1635 pps->num_tile_rows = num_tile_rows_minus1 + 1;
1639 if (!
pps->column_width || !
pps->row_height) {
1645 if (!
pps->uniform_spacing_flag) {
1647 for (
i = 0;
i <
pps->num_tile_columns - 1;
i++) {
1649 sum +=
pps->column_width[
i];
1651 if (sum >=
sps->ctb_width) {
1656 pps->column_width[
pps->num_tile_columns - 1] =
sps->ctb_width - sum;
1659 for (
i = 0;
i <
pps->num_tile_rows - 1;
i++) {
1661 sum +=
pps->row_height[
i];
1663 if (sum >=
sps->ctb_height) {
1668 pps->row_height[
pps->num_tile_rows - 1] =
sps->ctb_height - sum;
1670 pps->loop_filter_across_tiles_enabled_flag =
get_bits1(gb);
1673 pps->seq_loop_filter_across_slices_enabled_flag =
get_bits1(gb);
1675 pps->deblocking_filter_control_present_flag =
get_bits1(gb);
1676 if (
pps->deblocking_filter_control_present_flag) {
1677 pps->deblocking_filter_override_enabled_flag =
get_bits1(gb);
1679 if (!
pps->disable_dbf) {
1682 if (beta_offset_div2 < -6 || beta_offset_div2 > 6) {
1688 if (tc_offset_div2 < -6 || tc_offset_div2 > 6) {
1694 pps->beta_offset = 2 * beta_offset_div2;
1695 pps->tc_offset = 2 * tc_offset_div2;
1700 if (
pps->scaling_list_data_present_flag) {
1708 if (log2_parallel_merge_level_minus2 >
sps->log2_ctb_size) {
1710 log2_parallel_merge_level_minus2);
1714 pps->log2_parallel_merge_level = log2_parallel_merge_level_minus2 + 2;
1716 pps->slice_header_extension_present_flag =
get_bits1(gb);
1765 int max_poc_lsb = 1 <<
sps->log2_max_poc_lsb;
1766 int prev_poc_lsb = pocTid0 % max_poc_lsb;
1767 int prev_poc_msb = pocTid0 - prev_poc_lsb;
1770 if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
1771 poc_msb = prev_poc_msb + max_poc_lsb;
1772 else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 2)
1773 poc_msb = prev_poc_msb - max_poc_lsb;
1775 poc_msb = prev_poc_msb;
1783 return poc_msb + poc_lsb;