fix vfr handling for the ffmpegsource video provider, entire thing should be considered working now

Originally committed to SVN as r2313.
This commit is contained in:
Karl Blomster 2008-09-03 21:03:18 +00:00
parent 98341f62be
commit 3e13ef206f
2 changed files with 14 additions and 5 deletions

View file

@ -157,6 +157,9 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps)
VFR_Input.SetVFR(TimecodesVector); VFR_Input.SetVFR(TimecodesVector);
VFR_Output.SetVFR(TimecodesVector); VFR_Output.SetVFR(TimecodesVector);
} }
} else { // no timecodes loaded, go ahead and apply
VFR_Input.SetVFR(TimecodesVector);
VFR_Output.SetVFR(TimecodesVector);
} }
// we don't need this anymore // we don't need this anymore
@ -188,16 +191,22 @@ void FFmpegSourceVideoProvider::Close() {
/////////////// ///////////////
// Get frame // Get frame
const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int n, int FormatType) { const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int _n, int FormatType) {
// don't try to seek to insane places
int n = _n;
if (n < 0)
n = 0;
if (n >= GetFrameCount())
n = GetFrameCount()-1;
// set position
FrameNumber = n;
const AVFrameLite *SrcFrame = FFMS_GetFrame(VideoSource, n, FFMSErrorMessage, MessageSize); const AVFrameLite *SrcFrame = FFMS_GetFrame(VideoSource, n, FFMSErrorMessage, MessageSize);
if (SrcFrame == NULL) { if (SrcFrame == NULL) {
ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage); ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage);
throw ErrorMsg; throw ErrorMsg;
} }
// set position
FrameNumber = n;
AVPicture *SrcPicture = reinterpret_cast<AVPicture *>(const_cast<AVFrameLite *>(SrcFrame)); AVPicture *SrcPicture = reinterpret_cast<AVPicture *>(const_cast<AVFrameLite *>(SrcFrame));
// prepare stuff for conversion to RGB32 // prepare stuff for conversion to RGB32

View file

@ -94,7 +94,7 @@ public:
bool AreKeyFramesLoaded() { return KeyFramesLoaded; }; bool AreKeyFramesLoaded() { return KeyFramesLoaded; };
wxArrayInt GetKeyFrames() { return KeyFramesList; }; wxArrayInt GetKeyFrames() { return KeyFramesList; };
bool IsVFR() { return true; }; bool IsVFR() { return true; };
FrameRate GetTrueFrameRate() { return FrameRate(); }; FrameRate GetTrueFrameRate() { return Timecodes; };
Aegisub::String GetDecoderName() { return L"FFmpegSource"; } Aegisub::String GetDecoderName() { return L"FFmpegSource"; }
bool IsNativelyByFrames() { return true; } bool IsNativelyByFrames() { return true; }
int GetDesiredCacheSize() { return 8; } int GetDesiredCacheSize() { return 8; }