33 const uint8_t *
a = p + 4 - ((intptr_t)p & 3);
35 for (end -= 3; p <
a && p < end; p++) {
36 if (p[0] == 0 && p[1] == 0 && p[2] == 1)
40 for (end -= 3; p < end; p += 4) {
41 uint32_t x = *(
const uint32_t*)p;
44 if ((x - 0x01010101) & (~x) & 0x80808080) {
46 if (p[0] == 0 && p[2] == 1)
48 if (p[2] == 0 && p[3] == 1)
52 if (p[2] == 0 && p[4] == 1)
54 if (p[4] == 0 && p[5] == 1)
60 for (end += 3; p < end; p++) {
61 if (p[0] == 0 && p[1] == 0 && p[2] == 1)
75 const uint8_t *buf_in,
int size)
77 const uint8_t *p = buf_in;
78 const uint8_t *end = p +
size;
79 const uint8_t *nal_start, *nal_end;
84 const size_t nalu_limit = SIZE_MAX /
sizeof(*list->
nalus);
85 while (nal_start < end && !*(nal_start++));
90 size_t nalu_size = nal_end - nal_start;
91 while (nalu_size > 0 && nal_start[nalu_size - 1] == 0)
96 }
else if (list->
nb_nalus >= nalu_limit) {
107 size += 4 + nalu_size;
150 unsigned int res = 0;
152 if (end - start < nal_length_size)
154 while (nal_length_size--)
155 res = (res << 8) | *start++;
157 if (res > end - start)
164 uint32_t *dst_len,
int header_len)
175 while (
i < header_len &&
i < src_len)
178 while (
i + 2 < src_len)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
void avio_wb32(AVIOContext *s, unsigned int val)
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
#define i(width, name, range_min, range_max)
Misc types and constants that do not belong anywhere else.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
Memory handling functions.
void ff_nal_units_write_list(const NALUList *list, AVIOContext *pb, const uint8_t *buf)
int ff_nal_parse_units(AVIOContext *pb, const uint8_t *buf_in, int size)
int ff_nal_parse_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
uint8_t * ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len, uint32_t *dst_len, int header_len)
static int nal_parse_units(AVIOContext *pb, NALUList *list, const uint8_t *buf_in, int size)
int ff_nal_units_create_list(NALUList *list, const uint8_t *buf, int size)
const uint8_t * ff_nal_mp4_find_startcode(const uint8_t *start, const uint8_t *end, int nal_length_size)
const uint8_t * ff_nal_find_startcode(const uint8_t *p, const uint8_t *end)
static const uint8_t * nal_find_startcode_internal(const uint8_t *p, const uint8_t *end)
unsigned nb_nalus
valid entries in nalus
unsigned nalus_array_size