summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-03-03 09:43:14 +0100
committerAnton Khirnov <anton@khirnov.net>2012-03-05 18:44:30 +0100
commit52b0943f10a790145f990f8056ab603edc0f7edb (patch)
tree817a76aa0ddfd9c36a1e22c741f7efe799f087c7 /libavformat/utils.c
parentc9dbac36ad4bac07f6c1d06d465e361ab55bcb95 (diff)
lavf: factorize freeing a packet buffer.
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 123bc8bf9a..7661e98ae4 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1000,6 +1000,17 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
pkt->convergence_duration = pc->convergence_duration;
}
+static void free_packet_buffer(AVPacketList **pkt_buf, AVPacketList **pkt_buf_end)
+{
+ while (*pkt_buf) {
+ AVPacketList *pktl = *pkt_buf;
+ *pkt_buf = pktl->next;
+ av_free_packet(&pktl->pkt);
+ av_freep(&pktl);
+ }
+ *pkt_buf_end = NULL;
+}
+
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
{
@@ -1223,24 +1234,9 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
/* XXX: suppress the packet queue */
static void flush_packet_queue(AVFormatContext *s)
{
- AVPacketList *pktl;
+ free_packet_buffer(&s->packet_buffer, &s->packet_buffer_end);
+ free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end);
- for(;;) {
- pktl = s->packet_buffer;
- if (!pktl)
- break;
- s->packet_buffer = pktl->next;
- av_free_packet(&pktl->pkt);
- av_free(pktl);
- }
- while(s->raw_packet_buffer){
- pktl = s->raw_packet_buffer;
- s->raw_packet_buffer = pktl->next;
- av_free_packet(&pktl->pkt);
- av_free(pktl);
- }
- s->packet_buffer_end=
- s->raw_packet_buffer_end= NULL;
s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
}