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.

654 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. uint8_t *crow_buf_base = NULL;
  360. uint32_t tag, length;
  361. int ret, crc;
  362. FFSWAP(AVFrame *, s->current_picture, s->last_picture);
  363. avctx->coded_frame= s->current_picture;
  364. p = s->current_picture;
  365. s->bytestream_start=
  366. s->bytestream= buf;
  367. s->bytestream_end= buf + buf_size;
  368. /* check signature */
  369. if (memcmp(s->bytestream, ff_pngsig, 8) != 0 &&
  370. memcmp(s->bytestream, ff_mngsig, 8) != 0)
  371. return -1;
  372. s->bytestream+= 8;
  373. s->y=
  374. s->state=0;
  375. // memset(s, 0, sizeof(PNGDecContext));
  376. /* init the zlib */
  377. s->zstream.zalloc = ff_png_zalloc;
  378. s->zstream.zfree = ff_png_zfree;
  379. s->zstream.opaque = NULL;
  380. ret = inflateInit(&s->zstream);
  381. if (ret != Z_OK)
  382. return -1;
  383. for(;;) {
  384. int tag32;
  385. if (s->bytestream >= s->bytestream_end)
  386. goto fail;
  387. length = bytestream_get_be32(&s->bytestream);
  388. if (length > 0x7fffffff)
  389. goto fail;
  390. tag32 = bytestream_get_be32(&s->bytestream);
  391. tag = bswap_32(tag32);
  392. #ifdef DEBUG
  393. av_log(avctx, AV_LOG_DEBUG, "png: tag=%c%c%c%c length=%u\n",
  394. (tag & 0xff),
  395. ((tag >> 8) & 0xff),
  396. ((tag >> 16) & 0xff),
  397. ((tag >> 24) & 0xff), length);
  398. #endif
  399. switch(tag) {
  400. case MKTAG('I', 'H', 'D', 'R'):
  401. if (length != 13)
  402. goto fail;
  403. s->width = bytestream_get_be32(&s->bytestream);
  404. s->height = bytestream_get_be32(&s->bytestream);
  405. if(avcodec_check_dimensions(avctx, s->width, s->height)){
  406. s->width= s->height= 0;
  407. goto fail;
  408. }
  409. s->bit_depth = *s->bytestream++;
  410. s->color_type = *s->bytestream++;
  411. s->compression_type = *s->bytestream++;
  412. s->filter_type = *s->bytestream++;
  413. s->interlace_type = *s->bytestream++;
  414. crc = bytestream_get_be32(&s->bytestream);
  415. s->state |= PNG_IHDR;
  416. #ifdef DEBUG
  417. 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",
  418. s->width, s->height, s->bit_depth, s->color_type,
  419. s->compression_type, s->filter_type, s->interlace_type);
  420. #endif
  421. break;
  422. case MKTAG('I', 'D', 'A', 'T'):
  423. if (!(s->state & PNG_IHDR))
  424. goto fail;
  425. if (!(s->state & PNG_IDAT)) {
  426. /* init image info */
  427. avctx->width = s->width;
  428. avctx->height = s->height;
  429. s->channels = ff_png_get_nb_channels(s->color_type);
  430. s->bits_per_pixel = s->bit_depth * s->channels;
  431. s->bpp = (s->bits_per_pixel + 7) >> 3;
  432. s->row_size = (avctx->width * s->bits_per_pixel + 7) >> 3;
  433. if (s->bit_depth == 8 &&
  434. s->color_type == PNG_COLOR_TYPE_RGB) {
  435. avctx->pix_fmt = PIX_FMT_RGB24;
  436. } else if (s->bit_depth == 8 &&
  437. s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
  438. avctx->pix_fmt = PIX_FMT_RGB32;
  439. } else if (s->bit_depth == 8 &&
  440. s->color_type == PNG_COLOR_TYPE_GRAY) {
  441. avctx->pix_fmt = PIX_FMT_GRAY8;
  442. } else if (s->bit_depth == 16 &&
  443. s->color_type == PNG_COLOR_TYPE_GRAY) {
  444. avctx->pix_fmt = PIX_FMT_GRAY16BE;
  445. } else if (s->bit_depth == 1 &&
  446. s->color_type == PNG_COLOR_TYPE_GRAY) {
  447. avctx->pix_fmt = PIX_FMT_MONOBLACK;
  448. } else if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
  449. avctx->pix_fmt = PIX_FMT_PAL8;
  450. } else {
  451. goto fail;
  452. }
  453. if(p->data[0])
  454. avctx->release_buffer(avctx, p);
  455. p->reference= 0;
  456. if(avctx->get_buffer(avctx, p) < 0){
  457. av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
  458. goto fail;
  459. }
  460. p->pict_type= FF_I_TYPE;
  461. p->key_frame= 1;
  462. p->interlaced_frame = !!s->interlace_type;
  463. /* compute the compressed row size */
  464. if (!s->interlace_type) {
  465. s->crow_size = s->row_size + 1;
  466. } else {
  467. s->pass = 0;
  468. s->pass_row_size = ff_png_pass_row_size(s->pass,
  469. s->bits_per_pixel,
  470. s->width);
  471. s->crow_size = s->pass_row_size + 1;
  472. }
  473. #ifdef DEBUG
  474. av_log(avctx, AV_LOG_DEBUG, "row_size=%d crow_size =%d\n",
  475. s->row_size, s->crow_size);
  476. #endif
  477. s->image_buf = p->data[0];
  478. s->image_linesize = p->linesize[0];
  479. /* copy the palette if needed */
  480. if (s->color_type == PNG_COLOR_TYPE_PALETTE)
  481. memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t));
  482. /* empty row is used if differencing to the first row */
  483. s->last_row = av_mallocz(s->row_size);
  484. if (!s->last_row)
  485. goto fail;
  486. if (s->interlace_type ||
  487. s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
  488. s->tmp_row = av_malloc(s->row_size);
  489. if (!s->tmp_row)
  490. goto fail;
  491. }
  492. /* compressed row */
  493. crow_buf_base = av_malloc(s->row_size + 16);
  494. if (!crow_buf_base)
  495. goto fail;
  496. /* we want crow_buf+1 to be 16-byte aligned */
  497. s->crow_buf = crow_buf_base + 15;
  498. s->zstream.avail_out = s->crow_size;
  499. s->zstream.next_out = s->crow_buf;
  500. }
  501. s->state |= PNG_IDAT;
  502. if (png_decode_idat(s, length) < 0)
  503. goto fail;
  504. /* skip crc */
  505. crc = bytestream_get_be32(&s->bytestream);
  506. break;
  507. case MKTAG('P', 'L', 'T', 'E'):
  508. {
  509. int n, i, r, g, b;
  510. if ((length % 3) != 0 || length > 256 * 3)
  511. goto skip_tag;
  512. /* read the palette */
  513. n = length / 3;
  514. for(i=0;i<n;i++) {
  515. r = *s->bytestream++;
  516. g = *s->bytestream++;
  517. b = *s->bytestream++;
  518. s->palette[i] = (0xff << 24) | (r << 16) | (g << 8) | b;
  519. }
  520. for(;i<256;i++) {
  521. s->palette[i] = (0xff << 24);
  522. }
  523. s->state |= PNG_PLTE;
  524. crc = bytestream_get_be32(&s->bytestream);
  525. }
  526. break;
  527. case MKTAG('t', 'R', 'N', 'S'):
  528. {
  529. int v, i;
  530. /* read the transparency. XXX: Only palette mode supported */
  531. if (s->color_type != PNG_COLOR_TYPE_PALETTE ||
  532. length > 256 ||
  533. !(s->state & PNG_PLTE))
  534. goto skip_tag;
  535. for(i=0;i<length;i++) {
  536. v = *s->bytestream++;
  537. s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);
  538. }
  539. crc = bytestream_get_be32(&s->bytestream);
  540. }
  541. break;
  542. case MKTAG('I', 'E', 'N', 'D'):
  543. if (!(s->state & PNG_ALLIMAGE))
  544. goto fail;
  545. crc = bytestream_get_be32(&s->bytestream);
  546. goto exit_loop;
  547. default:
  548. /* skip tag */
  549. skip_tag:
  550. s->bytestream += length + 4;
  551. break;
  552. }
  553. }
  554. exit_loop:
  555. /* handle p-frames only if a predecessor frame is available */
  556. if(s->last_picture->data[0] != NULL) {
  557. if(!(avpkt->flags & PKT_FLAG_KEY)) {
  558. int i, j;
  559. uint8_t *pd = s->current_picture->data[0];
  560. uint8_t *pd_last = s->last_picture->data[0];
  561. for(j=0; j < s->height; j++) {
  562. for(i=0; i < s->width * s->bpp; i++) {
  563. pd[i] += pd_last[i];
  564. }
  565. pd += s->image_linesize;
  566. pd_last += s->image_linesize;
  567. }
  568. }
  569. }
  570. *picture= *s->current_picture;
  571. *data_size = sizeof(AVFrame);
  572. ret = s->bytestream - s->bytestream_start;
  573. the_end:
  574. inflateEnd(&s->zstream);
  575. av_free(crow_buf_base);
  576. s->crow_buf = NULL;
  577. av_freep(&s->last_row);
  578. av_freep(&s->tmp_row);
  579. return ret;
  580. fail:
  581. ret = -1;
  582. goto the_end;
  583. }
  584. static av_cold int png_dec_init(AVCodecContext *avctx){
  585. PNGDecContext *s = avctx->priv_data;
  586. s->current_picture = &s->picture1;
  587. s->last_picture = &s->picture2;
  588. avcodec_get_frame_defaults(&s->picture1);
  589. avcodec_get_frame_defaults(&s->picture2);
  590. dsputil_init(&s->dsp, avctx);
  591. return 0;
  592. }
  593. AVCodec png_decoder = {
  594. "png",
  595. CODEC_TYPE_VIDEO,
  596. CODEC_ID_PNG,
  597. sizeof(PNGDecContext),
  598. png_dec_init,
  599. NULL,
  600. NULL, //decode_end,
  601. decode_frame,
  602. 0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
  603. NULL,
  604. .long_name = NULL_IF_CONFIG_SMALL("PNG image"),
  605. };