22#include "config_components.h"
71 "not found. This is a bug, please report it.\n");
111#define DEC AV_OPT_FLAG_DECODING_PARAM
112#define OFFSET(x) offsetof(AV1DemuxContext, x)
120 .class_name =
"AV1 Annex B/low overhead OBU demuxer",
126#if CONFIG_AV1_DEMUXER
140 if (
i <= 3 || (
i == 4 &&
bits < (1 << 4)))
144 if (++
i == 8 && more)
150static int read_obu(
const uint8_t *buf,
int size,
int64_t *obu_size,
int *
type)
152 int start_pos, temporal_id, spatial_id;
156 type, &temporal_id, &spatial_id);
168 uint32_t temporal_unit_size, frame_unit_size, obu_unit_size;
170 int ret,
type, cnt = 0;
174 ret = leb(pb, &temporal_unit_size, 1);
178 ret = leb(pb, &frame_unit_size, 0);
179 if (ret < 0 || ((
int64_t)frame_unit_size + ret) > temporal_unit_size)
182 ret = leb(pb, &obu_unit_size, 0);
183 if (ret < 0 || ((
int64_t)obu_unit_size + ret) >= frame_unit_size)
187 frame_unit_size -= obu_unit_size + ret;
194 ret = read_obu(
p->buf + cnt,
FFMIN(
p->buf_size - cnt, obu_unit_size), &obu_size, &
type);
195 if (ret < 0 || type != AV1_OBU_TEMPORAL_DELIMITER || obu_size > 0)
197 cnt += obu_unit_size;
200 ret = leb(pb, &obu_unit_size, 0);
201 if (ret < 0 || ((
int64_t)obu_unit_size + ret) > frame_unit_size)
209 ret = read_obu(
p->buf + cnt,
FFMIN(
p->buf_size - cnt, obu_unit_size), &obu_size, &
type);
212 cnt += obu_unit_size;
218 frame_unit_size -= obu_unit_size + ret;
219 }
while (frame_unit_size);
227 uint32_t obu_unit_size;
233 if (
c->temporal_unit_size ||
c->frame_unit_size)
238 if (!
c->temporal_unit_size) {
240 len = leb(
s->pb, &
c->temporal_unit_size, 1);
242 else if (
len < 0)
return len;
245 if (!
c->frame_unit_size) {
246 len = leb(
s->pb, &
c->frame_unit_size, 0);
249 if (((
int64_t)
c->frame_unit_size +
len) >
c->temporal_unit_size)
251 c->temporal_unit_size -=
len;
254 len = leb(
s->pb, &obu_unit_size, 0);
257 if (((
int64_t)obu_unit_size +
len) >
c->frame_unit_size)
263 if (ret != obu_unit_size)
266 c->temporal_unit_size -= obu_unit_size +
len;
267 c->frame_unit_size -= obu_unit_size +
len;
273 "av1_frame_merge filter\n");
283 "send output packet\n");
295 .p.extensions =
"obu",
307#if CONFIG_OBU_DEMUXER
311static int read_obu_with_size(
const uint8_t *buf,
int buf_size,
int64_t *obu_size,
int *
type)
314 int ret, extension_flag, start_pos;
330 if (extension_flag) {
337 if (*obu_size > INT_MAX)
345 size = *obu_size + start_pos;
358 cnt = read_obu_with_size(
p->buf,
p->buf_size, &obu_size, &
type);
363 ret = read_obu_with_size(
p->buf + cnt,
p->buf_size - cnt, &obu_size, &
type);
364 if (ret < 0 || obu_size <= 0)
366 cnt +=
FFMIN(ret,
p->buf_size - cnt);
410 if (
s->io_repositioned) {
412 s->io_repositioned = 0;
415 ret = obu_get_packet(
s,
pkt);
424 "av1_frame_merge filter\n");
430 "send output packet\n");
441 .p.extensions =
"obu",
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
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
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_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
void ffio_init_read_context(FFIOContext *s, const uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for reading.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
common internal and external API header
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
static int annexb_probe(const AVProbeData *p)
static const uint8_t bits[8]
static int read_header(FFV1Context *f, RangeCoder *c)
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
Underlying C type is 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.
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
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.
AVStream * avformat_new_stream(AVFormatContext *s, const struct 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
static int64_t get_leb128(GetBitContext *gb)
Read a unsigned integer coded as a variable number of up to eight little-endian bytes,...
@ AV1_OBU_TEMPORAL_DELIMITER
@ AV1_OBU_SEQUENCE_HEADER
static const AVOption av1_options[]
#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)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
static const uint8_t header[24]
uint32_t temporal_unit_size
The bitstream filter state.
Describe the class of an AVClass context structure.
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.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational avg_frame_rate
Average framerate.
enum AVStreamParseType need_parsing
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static AVFormatContext * ctx