]> git.sesse.net Git - nageru/blobdiff - nageru/image_input.cpp
Stop using av_init_packet().
[nageru] / nageru / image_input.cpp
index 2e062714285b170148a9822c7289a4a1efe02d2f..7b11679e03b22089e1f0508e658e049d4be89662 100644 (file)
@@ -143,17 +143,14 @@ shared_ptr<const ImageInput::Image> ImageInput::load_image_raw(const string &pat
        AVFrameWithDeleter frame = av_frame_alloc_unique();
        bool eof = false;
        do {
-               AVPacket pkt;
-               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.get(), &pkt) == 0) {
-                       if (pkt.stream_index != stream_index) {
+               AVPacketWithDeleter pkt = av_packet_alloc_unique();
+               pkt->data = nullptr;
+               pkt->size = 0;
+               if (av_read_frame(format_ctx.get(), pkt.get()) == 0) {
+                       if (pkt->stream_index != stream_index) {
                                continue;
                        }
-                       if (avcodec_send_packet(codec_ctx.get(), &pkt) < 0) {
+                       if (avcodec_send_packet(codec_ctx.get(), pkt.get()) < 0) {
                                fprintf(stderr, "%s: Cannot send packet to codec.\n", pathname.c_str());
                                return nullptr;
                        }