forked from mia/Aegisub
Re-fixed VFR bug #138... (rolling back previous fix)
Originally committed to SVN as r432.
This commit is contained in:
parent
b1671d596c
commit
20a38ca021
10 changed files with 19 additions and 27 deletions
|
@ -418,7 +418,7 @@ namespace AutomationHelper {
|
||||||
{
|
{
|
||||||
int ms = (int)lua_tonumber(L, -1);
|
int ms = (int)lua_tonumber(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
if (VFR_Output.GetFrameRateType() != NONE) {
|
if (VFR_Output.IsLoaded()) {
|
||||||
lua_pushnumber(L, VFR_Output.GetFrameAtTime(ms, true));
|
lua_pushnumber(L, VFR_Output.GetFrameAtTime(ms, true));
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -443,7 +443,7 @@ namespace AutomationHelper {
|
||||||
{
|
{
|
||||||
int frame = (int)lua_tonumber(L, -1);
|
int frame = (int)lua_tonumber(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
if (VFR_Output.GetFrameRateType() != NONE) {
|
if (VFR_Output.IsLoaded()) {
|
||||||
lua_pushnumber(L, VFR_Output.GetTimeAtFrame(frame, true));
|
lua_pushnumber(L, VFR_Output.GetTimeAtFrame(frame, true));
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -70,7 +70,7 @@ DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid,VideoD
|
||||||
ShiftTime->SetToolTip(_("Enter time in h:mm:ss.cs notation"));
|
ShiftTime->SetToolTip(_("Enter time in h:mm:ss.cs notation"));
|
||||||
RadioTime->SetToolTip(_("Shift by time"));
|
RadioTime->SetToolTip(_("Shift by time"));
|
||||||
ShiftFrame->Disable();
|
ShiftFrame->Disable();
|
||||||
if (VFR_Output.GetFrameRateType() == NONE) RadioFrames->Disable();
|
if (!VFR_Output.IsLoaded()) RadioFrames->Disable();
|
||||||
else {
|
else {
|
||||||
ShiftFrame->SetToolTip(_("Enter number of frames to shift by"));
|
ShiftFrame->SetToolTip(_("Enter number of frames to shift by"));
|
||||||
RadioFrames->SetToolTip(_("Shift by frames"));
|
RadioFrames->SetToolTip(_("Shift by frames"));
|
||||||
|
|
|
@ -197,7 +197,7 @@ void DialogTimingProcessor::UpdateControls() {
|
||||||
adjascentThres->Enable(adjsEnable->IsChecked());
|
adjascentThres->Enable(adjsEnable->IsChecked());
|
||||||
|
|
||||||
// Keyframes are only available if timecodes are loaded
|
// Keyframes are only available if timecodes are loaded
|
||||||
bool keysAvailable = VFR_Output.GetFrameRateType() != NONE;
|
bool keysAvailable = VFR_Output.IsLoaded();
|
||||||
bool enableKeys = keysEnable->IsChecked() && keysAvailable;
|
bool enableKeys = keysEnable->IsChecked() && keysAvailable;
|
||||||
keysStartBefore->Enable(enableKeys);
|
keysStartBefore->Enable(enableKeys);
|
||||||
keysStartAfter->Enable(enableKeys);
|
keysStartAfter->Enable(enableKeys);
|
||||||
|
|
|
@ -84,7 +84,7 @@ wxWindow *AssTransformFramerateFilter::GetConfigDialogWindow(wxWindow *parent) {
|
||||||
wxSizer *InputSizer = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *InputSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxString initialInput;
|
wxString initialInput;
|
||||||
wxButton *FromVideo = new wxButton(base,Get_Input_From_Video,_("From Video"));
|
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 {
|
else {
|
||||||
initialInput = _T("23.976");
|
initialInput = _T("23.976");
|
||||||
FromVideo->Enable(false);
|
FromVideo->Enable(false);
|
||||||
|
|
|
@ -974,7 +974,7 @@ void FrameMain::LoadVFR(wxString filename) {
|
||||||
|
|
||||||
else {
|
else {
|
||||||
VFR_Output.Unload();
|
VFR_Output.Unload();
|
||||||
if (videoBox->videoDisplay->loaded && VFR_Output.GetFrameRateType() == NONE) {
|
if (videoBox->videoDisplay->loaded && !VFR_Output.IsLoaded()) {
|
||||||
VFR_Output.SetCFR(videoBox->videoDisplay->fps);
|
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_Wide,state);
|
||||||
MenuBar->Enable(Menu_Video_AR_235,state);
|
MenuBar->Enable(Menu_Video_AR_235,state);
|
||||||
MenuBar->Enable(Menu_Video_AR_Custom,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
|
// Set AR radio
|
||||||
int arType = videoBox->videoDisplay->GetAspectRatioType();
|
int arType = videoBox->videoDisplay->GetAspectRatioType();
|
||||||
|
|
|
@ -567,7 +567,7 @@ void SubsEditBox::SetControlsState (bool state) {
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
// Disables or enables frame timing
|
// Disables or enables frame timing
|
||||||
void SubsEditBox::UpdateFrameTiming () {
|
void SubsEditBox::UpdateFrameTiming () {
|
||||||
if (VFR_Output.GetFrameRateType() != NONE) ByFrame->Enable(enabled);
|
if (VFR_Output.IsLoaded()) ByFrame->Enable(enabled);
|
||||||
else {
|
else {
|
||||||
ByFrame->Enable(false);
|
ByFrame->Enable(false);
|
||||||
ByTime->SetValue(true);
|
ByTime->SetValue(true);
|
||||||
|
|
|
@ -163,7 +163,7 @@ void SubtitlesGrid::OnPopupMenu(bool alternate) {
|
||||||
|
|
||||||
// Duplicate selection
|
// Duplicate selection
|
||||||
menu.Append(MENU_DUPLICATE,_("&Duplicate"),_T("Duplicate the selected lines"))->Enable(continuous);
|
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);
|
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
|
// Swaps selection
|
||||||
|
@ -290,7 +290,7 @@ void SubtitlesGrid::OnKeyDown(wxKeyEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duplicate and shift
|
// Duplicate and shift
|
||||||
if (VFR_Output.GetFrameRateType() != NONE) {
|
if (VFR_Output.IsLoaded()) {
|
||||||
if (Hotkeys.IsPressed(_T("Grid duplicate and shift one frame"))) {
|
if (Hotkeys.IsPressed(_T("Grid duplicate and shift one frame"))) {
|
||||||
DuplicateLines(n,n2,true);
|
DuplicateLines(n,n2,true);
|
||||||
return;
|
return;
|
||||||
|
@ -1240,7 +1240,7 @@ void SubtitlesGrid::CommitChanges(bool force) {
|
||||||
// Set start to video pos
|
// Set start to video pos
|
||||||
void SubtitlesGrid::SetSubsToVideo(bool start) {
|
void SubtitlesGrid::SetSubsToVideo(bool start) {
|
||||||
// Check if it's OK to do it
|
// Check if it's OK to do it
|
||||||
if (VFR_Output.GetFrameRateType() == NONE) return;
|
if (!VFR_Output.IsLoaded()) return;
|
||||||
|
|
||||||
// Get new time
|
// Get new time
|
||||||
int ms = VFR_Output.GetTimeAtFrame(video->frame_n,start);
|
int ms = VFR_Output.GetTimeAtFrame(video->frame_n,start);
|
||||||
|
|
|
@ -104,7 +104,7 @@ void TimeEdit::SetByFrame(bool enable) {
|
||||||
|
|
||||||
// By frames
|
// By frames
|
||||||
if (enable) {
|
if (enable) {
|
||||||
if (VFR_Output.GetFrameRateType() != NONE) {
|
if (VFR_Output.IsLoaded()) {
|
||||||
byFrame = true;
|
byFrame = true;
|
||||||
UpdateText();
|
UpdateText();
|
||||||
}
|
}
|
||||||
|
|
20
core/vfr.cpp
20
core/vfr.cpp
|
@ -215,16 +215,8 @@ void FrameRate::Load(wxString filename) {
|
||||||
// Close file
|
// Close file
|
||||||
loaded = true;
|
loaded = true;
|
||||||
vfrFile = filename;
|
vfrFile = filename;
|
||||||
if (Frame.size() > 0) {
|
|
||||||
// At least some frames were loaded
|
|
||||||
FrameRateType = VFR;
|
FrameRateType = VFR;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// No frames were loaded, this might be a timecode file without any sections/frames defined
|
|
||||||
// Assume CFR then
|
|
||||||
FrameRateType = CFR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
|
@ -244,7 +236,7 @@ void FrameRate::Unload () {
|
||||||
// Sets to CFR
|
// Sets to CFR
|
||||||
void FrameRate::SetCFR(double fps) {
|
void FrameRate::SetCFR(double fps) {
|
||||||
Unload();
|
Unload();
|
||||||
//loaded = true;
|
loaded = true;
|
||||||
FrameRateType = CFR;
|
FrameRateType = CFR;
|
||||||
AverageFrameRate = fps;
|
AverageFrameRate = fps;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +248,7 @@ void FrameRate::SetVFR(std::vector<int> newTimes) {
|
||||||
// Prepare
|
// Prepare
|
||||||
Unload();
|
Unload();
|
||||||
|
|
||||||
//loaded = true;
|
loaded = true;
|
||||||
FrameRateType = VFR;
|
FrameRateType = VFR;
|
||||||
|
|
||||||
// Set new VFR;
|
// Set new VFR;
|
||||||
|
@ -271,13 +263,13 @@ void FrameRate::SetVFR(std::vector<int> newTimes) {
|
||||||
// Gets frame number at time
|
// Gets frame number at time
|
||||||
int FrameRate::PFrameAtTime(int ms,bool useceil) {
|
int FrameRate::PFrameAtTime(int ms,bool useceil) {
|
||||||
// Check if it's loaded
|
// Check if it's loaded
|
||||||
if (FrameRateType == NONE) return -1;
|
if (!loaded) return -1;
|
||||||
|
|
||||||
// Normalize miliseconds
|
// Normalize miliseconds
|
||||||
ms = MAX(ms,0);
|
ms = MAX(ms,0);
|
||||||
|
|
||||||
// Get for constant frame rate
|
// Get for constant frame rate
|
||||||
if (FrameRateType == CFR) {
|
if (FrameRateType == CFR || Frame.size() == 0) {
|
||||||
double value = double(ms) * AverageFrameRate / 1000.0;
|
double value = double(ms) * AverageFrameRate / 1000.0;
|
||||||
if (useceil) return ceil(value);
|
if (useceil) return ceil(value);
|
||||||
else return floor(value);
|
else return floor(value);
|
||||||
|
@ -334,13 +326,13 @@ int FrameRate::PFrameAtTime(int ms,bool useceil) {
|
||||||
// Gets time at frame
|
// Gets time at frame
|
||||||
int FrameRate::PTimeAtFrame(int frame) {
|
int FrameRate::PTimeAtFrame(int frame) {
|
||||||
// Not loaded
|
// Not loaded
|
||||||
if (FrameRateType == NONE) return -1;
|
if (!loaded) return -1;
|
||||||
|
|
||||||
// For negative/zero times, fallback to zero
|
// For negative/zero times, fallback to zero
|
||||||
if (frame <= 0) return 0;
|
if (frame <= 0) return 0;
|
||||||
|
|
||||||
// Constant frame rate
|
// Constant frame rate
|
||||||
if (FrameRateType == CFR) {
|
if (FrameRateType == CFR || Frame.size() == 0) {
|
||||||
return floor(double(frame) / AverageFrameRate * 1000.0);
|
return floor(double(frame) / AverageFrameRate * 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue