Aegisub now supports asa instead of vsfilter under avisynth

Originally committed to SVN as r792.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-15 01:46:59 +00:00
parent 0901d0157e
commit b1fb222591
3 changed files with 61 additions and 9 deletions

View file

@ -135,6 +135,7 @@ void OptionsManager::LoadDefaults() {
SetModificationType(MOD_RESTART); SetModificationType(MOD_RESTART);
SetBool(_T("Threaded Video"),false); SetBool(_T("Threaded Video"),false);
SetInt(_T("Avisynth MemoryMax"),64); SetInt(_T("Avisynth MemoryMax"),64);
SetText(_T("Avisynth Subs Renderer"),_T("vsfilter"));
SetModificationType(MOD_AUTOMATIC); SetModificationType(MOD_AUTOMATIC);
SetBool(_T("Allow Ancient Avisynth"),false); SetBool(_T("Allow Ancient Avisynth"),false);
SetText(_T("Video Provider"),_T("Avisynth")); SetText(_T("Video Provider"),_T("Avisynth"));

View file

@ -64,9 +64,9 @@ AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfi
subfilename = _subfilename; subfilename = _subfilename;
zoom = 1.0; zoom = 1.0;
AVSTRACE(_T("AvisynthVideoProvider: Loading VSFilter")); AVSTRACE(_T("AvisynthVideoProvider: Loading Subtitles Renderer"));
LoadVSFilter(); LoadRenderer();
AVSTRACE(_T("AvisynthVideoProvider: VSFilter loaded")); AVSTRACE(_T("AvisynthVideoProvider: Subtitles Renderer loaded"));
AVSTRACE(_T("AvisynthVideoProvider: Opening video")); AVSTRACE(_T("AvisynthVideoProvider: Opening video"));
RGB32Video = OpenVideo(_filename,mpeg2dec3_priority); RGB32Video = OpenVideo(_filename,mpeg2dec3_priority);
@ -314,10 +314,11 @@ PClip AvisynthVideoProvider::ApplySubtitles(wxString _filename, PClip videosourc
AVSValue args[2] = { videosource, temp }; AVSValue args[2] = { videosource, temp };
try { try {
AVSTRACE(_T("AvisynthVideoProvider::ApplySutitles: Now invoking TextSub")); AVSTRACE(_T("AvisynthVideoProvider::ApplySutitles: Now invoking ") + rendererCallString);
script = env->Invoke("TextSub", AVSValue(args,2)); script = env->Invoke(rendererCallString.mb_str(wxConvUTF8), AVSValue(args,2));
AVSTRACE(_T("AvisynthVideoProvider::ApplySutitles: TextSub invoked successfully")); AVSTRACE(_T("AvisynthVideoProvider::ApplySutitles: Invoked successfully"));
} catch (AvisynthError &err) { }
catch (AvisynthError &err) {
AVSTRACE(_T("AvisynthVideoProvider::ApplySutitles: Avisynth error: ") + wxString(err.msg,wxConvLocal)); AVSTRACE(_T("AvisynthVideoProvider::ApplySutitles: Avisynth error: ") + wxString(err.msg,wxConvLocal));
throw _T("AviSynth error: ") + wxString(err.msg,wxConvLocal); throw _T("AviSynth error: ") + wxString(err.msg,wxConvLocal);
} }
@ -471,6 +472,18 @@ void AvisynthVideoProvider::GetFloatFrame(float* Buffer, int n) {
} }
/////////////////////////////
// Load appropriate renderer
void AvisynthVideoProvider::LoadRenderer() {
// Get prefferred
wxString prefferred = Options.AsText(_T("Avisynth subs renderer"));
// Load
if (prefferred.Lower() == _T("asa")) LoadASA();
else LoadVSFilter();
}
///////////////// /////////////////
// Load VSFilter // Load VSFilter
void AvisynthVideoProvider::LoadVSFilter() { void AvisynthVideoProvider::LoadVSFilter() {
@ -478,12 +491,14 @@ void AvisynthVideoProvider::LoadVSFilter() {
// Loading an avisynth plugin multiple times does almost nothing // Loading an avisynth plugin multiple times does almost nothing
wxFileName vsfilterPath(AegisubApp::folderName + _T("vsfilter.dll")); wxFileName vsfilterPath(AegisubApp::folderName + _T("vsfilter.dll"));
rendererCallString = _T("TextSub");
if (vsfilterPath.FileExists()) { if (vsfilterPath.FileExists()) {
AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Invoking LoadPlugin")); AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Invoking LoadPlugin"));
env->Invoke("LoadPlugin",env->SaveString(vsfilterPath.GetFullPath().mb_str(wxConvLocal))); env->Invoke("LoadPlugin",env->SaveString(vsfilterPath.GetFullPath().mb_str(wxConvLocal)));
AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Loaded")); AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Loaded"));
} else { }
else {
AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: VSFilter.dll not found in Aegisub dir, trying to locate registered DShow filter")); AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: VSFilter.dll not found in Aegisub dir, trying to locate registered DShow filter"));
wxRegKey reg(_T("HKEY_CLASSES_ROOT\\CLSID\\{9852A670-F845-491B-9BE6-EBD841B8A613}\\InprocServer32")); wxRegKey reg(_T("HKEY_CLASSES_ROOT\\CLSID\\{9852A670-F845-491B-9BE6-EBD841B8A613}\\InprocServer32"));
if (reg.Exists()) { if (reg.Exists()) {
@ -500,8 +515,12 @@ void AvisynthVideoProvider::LoadVSFilter() {
} }
vsfilterPath = _T("vsfilter.dll"); vsfilterPath = _T("vsfilter.dll");
} else if (vsfilterPath.FileExists()) }
else if (vsfilterPath.FileExists()) {
AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Found on system path, loading"));
env->Invoke("LoadPlugin",env->SaveString(vsfilterPath.GetFullPath().mb_str(wxConvLocal))); env->Invoke("LoadPlugin",env->SaveString(vsfilterPath.GetFullPath().mb_str(wxConvLocal)));
AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Loaded"));
}
else if (!env->FunctionExists("TextSub")) { else if (!env->FunctionExists("TextSub")) {
AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Couldn't locate VSFilter")); AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Couldn't locate VSFilter"));
throw _T("Couldn't locate VSFilter"); throw _T("Couldn't locate VSFilter");
@ -510,6 +529,35 @@ void AvisynthVideoProvider::LoadVSFilter() {
} }
////////////
// Load asa
void AvisynthVideoProvider::LoadASA() {
AVSTRACE(_T("AvisynthVideoProvider::LoadASA: Loading asa"));
// Loading an avisynth plugin multiple times does almost nothing
wxFileName asaPath(AegisubApp::folderName + _T("asa.dll"));
rendererCallString = _T("asa");
if (asaPath.FileExists()) {
AVSTRACE(_T("AvisynthVideoProvider::LoadASA: Invoking LoadPlugin"));
env->Invoke("LoadPlugin",env->SaveString(asaPath.GetFullPath().mb_str(wxConvLocal)));
AVSTRACE(_T("AvisynthVideoProvider::LoadASA: Loaded"));
}
else {
asaPath = _T("asa.dll");
if (asaPath.FileExists()) {
AVSTRACE(_T("AvisynthVideoProvider::LoadASA: Invoking LoadPlugin"));
env->Invoke("LoadPlugin",env->SaveString(asaPath.GetFullPath().mb_str(wxConvLocal)));
AVSTRACE(_T("AvisynthVideoProvider::LoadASA: Loaded"));
}
else if (!env->FunctionExists("asa")) {
AVSTRACE(_T("AvisynthVideoProvider::LoadASA: Couldn't locate asa"));
throw _T("Couldn't locate asa");
}
}
}
//////////////////////// ////////////////////////
// Override frame times // Override frame times
void AvisynthVideoProvider::OverrideFrameTimeList(wxArrayInt list) { void AvisynthVideoProvider::OverrideFrameTimeList(wxArrayInt list) {

View file

@ -63,6 +63,7 @@ private:
VideoInfo vi; VideoInfo vi;
wxString subfilename; wxString subfilename;
wxString rendererCallString;
int last_fnum; int last_fnum;
int num_frames; int num_frames;
@ -86,6 +87,8 @@ private:
PClip ApplyDARZoom(double _zoom, double _dar, PClip videosource); PClip ApplyDARZoom(double _zoom, double _dar, PClip videosource);
wxBitmap GetFrame(int n, bool force); wxBitmap GetFrame(int n, bool force);
void LoadVSFilter(); void LoadVSFilter();
void LoadASA();
void LoadRenderer();
void AttachOverlay(SubtitleProvider::Overlay *_overlay) {} void AttachOverlay(SubtitleProvider::Overlay *_overlay) {}
public: public: