FFmpeg
av1dec.c
Go to the documentation of this file.
1 /*
2  * AV1 Annex B demuxer
3  * Copyright (c) 2019 James Almer <jamrial@gmail.com>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "config.h"
23 
24 #include "libavutil/common.h"
25 #include "libavutil/opt.h"
26 #include "libavcodec/av1_parse.h"
27 #include "libavcodec/bsf.h"
28 #include "avformat.h"
29 #include "avio_internal.h"
30 #include "internal.h"
31 
32 typedef struct AV1DemuxContext {
33  const AVClass *class;
37  uint32_t frame_unit_size;
39 
40 //return < 0 if we need more data
41 static int get_score(int type, int *seq)
42 {
43  switch (type) {
45  *seq = 1;
46  return -1;
47  case AV1_OBU_FRAME:
49  return *seq ? AVPROBE_SCORE_EXTENSION + 1 : 0;
50  case AV1_OBU_METADATA:
51  case AV1_OBU_PADDING:
52  return -1;
53  default:
54  break;
55  }
56  return 0;
57 }
58 
60 {
61  AV1DemuxContext *const c = s->priv_data;
62  const AVBitStreamFilter *filter = av_bsf_get_by_name("av1_frame_merge");
63  AVStream *st;
64  FFStream *sti;
65  int ret;
66 
67  if (!filter) {
68  av_log(s, AV_LOG_ERROR, "av1_frame_merge bitstream filter "
69  "not found. This is a bug, please report it.\n");
70  return AVERROR_BUG;
71  }
72 
73  st = avformat_new_stream(s, NULL);
74  if (!st)
75  return AVERROR(ENOMEM);
76  sti = ffstream(st);
77 
81 
82  sti->avctx->framerate = c->framerate;
83  // taken from rawvideo demuxers
84  avpriv_set_pts_info(st, 64, 1, 1200000);
85 
86  ret = av_bsf_alloc(filter, &c->bsf);
87  if (ret < 0)
88  return ret;
89 
90  ret = avcodec_parameters_copy(c->bsf->par_in, st->codecpar);
91  if (ret < 0)
92  return ret;
93 
94  ret = av_bsf_init(c->bsf);
95  if (ret < 0)
96  return ret;
97 
98  return 0;
99 }
100 
102 {
103  AV1DemuxContext *const c = s->priv_data;
104 
105  av_bsf_free(&c->bsf);
106  return 0;
107 }
108 
109 #define DEC AV_OPT_FLAG_DECODING_PARAM
110 #define OFFSET(x) offsetof(AV1DemuxContext, x)
111 static const AVOption av1_options[] = {
112  { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC},
113  { NULL },
114 };
115 #undef OFFSET
116 
117 static const AVClass av1_demuxer_class = {
118  .class_name = "AV1 Annex B/low overhead OBU demuxer",
119  .item_name = av_default_item_name,
120  .option = av1_options,
121  .version = LIBAVUTIL_VERSION_INT,
122 };
123 
124 #if CONFIG_AV1_DEMUXER
125 
126 static int leb(AVIOContext *pb, uint32_t *len) {
127  int more, i = 0;
128  uint8_t byte;
129  *len = 0;
130  do {
131  unsigned bits;
132  byte = avio_r8(pb);
133  more = byte & 0x80;
134  bits = byte & 0x7f;
135  if (i <= 3 || (i == 4 && bits < (1 << 4)))
136  *len |= bits << (i * 7);
137  else if (bits)
138  return AVERROR_INVALIDDATA;
139  if (++i == 8 && more)
140  return AVERROR_INVALIDDATA;
141  if (pb->eof_reached || pb->error)
142  return pb->error ? pb->error : AVERROR(EIO);
143  } while (more);
144  return i;
145 }
146 
147 static int read_obu(const uint8_t *buf, int size, int64_t *obu_size, int *type)
148 {
149  int start_pos, temporal_id, spatial_id;
150  int len;
151 
152  len = parse_obu_header(buf, size, obu_size, &start_pos,
153  type, &temporal_id, &spatial_id);
154  if (len < 0)
155  return len;
156 
157  return 0;
158 }
159 
160 static int annexb_probe(const AVProbeData *p)
161 {
163  AVIOContext *const pb = &ctx.pub;
164  int64_t obu_size;
165  uint32_t temporal_unit_size, frame_unit_size, obu_unit_size;
166  int seq = 0;
167  int ret, type, cnt = 0;
168 
169  ffio_init_context(&ctx, p->buf, p->buf_size, 0,
170  NULL, NULL, NULL, NULL);
171 
172  ret = leb(pb, &temporal_unit_size);
173  if (ret < 0)
174  return 0;
175  cnt += ret;
176  ret = leb(pb, &frame_unit_size);
177  if (ret < 0 || ((int64_t)frame_unit_size + ret) > temporal_unit_size)
178  return 0;
179  cnt += ret;
180  ret = leb(pb, &obu_unit_size);
181  if (ret < 0 || ((int64_t)obu_unit_size + ret) >= frame_unit_size)
182  return 0;
183  cnt += ret;
184 
185  frame_unit_size -= obu_unit_size + ret;
186 
187  avio_skip(pb, obu_unit_size);
188  if (pb->eof_reached || pb->error)
189  return 0;
190 
191  // Check that the first OBU is a Temporal Delimiter.
192  ret = read_obu(p->buf + cnt, FFMIN(p->buf_size - cnt, obu_unit_size), &obu_size, &type);
193  if (ret < 0 || type != AV1_OBU_TEMPORAL_DELIMITER || obu_size > 0)
194  return 0;
195  cnt += obu_unit_size;
196 
197  do {
198  ret = leb(pb, &obu_unit_size);
199  if (ret < 0 || ((int64_t)obu_unit_size + ret) > frame_unit_size)
200  return 0;
201  cnt += ret;
202 
203  avio_skip(pb, obu_unit_size);
204  if (pb->eof_reached || pb->error)
205  return 0;
206 
207  ret = read_obu(p->buf + cnt, FFMIN(p->buf_size - cnt, obu_unit_size), &obu_size, &type);
208  if (ret < 0)
209  return 0;
210  cnt += obu_unit_size;
211 
212  ret = get_score(type, &seq);
213  if (ret >= 0)
214  return ret;
215 
216  frame_unit_size -= obu_unit_size + ret;
217  } while (frame_unit_size);
218 
219  return 0;
220 }
221 
222 static int annexb_read_packet(AVFormatContext *s, AVPacket *pkt)
223 {
224  AV1DemuxContext *const c = s->priv_data;
225  uint32_t obu_unit_size;
226  int ret, len;
227 
228 retry:
229  if (avio_feof(s->pb)) {
230  if (c->temporal_unit_size || c->frame_unit_size)
231  return AVERROR(EIO);
232  goto end;
233  }
234 
235  if (!c->temporal_unit_size) {
236  len = leb(s->pb, &c->temporal_unit_size);
237  if (len < 0) return AVERROR_INVALIDDATA;
238  }
239 
240  if (!c->frame_unit_size) {
241  len = leb(s->pb, &c->frame_unit_size);
242  if (len < 0 || ((int64_t)c->frame_unit_size + len) > c->temporal_unit_size)
243  return AVERROR_INVALIDDATA;
244  c->temporal_unit_size -= len;
245  }
246 
247  len = leb(s->pb, &obu_unit_size);
248  if (len < 0 || ((int64_t)obu_unit_size + len) > c->frame_unit_size)
249  return AVERROR_INVALIDDATA;
250 
251  ret = av_get_packet(s->pb, pkt, obu_unit_size);
252  if (ret < 0)
253  return ret;
254  if (ret != obu_unit_size)
255  return AVERROR(EIO);
256 
257  c->temporal_unit_size -= obu_unit_size + len;
258  c->frame_unit_size -= obu_unit_size + len;
259 
260 end:
261  ret = av_bsf_send_packet(c->bsf, pkt);
262  if (ret < 0) {
263  av_log(s, AV_LOG_ERROR, "Failed to send packet to "
264  "av1_frame_merge filter\n");
265  return ret;
266  }
267 
268  ret = av_bsf_receive_packet(c->bsf, pkt);
269  if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
270  av_log(s, AV_LOG_ERROR, "av1_frame_merge filter failed to "
271  "send output packet\n");
272 
273  if (ret == AVERROR(EAGAIN))
274  goto retry;
275 
276  return ret;
277 }
278 
280  .name = "av1",
281  .long_name = NULL_IF_CONFIG_SMALL("AV1 Annex B"),
282  .priv_data_size = sizeof(AV1DemuxContext),
283  .flags_internal = FF_FMT_INIT_CLEANUP,
284  .read_probe = annexb_probe,
286  .read_packet = annexb_read_packet,
288  .extensions = "obu",
290  .priv_class = &av1_demuxer_class,
291 };
292 #endif
293 
294 #if CONFIG_OBU_DEMUXER
295 //For low overhead obu, we can't foresee the obu size before we parsed the header.
296 //So, we can't use parse_obu_header here, since it will check size <= buf_size
297 //see c27c7b49dc for more details
298 static int read_obu_with_size(const uint8_t *buf, int buf_size, int64_t *obu_size, int *type)
299 {
300  GetBitContext gb;
301  int ret, extension_flag, start_pos;
302  int64_t size;
303 
304  ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_OBU_HEADER_SIZE));
305  if (ret < 0)
306  return ret;
307 
308  if (get_bits1(&gb) != 0) // obu_forbidden_bit
309  return AVERROR_INVALIDDATA;
310 
311  *type = get_bits(&gb, 4);
312  extension_flag = get_bits1(&gb);
313  if (!get_bits1(&gb)) // has_size_flag
314  return AVERROR_INVALIDDATA;
315  skip_bits1(&gb); // obu_reserved_1bit
316 
317  if (extension_flag) {
318  get_bits(&gb, 3); // temporal_id
319  get_bits(&gb, 2); // spatial_id
320  skip_bits(&gb, 3); // extension_header_reserved_3bits
321  }
322 
323  *obu_size = leb128(&gb);
324  if (*obu_size > INT_MAX)
325  return AVERROR_INVALIDDATA;
326 
327  if (get_bits_left(&gb) < 0)
328  return AVERROR_INVALIDDATA;
329 
330  start_pos = get_bits_count(&gb) / 8;
331 
332  size = *obu_size + start_pos;
333  if (size > INT_MAX)
334  return AVERROR_INVALIDDATA;
335  return size;
336 }
337 
338 static int obu_probe(const AVProbeData *p)
339 {
340  int64_t obu_size;
341  int seq = 0;
342  int ret, type, cnt;
343 
344  // Check that the first OBU is a Temporal Delimiter.
345  cnt = read_obu_with_size(p->buf, p->buf_size, &obu_size, &type);
346  if (cnt < 0 || type != AV1_OBU_TEMPORAL_DELIMITER || obu_size != 0)
347  return 0;
348 
349  while (1) {
350  ret = read_obu_with_size(p->buf + cnt, p->buf_size - cnt, &obu_size, &type);
351  if (ret < 0 || obu_size <= 0)
352  return 0;
353  cnt += FFMIN(ret, p->buf_size - cnt);
354 
355  ret = get_score(type, &seq);
356  if (ret >= 0)
357  return ret;
358  }
359  return 0;
360 }
361 
362 static int obu_get_packet(AVFormatContext *s, AVPacket *pkt)
363 {
364  AV1DemuxContext *const c = s->priv_data;
366  int64_t obu_size;
367  int size;
368  int ret, len, type;
369 
370  if ((ret = ffio_ensure_seekback(s->pb, MAX_OBU_HEADER_SIZE)) < 0)
371  return ret;
373  if (size < 0)
374  return size;
375 
376  len = read_obu_with_size(header, size, &obu_size, &type);
377  if (len < 0) {
378  av_log(c, AV_LOG_ERROR, "Failed to read obu\n");
379  return len;
380  }
381  avio_seek(s->pb, -size, SEEK_CUR);
382 
383  ret = av_get_packet(s->pb, pkt, len);
384  if (ret != len) {
385  av_log(c, AV_LOG_ERROR, "Failed to get packet for obu\n");
386  return ret < 0 ? ret : AVERROR_INVALIDDATA;
387  }
388  return 0;
389 }
390 
391 static int obu_read_packet(AVFormatContext *s, AVPacket *pkt)
392 {
393  AV1DemuxContext *const c = s->priv_data;
394  int ret;
395 
396  if (s->io_repositioned) {
397  av_bsf_flush(c->bsf);
398  s->io_repositioned = 0;
399  }
400  while (1) {
401  ret = obu_get_packet(s, pkt);
402  /* In case of AVERROR_EOF we need to flush the BSF. Conveniently
403  * obu_get_packet() returns a blank pkt in this case which
404  * can be used to signal that the BSF should be flushed. */
405  if (ret < 0 && ret != AVERROR_EOF)
406  return ret;
407  ret = av_bsf_send_packet(c->bsf, pkt);
408  if (ret < 0) {
409  av_log(s, AV_LOG_ERROR, "Failed to send packet to "
410  "av1_frame_merge filter\n");
411  return ret;
412  }
413  ret = av_bsf_receive_packet(c->bsf, pkt);
414  if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
415  av_log(s, AV_LOG_ERROR, "av1_frame_merge filter failed to "
416  "send output packet\n");
417  if (ret != AVERROR(EAGAIN))
418  break;
419  }
420 
421  return ret;
422 }
423 
425  .name = "obu",
426  .long_name = NULL_IF_CONFIG_SMALL("AV1 low overhead OBU"),
427  .priv_data_size = sizeof(AV1DemuxContext),
428  .flags_internal = FF_FMT_INIT_CLEANUP,
429  .read_probe = obu_probe,
431  .read_packet = obu_read_packet,
433  .extensions = "obu",
435  .priv_class = &av1_demuxer_class,
436 };
437 #endif
AVFMT_NO_BYTE_SEEK
#define AVFMT_NO_BYTE_SEEK
Format does not allow seeking by bytes.
Definition: avformat.h:483
FF_FMT_INIT_CLEANUP
#define FF_FMT_INIT_CLEANUP
For an AVInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition: internal.h:49
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:850
AVERROR
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
opt.h
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:768
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
get_score
static int get_score(int type, int *seq)
Definition: av1dec.c:41
AV1DemuxContext
Definition: av1dec.c:32
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:237
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:220
av_bsf_init
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Definition: bsf.c:145
ff_obu_demuxer
const AVInputFormat ff_obu_demuxer
AVOption
AVOption.
Definition: opt.h:247
AVIOContext::error
int error
contains the error code or 0 if no error happened
Definition: avio.h:240
filter
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
Definition: filter_design.txt:228
AVProbeData::buf_size
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:450
AV1_OBU_TEMPORAL_DELIMITER
@ AV1_OBU_TEMPORAL_DELIMITER
Definition: av1.h:31
FFIOContext
Definition: avio_internal.h:29
AVBSFContext
The bitstream filter state.
Definition: bsf.h:47
av_bsf_get_by_name
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
Definition: bitstream_filters.c:78
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:468
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:1710
framerate
int framerate
Definition: h264_levels.c:65
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:380
av1_parse.h
bsf.h
ffstream
static av_always_inline FFStream * ffstream(AVStream *st)
Definition: internal.h:432
AV1_OBU_FRAME_HEADER
@ AV1_OBU_FRAME_HEADER
Definition: av1.h:32
GetBitContext
Definition: get_bits.h:62
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:141
AVFMT_GENERIC_INDEX
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition: avformat.h:476
type
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 type
Definition: writing_filters.txt:86
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AVInputFormat
Definition: avformat.h:650
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:678
parse_obu_header
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)
Definition: av1_parse.h:107
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:655
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:449
av1_read_close
static int av1_read_close(AVFormatContext *s)
Definition: av1dec.c:101
bits
uint8_t bits
Definition: vp3data.h:141
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FFStream::need_parsing
enum AVStreamParseType need_parsing
Definition: internal.h:405
AVFormatContext
Format I/O context.
Definition: avformat.h:1200
internal.h
DEC
#define DEC
Definition: av1dec.c:109
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1095
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
leb128
#define leb128(name)
Definition: cbs_av1.c:705
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:279
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:499
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:447
c
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
Definition: undefined.txt:32
AVPROBE_SCORE_EXTENSION
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition: avformat.h:457
AV1DemuxContext::bsf
AVBSFContext * bsf
Definition: av1dec.c:34
AV1_OBU_FRAME
@ AV1_OBU_FRAME
Definition: av1.h:35
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
OFFSET
#define OFFSET(x)
Definition: av1dec.c:110
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
byte
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
Definition: bytestream.h:99
FFStream
Definition: internal.h:194
ff_av1_demuxer
const AVInputFormat ff_av1_demuxer
size
int size
Definition: twinvq_data.h:10344
AV1_OBU_SEQUENCE_HEADER
@ AV1_OBU_SEQUENCE_HEADER
Definition: av1.h:30
header
static const uint8_t header[24]
Definition: sdr2.c:67
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:632
ffio_ensure_seekback
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
Definition: aviobuf.c:1055
skip_bits1
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:539
AV1DemuxContext::frame_unit_size
uint32_t frame_unit_size
Definition: av1dec.c:37
avcodec_parameters_copy
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
Definition: codec_par.c:72
AV1_OBU_PADDING
@ AV1_OBU_PADDING
Definition: av1.h:39
av_bsf_receive_packet
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Definition: bsf.c:226
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
avio_internal.h
ffio_init_context
void ffio_init_context(FFIOContext *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))
Definition: aviobuf.c:81
common.h
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
len
int len
Definition: vorbis_enc_data.h:426
av_get_packet
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:197
ret
ret
Definition: filter_design.txt:187
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AVStream
Stream structure.
Definition: avformat.h:935
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:260
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AVSTREAM_PARSE_HEADERS
@ AVSTREAM_PARSE_HEADERS
Only parse headers, do not repack.
Definition: avformat.h:793
avformat.h
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
av_bsf_send_packet
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Definition: bsf.c:198
AV1DemuxContext::temporal_unit_size
uint32_t temporal_unit_size
Definition: av1dec.c:36
av_bsf_flush
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
Definition: bsf.c:186
AVBitStreamFilter
Definition: bsf.h:90
FFStream::avctx
AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
Definition: internal.h:221
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:641
AVIOContext::eof_reached
int eof_reached
true if was unable to read due to error or eof
Definition: avio.h:239
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:1196
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:347
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
av1_options
static const AVOption av1_options[]
Definition: av1dec.c:111
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
AVPacket
This structure stores compressed data.
Definition: packet.h:350
av1_read_header
static int av1_read_header(AVFormatContext *s)
Definition: av1dec.c:59
av1_demuxer_class
static const AVClass av1_demuxer_class
Definition: av1dec.c:117
av_bsf_free
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition: bsf.c:48
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AV1DemuxContext::framerate
AVRational framerate
Definition: av1dec.c:35
AV1_OBU_METADATA
@ AV1_OBU_METADATA
Definition: av1.h:34
av_bsf_alloc
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
Definition: bsf.c:100
MAX_OBU_HEADER_SIZE
#define MAX_OBU_HEADER_SIZE
Definition: av1_parse.h:35
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:375