[FFmpeg-devel] Reading the NTP time from RTCP timestamps

Michael Niedermayer michaelni
Fri Jun 27 22:49:26 CEST 2008


On Fri, Jun 27, 2008 at 05:06:09PM +0200, Luca Abeni wrote:
> Hi Michael,
> 
> Michael Niedermayer wrote:
> [...]
> >> 	s->last_rtcp_ntp_time = AV_RB32(buf + 8) * 1000000ULL + ((AV_RB32(buf + 12)  * 1000000ULL) >> 32);
> >>
> >> This works well (returning the NTP time in usecs), but I
> >> suspect it can be computed in a simpler way...
> >> Any ideas/suggestions?
> > 
> > yes the reading code looks perfectly correct, you use the wrong timebase
> > all over the place probably
> 
> Yes, sorry; you are right (I was using a wrong timebase; not all over
> the place, but in some "strategic points" :).
> 
> I got confused by the fact that
> av_rescale_q(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 2^32}, s->st->time_base);
> did not work as I naively expected, and I worked around this in the
> wrong way...

AVRationals are 32/32bit ...


> 
> I am currently using
> av_rescale_q(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 1}, s->st->time_base) >> 32;
> but I hope to find a better way (basically, I have to convert
> from timebase 1/2^32 to s->st->time_base)

av_rescale(ntp, time_base.den, (uint64_t)time_base.num<<32)

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080627/ba0bf90e/attachment.pgp>



More information about the ffmpeg-devel mailing list