| 365 | } |
| 366 | |
| 367 | static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps, |
| 368 | int is_avc, void *logctx) |
| 369 | { |
| 370 | H2645Packet pkt = { 0 }; |
| 371 | int flags = (H2645_FLAG_IS_NALFF * !!is_avc) | H2645_FLAG_SMALL_PADDING; |
| 372 | int i, ret = 0; |
| 373 | |
| 374 | ret = ff_h2645_packet_split(&pkt, data, size, logctx, 2, AV_CODEC_ID_H264, flags); |
| 375 | if (ret < 0) { |
| 376 | ret = 0; |
| 377 | goto fail; |
| 378 | } |
| 379 | |
| 380 | for (i = 0; i < pkt.nb_nals; i++) { |
| 381 | H2645NAL *nal = &pkt.nals[i]; |
| 382 | switch (nal->type) { |
| 383 | case H264_NAL_SPS: { |
| 384 | GetBitContext tmp_gb = nal->gb; |
| 385 | ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0); |
| 386 | if (ret >= 0) |
| 387 | break; |
| 388 | av_log(logctx, AV_LOG_DEBUG, |
| 389 | "SPS decoding failure, trying again with the complete NAL\n"); |
| 390 | init_get_bits8(&tmp_gb, nal->raw_data + 1, nal->raw_size - 1); |
| 391 | ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0); |
| 392 | if (ret >= 0) |
| 393 | break; |
| 394 | ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 1); |
| 395 | if (ret < 0) |
| 396 | goto fail; |
| 397 | break; |
| 398 | } |
| 399 | case H264_NAL_PPS: |
| 400 | ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps, |
| 401 | nal->size_bits); |
| 402 | if (ret < 0) |
| 403 | goto fail; |
| 404 | break; |
| 405 | default: |
| 406 | av_log(logctx, AV_LOG_VERBOSE, "Ignoring NAL type %d in extradata\n", |
| 407 | nal->type); |
| 408 | break; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | fail: |
| 413 | ff_h2645_packet_uninit(&pkt); |
| 414 | return ret; |
| 415 | } |
| 416 | |
| 417 | /* There are (invalid) samples in the wild with mp4-style extradata, where the |
| 418 | * parameter sets are stored unescaped (i.e. as RBSP). |
no test coverage detected