Fixed minor glitch and some little update to vfr

Originally committed to SVN as r158.
This commit is contained in:
Rodrigo Braz Monteiro 2006-02-24 23:07:30 +00:00
parent 41b140d6b0
commit 9e3ffaf523
3 changed files with 18 additions and 9 deletions

View File

@ -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;

View File

@ -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; };

View File

@ -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();
}