p = last[i];
dst[i] = p + src[i];
}
- if (bpp > 1 && size > 4) {
+ if (bpp > 2 && size > 4) {
/* would write off the end of the array if we let it process
* the last pixel with bpp=3 */
int w = bpp == 4 ? size : size - 3;
/* check signature */
if (buf_size < 8 ||
- memcmp(buf, ff_pngsig, 8) != 0 &&
- memcmp(buf, ff_mngsig, 8) != 0)
- return -1;
+ (memcmp(buf, ff_pngsig, 8) != 0 && memcmp(buf, ff_mngsig, 8) != 0)) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid PNG signature (%d).\n", buf_size);
+ return AVERROR_INVALIDDATA;
+ }
bytestream2_init(&s->gb, buf + 8, buf_size - 8);
s->y = s->state = 0;
} else if (s->bit_depth == 8 &&
s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
avctx->pix_fmt = AV_PIX_FMT_YA8;
+ } else if (s->bit_depth == 16 &&
+ s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
+ avctx->pix_fmt = AV_PIX_FMT_YA16BE;
} else {
goto fail;
}