From 560221d5666a8df2fc728627b443c65722b17cdd Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 22 Nov 2011 22:38:01 +0000 Subject: [PATCH] add ffmpeg-show-seek-frames --- panda/src/movies/config_movies.cxx | 10 ++++++++++ panda/src/movies/config_movies.h | 1 + panda/src/movies/ffmpegVideoCursor.cxx | 12 ++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/panda/src/movies/config_movies.cxx b/panda/src/movies/config_movies.cxx index 1c9f4aa9e0..171ec5cb64 100644 --- a/panda/src/movies/config_movies.cxx +++ b/panda/src/movies/config_movies.cxx @@ -50,6 +50,16 @@ ConfigVariableInt ffmpeg_max_readahead_frames "should read in advance of actual playback. Set this to 0 to " "decode ffmpeg videos in the main thread.")); +ConfigVariableBool ffmpeg_show_seek_frames +("ffmpeg-show-seek-frames", true, + PRC_DESC("Set this true to allow showing the intermediate results of seeking " + "through the ffmpeg stream to a target frame, or false to hold the " + "current frame until the target frame is achieved. This has the " + "biggest effect on videos that are too expensive to decode in real " + "time: when this is true, the video can be seen to animate at least " + "a little bit; when it is false, you may get long periods of one " + "held frame.")); + ConfigVariableBool ffmpeg_support_seek ("ffmpeg-support-seek", true, PRC_DESC("True to use the av_seek_frame() function to seek within ffmpeg " diff --git a/panda/src/movies/config_movies.h b/panda/src/movies/config_movies.h index 676b72abf4..1c98f3f125 100644 --- a/panda/src/movies/config_movies.h +++ b/panda/src/movies/config_movies.h @@ -28,6 +28,7 @@ NotifyCategoryDecl(movies, EXPCL_PANDA_MOVIES, EXPTP_PANDA_MOVIES); NotifyCategoryDecl(ffmpeg, EXPCL_PANDA_MOVIES, EXPTP_PANDA_MOVIES); extern ConfigVariableInt ffmpeg_max_readahead_frames; +extern ConfigVariableBool ffmpeg_show_seek_frames; extern ConfigVariableBool ffmpeg_support_seek; extern ConfigVariableBool ffmpeg_global_lock; extern ConfigVariableEnum ffmpeg_thread_priority; diff --git a/panda/src/movies/ffmpegVideoCursor.cxx b/panda/src/movies/ffmpegVideoCursor.cxx index 48943d02c6..578516da29 100644 --- a/panda/src/movies/ffmpegVideoCursor.cxx +++ b/panda/src/movies/ffmpegVideoCursor.cxx @@ -434,10 +434,14 @@ fetch_buffer() { } } - if (frame != NULL && (frame->_end_frame < _current_frame || frame->_begin_frame > _current_frame)) { - // The frame is too old or too new. Just recycle it. - do_recycle_frame(frame); - frame = NULL; + if (frame != NULL) { + bool too_old = (frame->_end_frame < _current_frame && !ffmpeg_show_seek_frames); + bool too_new = frame->_begin_frame > _current_frame; + if (too_old || too_new) { + // The frame is too old or too new. Just recycle it. + do_recycle_frame(frame); + frame = NULL; + } } if (frame != NULL) {