Go to the documentation of this file.
43 #define STARTCODE_TEST \
44 if (i + 2 < length && src[i + 1] == 0 && \
45 (src[i + 2] == 3 || src[i + 2] == 1)) { \
46 if (src[i + 2] == 1) { \
52 #if HAVE_FAST_UNALIGNED
53 #define FIND_FIRST_ZERO \
54 if (i > 0 && !src[i]) \
59 for (
i = 0;
i + 1 < length;
i += 9) {
62 0x8000800080008080ULL))
69 for (
i = 0;
i + 1 < length;
i += 5) {
80 for (
i = 0;
i + 1 < length;
i += 2) {
83 if (
i > 0 &&
src[
i - 1] == 0)
89 if (
i >= length - 1 && small_padding) {
95 }
else if (
i > length)
102 while (si + 2 < length) {
104 if (
src[si + 2] > 3) {
107 }
else if (
src[si] == 0 &&
src[si + 1] == 0 &&
src[si + 2] != 0) {
108 if (
src[si + 2] == 3) {
267 "Coded slice of a non-IDR picture",
268 "Coded slice data partition A",
269 "Coded slice data partition B",
270 "Coded slice data partition C",
282 "Depth parameter set",
285 "Auxiliary coded picture without partitioning",
287 "Slice extension for a depth view or a 3D-AVC texture view",
309 int trailing_padding = 0;
311 while (skip_trailing_zeros &&
size > 0 && nal->
data[
size - 1] == 0)
317 if (
size <= min_size) {
318 if (nal->
size < min_size)
326 trailing_padding =
ff_ctz(v) + 1;
329 if (
size > INT_MAX / 8)
333 return size - trailing_padding;
359 "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n",
380 "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n",
397 "nal_unit_type: %d(%s), nal_ref_idc: %d\n",
407 if (buf + 3 >= next_avc)
408 return next_avc - buf;
410 while (buf +
i + 3 < next_avc) {
411 if (buf[
i] == 0 && buf[
i + 1] == 0 && buf[
i + 2] == 1)
466 void *logctx,
int nal_length_size,
470 int consumed,
ret = 0;
477 if (!
pkt->rbsp.rbsp_buffer)
480 pkt->rbsp.rbsp_buffer_size = 0;
484 int extract_length = 0;
485 int skip_trailing_zeros = 1;
491 if (extract_length < 0)
492 return extract_length;
509 if (
pkt->nb_nals > 0) {
528 if (
pkt->nals_allocated <
pkt->nb_nals + 1) {
529 int new_size =
pkt->nals_allocated + 1;
532 if (new_size >= INT_MAX /
sizeof(*
pkt->nals))
540 memset(
pkt->nals +
pkt->nals_allocated, 0,
sizeof(*
pkt->nals));
542 nal = &
pkt->nals[
pkt->nb_nals];
548 pkt->nals_allocated = new_size;
550 nal = &
pkt->nals[
pkt->nb_nals];
559 "NALFF: Consumed only %d bytes instead of %d\n",
560 consumed, extract_length);
566 bytestream2_peek_be32(&bc) == 0x000001E0)
567 skip_trailing_zeros = 0;
570 skip_trailing_zeros);
603 for (
i = 0;
i <
pkt->nals_allocated;
i++) {
607 pkt->nals_allocated =
pkt->nal_buffer_size = 0;
608 if (
pkt->rbsp.rbsp_buffer_ref) {
613 pkt->rbsp.rbsp_buffer_alloc_size =
pkt->rbsp.rbsp_buffer_size = 0;
#define AV_LOG_WARNING
Something somehow does not look correct.
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
@ H2645_FLAG_SMALL_PADDING
static int get_bit_length(H2645NAL *nal, int min_size, int skip_trailing_zeros)
int ref_idc
H.264 only, nal_ref_idc.
static int h264_parse_nal_header(H2645NAL *nal, void *logctx)
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
static int find_next_start_code(const uint8_t *buf, const uint8_t *next_avc)
int skipped_bytes_pos_size
int temporal_id
HEVC only, nuh_temporal_id_plus_1 - 1.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
int size_bits
Size, in bits, of just the data, excluding the stop bit and any trailing padding.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const char * hevc_nal_unit_name(int nal_type)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const char *const h264_nal_type_name[32]
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.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
static unsigned int get_bits1(GetBitContext *s)
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
AVCodecID
Identify the syntax and semantics of the bitstream.
static av_always_inline int bytestream2_tell(GetByteContext *g)
static const char *const hevc_nal_type_name[64]
static const char *const vvc_nal_type_name[32]
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const char * vvc_nal_unit_name(int nal_type)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
static void skip_bits1(GetBitContext *s)
static const char * h264_nal_unit_name(int nal_type)
#define i(width, name, range_min, range_max)
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645RBSP *rbsp, H2645NAL *nal, int small_padding)
Extract the raw (unescaped) bitstream.
#define av_malloc_array(a, b)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVBufferRef * rbsp_buffer_ref
int rbsp_buffer_alloc_size
int av_buffer_is_writable(const AVBufferRef *buf)
#define AV_INPUT_BUFFER_PADDING_SIZE
static int vvc_parse_nal_header(H2645NAL *nal, void *logctx)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static int get_nalsize(int nal_length_size, const uint8_t *buf, int buf_size, int *buf_index, void *logctx)
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int nal_length_size, enum AVCodecID codec_id, int flags)
Split an input packet into NAL units.
static void alloc_rbsp_buffer(H2645RBSP *rbsp, unsigned int size, int use_ref)