[FFmpeg-devel] [PATCH 14/18 v2] avformat/flacenc: port to the new packet list API

James Almer jamrial at gmail.com
Thu Nov 19 18:57:11 EET 2020


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/flacenc.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index a24d3be85d..3459c815db 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -39,7 +39,7 @@ typedef struct FlacMuxerContext {
     int audio_stream_idx;
     int waiting_pics;
     /* audio packets are queued here until we get all the attached pictures */
-    PacketListEntry *queue, *queue_end;
+    AVPacketList *queue;
 
     /* updated streaminfo sent by the encoder at the end */
     uint8_t streaminfo[FLAC_STREAMINFO_SIZE];
@@ -253,6 +253,10 @@ static int flac_init(struct AVFormatContext *s)
         }
     }
 
+    c->queue = av_packet_list_alloc();
+    if (!c->queue)
+        return AVERROR(ENOMEM);
+
     return 0;
 }
 
@@ -305,8 +309,7 @@ static int flac_queue_flush(AVFormatContext *s)
     if (ret < 0)
         write = 0;
 
-    while (c->queue) {
-        avpriv_packet_list_get(&c->queue, &c->queue_end, &pkt);
+    while (!av_packet_list_get(c->queue, &pkt, 0)) {
         if (write && (ret = flac_write_audio_packet(s, &pkt)) < 0)
             write = 0;
         av_packet_unref(&pkt);
@@ -346,7 +349,7 @@ static void flac_deinit(struct AVFormatContext *s)
 {
     FlacMuxerContext *c = s->priv_data;
 
-    avpriv_packet_list_free(&c->queue, &c->queue_end);
+    av_packet_list_free(&c->queue);
 }
 
 static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
@@ -357,7 +360,7 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
     if (pkt->stream_index == c->audio_stream_idx) {
         if (c->waiting_pics) {
             /* buffer audio packets until we get all the pictures */
-            ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, av_packet_ref, 0);
+            ret = av_packet_list_put(c->queue, pkt, av_packet_ref, 0);
             if (ret < 0) {
                 av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n");
                 c->waiting_pics = 0;
-- 
2.29.2



More information about the ffmpeg-devel mailing list