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)
122 uint8_t rps_predict = 0;
128 if (rps !=
sps->st_rps &&
sps->nb_st_rps)
134 unsigned abs_delta_rps;
135 uint8_t use_delta_flag = 0;
136 uint8_t delta_rps_sign;
138 if (is_slice_header) {
140 if (delta_idx >
sps->nb_st_rps) {
142 "Invalid value of delta_idx in slice header RPS: %d > %d.\n",
143 delta_idx,
sps->nb_st_rps);
146 rps_ridx = &
sps->st_rps[
sps->nb_st_rps - delta_idx];
149 rps_ridx = &
sps->st_rps[rps -
sps->st_rps - 1];
153 if (abs_delta_rps < 1 || abs_delta_rps > 32768) {
155 "Invalid value of abs_delta_rps: %d\n",
159 delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
166 if (used || use_delta_flag) {
167 if (i < rps_ridx->num_delta_pocs)
168 delta_poc = delta_rps + rps_ridx->
delta_poc[
i];
170 delta_poc = delta_rps;
180 "Invalid num_delta_pocs: %d\n", k);
192 for (k =
i - 1; k >= 0; k--) {
194 if (delta_poc <
tmp) {
218 unsigned int prev, nb_positive_pics;
233 if (delta_poc < 1 || delta_poc > 32768) {
235 "Invalid value of delta_poc: %d\n",
244 for (
i = 0;
i < nb_positive_pics;
i++) {
246 if (delta_poc < 1 || delta_poc > 32768) {
248 "Invalid value of delta_poc: %d\n",
284 for (
i = 0;
i < 32;
i++) {
287 if (
ptl->profile_idc == 0 &&
i > 0 &&
ptl->profile_compatibility_flag[
i])
288 ptl->profile_idc =
i;
295 #define check_profile_idc(idc) \
296 ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]
331 #undef check_profile_idc
337 PTL *
ptl,
int max_num_sub_layers)
341 get_bits_left(gb) < 8 + (8*2 * (max_num_sub_layers - 1 > 0))) {
348 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
353 if (max_num_sub_layers - 1> 0)
354 for (
i = max_num_sub_layers - 1;
i < 8;
i++)
356 for (
i = 0;
i < max_num_sub_layers - 1;
i++) {
360 "PTL information for sublayer %i too short\n",
i);
366 "Not enough data for sublayer %i level_idc\n",
i);
377 int subpic_params_present)
381 for (
i = 0;
i < nb_cpb;
i++) {
385 if (subpic_params_present) {
396 int nal_params_present = 0, vcl_params_present = 0;
397 int subpic_params_present = 0;
400 if (common_inf_present) {
404 if (nal_params_present || vcl_params_present) {
407 if (subpic_params_present) {
417 if (subpic_params_present)
426 for (
i = 0;
i < max_sublayers;
i++) {
428 unsigned int nb_cpb = 1;
441 if (nb_cpb < 1 || nb_cpb > 32) {
447 if (nal_params_present)
449 if (vcl_params_present)
471 if (nal_size >
sizeof(
vps->data)) {
474 nal_size,
sizeof(
vps->data));
475 vps->data_size =
sizeof(
vps->data);
477 vps->data_size = nal_size;
499 vps->vps_max_sub_layers);
506 vps->vps_sub_layer_ordering_info_present_flag =
get_bits1(gb);
508 i =
vps->vps_sub_layer_ordering_info_present_flag ? 0 :
vps->vps_max_sub_layers - 1;
509 for (;
i <
vps->vps_max_sub_layers;
i++) {
516 vps->vps_max_dec_pic_buffering[
i] - 1);
519 if (
vps->vps_num_reorder_pics[
i] >
vps->vps_max_dec_pic_buffering[
i] - 1) {
521 vps->vps_num_reorder_pics[
i]);
529 if (
vps->vps_num_layer_sets < 1 ||
vps->vps_num_layer_sets > 1024 ||
535 for (
i = 1;
i <
vps->vps_num_layer_sets;
i++)
536 for (j = 0; j <=
vps->vps_max_layer_id; j++)
540 if (
vps->vps_timing_info_present_flag) {
543 vps->vps_poc_proportional_to_timing_flag =
get_bits1(gb);
544 if (
vps->vps_poc_proportional_to_timing_flag)
547 if (
vps->vps_num_hrd_parameters > (
unsigned)
vps->vps_num_layer_sets) {
549 "vps_num_hrd_parameters %d is invalid\n",
vps->vps_num_hrd_parameters);
552 for (
i = 0;
i <
vps->vps_num_hrd_parameters;
i++) {
553 int common_inf_present = 1;
588 VUI backup_vui, *vui = &
sps->vui;
590 int sar_present, alt = 0;
599 else if (sar_idx == 255) {
604 "Unknown SAR index: %u.\n", sar_idx);
631 switch (
sps->pix_fmt) {
657 memcpy(&backup, gb,
sizeof(backup));
658 memcpy(&backup_vui, vui,
sizeof(backup_vui));
673 if (apply_defdispwin &&
676 "discarding vui default display window, "
677 "original values are l:%u r:%u t:%u b:%u\n",
698 "Strange VUI timing information, retrying...\n");
699 memcpy(vui, &backup_vui,
sizeof(backup_vui));
700 memcpy(gb, &backup,
sizeof(backup));
722 "Strange VUI bitstream restriction information, retrying"
723 " from timing information...\n");
724 memcpy(vui, &backup_vui,
sizeof(backup_vui));
725 memcpy(gb, &backup,
sizeof(backup));
742 "Overread in VUI, retrying from timing information...\n");
743 memcpy(vui, &backup_vui,
sizeof(backup_vui));
744 memcpy(gb, &backup,
sizeof(backup));
754 for (matrixId = 0; matrixId < 6; matrixId++) {
756 memset(sl->
sl[0][matrixId], 16, 16);
757 sl->
sl_dc[0][matrixId] = 16;
758 sl->
sl_dc[1][matrixId] = 16;
782 uint8_t scaling_list_pred_mode_flag;
783 uint8_t scaling_list_dc_coef[2][6];
784 int size_id, matrix_id,
pos;
787 for (size_id = 0; size_id < 4; size_id++)
788 for (matrix_id = 0; matrix_id < 6; matrix_id += ((size_id == 3) ? 3 : 1)) {
789 scaling_list_pred_mode_flag =
get_bits1(gb);
790 if (!scaling_list_pred_mode_flag) {
796 delta *= (size_id == 3) ? 3 : 1;
797 if (matrix_id <
delta) {
799 "Invalid delta in scaling list data: %d.\n",
delta);
803 memcpy(sl->
sl[size_id][matrix_id],
804 sl->
sl[size_id][matrix_id -
delta],
805 size_id > 0 ? 64 : 16);
807 sl->
sl_dc[size_id - 2][matrix_id] = sl->
sl_dc[size_id - 2][matrix_id -
delta];
810 int next_coef, coef_num;
811 int32_t scaling_list_delta_coef;
814 coef_num =
FFMIN(64, 1 << (4 + (size_id << 1)));
817 if (scaling_list_coeff_minus8 < -7 ||
818 scaling_list_coeff_minus8 > 247)
820 scaling_list_dc_coef[size_id - 2][matrix_id] = scaling_list_coeff_minus8 + 8;
821 next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
822 sl->
sl_dc[size_id - 2][matrix_id] = next_coef;
824 for (
i = 0;
i < coef_num;
i++) {
833 next_coef = (next_coef + 256
U + scaling_list_delta_coef) % 256;
834 sl->
sl[size_id][matrix_id][
pos] = next_coef;
839 if (
sps->chroma_format_idc == 3) {
840 for (
i = 0;
i < 64;
i++) {
841 sl->
sl[3][1][
i] = sl->
sl[2][1][
i];
842 sl->
sl[3][2][
i] = sl->
sl[2][2][
i];
843 sl->
sl[3][4][
i] = sl->
sl[2][4][
i];
844 sl->
sl[3][5][
i] = sl->
sl[2][5][
i];
859 switch (
sps->bit_depth) {
886 "The following bit-depths are currently specified: 8, 9, 10 and 12 bits, "
887 "chroma_format_idc is %d, depth is %d\n",
888 sps->chroma_format_idc,
sps->bit_depth);
896 sps->hshift[0] =
sps->vshift[0] = 0;
897 sps->hshift[2] =
sps->hshift[1] =
desc->log2_chroma_w;
898 sps->vshift[2] =
sps->vshift[1] =
desc->log2_chroma_h;
900 sps->pixel_shift =
sps->bit_depth > 8;
910 int log2_diff_max_min_transform_block_size;
911 int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
918 if (vps_list && !vps_list[
sps->vps_id]) {
927 sps->max_sub_layers);
943 if (
sps->chroma_format_idc > 3
U) {
948 if (
sps->chroma_format_idc == 3)
951 if (
sps->separate_colour_plane_flag)
952 sps->chroma_format_idc = 0;
957 sps->height, 0, avctx)) < 0)
970 "discarding sps conformance window, "
971 "original values are l:%u r:%u t:%u b:%u\n",
972 sps->pic_conf_win.left_offset,
973 sps->pic_conf_win.right_offset,
974 sps->pic_conf_win.top_offset,
975 sps->pic_conf_win.bottom_offset);
977 sps->pic_conf_win.left_offset =
978 sps->pic_conf_win.right_offset =
979 sps->pic_conf_win.top_offset =
980 sps->pic_conf_win.bottom_offset = 0;
982 sps->output_window =
sps->pic_conf_win;
987 if (
sps->chroma_format_idc && bit_depth_chroma !=
sps->bit_depth) {
989 "Luma bit depth (%d) is different from chroma bit depth (%d), "
990 "this is unsupported.\n",
991 sps->bit_depth, bit_depth_chroma);
994 sps->bit_depth_chroma = bit_depth_chroma;
1001 if (
sps->log2_max_poc_lsb > 16) {
1003 sps->log2_max_poc_lsb - 4);
1008 start = sublayer_ordering_info ? 0 :
sps->max_sub_layers - 1;
1009 for (
i = start;
i <
sps->max_sub_layers;
i++) {
1015 sps->temporal_layer[
i].max_dec_pic_buffering - 1
U);
1018 if (
sps->temporal_layer[
i].num_reorder_pics >
sps->temporal_layer[
i].max_dec_pic_buffering - 1) {
1020 sps->temporal_layer[
i].num_reorder_pics);
1025 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[
i].num_reorder_pics + 1;
1029 if (!sublayer_ordering_info) {
1030 for (
i = 0;
i < start;
i++) {
1031 sps->temporal_layer[
i].max_dec_pic_buffering =
sps->temporal_layer[start].max_dec_pic_buffering;
1032 sps->temporal_layer[
i].num_reorder_pics =
sps->temporal_layer[start].num_reorder_pics;
1033 sps->temporal_layer[
i].max_latency_increase =
sps->temporal_layer[start].max_latency_increase;
1041 sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size +
1042 sps->log2_min_tb_size;
1044 if (
sps->log2_min_cb_size < 3 ||
sps->log2_min_cb_size > 30) {
1049 if (
sps->log2_diff_max_min_coding_block_size > 30) {
1050 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);
1054 if (
sps->log2_min_tb_size >=
sps->log2_min_cb_size ||
sps->log2_min_tb_size < 2) {
1059 if (log2_diff_max_min_transform_block_size < 0 || log2_diff_max_min_transform_block_size > 30) {
1060 av_log(avctx,
AV_LOG_ERROR,
"Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size);
1068 if (
sps->scaling_list_enable_flag) {
1082 if (
sps->pcm_enabled_flag) {
1086 sps->pcm.log2_max_pcm_cb_size =
sps->pcm.log2_min_pcm_cb_size +
1088 if (
FFMAX(
sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma) >
sps->bit_depth) {
1090 "PCM bit depth (%d, %d) is greater than normal bit depth (%d)\n",
1091 sps->pcm.bit_depth,
sps->pcm.bit_depth_chroma,
sps->bit_depth);
1104 for (
i = 0;
i <
sps->nb_st_rps;
i++) {
1111 if (
sps->long_term_ref_pics_present_flag) {
1115 sps->num_long_term_ref_pics_sps);
1118 for (
i = 0;
i <
sps->num_long_term_ref_pics_sps;
i++) {
1125 sps->sps_strong_intra_smoothing_enable_flag =
get_bits1(gb);
1134 if (
sps->sps_range_extension_flag) {
1135 sps->transform_skip_rotation_enabled_flag =
get_bits1(gb);
1136 sps->transform_skip_context_enabled_flag =
get_bits1(gb);
1141 sps->extended_precision_processing_flag =
get_bits1(gb);
1142 if (
sps->extended_precision_processing_flag)
1144 "extended_precision_processing_flag not yet implemented\n");
1147 sps->high_precision_offsets_enabled_flag =
get_bits1(gb);
1148 if (
sps->high_precision_offsets_enabled_flag)
1150 "high_precision_offsets_enabled_flag not yet implemented\n");
1152 sps->persistent_rice_adaptation_enabled_flag =
get_bits1(gb);
1154 sps->cabac_bypass_alignment_enabled_flag =
get_bits1(gb);
1155 if (
sps->cabac_bypass_alignment_enabled_flag)
1157 "cabac_bypass_alignment_enabled_flag not yet implemented\n");
1160 if (apply_defdispwin) {
1161 sps->output_window.left_offset +=
sps->vui.def_disp_win.left_offset;
1162 sps->output_window.right_offset +=
sps->vui.def_disp_win.right_offset;
1163 sps->output_window.top_offset +=
sps->vui.def_disp_win.top_offset;
1164 sps->output_window.bottom_offset +=
sps->vui.def_disp_win.bottom_offset;
1167 ow = &
sps->output_window;
1178 "Displaying the whole video surface.\n");
1179 memset(ow, 0,
sizeof(*ow));
1180 memset(&
sps->pic_conf_win, 0,
sizeof(
sps->pic_conf_win));
1184 sps->log2_ctb_size =
sps->log2_min_cb_size +
1185 sps->log2_diff_max_min_coding_block_size;
1186 sps->log2_min_pu_size =
sps->log2_min_cb_size - 1;
1192 if (
sps->log2_ctb_size < 4) {
1195 "log2_ctb_size %d differs from the bounds of any known profile\n",
1196 sps->log2_ctb_size);
1201 sps->ctb_width = (
sps->width + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1202 sps->ctb_height = (
sps->height + (1 <<
sps->log2_ctb_size) - 1) >>
sps->log2_ctb_size;
1203 sps->ctb_size =
sps->ctb_width *
sps->ctb_height;
1205 sps->min_cb_width =
sps->width >>
sps->log2_min_cb_size;
1206 sps->min_cb_height =
sps->height >>
sps->log2_min_cb_size;
1207 sps->min_tb_width =
sps->width >>
sps->log2_min_tb_size;
1208 sps->min_tb_height =
sps->height >>
sps->log2_min_tb_size;
1209 sps->min_pu_width =
sps->width >>
sps->log2_min_pu_size;
1210 sps->min_pu_height =
sps->height >>
sps->log2_min_pu_size;
1211 sps->tb_mask = (1 << (
sps->log2_ctb_size -
sps->log2_min_tb_size)) - 1;
1213 sps->qp_bd_offset = 6 * (
sps->bit_depth - 8);
1221 if (
sps->max_transform_hierarchy_depth_inter >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1222 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_inter out of range: %d\n",
1223 sps->max_transform_hierarchy_depth_inter);
1226 if (
sps->max_transform_hierarchy_depth_intra >
sps->log2_ctb_size -
sps->log2_min_tb_size) {
1227 av_log(avctx,
AV_LOG_ERROR,
"max_transform_hierarchy_depth_intra out of range: %d\n",
1228 sps->max_transform_hierarchy_depth_intra);
1231 if (
sps->log2_max_trafo_size >
FFMIN(
sps->log2_ctb_size, 5)) {
1233 "max transform block size out of range: %d\n",
1234 sps->log2_max_trafo_size);
1252 unsigned int sps_id;
1263 if (nal_size >
sizeof(
sps->data)) {
1266 nal_size,
sizeof(
sps->data));
1267 sps->data_size =
sizeof(
sps->data);
1269 sps->data_size = nal_size;
1283 "Parsed SPS: id %d; coded wxh: %dx%d; "
1284 "cropped wxh: %dx%d; pix_fmt: %s.\n",
1285 sps_id,
sps->width,
sps->height,
1286 sps->width - (
sps->output_window.left_offset +
sps->output_window.right_offset),
1287 sps->height - (
sps->output_window.top_offset +
sps->output_window.bottom_offset),
1327 if (
pps->transform_skip_enabled_flag) {
1330 pps->cross_component_prediction_enabled_flag =
get_bits1(gb);
1331 pps->chroma_qp_offset_list_enabled_flag =
get_bits1(gb);
1332 if (
pps->chroma_qp_offset_list_enabled_flag) {
1335 if (
pps->chroma_qp_offset_list_len_minus1 > 5) {
1337 "chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
1340 for (
i = 0;
i <=
pps->chroma_qp_offset_list_len_minus1;
i++) {
1342 if (
pps->cb_qp_offset_list[
i]) {
1344 "cb_qp_offset_list not tested yet.\n");
1347 if (
pps->cr_qp_offset_list[
i]) {
1349 "cb_qp_offset_list not tested yet.\n");
1356 if (
pps->log2_sao_offset_scale_luma >
FFMAX(
sps->bit_depth - 10, 0)
1357 ||
pps->log2_sao_offset_scale_chroma >
FFMAX(
sps->bit_depth_chroma - 10, 0)
1368 int pic_area_in_ctbs;
1369 int i, j, x, y, ctb_addr_rs, tile_id;
1375 if (!
pps->col_bd || !
pps->row_bd || !
pps->col_idxX)
1378 if (
pps->uniform_spacing_flag) {
1379 if (!
pps->column_width) {
1383 if (!
pps->column_width || !
pps->row_height)
1386 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1387 pps->column_width[
i] = ((
i + 1) *
sps->ctb_width) /
pps->num_tile_columns -
1388 (
i *
sps->ctb_width) /
pps->num_tile_columns;
1391 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1392 pps->row_height[
i] = ((
i + 1) *
sps->ctb_height) /
pps->num_tile_rows -
1393 (
i *
sps->ctb_height) /
pps->num_tile_rows;
1398 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1399 pps->col_bd[
i + 1] =
pps->col_bd[
i] +
pps->column_width[
i];
1402 for (
i = 0;
i <
pps->num_tile_rows;
i++)
1403 pps->row_bd[
i + 1] =
pps->row_bd[
i] +
pps->row_height[
i];
1405 for (
i = 0, j = 0;
i <
sps->ctb_width;
i++) {
1406 if (
i >
pps->col_bd[j])
1408 pps->col_idxX[
i] = j;
1414 pic_area_in_ctbs =
sps->ctb_width *
sps->ctb_height;
1420 if (!
pps->ctb_addr_rs_to_ts || !
pps->ctb_addr_ts_to_rs ||
1421 !
pps->tile_id || !
pps->min_tb_addr_zs_tab) {
1425 for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
1426 int tb_x = ctb_addr_rs %
sps->ctb_width;
1427 int tb_y = ctb_addr_rs /
sps->ctb_width;
1432 for (
i = 0;
i <
pps->num_tile_columns;
i++) {
1433 if (tb_x < pps->col_bd[
i + 1]) {
1439 for (
i = 0;
i <
pps->num_tile_rows;
i++) {
1440 if (tb_y < pps->row_bd[
i + 1]) {
1446 for (
i = 0;
i < tile_x;
i++)
1447 val +=
pps->row_height[tile_y] *
pps->column_width[
i];
1448 for (
i = 0;
i < tile_y;
i++)
1451 val += (tb_y -
pps->row_bd[tile_y]) *
pps->column_width[tile_x] +
1452 tb_x -
pps->col_bd[tile_x];
1454 pps->ctb_addr_rs_to_ts[ctb_addr_rs] =
val;
1455 pps->ctb_addr_ts_to_rs[
val] = ctb_addr_rs;
1458 for (j = 0, tile_id = 0; j <
pps->num_tile_rows; j++)
1459 for (
i = 0;
i <
pps->num_tile_columns;
i++, tile_id++)
1460 for (y =
pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
1461 for (x =
pps->col_bd[
i]; x < pps->col_bd[
i + 1]; x++)
1462 pps->tile_id[
pps->ctb_addr_rs_to_ts[y *
sps->ctb_width + x]] = tile_id;
1465 if (!
pps->tile_pos_rs)
1468 for (j = 0; j <
pps->num_tile_rows; j++)
1469 for (
i = 0;
i <
pps->num_tile_columns;
i++)
1470 pps->tile_pos_rs[j *
pps->num_tile_columns +
i] =
1471 pps->row_bd[j] *
sps->ctb_width +
pps->col_bd[
i];
1473 log2_diff =
sps->log2_ctb_size -
sps->log2_min_tb_size;
1474 pps->min_tb_addr_zs = &
pps->min_tb_addr_zs_tab[1*(
sps->tb_mask+2)+1];
1475 for (y = 0; y <
sps->tb_mask+2; y++) {
1476 pps->min_tb_addr_zs_tab[y*(
sps->tb_mask+2)] = -1;
1477 pps->min_tb_addr_zs_tab[y] = -1;
1479 for (y = 0; y <
sps->tb_mask+1; y++) {
1480 for (x = 0; x <
sps->tb_mask+1; x++) {
1481 int tb_x = x >> log2_diff;
1482 int tb_y = y >> log2_diff;
1483 int rs =
sps->ctb_width * tb_y + tb_x;
1484 int val =
pps->ctb_addr_rs_to_ts[rs] << (log2_diff * 2);
1485 for (
i = 0;
i < log2_diff;
i++) {
1487 val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
1489 pps->min_tb_addr_zs[y * (
sps->tb_mask+2) + x] =
val;
1501 unsigned int pps_id = 0;
1503 unsigned log2_parallel_merge_level_minus2;
1521 if (nal_size >
sizeof(
pps->data)) {
1524 nal_size,
sizeof(
pps->data));
1525 pps->data_size =
sizeof(
pps->data);
1527 pps->data_size = nal_size;
1532 pps->loop_filter_across_tiles_enabled_flag = 1;
1533 pps->num_tile_columns = 1;
1534 pps->num_tile_rows = 1;
1535 pps->uniform_spacing_flag = 1;
1536 pps->disable_dbf = 0;
1537 pps->beta_offset = 0;
1539 pps->log2_max_transform_skip_block_size = 2;
1561 pps->dependent_slice_segments_enabled_flag =
get_bits1(gb);
1563 pps->num_extra_slice_header_bits =
get_bits(gb, 3);
1578 pps->diff_cu_qp_delta_depth = 0;
1579 if (
pps->cu_qp_delta_enabled_flag)
1582 if (
pps->diff_cu_qp_delta_depth < 0 ||
1583 pps->diff_cu_qp_delta_depth >
sps->log2_diff_max_min_coding_block_size) {
1585 pps->diff_cu_qp_delta_depth);
1591 if (
pps->cb_qp_offset < -12 ||
pps->cb_qp_offset > 12) {
1598 if (
pps->cr_qp_offset < -12 ||
pps->cr_qp_offset > 12) {
1604 pps->pic_slice_level_chroma_qp_offsets_present_flag =
get_bits1(gb);
1613 if (
pps->tiles_enabled_flag) {
1617 if (num_tile_columns_minus1 < 0 ||
1618 num_tile_columns_minus1 >=
sps->ctb_width) {
1620 num_tile_columns_minus1);
1624 if (num_tile_rows_minus1 < 0 ||
1625 num_tile_rows_minus1 >=
sps->ctb_height) {
1627 num_tile_rows_minus1);
1631 pps->num_tile_columns = num_tile_columns_minus1 + 1;
1632 pps->num_tile_rows = num_tile_rows_minus1 + 1;
1636 if (!
pps->column_width || !
pps->row_height) {
1642 if (!
pps->uniform_spacing_flag) {
1644 for (
i = 0;
i <
pps->num_tile_columns - 1;
i++) {
1646 sum +=
pps->column_width[
i];
1648 if (sum >=
sps->ctb_width) {
1653 pps->column_width[
pps->num_tile_columns - 1] =
sps->ctb_width - sum;
1656 for (
i = 0;
i <
pps->num_tile_rows - 1;
i++) {
1658 sum +=
pps->row_height[
i];
1660 if (sum >=
sps->ctb_height) {
1665 pps->row_height[
pps->num_tile_rows - 1] =
sps->ctb_height - sum;
1667 pps->loop_filter_across_tiles_enabled_flag =
get_bits1(gb);
1670 pps->seq_loop_filter_across_slices_enabled_flag =
get_bits1(gb);
1672 pps->deblocking_filter_control_present_flag =
get_bits1(gb);
1673 if (
pps->deblocking_filter_control_present_flag) {
1674 pps->deblocking_filter_override_enabled_flag =
get_bits1(gb);
1676 if (!
pps->disable_dbf) {
1679 if (beta_offset_div2 < -6 || beta_offset_div2 > 6) {
1685 if (tc_offset_div2 < -6 || tc_offset_div2 > 6) {
1691 pps->beta_offset = 2 * beta_offset_div2;
1692 pps->tc_offset = 2 * tc_offset_div2;
1697 if (
pps->scaling_list_data_present_flag) {
1705 if (log2_parallel_merge_level_minus2 >
sps->log2_ctb_size) {
1707 log2_parallel_merge_level_minus2);
1711 pps->log2_parallel_merge_level = log2_parallel_merge_level_minus2 + 2;
1713 pps->slice_header_extension_present_flag =
get_bits1(gb);
1762 int max_poc_lsb = 1 <<
sps->log2_max_poc_lsb;
1763 int prev_poc_lsb = pocTid0 % max_poc_lsb;
1764 int prev_poc_msb = pocTid0 - prev_poc_lsb;
1767 if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
1768 poc_msb = prev_poc_msb + max_poc_lsb;
1769 else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 2)
1770 poc_msb = prev_poc_msb - max_poc_lsb;
1772 poc_msb = prev_poc_msb;
1780 return poc_msb + poc_lsb;