diff --git a/core/automation.cpp b/core/automation.cpp index da96c46c1..9e03949d8 100644 --- a/core/automation.cpp +++ b/core/automation.cpp @@ -418,7 +418,7 @@ namespace AutomationHelper { { int ms = (int)lua_tonumber(L, -1); lua_pop(L, 1); - if (VFR_Output.GetFrameRateType() != NONE) { + if (VFR_Output.IsLoaded()) { lua_pushnumber(L, VFR_Output.GetFrameAtTime(ms, true)); return 1; } else { @@ -443,7 +443,7 @@ namespace AutomationHelper { { int frame = (int)lua_tonumber(L, -1); lua_pop(L, 1); - if (VFR_Output.GetFrameRateType() != NONE) { + if (VFR_Output.IsLoaded()) { lua_pushnumber(L, VFR_Output.GetTimeAtFrame(frame, true)); return 1; } else { diff --git a/core/dialog_shift_times.cpp b/core/dialog_shift_times.cpp index 8d4205455..af7a50a24 100644 --- a/core/dialog_shift_times.cpp +++ b/core/dialog_shift_times.cpp @@ -70,7 +70,7 @@ DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid,VideoD ShiftTime->SetToolTip(_("Enter time in h:mm:ss.cs notation")); RadioTime->SetToolTip(_("Shift by time")); ShiftFrame->Disable(); - if (VFR_Output.GetFrameRateType() == NONE) RadioFrames->Disable(); + if (!VFR_Output.IsLoaded()) RadioFrames->Disable(); else { ShiftFrame->SetToolTip(_("Enter number of frames to shift by")); RadioFrames->SetToolTip(_("Shift by frames")); diff --git a/core/dialog_timing_processor.cpp b/core/dialog_timing_processor.cpp index adb35e07d..3e6f4a977 100644 --- a/core/dialog_timing_processor.cpp +++ b/core/dialog_timing_processor.cpp @@ -197,7 +197,7 @@ void DialogTimingProcessor::UpdateControls() { adjascentThres->Enable(adjsEnable->IsChecked()); // Keyframes are only available if timecodes are loaded - bool keysAvailable = VFR_Output.GetFrameRateType() != NONE; + bool keysAvailable = VFR_Output.IsLoaded(); bool enableKeys = keysEnable->IsChecked() && keysAvailable; keysStartBefore->Enable(enableKeys); keysStartAfter->Enable(enableKeys); diff --git a/core/export_framerate.cpp b/core/export_framerate.cpp index 1f1a66022..a5ebb8d5f 100644 --- a/core/export_framerate.cpp +++ b/core/export_framerate.cpp @@ -84,7 +84,7 @@ wxWindow *AssTransformFramerateFilter::GetConfigDialogWindow(wxWindow *parent) { wxSizer *InputSizer = new wxBoxSizer(wxHORIZONTAL); wxString initialInput; wxButton *FromVideo = new wxButton(base,Get_Input_From_Video,_("From Video")); - if (VFR_Input.GetFrameRateType() != NONE) initialInput = wxString::Format(_T("%2.3f"),VFR_Input.GetAverage()); + if (VFR_Input.IsLoaded()) initialInput = wxString::Format(_T("%2.3f"),VFR_Input.GetAverage()); else { initialInput = _T("23.976"); FromVideo->Enable(false); diff --git a/core/frame_main.cpp b/core/frame_main.cpp index 1ce5942f1..945bf5f71 100644 --- a/core/frame_main.cpp +++ b/core/frame_main.cpp @@ -974,7 +974,7 @@ void FrameMain::LoadVFR(wxString filename) { else { VFR_Output.Unload(); - if (videoBox->videoDisplay->loaded && VFR_Output.GetFrameRateType() == NONE) { + if (videoBox->videoDisplay->loaded && !VFR_Output.IsLoaded()) { VFR_Output.SetCFR(videoBox->videoDisplay->fps); } } diff --git a/core/frame_main_events.cpp b/core/frame_main_events.cpp index ec42fee35..ee738b4f9 100644 --- a/core/frame_main_events.cpp +++ b/core/frame_main_events.cpp @@ -283,7 +283,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { MenuBar->Enable(Menu_Video_AR_Wide,state); MenuBar->Enable(Menu_Video_AR_235,state); MenuBar->Enable(Menu_Video_AR_Custom,state); - MenuBar->Enable(Menu_File_Close_VFR,VFR_Output.IsLoaded()); + MenuBar->Enable(Menu_File_Close_VFR,VFR_Output.GetFrameRateType() == VFR); //fix me, wrong? // Set AR radio int arType = videoBox->videoDisplay->GetAspectRatioType(); diff --git a/core/subs_edit_box.cpp b/core/subs_edit_box.cpp index bee5f58b9..4d3f9ad62 100644 --- a/core/subs_edit_box.cpp +++ b/core/subs_edit_box.cpp @@ -567,7 +567,7 @@ void SubsEditBox::SetControlsState (bool state) { //////////////////////////////////// // Disables or enables frame timing void SubsEditBox::UpdateFrameTiming () { - if (VFR_Output.GetFrameRateType() != NONE) ByFrame->Enable(enabled); + if (VFR_Output.IsLoaded()) ByFrame->Enable(enabled); else { ByFrame->Enable(false); ByTime->SetValue(true); diff --git a/core/subs_grid.cpp b/core/subs_grid.cpp index d34ba39b7..50df91ae9 100644 --- a/core/subs_grid.cpp +++ b/core/subs_grid.cpp @@ -163,7 +163,7 @@ void SubtitlesGrid::OnPopupMenu(bool alternate) { // Duplicate selection menu.Append(MENU_DUPLICATE,_("&Duplicate"),_T("Duplicate the selected lines"))->Enable(continuous); - menu.Append(MENU_DUPLICATE_NEXT_FRAME,_("&Duplicate and shift by 1 frame"),_T("Duplicate lines and shift by one frame"))->Enable(continuous && VFR_Output.GetFrameRateType()!=NONE); + menu.Append(MENU_DUPLICATE_NEXT_FRAME,_("&Duplicate and shift by 1 frame"),_T("Duplicate lines and shift by one frame"))->Enable(continuous && VFR_Output.IsLoaded()); menu.Append(MENU_SPLIT_BY_KARAOKE,_("Split (by karaoke)"),_T("Uses karaoke timing to split line into multiple smaller lines"))->Enable(sels > 0); // Swaps selection @@ -290,7 +290,7 @@ void SubtitlesGrid::OnKeyDown(wxKeyEvent &event) { } // Duplicate and shift - if (VFR_Output.GetFrameRateType() != NONE) { + if (VFR_Output.IsLoaded()) { if (Hotkeys.IsPressed(_T("Grid duplicate and shift one frame"))) { DuplicateLines(n,n2,true); return; @@ -1240,7 +1240,7 @@ void SubtitlesGrid::CommitChanges(bool force) { // Set start to video pos void SubtitlesGrid::SetSubsToVideo(bool start) { // Check if it's OK to do it - if (VFR_Output.GetFrameRateType() == NONE) return; + if (!VFR_Output.IsLoaded()) return; // Get new time int ms = VFR_Output.GetTimeAtFrame(video->frame_n,start); diff --git a/core/timeedit_ctrl.cpp b/core/timeedit_ctrl.cpp index af2cb1aad..c9b9d9795 100644 --- a/core/timeedit_ctrl.cpp +++ b/core/timeedit_ctrl.cpp @@ -104,7 +104,7 @@ void TimeEdit::SetByFrame(bool enable) { // By frames if (enable) { - if (VFR_Output.GetFrameRateType() != NONE) { + if (VFR_Output.IsLoaded()) { byFrame = true; UpdateText(); } diff --git a/core/vfr.cpp b/core/vfr.cpp index b7489a1a0..2061b56ff 100644 --- a/core/vfr.cpp +++ b/core/vfr.cpp @@ -215,15 +215,7 @@ void FrameRate::Load(wxString filename) { // Close file loaded = true; vfrFile = filename; - if (Frame.size() > 0) { - // At least some frames were loaded - FrameRateType = VFR; - } - else { - // No frames were loaded, this might be a timecode file without any sections/frames defined - // Assume CFR then - FrameRateType = CFR; - } + FrameRateType = VFR; } @@ -244,7 +236,7 @@ void FrameRate::Unload () { // Sets to CFR void FrameRate::SetCFR(double fps) { Unload(); - //loaded = true; + loaded = true; FrameRateType = CFR; AverageFrameRate = fps; } @@ -256,7 +248,7 @@ void FrameRate::SetVFR(std::vector newTimes) { // Prepare Unload(); - //loaded = true; + loaded = true; FrameRateType = VFR; // Set new VFR; @@ -271,13 +263,13 @@ void FrameRate::SetVFR(std::vector newTimes) { // Gets frame number at time int FrameRate::PFrameAtTime(int ms,bool useceil) { // Check if it's loaded - if (FrameRateType == NONE) return -1; + if (!loaded) return -1; // Normalize miliseconds ms = MAX(ms,0); // Get for constant frame rate - if (FrameRateType == CFR) { + if (FrameRateType == CFR || Frame.size() == 0) { double value = double(ms) * AverageFrameRate / 1000.0; if (useceil) return ceil(value); else return floor(value); @@ -334,13 +326,13 @@ int FrameRate::PFrameAtTime(int ms,bool useceil) { // Gets time at frame int FrameRate::PTimeAtFrame(int frame) { // Not loaded - if (FrameRateType == NONE) return -1; + if (!loaded) return -1; // For negative/zero times, fallback to zero if (frame <= 0) return 0; // Constant frame rate - if (FrameRateType == CFR) { + if (FrameRateType == CFR || Frame.size() == 0) { return floor(double(frame) / AverageFrameRate * 1000.0); }