History

avcodec/packet_internal: Add proper PacketList struct

Up until now, we had a PacketList structure which is actually a PacketListEntry; a proper PacketList did not exist and all the related functions just passed pointers to pointers to the head and tail elements around. All these pointers were actually consecutive elements of their containing structs, i.e. the users already treated them as if they were a struct. So add a proper PacketList struct and rename the current PacketList to PacketListEntry; also make the functions use this structure instead of the pair of pointers.

Andreas Rheinhardt committed 4 years ago

Commit d61240f1 parent b74e47c20 files · +153 −175Browse files

Unified · Split

20 files
  1. libavcodec/avpacket.c +16 −20
  2. libavcodec/packet_internal.h +11 −14
  3. libavdevice/decklink_common.h +4 −1
  4. libavdevice/decklink_dec.cpp +14 −15
  5. libavdevice/dshow.c +5 −5
  6. libavdevice/dshow_capture.h +1 −1
  7. libavdevice/vfwcap.c +6 −6
  8. libavformat/aiffenc.c +8 −9
  9. libavformat/demux.c +24 −30
  10. libavformat/flacenc.c +5 −5
  11. libavformat/internal.h +5 −7
  12. libavformat/matroskadec.c +9 −10
  13. libavformat/movenc.c +2 −4
  14. libavformat/movenc.h +1 −1
  15. libavformat/movenc_ttml.c +2 −4
  16. libavformat/mp3enc.c +5 −6
  17. libavformat/mux.c +19 −19
  18. libavformat/mxfenc.c +7 −7
  19. libavformat/ttaenc.c +6 −7
  20. libavformat/utils.c +3 −4
