38 #define STARTCODE_TEST \ 39 if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \ 40 if (src[i + 2] != 3) { \ 46 #if HAVE_FAST_UNALIGNED 47 #define FIND_FIRST_ZERO \ 48 if (i > 0 && !src[i]) \ 53 for (i = 0; i + 1 < length; i += 9) {
55 (
AV_RN64A(src + i) - 0x0100010001000101ULL)) &
56 0x8000800080008080ULL))
63 for (i = 0; i + 1 < length; i += 5) {
74 for (i = 0; i + 1 < length; i += 2) {
77 if (i > 0 && src[i - 1] == 0)
83 if (i >= length - 1) {
100 while (si + 2 < length) {
102 if (src[si + 2] > 3) {
103 dst[di++] = src[si++];
104 dst[di++] = src[si++];
105 }
else if (src[si] == 0 && src[si + 1] == 0) {
106 if (src[si + 2] == 3) {
116 dst[di++] = src[si++];
119 dst[di++] = src[si++];
136 while (skip_trailing_zeros && size > 0 && nal->
data[size - 1] == 0)
142 v = nal->
data[size - 1];
144 if (size > INT_MAX / 8)
176 "nal_unit_type: %d, nuh_layer_id: %dtemporal_id: %d\n",
179 return nuh_layer_id == 0;
193 "nal_unit_type: %d, nal_ref_idc: %d\n",
203 if (buf + 3 >= next_avc)
204 return next_avc - buf;
206 while (buf + i + 3 < next_avc) {
207 if (buf[i] == 0 && buf[i + 1] == 0 && buf[i + 2] == 1)
215 void *logctx,
int is_nalff,
int nal_length_size,
219 int consumed, ret = 0;
220 size_t next_avc = is_nalff ? 0 : length;
227 int extract_length = 0;
228 int skip_trailing_zeros = 1;
240 for (i = 0; i < nal_length_size; i++)
241 extract_length = (extract_length << 8) | bytestream2_get_byte(&bc);
245 "Invalid NAL unit size (%d > %d).\n",
269 }
else if (pkt->
nb_nals == 0) {
298 bytestream2_peek_be32(&bc) == 0x000001E0)
299 skip_trailing_zeros = 0;
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int get_bit_length(H2645NAL *nal, int skip_trailing_zeros)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
memory handling functions
int av_ctz(int v)
Trailing zero bit count.
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int is_nalff, int nal_length_size, enum AVCodecID codec_id)
Split an input packet into NAL units.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int size_bits
Size, in bits, of just the data, excluding the stop bit and any trailing padding. ...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
int ref_idc
H.264 only, nal_ref_idc.
static av_always_inline int bytestream2_tell(GetByteContext *g)
static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
static int h264_parse_nal_header(H2645NAL *nal, void *logctx)
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int temporal_id
HEVC only, nuh_temporal_id_plus_1 - 1.
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645NAL *nal)
Extract the raw (unescaped) bitstream.
static int find_next_start_code(const uint8_t *buf, const uint8_t *next_avc)