MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / parse_nal_unit

Function parse_nal_unit

libavcodec/lcevc_parser.c:86–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84};
85
86static 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);

Callers 1

parse_nal_unitsFunction · 0.70

Calls 11

bytestream2_initFunction · 0.85
bytestream2_skipFunction · 0.85
init_get_bits8Function · 0.85
get_mbFunction · 0.85
get_bits_countFunction · 0.85
get_bits1Function · 0.85
skip_bits1Function · 0.85
skip_bitsFunction · 0.85
skip_bits_longFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected