diff options
author | nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-01-23 22:26:13 +0000 |
---|---|---|
committer | nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-01-23 22:26:13 +0000 |
commit | ef29ff34ff9222a55c5e4672ba2ace3b21db630c (patch) | |
tree | b96ae0b40345325fde7c8f485c732d9e6c362c8a /libmpdemux/demux_rtp_codec.cpp | |
parent | 03429e8798e8685c08fbeb1ecd1262eb59c423a7 (diff) | |
download | mpv-ef29ff34ff9222a55c5e4672ba2ace3b21db630c.tar.bz2 mpv-ef29ff34ff9222a55c5e4672ba2ace3b21db630c.tar.xz |
better autodetection of framerate in case of h264; it works correctly with b-frames.
Patch by Eugen Hoyos (cehoyos ag or at)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22001 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/demux_rtp_codec.cpp')
-rw-r--r-- | libmpdemux/demux_rtp_codec.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libmpdemux/demux_rtp_codec.cpp b/libmpdemux/demux_rtp_codec.cpp index eda8b04c82..0eb3e60e93 100644 --- a/libmpdemux/demux_rtp_codec.cpp +++ b/libmpdemux/demux_rtp_codec.cpp @@ -4,6 +4,7 @@ #include "demux_rtp_internal.h" extern "C" { #include <limits.h> +#include <math.h> #include "stheader.h" } @@ -247,19 +248,24 @@ static void needVideoFrameRate(demuxer_t* demuxer, unsigned char* packetData; unsigned packetDataLen; float lastPTS = 0.0, curPTS; unsigned const maxNumFramesToWaitFor = 300; + int lastfps = 0; for (unsigned i = 0; i < maxNumFramesToWaitFor; ++i) { if (!awaitRTPPacket(demuxer, d_video, packetData, packetDataLen, curPTS)) { break; } - if (curPTS > lastPTS && lastPTS != 0.0) { + if (curPTS != lastPTS && lastPTS != 0.0) { // Use the difference between these two "pts"s to guess the frame rate. // (should really check that there were no missing frames inbetween)##### // Guess the frame rate as an integer. If it's not, use "-fps" instead. - fps = (int)(1/(curPTS-lastPTS) + 0.5); // rounding + fps = (int)(1/fabs(curPTS-lastPTS) + 0.5); // rounding + if (fps == lastfps) { fprintf(stderr, "demux_rtp: Guessed the video frame rate as %d frames-per-second.\n\t(If this is wrong, use the \"-fps <frame-rate>\" option instead.)\n", fps); sh_video->fps = fps; + sh_video->frametime=1.0f/fps; return; + } + if (fps>lastfps) lastfps = fps; } lastPTS = curPTS; } |