]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pngdec.c
hevc: store the escaped/raw bitstream in HEVCNAL
[ffmpeg] / libavcodec / pngdec.c
index 7bc2ad484798698b21f0a28f40034a8cd1952f1e..dec5bd512c5e5acb6a6b6dcb7d9ca623b7b6c7de 100644 (file)
@@ -240,7 +240,7 @@ static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
             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;
@@ -415,9 +415,10 @@ static int decode_frame(AVCodecContext *avctx,
 
     /* 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;
@@ -500,6 +501,9 @@ static int decode_frame(AVCodecContext *avctx,
                 } 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;
                 }