[FFmpeg-cvslog] avformat/rtpdec: Fix prft wallclock time.

Alok Priyadarshi git at videolan.org
Tue Mar 30 18:01:14 EEST 2021


ffmpeg | branch: master | Alok Priyadarshi <alokpr at gmail.com> | Wed Mar 24 21:46:36 2021 -0700| [62f486e7930c5f1c8e4bfe342eb6a2bbd8cfd177] | committer: James Almer

avformat/rtpdec: Fix prft wallclock time.

Timestamp difference is available in media timebase (1/90K) where as
rtcp time is in the default microseconds timebase. This patch fixes
the calculated prft wallclock time by rescaling the timestamp delta
to the microseconds timebase.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62f486e7930c5f1c8e4bfe342eb6a2bbd8cfd177
---

 libavformat/rtpdec.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 1edb64b9bf..6b0da9e636 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -623,14 +623,19 @@ void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite,
 }
 
 static int rtp_set_prft(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp) {
+    int64_t rtcp_time, delta_timestamp, delta_time;
+
     AVProducerReferenceTime *prft =
         (AVProducerReferenceTime *) av_packet_new_side_data(
             pkt, AV_PKT_DATA_PRFT, sizeof(AVProducerReferenceTime));
     if (!prft)
         return AVERROR(ENOMEM);
 
-    prft->wallclock = ff_parse_ntp_time(s->last_rtcp_ntp_time) - NTP_OFFSET_US +
-                      timestamp - s->last_rtcp_timestamp;
+    rtcp_time = ff_parse_ntp_time(s->last_rtcp_ntp_time) - NTP_OFFSET_US;
+    delta_timestamp = (int64_t)timestamp - (int64_t)s->last_rtcp_timestamp;
+    delta_time = av_rescale_q(delta_timestamp, s->st->time_base, AV_TIME_BASE_Q);
+
+    prft->wallclock = rtcp_time + delta_time;
     prft->flags = 24;
     return 0;
 }



More information about the ffmpeg-cvslog mailing list