From 62761934b024e987f7925787531a4989f1d667af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 13 Jan 2013 18:40:13 +0200 Subject: [PATCH 1/2] rtpdec: Remove a woefully misplaced comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code below the comment does not at all relate to statistics, and even if moved to the right place, the comment adds little value. Signed-off-by: Martin Storsjö --- libavformat/rtpdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 8e429cc735..97cfed85f8 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -50,7 +50,6 @@ static RTPDynamicProtocolHandler opus_dynamic_handler = { .codec_id = AV_CODEC_ID_OPUS, }; -/* statistics functions */ static RTPDynamicProtocolHandler *rtp_first_dynamic_payload_handler = NULL; void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler) From d0fe217e3990b003b3b3f2c2daaadfb2af590def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 7 Dec 2012 16:19:42 +0200 Subject: [PATCH 2/2] rtpdec: Simplify insertion into the linked list queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By using a pointer-to-pointer, we avoid having to keep track of the previous packet separately. Signed-off-by: Martin Storsjö --- libavformat/rtpdec.c | 16 ++++++---------- 1 file 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++; }