When the tta muxer writes the actual packet data at the end of the
muxing process, it repeatedly copies the packets contained in the
linked list of stored packets to an AVPacket located on the stack via
ff_packet_list_get(), writes the data and unrefs the packet.

But when one is willing to traverse and free the linked list oneself,
one can get rid of the copying. This also means that the tta muxer does
not rely on sizeof(AVPacket) any more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com>
---
 libavformat/ttaenc.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c
index 73c29ae936..84e3937141 100644
--- a/libavformat/ttaenc.c
+++ b/libavformat/ttaenc.c
@@ -122,13 +122,16 @@ static int tta_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 static void tta_queue_flush(AVFormatContext *s)
 {
     TTAMuxContext *tta = s->priv_data;
-    AVPacket pkt;
-
-    while (tta->queue) {
-        ff_packet_list_get(&tta->queue, &tta->queue_end, &pkt);
-        avio_write(s->pb, pkt.data, pkt.size);
-        av_packet_unref(&pkt);
+    AVPacketList *entry = tta->queue;
+
+    while (entry) {
+        AVPacketList *next = entry->next;
+        avio_write(s->pb, entry->pkt.data, entry->pkt.size);
+        av_packet_unref(&entry->pkt);
+        av_free(entry);
+        entry = next;
     }
+    tta->queue = tta->queue_end = NULL;
 }
 
 static int tta_write_trailer(AVFormatContext *s)
-- 
2.20.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to