FFmpeg
Loading...
Searching...
No Matches
rtpdec_av1.c
Go to the documentation of this file.
1/*
2 * Depacketization for RTP Payload Format For AV1 (v1.0)
3 * https://aomediacodec.github.io/av1-rtp-spec/
4 * Copyright (c) 2024 Axis Communications
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/**
24 * @file
25 * @brief AV1 / RTP depacketization code (RTP Payload Format For AV1 (v1.0))
26 * @author Chris Hodges <chris.hodges@axis.com>
27 * @note The process will restore TDs and put back size fields into headers.
28 * It will also try to keep complete OBUs and remove partial OBUs
29 * caused by packet drops and thus keep the stream syntactically intact.
30 */
31
32#include "libavutil/avstring.h"
33#include "libavutil/mem.h"
34#include "avformat.h"
35
36#include "rtpdec.h"
37#include "libavcodec/av1.h"
38#include "rtp_av1.h"
39
40// enable tracing of packet data
41//#define RTPDEC_AV1_VERBOSE_TRACE
42
43/**
44 * RTP/AV1 specific private data.
45 */
46struct PayloadContext {
47 AVPacket *pkt; ///< temporal unit being assembled
48 uint32_t timestamp; ///< last received timestamp for frame
49 uint8_t profile; ///< profile (main/high/professional)
50 uint8_t level_idx; ///< level (0-31)
51 uint8_t tier; ///< main tier or high tier
52 uint16_t prev_seq; ///< sequence number of previous packet
53 unsigned int frag_obu_size; ///< current total size of fragmented OBU
54 unsigned int frag_pkt_leb_pos; ///< offset in buffer where OBU LEB starts
55 unsigned int frag_lebs_res; ///< number of bytes reserved for LEB
56 unsigned int frag_header_size; ///< size of OBU header (1 or 2)
57 int needs_td; ///< indicates that a TD should be output
58 int drop_fragment; ///< drop all fragments until next frame
59 int keyframe_seen; ///< keyframe was seen
60 int wait_for_keyframe; ///< message about waiting for keyframe has been issued
61};
62
64 AVStream *stream,
65 PayloadContext *av1_data,
66 const char *attr, const char *value) {
67 if (!strcmp(attr, "profile")) {
68 av1_data->profile = atoi(value);
69 av_log(s, AV_LOG_DEBUG, "RTP AV1 profile: %u\n", av1_data->profile);
70 } else if (!strcmp(attr, "level-idx")) {
71 av1_data->level_idx = atoi(value);
72 av_log(s, AV_LOG_DEBUG, "RTP AV1 level: %u\n", av1_data->profile);
73 } else if (!strcmp(attr, "tier")) {
74 av1_data->tier = atoi(value);
75 av_log(s, AV_LOG_DEBUG, "RTP AV1 tier: %u\n", av1_data->tier);
76 }
77 return 0;
78}
79
80// return 0 on complete packet, -1 on partial packet
82 AVStream *st, AVPacket *out_pkt, uint32_t *timestamp,
83 const uint8_t *buf, int len, uint16_t seq,
84 int flags) {
85 AVPacket *pkt = data->pkt;
86 uint8_t aggr_hdr;
87 int result = 0;
88 int is_frag_cont;
89 int is_last_fragmented;
90 int is_first_pkt;
91 unsigned int num_obus;
92 unsigned int obu_cnt = 1;
93 unsigned int rem_pkt_size = len;
94 unsigned int pktpos;
95 const uint8_t *buf_ptr = buf;
96 uint16_t expected_seq = data->prev_seq + 1;
97 int16_t seq_diff = seq - expected_seq;
98
99 data->prev_seq = seq;
100
101 if (!len) {
102 av_log(ctx, AV_LOG_ERROR, "Empty AV1 RTP packet\n");
103 return AVERROR_INVALIDDATA;
104 }
105 if (len < 2) {
106 av_log(ctx, AV_LOG_ERROR, "AV1 RTP packet too short\n");
107 return AVERROR_INVALIDDATA;
108 }
109
110 /* The payload structure is supposed to be straight-forward, but there are a
111 * couple of edge cases which need to be tackled and make things a bit more
112 * complex.
113 * These are mainly due to:
114 * - To reconstruct the OBU size for fragmented packets and place it the OBU
115 * header, the final size will not be known until the last fragment has
116 * been parsed. However, the number LEBs in the header is variable
117 * depending on the length of the payload.
118 * - We are increasing the out-packet size while we are getting fragmented
119 * OBUs. If an RTP packet gets dropped, we would create corrupted OBUs.
120 * In this case we decide to drop the whole frame.
121 */
122
123#ifdef RTPDEC_AV1_VERBOSE_TRACE
124 av_log(ctx, AV_LOG_TRACE, "RTP Packet %d in (%x), len=%d:\n",
125 seq, flags, len);
127 av_log(ctx, AV_LOG_TRACE, "... end at offset %x:\n", FFMAX(len - 64, 0));
128 av_hex_dump_log(ctx, AV_LOG_TRACE, buf + FFMAX(len - 64, 0), FFMIN(len - 64, 64));
129#endif
130
131 /* 8 bit aggregate header: Z Y W W N - - - */
132 aggr_hdr = *buf_ptr++;
133 rem_pkt_size--;
134
135 /* Z: MUST be set to 1 if the first OBU element is an OBU fragment that is a
136 * continuation of an OBU fragment from the previous packet, and MUST be set
137 * to 0 otherwise */
138 is_frag_cont = (aggr_hdr >> AV1B_AGGR_HDR_FRAG_CONT) & 1;
139
140 /* Y: MUST be set to 1 if the last OBU element is an OBU fragment that will
141 * continue in the next packet, and MUST be set to 0 otherwise */
142 is_last_fragmented = (aggr_hdr >> AV1B_AGGR_HDR_LAST_FRAG) & 1;
143
144 /* W: two bit field that describes the number of OBU elements in the packet.
145 * This field MUST be set equal to 0 or equal to the number of OBU elements
146 * contained in the packet.
147 * If set to 0, each OBU element MUST be preceded by a length field.
148 * If not set to 0 (i.e., W = 1, 2 or 3) the last OBU element MUST NOT be
149 * preceded by a length field (it's derived from RTP packet size minus other
150 * known lengths). */
151 num_obus = (aggr_hdr >> AV1S_AGGR_HDR_NUM_OBUS) & AV1M_AGGR_HDR_NUM_OBUS;
152
153 /* N: MUST be set to 1 if the packet is the first packet of a coded video
154 * sequence, and MUST be set to 0 otherwise.*/
155 is_first_pkt = (aggr_hdr >> AV1B_AGGR_HDR_FIRST_PKT) & 1;
156
157 if (is_frag_cont) {
158 if (data->drop_fragment) {
159 return AVERROR_INVALIDDATA;
160 }
161 if (is_first_pkt) {
162 av_log(ctx, AV_LOG_ERROR, "Illegal aggregation header in first AV1 RTP packet\n");
163 return AVERROR_INVALIDDATA;
164 }
165 if (seq_diff) {
166 av_log(ctx, AV_LOG_WARNING, "AV1 RTP frag packet sequence mismatch (%d != %d), dropping temporal unit\n",
167 seq, expected_seq);
168 goto drop_fragment;
169 }
170 if (!pkt->size || !data->frag_obu_size) {
171 av_log(ctx, AV_LOG_WARNING, "Unexpected fragment continuation in AV1 RTP packet\n");
172 goto drop_fragment; // avoid repeated output for the same fragment
173 }
174 } else {
175 if (!is_first_pkt && !data->keyframe_seen) {
176 if (!data->wait_for_keyframe) {
177 data->wait_for_keyframe = 1;
178 av_log(ctx, AV_LOG_WARNING, "AV1 RTP packet before keyframe, dropping and waiting for next keyframe\n");
179 }
180 goto drop_fragment;
181 }
182 if (seq_diff && !is_first_pkt) {
183 av_log(ctx, AV_LOG_WARNING, "AV1 RTP unfrag packet sequence mismatch (%d != %d), dropping temporal unit\n",
184 seq, expected_seq);
185 goto drop_fragment;
186 }
187 data->drop_fragment = 0;
188 if (!data->needs_td && ((data->timestamp != *timestamp) || is_first_pkt)) {
189 av_log(ctx, AV_LOG_TRACE, "Timestamp changed to %u (or first pkt %d), forcing TD\n", *timestamp, is_first_pkt);
190 data->needs_td = 1;
191 data->frag_obu_size = 0; // new temporal unit might have been caused by dropped packets
192 }
193 if (data->frag_obu_size) {
194 data->frag_obu_size = 0; // make sure we recover
195 av_log(ctx, AV_LOG_ERROR, "Missing fragment continuation in AV1 RTP packet\n");
196 return AVERROR_INVALIDDATA;
197 }
198 // update the timestamp in the frame packet with the one from the RTP packet
199 data->timestamp = *timestamp;
200 }
201 pktpos = pkt->size;
202
203#ifdef RTPDEC_AV1_VERBOSE_TRACE
204 av_log(ctx, AV_LOG_TRACE, "Input buffer size %d, aggr head 0x%02x fc %d, lf %d, no %d, fp %d\n",
205 len, aggr_hdr, is_frag_cont, is_last_fragmented, num_obus, is_first_pkt);
206#endif
207
208 if (is_first_pkt) {
209 pkt->flags |= AV_PKT_FLAG_KEY;
210 data->keyframe_seen = 1;
211 data->wait_for_keyframe = 0;
212 }
213
214 // loop over OBU elements
215 while (rem_pkt_size) {
216 uint32_t obu_size;
217 int num_lebs;
218 int needs_size_field;
219 int output_size;
220 unsigned int obu_payload_size;
221 uint8_t obu_hdr;
222
223 obu_size = rem_pkt_size;
224 if (!num_obus || obu_cnt < num_obus) {
225 // read out explicit OBU element size (which almost corresponds to the original OBU size)
226 num_lebs = parse_leb(ctx, buf_ptr, rem_pkt_size, &obu_size);
227 if (!num_lebs) {
228 return AVERROR_INVALIDDATA;
229 }
230 rem_pkt_size -= num_lebs;
231 buf_ptr += num_lebs;
232 }
233 if (obu_size > rem_pkt_size) {
234 av_log(ctx, AV_LOG_ERROR, "AV1 OBU size %u larger than remaining pkt size %d\n", obu_size, rem_pkt_size);
235 return AVERROR_INVALIDDATA;
236 }
237
238 if (!obu_size) {
239 av_log(ctx, AV_LOG_ERROR, "Unreasonable AV1 OBU size %u\n", obu_size);
240 return AVERROR_INVALIDDATA;
241 }
242
243 // read first byte (which is the header byte only for non-fragmented elements)
244 obu_hdr = *buf_ptr;
245 if (!is_frag_cont) {
246 uint8_t obu_type = (obu_hdr >> AV1S_OBU_TYPE) & AV1M_OBU_TYPE;
247 if (obu_hdr & AV1F_OBU_FORBIDDEN) {
248 av_log(ctx, AV_LOG_ERROR, "Forbidden bit set in AV1 OBU header (0x%02x)\n", obu_hdr);
249 return AVERROR_INVALIDDATA;
250 }
251 // ignore and remove OBUs according to spec
252 if ((obu_type == AV1_OBU_TEMPORAL_DELIMITER) ||
253 (obu_type == AV1_OBU_TILE_LIST)) {
254 buf_ptr += obu_size;
255 rem_pkt_size -= obu_size;
256 // TODO: This probably breaks if the OBU_TILE_LIST is fragmented
257 // into the next RTP packet, so at least check and fail here
258 if (rem_pkt_size == 0 && is_last_fragmented) {
259 avpriv_report_missing_feature(ctx, "AV1 OBU_TILE_LIST (should not be there!) to be ignored but is fragmented\n");
261 }
262 obu_cnt++;
263 continue;
264 }
265 }
266
267 // If we need to add a size field, out size will be different
268 output_size = obu_size;
269 // Spec says the OBUs should have their size fields removed,
270 // but this is not mandatory
271 if (is_frag_cont || (obu_hdr & AV1F_OBU_HAS_SIZE_FIELD)) {
272 needs_size_field = 0;
273 } else {
274 needs_size_field = 1;
275 // (re)calculate number of LEB bytes needed (if it was implicit, there were no LEBs)
276 output_size += calc_leb_size(obu_size - (1 + ((obu_hdr & AV1F_OBU_EXTENSION_FLAG) ? 1 : 0)));
277 }
278
279 if (!is_frag_cont && (obu_cnt == 1)) {
280 if (data->needs_td) {
281 output_size += 2; // for Temporal Delimiter (TD)
282 }
283 result = av_grow_packet(pkt, output_size);
284 if (result < 0)
285 return result;
286
287 if (data->needs_td) {
288 // restore TD
289 pkt->data[pktpos++] = 0x12;
290 pkt->data[pktpos++] = 0x00;
291 }
292 data->needs_td = 0;
293 } else {
294 if ((result = av_grow_packet(pkt, output_size)) < 0)
295 return result;
296 }
297
298 obu_payload_size = obu_size;
299 // do we need to restore the OBU size field?
300 if (needs_size_field) {
301 // set obu_has_size_field in header byte
302 pkt->data[pktpos++] = *buf_ptr++ | AV1F_OBU_HAS_SIZE_FIELD;
303 data->frag_header_size = 1;
304 obu_payload_size--;
305
306 // copy extension byte, if available
307 if (obu_hdr & AV1F_OBU_EXTENSION_FLAG) {
308 /* TODO we cannot handle the edge case where last element is a
309 * fragment of exactly one byte AND the header has the extension
310 * flag set. Note that it would be more efficient to not send a
311 * fragment of one byte and instead drop the size field of the
312 * prior element */
313 if (!obu_payload_size) {
314 av_log(ctx, AV_LOG_ERROR, "AV1 OBU too short for extension byte (0x%02x)\n",
315 obu_hdr);
316 return AVERROR_INVALIDDATA;
317 }
318 pkt->data[pktpos++] = *buf_ptr++;
319 data->frag_header_size = 2;
320 obu_payload_size--;
321 }
322
323 // remember start position of LEB for possibly fragmented packet to
324 // fixup OBU size later
325 data->frag_pkt_leb_pos = pktpos;
326 // write intermediate OBU size field
327 num_lebs = write_leb(pkt->data + pktpos, obu_payload_size);
328 data->frag_lebs_res = num_lebs;
329 pktpos += num_lebs;
330 } else if (!is_frag_cont) {
331 data->frag_lebs_res = 0;
332 }
333 // copy verbatim or without above header size patch
334 memcpy(pkt->data + pktpos, buf_ptr, obu_payload_size);
335 pktpos += obu_payload_size;
336 buf_ptr += obu_payload_size;
337 rem_pkt_size -= obu_size;
338
339 // if we were handling a fragmented packet and this was the last
340 // fragment, correct OBU size field
341 if (data->frag_obu_size && (rem_pkt_size || !is_last_fragmented)) {
342 if (data->frag_lebs_res) {
343 uint32_t final_obu_size = data->frag_obu_size + obu_size - data->frag_header_size;
344 uint8_t *lebptr = pkt->data + data->frag_pkt_leb_pos;
345 num_lebs = calc_leb_size(final_obu_size);
346
347 // check if we had allocated enough LEB bytes in header,
348 // otherwise make some extra space
349 if (num_lebs > data->frag_lebs_res) {
350 int extra_bytes = num_lebs - data->frag_lebs_res;
351 if ((result = av_grow_packet(pkt, extra_bytes)) < 0)
352 return result;
353 // update pointer in case buffer address changed
354 lebptr = pkt->data + data->frag_pkt_leb_pos;
355 // move existing data for OBU back a bit
356 memmove(lebptr + extra_bytes, lebptr,
357 pkt->size - extra_bytes - data->frag_pkt_leb_pos);
358 // move pktpos further down for following OBUs in same packet.
359 pktpos += extra_bytes;
360 }
361
362 // update OBU size field
363 write_leb(lebptr, final_obu_size);
364 }
365 data->frag_obu_size = 0; // signal end of fragment
366 } else if (is_last_fragmented && !rem_pkt_size) {
367 data->frag_obu_size += obu_size;
368 // fragment not yet finished!
369 result = -1;
370 }
371 is_frag_cont = 0;
372
373 if (!rem_pkt_size && num_obus && (num_obus != obu_cnt)) {
374 av_log(ctx, AV_LOG_WARNING, "AV1 aggregation header indicated %u OBU elements, was %u\n",
375 num_obus, obu_cnt);
376 }
377 obu_cnt++;
378 }
379
380 if (flags & RTP_FLAG_MARKER) {
381 av_log(ctx, AV_LOG_TRACE, "TD on next packet due to marker\n");
382 data->needs_td = 1;
383 } else {
384 // fragment may be complete, but temporal unit is not yet finished
385 result = -1;
386 }
387
388 if (!is_last_fragmented) {
389 data->frag_obu_size = 0;
390 data->frag_pkt_leb_pos = 0;
391 }
392
393#ifdef RTPDEC_AV1_VERBOSE_TRACE
394 if (!result) {
395 av_log(ctx, AV_LOG_TRACE, "AV1 out pkt-size: %d\n", pkt->size);
396 av_hex_dump_log(ctx, AV_LOG_TRACE, pkt->data, FFMIN(pkt->size, 64));
397 av_log(ctx, AV_LOG_TRACE, "... end at offset %x:\n", FFMAX(pkt->size - 64, 0));
398 av_hex_dump_log(ctx, AV_LOG_TRACE, pkt->data + FFMAX(pkt->size - 64, 0), FFMIN(pkt->size, 64));
399 }
400#endif
401 pkt->stream_index = st->index;
402
403 if (!result) {
404 av_packet_unref(out_pkt);
405 av_packet_move_ref(out_pkt, pkt);
406 }
407
408 return result;
409
410drop_fragment:
411 data->keyframe_seen = 0;
412 data->drop_fragment = 1;
413 data->frag_obu_size = 0;
414 data->needs_td = 1;
415 if (pkt->size) {
416 av_log(ctx, AV_LOG_TRACE, "Dumping current AV1 frame packet\n");
417 // we can't seem to deallocate the fragmented packet, but we can shrink it to 0
419 }
420 return AVERROR_INVALIDDATA;
421}
422
423static av_cold int av1_init(AVFormatContext *s, int st_index,
425{
426 if (!data->pkt)
427 data->pkt = av_packet_alloc();
428 if (!data->pkt)
429 return AVERROR(ENOMEM);
430
431 return 0;
432}
433
435 av_packet_free(&data->pkt);
436}
437
439{
440 return !data->keyframe_seen;
441}
442
443static int parse_av1_sdp_line(AVFormatContext *s, int st_index,
444 PayloadContext *av1_data, const char *line) {
445 AVStream * stream;
446 const char *p = line;
447 int result = 0;
448
449 if (st_index < 0)
450 return 0;
451
452 stream = s->streams[st_index];
453
454 /* Optional parameters are profile, level-idx, and tier.
455 * See Section 7.2.1 of https://aomediacodec.github.io/av1-rtp-spec/ */
456 if (av_strstart(p, "fmtp:", &p)) {
457 result = ff_parse_fmtp(s, stream, av1_data, p, sdp_parse_fmtp_config_av1);
458 av_log(s, AV_LOG_DEBUG, "RTP AV1 Profile: %u, Level: %u, Tier: %u\n",
459 av1_data->profile, av1_data->level_idx, av1_data->tier);
460 }
461
462 return result;
463}
464
466 .enc_name = "AV1",
467 .codec_type = AVMEDIA_TYPE_VIDEO,
468 .codec_id = AV_CODEC_ID_AV1,
469 .need_parsing = AVSTREAM_PARSE_FULL,
470 .priv_data_size = sizeof(PayloadContext),
471 .parse_sdp_a_line = parse_av1_sdp_line,
472 .init = av1_init,
475 .need_keyframe = av1_need_keyframe,
476};
static AVFormatContext * ctx
Main libavformat public API header.
@ AVSTREAM_PARSE_FULL
full parsing and repack
Definition avformat.h:613
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define s(width, name)
Definition cbs_vp9.c:198
static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index, int flush)
Parse a packet, add all split parts to parse_queue.
Definition demux.c:1273
static AVPacket * pkt
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:613
double value
Definition eval.c:102
@ AV_CODEC_ID_AV1
Definition codec_id.h:275
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:435
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition packet.c:121
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition packet.h:657
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition packet.c:492
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition packet.c:113
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition packet.c:63
void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the log.
Definition dump.c:89
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition error.h:64
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
Definition avstring.c:36
static av_cold int av1_init(AVCodecContext *avctx)
Definition libaomdec.c:284
AV1 common definitions.
@ AV1_OBU_TILE_LIST
Definition av1.h:37
@ AV1_OBU_TEMPORAL_DELIMITER
Definition av1.h:31
av_cold void CBS_FUNC close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition cbs.c:118
#define av_cold
Definition attributes.h:117
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FFMIN(a, b)
Definition macros.h:49
#define FFMAX(a, b)
Definition macros.h:47
Memory handling functions.
const char data[16]
Definition mxf.c:155
shared defines and functions for AV1 RTP dec/enc
#define AV1F_OBU_EXTENSION_FLAG
Definition rtp_av1.h:42
#define AV1B_AGGR_HDR_FRAG_CONT
Definition rtp_av1.h:48
#define AV1B_AGGR_HDR_FIRST_PKT
Definition rtp_av1.h:54
#define AV1M_AGGR_HDR_NUM_OBUS
Definition rtp_av1.h:53
static unsigned int parse_leb(void *logctx, const uint8_t *buf_ptr, uint32_t buffer_size, uint32_t *obu_size)
securely parse LEB bytes and return the resulting encoded length
Definition rtp_av1.h:95
#define AV1S_AGGR_HDR_NUM_OBUS
Definition rtp_av1.h:52
#define AV1F_OBU_HAS_SIZE_FIELD
Definition rtp_av1.h:44
static unsigned int write_leb(uint8_t *lebptr, uint32_t length)
write out variable number of LEB bytes for the given length
Definition rtp_av1.h:68
#define AV1M_OBU_TYPE
Definition rtp_av1.h:40
#define AV1B_AGGR_HDR_LAST_FRAG
Definition rtp_av1.h:50
#define AV1S_OBU_TYPE
Definition rtp_av1.h:39
#define AV1F_OBU_FORBIDDEN
Definition rtp_av1.h:38
static unsigned int calc_leb_size(uint32_t length)
calculate number of required LEB bytes for the given length
Definition rtp_av1.h:58
int ff_parse_fmtp(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *p, int(*parse_fmtp)(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *attr, const char *value))
Definition rtpdec.c:950
#define RTP_FLAG_MARKER
RTP marker bit was set for this packet.
Definition rtpdec.h:94
static int sdp_parse_fmtp_config_av1(AVFormatContext *s, AVStream *stream, PayloadContext *av1_data, const char *attr, const char *value)
Definition rtpdec_av1.c:63
static void av1_close_context(PayloadContext *data)
Definition rtpdec_av1.c:434
static int parse_av1_sdp_line(AVFormatContext *s, int st_index, PayloadContext *av1_data, const char *line)
Definition rtpdec_av1.c:443
const RTPDynamicProtocolHandler ff_av1_dynamic_handler
Definition rtpdec_av1.c:465
static av_cold int av1_init(AVFormatContext *s, int st_index, PayloadContext *data)
Definition rtpdec_av1.c:423
static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data, AVStream *st, AVPacket *out_pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags)
Definition rtpdec_av1.c:81
static int av1_need_keyframe(PayloadContext *data)
Definition rtpdec_av1.c:438
Format I/O context.
Definition avformat.h:1401
This structure stores compressed data.
Definition packet.h:587
Stream structure.
Definition avformat.h:768
int index
stream index in AVFormatContext
Definition avformat.h:774
RTP/AV1 specific private data.
Definition rdt.c:85
int needs_td
indicates that a TD should be output
Definition rtpdec_av1.c:57
AVPacket * pkt
temporal unit being assembled
Definition rtpdec_av1.c:47
int wait_for_keyframe
message about waiting for keyframe has been issued
Definition rtpdec_av1.c:60
uint8_t level_idx
level (0-31)
Definition rtpdec_av1.c:50
unsigned int frag_lebs_res
number of bytes reserved for LEB
Definition rtpdec_av1.c:55
int keyframe_seen
keyframe was seen
Definition rtpdec_av1.c:59
unsigned int frag_pkt_leb_pos
offset in buffer where OBU LEB starts
Definition rtpdec_av1.c:54
uint32_t timestamp
last received timestamp for frame
Definition rtpdec_ac3.c:31
uint16_t prev_seq
sequence number of previous packet
Definition rtpdec_av1.c:52
uint8_t tier
main tier or high tier
Definition rtpdec_av1.c:51
int drop_fragment
drop all fragments until next frame
Definition rtpdec_av1.c:58
uint8_t profile
profile (main/high/professional)
Definition rtpdec_av1.c:49
unsigned int frag_header_size
size of OBU header (1 or 2)
Definition rtpdec_av1.c:56
unsigned int frag_obu_size
current total size of fragmented OBU
Definition rtpdec_av1.c:53
#define av_log(a,...)
int len