[MPlayer-dev-eng] [PATCH 2/6] gui: Use new lavc decode API for PNG decode.
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun Dec 20 19:50:30 EET 2020
---
gui/util/bitmap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/gui/util/bitmap.c b/gui/util/bitmap.c
index fa0522fcb..ff7cbf4c1 100644
--- a/gui/util/bitmap.c
+++ b/gui/util/bitmap.c
@@ -124,8 +124,6 @@ static int pngRead(const char *fname, guiImage *img, int *pix_fmt)
return 6;
}
- avcodec_register_all();
-
if (avcodec_open2(avctx, avcodec_find_decoder(AV_CODEC_ID_PNG), NULL) < 0) {
av_free(frame);
av_free(avctx);
@@ -139,7 +137,8 @@ static int pngRead(const char *fname, guiImage *img, int *pix_fmt)
/* HACK: Make PNGs decode normally instead of as CorePNG delta frames. */
pkt.flags = AV_PKT_FLAG_KEY;
- avcodec_decode_video2(avctx, frame, &decode_ok, &pkt);
+ avcodec_send_packet(avctx, &pkt);
+ decode_ok = avcodec_receive_frame(avctx, frame);
memset(img, 0, sizeof(*img));
memset(palette, 0, sizeof(palette));
@@ -165,7 +164,7 @@ static int pngRead(const char *fname, guiImage *img, int *pix_fmt)
break;
}
- if (decode_ok && img->Bpp) {
+ if (decode_ok >= 0 && img->Bpp) {
img->Width = avctx->width;
img->Height = avctx->height;
bpl = img->Width * (img->Bpp / 8);
@@ -183,7 +182,7 @@ static int pngRead(const char *fname, guiImage *img, int *pix_fmt)
if (frame->data[1])
memcpy(palette, frame->data[1], sizeof(palette));
} else
- decode_ok = False;
+ decode_ok = -1;
}
avcodec_close(avctx);
@@ -191,7 +190,7 @@ static int pngRead(const char *fname, guiImage *img, int *pix_fmt)
av_free(avctx);
av_free(data);
- return !(decode_ok && img->Bpp);
+ return !(decode_ok >= 0 && img->Bpp);
}
/**
--
2.29.2
More information about the MPlayer-dev-eng
mailing list