You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

649 lines
21KB

  1. /*
  2. * PNG image format
  3. * Copyright (c) 2003 Fabrice Bellard
  4. *
  5. * This file is part of FFmpeg.
  6. *
  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.
  11. *
  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.
  16. *
  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
  20. */
  21. #include "avcodec.h"
  22. #include "bytestream.h"
  23. #include "png.h"
  24. #include "dsputil.h"
  25. /* TODO:
  26. * - add 2, 4 and 16 bit depth support
  27. */
  28. #include <zlib.h>
  29. //#define DEBUG
  30. typedef struct PNGDecContext {
  31. DSPContext dsp;
  32. const uint8_t *bytestream;
  33. const uint8_t *bytestream_start;
  34. const uint8_t *bytestream_end;
  35. AVFrame picture1, picture2;
  36. AVFrame *current_picture, *last_picture;
  37. int state;
  38. int width, height;
  39. int bit_depth;
  40. int color_type;
  41. int compression_type;
  42. int interlace_type;
  43. int filter_type;
  44. int channels;
  45. int bits_per_pixel;
  46. int bpp;
  47. uint8_t *image_buf;
  48. int image_linesize;
  49. uint32_t palette[256];
  50. uint8_t *crow_buf;
  51. uint8_t *last_row;
  52. uint8_t *tmp_row;
  53. int pass;
  54. int crow_size; /* compressed row size (include filter type) */
  55. int row_size; /* decompressed row size */
  56. int pass_row_size; /* decompress row size of the current pass */
  57. int y;
  58. z_stream zstream;
  59. } PNGDecContext;
  60. /* Mask to determine which y pixels can be written in a pass */
  61. static const uint8_t png_pass_dsp_ymask[NB_PASSES] = {
  62. 0xff, 0xff, 0x0f, 0xcc, 0x33, 0xff, 0x55,
  63. };
  64. /* Mask to determine which pixels to overwrite while displaying */
  65. static const uint8_t png_pass_dsp_mask[NB_PASSES] = {
  66. 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
  67. };
  68. /* NOTE: we try to construct a good looking image at each pass. width
  69. is the original image width. We also do pixel format conversion at
  70. this stage */
  71. static void png_put_interlaced_row(uint8_t *dst, int width,
  72. int bits_per_pixel, int pass,
  73. int color_type, const uint8_t *src)
  74. {
  75. int x, mask, dsp_mask, j, src_x, b, bpp;
  76. uint8_t *d;
  77. const uint8_t *s;
  78. mask = ff_png_pass_mask[pass];
  79. dsp_mask = png_pass_dsp_mask[pass];
  80. switch(bits_per_pixel) {
  81. case 1:
  82. /* we must initialize the line to zero before writing to it */
  83. if (pass == 0)
  84. memset(dst, 0, (width + 7) >> 3);
  85. src_x = 0;
  86. for(x = 0; x < width; x++) {
  87. j = (x & 7);
  88. if ((dsp_mask << j) & 0x80) {
  89. b = (src[src_x >> 3] >> (7 - (src_x & 7))) & 1;
  90. dst[x >> 3] |= b << (7 - j);
  91. }
  92. if ((mask << j) & 0x80)
  93. src_x++;
  94. }
  95. break;
  96. default:
  97. bpp = bits_per_pixel >> 3;
  98. d = dst;
  99. s = src;
  100. if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
  101. for(x = 0; x < width; x++) {
  102. j = x & 7;
  103. if ((dsp_mask << j) & 0x80) {
  104. *(uint32_t *)d = (s[3] << 24) | (s[0] << 16) | (s[1] << 8) | s[2];
  105. }
  106. d += bpp;
  107. if ((mask << j) & 0x80)
  108. s += bpp;
  109. }
  110. } else {
  111. for(x = 0; x < width; x++) {
  112. j = x & 7;
  113. if ((dsp_mask << j) & 0x80) {
  114. memcpy(d, s, bpp);
  115. }
  116. d += bpp;
  117. if ((mask << j) & 0x80)
  118. s += bpp;
  119. }
  120. }
  121. break;
  122. }
  123. }
  124. void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)
  125. {
  126. int i;
  127. for(i = 0; i < w; i++) {
  128. int a, b, c, p, pa, pb, pc;
  129. a = dst[i - bpp];
  130. b = top[i];
  131. c = top[i - bpp];
  132. p = b - c;
  133. pc = a - c;
  134. pa = abs(p);
  135. pb = abs(pc);
  136. pc = abs(p + pc);
  137. if (pa <= pb && pa <= pc)
  138. p = a;
  139. else if (pb <= pc)
  140. p = b;
  141. else
  142. p = c;
  143. dst[i] = p + src[i];
  144. }
  145. }
  146. #define UNROLL1(bpp, op) {\
  147. r = dst[0];\
  148. if(bpp >= 2) g = dst[1];\
  149. if(bpp >= 3) b = dst[2];\
  150. if(bpp >= 4) a = dst[3];\
  151. for(; i < size; i+=bpp) {\
  152. dst[i+0] = r = op(r, src[i+0], last[i+0]);\
  153. if(bpp == 1) continue;\
  154. dst[i+1] = g = op(g, src[i+1], last[i+1]);\
  155. if(bpp == 2) continue;\
  156. dst[i+2] = b = op(b, src[i+2], last[i+2]);\
  157. if(bpp == 3) continue;\
  158. dst[i+3] = a = op(a, src[i+3], last[i+3]);\
  159. }\
  160. }
  161. #define UNROLL_FILTER(op)\
  162. if(bpp == 1) UNROLL1(1, op)\
  163. else if(bpp == 2) UNROLL1(2, op)\
  164. else if(bpp == 3) UNROLL1(3, op)\
  165. else if(bpp == 4) UNROLL1(4, op)\
  166. /* NOTE: 'dst' can be equal to 'last' */
  167. static void png_filter_row(DSPContext *dsp, uint8_t *dst, int filter_type,
  168. uint8_t *src, uint8_t *last, int size, int bpp)
  169. {
  170. int i, p, r, g, b, a;
  171. switch(filter_type) {
  172. case PNG_FILTER_VALUE_NONE:
  173. memcpy(dst, src, size);
  174. break;
  175. case PNG_FILTER_VALUE_SUB:
  176. for(i = 0; i < bpp; i++) {
  177. dst[i] = src[i];
  178. }
  179. if(bpp == 4) {
  180. p = *(int*)dst;
  181. for(; i < size; i+=bpp) {
  182. int s = *(int*)(src+i);
  183. p = ((s&0x7f7f7f7f) + (p&0x7f7f7f7f)) ^ ((s^p)&0x80808080);
  184. *(int*)(dst+i) = p;
  185. }
  186. } else {
  187. #define OP_SUB(x,s,l) x+s
  188. UNROLL_FILTER(OP_SUB);
  189. }
  190. break;
  191. case PNG_FILTER_VALUE_UP:
  192. dsp->add_bytes_l2(dst, src, last, size);
  193. break;
  194. case PNG_FILTER_VALUE_AVG:
  195. for(i = 0; i < bpp; i++) {
  196. p = (last[i] >> 1);
  197. dst[i] = p + src[i];
  198. }
  199. #define OP_AVG(x,s,l) (((x + l) >> 1) + s) & 0xff
  200. UNROLL_FILTER(OP_AVG);
  201. break;
  202. case PNG_FILTER_VALUE_PAETH:
  203. for(i = 0; i < bpp; i++) {
  204. p = last[i];
  205. dst[i] = p + src[i];
  206. }
  207. if(bpp > 1 && size > 4) {
  208. // would write off the end of the array if we let it process the last pixel with bpp=3
  209. int w = bpp==4 ? size : size-3;
  210. dsp->add_png_paeth_prediction(dst+i, src+i, last+i, w-i, bpp);
  211. i = w;
  212. }
  213. ff_add_png_paeth_prediction(dst+i, src+i, last+i, size-i, bpp);
  214. break;
  215. }
  216. }
  217. static av_always_inline void convert_to_rgb32_loco(uint8_t *dst, const uint8_t *src, int width, int loco)
  218. {
  219. int j;
  220. unsigned int r, g, b, a;
  221. for(j = 0;j < width; j++) {
  222. r = src[0];
  223. g = src[1];
  224. b = src[2];
  225. a = src[3];
  226. if(loco) {
  227. r = (r+g)&0xff;
  228. b = (b+g)&0xff;
  229. }
  230. *(uint32_t *)dst = (a << 24) | (r << 16) | (g << 8) | b;
  231. dst += 4;
  232. src += 4;
  233. }
  234. }
  235. static void convert_to_rgb32(uint8_t *dst, const uint8_t *src, int width, int loco)
  236. {
  237. if(loco)
  238. convert_to_rgb32_loco(dst, src, width, 1);
  239. else
  240. convert_to_rgb32_loco(dst, src, width, 0);
  241. }
  242. static void deloco_rgb24(uint8_t *dst, int size)
  243. {
  244. int i;
  245. for(i=0; i<size; i+=3) {
  246. int g = dst[i+1];
  247. dst[i+0] += g;
  248. dst[i+2] += g;
  249. }
  250. }
  251. /* process exactly one decompressed row */
  252. static void png_handle_row(PNGDecContext *s)
  253. {
  254. uint8_t *ptr, *last_row;
  255. int got_line;
  256. if (!s->interlace_type) {
  257. ptr = s->image_buf + s->image_linesize * s->y;
  258. /* need to swap bytes correctly for RGB_ALPHA */
  259. if (s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
  260. png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
  261. s->last_row, s->row_size, s->bpp);
  262. convert_to_rgb32(ptr, s->tmp_row, s->width, s->filter_type == PNG_FILTER_TYPE_LOCO);
  263. FFSWAP(uint8_t*, s->last_row, s->tmp_row);
  264. } else {
  265. /* in normal case, we avoid one copy */
  266. if (s->y == 0)
  267. last_row = s->last_row;
  268. else
  269. last_row = ptr - s->image_linesize;
  270. png_filter_row(&s->dsp, ptr, s->crow_buf[0], s->crow_buf + 1,
  271. last_row, s->row_size, s->bpp);
  272. }
  273. /* loco lags by 1 row so that it doesn't interfere with top prediction */
  274. if (s->filter_type == PNG_FILTER_TYPE_LOCO &&
  275. s->color_type == PNG_COLOR_TYPE_RGB && s->y > 0)
  276. deloco_rgb24(ptr - s->image_linesize, s->row_size);
  277. s->y++;
  278. if (s->y == s->height) {
  279. s->state |= PNG_ALLIMAGE;
  280. if (s->filter_type == PNG_FILTER_TYPE_LOCO &&
  281. s->color_type == PNG_COLOR_TYPE_RGB)
  282. deloco_rgb24(ptr, s->row_size);
  283. }
  284. } else {
  285. got_line = 0;
  286. for(;;) {
  287. ptr = s->image_buf + s->image_linesize * s->y;
  288. if ((ff_png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) {
  289. /* if we already read one row, it is time to stop to
  290. wait for the next one */
  291. if (got_line)
  292. break;
  293. png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
  294. s->last_row, s->pass_row_size, s->bpp);
  295. FFSWAP(uint8_t*, s->last_row, s->tmp_row);
  296. got_line = 1;
  297. }
  298. if ((png_pass_dsp_ymask[s->pass] << (s->y & 7)) & 0x80) {
  299. /* NOTE: RGB32 is handled directly in png_put_interlaced_row */
  300. png_put_interlaced_row(ptr, s->width, s->bits_per_pixel, s->pass,
  301. s->color_type, s->last_row);
  302. }
  303. s->y++;
  304. if (s->y == s->height) {
  305. for(;;) {
  306. if (s->pass == NB_PASSES - 1) {
  307. s->state |= PNG_ALLIMAGE;
  308. goto the_end;
  309. } else {
  310. s->pass++;
  311. s->y = 0;
  312. s->pass_row_size = ff_png_pass_row_size(s->pass,
  313. s->bits_per_pixel,
  314. s->width);
  315. s->crow_size = s->pass_row_size + 1;
  316. if (s->pass_row_size != 0)
  317. break;
  318. /* skip pass if empty row */
  319. }
  320. }
  321. }
  322. }
  323. the_end: ;
  324. }
  325. }
  326. static int png_decode_idat(PNGDecContext *s, int length)
  327. {
  328. int ret;
  329. s->zstream.avail_in = length;
  330. s->zstream.next_in = s->bytestream;
  331. s->bytestream += length;
  332. if(s->bytestream > s->bytestream_end)
  333. return -1;
  334. /* decode one line if possible */
  335. while (s->zstream.avail_in > 0) {
  336. ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);
  337. if (ret != Z_OK && ret != Z_STREAM_END) {
  338. return -1;
  339. }
  340. if (s->zstream.avail_out == 0) {
  341. if (!(s->state & PNG_ALLIMAGE)) {
  342. png_handle_row(s);
  343. }
  344. s->zstream.avail_out = s->crow_size;
  345. s->zstream.next_out = s->crow_buf;
  346. }
  347. }
  348. return 0;
  349. }
  350. static int decode_frame(AVCodecContext *avctx,
  351. void *data, int *data_size,
  352. AVPacket *avpkt)
  353. {
  354. const uint8_t *buf = avpkt->data;
  355. int buf_size = avpkt->size;
  356. PNGDecContext * const s = avctx->priv_data;
  357. AVFrame *picture = data;
  358. AVFrame *p;
  359. uint32_t tag, length;
  360. int ret, crc;
  361. FFSWAP(AVFrame *, s->current_picture, s->last_picture);
  362. avctx->coded_frame= s->current_picture;
  363. p = s->current_picture;
  364. s->bytestream_start=
  365. s->bytestream= buf;
  366. s->bytestream_end= buf + buf_size;
  367. /* check signature */
  368. if (memcmp(s->bytestream, ff_pngsig, 8) != 0 &&
  369. memcmp(s->bytestream, ff_mngsig, 8) != 0)
  370. return -1;
  371. s->bytestream+= 8;
  372. s->y=
  373. s->state=0;
  374. // memset(s, 0, sizeof(PNGDecContext));
  375. /* init the zlib */
  376. s->zstream.zalloc = ff_png_zalloc;
  377. s->zstream.zfree = ff_png_zfree;
  378. s->zstream.opaque = NULL;
  379. ret = inflateInit(&s->zstream);
  380. if (ret != Z_OK)
  381. return -1;
  382. for(;;) {
  383. int tag32;
  384. if (s->bytestream >= s->bytestream_end)
  385. goto fail;
  386. length = bytestream_get_be32(&s->bytestream);
  387. if (length > 0x7fffffff)
  388. goto fail;
  389. tag32 = bytestream_get_be32(&s->bytestream);
  390. tag = bswap_32(tag32);
  391. #ifdef DEBUG
  392. av_log(avctx, AV_LOG_DEBUG, "png: tag=%c%c%c%c length=%u\n",
  393. (tag & 0xff),
  394. ((tag >> 8) & 0xff),
  395. ((tag >> 16) & 0xff),
  396. ((tag >> 24) & 0xff), length);
  397. #endif
  398. switch(tag) {
  399. case MKTAG('I', 'H', 'D', 'R'):
  400. if (length != 13)
  401. goto fail;
  402. s->width = bytestream_get_be32(&s->bytestream);
  403. s->height = bytestream_get_be32(&s->bytestream);
  404. if(avcodec_check_dimensions(avctx, s->width, s->height)){
  405. s->width= s->height= 0;
  406. goto fail;
  407. }
  408. s->bit_depth = *s->bytestream++;
  409. s->color_type = *s->bytestream++;
  410. s->compression_type = *s->bytestream++;
  411. s->filter_type = *s->bytestream++;
  412. s->interlace_type = *s->bytestream++;
  413. crc = bytestream_get_be32(&s->bytestream);
  414. s->state |= PNG_IHDR;
  415. #ifdef DEBUG
  416. 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",
  417. s->width, s->height, s->bit_depth, s->color_type,
  418. s->compression_type, s->filter_type, s->interlace_type);
  419. #endif
  420. break;
  421. case MKTAG('I', 'D', 'A', 'T'):
  422. if (!(s->state & PNG_IHDR))
  423. goto fail;
  424. if (!(s->state & PNG_IDAT)) {
  425. /* init image info */
  426. avctx->width = s->width;
  427. avctx->height = s->height;
  428. s->channels = ff_png_get_nb_channels(s->color_type);
  429. s->bits_per_pixel = s->bit_depth * s->channels;
  430. s->bpp = (s->bits_per_pixel + 7) >> 3;
  431. s->row_size = (avctx->width * s->bits_per_pixel + 7) >> 3;
  432. if (s->bit_depth == 8 &&
  433. s->color_type == PNG_COLOR_TYPE_RGB) {
  434. avctx->pix_fmt = PIX_FMT_RGB24;
  435. } else if (s->bit_depth == 8 &&
  436. s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
  437. avctx->pix_fmt = PIX_FMT_RGB32;
  438. } else if (s->bit_depth == 8 &&
  439. s->color_type == PNG_COLOR_TYPE_GRAY) {
  440. avctx->pix_fmt = PIX_FMT_GRAY8;
  441. } else if (s->bit_depth == 16 &&
  442. s->color_type == PNG_COLOR_TYPE_GRAY) {
  443. avctx->pix_fmt = PIX_FMT_GRAY16BE;
  444. } else if (s->bit_depth == 1 &&
  445. s->color_type == PNG_COLOR_TYPE_GRAY) {
  446. avctx->pix_fmt = PIX_FMT_MONOBLACK;
  447. } else if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
  448. avctx->pix_fmt = PIX_FMT_PAL8;
  449. } else {
  450. goto fail;
  451. }
  452. if(p->data[0])
  453. avctx->release_buffer(avctx, p);
  454. p->reference= 0;
  455. if(avctx->get_buffer(avctx, p) < 0){
  456. av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
  457. goto fail;
  458. }
  459. p->pict_type= FF_I_TYPE;
  460. p->key_frame= 1;
  461. p->interlaced_frame = !!s->interlace_type;
  462. /* compute the compressed row size */
  463. if (!s->interlace_type) {
  464. s->crow_size = s->row_size + 1;
  465. } else {
  466. s->pass = 0;
  467. s->pass_row_size = ff_png_pass_row_size(s->pass,
  468. s->bits_per_pixel,
  469. s->width);
  470. s->crow_size = s->pass_row_size + 1;
  471. }
  472. #ifdef DEBUG
  473. av_log(avctx, AV_LOG_DEBUG, "row_size=%d crow_size =%d\n",
  474. s->row_size, s->crow_size);
  475. #endif
  476. s->image_buf = p->data[0];
  477. s->image_linesize = p->linesize[0];
  478. /* copy the palette if needed */
  479. if (s->color_type == PNG_COLOR_TYPE_PALETTE)
  480. memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t));
  481. /* empty row is used if differencing to the first row */
  482. s->last_row = av_mallocz(s->row_size);
  483. if (!s->last_row)
  484. goto fail;
  485. if (s->interlace_type ||
  486. s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
  487. s->tmp_row = av_malloc(s->row_size);
  488. if (!s->tmp_row)
  489. goto fail;
  490. }
  491. /* compressed row */
  492. s->crow_buf = av_malloc(s->row_size + 1);
  493. if (!s->crow_buf)
  494. goto fail;
  495. s->zstream.avail_out = s->crow_size;
  496. s->zstream.next_out = s->crow_buf;
  497. }
  498. s->state |= PNG_IDAT;
  499. if (png_decode_idat(s, length) < 0)
  500. goto fail;
  501. /* skip crc */
  502. crc = bytestream_get_be32(&s->bytestream);
  503. break;
  504. case MKTAG('P', 'L', 'T', 'E'):
  505. {
  506. int n, i, r, g, b;
  507. if ((length % 3) != 0 || length > 256 * 3)
  508. goto skip_tag;
  509. /* read the palette */
  510. n = length / 3;
  511. for(i=0;i<n;i++) {
  512. r = *s->bytestream++;
  513. g = *s->bytestream++;
  514. b = *s->bytestream++;
  515. s->palette[i] = (0xff << 24) | (r << 16) | (g << 8) | b;
  516. }
  517. for(;i<256;i++) {
  518. s->palette[i] = (0xff << 24);
  519. }
  520. s->state |= PNG_PLTE;
  521. crc = bytestream_get_be32(&s->bytestream);
  522. }
  523. break;
  524. case MKTAG('t', 'R', 'N', 'S'):
  525. {
  526. int v, i;
  527. /* read the transparency. XXX: Only palette mode supported */
  528. if (s->color_type != PNG_COLOR_TYPE_PALETTE ||
  529. length > 256 ||
  530. !(s->state & PNG_PLTE))
  531. goto skip_tag;
  532. for(i=0;i<length;i++) {
  533. v = *s->bytestream++;
  534. s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);
  535. }
  536. crc = bytestream_get_be32(&s->bytestream);
  537. }
  538. break;
  539. case MKTAG('I', 'E', 'N', 'D'):
  540. if (!(s->state & PNG_ALLIMAGE))
  541. goto fail;
  542. crc = bytestream_get_be32(&s->bytestream);
  543. goto exit_loop;
  544. default:
  545. /* skip tag */
  546. skip_tag:
  547. s->bytestream += length + 4;
  548. break;
  549. }
  550. }
  551. exit_loop:
  552. /* handle p-frames only if a predecessor frame is available */
  553. if(s->last_picture->data[0] != NULL) {
  554. if(!(avpkt->flags & PKT_FLAG_KEY)) {
  555. int i, j;
  556. uint8_t *pd = s->current_picture->data[0];
  557. uint8_t *pd_last = s->last_picture->data[0];
  558. for(j=0; j < s->height; j++) {
  559. for(i=0; i < s->width * s->bpp; i++) {
  560. pd[i] += pd_last[i];
  561. }
  562. pd += s->image_linesize;
  563. pd_last += s->image_linesize;
  564. }
  565. }
  566. }
  567. *picture= *s->current_picture;
  568. *data_size = sizeof(AVFrame);
  569. ret = s->bytestream - s->bytestream_start;
  570. the_end:
  571. inflateEnd(&s->zstream);
  572. av_freep(&s->crow_buf);
  573. av_freep(&s->last_row);
  574. av_freep(&s->tmp_row);
  575. return ret;
  576. fail:
  577. ret = -1;
  578. goto the_end;
  579. }
  580. static av_cold int png_dec_init(AVCodecContext *avctx){
  581. PNGDecContext *s = avctx->priv_data;
  582. s->current_picture = &s->picture1;
  583. s->last_picture = &s->picture2;
  584. avcodec_get_frame_defaults(&s->picture1);
  585. avcodec_get_frame_defaults(&s->picture2);
  586. dsputil_init(&s->dsp, avctx);
  587. return 0;
  588. }
  589. AVCodec png_decoder = {
  590. "png",
  591. CODEC_TYPE_VIDEO,
  592. CODEC_ID_PNG,
  593. sizeof(PNGDecContext),
  594. png_dec_init,
  595. NULL,
  596. NULL, //decode_end,
  597. decode_frame,
  598. 0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
  599. NULL,
  600. .long_name = NULL_IF_CONFIG_SMALL("PNG image"),
  601. };