1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 23:02:37 +00:00

image_writer: replace deprecated av_init_packet()

This commit is contained in:
sfan5 2021-12-13 16:12:31 +01:00
parent 79783f4ac5
commit 8b4a613c54

View File

@ -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;
}