Updated for decimal frame rates.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2867 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2009-05-08 13:47:19 +00:00
parent e69489e841
commit 820dce5e42
5 changed files with 10 additions and 10 deletions

View File

@ -1329,7 +1329,7 @@ void EventStream::runStream()
{ {
delta_us = (unsigned int)(frame_data->delta * 1000000); delta_us = (unsigned int)(frame_data->delta * 1000000);
if ( effective_fps < base_fps ) if ( effective_fps < base_fps )
delta_us = (delta_us * base_fps)/effective_fps; delta_us = (unsigned int)((delta_us * base_fps)/effective_fps);
send_frame = true; send_frame = true;
} }
} }

View File

@ -3568,7 +3568,7 @@ void MonitorStream::runStream()
} }
frame_count++; frame_count++;
} }
usleep( (1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2)) ); usleep( (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))) );
if ( ttl ) if ( ttl )
{ {
if ( (now.tv_sec - stream_start_time) > ttl ) if ( (now.tv_sec - stream_start_time) > ttl )

View File

@ -67,7 +67,7 @@ void VideoStream::SetupFormat( const char *p_filename, const char *p_format )
snprintf( ofc->filename, sizeof(ofc->filename), "%s", filename ); snprintf( ofc->filename, sizeof(ofc->filename), "%s", filename );
} }
void VideoStream::SetupCodec( int colours, int width, int height, int bitrate, int frame_rate ) void VideoStream::SetupCodec( int colours, int width, int height, int bitrate, double frame_rate )
{ {
pf = (colours==1?PIX_FMT_GRAY8:PIX_FMT_RGB24); pf = (colours==1?PIX_FMT_GRAY8:PIX_FMT_RGB24);
@ -102,14 +102,14 @@ void VideoStream::SetupCodec( int colours, int width, int height, int bitrate, i
of which frame timestamps are represented. for fixed-fps content, of which frame timestamps are represented. for fixed-fps content,
timebase should be 1/framerate and timestamp increments should be timebase should be 1/framerate and timestamp increments should be
identically 1. */ identically 1. */
c->time_base.den = frame_rate; c->time_base.den = (int)(frame_rate*100);
c->time_base.num = 1; c->time_base.num = 100;
#else #else
/* frames per second */ /* frames per second */
c->frame_rate = frame_rate; c->frame_rate = frame_rate;
c->frame_rate_base = 1; c->frame_rate_base = 1;
#endif #endif
c->gop_size = frame_rate/2; /* emit one intra frame every half second or so */ //c->gop_size = frame_rate/2; /* emit one intra frame every half second or so */
c->gop_size = 12; c->gop_size = 12;
if ( c->gop_size < 3 ) if ( c->gop_size < 3 )
c->gop_size = 3; c->gop_size = 3;
@ -233,7 +233,7 @@ void VideoStream::OpenStream()
av_write_header(ofc); av_write_header(ofc);
} }
VideoStream::VideoStream( const char *filename, const char *format, int bitrate, int frame_rate, int colours, int width, int height ) VideoStream::VideoStream( const char *filename, const char *format, int bitrate, double frame_rate, int colours, int width, int height )
{ {
if ( !initialised ) if ( !initialised )
{ {

View File

@ -54,11 +54,11 @@ protected:
static void Initialise(); static void Initialise();
void SetupFormat( const char *p_filename, const char *format ); void SetupFormat( const char *p_filename, const char *format );
void SetupCodec( int colours, int width, int height, int bitrate, int frame_rate ); void SetupCodec( int colours, int width, int height, int bitrate, double frame_rate );
void SetParameters(); void SetParameters();
public: public:
VideoStream( const char *filename, const char *format, int bitrate, int frame_rate, int colours, int width, int height ); VideoStream( const char *filename, const char *format, int bitrate, double frame_rate, int colours, int width, int height );
~VideoStream(); ~VideoStream();
const char *MimeType() const; const char *MimeType() const;
void OpenStream(); void OpenStream();

View File

@ -60,7 +60,7 @@ void StreamBase::updateFrameRate( double fps )
while( effective_fps > maxfps ) while( effective_fps > maxfps )
{ {
effective_fps /= 2.0; effective_fps /= 2.0;
frame_mod *= 2.0; frame_mod *= 2;
} }
Debug( 3, "aEFPS:%.2f, aFM:%d", effective_fps, frame_mod ); Debug( 3, "aEFPS:%.2f, aFM:%d", effective_fps, frame_mod );
} }