mirror of
https://github.com/mpv-player/mpv
synced 2024-12-23 07:12:39 +00:00
image_writer: replace deprecated av_init_packet()
This commit is contained in:
parent
79783f4ac5
commit
8b4a613c54
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user