diff options
author | Martin Storsjö <martin@martin.st> | 2012-12-07 16:19:42 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-01-14 17:51:48 +0200 |
commit | d0fe217e3990b003b3b3f2c2daaadfb2af590def (patch) | |
tree | 98a6ac97a516e2cf58dc44ca1f74f45d5c80a7fb /libavformat | |
parent | 62761934b024e987f7925787531a4989f1d667af (diff) | |
download | ffmpeg-d0fe217e3990b003b3b3f2c2daaadfb2af590def.tar.gz |
rtpdec: Simplify insertion into the linked list queue
By using a pointer-to-pointer, we avoid having to keep track
of the previous packet separately.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/rtpdec.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 97cfed85f8..1ccc0f6f79 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -723,15 +723,14 @@ void ff_rtp_reset_packet_queue(RTPDemuxContext *s) static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len) { uint16_t seq = AV_RB16(buf + 2); - RTPPacket *cur = s->queue, *prev = NULL, *packet; + RTPPacket **cur = &s->queue, *packet; /* Find the correct place in the queue to insert the packet */ - while (cur) { - int16_t diff = seq - cur->seq; + while (*cur) { + int16_t diff = seq - (*cur)->seq; if (diff < 0) break; - prev = cur; - cur = cur->next; + cur = &(*cur)->next; } packet = av_mallocz(sizeof(*packet)); @@ -741,11 +740,8 @@ static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len) packet->seq = seq; packet->len = len; packet->buf = buf; - packet->next = cur; - if (prev) - prev->next = packet; - else - s->queue = packet; + packet->next = *cur; + *cur = packet; s->queue_len++; } |