diff --git a/core/automation.cpp b/core/automation.cpp index 9e03949d8..da96c46c1 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.IsLoaded()) { + if (VFR_Output.GetFrameRateType() != NONE) { 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.IsLoaded()) { + if (VFR_Output.GetFrameRateType() != NONE) { 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 af7a50a24..8d4205455 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.IsLoaded()) RadioFrames->Disable(); + if (VFR_Output.GetFrameRateType() == NONE) 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 3e6f4a977..adb35e07d 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.IsLoaded(); + bool keysAvailable = VFR_Output.GetFrameRateType() != NONE; bool enableKeys = keysEnable->IsChecked() && keysAvailable; keysStartBefore->Enable(enableKeys); keysStartAfter->Enable(enableKeys); diff --git a/core/export_framerate.cpp b/core/export_framerate.cpp index a5ebb8d5f..1f1a66022 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.IsLoaded()) initialInput = wxString::Format(_T("%2.3f"),VFR_Input.GetAverage()); + if (VFR_Input.GetFrameRateType() != NONE) 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 9dc15b5cf..c9712d1d4 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.IsLoaded()) { + if (videoBox->videoDisplay->loaded && VFR_Output.GetFrameRateType() == NONE) { VFR_Output.SetCFR(videoBox->videoDisplay->fps); } } diff --git a/core/frame_main_events.cpp b/core/frame_main_events.cpp index 183894866..63e9f94ba 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.GetFrameRateType() == VFR); //fix me, wrong? + MenuBar->Enable(Menu_File_Close_VFR,VFR_Output.IsLoaded()); // Set AR radio int arType = videoBox->videoDisplay->GetAspectRatioType(); diff --git a/core/subs_edit_box.cpp b/core/subs_edit_box.cpp index 6adf68822..61d00b8f9 100644 --- a/core/subs_edit_box.cpp +++ b/core/subs_edit_box.cpp @@ -560,7 +560,7 @@ void SubsEditBox::SetControlsState (bool state) { //////////////////////////////////// // Disables or enables frame timing void SubsEditBox::UpdateFrameTiming () { - if (VFR_Output.IsLoaded()) ByFrame->Enable(enabled); + if (VFR_Output.GetFrameRateType() != NONE) ByFrame->Enable(enabled); else { ByFrame->Enable(false); ByTime->SetValue(true); diff --git a/core/subs_grid.cpp b/core/subs_grid.cpp index 399ea6933..b1659a488 100644 --- a/core/subs_grid.cpp +++ b/core/subs_grid.cpp @@ -137,7 +137,7 @@ void SubtitlesGrid::OnPopupMenu() { // 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.IsLoaded()); + 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_SPLIT_BY_KARAOKE,_("Split (by karaoke)"),_T("Uses karaoke timing to split line into multiple smaller lines"))->Enable(sels > 0); // Swaps selection @@ -247,7 +247,7 @@ void SubtitlesGrid::OnKeyDown(wxKeyEvent &event) { } // Duplicate and shift - if (VFR_Output.IsLoaded()) { + if (VFR_Output.GetFrameRateType() != NONE) { if (Hotkeys.IsPressed(_T("Grid duplicate and shift one frame"))) { DuplicateLines(n,n2,true); return; @@ -1197,7 +1197,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.IsLoaded()) return; + if (VFR_Output.GetFrameRateType() == NONE) 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 c9b9d9795..af2cb1aad 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.IsLoaded()) { + if (VFR_Output.GetFrameRateType() != NONE) { byFrame = true; UpdateText(); } diff --git a/core/vfr.cpp b/core/vfr.cpp index ba71bd9e0..9775bccbf 100644 --- a/core/vfr.cpp +++ b/core/vfr.cpp @@ -215,7 +215,15 @@ void FrameRate::Load(wxString filename) { // Close file loaded = true; vfrFile = filename; - FrameRateType = VFR; + 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; + } } @@ -236,7 +244,7 @@ void FrameRate::Unload () { // Sets to CFR void FrameRate::SetCFR(double fps) { Unload(); - loaded = true; + //loaded = true; FrameRateType = CFR; AverageFrameRate = fps; } @@ -248,7 +256,7 @@ void FrameRate::SetVFR(std::vector newTimes) { // Prepare Unload(); - loaded = true; + //loaded = true; FrameRateType = VFR; // Set new VFR; @@ -263,7 +271,7 @@ void FrameRate::SetVFR(std::vector newTimes) { // Gets frame number at time int FrameRate::PFrameAtTime(int ms,bool useceil) { // Check if it's loaded - if (!loaded) return -1; + if (FrameRateType == NONE) return -1; // Normalize miliseconds ms = MAX(ms,0); @@ -326,7 +334,7 @@ int FrameRate::PFrameAtTime(int ms,bool useceil) { // Gets time at frame int FrameRate::PTimeAtFrame(int frame) { // Not loaded - if (!loaded) return -1; + if (FrameRateType == NONE) return -1; // For negative/zero times, fallback to zero if (frame <= 0) return 0;