summaryrefslogtreecommitdiff
path: root/libavformat/rtpdec.c
diff options
context:
space:
mode:
authorJohn Brooks <john.brooks@bluecherry.net>2011-11-17 08:50:12 -0700
committerMartin Storsjö <martin@martin.st>2011-11-18 10:31:17 +0200
commit12348ca25e0bf44bf4530745753e938fc54e7ae3 (patch)
tree44fb1debd9ac2de9a91f8b052197bfa509866b61 /libavformat/rtpdec.c
parentbb4b0ad83b13c3af57675e80163f3f333adef96f (diff)
rtpdec: unwrap RTP timestamps for PTS calculation
The timestamp field in RTPDemuxContext was unused before this. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtpdec.c')
-rw-r--r--libavformat/rtpdec.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index a5ec1caf7a..94fa0f102b 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -439,7 +439,13 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam
if (!s->base_timestamp)
s->base_timestamp = timestamp;
- pkt->pts = s->range_start_offset + timestamp - s->base_timestamp;
+ /* assume that the difference is INT32_MIN < x < INT32_MAX, but allow the first timestamp to exceed INT32_MAX */
+ if (!s->timestamp)
+ s->unwrapped_timestamp += timestamp;
+ else
+ s->unwrapped_timestamp += (int32_t)(timestamp - s->timestamp);
+ s->timestamp = timestamp;
+ pkt->pts = s->unwrapped_timestamp + s->range_start_offset - s->base_timestamp;
}
static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,