Originally committed to SVN as r136.
This commit is contained in:
Fredrik Mellbin 2006-02-23 23:13:56 +00:00
parent 81ae0ae3ae
commit adf7f76d1e

View file

@ -59,14 +59,11 @@ void FrameRate::AddFrame(int ms) {
////////////////// //////////////////
// V2 Get Average // V2 Get Average
void FrameRate::CalcAverage() { void FrameRate::CalcAverage() {
double last = 0.0;
int frames = 0;
for (std::vector<int>::iterator cur=Frame.begin();cur!=Frame.end();cur++) {
last = *cur;
frames++;
}
AverageFrameRate = double(frames)*1000.0/last; if (Frame.size() <= 0)
throw _("No timecodes to average");
AverageFrameRate = double(Frame.back()) / Frame.size();
} }
@ -246,7 +243,13 @@ void FrameRate::Load(wxString filename) {
wxString tmp = curLine.BeforeFirst(_T('.')); wxString tmp = curLine.BeforeFirst(_T('.'));
tmp.ToLong(&cftime); tmp.ToLong(&cftime);
wxASSERT(lftime < cftime);
if (lftime < cftime) {
file.close();
Unload();
throw _T("Out of order timecodes found");
}
AddFrame(cftime); AddFrame(cftime);
lftime = cftime; lftime = cftime;
} }
@ -254,6 +257,8 @@ void FrameRate::Load(wxString filename) {
last_time = cftime; last_time = cftime;
last_frame = Frame.size(); last_frame = Frame.size();
CalcAverage();
} }
// Unknown // Unknown
@ -284,7 +289,6 @@ void FrameRate::Load(wxString filename) {
loaded = true; loaded = true;
vfrFile = filename; vfrFile = filename;
FrameRateType = VFR; FrameRateType = VFR;
CalcAverage();
} }
@ -309,7 +313,6 @@ void FrameRate::SetCFR(double fps,bool ifunset) {
Unload(); Unload();
loaded = true; loaded = true;
vfrFile = _T("");
FrameRateType = CFR; FrameRateType = CFR;
AverageFrameRate = fps; AverageFrameRate = fps;
} }
@ -320,15 +323,15 @@ void FrameRate::SetCFR(double fps,bool ifunset) {
void FrameRate::SetVFR(std::vector<int> newTimes) { void FrameRate::SetVFR(std::vector<int> newTimes) {
// Prepare // Prepare
Unload(); Unload();
loaded = true; loaded = true;
vfrFile = _T("");
FrameRateType = VFR; FrameRateType = VFR;
// Set new VFR // Set new VFR;
AverageFrameRate = newTimes.back() / (newTimes.size()-1);
Frame = newTimes; Frame = newTimes;
CalcAverage();
last_time = newTimes.back(); last_time = newTimes.back();
last_frame = newTimes.size()-1; last_frame = newTimes.size();
} }