Go to the documentation of this file.
34 #include "startcode.h"
58 for (
size_t i = 0;
i <
len;
i++)
66 static const int metadata_obu_types[] = {
83 static const int extradata_obu_types[] = {
102 int extradata_size = 0, filtered_size = 0;
103 int i, has_seq = 0,
ret = 0;
109 for (
i = 0;
i <
s->av1_pkt.nb_obus;
i++) {
115 }
else if (
s->remove) {
120 if (extradata_size && has_seq) {
140 *
size = extradata_size;
146 for (
i = 0;
i <
s->av1_pkt.nb_obus;
i++) {
150 }
else if (
s->remove) {
169 static const int extradata_nal_types_vvc[] = {
172 static const int extradata_nal_types_hevc[] = {
175 static const int extradata_nal_types_h264[] = {
181 int extradata_size = 0, filtered_size = 0;
182 const int *extradata_nal_types;
183 size_t nb_extradata_nal_types;
184 int i, has_sps = 0, has_vps = 0,
ret = 0;
187 extradata_nal_types = extradata_nal_types_vvc;
190 extradata_nal_types = extradata_nal_types_hevc;
191 nb_extradata_nal_types =
FF_ARRAY_ELEMS(extradata_nal_types_hevc);
193 extradata_nal_types = extradata_nal_types_h264;
194 nb_extradata_nal_types =
FF_ARRAY_ELEMS(extradata_nal_types_h264);
202 for (
i = 0;
i <
s->h2645_pkt.nb_nals;
i++) {
204 if (
val_in_array(extradata_nal_types, nb_extradata_nal_types,
nal->type)) {
205 extradata_size +=
nal->raw_size + 3;
215 }
else if (
s->remove) {
216 filtered_size +=
nal->raw_size + 3;
220 if (extradata_size &&
243 *
size = extradata_size;
249 for (
i = 0;
i <
s->h2645_pkt.nb_nals;
i++) {
251 if (
val_in_array(extradata_nal_types, nb_extradata_nal_types,
253 bytestream2_put_be24u(&pb_extradata, 1);
255 }
else if (
s->remove) {
256 bytestream2_put_be24u(&pb_filtered_data, 1);
283 int skipped_byte_pos = 0;
287 bytestream2_put_be16(pbc, bytestream2_get_be16(&gbc));
292 int payload_size_type, payload_type;
293 uint64_t payload_size;
294 int block_size, raw_block_size, block_end;
298 payload_size_type =
get_bits(&gb, 3);
300 payload_size = payload_size_type;
301 if (payload_size_type == 6)
303 if (payload_size_type == 7)
304 payload_size =
get_mb(&gb);
309 block_size = raw_block_size = payload_size + (
get_bits_count(&gb) >> 3);
316 for (; skipped_byte_pos <
nal->skipped_bytes; skipped_byte_pos++) {
317 if (
nal->skipped_bytes_pos[skipped_byte_pos] >= block_end)
322 switch (payload_type) {
343 if (!remove && !sc && !gc)
346 bytestream2_put_byte(pbc, 0x80);
354 static const int extradata_nal_types[] = {
360 int extradata_size = 0, filtered_size = 0;
361 size_t nb_extradata_nal_types =
FF_ARRAY_ELEMS(extradata_nal_types);
369 for (
i = 0;
i <
s->h2645_pkt.nb_nals;
i++) {
371 if (
val_in_array(extradata_nal_types, nb_extradata_nal_types,
nal->type)) {
375 extradata_size +=
nal->raw_size + 3;
377 filtered_size +=
nal->raw_size + 3;
380 if (extradata_size) {
407 for (
i = 0;
i <
s->h2645_pkt.nb_nals;
i++) {
409 if (
val_in_array(extradata_nal_types, nb_extradata_nal_types,
411 bytestream2_put_be24(&pb_extradata, 1);
420 bytestream2_put_be24(&pb_filtered_data, 1);
427 filtered_size +=
ret;
429 }
else if (
s->remove) {
430 bytestream2_put_be24(&pb_filtered_data, 1);
432 filtered_size +=
nal->raw_size;
452 uint32_t
state = UINT32_MAX;
453 int has_extradata = 0, extradata_size = 0;
460 extradata_size = ptr - 4 -
pkt->
data;
465 if (extradata_size) {
471 *
size = extradata_size;
486 uint32_t
state = UINT32_MAX;
493 else if (found &&
state != 0x1B5 && state < 0x200 && state >= 0x100) {
516 uint32_t
state = UINT32_MAX;
540 static const struct {
579 uint8_t *extradata =
NULL;
587 ret =
s->extract(
ctx,
pkt, &extradata, &extradata_size);
594 extradata, extradata_size);
631 #define OFFSET(x) offsetof(ExtractExtradataContext, x)
632 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
635 { .i64 = 0 }, 0, 1,
FLAGS },
647 .
p.
name =
"extract_extradata",
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
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
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static av_always_inline int bytestream2_tell(const GetByteContext *g)
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
uint8_t * data
The data buffer.
static int get_bits_count(const GetBitContext *s)
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
void(* filter)(uint8_t *src, int stride, int qscale)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static uint64_t get_mb(GetBitContext *s)
The bitstream filter state.
int ff_av1_packet_split(AV1Packet *pkt, const uint8_t *buf, int length, void *logctx)
Split an input packet into OBUs.
static av_cold void close(AVCodecParserContext *s)
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.
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
An input packet split into OBUs.
@ LCEVC_PAYLOAD_TYPE_SEQUENCE_CONFIG
static double val(void *priv, double ch)
#define FF_ARRAY_ELEMS(a)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
static av_always_inline int bytestream2_tell_p(const PutByteContext *p)
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
static AVFormatContext * ctx
@ AV1_METADATA_TYPE_HDR_MDCV
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static unsigned get_leb(GetBitContext *s)
Read a unsigned integer coded as a variable number of up to eight little-endian bytes,...
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
@ LCEVC_PAYLOAD_TYPE_ADDITIONAL_INFO
const char * av_default_item_name(void *ptr)
Return the context name.
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
AVCodecID
Identify the syntax and semantics of the bitstream.
AVBitStreamFilter p
The public AVBitStreamFilter.
int(* init)(AVBSFContext *ctx)
#define i(width, name, range_min, range_max)
@ AV1_OBU_SEQUENCE_HEADER
@ LCEVC_PAYLOAD_TYPE_GLOBAL_CONFIG
int raw_size
Size of entire OBU, including header.
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
int size_bits
Size, in bits, of just the data, excluding the trailing_one_bit and any trailing padding.
@ H2645_FLAG_SMALL_PADDING
static int FUNC() nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
@ AV1_METADATA_TYPE_HDR_CLL
void ff_av1_packet_uninit(AV1Packet *pkt)
Free all the allocated memory in the packet.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void * av_malloc(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define AV_INPUT_BUFFER_PADDING_SIZE
@ AV_OPT_TYPE_INT
Underlying C type is int.
A reference to a data buffer.
static av_always_inline unsigned int bytestream2_put_bufferu(PutByteContext *p, const uint8_t *src, unsigned int size)
This structure stores compressed data.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
#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.
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
void * priv_data
Format private data.