41 #define STARTCODE_TEST \ 42 if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \ 43 if (src[i + 2] != 3 && src[i + 2] != 0) { \ 49 #if HAVE_FAST_UNALIGNED 50 #define FIND_FIRST_ZERO \ 51 if (i > 0 && !src[i]) \ 56 for (i = 0; i + 1 <
length; i += 9) {
58 (
AV_RN64(src + i) - 0x0100010001000101ULL)) &
59 0x8000800080008080ULL))
66 for (i = 0; i + 1 <
length; i += 5) {
68 (
AV_RN32(src + i) - 0x01000101U)) &
77 for (i = 0; i + 1 <
length; i += 2) {
80 if (i > 0 && src[i - 1] == 0)
86 if (i >= length - 1 && small_padding) {
92 }
else if (i > length)
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 && src[si + 2] != 0) {
106 if (src[si + 2] == 3) {
132 dst[di++] = src[si++];
135 dst[di++] = src[si++];
224 "Coded slice of a non-IDR picture",
225 "Coded slice data partition A",
226 "Coded slice data partition B",
227 "Coded slice data partition C",
239 "Depth parameter set",
242 "Auxiliary coded picture without partitioning",
244 "Slice extension for a depth view or a 3D-AVC texture view",
268 while (skip_trailing_zeros && size > 0 && nal->
data[size - 1] == 0)
274 v = nal->
data[size - 1];
276 if (size > INT_MAX / 8)
307 "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n",
324 "nal_unit_type: %d(%s), nal_ref_idc: %d\n",
334 if (buf + 3 >= next_avc)
335 return next_avc - buf;
337 while (buf + i + 3 < next_avc) {
338 if (buf[i] == 0 && buf[i + 1] == 0 && buf[i + 2] == 1)
360 size =
FFMIN(size + size / 16 + 32, INT_MAX);
393 void *logctx,
int is_nalff,
int nal_length_size,
397 int consumed,
ret = 0;
398 int next_avc = is_nalff ? 0 :
length;
411 int extract_length = 0;
412 int skip_trailing_zeros = 1;
418 if (extract_length < 0)
419 return extract_length;
459 if (new_size >= INT_MAX /
sizeof(*pkt->
nals))
483 if (is_nalff && (extract_length != consumed) && extract_length)
485 "NALFF: Consumed only %d bytes instead of %d\n",
486 consumed, extract_length);
492 bytestream2_peek_be32(&bc) == 0x000001E0)
493 skip_trailing_zeros = 0;
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
static const char *const h264_nal_type_name[32]
static int get_bit_length(H2645NAL *nal, int skip_trailing_zeros)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
Memory handling functions.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static void alloc_rbsp_buffer(H2645RBSP *rbsp, unsigned int size, int use_ref)
static const char *const hevc_nal_type_name[64]
int size_bits
Size, in bits, of just the data, excluding the stop bit and any trailing padding. ...
int skipped_bytes_pos_size
#define av_assert0(cond)
assert() equivalent, that is always enabled.
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, int small_padding, int use_ref)
Split an input packet into NAL units.
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
H.264 common definitions.
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.
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
static int get_nalsize(int nal_length_size, const uint8_t *buf, int buf_size, int *buf_index, void *logctx)
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.
int av_buffer_is_writable(const AVBufferRef *buf)
int ref_idc
H.264 only, nal_ref_idc.
static av_always_inline int bytestream2_tell(GetByteContext *g)
AVBufferRef * rbsp_buffer_ref
static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
static int h264_parse_nal_header(H2645NAL *nal, void *logctx)
int rbsp_buffer_alloc_size
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const char * hevc_nal_unit_name(int nal_type)
static const char * h264_nal_unit_name(int nal_type)
#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.
#define av_malloc_array(a, b)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645RBSP *rbsp, H2645NAL *nal, int small_padding)
Extract the raw (unescaped) bitstream.
static int find_next_start_code(const uint8_t *buf, const uint8_t *next_avc)