From 0ab285a3ef07d41000c708024642933d5483f9c3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 8 May 2009 07:46:46 +0000 Subject: [PATCH] From Jean-Sebastien Guay, changed the timing control for when no audio layer is supplied. --- src/osgPlugins/ffmpeg/FFmpegClocks.hpp | 1 + src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp | 14 +++++++++++--- src/osgPlugins/ffmpeg/FFmpegDecoderVideo.hpp | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/osgPlugins/ffmpeg/FFmpegClocks.hpp b/src/osgPlugins/ffmpeg/FFmpegClocks.hpp index 904436e40..2f54a5f76 100644 --- a/src/osgPlugins/ffmpeg/FFmpegClocks.hpp +++ b/src/osgPlugins/ffmpeg/FFmpegClocks.hpp @@ -29,6 +29,7 @@ public: void audioAdjustBufferEndPts(double increment); void audioSetDelay(double delay); void audioDisable(); + bool audioDisabled() const { return m_audio_disabled; } double videoSynchClock(const AVFrame * frame, double time_base, double pts); double videoRefreshSchedule(double pts); diff --git a/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp b/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp index 7f2e61322..d413aa10b 100644 --- a/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp +++ b/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp @@ -190,7 +190,7 @@ void FFmpegDecoderVideo::decodeLoop() const double synched_pts = m_clocks.videoSynchClock(m_frame.get(), av_q2d(m_stream->time_base), pts); const double frame_delay = m_clocks.videoRefreshSchedule(synched_pts); - publishFrame(frame_delay); + publishFrame(frame_delay, m_clocks.audioDisabled()); } } @@ -268,16 +268,24 @@ int FFmpegDecoderVideo::convert(AVPicture *dst, int dst_pix_fmt, AVPicture *src, } -void FFmpegDecoderVideo::publishFrame(const double delay) +void FFmpegDecoderVideo::publishFrame(const double delay, bool audio_disabled) { // If no publishing function, just ignore the frame if (m_publish_func == 0) return; +#if 1 + // new code from Jean-Sebasiten Guay - needs testing as we're unclear on the best solution + // If the display delay is too small, we better skip the frame. + if (!audio_disabled && delay < -0.010) + return; +#else + // original solution that hung on video stream over web. // If the display delay is too small, we better skip the frame. if (delay < -0.010) return; - +#endif + AVPicture * const src = (AVPicture *) m_frame.get(); AVPicture * const dst = (AVPicture *) m_frame_rgba.get(); diff --git a/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.hpp b/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.hpp index 8df930737..6ba9d2c45 100644 --- a/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.hpp +++ b/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.hpp @@ -85,7 +85,7 @@ private: void decodeLoop(); void findAspectRatio(); - void publishFrame(double delay); + void publishFrame(double delay, bool audio_disabled); double synchronizeVideo(double pts); void yuva420pToRgba(AVPicture *dst, AVPicture *src, int width, int height);