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
22 #include "bytestream.h"
25 * - add 2, 4 and 16 bit depth support
26 * - 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 const uint8_t pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
92 /* Mask to determine which y pixels are valid in a pass */
93 static const uint8_t png_pass_ymask[NB_PASSES] = {
94 0x80, 0x80, 0x08, 0x88, 0x22, 0xaa, 0x55,
97 /* Mask to determine which y pixels can be written in a pass */
98 static const uint8_t png_pass_dsp_ymask[NB_PASSES] = {
99 0xff, 0xff, 0x0f, 0xcc, 0x33, 0xff, 0x55,
102 /* minimum x value */
103 static const uint8_t png_pass_xmin[NB_PASSES] = {
107 /* x shift to get row width */
108 static const uint8_t png_pass_xshift[NB_PASSES] = {
112 /* Mask to determine which pixels are valid in a pass */
113 static const uint8_t png_pass_mask[NB_PASSES] = {
114 0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff
117 /* Mask to determine which pixels to overwrite while displaying */
118 static const uint8_t png_pass_dsp_mask[NB_PASSES] = {
119 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
122 static int png_probe(AVProbeData *pd)
124 if (pd->buf_size >= 8 &&
125 memcmp(pd->buf, pngsig, 8) == 0)
126 return AVPROBE_SCORE_MAX;
131 static void *png_zalloc(void *opaque, unsigned int items, unsigned int size)
133 if(items >= UINT_MAX / size)
135 return av_malloc(items * size);
138 static void png_zfree(void *opaque, void *ptr)
143 static int png_get_nb_channels(int color_type)
147 if ((color_type & (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)) ==
148 PNG_COLOR_MASK_COLOR)
150 if (color_type & PNG_COLOR_MASK_ALPHA)
155 /* compute the row size of an interleaved pass */
156 static int png_pass_row_size(int pass, int bits_per_pixel, int width)
158 int shift, xmin, pass_width;
160 xmin = png_pass_xmin[pass];
163 shift = png_pass_xshift[pass];
164 pass_width = (width - xmin + (1 << shift) - 1) >> shift;
165 return (pass_width * bits_per_pixel + 7) >> 3;
168 /* NOTE: we try to construct a good looking image at each pass. width
169 is the original image width. We also do pixel format convertion at
171 static void png_put_interlaced_row(uint8_t *dst, int width,
172 int bits_per_pixel, int pass,
173 int color_type, const uint8_t *src)
175 int x, mask, dsp_mask, j, src_x, b, bpp;
179 mask = png_pass_mask[pass];
180 dsp_mask = png_pass_dsp_mask[pass];
181 switch(bits_per_pixel) {
183 /* we must initialize the line to zero before writing to it */
185 memset(dst, 0, (width + 7) >> 3);
187 for(x = 0; x < width; x++) {
189 if ((dsp_mask << j) & 0x80) {
190 b = (src[src_x >> 3] >> (7 - (src_x & 7))) & 1;
191 dst[x >> 3] |= b << (7 - j);
193 if ((mask << j) & 0x80)
198 bpp = bits_per_pixel >> 3;
201 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
202 for(x = 0; x < width; x++) {
204 if ((dsp_mask << j) & 0x80) {
205 *(uint32_t *)d = (s[3] << 24) | (s[0] << 16) | (s[1] << 8) | s[2];
208 if ((mask << j) & 0x80)
212 for(x = 0; x < width; x++) {
214 if ((dsp_mask << j) & 0x80) {
218 if ((mask << j) & 0x80)
226 #ifdef CONFIG_ENCODERS
227 static void png_get_interlaced_row(uint8_t *dst, int row_size,
228 int bits_per_pixel, int pass,
229 const uint8_t *src, int width)
231 int x, mask, dst_x, j, b, bpp;
235 mask = png_pass_mask[pass];
236 switch(bits_per_pixel) {
238 memset(dst, 0, row_size);
240 for(x = 0; x < width; x++) {
242 if ((mask << j) & 0x80) {
243 b = (src[x >> 3] >> (7 - j)) & 1;
244 dst[dst_x >> 3] |= b << (7 - (dst_x & 7));
250 bpp = bits_per_pixel >> 3;
253 for(x = 0; x < width; x++) {
255 if ((mask << j) & 0x80) {
267 /* NOTE: 'dst' can be equal to 'last' */
268 static void png_filter_row(uint8_t *dst, int filter_type,
269 uint8_t *src, uint8_t *last, int size, int bpp)
273 switch(filter_type) {
274 case PNG_FILTER_VALUE_NONE:
275 memcpy(dst, src, size);
277 case PNG_FILTER_VALUE_SUB:
278 for(i = 0; i < bpp; i++) {
281 for(i = bpp; i < size; i++) {
286 case PNG_FILTER_VALUE_UP:
287 for(i = 0; i < size; i++) {
292 case PNG_FILTER_VALUE_AVG:
293 for(i = 0; i < bpp; i++) {
297 for(i = bpp; i < size; i++) {
298 p = ((dst[i - bpp] + last[i]) >> 1);
302 case PNG_FILTER_VALUE_PAETH:
303 for(i = 0; i < bpp; i++) {
307 for(i = bpp; i < size; i++) {
308 int a, b, c, pa, pb, pc;
321 if (pa <= pb && pa <= pc)
333 #ifdef CONFIG_ENCODERS
334 static void convert_from_rgb32(uint8_t *dst, const uint8_t *src, int width)
341 for(j = 0; j < width; j++) {
342 v = ((const uint32_t *)src)[j];
352 #ifdef CONFIG_DECODERS
353 static void convert_to_rgb32(uint8_t *dst, const uint8_t *src, int width)
356 unsigned int r, g, b, a;
358 for(j = 0;j < width; j++) {
363 *(uint32_t *)dst = (a << 24) | (r << 16) | (g << 8) | b;
369 /* process exactly one decompressed row */
370 static void png_handle_row(PNGContext *s)
372 uint8_t *ptr, *last_row;
375 if (!s->interlace_type) {
376 ptr = s->image_buf + s->image_linesize * s->y;
377 /* need to swap bytes correctly for RGB_ALPHA */
378 if (s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
379 png_filter_row(s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
380 s->last_row, s->row_size, s->bpp);
381 memcpy(s->last_row, s->tmp_row, s->row_size);
382 convert_to_rgb32(ptr, s->tmp_row, s->width);
384 /* in normal case, we avoid one copy */
386 last_row = s->last_row;
388 last_row = ptr - s->image_linesize;
390 png_filter_row(ptr, s->crow_buf[0], s->crow_buf + 1,
391 last_row, s->row_size, s->bpp);
394 if (s->y == s->height) {
395 s->state |= PNG_ALLIMAGE;
400 ptr = s->image_buf + s->image_linesize * s->y;
401 if ((png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) {
402 /* if we already read one row, it is time to stop to
403 wait for the next one */
406 png_filter_row(s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
407 s->last_row, s->pass_row_size, s->bpp);
408 memcpy(s->last_row, s->tmp_row, s->pass_row_size);
411 if ((png_pass_dsp_ymask[s->pass] << (s->y & 7)) & 0x80) {
412 /* NOTE: RGB32 is handled directly in png_put_interlaced_row */
413 png_put_interlaced_row(ptr, s->width, s->bits_per_pixel, s->pass,
414 s->color_type, s->last_row);
417 if (s->y == s->height) {
419 if (s->pass == NB_PASSES - 1) {
420 s->state |= PNG_ALLIMAGE;
425 s->pass_row_size = png_pass_row_size(s->pass,
428 s->crow_size = s->pass_row_size + 1;
429 if (s->pass_row_size != 0)
431 /* skip pass if empty row */
440 static int png_decode_idat(PNGContext *s, int length)
443 s->zstream.avail_in = length;
444 s->zstream.next_in = s->bytestream;
445 s->bytestream += length;
447 if(s->bytestream > s->bytestream_end)
450 /* decode one line if possible */
451 while (s->zstream.avail_in > 0) {
452 ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);
453 if (ret != Z_OK && ret != Z_STREAM_END) {
456 if (s->zstream.avail_out == 0) {
457 if (!(s->state & PNG_ALLIMAGE)) {
460 s->zstream.avail_out = s->crow_size;
461 s->zstream.next_out = s->crow_buf;
467 static int decode_frame(AVCodecContext *avctx,
468 void *data, int *data_size,
469 uint8_t *buf, int buf_size)
471 PNGContext * const s = avctx->priv_data;
472 AVFrame *picture = data;
473 AVFrame * const p= (AVFrame*)&s->picture;
474 uint32_t tag, length;
479 s->bytestream_end= buf + buf_size;
481 /* check signature */
482 if (memcmp(s->bytestream, pngsig, 8) != 0)
487 // memset(s, 0, sizeof(PNGContext));
489 s->zstream.zalloc = png_zalloc;
490 s->zstream.zfree = png_zfree;
491 s->zstream.opaque = NULL;
492 ret = inflateInit(&s->zstream);
497 if (s->bytestream >= s->bytestream_end)
499 length = bytestream_get_be32(&s->bytestream);
500 if (length > 0x7fffffff)
502 tag32 = bytestream_get_be32(&s->bytestream);
503 tag = bswap_32(tag32);
505 av_log(avctx, AV_LOG_DEBUG, "png: tag=%c%c%c%c length=%u\n",
508 ((tag >> 16) & 0xff),
509 ((tag >> 24) & 0xff), length);
512 case MKTAG('I', 'H', 'D', 'R'):
515 s->width = bytestream_get_be32(&s->bytestream);
516 s->height = bytestream_get_be32(&s->bytestream);
517 if(avcodec_check_dimensions(avctx, s->width, s->height)){
518 s->width= s->height= 0;
521 s->bit_depth = *s->bytestream++;
522 s->color_type = *s->bytestream++;
523 s->compression_type = *s->bytestream++;
524 s->filter_type = *s->bytestream++;
525 s->interlace_type = *s->bytestream++;
526 crc = bytestream_get_be32(&s->bytestream);
527 s->state |= PNG_IHDR;
529 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",
530 s->width, s->height, s->bit_depth, s->color_type,
531 s->compression_type, s->filter_type, s->interlace_type);
534 case MKTAG('I', 'D', 'A', 'T'):
535 if (!(s->state & PNG_IHDR))
537 if (!(s->state & PNG_IDAT)) {
538 /* init image info */
539 avctx->width = s->width;
540 avctx->height = s->height;
542 s->channels = png_get_nb_channels(s->color_type);
543 s->bits_per_pixel = s->bit_depth * s->channels;
544 s->bpp = (s->bits_per_pixel + 7) >> 3;
545 s->row_size = (avctx->width * s->bits_per_pixel + 7) >> 3;
547 if (s->bit_depth == 8 &&
548 s->color_type == PNG_COLOR_TYPE_RGB) {
549 avctx->pix_fmt = PIX_FMT_RGB24;
550 } else if (s->bit_depth == 8 &&
551 s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
552 avctx->pix_fmt = PIX_FMT_RGB32;
553 } else if (s->bit_depth == 8 &&
554 s->color_type == PNG_COLOR_TYPE_GRAY) {
555 avctx->pix_fmt = PIX_FMT_GRAY8;
556 } else if (s->bit_depth == 16 &&
557 s->color_type == PNG_COLOR_TYPE_GRAY) {
558 avctx->pix_fmt = PIX_FMT_GRAY16BE;
559 } else if (s->bit_depth == 1 &&
560 s->color_type == PNG_COLOR_TYPE_GRAY) {
561 avctx->pix_fmt = PIX_FMT_MONOBLACK;
562 } else if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
563 avctx->pix_fmt = PIX_FMT_PAL8;
568 avctx->release_buffer(avctx, p);
571 if(avctx->get_buffer(avctx, p) < 0){
572 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
575 p->pict_type= FF_I_TYPE;
577 p->interlaced_frame = !!s->interlace_type;
579 /* compute the compressed row size */
580 if (!s->interlace_type) {
581 s->crow_size = s->row_size + 1;
584 s->pass_row_size = png_pass_row_size(s->pass,
587 s->crow_size = s->pass_row_size + 1;
590 av_log(avctx, AV_LOG_DEBUG, "row_size=%d crow_size =%d\n",
591 s->row_size, s->crow_size);
593 s->image_buf = p->data[0];
594 s->image_linesize = p->linesize[0];
595 /* copy the palette if needed */
596 if (s->color_type == PNG_COLOR_TYPE_PALETTE)
597 memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t));
598 /* empty row is used if differencing to the first row */
599 s->last_row = av_mallocz(s->row_size);
602 if (s->interlace_type ||
603 s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
604 s->tmp_row = av_malloc(s->row_size);
609 s->crow_buf = av_malloc(s->row_size + 1);
612 s->zstream.avail_out = s->crow_size;
613 s->zstream.next_out = s->crow_buf;
615 s->state |= PNG_IDAT;
616 if (png_decode_idat(s, length) < 0)
619 crc = bytestream_get_be32(&s->bytestream);
621 case MKTAG('P', 'L', 'T', 'E'):
625 if ((length % 3) != 0 || length > 256 * 3)
627 /* read the palette */
630 r = *s->bytestream++;
631 g = *s->bytestream++;
632 b = *s->bytestream++;
633 s->palette[i] = (0xff << 24) | (r << 16) | (g << 8) | b;
636 s->palette[i] = (0xff << 24);
638 s->state |= PNG_PLTE;
639 crc = bytestream_get_be32(&s->bytestream);
642 case MKTAG('t', 'R', 'N', 'S'):
646 /* read the transparency. XXX: Only palette mode supported */
647 if (s->color_type != PNG_COLOR_TYPE_PALETTE ||
649 !(s->state & PNG_PLTE))
651 for(i=0;i<length;i++) {
652 v = *s->bytestream++;
653 s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);
655 crc = bytestream_get_be32(&s->bytestream);
658 case MKTAG('I', 'E', 'N', 'D'):
659 if (!(s->state & PNG_ALLIMAGE))
661 crc = bytestream_get_be32(&s->bytestream);
666 s->bytestream += length + 4;
671 *picture= *(AVFrame*)&s->picture;
672 *data_size = sizeof(AVPicture);
674 ret = s->bytestream - s->bytestream_start;
676 inflateEnd(&s->zstream);
677 av_freep(&s->crow_buf);
678 av_freep(&s->last_row);
679 av_freep(&s->tmp_row);
687 #ifdef CONFIG_ENCODERS
688 static void png_write_chunk(uint8_t **f, uint32_t tag,
689 const uint8_t *buf, int length)
694 bytestream_put_be32(f, length);
695 crc = crc32(0, Z_NULL, 0);
696 AV_WL32(tagbuf, tag);
697 crc = crc32(crc, tagbuf, 4);
698 bytestream_put_be32(f, bswap_32(tag));
700 crc = crc32(crc, buf, length);
701 memcpy(*f, buf, length);
704 bytestream_put_be32(f, crc);
707 /* XXX: do filtering */
708 static int png_write_row(PNGContext *s, const uint8_t *data, int size)
712 s->zstream.avail_in = size;
713 s->zstream.next_in = (uint8_t *)data;
714 while (s->zstream.avail_in > 0) {
715 ret = deflate(&s->zstream, Z_NO_FLUSH);
718 if (s->zstream.avail_out == 0) {
719 if(s->bytestream_end - s->bytestream > IOBUF_SIZE + 100)
720 png_write_chunk(&s->bytestream, MKTAG('I', 'D', 'A', 'T'), s->buf, IOBUF_SIZE);
721 s->zstream.avail_out = IOBUF_SIZE;
722 s->zstream.next_out = s->buf;
727 #endif /* CONFIG_ENCODERS */
729 static int common_init(AVCodecContext *avctx){
730 PNGContext *s = avctx->priv_data;
732 avcodec_get_frame_defaults((AVFrame*)&s->picture);
733 avctx->coded_frame= (AVFrame*)&s->picture;
739 #ifdef CONFIG_ENCODERS
740 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
741 PNGContext *s = avctx->priv_data;
742 AVFrame *pict = data;
743 AVFrame * const p= (AVFrame*)&s->picture;
744 int bit_depth, color_type, y, len, row_size, ret, is_progressive;
745 int bits_per_pixel, pass_row_size;
747 uint8_t *crow_buf = NULL;
748 uint8_t *tmp_buf = NULL;
751 p->pict_type= FF_I_TYPE;
756 s->bytestream_end= buf+buf_size;
758 is_progressive = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
759 switch(avctx->pix_fmt) {
762 color_type = PNG_COLOR_TYPE_RGB_ALPHA;
766 color_type = PNG_COLOR_TYPE_RGB;
770 color_type = PNG_COLOR_TYPE_GRAY;
772 case PIX_FMT_MONOBLACK:
774 color_type = PNG_COLOR_TYPE_GRAY;
778 color_type = PNG_COLOR_TYPE_PALETTE;
783 bits_per_pixel = png_get_nb_channels(color_type) * bit_depth;
784 row_size = (avctx->width * bits_per_pixel + 7) >> 3;
786 s->zstream.zalloc = png_zalloc;
787 s->zstream.zfree = png_zfree;
788 s->zstream.opaque = NULL;
789 ret = deflateInit2(&s->zstream, Z_DEFAULT_COMPRESSION,
790 Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY);
793 crow_buf = av_malloc(row_size + 1);
796 if (is_progressive) {
797 tmp_buf = av_malloc(row_size + 1);
802 /* write png header */
803 memcpy(s->bytestream, pngsig, 8);
806 AV_WB32(s->buf, avctx->width);
807 AV_WB32(s->buf + 4, avctx->height);
808 s->buf[8] = bit_depth;
809 s->buf[9] = color_type;
810 s->buf[10] = 0; /* compression type */
811 s->buf[11] = 0; /* filter type */
812 s->buf[12] = is_progressive; /* interlace type */
814 png_write_chunk(&s->bytestream, MKTAG('I', 'H', 'D', 'R'), s->buf, 13);
816 /* put the palette if needed */
817 if (color_type == PNG_COLOR_TYPE_PALETTE) {
818 int has_alpha, alpha, i;
823 palette = (uint32_t *)p->data[1];
825 alpha_ptr = s->buf + 256 * 3;
827 for(i = 0; i < 256; i++) {
830 if (alpha && alpha != 0xff)
832 *alpha_ptr++ = alpha;
833 bytestream_put_be24(&ptr, v);
835 png_write_chunk(&s->bytestream, MKTAG('P', 'L', 'T', 'E'), s->buf, 256 * 3);
837 png_write_chunk(&s->bytestream, MKTAG('t', 'R', 'N', 'S'), s->buf + 256 * 3, 256);
841 /* now put each row */
842 s->zstream.avail_out = IOBUF_SIZE;
843 s->zstream.next_out = s->buf;
844 if (is_progressive) {
848 for(pass = 0; pass < NB_PASSES; pass++) {
849 /* NOTE: a pass is completely omited if no pixels would be
851 pass_row_size = png_pass_row_size(pass, bits_per_pixel, avctx->width);
852 if (pass_row_size > 0) {
853 for(y = 0; y < avctx->height; y++) {
854 if ((png_pass_ymask[pass] << (y & 7)) & 0x80) {
855 ptr = p->data[0] + y * p->linesize[0];
856 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
857 convert_from_rgb32(tmp_buf, ptr, avctx->width);
862 png_get_interlaced_row(crow_buf + 1, pass_row_size,
863 bits_per_pixel, pass,
865 crow_buf[0] = PNG_FILTER_VALUE_NONE;
866 png_write_row(s, crow_buf, pass_row_size + 1);
872 for(y = 0; y < avctx->height; y++) {
873 ptr = p->data[0] + y * p->linesize[0];
874 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
875 convert_from_rgb32(crow_buf + 1, ptr, avctx->width);
877 memcpy(crow_buf + 1, ptr, row_size);
878 crow_buf[0] = PNG_FILTER_VALUE_NONE;
879 png_write_row(s, crow_buf, row_size + 1);
882 /* compress last bytes */
884 ret = deflate(&s->zstream, Z_FINISH);
885 if (ret == Z_OK || ret == Z_STREAM_END) {
886 len = IOBUF_SIZE - s->zstream.avail_out;
887 if (len > 0 && s->bytestream_end - s->bytestream > len + 100) {
888 png_write_chunk(&s->bytestream, MKTAG('I', 'D', 'A', 'T'), s->buf, len);
890 s->zstream.avail_out = IOBUF_SIZE;
891 s->zstream.next_out = s->buf;
892 if (ret == Z_STREAM_END)
898 png_write_chunk(&s->bytestream, MKTAG('I', 'E', 'N', 'D'), NULL, 0);
900 ret = s->bytestream - s->bytestream_start;
904 deflateEnd(&s->zstream);
912 #ifdef CONFIG_PNG_DECODER
913 AVCodec png_decoder = {
922 0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
927 #ifdef CONFIG_PNG_ENCODER
928 AVCodec png_encoder = {
936 .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_PAL8, PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, -1},
938 #endif // CONFIG_PNG_ENCODER