45#define IOBUF_SIZE 4096
92 int bits_per_pixel,
int pass,
95 int x,
mask, dst_x, j,
b, bpp;
98 static const int masks[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
101 switch (bits_per_pixel) {
103 memset(
dst, 0, row_size);
105 for (x = 0; x <
width; x++) {
107 if ((
mask << j) & 0x80) {
108 b = (
src[x >> 3] >> (7 - j)) & 1;
109 dst[dst_x >> 3] |=
b << (7 - (dst_x & 7));
115 bpp = bits_per_pixel >> 3;
118 for (x = 0; x <
width; x++) {
120 if ((
mask << j) & 0x80) {
134 for (
i = 0;
i <
w;
i++) {
135 int a,
b,
c, p, pa, pb, pc;
148 if (pa <= pb && pa <= pc)
160 const uint8_t *
src1 =
src + bpp;
168 for (x = 0; x < unaligned_w; x++)
175 const uint8_t *
src,
const uint8_t *top,
int size,
int bpp)
179 switch (filter_type) {
190 for (
i = 0;
i < bpp;
i++)
196 for (
i = 0;
i < bpp;
i++)
201 av_unreachable(
"PNG_FILTER_VALUE_MIXED can't happen here and all others are covered");
206 const uint8_t *
src,
const uint8_t *top,
int size,
int bpp)
208 int pred =
s->filter_type;
214 int cost, bcost = INT_MAX;
221 cost +=
abs((int8_t) buf1[
i]);
224 FFSWAP(uint8_t *, buf1, buf2);
236 const uint8_t *buf,
int length)
242 bytestream_put_be32(
f, length);
244 crc =
av_crc(crc_table, crc, tagbuf, 4);
247 crc =
av_crc(crc_table, crc, buf, length);
249 memcpy(*
f, buf, length);
252 bytestream_put_be32(
f, ~crc);
256 const uint8_t *buf,
int length)
267 bytestream_put_be32(&
s->bytestream, length + 4);
269 bytestream_put_be32(&
s->bytestream,
MKBETAG(
'f',
'd',
'A',
'T'));
270 bytestream_put_be32(&
s->bytestream,
s->sequence_number);
271 crc =
av_crc(crc_table, crc,
s->bytestream - 8, 8);
273 crc =
av_crc(crc_table, crc, buf, length);
274 memcpy(
s->bytestream, buf, length);
275 s->bytestream += length;
277 bytestream_put_be32(&
s->bytestream, ~crc);
279 ++
s->sequence_number;
286 z_stream *
const zstream = &
s->zstream.zstream;
289 zstream->avail_in =
size;
290 zstream->next_in =
data;
291 while (zstream->avail_in > 0) {
292 ret =
deflate(zstream, Z_NO_FLUSH);
295 if (zstream->avail_out == 0) {
296 if (
s->bytestream_end -
s->bytestream >
IOBUF_SIZE + 100)
299 zstream->next_out =
s->buf;
305#define PNG_LRINT(d, divisor) lrint((d) * (divisor))
306#define PNG_Q2D(q, divisor) PNG_LRINT(av_q2d(q), (divisor))
307#define AV_WB32_PNG_D(buf, q) AV_WB32(buf, PNG_Q2D(q, 100000))
338 z_stream *
const zstream = &
s->zstream.zstream;
341 uint8_t *start, *buf;
344 if (!sd || !sd->
size)
346 zstream->next_in = sd->
data;
347 zstream->avail_in = sd->
size;
350 start =
s->bytestream + 8;
356 for (
int i = 0;;
i++) {
357 char c = (
i == 79) ? 0 :
name[
i];
358 bytestream_put_byte(&buf,
c);
364 bytestream_put_byte(&buf, 0);
365 zstream->next_out = buf;
366 zstream->avail_out =
s->bytestream_end - buf;
367 ret =
deflate(zstream, Z_FINISH);
368 deflateReset(zstream);
369 if (ret != Z_STREAM_END)
374 zstream->next_out - start);
387 s->buf[8] =
s->bit_depth;
388 s->buf[9] =
s->color_type;
391 s->buf[12] =
s->is_progressive;
410 switch (stereo3d->
type) {
418 av_log(avctx,
AV_LOG_WARNING,
"Only side-by-side stereo3d flag can be defined within sTER chunk\n");
467 for (
int i = 0;
i < 3;
i++) {
496 uint8_t *ptr, *alpha_ptr;
498 palette = (uint32_t *)pict->
data[1];
500 alpha_ptr =
s->buf + 256 * 3;
502 for (
i = 0;
i < 256;
i++) {
507 *alpha_ptr++ =
alpha;
508 bytestream_put_be24(&ptr, v);
511 MKTAG(
'P',
'L',
'T',
'E'),
s->buf, 256 * 3);
514 MKTAG(
't',
'R',
'N',
'S'),
s->buf + 256 * 3, 256);
524 z_stream *
const zstream = &
s->zstream.zstream;
527 int row_size, pass_row_size;
528 uint8_t *crow_buf, *crow;
529 uint8_t *crow_base =
NULL;
530 uint8_t *progressive_buf =
NULL;
531 uint8_t *top_buf =
NULL;
533 row_size = (pict->
width *
s->bits_per_pixel + 7) >> 3;
541 crow_buf = crow_base + 15;
542 if (
s->is_progressive) {
543 progressive_buf =
av_malloc(row_size + 1);
545 if (!progressive_buf || !top_buf) {
553 zstream->next_out =
s->buf;
554 if (
s->is_progressive) {
557 for (pass = 0; pass <
NB_PASSES; pass++) {
561 if (pass_row_size > 0) {
563 for (y = 0; y < pict->
height; y++)
565 const uint8_t *ptr = p->data[0] + y * p->linesize[0];
566 FFSWAP(uint8_t *, progressive_buf, top_buf);
568 s->bits_per_pixel, pass,
571 top, pass_row_size,
s->bits_per_pixel >> 3);
573 top = progressive_buf;
578 const uint8_t *top =
NULL;
579 for (y = 0; y < pict->
height; y++) {
580 const uint8_t *ptr = p->data[0] + y * p->linesize[0];
582 row_size,
s->bits_per_pixel >> 3);
589 ret =
deflate(zstream, Z_FINISH);
590 if (ret == Z_OK || ret == Z_STREAM_END) {
592 if (
len > 0 &&
s->bytestream_end -
s->bytestream >
len + 100) {
596 zstream->next_out =
s->buf;
597 if (ret == Z_STREAM_END)
611 deflateReset(zstream);
616 uint64_t *max_packet_size)
620 const int hdr_size = 128;
621 uint64_t new_pkt_size;
627 if (!sd || !sd->
size)
632 bound = deflateBound(&
s->zstream.zstream, sd->
size);
633 if (
bound > INT32_MAX - hdr_size)
636 new_pkt_size = *max_packet_size +
bound + hdr_size;
637 if (new_pkt_size < *max_packet_size)
639 *max_packet_size = new_pkt_size;
644 uint64_t *max_packet_size)
646 uint64_t new_pkt_size;
665 new_pkt_size = *max_packet_size +
s->exif_data->size + 12;
666 if (new_pkt_size < *max_packet_size) {
671 *max_packet_size = new_pkt_size;
677 const AVFrame *pict,
int *got_packet)
682 uint64_t max_packet_size;
684 enc_row_size = deflateBound(&
s->zstream.zstream,
685 (avctx->
width *
s->bits_per_pixel + 7) >> 3);
702 s->bytestream_start =
703 s->bytestream =
pkt->data;
704 s->bytestream_end =
pkt->data +
pkt->size;
719 pkt->size =
s->bytestream -
s->bytestream_start;
733 unsigned int leftmost_x = input->
width;
734 unsigned int rightmost_x = 0;
735 unsigned int topmost_y = input->
height;
736 unsigned int bottommost_y = 0;
739 ptrdiff_t input_linesize = input->
linesize[0];
740 ptrdiff_t output_linesize = output->
linesize[0];
743 for (y = 0; y < input->
height; ++y) {
744 for (x = 0; x < input->
width; ++x) {
750 if (x >= rightmost_x)
754 if (y >= bottommost_y)
755 bottommost_y = y + 1;
762 if (leftmost_x == input->
width && rightmost_x == 0) {
765 leftmost_x = topmost_y = 0;
766 rightmost_x = bottommost_y = 1;
772 for (y = topmost_y; y < bottommost_y; ++y) {
774 input->
data[0] + input_linesize * y + bpp * leftmost_x,
775 bpp * (rightmost_x - leftmost_x));
779 size_t transparent_palette_index;
790 palette = (uint32_t*)input->
data[1];
791 for (transparent_palette_index = 0; transparent_palette_index < 256; ++transparent_palette_index)
792 if (palette[transparent_palette_index] >> 24 == 0)
801 for (y = topmost_y; y < bottommost_y; ++y) {
802 const uint8_t *foreground = input->
data[0] + input_linesize * y + bpp * leftmost_x;
803 uint8_t *background = output->
data[0] + output_linesize * y + bpp * leftmost_x;
805 for (x = leftmost_x; x < rightmost_x; ++x, foreground += bpp, background += bpp,
output_data += bpp) {
806 if (!memcmp(foreground, background, bpp)) {
808 if (transparent_palette_index == 256) {
826 if (((uint16_t*)foreground)[3] == 0xffff ||
827 ((uint16_t*)background)[3] == 0)
832 if (((uint16_t*)foreground)[1] == 0xffff ||
833 ((uint16_t*)background)[1] == 0)
838 if (foreground[3] == 0xff || background[3] == 0)
843 if (foreground[1] == 0xff || background[1] == 0)
848 if (palette[*foreground] >> 24 == 0xff ||
849 palette[*background] >> 24 == 0)
862 output->
width = rightmost_x - leftmost_x;
863 output->
height = bottommost_y - topmost_y;
879 uint8_t bpp = (
s->bits_per_pixel + 7) >> 3;
880 uint8_t *original_bytestream, *original_bytestream_end;
881 uint8_t *temp_bytestream = 0, *temp_bytestream_end;
882 uint32_t best_sequence_number;
883 uint8_t *best_bytestream;
884 size_t best_bytestream_size = SIZE_MAX;
908 original_bytestream =
s->bytestream;
909 original_bytestream_end =
s->bytestream_end;
911 temp_bytestream =
av_malloc(original_bytestream_end - original_bytestream);
912 if (!temp_bytestream) {
916 temp_bytestream_end = temp_bytestream + (original_bytestream_end - original_bytestream);
930 uint32_t original_sequence_number =
s->sequence_number, sequence_number;
931 uint8_t *bytestream_start =
s->bytestream;
932 size_t bytestream_size;
944 size_t row_start = diffFrame->
linesize[0] * y + bpp * last_fctl_chunk.
x_offset;
945 memset(diffFrame->
data[0] + row_start, 0, bpp * last_fctl_chunk.
width);
965 sequence_number =
s->sequence_number;
966 s->sequence_number = original_sequence_number;
967 bytestream_size =
s->bytestream - bytestream_start;
968 s->bytestream = bytestream_start;
972 if (bytestream_size < best_bytestream_size) {
973 *best_fctl_chunk = fctl_chunk;
974 *best_last_fctl_chunk = last_fctl_chunk;
976 best_sequence_number = sequence_number;
977 best_bytestream =
s->bytestream;
978 best_bytestream_size = bytestream_size;
980 if (best_bytestream == original_bytestream) {
981 s->bytestream = temp_bytestream;
982 s->bytestream_end = temp_bytestream_end;
984 s->bytestream = original_bytestream;
985 s->bytestream_end = original_bytestream_end;
991 s->sequence_number = best_sequence_number;
992 s->bytestream = original_bytestream + best_bytestream_size;
993 s->bytestream_end = original_bytestream_end;
994 if (best_bytestream != original_bytestream)
995 memcpy(original_bytestream, best_bytestream, best_bytestream_size);
1006 const AVFrame *pict,
int *got_packet)
1011 uint64_t max_packet_size;
1018 s->palette_checksum = checksum;
1019 }
else if (checksum !=
s->palette_checksum) {
1021 "Input contains more than one unique palette. APNG does not support multiple palettes.\n");
1026 enc_row_size = deflateBound(&
s->zstream.zstream,
1027 (avctx->
width *
s->bits_per_pixel + 7) >> 3);
1034 if (max_packet_size > INT_MAX)
1048 if (extradata_size > SIZE_MAX)
1050 s->bytestream =
s->extra_data =
av_malloc(extradata_size);
1058 s->extra_data_size =
s->bytestream -
s->extra_data;
1060 s->last_frame_packet =
av_malloc(max_packet_size);
1061 if (!
s->last_frame_packet)
1063 }
else if (
s->last_frame) {
1068 memcpy(
pkt->data,
s->last_frame_packet,
s->last_frame_packet_size);
1069 pkt->pts =
s->last_frame->pts;
1070 pkt->duration =
s->last_frame->duration;
1078 s->bytestream_start =
1079 s->bytestream =
s->last_frame_packet;
1080 s->bytestream_end =
s->bytestream + max_packet_size;
1085 ++
s->sequence_number;
1098 if (
s->last_frame) {
1099 uint8_t* last_fctl_chunk_start =
pkt->data;
1101 if (!
s->extra_data_updated) {
1105 memcpy(side_data,
s->extra_data,
s->extra_data_size);
1106 s->extra_data_updated = 1;
1109 AV_WB32(buf + 0,
s->last_frame_fctl.sequence_number);
1110 AV_WB32(buf + 4,
s->last_frame_fctl.width);
1111 AV_WB32(buf + 8,
s->last_frame_fctl.height);
1112 AV_WB32(buf + 12,
s->last_frame_fctl.x_offset);
1113 AV_WB32(buf + 16,
s->last_frame_fctl.y_offset);
1114 AV_WB16(buf + 20,
s->last_frame_fctl.delay_num);
1115 AV_WB16(buf + 22,
s->last_frame_fctl.delay_den);
1116 buf[24] =
s->last_frame_fctl.dispose_op;
1117 buf[25] =
s->last_frame_fctl.blend_op;
1124 if (!
s->last_frame) {
1129 if (!
s->prev_frame) {
1134 s->prev_frame->format = pict->
format;
1135 s->prev_frame->width = pict->
width;
1136 s->prev_frame->height = pict->
height;
1145 uint8_t bpp = (
s->bits_per_pixel + 7) >> 3;
1146 for (y =
s->last_frame_fctl.y_offset; y < s->last_frame_fctl.y_offset +
s->last_frame_fctl.height; ++y) {
1147 size_t row_start =
s->prev_frame->linesize[0] * y + bpp *
s->last_frame_fctl.x_offset;
1148 memset(
s->prev_frame->data[0] + row_start, 0, bpp *
s->last_frame_fctl.width);
1157 s->last_frame_fctl = fctl_chunk;
1158 s->last_frame_packet_size =
s->bytestream -
s->bytestream_start;
1169 int compression_level;
1193 if (
s->dpi &&
s->dpm) {
1196 }
else if (
s->dpi) {
1197 s->dpm =
s->dpi * 10000 / 254;
1248 ? Z_DEFAULT_COMPRESSION
1263 s->extra_data_size = 0;
1267#define OFFSET(x) offsetof(PNGEncContext, x)
1268#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1271 {
"dpm",
"Set image resolution (in dots per meter)",
OFFSET(dpm),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 0x10000,
VE},
1283 .class_name =
"(A)PNG encoder",
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double bound(const double threshold, const double val)
const FFCodec ff_png_encoder
const FFCodec ff_apng_encoder
#define APNG_FCTL_CHUNK_SIZE
@ APNG_DISPOSE_OP_BACKGROUND
@ APNG_DISPOSE_OP_PREVIOUS
static av_cold void close(AVCodecParserContext *s)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define FF_COMPRESSION_DEFAULT
refcounted data buffer API
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_CAP_ICC_PROFILES
Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE).
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
Public header for CRC hash function implementation.
Colorspace value utility functions for libavutil.
int(* init)(AVBSFContext *ctx)
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
int ff_encode_reordered_opaque(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame)
Propagate user opaque values from the frame to avctx/pkt as needed.
#define FF_INPUT_BUFFER_MIN_SIZE
Used by some encoders as upper bound for the length of headers.
int ff_exif_get_buffer(void *logctx, const AVFrame *frame, AVBufferRef **buffer_ptr, enum AVExifHeaderMode header_mode)
Gets all relevant side data, collects it into an IFD, and writes it into the corresponding buffer poi...
@ AV_EXIF_TIFF_HEADER
The TIFF header starts with 0x49492a00, or 0x4d4d002a.
EXIF metadata parser - internal functions.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ 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...
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
int av_frame_replace(AVFrame *dst, const AVFrame *src)
Ensure the destination frame refers to the same data described by the source frame,...
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
const AVColorPrimariesDesc * av_csp_primaries_desc_from_id(enum AVColorPrimaries prm)
Retrieves a complete gamut description from an enum constant describing the color primaries.
double av_csp_approximate_eotf_gamma(enum AVColorTransferCharacteristic trc)
Determine a suitable EOTF 'gamma' value to match the supplied AVColorTransferCharacteristic.
#define LIBAVUTIL_VERSION_INT
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
@ AV_STEREO3D_2D
Video is not stereoscopic (and metadata has to be there).
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
static const int16_t alpha[]
static int output_data(MLPDecodeContext *m, unsigned int substr, AVFrame *frame, int *got_frame_ptr)
Write the audio data into the output buffer.
const uint8_t ff_png_pass_ymask[NB_PASSES]
int ff_png_pass_row_size(int pass, int bits_per_pixel, int width)
int ff_png_get_nb_channels(int color_type)
Replacements for frequently missing libm functions.
av_cold void ff_llvidencdsp_init(LLVidEncDSPContext *c)
static const uint16_t mask[17]
#define FFSWAP(type, a, b)
#define MKTAG(a, b, c, d)
#define MKBETAG(a, b, c, d)
Memory handling functions.
static void input_data(MLPEncodeContext *ctx, MLPSubstream *s, uint8_t **const samples, int nb_samples)
Wrapper function for inputting data in two different bit-depths.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVALPHA_MODE_STRAIGHT
Alpha channel is independent of color values.
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_YA16BE
16 bits gray, 16 bits alpha (big-endian)
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
@ AV_PIX_FMT_GRAY8A
alias for AV_PIX_FMT_YA8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_RGB48BE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
@ AV_PIX_FMT_RGBA64BE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
AVColorPrimaries
Chromaticity coordinates of the source primaries.
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
AVColorTransferCharacteristic
Color Transfer Characteristic.
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
#define PNG_COLOR_TYPE_RGB
#define PNG_FILTER_VALUE_MIXED
#define PNG_COLOR_TYPE_RGB_ALPHA
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_FILTER_VALUE_AVG
#define PNG_COLOR_MASK_PALETTE
#define PNG_FILTER_VALUE_UP
#define PNG_COLOR_TYPE_GRAY
#define PNG_COLOR_TYPE_PALETTE
#define PNG_FILTER_VALUE_PAETH
#define PNG_FILTER_VALUE_NONE
#define PNG_FILTER_VALUE_SUB
static av_cold int png_enc_init(AVCodecContext *avctx)
static int apng_encode_frame(AVCodecContext *avctx, const AVFrame *pict, APNGFctlChunk *best_fctl_chunk, APNGFctlChunk *best_last_fctl_chunk)
static int encode_apng(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static void sub_left_prediction(PNGEncContext *c, uint8_t *dst, const uint8_t *src, int bpp, int size)
static void png_write_chunk(uint8_t **f, uint32_t tag, const uint8_t *buf, int length)
static int encode_headers(AVCodecContext *avctx, const AVFrame *pict)
static void sub_png_paeth_prediction(uint8_t *dst, const uint8_t *src, const uint8_t *top, int w, int bpp)
static int png_write_iccp(PNGEncContext *s, const AVFrameSideData *sd)
static uint8_t * png_choose_filter(PNGEncContext *s, uint8_t *dst, const uint8_t *src, const uint8_t *top, int size, int bpp)
static void png_filter_row(PNGEncContext *c, uint8_t *dst, int filter_type, const uint8_t *src, const uint8_t *top, int size, int bpp)
static int encode_png(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static int encode_frame(AVCodecContext *avctx, const AVFrame *pict)
static int apng_do_inverse_blend(AVFrame *output, const AVFrame *input, APNGFctlChunk *fctl_chunk, uint8_t bpp)
#define PNG_Q2D(q, divisor)
static int png_get_chrm(enum AVColorPrimaries prim, uint8_t *buf)
static const AVClass pngenc_class
static int png_get_gama(enum AVColorTransferCharacteristic trc, uint8_t *buf)
static int png_write_row(AVCodecContext *avctx, const uint8_t *data, int size)
static av_cold int png_enc_close(AVCodecContext *avctx)
static void png_write_image_data(AVCodecContext *avctx, const uint8_t *buf, int length)
static int add_exif_profile_size(AVCodecContext *avctx, const AVFrame *pict, uint64_t *max_packet_size)
#define PNG_LRINT(d, divisor)
static void png_get_interlaced_row(uint8_t *dst, int row_size, int bits_per_pixel, int pass, const uint8_t *src, int width)
static int add_icc_profile_size(AVCodecContext *avctx, const AVFrame *pict, uint64_t *max_packet_size)
#define AV_WB32_PNG_D(buf, q)
Utilities for rational number calculation.
static const float pred[4]
A reference to a data buffer.
Describe the class of an AVClass context structure.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int64_t frame_num
Frame counter, set by libavcodec.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int flags
AV_CODEC_FLAG_*.
Struct that contains both white point location and primaries location, providing the complete descrip...
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
enum AVColorPrimaries color_primaries
enum AVColorRange color_range
MPEG vs JPEG YUV range.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
enum AVColorTransferCharacteristic color_trc
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This structure stores compressed data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
enum AVStereo3DType type
How views are packed within the video.
int flags
Additional information about the frame packing.
uint32_t palette_checksum
uint8_t * last_frame_packet
int dpm
Physical pixel density, in dots per meter, if set.
size_t last_frame_packet_size
int dpi
Physical pixel density, in dots per inch, if set.
uint8_t * bytestream_start
APNGFctlChunk last_frame_fctl
LLVidEncDSPContext llvidencdsp
static void deflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
int ff_deflate_init(FFZStream *zstream, int level, void *logctx)
Wrapper around deflateInit().
void ff_deflate_end(FFZStream *zstream)
Wrapper around deflateEnd().