diff mbox series

[FFmpeg-devel,13/18] avformat/mp3enc: port to the new packet list API

Message ID 20201118165247.4130-14-jamrial@gmail.com
State New
Headers show
Series AVPacketList public API
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

James Almer Nov. 18, 2020, 4:52 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/mp3enc.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index fddde33400..ed585c3976 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -132,7 +132,7 @@  typedef struct MP3Context {
     int pics_to_write;
 
     /* audio packets are queued here until we get all the attached pictures */
-    PacketListEntry *queue, *queue_end;
+    AVPacketList *queue;
 } MP3Context;
 
 static const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}};
@@ -387,8 +387,7 @@  static int mp3_queue_flush(AVFormatContext *s)
     ff_id3v2_finish(&mp3->id3, s->pb, s->metadata_header_padding);
     mp3_write_xing(s);
 
-    while (mp3->queue) {
-        avpriv_packet_list_get(&mp3->queue, &mp3->queue_end, &pkt);
+    while (!av_packet_list_get(mp3->queue, &pkt, 0)) {
         if (write && (ret = mp3_write_audio_packet(s, &pkt)) < 0)
             write = 0;
         av_packet_unref(&pkt);
@@ -523,7 +522,7 @@  static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (pkt->stream_index == mp3->audio_stream_idx) {
         if (mp3->pics_to_write) {
             /* buffer audio packets until we get all the pictures */
-            int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end, pkt, av_packet_ref, 0);
+            int ret = av_packet_list_put(mp3->queue, pkt, av_packet_ref, 0);
 
             if (ret < 0) {
                 av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n");
@@ -603,6 +602,10 @@  static int mp3_init(struct AVFormatContext *s)
         return AVERROR(EINVAL);
     }
 
+    mp3->queue = av_packet_list_alloc();
+    if (!mp3->queue)
+        return AVERROR(ENOMEM);
+
     return 0;
 }
 
@@ -631,7 +634,7 @@  static void mp3_deinit(struct AVFormatContext *s)
 {
     MP3Context *mp3 = s->priv_data;
 
-    avpriv_packet_list_free(&mp3->queue, &mp3->queue_end);
+    av_packet_list_free(&mp3->queue);
     av_freep(&mp3->xing_frame);
 }