summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-12-13 16:12:31 +0100
committersfan5 <sfan5@live.de>2022-01-10 22:56:52 +0100
commit8b4a613c54de038bcf0dd710563059a03968d82b (patch)
tree2a0224fa402fd63602298625197232c6111fefeb
parent79783f4ac5ab6025ec10286dff298b3c29513dde (diff)
downloadmpv-8b4a613c54de038bcf0dd710563059a03968d82b.tar.bz2
mpv-8b4a613c54de038bcf0dd710563059a03968d82b.tar.xz
image_writer: replace deprecated av_init_packet()
-rw-r--r--video/image_writer.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/video/image_writer.c b/video/image_writer.c
index cff8609ded..d294a4dc32 100644
--- a/video/image_writer.c
+++ b/video/image_writer.c
@@ -96,12 +96,9 @@ static enum AVPixelFormat replace_j_format(enum AVPixelFormat fmt)
static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp)
{
- bool success = 0;
+ bool success = false;
AVFrame *pic = NULL;
- AVPacket pkt = {0};
- int got_output = 0;
-
- av_init_packet(&pkt);
+ AVPacket *pkt = NULL;
const AVCodec *codec;
if (ctx->opts->format == AV_CODEC_ID_WEBP) {
@@ -172,18 +169,20 @@ static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp
ret = avcodec_send_frame(avctx, NULL); // send EOF
if (ret < 0)
goto error_exit;
- ret = avcodec_receive_packet(avctx, &pkt);
+ pkt = av_packet_alloc();
+ if (!pkt)
+ goto error_exit;
+ ret = avcodec_receive_packet(avctx, pkt);
if (ret < 0)
goto error_exit;
- got_output = 1;
+ success = true;
- fwrite(pkt.data, pkt.size, 1, fp);
+ fwrite(pkt->data, pkt->size, 1, fp);
- success = !!got_output;
error_exit:
avcodec_free_context(&avctx);
av_frame_free(&pic);
- av_packet_unref(&pkt);
+ av_packet_free(&pkt);
return success;
}