]> git.sesse.net Git - pkanalytics/commitdiff
Fix a deprecation warning, at the cost of more allocations.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 13 Jul 2023 18:02:07 +0000 (20:02 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 13 Jul 2023 18:02:07 +0000 (20:02 +0200)
video_widget.cpp

index b783b00651e2652608ba72b1a649c9160ee7ddaf..f8db9002b7ba91d2d32cf3ecdd0fcdeaea09e702 100644 (file)
@@ -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<AVPacket, decltype(av_packet_unref)*> 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);