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)))
117 if (++
i == 8 && more)
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;
144 int ret,
type, cnt = 0;
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;
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)
187 cnt += obu_unit_size;
193 frame_unit_size -= obu_unit_size + ret;
194 }
while (frame_unit_size);
201 AnnexBContext *
c =
s->priv_data;
207 AnnexBContext *
c =
s->priv_data;
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");
264 AnnexBContext *
c =
s->priv_data;
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;
361 ret = read_obu_with_size(p->
buf + cnt, p->
buf_size - cnt, &obu_size, &
type);
362 if (ret < 0 || obu_size <= 0)
375 ObuContext *
c =
s->priv_data;
384 ObuContext *
c =
s->priv_data;
424 ObuContext *
c =
s->priv_data;
428 ret = obu_get_packet(
s,
pkt);
434 "av1_frame_merge filter\n");
440 "send output packet\n");
450 ObuContext *
c =
s->priv_data;
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,
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)
#define MAX_OBU_HEADER_SIZE
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int avio_r8(AVIOContext *s)
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))
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define flags(name, subs,...)
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
common internal and external API header
a very simple circular buffer FIFO implementation
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_bits_count(const GetBitContext *s)
static void skip_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
@ AV1_OBU_TEMPORAL_DELIMITER
@ AV1_OBU_SEQUENCE_HEADER
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
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 ...
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_read(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_space(const AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
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.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
static const uint8_t header[24]
The bitstream filter state.
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int eof_reached
true if was unable to read due to error or eof
int error
contains the error code or 0 if no error happened
This structure stores compressed data.
This structure contains the data a format has to probe a file.
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.
Rational number (pair of numerator and denominator).
AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
enum AVStreamParseType need_parsing
AVStreamInternal * internal
An opaque field for libavformat internal usage.