libavcodec/avpacket.c+16−20
@@ -535,13 +535,12 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb) · 534 unmodified lines
535535 pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
536536 }
537537
538−int avpriv_packet_list_put(PacketList **packet_buffer,
539− PacketList **plast_pktl,
538+int avpriv_packet_list_put(PacketList *packet_buffer,
540539 AVPacket *pkt,
541540 int (*copy)(AVPacket *dst, const AVPacket *src),
542541 int flags)
543542 {
544− PacketList *pktl = av_malloc(sizeof(PacketList));
543+ PacketListEntry *pktl = av_malloc(sizeof(*pktl));
545544 int ret;
546545
547546 if (!pktl)
@@ -565,44 +564,41 @@ int avpriv_packet_list_put(PacketList **packet_buffer, · 17 unmodified lines
565564
566565 pktl->next = NULL;
567566
568− if (*packet_buffer)
569− (*plast_pktl)->next = pktl;
567+ if (packet_buffer->head)
568+ packet_buffer->tail->next = pktl;
570569 else
571− *packet_buffer = pktl;
570+ packet_buffer->head = pktl;
572571
573572 /* Add the packet in the buffered packet list. */
574− *plast_pktl = pktl;
573+ packet_buffer->tail = pktl;
575574 return 0;
576575 }
577576
578−int avpriv_packet_list_get(PacketList **pkt_buffer,
579− PacketList **pkt_buffer_end,
577+int avpriv_packet_list_get(PacketList *pkt_buffer,
580578 AVPacket *pkt)
581579 {
582− PacketList *pktl;
583− if (!*pkt_buffer)
580+ PacketListEntry *pktl = pkt_buffer->head;
581+ if (!pktl)
584582 return AVERROR(EAGAIN);
585− pktl = *pkt_buffer;
586583 *pkt = pktl->pkt;
587− *pkt_buffer = pktl->next;
588− if (!pktl->next)
589− *pkt_buffer_end = NULL;
584+ pkt_buffer->head = pktl->next;
585+ if (!pkt_buffer->head)
586+ pkt_buffer->tail = NULL;
590587 av_freep(&pktl);
591588 return 0;
592589 }
593590
594−void avpriv_packet_list_free(PacketList **pkt_buf, PacketList **pkt_buf_end)
591+void avpriv_packet_list_free(PacketList *pkt_buf)
595592 {
596− PacketList *tmp = *pkt_buf;
593+ PacketListEntry *tmp = pkt_buf->head;
597594
598595 while (tmp) {
599− PacketList *pktl = tmp;
596+ PacketListEntry *pktl = tmp;
600597 tmp = pktl->next;
601598 av_packet_unref(&pktl->pkt);
602599 av_freep(&pktl);
603600 }
604− *pkt_buf = NULL;
605− *pkt_buf_end = NULL;
601+ pkt_buf->head = pkt_buf->tail = NULL;
606602 }
607603
608604 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
libavcodec/packet_internal.h+11−14
@@ -23,16 +23,19 @@ · 22 unmodified lines
2323
2424 #include "packet.h"
2525
26−typedef struct PacketList {
27− struct PacketList *next;
26+typedef struct PacketListEntry {
27+ struct PacketListEntry *next;
2828 AVPacket pkt;
29+} PacketListEntry;
30+
31+typedef struct PacketList {
32+ PacketListEntry *head, *tail;
2933 } PacketList;
3034
3135 /**
3236 * Append an AVPacket to the list.
3337 *
34− * @param head List head element
35− * @param tail List tail element
38+ * @param list A PacketList
3639 * @param pkt The packet being appended. The data described in it will
3740 * be made reference counted if it isn't already.
3841 * @param copy A callback to copy the contents of the packet to the list.
@@ -41,8 +44,7 @@ typedef struct PacketList { · 2 unmodified lines
4144 * @return 0 on success, negative AVERROR value on failure. On failure,
4245 the packet and the list are unchanged.
4346 */
44−int avpriv_packet_list_put(PacketList **head, PacketList **tail,
45− AVPacket *pkt,
47+int avpriv_packet_list_put(PacketList *list, AVPacket *pkt,
4648 int (*copy)(AVPacket *dst, const AVPacket *src),
4749 int flags);
4850
@@ -52,22 +54,17 @@ int avpriv_packet_list_put(PacketList **head, PacketList **tail, · 3 unmodified lines
5254 * @note The pkt will be overwritten completely on success. The caller
5355 * owns the packet and must unref it by itself.
5456 *
55− * @param head List head element
56− * @param tail List tail element
57+ * @param head A pointer to a PacketList struct
5758 * @param pkt Pointer to an AVPacket struct
5859 * @return 0 on success, and a packet is returned. AVERROR(EAGAIN) if
5960 * the list was empty.
6061 */
61−int avpriv_packet_list_get(PacketList **head, PacketList **tail,
62− AVPacket *pkt);
62+int avpriv_packet_list_get(PacketList *list, AVPacket *pkt);
6363
6464 /**
6565 * Wipe the list and unref all the packets in it.
66− *
67− * @param head List head element
68− * @param tail List tail element
6966 */
70−void avpriv_packet_list_free(PacketList **head, PacketList **tail);
67+void avpriv_packet_list_free(PacketList *list);
7168
7269 int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type);
7370
libavdevice/decklink_common.h+4−1
@@ -29,6 +29,9 @@ · 28 unmodified lines
2929 #define IDeckLinkProfileAttributes IDeckLinkAttributes
3030 #endif
3131
32+extern "C" {
33+#include "libavcodec/packet_internal.h"
34+}
3235 #include "libavutil/thread.h"
3336 #include "decklink_common_c.h"
3437 #if CONFIG_LIBKLVANC
@@ -75,7 +78,7 @@ class decklink_output_callback; · 40 unmodified lines
7578 class decklink_input_callback;
7679
7780 typedef struct AVPacketQueue {
78− PacketList *first_pkt, *last_pkt;
81+ PacketList pkt_list;
7982 int nb_packets;
8083 unsigned long long size;
8184 int abort_request;
libavdevice/decklink_dec.cpp+14−15
@@ -483,16 +483,16 @@ static void avpacket_queue_init(AVFormatContext *avctx, AVPacketQueue *q) · 482 unmodified lines
483483
484484 static void avpacket_queue_flush(AVPacketQueue *q)
485485 {
486− PacketList *pkt, *pkt1;
486+ PacketListEntry *pkt, *pkt1;
487487
488488 pthread_mutex_lock(&q->mutex);
489− for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) {
489+ for (pkt = q->pkt_list.head; pkt != NULL; pkt = pkt1) {
490490 pkt1 = pkt->next;
491491 av_packet_unref(&pkt->pkt);
492492 av_freep(&pkt);
493493 }
494− q->last_pkt = NULL;
495− q->first_pkt = NULL;
494+ q->pkt_list.head = NULL;
495+ q->pkt_list.tail = NULL;
496496 q->nb_packets = 0;
497497 q->size = 0;
498498 pthread_mutex_unlock(&q->mutex);
@@ -516,7 +516,7 @@ static unsigned long long avpacket_queue_size(AVPacketQueue *q) · 17 unmodified lines
516516
517517 static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt)
518518 {
519− PacketList *pkt1;
519+ PacketListEntry *pkt1;
520520
521521 // Drop Packet if queue size is > maximum queue size
522522 if (avpacket_queue_size(q) > (uint64_t)q->max_q_size) {
@@ -530,7 +530,7 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) · 7 unmodified lines
530530 return -1;
531531 }
532532
533− pkt1 = (PacketList *)av_malloc(sizeof(PacketList));
533+ pkt1 = (PacketListEntry *)av_malloc(sizeof(*pkt1));
534534 if (!pkt1) {
535535 av_packet_unref(pkt);
536536 return -1;
@@ -540,13 +540,13 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) · 3 unmodified lines
540540
541541 pthread_mutex_lock(&q->mutex);
542542
543− if (!q->last_pkt) {
544− q->first_pkt = pkt1;
543+ if (!q->pkt_list.tail) {
544+ q->pkt_list.head = pkt1;
545545 } else {
546− q->last_pkt->next = pkt1;
546+ q->pkt_list.tail->next = pkt1;
547547 }
548548
549− q->last_pkt = pkt1;
549+ q->pkt_list.tail = pkt1;
550550 q->nb_packets++;
551551 q->size += pkt1->pkt.size + sizeof(*pkt1);
552552
@@ -558,17 +558,16 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) · 5 unmodified lines
558558
559559 static int avpacket_queue_get(AVPacketQueue *q, AVPacket *pkt, int block)
560560 {
561− PacketList *pkt1;
562561 int ret;
563562
564563 pthread_mutex_lock(&q->mutex);
565564
566565 for (;; ) {
567− pkt1 = q->first_pkt;
566+ PacketListEntry *pkt1 = q->pkt_list.head;
568567 if (pkt1) {
569− q->first_pkt = pkt1->next;
570− if (!q->first_pkt) {
571− q->last_pkt = NULL;
568+ q->pkt_list.head = pkt1->next;
569+ if (!q->pkt_list.head) {
570+ q->pkt_list.tail = NULL;
572571 }
573572 q->nb_packets--;
574573 q->size -= pkt1->pkt.size + sizeof(*pkt1);
libavdevice/dshow.c+5−5
@@ -238,7 +238,7 @@ static int · 237 unmodified lines
238238 dshow_read_close(AVFormatContext *s)
239239 {
240240 struct dshow_ctx *ctx = s->priv_data;
241− PacketList *pktl;
241+ PacketListEntry *pktl;
242242
243243 if (ctx->control) {
244244 IMediaControl_Stop(ctx->control);
@@ -298,7 +298,7 @@ dshow_read_close(AVFormatContext *s) · 53 unmodified lines
298298
299299 pktl = ctx->pktl;
300300 while (pktl) {
301− PacketList *next = pktl->next;
301+ PacketListEntry *next = pktl->next;
302302 av_packet_unref(&pktl->pkt);
303303 av_free(pktl);
304304 pktl = next;
@@ -342,7 +342,7 @@ callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, e · 37 unmodified lines
342342 {
343343 AVFormatContext *s = priv_data;
344344 struct dshow_ctx *ctx = s->priv_data;
345− PacketList **ppktl, *pktl_next;
345+ PacketListEntry **ppktl, *pktl_next;
346346
347347 // dump_videohdr(s, vdhdr);
348348
@@ -351,7 +351,7 @@ callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, e · 2 unmodified lines
351351 if(shall_we_drop(s, index, devtype))
352352 goto fail;
353353
354− pktl_next = av_mallocz(sizeof(PacketList));
354+ pktl_next = av_mallocz(sizeof(*pktl_next));
355355 if(!pktl_next)
356356 goto fail;
357357
@@ -1868,7 +1868,7 @@ static int dshow_check_event_queue(IMediaEvent *media_event) · 1510 unmodified lines
18681868 static int dshow_read_packet(AVFormatContext *s, AVPacket *pkt)
18691869 {
18701870 struct dshow_ctx *ctx = s->priv_data;
1871− PacketList *pktl = NULL;
1871+ PacketListEntry *pktl = NULL;
18721872
18731873 while (!ctx->eof && !pktl) {
18741874 WaitForSingleObject(ctx->mutex, INFINITE);
libavdevice/dshow_capture.h+1−1
@@ -322,7 +322,7 @@ struct dshow_ctx { · 321 unmodified lines
322322 HANDLE mutex;
323323 HANDLE event[2]; /* event[0] is set by DirectShow
324324 * event[1] is set by callback() */
325− PacketList *pktl;
325+ PacketListEntry *pktl;
326326
327327 int eof;
328328
libavdevice/vfwcap.c+6−6
@@ -45,7 +45,7 @@ struct vfw_ctx { · 44 unmodified lines
4545 HWND hwnd;
4646 HANDLE mutex;
4747 HANDLE event;
48− PacketList *pktl;
48+ PacketListEntry *pktl;
4949 unsigned int curbufsize;
5050 unsigned int frame_num;
5151 char *video_size; /**< A string describing video size, set by a private option. */
@@ -179,7 +179,7 @@ static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr) · 127 unmodified lines
179179 {
180180 AVFormatContext *s;
181181 struct vfw_ctx *ctx;
182− PacketList **ppktl, *pktl_next;
182+ PacketListEntry **ppktl, *pktl_next;
183183
184184 s = (AVFormatContext *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
185185 ctx = s->priv_data;
@@ -191,7 +191,7 @@ static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr) · 5 unmodified lines
191191
192192 WaitForSingleObject(ctx->mutex, INFINITE);
193193
194− pktl_next = av_mallocz(sizeof(PacketList));
194+ pktl_next = av_mallocz(sizeof(*pktl_next));
195195 if(!pktl_next)
196196 goto fail;
197197
@@ -220,7 +220,7 @@ fail: · 22 unmodified lines
220220 static int vfw_read_close(AVFormatContext *s)
221221 {
222222 struct vfw_ctx *ctx = s->priv_data;
223− PacketList *pktl;
223+ PacketListEntry *pktl;
224224
225225 if(ctx->hwnd) {
226226 SendMessage(ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
@@ -234,7 +234,7 @@ static int vfw_read_close(AVFormatContext *s) · 7 unmodified lines
234234
235235 pktl = ctx->pktl;
236236 while (pktl) {
237− PacketList *next = pktl->next;
237+ PacketListEntry *next = pktl->next;
238238 av_packet_unref(&pktl->pkt);
239239 av_free(pktl);
240240 pktl = next;
@@ -440,7 +440,7 @@ fail: · 199 unmodified lines
440440 static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)
441441 {
442442 struct vfw_ctx *ctx = s->priv_data;
443− PacketList *pktl = NULL;
443+ PacketListEntry *pktl = NULL;
444444
445445 while(!pktl) {
446446 WaitForSingleObject(ctx->mutex, INFINITE);
libavformat/aiffenc.c+8−9
@@ -37,7 +37,7 @@ typedef struct AIFFOutputContext { · 36 unmodified lines
3737 int64_t frames;
3838 int64_t ssnd;
3939 int audio_stream_idx;
40− PacketList *pict_list, *pict_list_end;
40+ PacketList pict_list;
4141 int write_id3v2;
4242 int id3v2_version;
4343 } AIFFOutputContext;
@@ -48,9 +48,9 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff) · 4 unmodified lines
4848 uint64_t pos, end, size;
4949 ID3v2EncContext id3v2 = { 0 };
5050 AVIOContext *pb = s->pb;
51− PacketList *pict_list = aiff->pict_list;
51+ PacketListEntry *list_entry = aiff->pict_list.head;
5252
53− if (!s->metadata && !s->nb_chapters && !aiff->pict_list)
53+ if (!s->metadata && !s->nb_chapters && !list_entry)
5454 return 0;
5555
5656 avio_wl32(pb, MKTAG('I', 'D', '3', ' '));
@@ -59,10 +59,10 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff) · 2 unmodified lines
5959
6060 ff_id3v2_start(&id3v2, pb, aiff->id3v2_version, ID3v2_DEFAULT_MAGIC);
6161 ff_id3v2_write_metadata(s, &id3v2);
62− while (pict_list) {
63− if ((ret = ff_id3v2_write_apic(s, &id3v2, &pict_list->pkt)) < 0)
62+ while (list_entry) {
63+ if ((ret = ff_id3v2_write_apic(s, &id3v2, &list_entry->pkt)) < 0)
6464 return ret;
65− pict_list = pict_list->next;
65+ list_entry = list_entry->next;
6666 }
6767 ff_id3v2_finish(&id3v2, pb, s->metadata_header_padding);
6868
@@ -218,8 +218,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt) · 149 unmodified lines
218218 if (s->streams[pkt->stream_index]->nb_frames >= 1)
219219 return 0;
220220
221− return avpriv_packet_list_put(&aiff->pict_list, &aiff->pict_list_end,
222− pkt, NULL, 0);
221+ return avpriv_packet_list_put(&aiff->pict_list, pkt, NULL, 0);
223222 }
224223
225224 return 0;
@@ -265,7 +264,7 @@ static void aiff_deinit(AVFormatContext *s) · 39 unmodified lines
265264 {
266265 AIFFOutputContext *aiff = s->priv_data;
267266
268− avpriv_packet_list_free(&aiff->pict_list, &aiff->pict_list_end);
267+ avpriv_packet_list_free(&aiff->pict_list);
269268 }
270269
271270 #define OFFSET(x) offsetof(AIFFOutputContext, x)
libavformat/demux.c+24−30
@@ -537,7 +537,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 536 unmodified lines
537537 #endif
538538
539539 for (;;) {
540− PacketList *pktl = si->raw_packet_buffer;
540+ PacketListEntry *pktl = si->raw_packet_buffer.head;
541541 AVStream *st;
542542 FFStream *sti;
543543 const AVPacket *pkt1;
@@ -548,8 +548,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 4 unmodified lines
548548 if ((err = probe_codec(s, st, NULL)) < 0)
549549 return err;
550550 if (ffstream(st)->request_probe <= 0) {
551− avpriv_packet_list_get(&si->raw_packet_buffer,
552− &si->raw_packet_buffer_end, pkt);
551+ avpriv_packet_list_get(&si->raw_packet_buffer, pkt);
553552 si->raw_packet_buffer_size -= pkt->size;
554553 return 0;
555554 }
@@ -624,13 +623,12 @@ FF_ENABLE_DEPRECATION_WARNINGS · 68 unmodified lines
624623 return 0;
625624
626625 err = avpriv_packet_list_put(&si->raw_packet_buffer,
627− &si->raw_packet_buffer_end,
628626 pkt, NULL, 0);
629627 if (err < 0) {
630628 av_packet_unref(pkt);
631629 return err;
632630 }
633− pkt1 = &si->raw_packet_buffer_end->pkt;
631+ pkt1 = &si->raw_packet_buffer.tail->pkt;
634632 si->raw_packet_buffer_size += pkt1->size;
635633
636634 if ((err = probe_codec(s, st, pkt1)) < 0)
@@ -716,13 +714,14 @@ static int has_decode_delay_been_guessed(AVStream *st) · 79 unmodified lines
716714 return sti->nb_decoded_frames >= 20;
717715 }
718716
719−static PacketList *get_next_pkt(AVFormatContext *s, AVStream *st, PacketList *pktl)
717+static PacketListEntry *get_next_pkt(AVFormatContext *s, AVStream *st,
718+ PacketListEntry *pktl)
720719 {
721720 FFFormatContext *const si = ffformatcontext(s);
722721 if (pktl->next)
723722 return pktl->next;
724− if (pktl == si->packet_buffer_end)
725− return si->parse_queue;
723+ if (pktl == si->packet_buffer.tail)
724+ return si->parse_queue.head;
726725 return NULL;
727726 }
728727
@@ -774,7 +773,7 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t · 45 unmodified lines
774773 * of the packets in a window.
775774 */
776775 static void update_dts_from_pts(AVFormatContext *s, int stream_index,
777− PacketList *pkt_buffer)
776+ PacketListEntry *pkt_buffer)
778777 {
779778 AVStream *const st = s->streams[stream_index];
780779 int delay = ffstream(st)->avctx->has_b_frames;
@@ -804,7 +803,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, · 23 unmodified lines
804803 FFFormatContext *const si = ffformatcontext(s);
805804 AVStream *const st = s->streams[stream_index];
806805 FFStream *const sti = ffstream(st);
807− PacketList *pktl = si->packet_buffer ? si->packet_buffer : si->parse_queue;
806+ PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head;
808807
809808 uint64_t shift;
810809
@@ -823,7 +822,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, · 12 unmodified lines
823822 if (is_relative(pts))
824823 pts += shift;
825824
826− for (PacketList *pktl_it = pktl; pktl_it; pktl_it = get_next_pkt(s, st, pktl_it)) {
825+ for (PacketListEntry *pktl_it = pktl; pktl_it; pktl_it = get_next_pkt(s, st, pktl_it)) {
827826 if (pktl_it->pkt.stream_index != stream_index)
828827 continue;
829828 if (is_relative(pktl_it->pkt.pts))
@@ -856,7 +855,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, · 26 unmodified lines
856855 {
857856 FFFormatContext *const si = ffformatcontext(s);
858857 FFStream *const sti = ffstream(st);
859− PacketList *pktl = si->packet_buffer ? si->packet_buffer : si->parse_queue;
858+ PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head;
860859 int64_t cur_dts = RELATIVE_TS_BASE;
861860
862861 if (sti->first_dts != AV_NOPTS_VALUE) {
@@ -882,7 +881,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, · 19 unmodified lines
882881 av_log(s, AV_LOG_DEBUG, "first_dts %s but no packet with dts in the queue\n", av_ts2str(sti->first_dts));
883882 return;
884883 }
885− pktl = si->packet_buffer ? si->packet_buffer : si->parse_queue;
884+ pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head;
886885 sti->first_dts = cur_dts;
887886 } else if (sti->cur_dts != RELATIVE_TS_BASE)
888887 return;
@@ -998,7 +997,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, · 109 unmodified lines
998997 }
999998 }
1000999
1001− if (pkt->duration > 0 && (si->packet_buffer || si->parse_queue))
1000+ if (pkt->duration > 0 && (si->packet_buffer.head || si->parse_queue.head))
10021001 update_initial_durations(s, st, pkt->stream_index, pkt->duration);
10031002
10041003 /* Correct timestamps with byte offset if demuxers only have timestamps
@@ -1195,7 +1194,6 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, · 190 unmodified lines
11951194 compute_pkt_fields(s, st, sti->parser, out_pkt, next_dts, next_pts);
11961195
11971196 ret = avpriv_packet_list_put(&si->parse_queue,
1198− &si->parse_queue_end,
11991197 out_pkt, NULL, 0);
12001198 if (ret < 0)
12011199 goto fail;
@@ -1225,7 +1223,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 23 unmodified lines
12251223 int ret, got_packet = 0;
12261224 AVDictionary *metadata = NULL;
12271225
1228− while (!got_packet && !si->parse_queue) {
1226+ while (!got_packet && !si->parse_queue.head) {
12291227 AVStream *st;
12301228 FFStream *sti;
12311229
@@ -1338,8 +1336,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 106 unmodified lines
13381336 }
13391337 }
13401338
1341− if (!got_packet && si->parse_queue)
1342− ret = avpriv_packet_list_get(&si->parse_queue, &si->parse_queue_end, pkt);
1339+ if (!got_packet && si->parse_queue.head)
1340+ ret = avpriv_packet_list_get(&si->parse_queue, pkt);
13431341
13441342 if (ret >= 0) {
13451343 AVStream *const st = s->streams[pkt->stream_index];
@@ -1420,9 +1418,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 74 unmodified lines
14201418 AVStream *st;
14211419
14221420 if (!genpts) {
1423− ret = si->packet_buffer
1424− ? avpriv_packet_list_get(&si->packet_buffer,
1425− &si->packet_buffer_end, pkt)
1421+ ret = si->packet_buffer.head
1422+ ? avpriv_packet_list_get(&si->packet_buffer, pkt)
14261423 : read_frame_internal(s, pkt);
14271424 if (ret < 0)
14281425 return ret;
@@ -1430,7 +1427,7 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 1 unmodified line
14301427 }
14311428
14321429 for (;;) {
1433− PacketList *pktl = si->packet_buffer;
1430+ PacketListEntry *pktl = si->packet_buffer.head;
14341431
14351432 if (pktl) {
14361433 AVPacket *next_pkt = &pktl->pkt;
@@ -1463,15 +1460,14 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 26 unmodified lines
14631460 // 3. the packets for this stream at the end of the files had valid dts.
14641461 next_pkt->pts = last_dts + next_pkt->duration;
14651462 }
1466− pktl = si->packet_buffer;
1463+ pktl = si->packet_buffer.head;
14671464 }
14681465
14691466 /* read packet from packet buffer, if there is data */
14701467 st = s->streams[next_pkt->stream_index];
14711468 if (!(next_pkt->pts == AV_NOPTS_VALUE && st->discard < AVDISCARD_ALL &&
14721469 next_pkt->dts != AV_NOPTS_VALUE && !eof)) {
1473− ret = avpriv_packet_list_get(&si->packet_buffer,
1474− &si->packet_buffer_end, pkt);
1470+ ret = avpriv_packet_list_get(&si->packet_buffer, pkt);
14751471 goto return_packet;
14761472 }
14771473 }
@@ -1486,7 +1482,6 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 8 unmodified lines
14861482 }
14871483
14881484 ret = avpriv_packet_list_put(&si->packet_buffer,
1489− &si->packet_buffer_end,
14901485 pkt, NULL, 0);
14911486 if (ret < 0) {
14921487 av_packet_unref(pkt);
@@ -2598,12 +2593,11 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 1105 unmodified lines
25982593
25992594 if (!(ic->flags & AVFMT_FLAG_NOBUFFER)) {
26002595 ret = avpriv_packet_list_put(&si->packet_buffer,
2601− &si->packet_buffer_end,
26022596 pkt1, NULL, 0);
26032597 if (ret < 0)
26042598 goto unref_then_goto_end;
26052599
2606− pkt = &si->packet_buffer_end->pkt;
2600+ pkt = &si->packet_buffer.tail->pkt;
26072601 } else {
26082602 pkt = pkt1;
26092603 }
@@ -2751,8 +2745,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 141 unmodified lines
27512745
27522746 // EOF already reached while reading the stream above.
27532747 // So continue with reoordering DTS with whatever delay we have.
2754− if (si->packet_buffer && !has_decode_delay_been_guessed(st)) {
2755− update_dts_from_pts(ic, stream_index, si->packet_buffer);
2748+ if (si->packet_buffer.head && !has_decode_delay_been_guessed(st)) {
2749+ update_dts_from_pts(ic, stream_index, si->packet_buffer.head);
27562750 }
27572751 }
27582752 }
libavformat/flacenc.c+5−5
@@ -40,7 +40,7 @@ typedef struct FlacMuxerContext { · 39 unmodified lines
4040 int audio_stream_idx;
4141 int waiting_pics;
4242 /* audio packets are queued here until we get all the attached pictures */
43− PacketList *queue, *queue_end;
43+ PacketList queue;
4444
4545 /* updated streaminfo sent by the encoder at the end */
4646 uint8_t streaminfo[FLAC_STREAMINFO_SIZE];
@@ -306,8 +306,8 @@ static int flac_queue_flush(AVFormatContext *s) · 259 unmodified lines
306306 if (ret < 0)
307307 write = 0;
308308
309− while (c->queue) {
310− avpriv_packet_list_get(&c->queue, &c->queue_end, pkt);
309+ while (c->queue.head) {
310+ avpriv_packet_list_get(&c->queue, pkt);
311311 if (write && (ret = flac_write_audio_packet(s, pkt)) < 0)
312312 write = 0;
313313 av_packet_unref(pkt);
@@ -347,7 +347,7 @@ static void flac_deinit(struct AVFormatContext *s) · 33 unmodified lines
347347 {
348348 FlacMuxerContext *c = s->priv_data;
349349
350− avpriv_packet_list_free(&c->queue, &c->queue_end);
350+ avpriv_packet_list_free(&c->queue);
351351 for (unsigned i = 0; i < s->nb_streams; i++)
352352 av_packet_free((AVPacket **)&s->streams[i]->priv_data);
353353 }
@@ -360,7 +360,7 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt) · 6 unmodified lines
360360 if (pkt->stream_index == c->audio_stream_idx) {
361361 if (c->waiting_pics) {
362362 /* buffer audio packets until we get all the pictures */
363− ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, NULL, 0);
363+ ret = avpriv_packet_list_put(&c->queue, pkt, NULL, 0);
364364 if (ret < 0) {
365365 av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n");
366366 c->waiting_pics = 0;
libavformat/internal.h+5−7
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525
2626 #include "libavcodec/avcodec.h"
2727 #include "libavcodec/bsf.h"
28+#include "libavcodec/packet_internal.h"
2829
2930 #include "avformat.h"
3031 #include "os_support.h"
@@ -92,8 +93,7 @@ typedef struct FFFormatContext { · 61 unmodified lines
9293 * not decoded, for example to get the codec parameters in MPEG
9394 * streams.
9495 */
95− struct PacketList *packet_buffer;
96− struct PacketList *packet_buffer_end;
96+ PacketList packet_buffer;
9797
9898 /* av_seek_frame() support */
9999 int64_t data_offset; /**< offset of the first packet */
@@ -104,13 +104,11 @@ typedef struct FFFormatContext { · 4 unmodified lines
104104 * be identified, as parsing cannot be done without knowing the
105105 * codec.
106106 */
107− struct PacketList *raw_packet_buffer;
108− struct PacketList *raw_packet_buffer_end;
107+ PacketList raw_packet_buffer;
109108 /**
110109 * Packets split by the parser get queued here.
111110 */
112− struct PacketList *parse_queue;
113− struct PacketList *parse_queue_end;
111+ PacketList parse_queue;
114112 /**
115113 * The generic code uses this as a temporary packet
116114 * to parse packets or for muxing, especially flushing.
@@ -393,7 +391,7 @@ typedef struct FFStream { · 276 unmodified lines
393391 /**
394392 * last packet in packet_buffer for this stream when muxing.
395393 */
396− struct PacketList *last_in_packet_buffer;
394+ PacketListEntry *last_in_packet_buffer;
397395
398396 int64_t last_IP_pts;
399397 int last_IP_duration;
libavformat/matroskadec.c+9−10
@@ -396,8 +396,7 @@ typedef struct MatroskaDemuxContext { · 395 unmodified lines
396396 AVPacket *pkt;
397397
398398 /* the packet queue */
399− PacketList *queue;
400− PacketList *queue_end;
399+ PacketList queue;
401400
402401 int done;
403402
@@ -3112,11 +3111,11 @@ static int matroska_read_header(AVFormatContext *s) · 2708 unmodified lines
31123111 static int matroska_deliver_packet(MatroskaDemuxContext *matroska,
31133112 AVPacket *pkt)
31143113 {
3115− if (matroska->queue) {
3114+ if (matroska->queue.head) {
31163115 MatroskaTrack *tracks = matroska->tracks.elem;
31173116 MatroskaTrack *track;
31183117
3119− avpriv_packet_list_get(&matroska->queue, &matroska->queue_end, pkt);
3118+ avpriv_packet_list_get(&matroska->queue, pkt);
31203119 track = &tracks[pkt->stream_index];
31213120 if (track->has_palette) {
31223121 uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
@@ -3138,7 +3137,7 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska, · 15 unmodified lines
31383137 */
31393138 static void matroska_clear_queue(MatroskaDemuxContext *matroska)
31403139 {
3141− avpriv_packet_list_free(&matroska->queue, &matroska->queue_end);
3140+ avpriv_packet_list_free(&matroska->queue);
31423141 }
31433142
31443143 static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
@@ -3304,7 +3303,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska, · 159 unmodified lines
33043303 track->audio.buf_timecode = AV_NOPTS_VALUE;
33053304 pkt->pos = pos;
33063305 pkt->stream_index = st->index;
3307− ret = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0);
3306+ ret = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0);
33083307 if (ret < 0) {
33093308 av_packet_unref(pkt);
33103309 return AVERROR(ENOMEM);
@@ -3526,7 +3525,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, · 215 unmodified lines
35263525 pkt->duration = duration;
35273526 pkt->pos = pos;
35283527
3529− err = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0);
3528+ err = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0);
35303529 if (err < 0) {
35313530 av_packet_unref(pkt);
35323531 return AVERROR(ENOMEM);
@@ -3628,7 +3627,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, · 95 unmodified lines
36283627 pkt->pos = pos;
36293628 pkt->duration = lace_duration;
36303629
3631− res = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0);
3630+ res = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0);
36323631 if (res < 0) {
36333632 av_packet_unref(pkt);
36343633 return AVERROR(ENOMEM);
@@ -4030,10 +4029,10 @@ static int webm_clusters_start_with_keyframe(AVFormatContext *s) · 395 unmodified lines
40304029 matroska_reset_status(matroska, 0, cluster_pos);
40314030 matroska_clear_queue(matroska);
40324031 if (matroska_parse_cluster(matroska) < 0 ||
4033− !matroska->queue) {
4032+ !matroska->queue.head) {
40344033 break;
40354034 }
4036− pkt = &matroska->queue->pkt;
4035+ pkt = &matroska->queue.head->pkt;
40374036 // 4 + read is the length of the cluster id and the cluster length field.
40384037 cluster_pos += 4 + read + cluster_length;
40394038 if (!(pkt->flags & AV_PKT_FLAG_KEY)) {
libavformat/movenc.c+2−4
@@ -5339,7 +5339,7 @@ static int mov_write_squashed_packet(AVFormatContext *s, MOVTrack *track) · 5338 unmodified lines
53395339
53405340 switch (track->st->codecpar->codec_id) {
53415341 case AV_CODEC_ID_TTML: {
5342− int had_packets = !!track->squashed_packet_queue;
5342+ int had_packets = !!track->squashed_packet_queue.head;
53435343
53445344 if ((ret = ff_mov_generate_squashed_ttml_packet(s, track, squashed_packet)) < 0) {
53455345 goto finish_squash;
@@ -6190,7 +6190,6 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) · 844 unmodified lines
61906190 /* The following will reset pkt and is only allowed to be used
61916191 * because we return immediately. afterwards. */
61926192 if ((ret = avpriv_packet_list_put(&trk->squashed_packet_queue,
6193− &trk->squashed_packet_queue_end,
61946193 pkt, NULL, 0)) < 0) {
61956194 return ret;
61966195 }
@@ -6478,8 +6477,7 @@ static void mov_free(AVFormatContext *s) · 281 unmodified lines
64786477 ff_mov_cenc_free(&track->cenc);
64796478 ffio_free_dyn_buf(&track->mdat_buf);
64806479
6481− avpriv_packet_list_free(&track->squashed_packet_queue,
6482− &track->squashed_packet_queue_end);
6480+ avpriv_packet_list_free(&track->squashed_packet_queue);
64836481 }
64846482
64856483 av_freep(&mov->tracks);
libavformat/movenc.h+1−1
@@ -167,7 +167,7 @@ typedef struct MOVTrack { · 166 unmodified lines
167167
168168 unsigned int squash_fragment_samples_to_one; //< flag to note formats where all samples for a fragment are to be squashed
169169
170− PacketList *squashed_packet_queue, *squashed_packet_queue_end;
170+ PacketList squashed_packet_queue;
171171 } MOVTrack;
172172
173173 typedef enum {
libavformat/movenc_ttml.c+2−4
@@ -70,9 +70,7 @@ static int mov_write_ttml_document_from_queue(AVFormatContext *s, · 69 unmodified lines
7070 return ret;
7171 }
7272
73− while (!avpriv_packet_list_get(&track->squashed_packet_queue,
74− &track->squashed_packet_queue_end,
75− pkt)) {
73+ while (!avpriv_packet_list_get(&track->squashed_packet_queue, pkt)) {
7674 end_ts = FFMAX(end_ts, pkt->pts + pkt->duration);
7775
7876 // in case of the 'dfxp' muxing mode, each written document is offset
@@ -121,7 +119,7 @@ int ff_mov_generate_squashed_ttml_packet(AVFormatContext *s, · 42 unmodified lines
121119 goto cleanup;
122120 }
123121
124− if (!track->squashed_packet_queue) {
122+ if (!track->squashed_packet_queue.head) {
125123 // empty queue, write minimal empty document with zero duration
126124 avio_write(ttml_ctx->pb, empty_ttml_document,
127125 sizeof(empty_ttml_document) - 1);
libavformat/mp3enc.c+5−6
@@ -132,7 +132,7 @@ typedef struct MP3Context { · 131 unmodified lines
132132 int pics_to_write;
133133
134134 /* audio packets are queued here until we get all the attached pictures */
135− PacketList *queue, *queue_end;
135+ PacketList queue;
136136 } MP3Context;
137137
138138 static const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}};
@@ -387,8 +387,8 @@ static int mp3_queue_flush(AVFormatContext *s) · 248 unmodified lines
387387 ff_id3v2_finish(&mp3->id3, s->pb, s->metadata_header_padding);
388388 mp3_write_xing(s);
389389
390− while (mp3->queue) {
391− avpriv_packet_list_get(&mp3->queue, &mp3->queue_end, pkt);
390+ while (mp3->queue.head) {
391+ avpriv_packet_list_get(&mp3->queue, pkt);
392392 if (write && (ret = mp3_write_audio_packet(s, pkt)) < 0)
393393 write = 0;
394394 av_packet_unref(pkt);
@@ -524,8 +524,7 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt) · 129 unmodified lines
524524 if (pkt->stream_index == mp3->audio_stream_idx) {
525525 if (mp3->pics_to_write) {
526526 /* buffer audio packets until we get all the pictures */
527− int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end,
528− pkt, NULL, 0);
527+ int ret = avpriv_packet_list_put(&mp3->queue, pkt, NULL, 0);
529528
530529 if (ret < 0) {
531530 av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n");
@@ -633,7 +632,7 @@ static void mp3_deinit(struct AVFormatContext *s) · 101 unmodified lines
633632 {
634633 MP3Context *mp3 = s->priv_data;
635634
636− avpriv_packet_list_free(&mp3->queue, &mp3->queue_end);
635+ avpriv_packet_list_free(&mp3->queue);
637636 av_freep(&mp3->xing_frame);
638637 }
639638
libavformat/mux.c+19−19
@@ -809,12 +809,12 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, · 808 unmodified lines
809809 {
810810 int ret;
811811 FFFormatContext *const si = ffformatcontext(s);
812− PacketList **next_point, *this_pktl;
812+ PacketListEntry **next_point, *this_pktl;
813813 AVStream *st = s->streams[pkt->stream_index];
814814 FFStream *const sti = ffstream(st);
815815 int chunked = s->max_chunk_size || s->max_chunk_duration;
816816
817− this_pktl = av_malloc(sizeof(PacketList));
817+ this_pktl = av_malloc(sizeof(*this_pktl));
818818 if (!this_pktl) {
819819 av_packet_unref(pkt);
820820 return AVERROR(ENOMEM);
@@ -831,7 +831,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, · 10 unmodified lines
831831 if (sti->last_in_packet_buffer) {
832832 next_point = &(sti->last_in_packet_buffer->next);
833833 } else {
834− next_point = &si->packet_buffer;
834+ next_point = &si->packet_buffer.head;
835835 }
836836
837837 if (chunked) {
@@ -855,7 +855,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, · 17 unmodified lines
855855 if (chunked && !(pkt->flags & CHUNK_START))
856856 goto next_non_null;
857857
858− if (compare(s, &si->packet_buffer_end->pkt, pkt)) {
858+ if (compare(s, &si->packet_buffer.tail->pkt, pkt)) {
859859 while ( *next_point
860860 && ((chunked && !((*next_point)->pkt.flags&CHUNK_START))
861861 || !compare(s, &(*next_point)->pkt, pkt)))
@@ -863,12 +863,12 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, · 1 unmodified line
863863 if (*next_point)
864864 goto next_non_null;
865865 } else {
866− next_point = &(si->packet_buffer_end->next);
866+ next_point = &(si->packet_buffer.tail->next);
867867 }
868868 }
869869 av_assert1(!*next_point);
870870
871− si->packet_buffer_end = this_pktl;
871+ si->packet_buffer.tail = this_pktl;
872872 next_non_null:
873873
874874 this_pktl->next = *next_point;
@@ -939,11 +939,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 64 unmodified lines
939939 flush = 1;
940940
941941 if (s->max_interleave_delta > 0 &&
942− si->packet_buffer &&
942+ si->packet_buffer.head &&
943943 !flush &&
944944 si->nb_interleaved_streams == stream_count+noninterleaved_count
945945 ) {
946− AVPacket *const top_pkt = &si->packet_buffer->pkt;
946+ AVPacket *const top_pkt = &si->packet_buffer.head->pkt;
947947 int64_t delta_dts = INT64_MIN;
948948 int64_t top_dts = av_rescale_q(top_pkt->dts,
949949 s->streams[top_pkt->stream_index]->time_base,
@@ -952,7 +952,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 2 unmodified lines
952952 for (unsigned i = 0; i < s->nb_streams; i++) {
953953 const AVStream *const st = s->streams[i];
954954 const FFStream *const sti = cffstream(st);
955− const PacketList *last = sti->last_in_packet_buffer;
955+ const PacketListEntry *const last = sti->last_in_packet_buffer;
956956 int64_t last_dts;
957957
958958 if (!last)
@@ -973,11 +973,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 14 unmodified lines
973973 }
974974 }
975975
976− if (si->packet_buffer &&
976+ if (si->packet_buffer.head &&
977977 eof &&
978978 (s->flags & AVFMT_FLAG_SHORTEST) &&
979979 si->shortest_end == AV_NOPTS_VALUE) {
980− AVPacket *const top_pkt = &si->packet_buffer->pkt;
980+ AVPacket *const top_pkt = &si->packet_buffer.head->pkt;
981981
982982 si->shortest_end = av_rescale_q(top_pkt->dts,
983983 s->streams[top_pkt->stream_index]->time_base,
@@ -985,8 +985,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 1 unmodified line
985985 }
986986
987987 if (si->shortest_end != AV_NOPTS_VALUE) {
988− while (si->packet_buffer) {
989− PacketList *pktl = si->packet_buffer;
988+ while (si->packet_buffer.head) {
989+ PacketListEntry *pktl = si->packet_buffer.head;
990990 AVPacket *const top_pkt = &pktl->pkt;
991991 AVStream *const st = s->streams[top_pkt->stream_index];
992992 FFStream *const sti = ffstream(st);
@@ -996,9 +996,9 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 3 unmodified lines
996996 if (si->shortest_end + 1 >= top_dts)
997997 break;
998998
999− si->packet_buffer = pktl->next;
1000− if (!si->packet_buffer)
1001− si->packet_buffer_end = NULL;
999+ si->packet_buffer.head = pktl->next;
1000+ if (!si->packet_buffer.head)
1001+ si->packet_buffer.tail = NULL;
10021002
10031003 if (sti->last_in_packet_buffer == pktl)
10041004 sti->last_in_packet_buffer = NULL;
@@ -1010,13 +1010,13 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 5 unmodified lines
10101010 }
10111011
10121012 if (stream_count && flush) {
1013− PacketList *pktl = si->packet_buffer;
1013+ PacketListEntry *pktl = si->packet_buffer.head;
10141014 AVStream *const st = s->streams[pktl->pkt.stream_index];
10151015 FFStream *const sti = ffstream(st);
10161016
10171017 if (sti->last_in_packet_buffer == pktl)
10181018 sti->last_in_packet_buffer = NULL;
1019− avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, pkt);
1019+ avpriv_packet_list_get(&si->packet_buffer, pkt);
10201020
10211021 return 1;
10221022 } else {
@@ -1049,7 +1049,7 @@ int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset · 26 unmodified lines
10491049 const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream)
10501050 {
10511051 FFFormatContext *const si = ffformatcontext(s);
1052− PacketList *pktl = si->packet_buffer;
1052+ PacketListEntry *pktl = si->packet_buffer.head;
10531053 while (pktl) {
10541054 if (pktl->pkt.stream_index == stream) {
10551055 return &pktl->pkt;
libavformat/mxfenc.c+7−7
@@ -3097,9 +3097,9 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus · 3096 unmodified lines
30973097 stream_count += !!ffstream(s->streams[i])->last_in_packet_buffer;
30983098
30993099 if (stream_count && (s->nb_streams == stream_count || flush)) {
3100− PacketList *pktl = si->packet_buffer;
3100+ PacketListEntry *pktl = si->packet_buffer.head;
31013101 if (s->nb_streams != stream_count) {
3102− PacketList *last = NULL;
3102+ PacketListEntry *last = NULL;
31033103 // find last packet in edit unit
31043104 while (pktl) {
31053105 if (!stream_count || pktl->pkt.stream_index == 0)
@@ -3113,7 +3113,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus · 7 unmodified lines
31133113 }
31143114 // purge packet queue
31153115 while (pktl) {
3116− PacketList *next = pktl->next;
3116+ PacketListEntry *next = pktl->next;
31173117 av_packet_unref(&pktl->pkt);
31183118 av_freep(&pktl);
31193119 pktl = next;
@@ -3121,16 +3121,16 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus · 1 unmodified line
31213121 if (last)
31223122 last->next = NULL;
31233123 else {
3124− si->packet_buffer = NULL;
3125− si->packet_buffer_end = NULL;
3124+ si->packet_buffer.head = NULL;
3125+ si->packet_buffer.tail = NULL;
31263126 goto out;
31273127 }
3128− pktl = si->packet_buffer;
3128+ pktl = si->packet_buffer.head;
31293129 }
31303130
31313131 if (ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer == pktl)
31323132 ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer = NULL;
3133− avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, out);
3133+ avpriv_packet_list_get(&si->packet_buffer, out);
31343134 av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", out->stream_index, out->dts);
31353135 return 1;
31363136 } else {
libavformat/ttaenc.c+6−7
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030
3131 typedef struct TTAMuxContext {
3232 AVIOContext *seek_table;
33− PacketList *queue, *queue_end;
33+ PacketList queue;
3434 uint32_t nb_samples;
3535 int frame_size;
3636 int last_frame;
@@ -94,12 +94,11 @@ static int tta_write_packet(AVFormatContext *s, AVPacket *pkt) · 57 unmodified lines
9494 TTAMuxContext *tta = s->priv_data;
9595 int ret;
9696
97− ret = avpriv_packet_list_put(&tta->queue, &tta->queue_end, pkt,
98− NULL, 0);
97+ ret = avpriv_packet_list_put(&tta->queue, pkt, NULL, 0);
9998 if (ret < 0) {
10099 return ret;
101100 }
102− pkt = &tta->queue_end->pkt;
101+ pkt = &tta->queue.tail->pkt;
103102
104103 avio_wl32(tta->seek_table, pkt->size);
105104 tta->nb_samples += pkt->duration;
@@ -126,8 +125,8 @@ static void tta_queue_flush(AVFormatContext *s) · 20 unmodified lines
126125 TTAMuxContext *tta = s->priv_data;
127126 AVPacket *const pkt = ffformatcontext(s)->pkt;
128127
129− while (tta->queue) {
130− avpriv_packet_list_get(&tta->queue, &tta->queue_end, pkt);
128+ while (tta->queue.head) {
129+ avpriv_packet_list_get(&tta->queue, pkt);
131130 avio_write(s->pb, pkt->data, pkt->size);
132131 av_packet_unref(pkt);
133132 }
@@ -163,7 +162,7 @@ static void tta_deinit(AVFormatContext *s) · 29 unmodified lines
163162 TTAMuxContext *tta = s->priv_data;
164163
165164 ffio_free_dyn_buf(&tta->seek_table);
166− avpriv_packet_list_free(&tta->queue, &tta->queue_end);
165+ avpriv_packet_list_free(&tta->queue);
167166 }
168167
169168 const AVOutputFormat ff_tta_muxer = {
libavformat/utils.c+3−4
@@ -239,7 +239,6 @@ int avformat_queue_attached_pictures(AVFormatContext *s) · 238 unmodified lines
239239 }
240240
241241 ret = avpriv_packet_list_put(&si->raw_packet_buffer,
242− &si->raw_packet_buffer_end,
243242 &s->streams[i]->attached_pic,
244243 av_packet_ref, 0);
245244 if (ret < 0)
@@ -300,9 +299,9 @@ int ff_is_intra_only(enum AVCodecID id) · 54 unmodified lines
300299 void ff_flush_packet_queue(AVFormatContext *s)
301300 {
302301 FFFormatContext *const si = ffformatcontext(s);
303− avpriv_packet_list_free(&si->parse_queue, &si->parse_queue_end);
304− avpriv_packet_list_free(&si->packet_buffer, &si->packet_buffer_end);
305− avpriv_packet_list_free(&si->raw_packet_buffer, &si->raw_packet_buffer_end);
302+ avpriv_packet_list_free(&si->parse_queue);
303+ avpriv_packet_list_free(&si->packet_buffer);
304+ avpriv_packet_list_free(&si->raw_packet_buffer);
306305
307306 si->raw_packet_buffer_size = 0;
308307 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t