Go to the documentation of this file.
65 const char *attr,
const char *
value) {
66 if (!strcmp(attr,
"profile")) {
69 }
else if (!strcmp(attr,
"level-idx")) {
72 }
else if (!strcmp(attr,
"tier")) {
82 const uint8_t *buf,
int len, uint16_t seq,
87 int is_last_fragmented;
89 unsigned int num_obus;
90 unsigned int obu_cnt = 1;
91 unsigned int rem_pkt_size =
len;
93 const uint8_t *buf_ptr = buf;
94 uint16_t expected_seq =
data->prev_seq + 1;
95 int16_t seq_diff = seq - expected_seq;
121 #ifdef RTPDEC_AV1_VERBOSE_TRACE
130 aggr_hdr = *buf_ptr++;
156 if (
data->drop_fragment) {
173 if (!is_first_pkt && !
data->keyframe_seen) {
174 if (!
data->wait_for_keyframe) {
175 data->wait_for_keyframe = 1;
180 if (seq_diff && !is_first_pkt) {
185 data->drop_fragment = 0;
186 if (!
data->needs_td && ((
data->timestamp != *timestamp) || is_first_pkt)) {
187 av_log(
ctx,
AV_LOG_TRACE,
"Timestamp changed to %u (or first pkt %d), forcing TD\n", *timestamp, is_first_pkt);
189 data->frag_obu_size = 0;
191 if (
data->frag_obu_size) {
192 data->frag_obu_size = 0;
197 data->timestamp = *timestamp;
201 #ifdef RTPDEC_AV1_VERBOSE_TRACE
203 len, aggr_hdr, is_frag_cont, is_last_fragmented, num_obus, is_first_pkt);
208 data->keyframe_seen = 1;
209 data->wait_for_keyframe = 0;
213 while (rem_pkt_size) {
216 int needs_size_field;
218 unsigned int obu_payload_size;
221 obu_size = rem_pkt_size;
222 if (!num_obus || obu_cnt < num_obus) {
224 num_lebs =
parse_leb(
ctx, buf_ptr, rem_pkt_size, &obu_size);
228 rem_pkt_size -= num_lebs;
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);
253 rem_pkt_size -= obu_size;
256 if (rem_pkt_size == 0 && is_last_fragmented) {
266 output_size = obu_size;
270 needs_size_field = 0;
272 needs_size_field = 1;
277 if (!is_frag_cont && (obu_cnt == 1)) {
278 if (
data->needs_td) {
289 if (
data->needs_td) {
300 obu_payload_size = obu_size;
302 if (needs_size_field) {
305 data->frag_header_size = 1;
315 if (!obu_payload_size) {
320 pkt->
data[pktpos++] = *buf_ptr++;
321 data->frag_header_size = 2;
327 data->frag_pkt_leb_pos = pktpos;
330 data->frag_lebs_res = num_lebs;
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;
341 if (
data->frag_obu_size && (rem_pkt_size || !is_last_fragmented)) {
342 uint32_t final_obu_size =
data->frag_obu_size + obu_size -
data->frag_header_size;
343 uint8_t *lebptr =
pkt->
data +
data->frag_pkt_leb_pos;
348 if (num_lebs >
data->frag_lebs_res) {
349 int extra_bytes = num_lebs -
data->frag_lebs_res;
355 memmove(lebptr + extra_bytes, lebptr,
358 pktpos += extra_bytes;
364 data->frag_obu_size = 0;
365 }
else if (is_last_fragmented && !rem_pkt_size) {
368 if (needs_size_field ||
data->frag_obu_size) {
369 data->frag_obu_size += obu_size;
376 if (!rem_pkt_size && !num_obus && (num_obus != obu_cnt)) {
391 if (!is_last_fragmented) {
392 data->frag_obu_size = 0;
393 data->frag_pkt_leb_pos = 0;
396 #ifdef RTPDEC_AV1_VERBOSE_TRACE
409 data->keyframe_seen = 0;
410 data->drop_fragment = 1;
411 data->frag_obu_size = 0;
426 return !
data->keyframe_seen;
432 const char *p =
line;
438 stream =
s->streams[st_index];
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV1M_AGGR_HDR_NUM_OBUS
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))
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
#define RTP_FLAG_MARKER
RTP marker bit was set for this packet.
const RTPDynamicProtocolHandler ff_av1_dynamic_handler
@ AV1_OBU_TEMPORAL_DELIMITER
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static unsigned int write_leb(uint8_t *lebptr, uint32_t length)
write out variable number of LEB bytes for the given length
uint8_t level_idx
level (0-31)
uint8_t tier
main tier or high tier
uint32_t timestamp
last received timestamp for frame
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
unsigned int frag_lebs_res
number of bytes reserved for LEB
unsigned int frag_pkt_leb_pos
offset in buffer where OBU LEB starts
#define AV1F_OBU_FORBIDDEN
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV1F_OBU_HAS_SIZE_FIELD
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV1B_AGGR_HDR_FRAG_CONT
unsigned int frag_obu_size
current total size of fragmented OBU
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV1F_OBU_EXTENSION_FLAG
and forward the result(frame or status change) to the corresponding input. If nothing is possible
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int av1_need_keyframe(PayloadContext *data)
uint16_t prev_seq
sequence number of previous packet
static int parse_av1_sdp_line(AVFormatContext *s, int st_index, PayloadContext *av1_data, const char *line)
uint8_t profile
profile (main/high/professional)
static void av1_close_context(PayloadContext *data)
unsigned int frag_header_size
size of OBU header (1 or 2)
static int sdp_parse_fmtp_config_av1(AVFormatContext *s, AVStream *stream, PayloadContext *av1_data, const char *attr, const char *value)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int needs_td
indicates that a TD should be output
int flags
A combination of AV_PKT_FLAG values.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
static unsigned int calc_leb_size(uint32_t length)
calculate number of required LEB bytes for the given length
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
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
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.
int index
stream index in AVFormatContext
shared defines and functions for AV1 RTP dec/enc
static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index, int flush)
Parse a packet, add all split parts to parse_queue.
int drop_fragment
drop all fragments until next frame
#define AV1B_AGGR_HDR_FIRST_PKT
#define AV1B_AGGR_HDR_LAST_FRAG
This structure stores compressed data.
#define AV1S_AGGR_HDR_NUM_OBUS
int wait_for_keyframe
message about waiting for keyframe has been issued
#define flags(name, subs,...)
static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
RTP/AV1 specific private data.
int keyframe_seen
keyframe was seen
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line