Browse Source

add ffmpeg-show-seek-frames

David Rose 14 years ago
parent
commit
560221d566

+ 10 - 0
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 "
           "should read in advance of actual playback.  Set this to 0 to "
           "decode ffmpeg videos in the main thread."));
           "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
 ConfigVariableBool ffmpeg_support_seek
 ("ffmpeg-support-seek", true,
 ("ffmpeg-support-seek", true,
  PRC_DESC("True to use the av_seek_frame() function to seek within ffmpeg "
  PRC_DESC("True to use the av_seek_frame() function to seek within ffmpeg "

+ 1 - 0
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);
 NotifyCategoryDecl(ffmpeg, EXPCL_PANDA_MOVIES, EXPTP_PANDA_MOVIES);
 
 
 extern ConfigVariableInt ffmpeg_max_readahead_frames;
 extern ConfigVariableInt ffmpeg_max_readahead_frames;
+extern ConfigVariableBool ffmpeg_show_seek_frames;
 extern ConfigVariableBool ffmpeg_support_seek;
 extern ConfigVariableBool ffmpeg_support_seek;
 extern ConfigVariableBool ffmpeg_global_lock;
 extern ConfigVariableBool ffmpeg_global_lock;
 extern ConfigVariableEnum<ThreadPriority> ffmpeg_thread_priority;
 extern ConfigVariableEnum<ThreadPriority> ffmpeg_thread_priority;

+ 8 - 4
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) {
   if (frame != NULL) {