[FFmpeg-devel] [PATCH 07/18] avformat: port AVFormatInternal->raw_packet_buffer to the new packet list API
James Almer
jamrial at gmail.com
Wed Nov 18 18:52:36 EET 2020
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/internal.h | 3 +--
libavformat/options.c | 6 +++++-
libavformat/utils.c | 21 ++++++++++++---------
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 3182409dfb..a0649956e8 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -85,8 +85,7 @@ struct AVFormatInternal {
* be identified, as parsing cannot be done without knowing the
* codec.
*/
- struct PacketListEntry *raw_packet_buffer;
- struct PacketListEntry *raw_packet_buffer_end;
+ struct AVPacketList *raw_packet_buffer;
/**
* Packets split by the parser get queued here.
*/
diff --git a/libavformat/options.c b/libavformat/options.c
index 9fe1500cee..ee7a533aa0 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -221,7 +221,11 @@ AVFormatContext *avformat_alloc_context(void)
return NULL;
}
internal->packet_buffer = av_packet_list_alloc();
- if (!internal->packet_buffer) {
+ internal->raw_packet_buffer = av_packet_list_alloc();
+ if (!internal->packet_buffer ||
+ !internal->raw_packet_buffer) {
+ av_packet_list_free(&internal->packet_buffer);
+ av_packet_list_free(&internal->raw_packet_buffer);
av_free(internal);
av_free(ic);
return NULL;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 88ce64496d..02c0ead44b 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -452,8 +452,7 @@ int avformat_queue_attached_pictures(AVFormatContext *s)
continue;
}
- ret = avpriv_packet_list_put(&s->internal->raw_packet_buffer,
- &s->internal->raw_packet_buffer_end,
+ ret = av_packet_list_put(s->internal->raw_packet_buffer,
&s->streams[i]->attached_pic,
av_packet_ref, 0);
if (ret < 0)
@@ -793,13 +792,18 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, i, err;
AVStream *st;
+#if FF_API_PACKET_LIST
+ struct PacketList *raw_packet_buffer = (struct PacketList *)s->internal->raw_packet_buffer;
+#else
+ AVPacketList *raw_packet_buffer = s->internal->raw_packet_buffer;
+#endif
pkt->data = NULL;
pkt->size = 0;
av_init_packet(pkt);
for (;;) {
- PacketListEntry *pktl = s->internal->raw_packet_buffer;
+ PacketListEntry *pktl = raw_packet_buffer->head;
const AVPacket *pkt1;
if (pktl) {
@@ -808,8 +812,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
if ((err = probe_codec(s, st, NULL)) < 0)
return err;
if (st->internal->request_probe <= 0) {
- avpriv_packet_list_get(&s->internal->raw_packet_buffer,
- &s->internal->raw_packet_buffer_end, pkt);
+ av_packet_list_get(s->internal->raw_packet_buffer, pkt, 0);
s->internal->raw_packet_buffer_remaining_size += pkt->size;
return 0;
}
@@ -881,14 +884,13 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!pktl && st->internal->request_probe <= 0)
return ret;
- err = avpriv_packet_list_put(&s->internal->raw_packet_buffer,
- &s->internal->raw_packet_buffer_end,
+ err = av_packet_list_put(s->internal->raw_packet_buffer,
pkt, NULL, 0);
if (err < 0) {
av_packet_unref(pkt);
return err;
}
- pkt1 = &s->internal->raw_packet_buffer_end->pkt;
+ pkt1 = &raw_packet_buffer->tail->pkt;
s->internal->raw_packet_buffer_remaining_size -= pkt1->size;
if ((err = probe_codec(s, st, pkt1)) < 0)
@@ -1843,7 +1845,7 @@ static void flush_packet_queue(AVFormatContext *s)
return;
avpriv_packet_list_free(&s->internal->parse_queue, &s->internal->parse_queue_end);
av_packet_list_flush(s->internal->packet_buffer);
- avpriv_packet_list_free(&s->internal->raw_packet_buffer, &s->internal->raw_packet_buffer_end);
+ av_packet_list_flush(s->internal->raw_packet_buffer);
s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
}
@@ -4471,6 +4473,7 @@ void avformat_free_context(AVFormatContext *s)
av_freep(&s->streams);
flush_packet_queue(s);
av_packet_list_free(&s->internal->packet_buffer);
+ av_packet_list_free(&s->internal->raw_packet_buffer);
av_freep(&s->internal);
av_freep(&s->url);
av_free(s);
--
2.29.2
More information about the ffmpeg-devel
mailing list