mirror of https://github.com/odrling/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
|
@ -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 {
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
20
core/vfr.cpp
20
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<int> newTimes) {
|
|||
// Prepare
|
||||
Unload();
|
||||
|
||||
//loaded = true;
|
||||
loaded = true;
|
||||
FrameRateType = VFR;
|
||||
|
||||
// Set new VFR;
|
||||
|
@ -271,13 +263,13 @@ 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 (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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue