@see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax)
| 78 | |
| 79 | // @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) |
| 80 | static int evcc_parse_sps(const uint8_t *bs, int bs_size, EVCDecoderConfigurationRecord *evcc) |
| 81 | { |
| 82 | GetBitContext gb; |
| 83 | unsigned sps_seq_parameter_set_id; |
| 84 | int ret; |
| 85 | |
| 86 | bs += EVC_NALU_HEADER_SIZE; |
| 87 | bs_size -= EVC_NALU_HEADER_SIZE; |
| 88 | |
| 89 | ret = init_get_bits8(&gb, bs, bs_size); |
| 90 | if (ret < 0) |
| 91 | return ret; |
| 92 | |
| 93 | sps_seq_parameter_set_id = get_ue_golomb_long(&gb); |
| 94 | |
| 95 | if (sps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) |
| 96 | return AVERROR_INVALIDDATA; |
| 97 | |
| 98 | // the Baseline profile is indicated by profile_idc eqal to 0 |
| 99 | // the Main profile is indicated by profile_idc eqal to 1 |
| 100 | evcc->profile_idc = get_bits(&gb, 8); |
| 101 | |
| 102 | evcc->level_idc = get_bits(&gb, 8); |
| 103 | |
| 104 | evcc->toolset_idc_h = get_bits_long(&gb, 32); |
| 105 | evcc->toolset_idc_l = get_bits_long(&gb, 32); |
| 106 | |
| 107 | // 0 - monochrome |
| 108 | // 1 - 4:2:0 |
| 109 | // 2 - 4:2:2 |
| 110 | // 3 - 4:4:4 |
| 111 | evcc->chroma_format_idc = get_ue_golomb_long(&gb); |
| 112 | if (evcc->chroma_format_idc > 3) |
| 113 | return AVERROR_INVALIDDATA; |
| 114 | |
| 115 | evcc->pic_width_in_luma_samples = get_ue_golomb_long(&gb); |
| 116 | evcc->pic_height_in_luma_samples = get_ue_golomb_long(&gb); |
| 117 | |
| 118 | evcc->bit_depth_luma_minus8 = get_ue_golomb_long(&gb); |
| 119 | evcc->bit_depth_chroma_minus8 = get_ue_golomb_long(&gb); |
| 120 | // EVCDecoderConfigurationRecord can't store values > 7. Limit it to bit depth 14. |
| 121 | if (evcc->bit_depth_luma_minus8 > 6 || evcc->bit_depth_chroma_minus8 > 6) |
| 122 | return AVERROR_INVALIDDATA; |
| 123 | |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | // @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.3 |
| 128 | static int evcc_array_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size, |
no test coverage detected