| 84 | }; |
| 85 | |
| 86 | static int parse_nal_unit(AVCodecParserContext *s, AVCodecContext *avctx, |
| 87 | const H2645NAL *nal) |
| 88 | { |
| 89 | GetByteContext gbc; |
| 90 | bytestream2_init(&gbc, nal->data, nal->size); |
| 91 | bytestream2_skip(&gbc, 2); |
| 92 | |
| 93 | while (bytestream2_get_bytes_left(&gbc) > 1) { |
| 94 | GetBitContext gb; |
| 95 | uint64_t payload_size; |
| 96 | int payload_size_type, payload_type; |
| 97 | int block_size; |
| 98 | |
| 99 | int ret = init_get_bits8(&gb, gbc.buffer, bytestream2_get_bytes_left(&gbc)); |
| 100 | if (ret < 0) |
| 101 | return ret; |
| 102 | |
| 103 | payload_size_type = get_bits(&gb, 3); |
| 104 | payload_type = get_bits(&gb, 5); |
| 105 | payload_size = payload_size_type; |
| 106 | if (payload_size_type == 6) |
| 107 | return AVERROR_PATCHWELCOME; |
| 108 | if (payload_size_type == 7) |
| 109 | payload_size = get_mb(&gb); |
| 110 | |
| 111 | if (payload_size > INT_MAX - (get_bits_count(&gb) >> 3)) |
| 112 | return AVERROR_INVALIDDATA; |
| 113 | |
| 114 | block_size = payload_size + (get_bits_count(&gb) >> 3); |
| 115 | if (block_size >= bytestream2_get_bytes_left(&gbc)) |
| 116 | return AVERROR_INVALIDDATA; |
| 117 | |
| 118 | switch (payload_type) { |
| 119 | case LCEVC_PAYLOAD_TYPE_SEQUENCE_CONFIG: |
| 120 | avctx->profile = get_bits(&gb, 4); |
| 121 | avctx->level = get_bits(&gb, 4); |
| 122 | break; |
| 123 | case LCEVC_PAYLOAD_TYPE_GLOBAL_CONFIG: { |
| 124 | int resolution_type, chroma_format_idc, bit_depth; |
| 125 | int processed_planes_type_flag; |
| 126 | |
| 127 | processed_planes_type_flag = get_bits1(&gb); |
| 128 | resolution_type = get_bits(&gb, 6); |
| 129 | skip_bits1(&gb); |
| 130 | chroma_format_idc = get_bits(&gb, 2); |
| 131 | skip_bits(&gb, 2); |
| 132 | bit_depth = get_bits(&gb, 2); // enhancement_depth_type |
| 133 | |
| 134 | s->format = pix_fmts[bit_depth][chroma_format_idc]; |
| 135 | |
| 136 | if (resolution_type < 63) { |
| 137 | s->width = ff_lcevc_resolution_type[resolution_type].width; |
| 138 | s->height = ff_lcevc_resolution_type[resolution_type].height; |
| 139 | } else { |
| 140 | int upsample_type, tile_dimensions_type; |
| 141 | int temporal_step_width_modifier_signalled_flag, level1_filtering_signalled_flag; |
| 142 | // Skip syntax elements until we get to the custom dimension ones |
| 143 | temporal_step_width_modifier_signalled_flag = get_bits1(&gb); |
no test coverage detected