33 16, 16, 16, 16, 17, 18, 21, 24,
34 16, 16, 16, 16, 17, 19, 22, 25,
35 16, 16, 17, 18, 20, 22, 25, 29,
36 16, 16, 18, 21, 24, 27, 31, 36,
37 17, 17, 20, 24, 30, 35, 41, 47,
38 18, 19, 22, 27, 35, 44, 54, 65,
39 21, 22, 25, 31, 41, 54, 70, 88,
40 24, 25, 29, 36, 47, 65, 88, 115
44 16, 16, 16, 16, 17, 18, 20, 24,
45 16, 16, 16, 17, 18, 20, 24, 25,
46 16, 16, 17, 18, 20, 24, 25, 28,
47 16, 17, 18, 20, 24, 25, 28, 33,
48 17, 18, 20, 24, 25, 28, 33, 41,
49 18, 20, 24, 25, 28, 33, 41, 54,
50 20, 24, 25, 28, 33, 41, 54, 71,
51 24, 25, 28, 33, 41, 54, 71, 91
64 if (
s->pps_list[
id] &&
s->pps == (
const HEVCPPS*)
s->pps_list[
id]->data)
72 if (
s->sps_list[
id]) {
73 if (
s->sps == (
const HEVCSPS*)
s->sps_list[
id]->data)
78 if (
s->pps_list[
i] && ((
HEVCPPS*)
s->pps_list[
i]->data)->sps_id ==
id)
89 if (
s->vps_list[
id]) {
90 if (
s->vps == (
const HEVCVPS*)
s->vps_list[
id]->data)
94 if (
s->sps_list[
i] && ((
HEVCSPS*)
s->sps_list[
i]->data)->vps_id ==
id)
103 uint8_t rps_predict = 0;
109 if (rps !=
sps->st_rps &&
sps->nb_st_rps)
115 unsigned abs_delta_rps;
116 uint8_t use_delta_flag = 0;
117 uint8_t delta_rps_sign;
119 if (is_slice_header) {
121 if (delta_idx >
sps->nb_st_rps) {
123 "Invalid value of delta_idx in slice header RPS: %d > %d.\n",
124 delta_idx,
sps->nb_st_rps);
127 rps_ridx = &
sps->st_rps[
sps->nb_st_rps - delta_idx];
130 rps_ridx = &
sps->st_rps[rps -
sps->st_rps - 1];
134 if (abs_delta_rps < 1 || abs_delta_rps > 32768) {
136 "Invalid value of abs_delta_rps: %d\n",
140 delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
147 if (used || use_delta_flag) {
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",
265 for (
i = 0;
i < 32;
i++) {
268 if (
ptl->profile_idc == 0 &&
i > 0 &&
ptl->profile_compatibility_flag[
i])
269 ptl->profile_idc =
i;
276 #define check_profile_idc(idc) \
277 ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]
312 #undef check_profile_idc
318 PTL *
ptl,
int max_num_sub_layers)
322 get_bits_left(gb) < 8 + (8*2 * (max_num_sub_layers - 1 > 0))) {
329 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
334 if (max_num_sub_layers - 1> 0)
335 for (
i = max_num_sub_layers - 1;
i < 8;
i++)
337 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
341 "PTL information for sublayer %i too short\n",
i);
347 "Not enough data for sublayer %i level_idc\n",
i);
358 int subpic_params_present)
362 for (
i = 0;
i < nb_cpb;
i++) {
366 if (subpic_params_present) {
377 int nal_params_present = 0, vcl_params_present = 0;
378 int subpic_params_present = 0;
381 if (common_inf_present) {
385 if (nal_params_present || vcl_params_present) {
388 if (subpic_params_present) {
398 if (subpic_params_present)
407 for (
i = 0;
i < max_sublayers;
i++) {
409 unsigned int nb_cpb = 1;
422 if (nb_cpb < 1 || nb_cpb > 32) {
428 if (nal_params_present)
430 if (vcl_params_present)
452 if (nal_size >
sizeof(
vps->data)) {
455 nal_size,
sizeof(
vps->data));
456 vps->data_size =
sizeof(
vps->data);
458 vps->data_size = nal_size;
480 vps->vps_max_sub_layers);
487 vps->vps_sub_layer_ordering_info_present_flag =
get_bits1(gb);
489 i =
vps->vps_sub_layer_ordering_info_present_flag ? 0 :
vps->vps_max_sub_layers - 1;
490 for (;
i <
vps->vps_max_sub_layers;
i++) {
497 vps->vps_max_dec_pic_buffering[
i] - 1);
500 if (
vps->vps_num_reorder_pics[
i] >
vps->vps_max_dec_pic_buffering[
i] - 1) {
502 vps->vps_num_reorder_pics[
i]);
510 if (
vps->vps_num_layer_sets < 1 ||
vps->vps_num_layer_sets > 1024 ||
516 for (
i = 1;
i <
vps->vps_num_layer_sets;
i++)
517 for (j = 0; j <=
vps->vps_max_layer_id; j++)
521 if (
vps->vps_timing_info_present_flag) {
524 vps->vps_poc_proportional_to_timing_flag =
get_bits1(gb);
525 if (
vps->vps_poc_proportional_to_timing_flag)
528 if (
vps->vps_num_hrd_parameters > (
unsigned)
vps->vps_num_layer_sets) {
530 "vps_num_hrd_parameters %d is invalid\n",
vps->vps_num_hrd_parameters);
533 for (
i = 0;
i <
vps->vps_num_hrd_parameters;
i++) {
534 int common_inf_present = 1;
569 VUI backup_vui, *vui = &
sps->vui;
580 switch (
sps->pix_fmt) {
600 memcpy(&backup, gb,
sizeof(backup));
601 memcpy(&backup_vui, vui,
sizeof(backup_vui));
616 if (apply_defdispwin &&
619 "discarding vui default display window, "
620 "original values are l:%u r:%u t:%u b:%u\n",
641 "Strange VUI timing information, retrying...\n");
642 memcpy(vui, &backup_vui,
sizeof(backup_vui));
643 memcpy(gb, &backup,
sizeof(backup));
665 "Strange VUI bitstream restriction information, retrying"
666 " from timing information...\n");
667 memcpy(vui, &backup_vui,
sizeof(backup_vui));
668 memcpy(gb, &backup,
sizeof(backup));
685 "Overread in VUI, retrying from timing information...\n");
686 memcpy(vui, &backup_vui,
sizeof(backup_vui));
687 memcpy(gb, &backup,
sizeof(backup));
697 for (matrixId = 0; matrixId < 6; matrixId++) {
699 memset(sl->
sl[0][matrixId], 16, 16);
700 sl->
sl_dc[0][matrixId] = 16;
701 sl->
sl_dc[1][matrixId] = 16;
725 uint8_t scaling_list_pred_mode_flag;
726 uint8_t scaling_list_dc_coef[2][6];
727 int size_id, matrix_id,
pos;
730 for (size_id = 0; size_id < 4; size_id++)
731 for (matrix_id = 0; matrix_id < 6; matrix_id += ((size_id == 3) ? 3 : 1)) {
732 scaling_list_pred_mode_flag =
get_bits1(gb);
733 if (!scaling_list_pred_mode_flag) {
739 delta *= (size_id == 3) ? 3 : 1;
740 if (matrix_id <
delta) {
742 "Invalid delta in scaling list data: %d.\n",
delta);
746 memcpy(sl->
sl[size_id][matrix_id],
747 sl->
sl[size_id][matrix_id -
delta],
748 size_id > 0 ? 64 : 16);
750 sl->
sl_dc[size_id - 2][matrix_id] = sl->
sl_dc[size_id - 2][matrix_id -
delta];
753 int next_coef, coef_num;
754 int32_t scaling_list_delta_coef;
757 coef_num =
FFMIN(64, 1 << (4 + (size_id << 1)));
760 if (scaling_list_coeff_minus8 < -7 ||
761 scaling_list_coeff_minus8 > 247)
763 scaling_list_dc_coef[size_id - 2][matrix_id] = scaling_list_coeff_minus8 + 8;
764 next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
765 sl->
sl_dc[size_id - 2][matrix_id] = next_coef;
767 for (
i = 0;
i < coef_num;
i++) {
776 next_coef = (next_coef + 256
U + scaling_list_delta_coef) % 256;
777 sl->
sl[size_id][matrix_id][
pos] = next_coef;
782 if (
sps->chroma_format_idc == 3) {
783 for (
i = 0;
i < 64;
i++) {
784 sl->
sl[3][1][
i] = sl->
sl[2][1][
i];
785 sl->
sl[3][2][
i] = sl->
sl[2][2][
i];
786 sl->
sl[3][4][
i] = sl->
sl[2][4][
i];
787 sl->
sl[3][5][
i] = sl->
sl[2][5][
i];
802 switch (
sps->bit_depth) {
829 "The following bit-depths are currently specified: 8, 9, 10 and 12 bits, "
830 "chroma_format_idc is %d, depth is %d\n",
831 sps->chroma_format_idc,
sps->bit_depth);
839 sps->hshift[0] =
sps->vshift[0] = 0;
840 sps->hshift[2] =
sps->hshift[1] =
desc->log2_chroma_w;
841 sps->vshift[2] =
sps->vshift[1] =
desc->log2_chroma_h;
843 sps->pixel_shift =
sps->bit_depth > 8;
853 int log2_diff_max_min_transform_block_size;
854 int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
861 if (vps_list && !vps_list[
sps->vps_id]) {
870 sps->max_sub_layers);
886 if (
sps->chroma_format_idc > 3
U) {
891 if (
sps->chroma_format_idc == 3)
894 if (
sps->separate_colour_plane_flag)
895 sps->chroma_format_idc = 0;
900 sps->height, 0, avctx)) < 0)
913 "discarding sps conformance window, "
914 "original values are l:%u r:%u t:%u b:%u\n",
915 sps->pic_conf_win.left_offset,
916 sps->pic_conf_win.right_offset,
917 sps->pic_conf_win.top_offset,
918 sps->pic_conf_win.bottom_offset);
920 sps->pic_conf_win.left_offset =
921 sps->pic_conf_win.right_offset =
922 sps->pic_conf_win.top_offset =
923 sps->pic_conf_win.bottom_offset = 0;
925 sps->output_window =
sps->pic_conf_win;
930 if (
sps->chroma_format_idc && bit_depth_chroma !=
sps->bit_depth) {
932 "Luma bit depth (%d) is different from chroma bit depth (%d), "
933 "this is unsupported.\n",
934 sps->bit_depth, bit_depth_chroma);
937 sps->bit_depth_chroma = bit_depth_chroma;
944 if (
sps->log2_max_poc_lsb > 16) {
946 sps->log2_max_poc_lsb - 4);
951 start = sublayer_ordering_info ? 0 :
sps->max_sub_layers - 1;
952 for (
i = start;
i <
sps->max_sub_layers;
i++) {
958 sps->temporal_layer[
i].max_dec_pic_buffering - 1
U);
961 if (
sps->temporal_layer[
i].num_reorder_pics >
sps->temporal_layer[
i].max_dec_pic_buffering - 1) {
963 sps->temporal_layer[
i].num_reorder_pics);
968 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[
i].num_reorder_pics + 1;
972 if (!sublayer_ordering_info) {
973 for (
i = 0;
i < start;
i++) {
974 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[start].max_dec_pic_buffering;
975 sps->temporal_layer[
i].num_reorder_pics =
sps->temporal_layer[start].num_reorder_pics;
976 sps->temporal_layer[
i].max_latency_increase =
sps->temporal_layer[start].max_latency_increase;
984 sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size +
985 sps->log2_min_tb_size;
987 if (
sps->log2_min_cb_size < 3 ||
sps->log2_min_cb_size > 30) {
992 if (
sps->log2_diff_max_min_coding_block_size > 30) {
993 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);
997 if (
sps->log2_min_tb_size >=
sps->log2_min_cb_size ||
sps->log2_min_tb_size < 2) {
1002 if (log2_diff_max_min_transform_block_size < 0 || log2_diff_max_min_transform_block_size > 30) {
1003 av_log(avctx,
AV_LOG_ERROR,
"Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size);
1011 if (
sps->scaling_list_enable_flag) {
1025 if (
sps->pcm_enabled_flag) {
1029 sps->pcm.log2_max_pcm_cb_size =
sps->pcm.log2_min_pcm_cb_size +
1031 if (
FFMAX(
sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma) >
sps->bit_depth) {
1033 "PCM bit depth (%d, %d) is greater than normal bit depth (%d)\n",
1034 sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma,
sps->bit_depth);
1047 for (
i = 0;
i <
sps->nb_st_rps;
i++) {
1054 if (
sps->long_term_ref_pics_present_flag) {
1058 sps->num_long_term_ref_pics_sps);
1061 for (
i = 0;
i <
sps->num_long_term_ref_pics_sps;
i++) {
1068 sps->sps_strong_intra_smoothing_enable_flag =
get_bits1(gb);
1077 if (
sps->sps_range_extension_flag) {
1078 sps->transform_skip_rotation_enabled_flag =
get_bits1(gb);
1079 sps->transform_skip_context_enabled_flag =
get_bits1(gb);
1084 sps->extended_precision_processing_flag =
get_bits1(gb);
1085 if (
sps->extended_precision_processing_flag)
1087 "extended_precision_processing_flag not yet implemented\n");
1090 sps->high_precision_offsets_enabled_flag =
get_bits1(gb);
1091 if (
sps->high_precision_offsets_enabled_flag)
1093 "high_precision_offsets_enabled_flag not yet implemented\n");
1095 sps->persistent_rice_adaptation_enabled_flag =
get_bits1(gb);
1097 sps->cabac_bypass_alignment_enabled_flag =
get_bits1(gb);
1098 if (
sps->cabac_bypass_alignment_enabled_flag)
1100 "cabac_bypass_alignment_enabled_flag not yet implemented\n");
1103 if (apply_defdispwin) {
1104 sps->output_window.left_offset +=
sps->vui.def_disp_win.left_offset;
1105 sps->output_window.right_offset +=
sps->vui.def_disp_win.right_offset;
1106 sps->output_window.top_offset +=
sps->vui.def_disp_win.top_offset;
1107 sps->output_window.bottom_offset +=
sps->vui.def_disp_win.bottom_offset;
1110 ow = &
sps->output_window;
1121 "Displaying the whole video surface.\n");
1122 memset(ow, 0,
sizeof(*ow));
1123 memset(&
sps->pic_conf_win, 0,
sizeof(
sps->pic_conf_win));
1127 sps->log2_ctb_size =
sps->log2_min_cb_size +
1128 sps->log2_diff_max_min_coding_block_size;
1129 sps->log2_min_pu_size =
sps->log2_min_cb_size - 1;
1135 if (
sps->log2_ctb_size < 4) {
1138 "log2_ctb_size %d differs from the bounds of any known profile\n",
1139 sps->log2_ctb_size);
1144 sps->ctb_width = (
sps->width + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1145 sps->ctb_height = (
sps->height + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1146 sps->ctb_size =
sps->ctb_width *
sps->ctb_height;
1148 sps->min_cb_width =
sps->width >>
sps->log2_min_cb_size;
1149 sps->min_cb_height =
sps->height >>
sps->log2_min_cb_size;
1150 sps->min_tb_width =
sps->width >>
sps->log2_min_tb_size;
1151 sps->min_tb_height =
sps->height >>
sps->log2_min_tb_size;
1152 sps->min_pu_width =
sps->width >>
sps->log2_min_pu_size;
1153 sps->min_pu_height =
sps->height >>
sps->log2_min_pu_size;
1154 sps->tb_mask = (1 << (
sps->log2_ctb_size -
sps->log2_min_tb_size)) - 1;
1156 sps->qp_bd_offset = 6 * (
sps->bit_depth - 8);
1164 if (
sps->max_transform_hierarchy_depth_inter >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1165 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_inter out of range: %d\n",
1166 sps->max_transform_hierarchy_depth_inter);
1169 if (
sps->max_transform_hierarchy_depth_intra >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1170 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_intra out of range: %d\n",
1171 sps->max_transform_hierarchy_depth_intra);
1174 if (
sps->log2_max_trafo_size >
FFMIN(
sps->log2_ctb_size, 5)) {
1176 "max transform block size out of range: %d\n",
1177 sps->log2_max_trafo_size);
1195 unsigned int sps_id;
1206 if (nal_size >
sizeof(
sps->data)) {
1209 nal_size,
sizeof(
sps->data));
1210 sps->data_size =
sizeof(
sps->data);
1212 sps->data_size = nal_size;
1226 "Parsed SPS: id %d; coded wxh: %dx%d; "
1227 "cropped wxh: %dx%d; pix_fmt: %s.\n",
1228 sps_id,
sps->width,
sps->height,
1229 sps->width - (
sps->output_window.left_offset +
sps->output_window.right_offset),
1230 sps->height - (
sps->output_window.top_offset +
sps->output_window.bottom_offset),
1270 if (
pps->transform_skip_enabled_flag) {
1273 pps->cross_component_prediction_enabled_flag =
get_bits1(gb);
1274 pps->chroma_qp_offset_list_enabled_flag =
get_bits1(gb);
1275 if (
pps->chroma_qp_offset_list_enabled_flag) {
1278 if (
pps->chroma_qp_offset_list_len_minus1 > 5) {
1280 "chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
1283 for (
i = 0;
i <=
pps->chroma_qp_offset_list_len_minus1;
i++) {
1285 if (
pps->cb_qp_offset_list[
i]) {
1287 "cb_qp_offset_list not tested yet.\n");
1290 if (
pps->cr_qp_offset_list[
i]) {
1292 "cb_qp_offset_list not tested yet.\n");
1299 if (
pps->log2_sao_offset_scale_luma >
FFMAX(
sps->bit_depth - 10, 0)
1300 ||
pps->log2_sao_offset_scale_chroma >
FFMAX(
sps->bit_depth_chroma - 10, 0)
1311 int pic_area_in_ctbs;
1312 int i, j, x, y, ctb_addr_rs, tile_id;
1318 if (!
pps->col_bd || !
pps->row_bd || !
pps->col_idxX)
1321 if (
pps->uniform_spacing_flag) {
1322 if (!
pps->column_width) {
1326 if (!
pps->column_width || !
pps->row_height)
1329 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1330 pps->column_width[
i] = ((
i + 1) *
sps->ctb_width) /
pps->num_tile_columns -
1331 (
i *
sps->ctb_width) /
pps->num_tile_columns;
1334 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1335 pps->row_height[
i] = ((
i + 1) *
sps->ctb_height) /
pps->num_tile_rows -
1336 (
i *
sps->ctb_height) /
pps->num_tile_rows;
1341 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1342 pps->col_bd[
i + 1] =
pps->col_bd[
i] +
pps->column_width[
i];
1345 for (
i = 0;
i <
pps->num_tile_rows;
i++)
1346 pps->row_bd[
i + 1] =
pps->row_bd[
i] +
pps->row_height[
i];
1348 for (
i = 0, j = 0;
i <
sps->ctb_width;
i++) {
1349 if (
i >
pps->col_bd[j])
1351 pps->col_idxX[
i] = j;
1357 pic_area_in_ctbs =
sps->ctb_width *
sps->ctb_height;
1363 if (!
pps->ctb_addr_rs_to_ts || !
pps->ctb_addr_ts_to_rs ||
1364 !
pps->tile_id || !
pps->min_tb_addr_zs_tab) {
1368 for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
1369 int tb_x = ctb_addr_rs %
sps->ctb_width;
1370 int tb_y = ctb_addr_rs /
sps->ctb_width;
1375 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1376 if (tb_x < pps->col_bd[
i + 1]) {
1382 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1383 if (tb_y < pps->row_bd[
i + 1]) {
1389 for (
i = 0;
i < tile_x;
i++)
1390 val +=
pps->row_height[tile_y] *
pps->column_width[
i];
1391 for (
i = 0;
i < tile_y;
i++)
1394 val += (tb_y -
pps->row_bd[tile_y]) *
pps->column_width[tile_x] +
1395 tb_x -
pps->col_bd[tile_x];
1397 pps->ctb_addr_rs_to_ts[ctb_addr_rs] =
val;
1398 pps->ctb_addr_ts_to_rs[
val] = ctb_addr_rs;
1401 for (j = 0, tile_id = 0; j <
pps->num_tile_rows; j++)
1402 for (
i = 0;
i <
pps->num_tile_columns;
i++, tile_id++)
1403 for (y =
pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
1404 for (x =
pps->col_bd[
i]; x < pps->col_bd[
i + 1]; x++)
1405 pps->tile_id[
pps->ctb_addr_rs_to_ts[y *
sps->ctb_width + x]] = tile_id;
1408 if (!
pps->tile_pos_rs)
1411 for (j = 0; j <
pps->num_tile_rows; j++)
1412 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1413 pps->tile_pos_rs[j *
pps->num_tile_columns +
i] =
1414 pps->row_bd[j] *
sps->ctb_width +
pps->col_bd[
i];
1416 log2_diff =
sps->log2_ctb_size -
sps->log2_min_tb_size;
1417 pps->min_tb_addr_zs = &
pps->min_tb_addr_zs_tab[1*(
sps->tb_mask+2)+1];
1418 for (y = 0; y <
sps->tb_mask+2; y++) {
1419 pps->min_tb_addr_zs_tab[y*(
sps->tb_mask+2)] = -1;
1420 pps->min_tb_addr_zs_tab[y] = -1;
1422 for (y = 0; y <
sps->tb_mask+1; y++) {
1423 for (x = 0; x <
sps->tb_mask+1; x++) {
1424 int tb_x = x >> log2_diff;
1425 int tb_y = y >> log2_diff;
1426 int rs =
sps->ctb_width * tb_y + tb_x;
1427 int val =
pps->ctb_addr_rs_to_ts[rs] << (log2_diff * 2);
1428 for (
i = 0;
i < log2_diff;
i++) {
1430 val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
1432 pps->min_tb_addr_zs[y * (
sps->tb_mask+2) + x] =
val;
1444 unsigned int pps_id = 0;
1446 unsigned log2_parallel_merge_level_minus2;
1464 if (nal_size >
sizeof(
pps->data)) {
1467 nal_size,
sizeof(
pps->data));
1468 pps->data_size =
sizeof(
pps->data);
1470 pps->data_size = nal_size;
1475 pps->loop_filter_across_tiles_enabled_flag = 1;
1476 pps->num_tile_columns = 1;
1477 pps->num_tile_rows = 1;
1478 pps->uniform_spacing_flag = 1;
1479 pps->disable_dbf = 0;
1480 pps->beta_offset = 0;
1482 pps->log2_max_transform_skip_block_size = 2;
1504 pps->dependent_slice_segments_enabled_flag =
get_bits1(gb);
1506 pps->num_extra_slice_header_bits =
get_bits(gb, 3);
1521 pps->diff_cu_qp_delta_depth = 0;
1522 if (
pps->cu_qp_delta_enabled_flag)
1525 if (
pps->diff_cu_qp_delta_depth < 0 ||
1526 pps->diff_cu_qp_delta_depth >
sps->log2_diff_max_min_coding_block_size) {
1528 pps->diff_cu_qp_delta_depth);
1534 if (
pps->cb_qp_offset < -12 ||
pps->cb_qp_offset > 12) {
1541 if (
pps->cr_qp_offset < -12 ||
pps->cr_qp_offset > 12) {
1547 pps->pic_slice_level_chroma_qp_offsets_present_flag =
get_bits1(gb);
1556 if (
pps->tiles_enabled_flag) {
1560 if (num_tile_columns_minus1 < 0 ||
1561 num_tile_columns_minus1 >=
sps->ctb_width) {
1563 num_tile_columns_minus1);
1567 if (num_tile_rows_minus1 < 0 ||
1568 num_tile_rows_minus1 >=
sps->ctb_height) {
1570 num_tile_rows_minus1);
1574 pps->num_tile_columns = num_tile_columns_minus1 + 1;
1575 pps->num_tile_rows = num_tile_rows_minus1 + 1;
1579 if (!
pps->column_width || !
pps->row_height) {
1585 if (!
pps->uniform_spacing_flag) {
1587 for (
i = 0;
i <
pps->num_tile_columns - 1;
i++) {
1589 sum +=
pps->column_width[
i];
1591 if (sum >=
sps->ctb_width) {
1596 pps->column_width[
pps->num_tile_columns - 1] =
sps->ctb_width - sum;
1599 for (
i = 0;
i <
pps->num_tile_rows - 1;
i++) {
1601 sum +=
pps->row_height[
i];
1603 if (sum >=
sps->ctb_height) {
1608 pps->row_height[
pps->num_tile_rows - 1] =
sps->ctb_height - sum;
1610 pps->loop_filter_across_tiles_enabled_flag =
get_bits1(gb);
1613 pps->seq_loop_filter_across_slices_enabled_flag =
get_bits1(gb);
1615 pps->deblocking_filter_control_present_flag =
get_bits1(gb);
1616 if (
pps->deblocking_filter_control_present_flag) {
1617 pps->deblocking_filter_override_enabled_flag =
get_bits1(gb);
1619 if (!
pps->disable_dbf) {
1622 if (beta_offset_div2 < -6 || beta_offset_div2 > 6) {
1628 if (tc_offset_div2 < -6 || tc_offset_div2 > 6) {
1634 pps->beta_offset = 2 * beta_offset_div2;
1635 pps->tc_offset = 2 * tc_offset_div2;
1640 if (
pps->scaling_list_data_present_flag) {
1648 if (log2_parallel_merge_level_minus2 >
sps->log2_ctb_size) {
1650 log2_parallel_merge_level_minus2);
1654 pps->log2_parallel_merge_level = log2_parallel_merge_level_minus2 + 2;
1656 pps->slice_header_extension_present_flag =
get_bits1(gb);
1705 int max_poc_lsb = 1 <<
sps->log2_max_poc_lsb;
1706 int prev_poc_lsb = pocTid0 % max_poc_lsb;
1707 int prev_poc_msb = pocTid0 - prev_poc_lsb;
1710 if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
1711 poc_msb = prev_poc_msb + max_poc_lsb;
1712 else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 2)
1713 poc_msb = prev_poc_msb - max_poc_lsb;
1715 poc_msb = prev_poc_msb;
1723 return poc_msb + poc_lsb;