[FFmpeg-devel] [PATCH] Extracting NTP timestamp from RTCP
Michael Niedermayer
michaelni at gmx.at
Fri Nov 8 09:21:43 CET 2013
On Thu, Nov 07, 2013 at 02:47:40PM -0700, Fred Rothganger wrote:
> On 11/07/2013 01:55 PM, Michael Niedermayer wrote:
> >+ if (s->start_time_realtime == 0) {
> >+ s->start_time_realtime =
> >+ (((uint64_t) rtpctx->first_rtcp_ntp_time >> 32 ) - NTP_OFFSET) * 1000000
> >+ + (( rtpctx->first_rtcp_ntp_time & 0xFFFFFFFF) * 1000000 >> 32);
> >why doesnt this use av_rescale ?
> >
> >
>
> Mainly because I didn't think of it. I would still choose this code
> because the math is more efficient. Since this code executes very
> rarely, I gather your concern is more about readability. Attached is
> another patch that uses av_rescale.
> doc/APIchanges | 3 +++
> libavformat/avformat.h | 2 +-
> libavformat/rtsp.c | 11 +++++++++++
> libavformat/version.h | 2 +-
> 4 files changed, 16 insertions(+), 2 deletions(-)
> 7531702dc18dcfdd6e3017380c977acba2cd5c54 rtsp.patch
> diff --git a/doc/APIchanges b/doc/APIchanges
> index dfdc159..be3d90a 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2012-10-22
>
> API changes, most recent first:
>
> +2013-11-07 - xxxxxxx - lavf 55.21.101 - avformat.h
> + Set AVFormatContext.start_time_realtime when decoding.
> +
> 2013-11-xx - xxxxxxx - lavc 55.41.100 / 55.25.0 - avcodec.h
> lavu 52.51.100 - frame.h
> Add ITU-R BT.2020 and other not yet included values to color primaries,
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 6bd54ce..1c4929d 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1127,7 +1127,7 @@ typedef struct AVFormatContext {
> * since the unix epoch (00:00 1st January 1970). That is, pts=0
> * in the stream was captured at this real world time.
> * - encoding: Set by user.
> - * - decoding: Unused.
> + * - decoding: Set by libavformt.
> */
> int64_t start_time_realtime;
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 3b88fc7..e5fe53d 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2051,6 +2051,17 @@ redo:
> * as this one. */
> int i;
> AVStream *st = NULL;
> + if (s->start_time_realtime == 0) {
> + s->start_time_realtime =
> + (((uint64_t) rtpctx->first_rtcp_ntp_time >> 32 ) - NTP_OFFSET) * 1000000
> + + av_rescale (rtpctx->first_rtcp_ntp_time & 0xFFFFFFFF, 1000000, 1LL << 32);
why is first_rtcp_ntp_time split in low and high 32bit halfs ?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131108/23a8a3c8/attachment.asc>
More information about the ffmpeg-devel
mailing list