From: Steinar H. Gunderson Date: Thu, 13 Jul 2023 18:02:07 +0000 (+0200) Subject: Fix a deprecation warning, at the cost of more allocations. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ea64bc10a1cdeff0363985bbf742c8437956da70;hp=d4c0ea6e97e0b0edd354ef8233f75938ea5dc08a;p=pkanalytics Fix a deprecation warning, at the cost of more allocations. --- 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);