191
192
/* NOTE: 'dst' can be equal to 'last' */
192
static void png_filter_row(DSPContext *dsp, uint8_t *dst, int filter_type,
193
static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
193
194
uint8_t *src, uint8_t *last, int size, int bpp)
195
196
int i, p, r, g, b, a;
233
234
if(bpp > 1 && size > 4) {
234
235
// would write off the end of the array if we let it process the last pixel with bpp=3
235
236
int w = bpp==4 ? size : size-3;
236
dsp->add_png_paeth_prediction(dst+i, src+i, last+i, w-i, bpp);
237
dsp->add_paeth_prediction(dst+i, src+i, last+i, w-i, bpp);
239
240
ff_add_png_paeth_prediction(dst+i, src+i, last+i, size-i, bpp);
384
385
static int decode_frame(AVCodecContext *avctx,
385
void *data, int *data_size,
386
void *data, int *got_frame,
388
389
const uint8_t *buf = avpkt->data;
464
465
if (s->bit_depth == 8 &&
465
466
s->color_type == PNG_COLOR_TYPE_RGB) {
466
avctx->pix_fmt = PIX_FMT_RGB24;
467
avctx->pix_fmt = AV_PIX_FMT_RGB24;
467
468
} else if (s->bit_depth == 8 &&
468
469
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
469
avctx->pix_fmt = PIX_FMT_RGB32;
470
avctx->pix_fmt = AV_PIX_FMT_RGB32;
470
471
} else if (s->bit_depth == 8 &&
471
472
s->color_type == PNG_COLOR_TYPE_GRAY) {
472
avctx->pix_fmt = PIX_FMT_GRAY8;
473
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
473
474
} else if (s->bit_depth == 16 &&
474
475
s->color_type == PNG_COLOR_TYPE_GRAY) {
475
avctx->pix_fmt = PIX_FMT_GRAY16BE;
476
avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
476
477
} else if (s->bit_depth == 16 &&
477
478
s->color_type == PNG_COLOR_TYPE_RGB) {
478
avctx->pix_fmt = PIX_FMT_RGB48BE;
479
avctx->pix_fmt = AV_PIX_FMT_RGB48BE;
479
480
} else if (s->bit_depth == 1 &&
480
481
s->color_type == PNG_COLOR_TYPE_GRAY) {
481
avctx->pix_fmt = PIX_FMT_MONOBLACK;
482
avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
482
483
} else if (s->bit_depth == 8 &&
483
484
s->color_type == PNG_COLOR_TYPE_PALETTE) {
484
avctx->pix_fmt = PIX_FMT_PAL8;
485
avctx->pix_fmt = AV_PIX_FMT_PAL8;
485
486
} else if (s->bit_depth == 8 &&
486
487
s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
487
avctx->pix_fmt = PIX_FMT_Y400A;
488
avctx->pix_fmt = AV_PIX_FMT_Y400A;
492
493
avctx->release_buffer(avctx, p);
495
if(avctx->get_buffer(avctx, p) < 0){
496
if(ff_get_buffer(avctx, p) < 0){
496
497
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
632
633
s->last_picture = &s->picture2;
633
634
avcodec_get_frame_defaults(&s->picture1);
634
635
avcodec_get_frame_defaults(&s->picture2);
635
dsputil_init(&s->dsp, avctx);
636
ff_pngdsp_init(&s->dsp);
652
653
AVCodec ff_png_decoder = {
654
655
.type = AVMEDIA_TYPE_VIDEO,
656
.id = AV_CODEC_ID_PNG,
656
657
.priv_data_size = sizeof(PNGDecContext),
657
658
.init = png_dec_init,
658
659
.close = png_dec_end,
659
660
.decode = decode_frame,
660
661
.capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
661
.long_name = NULL_IF_CONFIG_SMALL("PNG image"),
662
.long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"),