Go to the documentation of this file.
33 #define MIN_HEVCC_LENGTH 23
43 int length_size, num_arrays,
i, j;
46 uint8_t *new_extradata =
NULL;
47 size_t new_extradata_size = 0;
52 length_size = (bytestream2_get_byte(&gb) & 3) + 1;
53 num_arrays = bytestream2_get_byte(&gb);
55 for (
i = 0;
i < num_arrays;
i++) {
56 int type = bytestream2_get_byte(&gb) & 0x3f;
57 int cnt = bytestream2_get_be16(&gb);
67 for (j = 0; j < cnt; j++) {
68 int nalu_len = bytestream2_get_be16(&gb);
78 AV_WB32(new_extradata + new_extradata_size, 1);
80 new_extradata_size += 4 + nalu_len;
86 ctx->par_out->extradata = new_extradata;
87 ctx->par_out->extradata_size = new_extradata_size;
89 if (!new_extradata_size)
107 "The input looks like it is Annex B already\n");
112 s->length_size =
ret;
113 s->extradata_parsed = 1;
132 if (!
s->extradata_parsed) {
141 uint32_t nalu_size = 0;
143 int is_irap, add_extradata, extra_size, prev_size;
149 for (
i = 0;
i <
s->length_size;
i++)
150 nalu_size = (nalu_size << 8) | bytestream2_get_byte(&gb);
157 nalu_type = (bytestream2_peek_byte(&gb) >> 1) & 0x3f;
160 is_irap = nalu_type >= 16 && nalu_type <= 23;
161 add_extradata = is_irap && !got_irap;
162 extra_size = add_extradata *
ctx->par_out->extradata_size;
165 if (
FFMIN(INT_MAX, SIZE_MAX) < 4ULL + nalu_size + extra_size) {
170 prev_size =
out->size;
177 memcpy(
out->data + prev_size,
ctx->par_out->extradata, extra_size);
178 AV_WB32(
out->data + prev_size + extra_size, 1);
199 .
name =
"hevc_mp4toannexb",
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int hevc_mp4toannexb_init(AVBSFContext *ctx)
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
#define AV_LOG_VERBOSE
Detailed information.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
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)
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 enum AVCodecID codec_ids[]
const AVBitStreamFilter ff_hevc_mp4toannexb_bsf
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.
static int hevc_extradata_to_annexb(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
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
static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
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
void * priv_data
Format private data.