39 #define DEFAULT_APNG_FPS 15
78 if (bytestream2_get_be64(&gb) !=
PNGSIG)
82 len = bytestream2_get_be32(&gb);
86 tag = bytestream2_get_le32(&gb);
89 if (tag !=
MKTAG(
'I',
'D',
'A',
'T') &&
94 case MKTAG(
'I',
'H',
'D',
'R'):
102 case MKTAG(
'a',
'c',
'T',
'L'):
105 bytestream2_get_be32(&gb) == 0)
110 case MKTAG(
'I',
'D',
'A',
'T'):
131 if (previous_size > INT_MAX - len)
134 new_size = previous_size +
len;
144 return previous_size;
163 if (len != 13 || tag !=
MKTAG(
'I',
'H',
'D',
'R'))
193 if (acTL_found && ctx->
num_play != 1) {
199 }
else if (offset < 0) {
207 if ((ctx->
num_play == 1 || !acTL_found) &&
212 if (len > 0x7fffffff) {
219 case MKTAG(
'a',
'c',
'T',
'L'):
220 if ((ret =
avio_seek(pb, -8, SEEK_CUR)) < 0 ||
229 case MKTAG(
'f',
'c',
'T',
'L'):
234 if ((ret =
avio_seek(pb, -8, SEEK_CUR)) < 0)
238 if ((ret =
avio_seek(pb, -8, SEEK_CUR)) < 0 ||
254 uint32_t sequence_number,
width,
height, x_offset, y_offset;
255 uint16_t delay_num, delay_den;
272 if (!delay_num || (ctx->
max_fps && delay_den / delay_num > ctx->
max_fps)) {
281 "sequence_number: %"PRId32
", "
283 "height: %"PRIu32
", "
284 "x_offset: %"PRIu32
", "
285 "y_offset: %"PRIu32
", "
286 "delay_num: %"PRIu16
", "
287 "delay_den: %"PRIu16
", "
305 if (sequence_number == 0 ||
347 case MKTAG(
'f',
'c',
'T',
'L'):
357 if (len > 0x7fffffff ||
358 tag !=
MKTAG(
'f',
'd',
'A',
'T') &&
359 tag !=
MKTAG(
'I',
'D',
'A',
'T'))
362 size = 38 + 8 + len + 4 ;
366 if ((ret =
avio_seek(pb, -46, SEEK_CUR)) < 0 ||
376 tag !=
MKTAG(
'f',
'c',
'T',
'L') &&
377 tag !=
MKTAG(
'I',
'E',
'N',
'D')) {
378 if (len > 0x7fffffff)
380 if ((ret =
avio_seek(pb, -8, SEEK_CUR)) < 0 ||
388 if ((ret =
avio_seek(pb, -8, SEEK_CUR)) < 0)
397 case MKTAG(
'I',
'E',
'N',
'D'):
417 {
"ignore_loop",
"ignore loop setting" , offsetof(
APNGDemuxContext, ignore_loop),
419 {
"max_fps" ,
"maximum framerate (0 is no limit)" , offsetof(
APNGDemuxContext, max_fps),
421 {
"default_fps",
"default framerate (0 is as fast as possible)", offsetof(
APNGDemuxContext, default_fps),
442 .priv_class = &demuxer_class,
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static int apng_probe(AVProbeData *p)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
AVInputFormat ff_apng_demuxer
unsigned int avio_rb16(AVIOContext *s)
This struct describes the properties of an encoded stream.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
unsigned int avio_rb32(AVIOContext *s)
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
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
AVStream ** streams
A list of all streams in the file.
#define AVERROR_EOF
End of file.
uint64_t avio_rb64(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
unsigned int avio_rl32(AVIOContext *s)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define av_fourcc2str(fourcc)
enum AVMediaType codec_type
General type of the encoded data.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
static const uint8_t offset[127][2]
int flags
A combination of AV_PKT_FLAG values.
int extradata_size
Size of the extradata content in bytes.
int avio_r8(AVIOContext *s)
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
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...
static int decode_fctl_chunk(AVFormatContext *s, APNGDemuxContext *ctx, AVPacket *pkt)
static int append_extradata(AVCodecParameters *par, AVIOContext *pb, int len)
static int apng_read_packet(AVFormatContext *s, AVPacket *pkt)
static int read_header(FFV1Context *f)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
AVIOContext * pb
I/O context.
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static const AVOption options[]
This structure contains the data a format has to probe a file.
static const AVClass demuxer_class
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
void * priv_data
Format private data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
AVCodecParameters * codecpar
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define MKTAG(a, b, c, d)
This structure stores compressed data.
static int apng_read_header(AVFormatContext *s)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...