Go to the documentation of this file.
33 #include "startcode.h"
57 for (
size_t i = 0;
i <
len;
i++)
65 static const int metadata_obu_types[] = {
82 static const int extradata_obu_types[] = {
101 int extradata_size = 0, filtered_size = 0;
102 int i, has_seq = 0,
ret = 0;
108 for (
i = 0;
i <
s->av1_pkt.nb_obus;
i++) {
114 }
else if (
s->remove) {
119 if (extradata_size && has_seq) {
139 *
size = extradata_size;
145 for (
i = 0;
i <
s->av1_pkt.nb_obus;
i++) {
149 }
else if (
s->remove) {
168 static const int extradata_nal_types_vvc[] = {
171 static const int extradata_nal_types_hevc[] = {
174 static const int extradata_nal_types_h264[] = {
180 int extradata_size = 0, filtered_size = 0;
181 const int *extradata_nal_types;
182 size_t nb_extradata_nal_types;
183 int i, has_sps = 0, has_vps = 0,
ret = 0;
186 extradata_nal_types = extradata_nal_types_vvc;
189 extradata_nal_types = extradata_nal_types_hevc;
190 nb_extradata_nal_types =
FF_ARRAY_ELEMS(extradata_nal_types_hevc);
192 extradata_nal_types = extradata_nal_types_h264;
193 nb_extradata_nal_types =
FF_ARRAY_ELEMS(extradata_nal_types_h264);
201 for (
i = 0;
i <
s->h2645_pkt.nb_nals;
i++) {
203 if (
val_in_array(extradata_nal_types, nb_extradata_nal_types,
nal->type)) {
204 extradata_size +=
nal->raw_size + 3;
214 }
else if (
s->remove) {
215 filtered_size +=
nal->raw_size + 3;
219 if (extradata_size &&
242 *
size = extradata_size;
248 for (
i = 0;
i <
s->h2645_pkt.nb_nals;
i++) {
250 if (
val_in_array(extradata_nal_types, nb_extradata_nal_types,
252 bytestream2_put_be24u(&pb_extradata, 1);
254 }
else if (
s->remove) {
255 bytestream2_put_be24u(&pb_filtered_data, 1);
277 unsigned bits =
byte & 0x7f;
298 int skipped_byte_pos = 0;
302 bytestream2_put_be16(pbc, bytestream2_get_be16(&gbc));
307 int payload_size_type, payload_type, payload_size;
308 int block_size, raw_block_size, block_end;
312 payload_size_type =
get_bits(&gb, 3);
314 payload_size = payload_size_type;
315 if (payload_size_type == 6)
317 if (payload_size_type == 7)
318 payload_size =
get_mb(&gb);
320 block_size = raw_block_size = payload_size + (
get_bits_count(&gb) >> 3);
327 for (; skipped_byte_pos <
nal->skipped_bytes; skipped_byte_pos++) {
328 if (
nal->skipped_bytes_pos[skipped_byte_pos] >= block_end)
333 switch (payload_type) {
354 if (!remove && !sc && !gc)
357 bytestream2_put_byte(pbc, 0x80);
365 static const int extradata_nal_types[] = {
371 int extradata_size = 0, filtered_size = 0;
372 size_t nb_extradata_nal_types =
FF_ARRAY_ELEMS(extradata_nal_types);
380 for (
i = 0;
i <
s->h2645_pkt.nb_nals;
i++) {
382 if (
val_in_array(extradata_nal_types, nb_extradata_nal_types,
nal->type)) {
386 extradata_size +=
nal->raw_size + 3;
388 filtered_size +=
nal->raw_size + 3;
391 if (extradata_size) {
418 for (
i = 0;
i <
s->h2645_pkt.nb_nals;
i++) {
420 if (
val_in_array(extradata_nal_types, nb_extradata_nal_types,
422 bytestream2_put_be24(&pb_extradata, 1);
431 bytestream2_put_be24(&pb_filtered_data, 1);
438 filtered_size +=
ret;
440 }
else if (
s->remove) {
441 bytestream2_put_be24(&pb_filtered_data, 1);
443 filtered_size +=
nal->raw_size;
463 uint32_t
state = UINT32_MAX;
464 int has_extradata = 0, extradata_size = 0;
471 extradata_size = ptr - 4 -
pkt->
data;
476 if (extradata_size) {
482 *
size = extradata_size;
497 uint32_t
state = UINT32_MAX;
504 else if (found &&
state != 0x1B5 && state < 0x200 && state >= 0x100) {
527 uint32_t
state = UINT32_MAX;
551 static const struct {
590 uint8_t *extradata =
NULL;
598 ret =
s->extract(
ctx,
pkt, &extradata, &extradata_size);
605 extradata, extradata_size);
642 #define OFFSET(x) offsetof(ExtractExtradataContext, x)
643 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
646 { .i64 = 0 }, 0, 1,
FLAGS },
658 .
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.
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.