Go to the documentation of this file.
29 #ifndef AVFORMAT_RTP_AV1_H
30 #define AVFORMAT_RTP_AV1_H
37 #define AV1B_OBU_FORBIDDEN 7
38 #define AV1F_OBU_FORBIDDEN (1u << AV1B_OBU_FORBIDDEN)
39 #define AV1S_OBU_TYPE 3
40 #define AV1M_OBU_TYPE 15
41 #define AV1B_OBU_EXTENSION_FLAG 2
42 #define AV1F_OBU_EXTENSION_FLAG (1u << AV1B_OBU_EXTENSION_FLAG)
43 #define AV1B_OBU_HAS_SIZE_FIELD 1
44 #define AV1F_OBU_HAS_SIZE_FIELD (1u << AV1B_OBU_HAS_SIZE_FIELD)
45 #define AV1B_OBU_RESERVED_1BIT 0
46 #define AV1F_OBU_RESERVED_1BIT (1u << AV1B_OBU_RESERVED_1BIT)
48 #define AV1B_AGGR_HDR_FRAG_CONT 7
49 #define AV1F_AGGR_HDR_FRAG_CONT (1u << AV1B_AGGR_HDR_FRAG_CONT)
50 #define AV1B_AGGR_HDR_LAST_FRAG 6
51 #define AV1F_AGGR_HDR_LAST_FRAG (1u << AV1B_AGGR_HDR_LAST_FRAG)
52 #define AV1S_AGGR_HDR_NUM_OBUS 4
53 #define AV1M_AGGR_HDR_NUM_OBUS 3
54 #define AV1B_AGGR_HDR_FIRST_PKT 3
55 #define AV1F_AGGR_HDR_FIRST_PKT (1u << AV1B_AGGR_HDR_FIRST_PKT)
59 unsigned int num_lebs = 0;
68 static inline unsigned int write_leb(uint8_t *lebptr, uint32_t length) {
69 unsigned int num_lebs = 0;
76 *lebptr++ = length | 0x80;
83 static inline void write_leb_n(uint8_t *lebptr, uint32_t length,
unsigned int num_lebs) {
84 for (
int i = 0;
i < num_lebs;
i++) {
85 if (
i == num_lebs - 1) {
86 *lebptr = length & 0x7f;
88 *lebptr++ = length | 0x80;
95 static inline unsigned int parse_leb(
void *logctx,
const uint8_t *buf_ptr,
96 uint32_t buffer_size, uint32_t *obu_size) {
98 unsigned int num_lebs = 0;
113 if (((num_lebs == 4) && (leb7 >= 0x10)) || ((num_lebs > 4) && leb7)) {
114 av_log(logctx,
AV_LOG_ERROR,
"AV1: OBU size field exceeds 32 bit in AV1 RTP packet\n");
117 if ((num_lebs == 7) && (
leb128 >= 0x80)) {
120 av_log(logctx,
AV_LOG_ERROR,
"AV1: OBU size field consists of too many bytes in AV1 RTP packet\n");
125 *obu_size |= leb7 << (7 * num_lebs);
static void write_leb_n(uint8_t *lebptr, uint32_t length, unsigned int num_lebs)
write out fixed number of LEB bytes (may have "unused" bytes)
static unsigned int write_leb(uint8_t *lebptr, uint32_t length)
write out variable number of LEB bytes for the given length
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define i(width, name, range_min, range_max)
static unsigned int calc_leb_size(uint32_t length)
calculate number of required LEB bytes for the given length
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