added option to allow potentially unsafe seeking with the ffmpeg video provider. named "ffmpeg allow unsafe seeking" and defaults to false.

Originally committed to SVN as r2254.
This commit is contained in:
Karl Blomster 2008-07-15 14:24:00 +00:00
parent cdb2227024
commit 904873f0d9
3 changed files with 12 additions and 3 deletions

View file

@ -165,6 +165,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults,bool doOverride) {
#else
SetText(_T("Video Provider"),_T("FFMPEG"),1945);
#endif
SetBool(_T("FFmpeg allow unsafe seeking"),false);
SetBool(_T("Allow Ancient Avisynth"),false,1700);
SetText(_T("Avisynth subs renderer"),_T("vsfilter"),1700);
SetBool(_T("Avisynth render own subs"),true,1700);

View file

@ -57,6 +57,7 @@
#include "ass_file.h"
#include "lavc_keyframes.h"
#include "video_context.h"
#include "options.h"
///////////////
@ -154,6 +155,8 @@ void LAVCVideoProvider::LoadVideo(Aegisub::String filename, double fps) {
// Set frame
frameNumber = -1;
lastFrameNumber = -1;
allowUnsafeSeeking = Options.AsBool(_T("FFmpeg allow unsafe seeking"));
}
// Catch errors
@ -398,9 +401,13 @@ const AegiVideoFrame LAVCVideoProvider::GetFrame(int n,int formatType) {
hasSeeked = false;
// is the seek destination known? does it belong to a frame?
if (startTime < 0 || (frameNumber = FrameFromDTS(startTime)) < 0)
throw _T("ffmpeg video provider: frame accurate seeking failed");
//frameNumber = ClosestFrameFromDTS(startTime);
if (startTime < 0 || (frameNumber = FrameFromDTS(startTime)) < 0) {
if (allowUnsafeSeeking)
frameNumber = ClosestFrameFromDTS(startTime);
else
throw _T("ffmpeg video provider: frame accurate seeking failed");
}
}
frameNumber++;

View file

@ -82,6 +82,7 @@ private:
wxArrayInt bytePos;
bool allowUnsafeSeeking;
bool isMkv;
int64_t lastDecodeTime;
int frameNumber;