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