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/fifo.h"
26 #include "libavutil/opt.h"
27 #include "libavcodec/av1_parse.h"
28 #include "avformat.h"
29 #include "avio_internal.h"
30 #include "internal.h"
31 
32 //return < 0 if we need more data
33 static int get_score(int type, int *seq)
34 {
35  switch (type) {
37  *seq = 1;
38  return -1;
39  case AV1_OBU_FRAME:
41  return *seq ? AVPROBE_SCORE_EXTENSION + 1 : 0;
42  case AV1_OBU_METADATA:
43  case AV1_OBU_PADDING:
44  return -1;
45  default:
46  break;
47  }
48  return 0;
49 }
50 
51 static int read_header(AVFormatContext *s, const AVRational *framerate, AVBSFContext **bsf, void *logctx)
52 {
53  const AVBitStreamFilter *filter = av_bsf_get_by_name("av1_frame_merge");
54  AVStream *st;
55  int ret;
56 
57  if (!filter) {
58  av_log(logctx, AV_LOG_ERROR, "av1_frame_merge bitstream filter "
59  "not found. This is a bug, please report it.\n");
60  return AVERROR_BUG;
61  }
62 
63  st = avformat_new_stream(s, NULL);
64  if (!st)
65  return AVERROR(ENOMEM);
66 
70 
72  // taken from rawvideo demuxers
73  avpriv_set_pts_info(st, 64, 1, 1200000);
74 
75  ret = av_bsf_alloc(filter, bsf);
76  if (ret < 0)
77  return ret;
78 
79  ret = avcodec_parameters_copy((*bsf)->par_in, st->codecpar);
80  if (ret < 0) {
81  av_bsf_free(bsf);
82  return ret;
83  }
84 
85  ret = av_bsf_init(*bsf);
86  if (ret < 0)
87  av_bsf_free(bsf);
88 
89  return ret;
90 
91 }
92 
93 #define DEC AV_OPT_FLAG_DECODING_PARAM
94 
95 #if CONFIG_AV1_DEMUXER
96 typedef struct AnnexBContext {
97  const AVClass *class;
98  AVBSFContext *bsf;
99  uint32_t temporal_unit_size;
100  uint32_t frame_unit_size;
102 } AnnexBContext;
103 
104 static int leb(AVIOContext *pb, uint32_t *len) {
105  int more, i = 0;
106  uint8_t byte;
107  *len = 0;
108  do {
109  unsigned bits;
110  byte = avio_r8(pb);
111  more = byte & 0x80;
112  bits = byte & 0x7f;
113  if (i <= 3 || (i == 4 && bits < (1 << 4)))
114  *len |= bits << (i * 7);
115  else if (bits)
116  return AVERROR_INVALIDDATA;
117  if (++i == 8 && more)
118  return AVERROR_INVALIDDATA;
119  if (pb->eof_reached || pb->error)
120  return pb->error ? pb->error : AVERROR(EIO);
121  } while (more);
122  return i;
123 }
124 
125 static int read_obu(const uint8_t *buf, int size, int64_t *obu_size, int *type)
126 {
127  int start_pos, temporal_id, spatial_id;
128  int len;
129 
130  len = parse_obu_header(buf, size, obu_size, &start_pos,
131  type, &temporal_id, &spatial_id);
132  if (len < 0)
133  return len;
134 
135  return 0;
136 }
137 
138 static int annexb_probe(const AVProbeData *p)
139 {
140  AVIOContext pb;
141  int64_t obu_size;
142  uint32_t temporal_unit_size, frame_unit_size, obu_unit_size;
143  int seq = 0;
144  int ret, type, cnt = 0;
145 
146  ffio_init_context(&pb, p->buf, p->buf_size, 0,
147  NULL, NULL, NULL, NULL);
148 
149  ret = leb(&pb, &temporal_unit_size);
150  if (ret < 0)
151  return 0;
152  cnt += ret;
153  ret = leb(&pb, &frame_unit_size);
154  if (ret < 0 || ((int64_t)frame_unit_size + ret) > temporal_unit_size)
155  return 0;
156  cnt += ret;
157  ret = leb(&pb, &obu_unit_size);
158  if (ret < 0 || ((int64_t)obu_unit_size + ret) >= frame_unit_size)
159  return 0;
160  cnt += ret;
161 
162  frame_unit_size -= obu_unit_size + ret;
163 
164  avio_skip(&pb, obu_unit_size);
165  if (pb.eof_reached || pb.error)
166  return 0;
167 
168  // Check that the first OBU is a Temporal Delimiter.
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)
171  return 0;
172  cnt += obu_unit_size;
173 
174  do {
175  ret = leb(&pb, &obu_unit_size);
176  if (ret < 0 || ((int64_t)obu_unit_size + ret) > frame_unit_size)
177  return 0;
178  cnt += ret;
179 
180  avio_skip(&pb, obu_unit_size);
181  if (pb.eof_reached || pb.error)
182  return 0;
183 
184  ret = read_obu(p->buf + cnt, FFMIN(p->buf_size - cnt, obu_unit_size), &obu_size, &type);
185  if (ret < 0)
186  return 0;
187  cnt += obu_unit_size;
188 
189  ret = get_score(type, &seq);
190  if (ret >= 0)
191  return ret;
192 
193  frame_unit_size -= obu_unit_size + ret;
194  } while (frame_unit_size);
195 
196  return 0;
197 }
198 
199 static int annexb_read_header(AVFormatContext *s)
200 {
201  AnnexBContext *c = s->priv_data;
202  return read_header(s, &c->framerate, &c->bsf, c);
203 }
204 
205 static int annexb_read_packet(AVFormatContext *s, AVPacket *pkt)
206 {
207  AnnexBContext *c = s->priv_data;
208  uint32_t obu_unit_size;
209  int ret, len;
210 
211 retry:
212  if (avio_feof(s->pb)) {
213  if (c->temporal_unit_size || c->frame_unit_size)
214  return AVERROR(EIO);
215  goto end;
216  }
217 
218  if (!c->temporal_unit_size) {
219  len = leb(s->pb, &c->temporal_unit_size);
220  if (len < 0) return AVERROR_INVALIDDATA;
221  }
222 
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)
226  return AVERROR_INVALIDDATA;
227  c->temporal_unit_size -= len;
228  }
229 
230  len = leb(s->pb, &obu_unit_size);
231  if (len < 0 || ((int64_t)obu_unit_size + len) > c->frame_unit_size)
232  return AVERROR_INVALIDDATA;
233 
234  ret = av_get_packet(s->pb, pkt, obu_unit_size);
235  if (ret < 0)
236  return ret;
237  if (ret != obu_unit_size)
238  return AVERROR(EIO);
239 
240  c->temporal_unit_size -= obu_unit_size + len;
241  c->frame_unit_size -= obu_unit_size + len;
242 
243 end:
244  ret = av_bsf_send_packet(c->bsf, pkt);
245  if (ret < 0) {
246  av_log(s, AV_LOG_ERROR, "Failed to send packet to "
247  "av1_frame_merge filter\n");
248  return ret;
249  }
250 
251  ret = av_bsf_receive_packet(c->bsf, pkt);
252  if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
253  av_log(s, AV_LOG_ERROR, "av1_frame_merge filter failed to "
254  "send output packet\n");
255 
256  if (ret == AVERROR(EAGAIN))
257  goto retry;
258 
259  return ret;
260 }
261 
262 static int annexb_read_close(AVFormatContext *s)
263 {
264  AnnexBContext *c = s->priv_data;
265 
266  av_bsf_free(&c->bsf);
267  return 0;
268 }
269 
270 #define OFFSET(x) offsetof(AnnexBContext, x)
271 static const AVOption annexb_options[] = {
272  { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC},
273  { NULL },
274 };
275 #undef OFFSET
276 
277 static const AVClass annexb_demuxer_class = {
278  .class_name = "AV1 Annex B demuxer",
279  .item_name = av_default_item_name,
280  .option = annexb_options,
281  .version = LIBAVUTIL_VERSION_INT,
282 };
283 
285  .name = "av1",
286  .long_name = NULL_IF_CONFIG_SMALL("AV1 Annex B"),
287  .priv_data_size = sizeof(AnnexBContext),
288  .read_probe = annexb_probe,
289  .read_header = annexb_read_header,
290  .read_packet = annexb_read_packet,
291  .read_close = annexb_read_close,
292  .extensions = "obu",
294  .priv_class = &annexb_demuxer_class,
295 };
296 #endif
297 
298 #if CONFIG_OBU_DEMUXER
299 typedef struct ObuContext {
300  const AVClass *class;
301  AVBSFContext *bsf;
303  AVFifoBuffer *fifo;
304 } ObuContext;
305 
306 //For low overhead obu, we can't foresee the obu size before we parsed the header.
307 //So, we can't use parse_obu_header here, since it will check size <= buf_size
308 //see c27c7b49dc for more details
309 static int read_obu_with_size(const uint8_t *buf, int buf_size, int64_t *obu_size, int *type)
310 {
311  GetBitContext gb;
312  int ret, extension_flag, start_pos;
313  int64_t size;
314 
315  ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_OBU_HEADER_SIZE));
316  if (ret < 0)
317  return ret;
318 
319  if (get_bits1(&gb) != 0) // obu_forbidden_bit
320  return AVERROR_INVALIDDATA;
321 
322  *type = get_bits(&gb, 4);
323  extension_flag = get_bits1(&gb);
324  if (!get_bits1(&gb)) // has_size_flag
325  return AVERROR_INVALIDDATA;
326  skip_bits1(&gb); // obu_reserved_1bit
327 
328  if (extension_flag) {
329  get_bits(&gb, 3); // temporal_id
330  get_bits(&gb, 2); // spatial_id
331  skip_bits(&gb, 3); // extension_header_reserved_3bits
332  }
333 
334  *obu_size = leb128(&gb);
335  if (*obu_size > INT_MAX)
336  return AVERROR_INVALIDDATA;
337 
338  if (get_bits_left(&gb) < 0)
339  return AVERROR_INVALIDDATA;
340 
341  start_pos = get_bits_count(&gb) / 8;
342 
343  size = *obu_size + start_pos;
344  if (size > INT_MAX)
345  return AVERROR_INVALIDDATA;
346  return size;
347 }
348 
349 static int obu_probe(const AVProbeData *p)
350 {
351  int64_t obu_size;
352  int seq = 0;
353  int ret, type, cnt;
354 
355  // Check that the first OBU is a Temporal Delimiter.
356  cnt = read_obu_with_size(p->buf, p->buf_size, &obu_size, &type);
357  if (cnt < 0 || type != AV1_OBU_TEMPORAL_DELIMITER || obu_size != 0)
358  return 0;
359 
360  while (1) {
361  ret = read_obu_with_size(p->buf + cnt, p->buf_size - cnt, &obu_size, &type);
362  if (ret < 0 || obu_size <= 0)
363  return 0;
364  cnt += ret;
365 
366  ret = get_score(type, &seq);
367  if (ret >= 0)
368  return ret;
369  }
370  return 0;
371 }
372 
373 static int obu_read_header(AVFormatContext *s)
374 {
375  ObuContext *c = s->priv_data;
377  if (!c->fifo)
378  return AVERROR(ENOMEM);
379  return read_header(s, &c->framerate, &c->bsf, c);
380 }
381 
382 static int obu_get_packet(AVFormatContext *s, AVPacket *pkt)
383 {
384  ObuContext *c = s->priv_data;
386  int64_t obu_size;
387  int size = av_fifo_space(c->fifo);
388  int ret, len, type;
389 
390  av_fifo_generic_write(c->fifo, s->pb, size,
391  (int (*)(void*, void*, int))avio_read);
392  size = av_fifo_size(c->fifo);
393  if (!size)
394  return 0;
395 
396  av_fifo_generic_peek(c->fifo, header, size, NULL);
397 
398  len = read_obu_with_size(header, size, &obu_size, &type);
399  if (len < 0) {
400  av_log(c, AV_LOG_ERROR, "Failed to read obu\n");
401  return len;
402  }
403 
404  ret = av_new_packet(pkt, len);
405  if (ret < 0) {
406  av_log(c, AV_LOG_ERROR, "Failed to allocate packet for obu\n");
407  return ret;
408  }
409  size = FFMIN(size, len);
410  av_fifo_generic_read(c->fifo, pkt->data, size, NULL);
411  len -= size;
412  if (len > 0) {
413  ret = avio_read(s->pb, pkt->data + size, len);
414  if (ret != len) {
415  av_log(c, AV_LOG_ERROR, "Failed to read %d frome file\n", len);
416  return ret < 0 ? ret : AVERROR_INVALIDDATA;
417  }
418  }
419  return 0;
420 }
421 
422 static int obu_read_packet(AVFormatContext *s, AVPacket *pkt)
423 {
424  ObuContext *c = s->priv_data;
425  int ret;
426 
427  while (1) {
428  ret = obu_get_packet(s, pkt);
429  if (ret < 0)
430  return ret;
431  ret = av_bsf_send_packet(c->bsf, pkt);
432  if (ret < 0) {
433  av_log(s, AV_LOG_ERROR, "Failed to send packet to "
434  "av1_frame_merge filter\n");
435  return ret;
436  }
437  ret = av_bsf_receive_packet(c->bsf, pkt);
438  if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
439  av_log(s, AV_LOG_ERROR, "av1_frame_merge filter failed to "
440  "send output packet\n");
441  if (ret != AVERROR(EAGAIN))
442  break;
443  }
444 
445  return ret;
446 }
447 
448 static int obu_read_close(AVFormatContext *s)
449 {
450  ObuContext *c = s->priv_data;
451 
452  av_fifo_freep(&c->fifo);
453  av_bsf_free(&c->bsf);
454  return 0;
455 }
456 
457 #define OFFSET(x) offsetof(ObuContext, x)
458 static const AVOption obu_options[] = {
459  { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC},
460  { NULL },
461 };
462 #undef OFFSET
463 
464 static const AVClass obu_demuxer_class = {
465  .class_name = "AV1 low overhead OBU demuxer",
466  .item_name = av_default_item_name,
467  .option = obu_options,
468  .version = LIBAVUTIL_VERSION_INT,
469 };
470 
472  .name = "obu",
473  .long_name = NULL_IF_CONFIG_SMALL("AV1 low overhead OBU"),
474  .priv_data_size = sizeof(ObuContext),
475  .read_probe = obu_probe,
476  .read_header = obu_read_header,
477  .read_packet = obu_read_packet,
478  .read_close = obu_read_close,
479  .extensions = "obu",
481  .priv_class = &obu_demuxer_class,
482 };
483 #endif
#define NULL
Definition: coverity.c:32
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
AVRational framerate
Definition: avcodec.h:2069
Bytestream IO Context.
Definition: avio.h:161
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AVOption.
Definition: opt.h:248
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
void avpriv_set_pts_info(AVStream *s, 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:4868
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
The bitstream filter state.
Definition: bsf.h:49
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
GLint GLenum type
Definition: opengl_enc.c:104
static int get_score(int type, int *seq)
Definition: av1dec.c:33
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:341
static AVPacket pkt
int framerate
Definition: h264_levels.c:65
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.
Definition: fifo.c:189
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.
Definition: fifo.c:122
Format I/O context.
Definition: avformat.h:1355
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:72
#define leb128(name)
Definition: cbs_av1.c:704
uint8_t
AVOptions.
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:92
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
enum AVStreamParseType need_parsing
Definition: avformat.h:1098
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...
Definition: fifo.c:82
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4449
uint8_t * data
Definition: packet.h:363
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
#define AVERROR_EOF
End of file.
Definition: error.h:55
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
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:305
ptrdiff_t size
Definition: opengl_enc.c:100
static const uint8_t header[24]
Definition: sdr2.c:67
#define av_log(a,...)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:637
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:88
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:849
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
Definition: bsf.c:94
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
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. ...
Definition: internal.h:153
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.
Definition: fifo.c:213
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.
Definition: codec_par.h:56
uint8_t bits
Definition: vp3data.h:202
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Definition: bsf.c:147
Only parse headers, do not repack.
Definition: avformat.h:800
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:628
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:444
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:443
#define DEC
Definition: av1dec.c:93
#define FFMIN(a, b)
Definition: common.h:96
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:103
#define s(width, name)
Definition: cbs_vp9.c:257
Stream structure.
Definition: avformat.h:880
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Definition: bsf.c:200
AVStreamInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1235
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 ...
Definition: fifo.c:77
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:91
AVIOContext * pb
I/O context.
Definition: avformat.h:1397
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:677
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Definition: bsf.c:226
a very simple circular buffer FIFO implementation
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:538
Describe the class of an AVClass context structure.
Definition: log.h:67
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:467
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition: avformat.h:463
Rational number (pair of numerator and denominator).
Definition: rational.h:58
offset must point to AVRational
Definition: opt.h:238
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition: avformat.h:451
int error
contains the error code or 0 if no error happened
Definition: avio.h:245
This structure contains the data a format has to probe a file.
Definition: avformat.h:441
#define flags(name, subs,...)
Definition: cbs_av1.c:560
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
Main libavformat public API header.
int
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))
Definition: aviobuf.c:88
#define MAX_OBU_HEADER_SIZE
Definition: av1_parse.h:31
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:215
static int read_header(AVFormatContext *s, const AVRational *framerate, AVBSFContext **bsf, void *logctx)
Definition: av1dec.c:51
int eof_reached
true if was unable to read due to error or eof
Definition: avio.h:239
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:43
int len
AVInputFormat ff_obu_demuxer
void * priv_data
Format private data.
Definition: avformat.h:1383
AVInputFormat ff_av1_demuxer
AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
Definition: internal.h:169
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:652
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:40
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
Definition: fifo.c:63
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1027
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:368
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
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
Definition: utils.c:2091
This structure stores compressed data.
Definition: packet.h:340
int i
Definition: input.c:407