FFmpeg
apngdec.c
Go to the documentation of this file.
1 /*
2  * APNG demuxer
3  * Copyright (c) 2014 Benoit Fouet
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 /**
23  * @file
24  * APNG demuxer.
25  * @see https://wiki.mozilla.org/APNG_Specification
26  * @see http://www.w3.org/TR/PNG
27  */
28 
29 #include "avformat.h"
30 #include "avio_internal.h"
31 #include "internal.h"
32 #include "libavutil/imgutils.h"
33 #include "libavutil/intreadwrite.h"
34 #include "libavutil/opt.h"
35 #include "libavcodec/apng.h"
36 #include "libavcodec/png.h"
37 #include "libavcodec/bytestream.h"
38 
39 #define DEFAULT_APNG_FPS 15
40 
41 typedef struct APNGDemuxContext {
42  const AVClass *class;
43 
44  int max_fps;
46 
48 
50 
51  /*
52  * loop options
53  */
55  uint32_t num_frames;
56  uint32_t num_play;
57  uint32_t cur_loop;
59 
60 /*
61  * To be a valid APNG file, we mandate, in this order:
62  * PNGSIG
63  * IHDR
64  * ...
65  * acTL
66  * ...
67  * IDAT
68  */
69 static int apng_probe(const AVProbeData *p)
70 {
71  GetByteContext gb;
72  int state = 0;
73  uint32_t len, tag;
74 
75  bytestream2_init(&gb, p->buf, p->buf_size);
76 
77  if (bytestream2_get_be64(&gb) != PNGSIG)
78  return 0;
79 
80  for (;;) {
81  len = bytestream2_get_be32(&gb);
82  if (len > 0x7fffffff)
83  return 0;
84 
85  tag = bytestream2_get_le32(&gb);
86  /* we don't check IDAT size, as this is the last tag
87  * we check, and it may be larger than the probe buffer */
88  if (tag != MKTAG('I', 'D', 'A', 'T') &&
89  len + 4 > bytestream2_get_bytes_left(&gb))
90  return 0;
91 
92  switch (tag) {
93  case MKTAG('I', 'H', 'D', 'R'):
94  if (len != 13)
95  return 0;
96  if (av_image_check_size(bytestream2_get_be32(&gb), bytestream2_get_be32(&gb), 0, NULL))
97  return 0;
98  bytestream2_skip(&gb, 9);
99  state++;
100  break;
101  case MKTAG('a', 'c', 'T', 'L'):
102  if (state != 1 ||
103  len != 8 ||
104  bytestream2_get_be32(&gb) == 0) /* 0 is not a valid value for number of frames */
105  return 0;
106  bytestream2_skip(&gb, 8);
107  state++;
108  break;
109  case MKTAG('I', 'D', 'A', 'T'):
110  if (state != 2)
111  return 0;
112  goto end;
113  default:
114  /* skip other tags */
115  bytestream2_skip(&gb, len + 4);
116  break;
117  }
118  }
119 
120 end:
121  return AVPROBE_SCORE_MAX;
122 }
123 
125 {
126  int previous_size = par->extradata_size;
127  int new_size, ret;
128  uint8_t *new_extradata;
129 
130  if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - previous_size)
131  return AVERROR_INVALIDDATA;
132 
133  new_size = previous_size + len;
134  new_extradata = av_realloc(par->extradata, new_size + AV_INPUT_BUFFER_PADDING_SIZE);
135  if (!new_extradata)
136  return AVERROR(ENOMEM);
137  memset(new_extradata + new_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
138  par->extradata = new_extradata;
139  par->extradata_size = new_size;
140 
141  if ((ret = ffio_read_size(pb, par->extradata + previous_size, len)) < 0)
142  return ret;
143 
144  return previous_size;
145 }
146 
148 {
150  AVIOContext *pb = s->pb;
151  uint32_t len, tag;
152  AVStream *st;
153  int acTL_found = 0;
154  int64_t ret;
155 
156  /* verify PNGSIG */
157  if (avio_rb64(pb) != PNGSIG)
158  return AVERROR_INVALIDDATA;
159 
160  /* parse IHDR (must be first chunk) */
161  len = avio_rb32(pb);
162  tag = avio_rl32(pb);
163  if (len != 13 || tag != MKTAG('I', 'H', 'D', 'R'))
164  return AVERROR_INVALIDDATA;
165 
166  st = avformat_new_stream(s, NULL);
167  if (!st)
168  return AVERROR(ENOMEM);
169 
170  /* set the timebase to something large enough (1/100,000 of second)
171  * to hopefully cope with all sane frame durations */
172  avpriv_set_pts_info(st, 64, 1, 100000);
175  st->codecpar->width = avio_rb32(pb);
176  st->codecpar->height = avio_rb32(pb);
177  if ((ret = av_image_check_size(st->codecpar->width, st->codecpar->height, 0, s)) < 0)
178  return ret;
179 
180  /* extradata will contain every chunk up to the first fcTL (excluded) */
181  ret = ff_alloc_extradata(st->codecpar, len + 12);
182  if (ret < 0)
183  return ret;
184  AV_WB32(st->codecpar->extradata, len);
185  AV_WL32(st->codecpar->extradata+4, tag);
186  AV_WB32(st->codecpar->extradata+8, st->codecpar->width);
187  AV_WB32(st->codecpar->extradata+12, st->codecpar->height);
188  if ((ret = ffio_read_size(pb, st->codecpar->extradata + 16, 9)) < 0)
189  return ret;
190 
191  while (1) {
192  if (acTL_found && ctx->num_play != 1) {
193  int64_t size = avio_size(pb);
194  int64_t offset = avio_tell(pb);
195  if (size < 0) {
196  return size;
197  } else if (offset < 0) {
198  return offset;
199  } else if ((ret = ffio_ensure_seekback(pb, size - offset)) < 0) {
200  av_log(s, AV_LOG_WARNING, "Could not ensure seekback, will not loop\n");
201  ctx->num_play = 1;
202  }
203  }
204  if ((ctx->num_play == 1 || !acTL_found) &&
205  ((ret = ffio_ensure_seekback(pb, 4 /* len */ + 4 /* tag */)) < 0))
206  return ret;
207 
208  len = avio_rb32(pb);
209  if (len > INT_MAX - 12)
210  return AVERROR_INVALIDDATA;
211 
212  tag = avio_rl32(pb);
213  switch (tag) {
214  case MKTAG('a', 'c', 'T', 'L'):
215  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
216  (ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
217  return ret;
218  acTL_found = 1;
219  ctx->num_frames = AV_RB32(st->codecpar->extradata + ret + 8);
220  ctx->num_play = AV_RB32(st->codecpar->extradata + ret + 12);
221  av_log(s, AV_LOG_DEBUG, "num_frames: %"PRIu32", num_play: %"PRIu32"\n",
222  ctx->num_frames, ctx->num_play);
223  break;
224  case MKTAG('f', 'c', 'T', 'L'):
225  if (!acTL_found || len != 26) {
226  return AVERROR_INVALIDDATA;
227  }
228  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0)
229  return ret;
230  return 0;
231  default:
232  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
233  (ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
234  return ret;
235  }
236  }
237 }
238 
240 {
241  uint32_t sequence_number, width, height, x_offset, y_offset;
242  uint16_t delay_num, delay_den;
243  uint8_t dispose_op, blend_op;
244 
245  sequence_number = avio_rb32(s->pb);
246  width = avio_rb32(s->pb);
247  height = avio_rb32(s->pb);
248  x_offset = avio_rb32(s->pb);
249  y_offset = avio_rb32(s->pb);
250  delay_num = avio_rb16(s->pb);
251  delay_den = avio_rb16(s->pb);
252  dispose_op = avio_r8(s->pb);
253  blend_op = avio_r8(s->pb);
254  avio_skip(s->pb, 4); /* crc */
255 
256  /* default is hundredths of seconds */
257  if (!delay_den)
258  delay_den = 100;
259  if (!delay_num || (ctx->max_fps && delay_den / delay_num > ctx->max_fps)) {
260  delay_num = 1;
261  delay_den = ctx->default_fps;
262  }
263  ctx->pkt_duration = av_rescale_q(delay_num,
264  (AVRational){ 1, delay_den },
265  s->streams[0]->time_base);
266 
267  av_log(s, AV_LOG_DEBUG, "%s: "
268  "sequence_number: %"PRId32", "
269  "width: %"PRIu32", "
270  "height: %"PRIu32", "
271  "x_offset: %"PRIu32", "
272  "y_offset: %"PRIu32", "
273  "delay_num: %"PRIu16", "
274  "delay_den: %"PRIu16", "
275  "dispose_op: %d, "
276  "blend_op: %d\n",
277  __FUNCTION__,
278  sequence_number,
279  width,
280  height,
281  x_offset,
282  y_offset,
283  delay_num,
284  delay_den,
285  dispose_op,
286  blend_op);
287 
288  if (width != s->streams[0]->codecpar->width ||
289  height != s->streams[0]->codecpar->height ||
290  x_offset != 0 ||
291  y_offset != 0) {
292  if (sequence_number == 0 ||
293  x_offset >= s->streams[0]->codecpar->width ||
294  width > s->streams[0]->codecpar->width - x_offset ||
295  y_offset >= s->streams[0]->codecpar->height ||
296  height > s->streams[0]->codecpar->height - y_offset)
297  return AVERROR_INVALIDDATA;
298  ctx->is_key_frame = 0;
299  } else {
300  if (sequence_number == 0 && dispose_op == APNG_DISPOSE_OP_PREVIOUS)
301  dispose_op = APNG_DISPOSE_OP_BACKGROUND;
302  ctx->is_key_frame = dispose_op == APNG_DISPOSE_OP_BACKGROUND ||
303  blend_op == APNG_BLEND_OP_SOURCE;
304  }
305 
306  return 0;
307 }
308 
310 {
312  int64_t ret;
313  int64_t size;
314  AVIOContext *pb = s->pb;
315  uint32_t len, tag;
316 
317  /*
318  * fcTL chunk length, in bytes:
319  * 4 (length)
320  * 4 (tag)
321  * 26 (actual chunk)
322  * 4 (crc) bytes
323  * and needed next:
324  * 4 (length)
325  * 4 (tag (must be fdAT or IDAT))
326  */
327  /* if num_play is not 1, then the seekback is already guaranteed */
328  if (ctx->num_play == 1 && (ret = ffio_ensure_seekback(pb, 46)) < 0)
329  return ret;
330 
331  len = avio_rb32(pb);
332  tag = avio_rl32(pb);
333 
334  if (avio_feof(pb))
335  return AVERROR_EOF;
336 
337  switch (tag) {
338  case MKTAG('f', 'c', 'T', 'L'):
339  if (len != 26)
340  return AVERROR_INVALIDDATA;
341 
342  if ((ret = decode_fctl_chunk(s, ctx, pkt)) < 0)
343  return ret;
344 
345  /* fcTL must precede fdAT or IDAT */
346  len = avio_rb32(pb);
347  tag = avio_rl32(pb);
348  if (len > 0x7fffffff ||
349  tag != MKTAG('f', 'd', 'A', 'T') &&
350  tag != MKTAG('I', 'D', 'A', 'T'))
351  return AVERROR_INVALIDDATA;
352 
353  size = 38 /* fcTL */ + 8 /* len, tag */ + len + 4 /* crc */;
354  if (size > INT_MAX)
355  return AVERROR(EINVAL);
356 
357  if ((ret = avio_seek(pb, -46, SEEK_CUR)) < 0 ||
358  (ret = av_append_packet(pb, pkt, size)) < 0)
359  return ret;
360 
361  if (ctx->num_play == 1 && (ret = ffio_ensure_seekback(pb, 8)) < 0)
362  return ret;
363 
364  len = avio_rb32(pb);
365  tag = avio_rl32(pb);
366  while (tag &&
367  tag != MKTAG('f', 'c', 'T', 'L') &&
368  tag != MKTAG('I', 'E', 'N', 'D')) {
369  if (len > 0x7fffffff)
370  return AVERROR_INVALIDDATA;
371  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
372  (ret = av_append_packet(pb, pkt, len + 12)) < 0)
373  return ret;
374  if (ctx->num_play == 1 && (ret = ffio_ensure_seekback(pb, 8)) < 0)
375  return ret;
376  len = avio_rb32(pb);
377  tag = avio_rl32(pb);
378  }
379  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0)
380  return ret;
381 
382  if (ctx->is_key_frame)
383  pkt->flags |= AV_PKT_FLAG_KEY;
384  pkt->pts = pkt->dts = AV_NOPTS_VALUE;
385  pkt->duration = ctx->pkt_duration;
386  return ret;
387  case MKTAG('I', 'E', 'N', 'D'):
388  ctx->cur_loop++;
389  if (ctx->ignore_loop || ctx->num_play >= 1 && ctx->cur_loop == ctx->num_play) {
390  avio_seek(pb, -8, SEEK_CUR);
391  return AVERROR_EOF;
392  }
393  if ((ret = avio_seek(pb, s->streams[0]->codecpar->extradata_size + 8, SEEK_SET)) < 0)
394  return ret;
395  return 0;
396  default:
397  avpriv_request_sample(s, "In-stream tag=%s (0x%08"PRIX32") len=%"PRIu32,
398  av_fourcc2str(tag), tag, len);
399  avio_skip(pb, len + 4);
400  }
401 
402  /* Handle the unsupported yet cases */
403  return AVERROR_PATCHWELCOME;
404 }
405 
406 static const AVOption options[] = {
407  { "ignore_loop", "ignore loop setting" , offsetof(APNGDemuxContext, ignore_loop),
408  AV_OPT_TYPE_BOOL, { .i64 = 1 } , 0, 1 , AV_OPT_FLAG_DECODING_PARAM },
409  { "max_fps" , "maximum framerate (0 is no limit)" , offsetof(APNGDemuxContext, max_fps),
410  AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
411  { "default_fps", "default framerate (0 is as fast as possible)", offsetof(APNGDemuxContext, default_fps),
412  AV_OPT_TYPE_INT, { .i64 = DEFAULT_APNG_FPS }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
413  { NULL },
414 };
415 
416 static const AVClass demuxer_class = {
417  .class_name = "APNG demuxer",
418  .item_name = av_default_item_name,
419  .option = options,
420  .version = LIBAVUTIL_VERSION_INT,
421  .category = AV_CLASS_CATEGORY_DEMUXER,
422 };
423 
425  .name = "apng",
426  .long_name = NULL_IF_CONFIG_SMALL("Animated Portable Network Graphics"),
427  .priv_data_size = sizeof(APNGDemuxContext),
432  .priv_class = &demuxer_class,
433 };
#define NULL
Definition: coverity.c:32
Bytestream IO Context.
Definition: avio.h:161
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:346
AVOption.
Definition: opt.h:248
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:134
misc image utilities
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:200
#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:4871
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:686
#define avpriv_request_sample(...)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:253
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:341
AVInputFormat ff_apng_demuxer
Definition: apngdec.c:424
static AVPacket pkt
unsigned int avio_rb16(AVIOContext *s)
Definition: aviobuf.c:770
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
Format I/O context.
Definition: avformat.h:1239
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
uint8_t
int width
Video only.
Definition: codec_par.h:126
AVOptions.
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:785
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 offset
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:92
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:381
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4453
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_RB32
Definition: bytestream.h:91
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1307
#define height
uint32_t tag
Definition: movenc.c:1597
#define AVERROR_EOF
End of file.
Definition: error.h:55
ptrdiff_t size
Definition: opengl_enc.c:100
uint64_t avio_rb64(AVIOContext *s)
Definition: aviobuf.c:906
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
#define av_log(a,...)
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
Read data and append it to the current content of the AVPacket.
Definition: utils.c:315
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:401
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:754
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:153
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:215
#define av_fourcc2str(fourcc)
Definition: avutil.h:348
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
#define PNGSIG
Definition: png.h:47
uint32_t num_play
Definition: apngdec.c:56
#define DEFAULT_APNG_FPS
Definition: apngdec.c:39
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:369
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:78
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
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition: imgutils.c:317
int ff_alloc_extradata(AVCodecParameters *par, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0...
Definition: utils.c:3260
#define width
static int decode_fctl_chunk(AVFormatContext *s, APNGDemuxContext *ctx, AVPacket *pkt)
Definition: apngdec.c:239
AVFormatContext * ctx
Definition: movenc.c:48
#define s(width, name)
Definition: cbs_vp9.c:257
static int append_extradata(AVCodecParameters *par, AVIOContext *pb, int len)
Definition: apngdec.c:124
static int apng_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: apngdec.c:309
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
Stream structure.
Definition: avformat.h:880
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AVIOContext * pb
I/O context.
Definition: avformat.h:1281
int pkt_duration
Definition: apngdec.c:47
int is_key_frame
Definition: apngdec.c:49
Describe the class of an AVClass context structure.
Definition: log.h:67
#define AV_WB32(p, v)
Definition: intreadwrite.h:419
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition: avformat.h:463
Rational number (pair of numerator and denominator).
Definition: rational.h:58
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:279
static const AVOption options[]
Definition: apngdec.c:406
This structure contains the data a format has to probe a file.
Definition: avformat.h:441
static const AVClass demuxer_class
Definition: apngdec.c:416
#define flags(name, subs,...)
Definition: cbs_av1.c:560
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
Definition: aviobuf.c:1002
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:453
Main libavformat public API header.
static struct @323 state
uint32_t cur_loop
Definition: apngdec.c:57
#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
int len
void * priv_data
Format private data.
Definition: avformat.h:1267
APNG common header.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:74
uint32_t num_frames
Definition: apngdec.c:55
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: packet.h:362
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:652
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1045
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:368
static int apng_probe(const AVProbeData *p)
Definition: apngdec.c:69
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:909
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
#define MKTAG(a, b, c, d)
Definition: common.h:405
This structure stores compressed data.
Definition: packet.h:340
static int apng_read_header(AVFormatContext *s)
Definition: apngdec.c:147
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:356
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
#define AV_WL32(p, v)
Definition: intreadwrite.h:426