3 * Copyright (c) 2003 Fabrice Bellard.
5 * This file is part of FFmpeg.
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.
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.
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
24 * - add 2, 4 and 16 bit depth support
25 * - use filters when generating a png (better compression)
33 #define PNG_COLOR_MASK_PALETTE 1
34 #define PNG_COLOR_MASK_COLOR 2
35 #define PNG_COLOR_MASK_ALPHA 4
37 #define PNG_COLOR_TYPE_GRAY 0
38 #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
39 #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
40 #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
41 #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
43 #define PNG_FILTER_VALUE_NONE 0
44 #define PNG_FILTER_VALUE_SUB 1
45 #define PNG_FILTER_VALUE_UP 2
46 #define PNG_FILTER_VALUE_AVG 3
47 #define PNG_FILTER_VALUE_PAETH 4
49 #define PNG_IHDR 0x0001
50 #define PNG_IDAT 0x0002
51 #define PNG_ALLIMAGE 0x0004
52 #define PNG_PLTE 0x0008
56 #define IOBUF_SIZE 4096
58 typedef struct PNGContext {
60 uint8_t *bytestream_start;
61 uint8_t *bytestream_end;
77 uint32_t palette[256];
82 int crow_size; /* compressed row size (include filter type) */
83 int row_size; /* decompressed row size */
84 int pass_row_size; /* decompress row size of the current pass */
87 uint8_t buf[IOBUF_SIZE];
90 static unsigned int get32(uint8_t **b){
92 return ((*b)[-4]<<24) + ((*b)[-3]<<16) + ((*b)[-2]<<8) + (*b)[-1];
95 #ifdef CONFIG_ENCODERS
96 static void put32(uint8_t **b, unsigned int v){
104 static const uint8_t pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
106 /* Mask to determine which y pixels are valid in a pass */
107 static const uint8_t png_pass_ymask[NB_PASSES] = {
108 0x80, 0x80, 0x08, 0x88, 0x22, 0xaa, 0x55,
111 /* Mask to determine which y pixels can be written in a pass */
112 static const uint8_t png_pass_dsp_ymask[NB_PASSES] = {
113 0xff, 0xff, 0x0f, 0xcc, 0x33, 0xff, 0x55,
116 /* minimum x value */
117 static const uint8_t png_pass_xmin[NB_PASSES] = {
121 /* x shift to get row width */
122 static const uint8_t png_pass_xshift[NB_PASSES] = {
126 /* Mask to determine which pixels are valid in a pass */
127 static const uint8_t png_pass_mask[NB_PASSES] = {
128 0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff
131 /* Mask to determine which pixels to overwrite while displaying */
132 static const uint8_t png_pass_dsp_mask[NB_PASSES] = {
133 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
136 static int png_probe(AVProbeData *pd)
138 if (pd->buf_size >= 8 &&
139 memcmp(pd->buf, pngsig, 8) == 0)
140 return AVPROBE_SCORE_MAX;
145 static void *png_zalloc(void *opaque, unsigned int items, unsigned int size)
147 if(items >= UINT_MAX / size)
149 return av_malloc(items * size);
152 static void png_zfree(void *opaque, void *ptr)
157 static int png_get_nb_channels(int color_type)
161 if ((color_type & (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)) ==
162 PNG_COLOR_MASK_COLOR)
164 if (color_type & PNG_COLOR_MASK_ALPHA)
169 /* compute the row size of an interleaved pass */
170 static int png_pass_row_size(int pass, int bits_per_pixel, int width)
172 int shift, xmin, pass_width;
174 xmin = png_pass_xmin[pass];
177 shift = png_pass_xshift[pass];
178 pass_width = (width - xmin + (1 << shift) - 1) >> shift;
179 return (pass_width * bits_per_pixel + 7) >> 3;
182 /* NOTE: we try to construct a good looking image at each pass. width
183 is the original image width. We also do pixel format convertion at
185 static void png_put_interlaced_row(uint8_t *dst, int width,
186 int bits_per_pixel, int pass,
187 int color_type, const uint8_t *src)
189 int x, mask, dsp_mask, j, src_x, b, bpp;
193 mask = png_pass_mask[pass];
194 dsp_mask = png_pass_dsp_mask[pass];
195 switch(bits_per_pixel) {
197 /* we must intialize the line to zero before writing to it */
199 memset(dst, 0, (width + 7) >> 3);
201 for(x = 0; x < width; x++) {
203 if ((dsp_mask << j) & 0x80) {
204 b = (src[src_x >> 3] >> (7 - (src_x & 7))) & 1;
205 dst[x >> 3] |= b << (7 - j);
207 if ((mask << j) & 0x80)
212 bpp = bits_per_pixel >> 3;
215 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
216 for(x = 0; x < width; x++) {
218 if ((dsp_mask << j) & 0x80) {
219 *(uint32_t *)d = (s[3] << 24) | (s[0] << 16) | (s[1] << 8) | s[2];
222 if ((mask << j) & 0x80)
226 for(x = 0; x < width; x++) {
228 if ((dsp_mask << j) & 0x80) {
232 if ((mask << j) & 0x80)
240 #ifdef CONFIG_ENCODERS
241 static void png_get_interlaced_row(uint8_t *dst, int row_size,
242 int bits_per_pixel, int pass,
243 const uint8_t *src, int width)
245 int x, mask, dst_x, j, b, bpp;
249 mask = png_pass_mask[pass];
250 switch(bits_per_pixel) {
252 memset(dst, 0, row_size);
254 for(x = 0; x < width; x++) {
256 if ((mask << j) & 0x80) {
257 b = (src[x >> 3] >> (7 - j)) & 1;
258 dst[dst_x >> 3] |= b << (7 - (dst_x & 7));
264 bpp = bits_per_pixel >> 3;
267 for(x = 0; x < width; x++) {
269 if ((mask << j) & 0x80) {
281 /* NOTE: 'dst' can be equal to 'last' */
282 static void png_filter_row(uint8_t *dst, int filter_type,
283 uint8_t *src, uint8_t *last, int size, int bpp)
287 switch(filter_type) {
288 case PNG_FILTER_VALUE_NONE:
289 memcpy(dst, src, size);
291 case PNG_FILTER_VALUE_SUB:
292 for(i = 0; i < bpp; i++) {
295 for(i = bpp; i < size; i++) {
300 case PNG_FILTER_VALUE_UP:
301 for(i = 0; i < size; i++) {
306 case PNG_FILTER_VALUE_AVG:
307 for(i = 0; i < bpp; i++) {
311 for(i = bpp; i < size; i++) {
312 p = ((dst[i - bpp] + last[i]) >> 1);
316 case PNG_FILTER_VALUE_PAETH:
317 for(i = 0; i < bpp; i++) {
321 for(i = bpp; i < size; i++) {
322 int a, b, c, pa, pb, pc;
335 if (pa <= pb && pa <= pc)
347 #ifdef CONFIG_ENCODERS
348 static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width)
355 for(j = 0; j < width; j++) {
356 v = ((const uint32_t *)src)[j];
366 #ifdef CONFIG_DECODERS
367 static void convert_to_rgba32(uint8_t *dst, const uint8_t *src, int width)
370 unsigned int r, g, b, a;
372 for(j = 0;j < width; j++) {
377 *(uint32_t *)dst = (a << 24) | (r << 16) | (g << 8) | b;
383 /* process exactly one decompressed row */
384 static void png_handle_row(PNGContext *s)
386 uint8_t *ptr, *last_row;
389 if (!s->interlace_type) {
390 ptr = s->image_buf + s->image_linesize * s->y;
391 /* need to swap bytes correctly for RGB_ALPHA */
392 if (s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
393 png_filter_row(s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
394 s->last_row, s->row_size, s->bpp);
395 memcpy(s->last_row, s->tmp_row, s->row_size);
396 convert_to_rgba32(ptr, s->tmp_row, s->width);
398 /* in normal case, we avoid one copy */
400 last_row = s->last_row;
402 last_row = ptr - s->image_linesize;
404 png_filter_row(ptr, s->crow_buf[0], s->crow_buf + 1,
405 last_row, s->row_size, s->bpp);
408 if (s->y == s->height) {
409 s->state |= PNG_ALLIMAGE;
414 ptr = s->image_buf + s->image_linesize * s->y;
415 if ((png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) {
416 /* if we already read one row, it is time to stop to
417 wait for the next one */
420 png_filter_row(s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
421 s->last_row, s->pass_row_size, s->bpp);
422 memcpy(s->last_row, s->tmp_row, s->pass_row_size);
425 if ((png_pass_dsp_ymask[s->pass] << (s->y & 7)) & 0x80) {
426 /* NOTE: rgba32 is handled directly in png_put_interlaced_row */
427 png_put_interlaced_row(ptr, s->width, s->bits_per_pixel, s->pass,
428 s->color_type, s->last_row);
431 if (s->y == s->height) {
433 if (s->pass == NB_PASSES - 1) {
434 s->state |= PNG_ALLIMAGE;
439 s->pass_row_size = png_pass_row_size(s->pass,
442 s->crow_size = s->pass_row_size + 1;
443 if (s->pass_row_size != 0)
445 /* skip pass if empty row */
454 static int png_decode_idat(PNGContext *s, int length)
457 s->zstream.avail_in = length;
458 s->zstream.next_in = s->bytestream;
459 s->bytestream += length;
461 if(s->bytestream > s->bytestream_end)
464 /* decode one line if possible */
465 while (s->zstream.avail_in > 0) {
466 ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);
467 if (ret != Z_OK && ret != Z_STREAM_END) {
470 if (s->zstream.avail_out == 0) {
471 if (!(s->state & PNG_ALLIMAGE)) {
474 s->zstream.avail_out = s->crow_size;
475 s->zstream.next_out = s->crow_buf;
481 static int decode_frame(AVCodecContext *avctx,
482 void *data, int *data_size,
483 uint8_t *buf, int buf_size)
485 PNGContext * const s = avctx->priv_data;
486 AVFrame *picture = data;
487 AVFrame * const p= (AVFrame*)&s->picture;
488 uint32_t tag, length;
493 s->bytestream_end= buf + buf_size;
495 /* check signature */
496 if (memcmp(s->bytestream, pngsig, 8) != 0)
501 // memset(s, 0, sizeof(PNGContext));
503 s->zstream.zalloc = png_zalloc;
504 s->zstream.zfree = png_zfree;
505 s->zstream.opaque = NULL;
506 ret = inflateInit(&s->zstream);
511 if (s->bytestream >= s->bytestream_end)
513 length = get32(&s->bytestream);
514 if (length > 0x7fffffff)
516 tag32 = get32(&s->bytestream);
517 tag = bswap_32(tag32);
519 av_log(avctx, AV_LOG_DEBUG, "png: tag=%c%c%c%c length=%u\n",
522 ((tag >> 16) & 0xff),
523 ((tag >> 24) & 0xff), length);
526 case MKTAG('I', 'H', 'D', 'R'):
529 s->width = get32(&s->bytestream);
530 s->height = get32(&s->bytestream);
531 if(avcodec_check_dimensions(avctx, s->width, s->height)){
532 s->width= s->height= 0;
535 s->bit_depth = *s->bytestream++;
536 s->color_type = *s->bytestream++;
537 s->compression_type = *s->bytestream++;
538 s->filter_type = *s->bytestream++;
539 s->interlace_type = *s->bytestream++;
540 crc = get32(&s->bytestream);
541 s->state |= PNG_IHDR;
543 av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d compression_type=%d filter_type=%d interlace_type=%d\n",
544 s->width, s->height, s->bit_depth, s->color_type,
545 s->compression_type, s->filter_type, s->interlace_type);
548 case MKTAG('I', 'D', 'A', 'T'):
549 if (!(s->state & PNG_IHDR))
551 if (!(s->state & PNG_IDAT)) {
552 /* init image info */
553 avctx->width = s->width;
554 avctx->height = s->height;
556 s->channels = png_get_nb_channels(s->color_type);
557 s->bits_per_pixel = s->bit_depth * s->channels;
558 s->bpp = (s->bits_per_pixel + 7) >> 3;
559 s->row_size = (avctx->width * s->bits_per_pixel + 7) >> 3;
561 if (s->bit_depth == 8 &&
562 s->color_type == PNG_COLOR_TYPE_RGB) {
563 avctx->pix_fmt = PIX_FMT_RGB24;
564 } else if (s->bit_depth == 8 &&
565 s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
566 avctx->pix_fmt = PIX_FMT_RGBA32;
567 } else if (s->bit_depth == 8 &&
568 s->color_type == PNG_COLOR_TYPE_GRAY) {
569 avctx->pix_fmt = PIX_FMT_GRAY8;
570 } else if (s->bit_depth == 16 &&
571 s->color_type == PNG_COLOR_TYPE_GRAY) {
572 avctx->pix_fmt = PIX_FMT_GRAY16BE;
573 } else if (s->bit_depth == 1 &&
574 s->color_type == PNG_COLOR_TYPE_GRAY) {
575 avctx->pix_fmt = PIX_FMT_MONOBLACK;
576 } else if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
577 avctx->pix_fmt = PIX_FMT_PAL8;
582 avctx->release_buffer(avctx, p);
585 if(avctx->get_buffer(avctx, p) < 0){
586 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
589 p->pict_type= FF_I_TYPE;
591 p->interlaced_frame = !!s->interlace_type;
593 /* compute the compressed row size */
594 if (!s->interlace_type) {
595 s->crow_size = s->row_size + 1;
598 s->pass_row_size = png_pass_row_size(s->pass,
601 s->crow_size = s->pass_row_size + 1;
604 av_log(avctx, AV_LOG_DEBUG, "row_size=%d crow_size =%d\n",
605 s->row_size, s->crow_size);
607 s->image_buf = p->data[0];
608 s->image_linesize = p->linesize[0];
609 /* copy the palette if needed */
610 if (s->color_type == PNG_COLOR_TYPE_PALETTE)
611 memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t));
612 /* empty row is used if differencing to the first row */
613 s->last_row = av_mallocz(s->row_size);
616 if (s->interlace_type ||
617 s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
618 s->tmp_row = av_malloc(s->row_size);
623 s->crow_buf = av_malloc(s->row_size + 1);
626 s->zstream.avail_out = s->crow_size;
627 s->zstream.next_out = s->crow_buf;
629 s->state |= PNG_IDAT;
630 if (png_decode_idat(s, length) < 0)
633 crc = get32(&s->bytestream);
635 case MKTAG('P', 'L', 'T', 'E'):
639 if ((length % 3) != 0 || length > 256 * 3)
641 /* read the palette */
644 r = *s->bytestream++;
645 g = *s->bytestream++;
646 b = *s->bytestream++;
647 s->palette[i] = (0xff << 24) | (r << 16) | (g << 8) | b;
650 s->palette[i] = (0xff << 24);
652 s->state |= PNG_PLTE;
653 crc = get32(&s->bytestream);
656 case MKTAG('t', 'R', 'N', 'S'):
660 /* read the transparency. XXX: Only palette mode supported */
661 if (s->color_type != PNG_COLOR_TYPE_PALETTE ||
663 !(s->state & PNG_PLTE))
665 for(i=0;i<length;i++) {
666 v = *s->bytestream++;
667 s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);
669 crc = get32(&s->bytestream);
672 case MKTAG('I', 'E', 'N', 'D'):
673 if (!(s->state & PNG_ALLIMAGE))
675 crc = get32(&s->bytestream);
680 s->bytestream += length + 4;
685 *picture= *(AVFrame*)&s->picture;
686 *data_size = sizeof(AVPicture);
688 ret = s->bytestream - s->bytestream_start;
690 inflateEnd(&s->zstream);
691 av_freep(&s->crow_buf);
692 av_freep(&s->last_row);
693 av_freep(&s->tmp_row);
701 #ifdef CONFIG_ENCODERS
702 static void png_write_chunk(uint8_t **f, uint32_t tag,
703 const uint8_t *buf, int length)
709 crc = crc32(0, Z_NULL, 0);
711 tagbuf[1] = tag >> 8;
712 tagbuf[2] = tag >> 16;
713 tagbuf[3] = tag >> 24;
714 crc = crc32(crc, tagbuf, 4);
715 put32(f, bswap_32(tag));
717 crc = crc32(crc, buf, length);
718 memcpy(*f, buf, length);
724 /* XXX: use avcodec generic function ? */
725 static void to_be32(uint8_t *p, uint32_t v)
733 /* XXX: do filtering */
734 static int png_write_row(PNGContext *s, const uint8_t *data, int size)
738 s->zstream.avail_in = size;
739 s->zstream.next_in = (uint8_t *)data;
740 while (s->zstream.avail_in > 0) {
741 ret = deflate(&s->zstream, Z_NO_FLUSH);
744 if (s->zstream.avail_out == 0) {
745 if(s->bytestream_end - s->bytestream > IOBUF_SIZE + 100)
746 png_write_chunk(&s->bytestream, MKTAG('I', 'D', 'A', 'T'), s->buf, IOBUF_SIZE);
747 s->zstream.avail_out = IOBUF_SIZE;
748 s->zstream.next_out = s->buf;
753 #endif /* CONFIG_ENCODERS */
755 static int common_init(AVCodecContext *avctx){
756 PNGContext *s = avctx->priv_data;
758 avcodec_get_frame_defaults((AVFrame*)&s->picture);
759 avctx->coded_frame= (AVFrame*)&s->picture;
765 #ifdef CONFIG_ENCODERS
766 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
767 PNGContext *s = avctx->priv_data;
768 AVFrame *pict = data;
769 AVFrame * const p= (AVFrame*)&s->picture;
770 int bit_depth, color_type, y, len, row_size, ret, is_progressive;
771 int bits_per_pixel, pass_row_size;
773 uint8_t *crow_buf = NULL;
774 uint8_t *tmp_buf = NULL;
777 p->pict_type= FF_I_TYPE;
782 s->bytestream_end= buf+buf_size;
784 is_progressive = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
785 switch(avctx->pix_fmt) {
788 color_type = PNG_COLOR_TYPE_RGB_ALPHA;
792 color_type = PNG_COLOR_TYPE_RGB;
796 color_type = PNG_COLOR_TYPE_GRAY;
798 case PIX_FMT_MONOBLACK:
800 color_type = PNG_COLOR_TYPE_GRAY;
804 color_type = PNG_COLOR_TYPE_PALETTE;
809 bits_per_pixel = png_get_nb_channels(color_type) * bit_depth;
810 row_size = (avctx->width * bits_per_pixel + 7) >> 3;
812 s->zstream.zalloc = png_zalloc;
813 s->zstream.zfree = png_zfree;
814 s->zstream.opaque = NULL;
815 ret = deflateInit2(&s->zstream, Z_DEFAULT_COMPRESSION,
816 Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY);
819 crow_buf = av_malloc(row_size + 1);
822 if (is_progressive) {
823 tmp_buf = av_malloc(row_size + 1);
828 /* write png header */
829 memcpy(s->bytestream, pngsig, 8);
832 to_be32(s->buf, avctx->width);
833 to_be32(s->buf + 4, avctx->height);
834 s->buf[8] = bit_depth;
835 s->buf[9] = color_type;
836 s->buf[10] = 0; /* compression type */
837 s->buf[11] = 0; /* filter type */
838 s->buf[12] = is_progressive; /* interlace type */
840 png_write_chunk(&s->bytestream, MKTAG('I', 'H', 'D', 'R'), s->buf, 13);
842 /* put the palette if needed */
843 if (color_type == PNG_COLOR_TYPE_PALETTE) {
844 int has_alpha, alpha, i;
849 palette = (uint32_t *)p->data[1];
851 alpha_ptr = s->buf + 256 * 3;
853 for(i = 0; i < 256; i++) {
856 if (alpha && alpha != 0xff)
858 *alpha_ptr++ = alpha;
864 png_write_chunk(&s->bytestream, MKTAG('P', 'L', 'T', 'E'), s->buf, 256 * 3);
866 png_write_chunk(&s->bytestream, MKTAG('t', 'R', 'N', 'S'), s->buf + 256 * 3, 256);
870 /* now put each row */
871 s->zstream.avail_out = IOBUF_SIZE;
872 s->zstream.next_out = s->buf;
873 if (is_progressive) {
877 for(pass = 0; pass < NB_PASSES; pass++) {
878 /* NOTE: a pass is completely omited if no pixels would be
880 pass_row_size = png_pass_row_size(pass, bits_per_pixel, avctx->width);
881 if (pass_row_size > 0) {
882 for(y = 0; y < avctx->height; y++) {
883 if ((png_pass_ymask[pass] << (y & 7)) & 0x80) {
884 ptr = p->data[0] + y * p->linesize[0];
885 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
886 convert_from_rgba32(tmp_buf, ptr, avctx->width);
891 png_get_interlaced_row(crow_buf + 1, pass_row_size,
892 bits_per_pixel, pass,
894 crow_buf[0] = PNG_FILTER_VALUE_NONE;
895 png_write_row(s, crow_buf, pass_row_size + 1);
901 for(y = 0; y < avctx->height; y++) {
902 ptr = p->data[0] + y * p->linesize[0];
903 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
904 convert_from_rgba32(crow_buf + 1, ptr, avctx->width);
906 memcpy(crow_buf + 1, ptr, row_size);
907 crow_buf[0] = PNG_FILTER_VALUE_NONE;
908 png_write_row(s, crow_buf, row_size + 1);
911 /* compress last bytes */
913 ret = deflate(&s->zstream, Z_FINISH);
914 if (ret == Z_OK || ret == Z_STREAM_END) {
915 len = IOBUF_SIZE - s->zstream.avail_out;
916 if (len > 0 && s->bytestream_end - s->bytestream > len + 100) {
917 png_write_chunk(&s->bytestream, MKTAG('I', 'D', 'A', 'T'), s->buf, len);
919 s->zstream.avail_out = IOBUF_SIZE;
920 s->zstream.next_out = s->buf;
921 if (ret == Z_STREAM_END)
927 png_write_chunk(&s->bytestream, MKTAG('I', 'E', 'N', 'D'), NULL, 0);
929 ret = s->bytestream - s->bytestream_start;
933 deflateEnd(&s->zstream);
941 #ifdef CONFIG_PNG_DECODER
942 AVCodec png_decoder = {
951 0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
956 #ifdef CONFIG_PNG_ENCODER
957 AVCodec png_encoder = {
965 .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA32, PIX_FMT_PAL8, PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, -1},
967 #endif // CONFIG_PNG_ENCODER