diff mbox series

[FFmpeg-devel,03/18] avcodec/avpacket: make avpriv_packet_* use PacketListEntry

Message ID 20201118165247.4130-4-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>
---
 libavcodec/avpacket.c        | 18 +++++++++---------
 libavcodec/internal.h        |  5 +++--
 libavcodec/packet_internal.h |  6 +++---
 libavformat/aiffenc.c        |  4 ++--
 libavformat/flacenc.c        |  2 +-
 libavformat/internal.h       | 12 ++++++------
 libavformat/matroskadec.c    |  4 ++--
 libavformat/mp3enc.c         |  2 +-
 libavformat/mux.c            | 16 ++++++++--------
 libavformat/mxfenc.c         | 12 ++++++------
 libavformat/ttaenc.c         |  2 +-
 libavformat/utils.c          | 14 +++++++-------
 12 files changed, 49 insertions(+), 48 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index e4ba403cf6..c12515cf05 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -726,13 +726,13 @@  FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 }
 
-int avpriv_packet_list_put(AVPacketList **packet_buffer,
-                           AVPacketList **plast_pktl,
+int avpriv_packet_list_put(PacketListEntry **packet_buffer,
+                           PacketListEntry **plast_pktl,
                            AVPacket      *pkt,
                            int (*copy)(AVPacket *dst, const AVPacket *src),
                            int flags)
 {
-    AVPacketList *pktl = av_mallocz(sizeof(AVPacketList));
+    PacketListEntry *pktl = av_mallocz(sizeof(PacketListEntry));
     int ret;
 
     if (!pktl)
@@ -763,11 +763,11 @@  int avpriv_packet_list_put(AVPacketList **packet_buffer,
     return 0;
 }
 
-int avpriv_packet_list_get(AVPacketList **pkt_buffer,
-                           AVPacketList **pkt_buffer_end,
+int avpriv_packet_list_get(PacketListEntry **pkt_buffer,
+                           PacketListEntry **pkt_buffer_end,
                            AVPacket      *pkt)
 {
-    AVPacketList *pktl;
+    PacketListEntry *pktl;
     if (!*pkt_buffer)
         return AVERROR(EAGAIN);
     pktl        = *pkt_buffer;
@@ -779,12 +779,12 @@  int avpriv_packet_list_get(AVPacketList **pkt_buffer,
     return 0;
 }
 
-void avpriv_packet_list_free(AVPacketList **pkt_buf, AVPacketList **pkt_buf_end)
+void avpriv_packet_list_free(PacketListEntry **pkt_buf, PacketListEntry **pkt_buf_end)
 {
-    AVPacketList *tmp = *pkt_buf;
+    PacketListEntry *tmp = *pkt_buf;
 
     while (tmp) {
-        AVPacketList *pktl = tmp;
+        PacketListEntry *pktl = tmp;
         tmp = pktl->next;
         av_packet_unref(&pktl->pkt);
         av_freep(&pktl);
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 17defb9b50..c72cce869e 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -31,6 +31,7 @@ 
 #include "libavutil/mathematics.h"
 #include "libavutil/pixfmt.h"
 #include "avcodec.h"
+#include "packet_internal.h"
 #include "config.h"
 
 /**
@@ -145,8 +146,8 @@  typedef struct AVCodecInternal {
      * for decoding.
      */
     AVPacket *last_pkt_props;
-    AVPacketList *pkt_props;
-    AVPacketList *pkt_props_tail;
+    PacketListEntry *pkt_props;
+    PacketListEntry *pkt_props_tail;
 
     /**
      * temporary buffer used for encoders to store their bitstream
diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h
index 9b9bef94f0..33c9513f16 100644
--- a/libavcodec/packet_internal.h
+++ b/libavcodec/packet_internal.h
@@ -41,7 +41,7 @@  typedef struct PacketListEntry {
  * @return 0 on success, negative AVERROR value on failure. On failure,
            the packet and the list are unchanged.
  */
-int avpriv_packet_list_put(AVPacketList **head, AVPacketList **tail,
+int avpriv_packet_list_put(PacketListEntry **head, PacketListEntry **tail,
                            AVPacket *pkt,
                            int (*copy)(AVPacket *dst, const AVPacket *src),
                            int flags);
@@ -58,7 +58,7 @@  int avpriv_packet_list_put(AVPacketList **head, AVPacketList **tail,
  * @return 0 on success, and a packet is returned. AVERROR(EAGAIN) if
  *         the list was empty.
  */
-int avpriv_packet_list_get(AVPacketList **head, AVPacketList **tail,
+int avpriv_packet_list_get(PacketListEntry **head, PacketListEntry **tail,
                            AVPacket *pkt);
 
 /**
@@ -67,7 +67,7 @@  int avpriv_packet_list_get(AVPacketList **head, AVPacketList **tail,
  * @param head List head element
  * @param tail List tail element
  */
-void avpriv_packet_list_free(AVPacketList **head, AVPacketList **tail);
+void avpriv_packet_list_free(PacketListEntry **head, PacketListEntry **tail);
 
 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type);
 
diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index c4ffe9f6d0..7c28109814 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -37,7 +37,7 @@  typedef struct AIFFOutputContext {
     int64_t frames;
     int64_t ssnd;
     int audio_stream_idx;
-    AVPacketList *pict_list, *pict_list_end;
+    PacketListEntry *pict_list, *pict_list_end;
     int write_id3v2;
     int id3v2_version;
 } AIFFOutputContext;
@@ -48,7 +48,7 @@  static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff)
     uint64_t pos, end, size;
     ID3v2EncContext id3v2 = { 0 };
     AVIOContext *pb = s->pb;
-    AVPacketList *pict_list = aiff->pict_list;
+    PacketListEntry *pict_list = aiff->pict_list;
 
     if (!s->metadata && !s->nb_chapters && !aiff->pict_list)
         return 0;
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 6b8ce8d7ee..a24d3be85d 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 */
-    AVPacketList *queue, *queue_end;
+    PacketListEntry *queue, *queue_end;
 
     /* updated streaminfo sent by the encoder at the end */
     uint8_t streaminfo[FLAC_STREAMINFO_SIZE];
diff --git a/libavformat/internal.h b/libavformat/internal.h
index c29c7deec7..d366bdc452 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -74,8 +74,8 @@  struct AVFormatInternal {
      * not decoded, for example to get the codec parameters in MPEG
      * streams.
      */
-    struct AVPacketList *packet_buffer;
-    struct AVPacketList *packet_buffer_end;
+    struct PacketListEntry *packet_buffer;
+    struct PacketListEntry *packet_buffer_end;
 
     /* av_seek_frame() support */
     int64_t data_offset; /**< offset of the first packet */
@@ -86,13 +86,13 @@  struct AVFormatInternal {
      * be identified, as parsing cannot be done without knowing the
      * codec.
      */
-    struct AVPacketList *raw_packet_buffer;
-    struct AVPacketList *raw_packet_buffer_end;
+    struct PacketListEntry *raw_packet_buffer;
+    struct PacketListEntry *raw_packet_buffer_end;
     /**
      * Packets split by the parser get queued here.
      */
-    struct AVPacketList *parse_queue;
-    struct AVPacketList *parse_queue_end;
+    struct PacketListEntry *parse_queue;
+    struct PacketListEntry *parse_queue_end;
     /**
      * Remaining size available for raw_packet_buffer, in bytes.
      */
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 981e044263..0970e1d1ef 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -366,8 +366,8 @@  typedef struct MatroskaDemuxContext {
     int64_t segment_start;
 
     /* the packet queue */
-    AVPacketList *queue;
-    AVPacketList *queue_end;
+    PacketListEntry *queue;
+    PacketListEntry *queue_end;
 
     int done;
 
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 4f91c4f1c3..fddde33400 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 */
-    AVPacketList *queue, *queue_end;
+    PacketListEntry *queue, *queue_end;
 } MP3Context;
 
 static const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}};
diff --git a/libavformat/mux.c b/libavformat/mux.c
index d60bf2218b..cf52de5366 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -813,11 +813,11 @@  int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
                              int (*compare)(AVFormatContext *, const AVPacket *, const AVPacket *))
 {
     int ret;
-    AVPacketList **next_point, *this_pktl;
+    PacketListEntry **next_point, *this_pktl;
     AVStream *st = s->streams[pkt->stream_index];
     int chunked  = s->max_chunk_size || s->max_chunk_duration;
 
-    this_pktl    = av_malloc(sizeof(AVPacketList));
+    this_pktl    = av_malloc(sizeof(PacketListEntry));
     if (!this_pktl) {
         av_packet_unref(pkt);
         return AVERROR(ENOMEM);
@@ -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 = (AVPacketList **)&(st->internal->last_in_packet_buffer->next);
+        next_point = &(st->internal->last_in_packet_buffer->next);
     } else {
         next_point = &s->internal->packet_buffer;
     }
@@ -877,7 +877,7 @@  next_non_null:
     this_pktl->next = *next_point;
 
     *next_point = this_pktl;
-    st->internal->last_in_packet_buffer = (PacketListEntry *)this_pktl;
+    st->internal->last_in_packet_buffer = this_pktl;
 
     return 0;
 }
@@ -915,7 +915,7 @@  static int interleave_compare_dts(AVFormatContext *s, const AVPacket *next,
 int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
                                  AVPacket *pkt, int flush)
 {
-    AVPacketList *pktl;
+    PacketListEntry *pktl;
     int stream_count = 0;
     int noninterleaved_count = 0;
     int i, ret;
@@ -1001,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 == (PacketListEntry *)pktl)
+            if (st->internal->last_in_packet_buffer == pktl)
                 st->internal->last_in_packet_buffer = NULL;
 
             av_packet_unref(&pktl->pkt);
@@ -1020,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 == (PacketListEntry *)pktl)
+        if (st->internal->last_in_packet_buffer == pktl)
             st->internal->last_in_packet_buffer = NULL;
         av_freep(&pktl);
 
@@ -1033,7 +1033,7 @@  int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
 int ff_interleaved_peek(AVFormatContext *s, int stream,
                         AVPacket *pkt, int add_offset)
 {
-    AVPacketList *pktl = s->internal->packet_buffer;
+    PacketListEntry *pktl = s->internal->packet_buffer;
     while (pktl) {
         if (pktl->pkt.stream_index == stream) {
             *pkt = pktl->pkt;
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index c7f98ac257..8f2649c31f 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -3053,23 +3053,23 @@  static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
         stream_count += !!s->streams[i]->internal->last_in_packet_buffer;
 
     if (stream_count && (s->nb_streams == stream_count || flush)) {
-        AVPacketList *pktl = s->internal->packet_buffer;
+        PacketListEntry *pktl = s->internal->packet_buffer;
         if (s->nb_streams != stream_count) {
-            AVPacketList *last = NULL;
+            PacketListEntry *last = NULL;
             // find last packet in edit unit
             while (pktl) {
                 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 != (PacketListEntry *)pktl)
-                    s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer = (PacketListEntry *)pktl;
+                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;
                 last = pktl;
                 pktl = pktl->next;
                 stream_count--;
             }
             // purge packet queue
             while (pktl) {
-                AVPacketList *next = pktl->next;
+                PacketListEntry *next = pktl->next;
                 av_packet_unref(&pktl->pkt);
                 av_freep(&pktl);
                 pktl = next;
@@ -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 == (PacketListEntry *)pktl)
+        if(s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer == pktl)
             s->streams[pktl->pkt.stream_index]->internal->last_in_packet_buffer= NULL;
         if(!s->internal->packet_buffer)
             s->internal->packet_buffer_end= NULL;
diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c
index 92f5053d52..39d9034f68 100644
--- a/libavformat/ttaenc.c
+++ b/libavformat/ttaenc.c
@@ -30,7 +30,7 @@ 
 
 typedef struct TTAMuxContext {
     AVIOContext *seek_table;
-    AVPacketList *queue, *queue_end;
+    PacketListEntry *queue, *queue_end;
     uint32_t nb_samples;
     int frame_size;
     int last_frame;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 0391e0da13..20bf723a55 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -799,7 +799,7 @@  int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
     av_init_packet(pkt);
 
     for (;;) {
-        AVPacketList *pktl = s->internal->raw_packet_buffer;
+        PacketListEntry *pktl = s->internal->raw_packet_buffer;
         const AVPacket *pkt1;
 
         if (pktl) {
@@ -1007,7 +1007,7 @@  static int has_decode_delay_been_guessed(AVStream *st)
         return st->internal->nb_decoded_frames >= 20;
 }
 
-static AVPacketList *get_next_pkt(AVFormatContext *s, AVStream *st, AVPacketList *pktl)
+static PacketListEntry *get_next_pkt(AVFormatContext *s, AVStream *st, PacketListEntry *pktl)
 {
     if (pktl->next)
         return pktl->next;
@@ -1063,7 +1063,7 @@  static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t
  * of the packets in a window.
  */
 static void update_dts_from_pts(AVFormatContext *s, int stream_index,
-                                AVPacketList *pkt_buffer)
+                                PacketListEntry *pkt_buffer)
 {
     AVStream *st       = s->streams[stream_index];
     int delay          = st->internal->avctx->has_b_frames;
@@ -1092,8 +1092,8 @@  static void update_initial_timestamps(AVFormatContext *s, int stream_index,
                                       int64_t dts, int64_t pts, AVPacket *pkt)
 {
     AVStream *st       = s->streams[stream_index];
-    AVPacketList *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue;
-    AVPacketList *pktl_it;
+    PacketListEntry *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue;
+    PacketListEntry *pktl_it;
 
     uint64_t shift;
 
@@ -1143,7 +1143,7 @@  static void update_initial_timestamps(AVFormatContext *s, int stream_index,
 static void update_initial_durations(AVFormatContext *s, AVStream *st,
                                      int stream_index, int64_t duration)
 {
-    AVPacketList *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue;
+    PacketListEntry *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue;
     int64_t cur_dts    = RELATIVE_TS_BASE;
 
     if (st->first_dts != AV_NOPTS_VALUE) {
@@ -1727,7 +1727,7 @@  int av_read_frame(AVFormatContext *s, AVPacket *pkt)
     }
 
     for (;;) {
-        AVPacketList *pktl = s->internal->packet_buffer;
+        PacketListEntry *pktl = s->internal->packet_buffer;
 
         if (pktl) {
             AVPacket *next_pkt = &pktl->pkt;