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

Function parse_obu_header

libavcodec/av1_parse.h:92–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90void ff_av1_packet_uninit(AV1Packet *pkt);
91
92static inline int parse_obu_header(const uint8_t *buf, int buf_size,
93 int64_t *obu_size, int *start_pos, int *type,
94 int *temporal_id, int *spatial_id)
95{
96 GetBitContext gb;
97 int ret, extension_flag, has_size_flag;
98 int64_t size;
99
100 ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_OBU_HEADER_SIZE));
101 if (ret < 0)
102 return ret;
103
104 if (get_bits1(&gb) != 0) // obu_forbidden_bit
105 return AVERROR_INVALIDDATA;
106
107 *type = get_bits(&gb, 4);
108 extension_flag = get_bits1(&gb);
109 has_size_flag = get_bits1(&gb);
110 skip_bits1(&gb); // obu_reserved_1bit
111
112 if (extension_flag) {
113 *temporal_id = get_bits(&gb, 3);
114 *spatial_id = get_bits(&gb, 2);
115 skip_bits(&gb, 3); // extension_header_reserved_3bits
116 } else {
117 *temporal_id = *spatial_id = 0;
118 }
119
120 *obu_size = has_size_flag ? get_leb128(&gb)
121 : buf_size - 1 - extension_flag;
122
123 if (get_bits_left(&gb) < 0)
124 return AVERROR_INVALIDDATA;
125
126 *start_pos = get_bits_count(&gb) / 8;
127
128 size = *obu_size + *start_pos;
129
130 if (size > buf_size)
131 return AVERROR_INVALIDDATA;
132
133 return size;
134}
135
136static inline int get_obu_bit_length(const uint8_t *buf, int size, int type)
137{

Callers 5

read_obuFunction · 0.85
av1_filter_obusFunction · 0.85
ff_av1_parse_seq_headerFunction · 0.85
ff_isom_write_av1cFunction · 0.85
ff_av1_extract_obuFunction · 0.85

Calls 8

init_get_bits8Function · 0.85
get_bits1Function · 0.85
skip_bits1Function · 0.85
skip_bitsFunction · 0.85
get_leb128Function · 0.85
get_bits_leftFunction · 0.85
get_bits_countFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected