| 282 | } |
| 283 | |
| 284 | int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, |
| 285 | H264ParamSets *ps, int ignore_truncation) |
| 286 | { |
| 287 | int profile_idc, level_idc, constraint_set_flags = 0; |
| 288 | unsigned int sps_id; |
| 289 | int i, log2_max_frame_num_minus4; |
| 290 | SPS *sps; |
| 291 | int ret; |
| 292 | |
| 293 | sps = av_refstruct_allocz(sizeof(*sps)); |
| 294 | if (!sps) |
| 295 | return AVERROR(ENOMEM); |
| 296 | |
| 297 | sps->data_size = get_bits_bytesize(gb, 1); |
| 298 | if (sps->data_size > sizeof(sps->data)) { |
| 299 | av_log(avctx, AV_LOG_DEBUG, "Truncating likely oversized SPS\n"); |
| 300 | sps->data_size = sizeof(sps->data); |
| 301 | } |
| 302 | memcpy(sps->data, gb->buffer, sps->data_size); |
| 303 | |
| 304 | // Re-add the removed stop bit (may be used by hwaccels). |
| 305 | if (!(gb->size_in_bits & 7) && sps->data_size < sizeof(sps->data)) |
| 306 | sps->data[sps->data_size++] = 0x80; |
| 307 | |
| 308 | profile_idc = get_bits(gb, 8); |
| 309 | constraint_set_flags |= get_bits1(gb) << 0; // constraint_set0_flag |
| 310 | constraint_set_flags |= get_bits1(gb) << 1; // constraint_set1_flag |
| 311 | constraint_set_flags |= get_bits1(gb) << 2; // constraint_set2_flag |
| 312 | constraint_set_flags |= get_bits1(gb) << 3; // constraint_set3_flag |
| 313 | constraint_set_flags |= get_bits1(gb) << 4; // constraint_set4_flag |
| 314 | constraint_set_flags |= get_bits1(gb) << 5; // constraint_set5_flag |
| 315 | skip_bits(gb, 2); // reserved_zero_2bits |
| 316 | level_idc = get_bits(gb, 8); |
| 317 | sps_id = get_ue_golomb_31(gb); |
| 318 | |
| 319 | if (sps_id >= MAX_SPS_COUNT) { |
| 320 | av_log(avctx, AV_LOG_ERROR, "sps_id %u out of range\n", sps_id); |
| 321 | goto fail; |
| 322 | } |
| 323 | |
| 324 | sps->sps_id = sps_id; |
| 325 | sps->time_offset_length = 24; |
| 326 | sps->profile_idc = profile_idc; |
| 327 | sps->constraint_set_flags = constraint_set_flags; |
| 328 | sps->level_idc = level_idc; |
| 329 | sps->vui.video_full_range_flag = -1; |
| 330 | |
| 331 | memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4)); |
| 332 | memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8)); |
| 333 | sps->scaling_matrix_present = 0; |
| 334 | sps->vui.matrix_coeffs = AVCOL_SPC_UNSPECIFIED; |
| 335 | |
| 336 | if (sps->profile_idc == 100 || // High profile |
| 337 | sps->profile_idc == 110 || // High10 profile |
| 338 | sps->profile_idc == 122 || // High422 profile |
| 339 | sps->profile_idc == 244 || // High444 Predictive profile |
| 340 | sps->profile_idc == 44 || // Cavlc444 profile |
| 341 | sps->profile_idc == 83 || // Scalable Constrained High profile (SVC) |
no test coverage detected