Fix for bug #138.
If v1 timecodes are loaded, but no sections found, make timecodes act as CFR with the assumed FPS. Changed semantics of FrameRate::loaded. It now only tells whether the current data were loaded from a timecodes file. To tell whether framerate data are present, test for FrameRate::GetFrameRateType()!=NONE. Originally committed to SVN as r421.
This commit is contained in:
parent
2bad28e999
commit
1fa1d75211
10 changed files with 25 additions and 17 deletions
|
@ -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 {
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
18
core/vfr.cpp
18
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<int> newTimes) {
|
|||
// Prepare
|
||||
Unload();
|
||||
|
||||
loaded = true;
|
||||
//loaded = true;
|
||||
FrameRateType = VFR;
|
||||
|
||||
// Set new VFR;
|
||||
|
@ -263,7 +271,7 @@ void FrameRate::SetVFR(std::vector<int> 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;
|
||||
|
|
Loading…
Reference in a new issue