From 716539b54a6524d53f2c9105bea97fb5aed4dcd2 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 8 Apr 2007 19:27:46 +0000 Subject: [PATCH] Allowed using detached subtitles providers on avisynth video provider, and changed the advanced video options in the options dialog to reload the video (so you can immediately see the changes) Originally committed to SVN as r1032. --- aegisub/dialog_options.cpp | 13 +++++++++++-- aegisub/options.cpp | 15 +++++++++++---- aegisub/options.h | 1 + aegisub/subtitles_provider.h | 1 + aegisub/video_context.cpp | 22 +++++++++++++++++++--- aegisub/video_context.h | 1 + aegisub/video_provider_avs.cpp | 4 +++- 7 files changed, 47 insertions(+), 10 deletions(-) diff --git a/aegisub/dialog_options.cpp b/aegisub/dialog_options.cpp index 1837a33de..cf343f3df 100644 --- a/aegisub/dialog_options.cpp +++ b/aegisub/dialog_options.cpp @@ -57,6 +57,7 @@ #include "subtitles_provider.h" #include "audio_box.h" #include "audio_display.h" +#include "video_context.h" /////////////// @@ -319,7 +320,7 @@ DialogOptions::DialogOptions(wxWindow *parent) wxSizer *videoSizer1 = new wxStaticBoxSizer(wxVERTICAL,videoPage,_("Options")); wxSizer *videoSizer2 = new wxStaticBoxSizer(wxVERTICAL,videoPage,_("Advanced - EXPERT USERS ONLY")); wxFlexGridSizer *videoSizer3 = new wxFlexGridSizer(5,2,5,5); - wxFlexGridSizer *videoSizer4 = new wxFlexGridSizer(4,2,5,5); + wxFlexGridSizer *videoSizer4 = new wxFlexGridSizer(5,2,5,5); wxControl *control; // First sizer @@ -379,6 +380,9 @@ DialogOptions::DialogOptions(wxWindow *parent) Bind(control,_T("Allow Ancient Avisynth")); videoSizer4->Add(control,1,wxEXPAND); videoSizer4->AddGrowableCol(1,1); + control = new wxCheckBox(videoPage,-1,_("Avisynth renders its own subs")); + Bind(control,_T("Avisynth render own subs")); + videoSizer4->Add(control,1,wxEXPAND); // Sizers videoSizer1->Add(videoSizer3,1,wxEXPAND | wxALL,5); @@ -694,6 +698,7 @@ void DialogOptions::WriteToOptions(bool justApply) { bool mustRestart = false; bool editBox = false; bool grid = false; + bool videoRestart = false; bool video = false; bool audio = false; @@ -767,6 +772,7 @@ void DialogOptions::WriteToOptions(bool justApply) { if (type == MOD_EDIT_BOX) editBox = true; if (type == MOD_GRID) grid = true; if (type == MOD_VIDEO) video = true; + if (type == MOD_VIDEO_RELOAD) videoRestart = true; if (type == MOD_AUDIO) audio = true; } } @@ -802,7 +808,10 @@ void DialogOptions::WriteToOptions(bool justApply) { } // Video - if (video) { + if (videoRestart) { + VideoContext::Get()->Reload(); + } + else if (video) { FrameMain *frame = (FrameMain*) GetParent(); frame->videoBox->videoSlider->Refresh(); } diff --git a/aegisub/options.cpp b/aegisub/options.cpp index 9f18ec598..35b88bcc6 100644 --- a/aegisub/options.cpp +++ b/aegisub/options.cpp @@ -140,6 +140,7 @@ void OptionsManager::LoadDefaults() { SetBool(_T("Show keyframes on video slider"),true); // Dummy video defaults + SetModificationType(MOD_AUTOMATIC); SetInt(_T("Video Dummy Last Width"), 640); SetInt(_T("Video Dummy Last Height"), 480); SetColour(_T("Video Dummy Last Colour"), wxColour(47, 163, 254)); @@ -151,14 +152,20 @@ void OptionsManager::LoadDefaults() { SetModificationType(MOD_RESTART); SetBool(_T("Threaded Video"),false); SetInt(_T("Avisynth MemoryMax"),64); - SetText(_T("Avisynth Subs Renderer"),_T("vsfilter")); - SetModificationType(MOD_AUTOMATIC); - SetBool(_T("Allow Ancient Avisynth"),false); + SetModificationType(MOD_VIDEO_RELOAD); SetText(_T("Video Provider"),_T("Avisynth")); - SetText(_T("Subtitles Provider"),_T("csri")); + SetBool(_T("Allow Ancient Avisynth"),false); + SetText(_T("Avisynth subs renderer"),_T("vsfilter")); + SetBool(_T("Avisynth render own subs"),true); + #ifdef __WINDOWS__ + SetText(_T("Subtitles Provider"),_T("csri/vsfilter")); + #else + SetText(_T("Subtitles Provider"),_T("csri/asa")); + #endif SetBool(_T("Video Use Pixel Shaders"),false); // Audio Options + SetModificationType(MOD_AUTOMATIC); SetBool(_T("Audio Next Line on Commit"),true); SetBool(_T("Audio Autofocus"),false); SetBool(_T("Audio Wheel Default To Zoom"),false); diff --git a/aegisub/options.h b/aegisub/options.h index db45cab35..dfd421869 100644 --- a/aegisub/options.h +++ b/aegisub/options.h @@ -53,6 +53,7 @@ enum ModType { MOD_EDIT_BOX, MOD_GRID, MOD_VIDEO, + MOD_VIDEO_RELOAD, MOD_AUDIO }; diff --git a/aegisub/subtitles_provider.h b/aegisub/subtitles_provider.h index 50657d936..f4933ca6f 100644 --- a/aegisub/subtitles_provider.h +++ b/aegisub/subtitles_provider.h @@ -56,6 +56,7 @@ public: virtual ~SubtitlesProvider(); virtual bool CanRaster() { return false; } + virtual bool LockedToVideo() { return false; } virtual void LoadSubtitles(AssFile *subs)=0; virtual void DrawSubtitles(AegiVideoFrame &dst,double time) {} diff --git a/aegisub/video_context.cpp b/aegisub/video_context.cpp index dba862540..832e04911 100644 --- a/aegisub/video_context.cpp +++ b/aegisub/video_context.cpp @@ -188,10 +188,26 @@ void VideoContext::Reset() { tempFrame.Clear(); // Remove provider - if (provider && subsProvider && provider->GetAsSubtitlesProvider() != subsProvider) delete subsProvider; + if (provider) { + if (subsProvider && !subsProvider->LockedToVideo()) delete subsProvider; + delete provider; + provider = NULL; + } + else delete subsProvider; subsProvider = NULL; - delete provider; - provider = NULL; +} + + +//////////////// +// Reload video +void VideoContext::Reload() { + if (IsLoaded()) { + wxString name = videoName; + int n = frame_n; + SetVideo(_T("")); + SetVideo(name); + JumpToFrame(n); + } } diff --git a/aegisub/video_context.h b/aegisub/video_context.h index f17030591..9664cbc8b 100644 --- a/aegisub/video_context.h +++ b/aegisub/video_context.h @@ -160,6 +160,7 @@ public: void SetVideo(const wxString &filename); void Reset(); + void Reload(); void JumpToFrame(int n); void JumpToTime(int ms,bool exact=false); diff --git a/aegisub/video_provider_avs.cpp b/aegisub/video_provider_avs.cpp index b275f09df..4e82cdcb1 100644 --- a/aegisub/video_provider_avs.cpp +++ b/aegisub/video_provider_avs.cpp @@ -83,6 +83,7 @@ public: SubtitlesProvider *GetAsSubtitlesProvider(); void LoadSubtitles(AssFile *subs); + bool LockedToVideo() { return true; } const AegiVideoFrame DoGetFrame(int n); void GetFloatFrame(float* Buffer, int n); @@ -412,7 +413,8 @@ PClip AvisynthVideoProvider::ApplySubtitles(wxString _filename, PClip videosourc ///////////////////////////// // Get as subtitles provider SubtitlesProvider *AvisynthVideoProvider::GetAsSubtitlesProvider() { - return this; + if (Options.AsBool(_T("Avisynth render own subs"))) return this; + return NULL; }