From ea64bc10a1cdeff0363985bbf742c8437956da70 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 13 Jul 2023 20:02:07 +0200 Subject: [PATCH] Fix a deprecation warning, at the cost of more allocations. --- video_widget.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/video_widget.cpp b/video_widget.cpp index b783b00..f8db900 100644 --- a/video_widget.cpp +++ b/video_widget.cpp @@ -740,15 +740,14 @@ AVFrameWithDeleter VideoWidget::decode_frame(AVFormatContext *format_ctx, AVCode AVFrameWithDeleter video_avframe = av_frame_alloc_unique(); bool eof = false; do { - AVPacket pkt; + AVPacket *pkt = av_packet_alloc(); unique_ptr pkt_cleanup( - &pkt, av_packet_unref); - av_init_packet(&pkt); - pkt.data = nullptr; - pkt.size = 0; - if (av_read_frame(format_ctx, &pkt) == 0) { - if (pkt.stream_index == video_stream_index) { - if (avcodec_send_packet(video_codec_ctx, &pkt) < 0) { + pkt, av_packet_unref); + pkt->data = nullptr; + pkt->size = 0; + if (av_read_frame(format_ctx, pkt) == 0) { + if (pkt->stream_index == video_stream_index) { + if (avcodec_send_packet(video_codec_ctx, pkt) < 0) { fprintf(stderr, "%s: Cannot send packet to video codec.\n", pathname.c_str()); *error = true; return AVFrameWithDeleter(nullptr); -- 2.39.2