diff --git a/core/vfr.cpp b/core/vfr.cpp index 93458f740..ef33d36d7 100644 --- a/core/vfr.cpp +++ b/core/vfr.cpp @@ -353,14 +353,23 @@ int FrameRate::GetFrameAtTime(int ms,bool start) { ///////////////////////////// // Get correct time at frame // compensates and returns an end time when start=false -int FrameRate::GetTimeAtFrame(int frame,bool start) { +int FrameRate::GetTimeAtFrame(int frame,bool start,bool exact) { int finalTime; - if (start) { - finalTime = (PTimeAtFrame(frame-1) + PTimeAtFrame(frame))/2; + + // Exact, for display + if (exact) { + finalTime = PTimeAtFrame(frame); } + + // Adjusted, for subs sync else { - if (FrameRateType == VFR) finalTime = PTimeAtFrame(frame); - else finalTime = (PTimeAtFrame(frame) + PTimeAtFrame(frame+1))/2; + if (start) { + finalTime = (PTimeAtFrame(frame-1) + PTimeAtFrame(frame))/2; + } + else { + if (FrameRateType == VFR) finalTime = PTimeAtFrame(frame); + else finalTime = (PTimeAtFrame(frame) + PTimeAtFrame(frame+1))/2; + } } return finalTime; diff --git a/core/vfr.h b/core/vfr.h index 99432586d..7a7742fd2 100644 --- a/core/vfr.h +++ b/core/vfr.h @@ -88,7 +88,7 @@ public: void Load(wxString file); void Unload(); int GetFrameAtTime(int ms,bool start=true); - int GetTimeAtFrame(int frame,bool start=true); + int GetTimeAtFrame(int frame,bool start=true,bool exact=false); double GetAverage() { return AverageFrameRate; }; bool IsLoaded() { return loaded; }; diff --git a/core/video_display.cpp b/core/video_display.cpp index 1da48d4c2..0e7a7c1f6 100644 --- a/core/video_display.cpp +++ b/core/video_display.cpp @@ -207,6 +207,7 @@ void VideoDisplay::SetVideo(const wxString &filename) { Options.AddToRecentList(filename,_T("Recent vid")); RefreshVideo(); + UpdatePositionDisplay(); } catch (wxString &e) { wxMessageBox(e,_T("Error setting video"),wxICON_ERROR | wxOK); } @@ -520,8 +521,7 @@ void VideoDisplay::UpdatePositionDisplay() { } // Get time - int time = VFR_Output.GetTimeAtFrame(frame_n); - //int time = VFR_Output.CorrectTimeAtFrame(frame_n,false); + int time = VFR_Output.GetTimeAtFrame(frame_n,true,true); int temp = time; int h=0, m=0, s=0, ms=0; while (temp >= 3600000) { @@ -564,7 +564,7 @@ void VideoDisplay::UpdateSubsRelativeTime() { // Set start/end if (curLine) { - int time = VFR_Output.GetTimeAtFrame(frame_n); + int time = VFR_Output.GetTimeAtFrame(frame_n,true,true); startOff = time - curLine->Start.GetMS(); endOff = time - curLine->End.GetMS(); }