diff --git a/core/changelog.txt b/core/changelog.txt index 614b57e39..b6674c622 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -78,6 +78,7 @@ Please visit http://aegisub.net to download latest version o Italian (thanks to EmBoLo) o Korean (thanks to oblisk) - Style editor now uses a dropdown for the encoding field. (AMZ) +- Added 2.35 and custom aspect ratio support for video display. (AMZ) = 1.09 beta - 2006.01.16 =========================== diff --git a/core/frame_main.cpp b/core/frame_main.cpp index 7d479dfa9..204a8038f 100644 --- a/core/frame_main.cpp +++ b/core/frame_main.cpp @@ -279,9 +279,11 @@ void FrameMain::InitMenu() { AppendBitmapMenuItem(videoMenu,Menu_Video_Snap_To_Scene, _("Snap to scene\t") + Hotkeys.GetText(_T("Snap to Scene")), _("Set start and end of subtitles to the keyframes around current video frame"), wxBITMAP(snap_subs_to_scene)); AppendBitmapMenuItem(videoMenu,Menu_Video_Shift_To_Frame, _("Shift to Current Frame\t") + Hotkeys.GetText(_T("Shift by Current Time")), _("Shift selection so first selected line starts at current frame"), wxBITMAP(shift_to_frame)); videoMenu->AppendSeparator(); - videoMenu->AppendRadioItem(Menu_Video_AR_Default, _("&Default Aspect Ratio"), _("Leave video on original aspect ratio")); - videoMenu->AppendRadioItem(Menu_Video_AR_Full, _("&Fullscreen Aspect Ratio (4:3)"), _("Forces video to fullscreen aspect ratio")); - videoMenu->AppendRadioItem(Menu_Video_AR_Wide, _("&Widescreen Aspect Ratio (16:9)"), _("Forces video to widescreen aspect ratio")); + videoMenu->AppendCheckItem(Menu_Video_AR_Default, _("&Default Aspect Ratio"), _("Leave video on original aspect ratio")); + videoMenu->AppendCheckItem(Menu_Video_AR_Full, _("&Fullscreen Aspect Ratio (4:3)"), _("Forces video to fullscreen aspect ratio")); + videoMenu->AppendCheckItem(Menu_Video_AR_Wide, _("&Widescreen Aspect Ratio (16:9)"), _("Forces video to widescreen aspect ratio")); + videoMenu->AppendCheckItem(Menu_Video_AR_235, _("&2.35 Aspect Ratio"), _("Forces video to 2.35 aspect ratio")); + videoMenu->AppendCheckItem(Menu_Video_AR_Custom, _("Custom Aspect Ratio..."), _("Forces video to a custom aspect ratio")); MenuBar->Append(videoMenu, _("&Video")); // Create audio menu @@ -725,6 +727,7 @@ void FrameMain::SynchronizeProject(bool fromSubs) { // Reset the state long videoPos = 0; long videoAr = 0; + double videoArValue = 0.0; long videoZoom = 0; { std::list::const_iterator next = AssAutomationFilter::GetFilterList().begin(), f; @@ -736,9 +739,17 @@ void FrameMain::SynchronizeProject(bool fromSubs) { } } + // Get AR + wxString arString = subs->GetScriptInfo(_T("Video Aspect Ratio")); + if (arString.Left(1) == _T("c")) { + videoAr = 4; + arString = arString.Mid(1); + arString.ToDouble(&videoArValue); + } + else if (arString.IsNumber()) arString.ToLong(&videoAr); + // Get new state info subs->GetScriptInfo(_T("Video Position")).ToLong(&videoPos); - subs->GetScriptInfo(_T("Video Aspect Ratio")).ToLong(&videoAr); subs->GetScriptInfo(_T("Video Zoom")).ToLong(&videoZoom); wxString curSubsVideo = DecodeRelativePath(subs->GetScriptInfo(_T("Video File")),AssFile::top->filename); wxString curSubsVFR = DecodeRelativePath(subs->GetScriptInfo(_T("VFR File")),AssFile::top->filename); @@ -802,7 +813,7 @@ void FrameMain::SynchronizeProject(bool fromSubs) { LoadVideo(curSubsVideo); if (videoBox->videoDisplay->loaded) { videoBox->videoDisplay->JumpToFrame(videoPos); - videoBox->videoDisplay->SetAspectRatio(videoAr); + videoBox->videoDisplay->SetAspectRatio(videoAr,videoArValue); videoBox->videoDisplay->SetZoomPos(videoZoom-1); } } @@ -827,8 +838,11 @@ void FrameMain::SynchronizeProject(bool fromSubs) { wxString zoom = _T("6"); if (videoBox->videoDisplay->loaded) { seekpos = wxString::Format(_T("%i"),videoBox->videoDisplay->ControlSlider->GetValue()); - ar = wxString::Format(_T("%i"),videoBox->videoDisplay->GetAspectRatio()); zoom = wxString::Format(_T("%i"),videoBox->videoDisplay->zoomBox->GetSelection()+1); + + int arType = videoBox->videoDisplay->GetAspectRatioType(); + if (arType == 4) ar = wxString(_T("c")) + FloatToString(videoBox->videoDisplay->GetAspectRatioValue()); + else ar = wxString::Format(_T("%i"),arType); } // Store audio data diff --git a/core/frame_main.h b/core/frame_main.h index ce039d847..a2ec097d6 100644 --- a/core/frame_main.h +++ b/core/frame_main.h @@ -157,6 +157,8 @@ private: void OnSetARDefault (wxCommandEvent &event); void OnSetARWide (wxCommandEvent &event); void OnSetARFull (wxCommandEvent &event); + void OnSetAR235 (wxCommandEvent &event); + void OnSetARCustom (wxCommandEvent &event); void OnOpenAudio (wxCommandEvent &event); void OnOpenAudioFromVideo (wxCommandEvent &event); @@ -282,6 +284,8 @@ enum { Menu_Video_AR_Default, Menu_Video_AR_Full, Menu_Video_AR_Wide, + Menu_Video_AR_235, + Menu_Video_AR_Custom, Menu_Video_Select_Visible, Menu_Audio_Open_File, diff --git a/core/frame_main_events.cpp b/core/frame_main_events.cpp index 052582643..dbdb38238 100644 --- a/core/frame_main_events.cpp +++ b/core/frame_main_events.cpp @@ -79,6 +79,7 @@ #include "dialog_fextracker.h" #endif #include "dialog_progress.h" +#include "utils.h" //////////////////// @@ -142,6 +143,8 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame) EVT_MENU(Menu_Video_AR_Default, FrameMain::OnSetARDefault) EVT_MENU(Menu_Video_AR_Full, FrameMain::OnSetARFull) EVT_MENU(Menu_Video_AR_Wide, FrameMain::OnSetARWide) + EVT_MENU(Menu_Video_AR_235, FrameMain::OnSetAR235) + EVT_MENU(Menu_Video_AR_Custom, FrameMain::OnSetARCustom) EVT_MENU(Menu_Video_JumpTo, FrameMain::OnJumpTo) EVT_MENU(Menu_Video_Select_Visible, FrameMain::OnSelectVisible) @@ -271,12 +274,24 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { MenuBar->Enable(Menu_Video_AR_Default,state); MenuBar->Enable(Menu_Video_AR_Full,state); 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? // Set AR radio - if (videoBox->videoDisplay->arType == 0) MenuBar->Check(Menu_Video_AR_Default,true); - if (videoBox->videoDisplay->arType == 1) MenuBar->Check(Menu_Video_AR_Full,true); - if (videoBox->videoDisplay->arType == 2) MenuBar->Check(Menu_Video_AR_Wide,true); + int arType = videoBox->videoDisplay->GetAspectRatioType(); + MenuBar->Check(Menu_Video_AR_Default,false); + MenuBar->Check(Menu_Video_AR_Full,false); + MenuBar->Check(Menu_Video_AR_Wide,false); + MenuBar->Check(Menu_Video_AR_235,false); + MenuBar->Check(Menu_Video_AR_Custom,false); + switch (arType) { + case 0: MenuBar->Check(Menu_Video_AR_Default,true); break; + case 1: MenuBar->Check(Menu_Video_AR_Full,true); break; + case 2: MenuBar->Check(Menu_Video_AR_Wide,true); break; + case 3: MenuBar->Check(Menu_Video_AR_235,true); break; + case 4: MenuBar->Check(Menu_Video_AR_Custom,true); break; + } // Wipe recent int count = RecentVids->GetMenuItemCount(); @@ -974,6 +989,51 @@ void FrameMain::OnSetARWide (wxCommandEvent &event) { } +/////////////////////////////// +// Change aspect ratio to 2:35 +void FrameMain::OnSetAR235 (wxCommandEvent &event) { + videoBox->videoDisplay->Stop(); + videoBox->videoDisplay->SetAspectRatio(3); + SetDisplayMode(-1); +} + + +///////////////////////////////////////// +// Change aspect ratio to a custom value +void FrameMain::OnSetARCustom (wxCommandEvent &event) { + // Get text + videoBox->videoDisplay->Stop(); + wxString value = wxGetTextFromUser(_T("Enter aspect ratio in either decimal (e.g. 2.35) or fractional (e.g. 16:9) form:"),_T("Enter aspect ratio"),FloatToString(videoBox->videoDisplay->GetAspectRatioValue())); + + // Process text + double numval = 0.0; + value.Replace(_T(","),_T(".")); + if (value.Freq(_T('.')) == 1) { + value.ToDouble(&numval); + } + else if (value.Freq(_T(':')) == 1) { + int pos = value.Find(_T(':')); + wxString num = value.Left(pos); + wxString denum = value.Mid(pos+1); + if (num.IsNumber() && denum.IsNumber()) { + double a,b; + num.ToDouble(&a); + denum.ToDouble(&b); + if (b != 0) numval = a/b; + } + } + + // Sanity check + if (numval < 0.5 || numval > 5.0) wxMessageBox(_T("Invalid value! Aspect ratio must be between 0.5 and 5.0."),_T("Invalid Aspect Ratio"),wxICON_ERROR); + + // Set value + else { + videoBox->videoDisplay->SetAspectRatio(4,numval); + SetDisplayMode(-1); + } +} + + //////////////////////////////////// // Window is attempted to be closed void FrameMain::OnCloseWindow (wxCloseEvent &event) { diff --git a/core/video_display.cpp b/core/video_display.cpp index 6699697b8..1fb3d3050 100644 --- a/core/video_display.cpp +++ b/core/video_display.cpp @@ -506,16 +506,24 @@ double VideoDisplay::GetARFromType(int type) { if (type == 0) return (double)provider->GetSourceWidth()/(double)provider->GetSourceHeight(); if (type == 1) return 4.0/3.0; if (type == 2) return 16.0/9.0; - return 1; //error + if (type == 3) return 2.35; + return 1.0; //error } ///////////////////// // Sets aspect ratio -void VideoDisplay::SetAspectRatio(int value) { +void VideoDisplay::SetAspectRatio(int _type, double value) { if (provider) { - provider->SetDAR(GetARFromType(value)); - arType = value; + // Get value + if (_type != 4) value = GetARFromType(_type); + if (value < 0.5) value = 0.5; + if (value > 5.0) value = 5.0; + + // Set + provider->SetDAR(value); + arType = _type; + arValue = value; UpdateSize(); RefreshVideo(); GetParent()->Layout(); diff --git a/core/video_display.h b/core/video_display.h index b6688d0b9..63761127c 100644 --- a/core/video_display.h +++ b/core/video_display.h @@ -77,6 +77,8 @@ private: int StartFrame; int EndFrame; int PlayNextFrame; + double arValue; + int arType; wxBitmap GetFrame(int n); wxBitmap GetFrame() { return GetFrame(frame_n); }; @@ -100,7 +102,6 @@ public: wxArrayInt KeyFrames; SubtitlesGrid *grid; wxString videoName; - int arType; int w,h; int frame_n; int length; @@ -133,15 +134,17 @@ public: void RefreshVideo(); void DrawText( wxPoint Pos, wxString Text ); void UpdatePositionDisplay(); - double GetARFromType(int type); - void SetAspectRatio(int type); void SetZoom(double value); - int GetAspectRatio() { return arType; } void SetZoomPos(int pos); void UpdateSubsRelativeTime(); void GetScriptSize(int &w,int &h); wxString GetTempWorkFile (); + double GetARFromType(int type); + void SetAspectRatio(int type,double value=1.0); + int GetAspectRatioType() { return arType; } + double GetAspectRatioValue() { return arValue; } + void Play(); void PlayLine(); void Stop();