Go to the documentation of this file.
34 #define MIN_HEVCC_LENGTH 23
44 int length_size, num_arrays,
i, j;
47 uint8_t *new_extradata =
NULL;
48 size_t new_extradata_size = 0;
53 length_size = (bytestream2_get_byte(&gb) & 3) + 1;
54 num_arrays = bytestream2_get_byte(&gb);
56 for (
i = 0;
i < num_arrays;
i++) {
57 int type = bytestream2_get_byte(&gb) & 0x3f;
58 int cnt = bytestream2_get_be16(&gb);
68 for (j = 0; j < cnt; j++) {
69 const int nalu_len = bytestream2_get_be16(&gb);
81 AV_WB32(new_extradata + new_extradata_size, 1);
83 new_extradata_size += 4 + nalu_len;
89 ctx->par_out->extradata = new_extradata;
90 ctx->par_out->extradata_size = new_extradata_size;
92 if (!new_extradata_size)
110 "The input looks like it is Annex B already\n");
115 s->length_size =
ret;
116 s->extradata_parsed = 1;
135 if (!
s->extradata_parsed) {
144 uint32_t nalu_size = 0;
146 int is_irap, add_extradata, extra_size, prev_size;
152 for (
i = 0;
i <
s->length_size;
i++)
153 nalu_size = (nalu_size << 8) | bytestream2_get_byte(&gb);
160 nalu_type = (bytestream2_peek_byte(&gb) >> 1) & 0x3f;
165 add_extradata = is_irap && !got_irap;
166 extra_size = add_extradata *
ctx->par_out->extradata_size;
169 if (
FFMIN(INT_MAX, SIZE_MAX) < 4ULL + nalu_size + extra_size) {
174 prev_size =
out->size;
181 memcpy(
out->data + prev_size,
ctx->par_out->extradata, extra_size);
182 AV_WB32(
out->data + prev_size + extra_size, 1);
203 .
p.
name =
"hevc_mp4toannexb",
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
#define AV_LOG_VERBOSE
Detailed information.
void(* filter)(uint8_t *src, int stride, int qscale)
const FFBitStreamFilter ff_hevc_mp4toannexb_bsf
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
Called by the bitstream filters to get the next packet for filtering.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
The bitstream filter state.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static int hevc_mp4toannexb_init(AVBSFContext *ctx)
static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
AVCodecID
Identify the syntax and semantics of the bitstream.
@ HEVC_NAL_RSV_IRAP_VCL23
AVBitStreamFilter p
The public AVBitStreamFilter.
int(* init)(AVBSFContext *ctx)
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
static enum AVCodecID codec_ids[]
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
#define i(width, name, range_min, range_max)
#define AV_INPUT_BUFFER_PADDING_SIZE
This structure stores compressed data.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
static int hevc_extradata_to_annexb(AVBSFContext *ctx)
void * priv_data
Format private data.