59 "not found. This is a bug, please report it.\n");
93 #define DEC AV_OPT_FLAG_DECODING_PARAM 95 #if CONFIG_AV1_DEMUXER 96 typedef struct AnnexBContext {
99 uint32_t temporal_unit_size;
100 uint32_t frame_unit_size;
113 if (i <= 3 || (i == 4 && bits < (1 << 4)))
114 *len |= bits << (i * 7);
117 if (++i == 8 && more)
125 static int read_obu(
const uint8_t *buf,
int size, int64_t *obu_size,
int *
type)
127 int start_pos, temporal_id, spatial_id;
131 type, &temporal_id, &spatial_id);
142 uint32_t temporal_unit_size, frame_unit_size, obu_unit_size;
149 ret = leb(&pb, &temporal_unit_size);
153 ret = leb(&pb, &frame_unit_size);
154 if (ret < 0 || ((int64_t)frame_unit_size + ret) > temporal_unit_size)
157 ret = leb(&pb, &obu_unit_size);
158 if (ret < 0 || ((int64_t)obu_unit_size + ret) >= frame_unit_size)
162 frame_unit_size -= obu_unit_size +
ret;
169 ret = read_obu(p->
buf + cnt,
FFMIN(p->
buf_size - cnt, obu_unit_size), &obu_size, &type);
170 if (ret < 0 || type != AV1_OBU_TEMPORAL_DELIMITER || obu_size > 0)
172 cnt += obu_unit_size;
175 ret = leb(&pb, &obu_unit_size);
176 if (ret < 0 || ((int64_t)obu_unit_size + ret) > frame_unit_size)
184 ret = read_obu(p->
buf + cnt,
FFMIN(p->
buf_size - cnt, obu_unit_size), &obu_size, &type);
187 cnt += obu_unit_size;
193 frame_unit_size -= obu_unit_size +
ret;
194 }
while (frame_unit_size);
208 uint32_t obu_unit_size;
213 if (c->temporal_unit_size || c->frame_unit_size)
218 if (!c->temporal_unit_size) {
219 len = leb(s->
pb, &c->temporal_unit_size);
223 if (!c->frame_unit_size) {
224 len = leb(s->
pb, &c->frame_unit_size);
225 if (len < 0 || ((int64_t)c->frame_unit_size + len) > c->temporal_unit_size)
227 c->temporal_unit_size -=
len;
230 len = leb(s->
pb, &obu_unit_size);
231 if (len < 0 || ((int64_t)obu_unit_size + len) > c->frame_unit_size)
237 if (ret != obu_unit_size)
240 c->temporal_unit_size -= obu_unit_size +
len;
241 c->frame_unit_size -= obu_unit_size +
len;
247 "av1_frame_merge filter\n");
254 "send output packet\n");
270 #define OFFSET(x) offsetof(AnnexBContext, x) 271 static const AVOption annexb_options[] = {
277 static const AVClass annexb_demuxer_class = {
280 .option = annexb_options,
287 .priv_data_size =
sizeof(AnnexBContext),
294 .priv_class = &annexb_demuxer_class,
298 #if CONFIG_OBU_DEMUXER 299 typedef struct ObuContext {
309 static int read_obu_with_size(
const uint8_t *buf,
int buf_size, int64_t *obu_size,
int *
type)
312 int ret, extension_flag, start_pos;
328 if (extension_flag) {
335 if (*obu_size > INT_MAX)
343 size = *obu_size + start_pos;
356 cnt = read_obu_with_size(p->
buf, p->
buf_size, &obu_size, &type);
361 ret = read_obu_with_size(p->
buf + cnt, p->
buf_size - cnt, &obu_size, &type);
362 if (ret < 0 || obu_size <= 0)
398 len = read_obu_with_size(header, size, &obu_size, &type);
409 size =
FFMIN(size, len);
428 ret = obu_get_packet(s, pkt);
434 "av1_frame_merge filter\n");
440 "send output packet\n");
457 #define OFFSET(x) offsetof(ObuContext, x) 458 static const AVOption obu_options[] = {
464 static const AVClass obu_demuxer_class = {
467 .option = obu_options,
474 .priv_data_size =
sizeof(ObuContext),
481 .priv_class = &obu_demuxer_class,
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define LIBAVUTIL_VERSION_INT
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
The bitstream filter state.
const char * av_default_item_name(void *ptr)
Return the context name.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int read_header(AVFormatContext *s, const AVRational *framerate, AVBSFContext **bsf, void *logctx)
int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static av_cold int end(AVCodecContext *avctx)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
enum AVStreamParseType need_parsing
int av_fifo_space(const AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
static int get_bits_count(const GetBitContext *s)
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
static const uint8_t header[24]
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static int get_bits_left(GetBitContext *gb)
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
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 default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your local see the OFFSET() macro
enum AVMediaType codec_type
General type of the encoded data.
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
int avio_r8(AVIOContext *s)
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int parse_obu_header(const uint8_t *buf, int buf_size, int64_t *obu_size, int *start_pos, int *type, int *temporal_id, int *spatial_id)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
AVStreamInternal * internal
An opaque field for libavformat internal usage.
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
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_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
AVIOContext * pb
I/O context.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
a very simple circular buffer FIFO implementation
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
Describe the class of an AVClass context structure.
static void skip_bits(GetBitContext *s, int n)
Rational number (pair of numerator and denominator).
offset must point to AVRational
int error
contains the error code or 0 if no error happened
This structure contains the data a format has to probe a file.
#define flags(name, subs,...)
common internal and external API header
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
#define MAX_OBU_HEADER_SIZE
int eof_reached
true if was unable to read due to error or eof
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
void * priv_data
Format private data.
AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
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 int get_score(int type, int *seq)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
This structure stores compressed data.