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') &&
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 (previous_size > INT_MAX - len)
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  par->extradata = new_extradata;
138  par->extradata_size = new_size;
139 
140  if ((ret = avio_read(pb, par->extradata + previous_size, len)) < 0)
141  return ret;
142 
143  return previous_size;
144 }
145 
147 {
148  APNGDemuxContext *ctx = s->priv_data;
149  AVIOContext *pb = s->pb;
150  uint32_t len, tag;
151  AVStream *st;
152  int acTL_found = 0;
153  int64_t ret = AVERROR_INVALIDDATA;
154 
155  /* verify PNGSIG */
156  if (avio_rb64(pb) != PNGSIG)
157  return ret;
158 
159  /* parse IHDR (must be first chunk) */
160  len = avio_rb32(pb);
161  tag = avio_rl32(pb);
162  if (len != 13 || tag != MKTAG('I', 'H', 'D', 'R'))
163  return ret;
164 
165  st = avformat_new_stream(s, NULL);
166  if (!st)
167  return AVERROR(ENOMEM);
168 
169  /* set the timebase to something large enough (1/100,000 of second)
170  * to hopefully cope with all sane frame durations */
171  avpriv_set_pts_info(st, 64, 1, 100000);
174  st->codecpar->width = avio_rb32(pb);
175  st->codecpar->height = avio_rb32(pb);
176  if ((ret = av_image_check_size(st->codecpar->width, st->codecpar->height, 0, s)) < 0)
177  return ret;
178 
179  /* extradata will contain every chunk up to the first fcTL (excluded) */
181  if (!st->codecpar->extradata)
182  return AVERROR(ENOMEM);
183  st->codecpar->extradata_size = len + 12;
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 = avio_read(pb, st->codecpar->extradata+16, 9)) < 0)
189  goto fail;
190 
191  while (!avio_feof(pb)) {
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  ret = size;
197  goto fail;
198  } else if (offset < 0) {
199  ret = offset;
200  goto fail;
201  } else if ((ret = ffio_ensure_seekback(pb, size - offset)) < 0) {
202  av_log(s, AV_LOG_WARNING, "Could not ensure seekback, will not loop\n");
203  ctx->num_play = 1;
204  }
205  }
206  if ((ctx->num_play == 1 || !acTL_found) &&
207  ((ret = ffio_ensure_seekback(pb, 4 /* len */ + 4 /* tag */)) < 0))
208  goto fail;
209 
210  len = avio_rb32(pb);
211  if (len > 0x7fffffff) {
213  goto fail;
214  }
215 
216  tag = avio_rl32(pb);
217  switch (tag) {
218  case MKTAG('a', 'c', 'T', 'L'):
219  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
220  (ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
221  goto fail;
222  acTL_found = 1;
223  ctx->num_frames = AV_RB32(st->codecpar->extradata + ret + 8);
224  ctx->num_play = AV_RB32(st->codecpar->extradata + ret + 12);
225  av_log(s, AV_LOG_DEBUG, "num_frames: %"PRIu32", num_play: %"PRIu32"\n",
226  ctx->num_frames, ctx->num_play);
227  break;
228  case MKTAG('f', 'c', 'T', 'L'):
229  if (!acTL_found) {
231  goto fail;
232  }
233  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0)
234  goto fail;
235  return 0;
236  default:
237  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
238  (ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
239  goto fail;
240  }
241  }
242 
243 fail:
244  if (st->codecpar->extradata_size) {
245  av_freep(&st->codecpar->extradata);
246  st->codecpar->extradata_size = 0;
247  }
248  return ret;
249 }
250 
252 {
253  uint32_t sequence_number, width, height, x_offset, y_offset;
254  uint16_t delay_num, delay_den;
255  uint8_t dispose_op, blend_op;
256 
257  sequence_number = avio_rb32(s->pb);
258  width = avio_rb32(s->pb);
259  height = avio_rb32(s->pb);
260  x_offset = avio_rb32(s->pb);
261  y_offset = avio_rb32(s->pb);
262  delay_num = avio_rb16(s->pb);
263  delay_den = avio_rb16(s->pb);
264  dispose_op = avio_r8(s->pb);
265  blend_op = avio_r8(s->pb);
266  avio_skip(s->pb, 4); /* crc */
267 
268  /* default is hundredths of seconds */
269  if (!delay_den)
270  delay_den = 100;
271  if (!delay_num || (ctx->max_fps && delay_den / delay_num > ctx->max_fps)) {
272  delay_num = 1;
273  delay_den = ctx->default_fps;
274  }
275  ctx->pkt_duration = av_rescale_q(delay_num,
276  (AVRational){ 1, delay_den },
277  s->streams[0]->time_base);
278 
279  av_log(s, AV_LOG_DEBUG, "%s: "
280  "sequence_number: %"PRId32", "
281  "width: %"PRIu32", "
282  "height: %"PRIu32", "
283  "x_offset: %"PRIu32", "
284  "y_offset: %"PRIu32", "
285  "delay_num: %"PRIu16", "
286  "delay_den: %"PRIu16", "
287  "dispose_op: %d, "
288  "blend_op: %d\n",
289  __FUNCTION__,
290  sequence_number,
291  width,
292  height,
293  x_offset,
294  y_offset,
295  delay_num,
296  delay_den,
297  dispose_op,
298  blend_op);
299 
300  if (width != s->streams[0]->codecpar->width ||
301  height != s->streams[0]->codecpar->height ||
302  x_offset != 0 ||
303  y_offset != 0) {
304  if (sequence_number == 0 ||
305  x_offset >= s->streams[0]->codecpar->width ||
306  width > s->streams[0]->codecpar->width - x_offset ||
307  y_offset >= s->streams[0]->codecpar->height ||
308  height > s->streams[0]->codecpar->height - y_offset)
309  return AVERROR_INVALIDDATA;
310  ctx->is_key_frame = 0;
311  } else {
312  if (sequence_number == 0 && dispose_op == APNG_DISPOSE_OP_PREVIOUS)
313  dispose_op = APNG_DISPOSE_OP_BACKGROUND;
314  ctx->is_key_frame = dispose_op == APNG_DISPOSE_OP_BACKGROUND ||
315  blend_op == APNG_BLEND_OP_SOURCE;
316  }
317 
318  return 0;
319 }
320 
322 {
323  APNGDemuxContext *ctx = s->priv_data;
324  int64_t ret;
325  int64_t size;
326  AVIOContext *pb = s->pb;
327  uint32_t len, tag;
328 
329  /*
330  * fcTL chunk length, in bytes:
331  * 4 (length)
332  * 4 (tag)
333  * 26 (actual chunk)
334  * 4 (crc) bytes
335  * and needed next:
336  * 4 (length)
337  * 4 (tag (must be fdAT or IDAT))
338  */
339  /* if num_play is not 1, then the seekback is already guaranteed */
340  if (ctx->num_play == 1 && (ret = ffio_ensure_seekback(pb, 46)) < 0)
341  return ret;
342 
343  len = avio_rb32(pb);
344  tag = avio_rl32(pb);
345 
346  if (avio_feof(pb))
347  return AVERROR_EOF;
348 
349  switch (tag) {
350  case MKTAG('f', 'c', 'T', 'L'):
351  if (len != 26)
352  return AVERROR_INVALIDDATA;
353 
354  if ((ret = decode_fctl_chunk(s, ctx, pkt)) < 0)
355  return ret;
356 
357  /* fcTL must precede fdAT or IDAT */
358  len = avio_rb32(pb);
359  tag = avio_rl32(pb);
360  if (len > 0x7fffffff ||
361  tag != MKTAG('f', 'd', 'A', 'T') &&
362  tag != MKTAG('I', 'D', 'A', 'T'))
363  return AVERROR_INVALIDDATA;
364 
365  size = 38 /* fcTL */ + 8 /* len, tag */ + len + 4 /* crc */;
366  if (size > INT_MAX)
367  return AVERROR(EINVAL);
368 
369  if ((ret = avio_seek(pb, -46, SEEK_CUR)) < 0 ||
370  (ret = av_append_packet(pb, pkt, size)) < 0)
371  return ret;
372 
373  if (ctx->num_play == 1 && (ret = ffio_ensure_seekback(pb, 8)) < 0)
374  return ret;
375 
376  len = avio_rb32(pb);
377  tag = avio_rl32(pb);
378  while (tag &&
379  tag != MKTAG('f', 'c', 'T', 'L') &&
380  tag != MKTAG('I', 'E', 'N', 'D')) {
381  if (len > 0x7fffffff)
382  return AVERROR_INVALIDDATA;
383  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
384  (ret = av_append_packet(pb, pkt, len + 12)) < 0)
385  return ret;
386  if (ctx->num_play == 1 && (ret = ffio_ensure_seekback(pb, 8)) < 0)
387  return ret;
388  len = avio_rb32(pb);
389  tag = avio_rl32(pb);
390  }
391  if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0)
392  return ret;
393 
394  if (ctx->is_key_frame)
396  pkt->pts = pkt->dts = AV_NOPTS_VALUE;
397  pkt->duration = ctx->pkt_duration;
398  return ret;
399  case MKTAG('I', 'E', 'N', 'D'):
400  ctx->cur_loop++;
401  if (ctx->ignore_loop || ctx->num_play >= 1 && ctx->cur_loop == ctx->num_play) {
402  avio_seek(pb, -8, SEEK_CUR);
403  return AVERROR_EOF;
404  }
405  if ((ret = avio_seek(pb, s->streams[0]->codecpar->extradata_size + 8, SEEK_SET)) < 0)
406  return ret;
407  return 0;
408  default:
409  avpriv_request_sample(s, "In-stream tag=%s (0x%08"PRIX32") len=%"PRIu32,
410  av_fourcc2str(tag), tag, len);
411  avio_skip(pb, len + 4);
412  }
413 
414  /* Handle the unsupported yet cases */
415  return AVERROR_PATCHWELCOME;
416 }
417 
418 static const AVOption options[] = {
419  { "ignore_loop", "ignore loop setting" , offsetof(APNGDemuxContext, ignore_loop),
420  AV_OPT_TYPE_BOOL, { .i64 = 1 } , 0, 1 , AV_OPT_FLAG_DECODING_PARAM },
421  { "max_fps" , "maximum framerate (0 is no limit)" , offsetof(APNGDemuxContext, max_fps),
422  AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
423  { "default_fps", "default framerate (0 is as fast as possible)", offsetof(APNGDemuxContext, default_fps),
425  { NULL },
426 };
427 
428 static const AVClass demuxer_class = {
429  .class_name = "APNG demuxer",
430  .item_name = av_default_item_name,
431  .option = options,
432  .version = LIBAVUTIL_VERSION_INT,
433  .category = AV_CLASS_CATEGORY_DEMUXER,
434 };
435 
437  .name = "apng",
438  .long_name = NULL_IF_CONFIG_SMALL("Animated Portable Network Graphics"),
439  .priv_data_size = sizeof(APNGDemuxContext),
444  .priv_class = &demuxer_class,
445 };
ff_apng_demuxer
AVInputFormat ff_apng_demuxer
Definition: apngdec.c:436
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: avcodec.h:3971
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:4480
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:3953
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
GetByteContext
Definition: bytestream.h:33
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: avcodec.h:3949
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:55
MKTAG
#define MKTAG(a, b, c, d)
Definition: common.h:366
end
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
apng_read_header
static int apng_read_header(AVFormatContext *s)
Definition: apngdec.c:146
AVOption
AVOption.
Definition: opt.h:246
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1495
AVProbeData::buf_size
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:449
AV_CODEC_ID_APNG
@ AV_CODEC_ID_APNG
Definition: avcodec.h:428
avio_size
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:336
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1509
APNGDemuxContext::ignore_loop
int ignore_loop
Definition: apngdec.c:54
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
bytestream2_get_bytes_left
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:154
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:458
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:164
fail
#define fail()
Definition: checkasm.h:120
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
AVFMT_GENERIC_INDEX
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition: avformat.h:468
APNG_DISPOSE_OP_BACKGROUND
@ APNG_DISPOSE_OP_BACKGROUND
Definition: apng.h:32
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:800
state
static struct @313 state
AVInputFormat
Definition: avformat.h:640
width
#define width
intreadwrite.h
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:645
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:448
AVCodecParameters::width
int width
Video only.
Definition: avcodec.h:4023
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
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
AV_CLASS_CATEGORY_DEMUXER
@ AV_CLASS_CATEGORY_DEMUXER
Definition: log.h:34
apng_read_packet
static int apng_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: apngdec.c:321
AVFormatContext
Format I/O context.
Definition: avformat.h:1342
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1017
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:530
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
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:191
avio_rb64
uint64_t avio_rb64(AVIOContext *s)
Definition: aviobuf.c:921
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:446
APNGDemuxContext::num_play
uint32_t num_play
Definition: apngdec.c:56
DEFAULT_APNG_FPS
#define DEFAULT_APNG_FPS
Definition: apngdec.c:39
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: avcodec.h:3975
AV_WB32
#define AV_WB32(p, v)
Definition: intreadwrite.h:419
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:769
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
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:188
decode_fctl_chunk
static int decode_fctl_chunk(AVFormatContext *s, APNGDemuxContext *ctx, AVPacket *pkt)
Definition: apngdec.c:251
avpriv_set_pts_info
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:4910
size
int size
Definition: twinvq_data.h:11134
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:92
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: avcodec.h:1476
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:638
height
#define height
append_extradata
static int append_extradata(AVCodecParameters *par, AVIOContext *pb, int len)
Definition: apngdec.c:124
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:1051
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: avcodec.h:1483
PNGSIG
#define PNGSIG
Definition: png.h:47
av_realloc
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:135
options
static const AVOption options[]
Definition: apngdec.c:418
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1470
avio_internal.h
APNGDemuxContext::max_fps
int max_fps
Definition: apngdec.c:44
AVCodecParameters::height
int height
Definition: avcodec.h:4024
APNGDemuxContext::is_key_frame
int is_key_frame
Definition: apngdec.c:49
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:277
uint8_t
uint8_t
Definition: audio_convert.c:194
APNGDemuxContext::pkt_duration
int pkt_duration
Definition: apngdec.c:47
len
int len
Definition: vorbis_enc_data.h:452
tag
uint32_t tag
Definition: movenc.c:1496
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:870
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:246
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:72
avio_rb16
unsigned int avio_rb16(AVIOContext *s)
Definition: aviobuf.c:785
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:323
avformat.h
APNG_DISPOSE_OP_PREVIOUS
@ APNG_DISPOSE_OP_PREVIOUS
Definition: apng.h:33
apng_probe
static int apng_probe(const AVProbeData *p)
Definition: apngdec.c:69
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: avcodec.h:790
APNGDemuxContext
Definition: apngdec.c:41
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
APNG_BLEND_OP_SOURCE
@ APNG_BLEND_OP_SOURCE
Definition: apng.h:37
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:647
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:331
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:39
APNGDemuxContext::cur_loop
uint32_t cur_loop
Definition: apngdec.c:57
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:3957
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1454
png.h
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
bytestream.h
demuxer_class
static const AVClass demuxer_class
Definition: apngdec.c:428
imgutils.h
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:133
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
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:59
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:282
APNGDemuxContext::default_fps
int default_fps
Definition: apngdec.c:45
APNGDemuxContext::num_frames
uint32_t num_frames
Definition: apngdec.c:55
av_fourcc2str
#define av_fourcc2str(fourcc)
Definition: avutil.h:348
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:358