Go to the documentation of this file.
63 uint8_t *buf,
size_t length)
73 crc =
av_crc(crc_table, crc, tagbuf, 4);
76 crc =
av_crc(crc_table, crc, buf, length);
91 "APNG muxer supports only a single video APNG stream.\n");
99 "Last frame delay is too precise. Reducing to %d/%d (%f).\n",
122 uint8_t *side_data =
NULL;
123 size_t side_data_size;
129 if (side_data_size) {
139 const uint8_t *existing_acTL_chunk;
140 const uint8_t *existing_fcTL_chunk;
142 av_log(format_context,
AV_LOG_INFO,
"Only a single frame so saving as a normal PNG.\n");
146 if (existing_acTL_chunk) {
147 const uint8_t *chunk_after_acTL = existing_acTL_chunk +
AV_RB32(existing_acTL_chunk) + 12;
156 if (existing_fcTL_chunk) {
157 const uint8_t *chunk_after_fcTL = existing_fcTL_chunk +
AV_RB32(existing_fcTL_chunk) + 12;
164 const uint8_t *
data, *data_end;
165 const uint8_t *existing_fcTL_chunk;
168 const uint8_t *existing_acTL_chunk;
174 if (!existing_acTL_chunk) {
187 if (existing_fcTL_chunk) {
193 existing_fcTL_chunk += 8;
194 delay.
num =
AV_RB16(existing_fcTL_chunk + 20);
195 delay.
den =
AV_RB16(existing_fcTL_chunk + 22);
197 if (delay.
num == 0 && delay.
den == 0) {
203 if (!
av_reduce(&delay.
num, &delay.
den, delay_num_raw, delay_den_raw, UINT16_MAX) &&
206 "Frame rate is too high or specified too precisely. Unable to copy losslessly.\n");
218 memcpy(new_fcTL_chunk, existing_fcTL_chunk,
sizeof(new_fcTL_chunk));
222 new_fcTL_chunk,
sizeof(new_fcTL_chunk));
293 #define OFFSET(x) offsetof(APNGMuxContext, x)
294 #define ENC AV_OPT_FLAG_ENCODING_PARAM
296 {
"plays",
"Number of times to play the output: 0 - infinite loop, 1 - no loop",
OFFSET(plays),
298 {
"final_delay",
"Force delay after the last frame",
OFFSET(last_delay),
313 .p.mime_type =
"image/png",
314 .p.extensions =
"apng",
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
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
enum AVMediaType codec_type
General type of the encoded data.
static const AVClass apng_muxer_class
static int apng_write_trailer(AVFormatContext *format_context)
This struct describes the properties of an encoded stream.
#define APNG_FCTL_CHUNK_SIZE
AVStream ** streams
A list of all streams in the file.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int flush_packet(AVFormatContext *format_context, AVPacket *packet)
static void apng_write_chunk(AVIOContext *io_context, uint32_t tag, uint8_t *buf, size_t length)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
AVIOContext * pb
I/O context.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
int extradata_size
Size of the extradata content in bytes.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
#define MKBETAG(a, b, c, d)
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
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wb32(AVIOContext *s, unsigned int val)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
static const AVOption options[]
#define AV_LOG_INFO
Standard information.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
static const uint8_t * apng_find_chunk(uint32_t tag, const uint8_t *buf, size_t length)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int apng_write_packet(AVFormatContext *format_context, AVPacket *packet)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_INPUT_BUFFER_PADDING_SIZE
const FFOutputFormat ff_apng_muxer
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
void avio_wb64(AVIOContext *s, uint64_t val)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int apng_write_header(AVFormatContext *format_context)
void * priv_data
Format private data.
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_RB16
static void apng_deinit(AVFormatContext *s)