[FFmpeg-devel] [PATCH 02/18] avformat/internal: make last_in_packet_buffer of type PacketListEntry

James Almer jamrial at gmail.com
Wed Nov 18 18:52:31 EET 2020


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/internal.h |  3 ++-
 libavformat/mux.c      | 11 ++++++-----
 libavformat/mxfenc.c   |  6 +++---
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 49e82bfbca..c29c7deec7 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -26,6 +26,7 @@
 #include "libavutil/bprint.h"
 #include "avformat.h"
 #include "os_support.h"
+#include "libavcodec/packet_internal.h"
 
 #define MAX_URL_SIZE 4096
 
@@ -342,7 +343,7 @@ struct AVStreamInternal {
     /**
      * last packet in packet_buffer for this stream when muxing.
      */
-    struct AVPacketList *last_in_packet_buffer;
+    struct PacketListEntry *last_in_packet_buffer;
 };
 
 #ifdef __GNUC__
diff --git a/libavformat/mux.c b/libavformat/mux.c
index d2a56d216b..d60bf2218b 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -832,7 +832,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
     pkt = &this_pktl->pkt;
 
     if (st->internal->last_in_packet_buffer) {
-        next_point = &(st->internal->last_in_packet_buffer->next);
+        next_point = (AVPacketList **)&(st->internal->last_in_packet_buffer->next);
     } else {
         next_point = &s->internal->packet_buffer;
     }
@@ -876,7 +876,8 @@ next_non_null:
 
     this_pktl->next = *next_point;
 
-    st->internal->last_in_packet_buffer = *next_point = this_pktl;
+    *next_point = this_pktl;
+    st->internal->last_in_packet_buffer = (PacketListEntry *)this_pktl;
 
     return 0;
 }
@@ -951,7 +952,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
 
         for (i = 0; i < s->nb_streams; i++) {
             int64_t last_dts;
-            const AVPacketList *last = s->streams[i]->internal->last_in_packet_buffer;
+            const PacketListEntry *last = s->streams[i]->internal->last_in_packet_buffer;
 
             if (!last)
                 continue;
@@ -1000,7 +1001,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
             if (!s->internal->packet_buffer)
                 s->internal->packet_buffer_end = NULL;
 
-            if (st->internal->last_in_packet_buffer == pktl)
+            if (st->internal->last_in_packet_buffer == (PacketListEntry *)pktl)
                 st->internal->last_in_packet_buffer = NULL;
 
             av_packet_unref(&pktl->pkt);
@@ -1019,7 +1020,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
         if (!s->internal->packet_buffer)
             s->internal->packet_buffer_end = NULL;
 
-        if (st->internal->last_in_packet_buffer == pktl)
+        if (st->internal->last_in_packet_buffer == (PacketListEntry *)pktl)
             st->internal->last_in_packet_buffer = NULL;
         av_freep(&pktl);
 
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index d8678c9d25..c7f98ac257 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -3061,8 +3061,8 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
                 if (!stream_count || pktl->pkt.stream_index == 0)
                     break;
                 // update last packet in packet buffer
-                if (s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer != pktl)
-                    s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer = pktl;
+                if (s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer != (PacketListEntry *)pktl)
+                    s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer = (PacketListEntry *)pktl;
                 last = pktl;
                 pktl = pktl->next;
                 stream_count--;
@@ -3087,7 +3087,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
         *out = pktl->pkt;
         av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", (*out).stream_index, (*out).dts);
         s->internal->packet_buffer = pktl->next;
-        if(s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer == pktl)
+        if(s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer == (PacketListEntry *)pktl)
             s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer= NULL;
         if(!s->internal->packet_buffer)
             s->internal->packet_buffer_end= NULL;
-- 
2.29.2



More information about the ffmpeg-devel mailing list