mirror of https://github.com/odrling/Aegisub
Added support for DirectShowSource2 if avss.dll is on Aegisub's folder.
Originally committed to SVN as r583.
This commit is contained in:
parent
091226bb4b
commit
16e34c32c2
|
@ -37,6 +37,7 @@ Please visit http://aegisub.net to download latest version
|
||||||
- Switching to a new line in audio mode now centers the line on the grid. (AMZ)
|
- Switching to a new line in audio mode now centers the line on the grid. (AMZ)
|
||||||
- Commiting changes in audio to the last line will insert a new line after it. (AMZ)
|
- Commiting changes in audio to the last line will insert a new line after it. (AMZ)
|
||||||
- Fonts collector can now collect fonts directly to a zip archive. (AMZ)
|
- Fonts collector can now collect fonts directly to a zip archive. (AMZ)
|
||||||
|
- Added support for DirectShowSource2 if avss.dll is on Aegisub's folder. (AMZ)
|
||||||
|
|
||||||
|
|
||||||
= 1.10 beta - 2006.08.07 ===========================
|
= 1.10 beta - 2006.08.07 ===========================
|
||||||
|
|
|
@ -43,6 +43,8 @@
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
|
|
||||||
|
|
||||||
|
///////////////
|
||||||
|
// Constructor
|
||||||
AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfilename) {
|
AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfilename) {
|
||||||
AVSTRACE(wxString::Format(_T("AvisynthVideoProvider: Creating new AvisynthVideoProvider: \"%s\", \"%s\""), _filename, _subfilename));
|
AVSTRACE(wxString::Format(_T("AvisynthVideoProvider: Creating new AvisynthVideoProvider: \"%s\", \"%s\""), _filename, _subfilename));
|
||||||
bool mpeg2dec3_priority = true;
|
bool mpeg2dec3_priority = true;
|
||||||
|
@ -81,6 +83,9 @@ AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfi
|
||||||
AVSTRACE(_T("AvisynthVideoProvider: Done creating AvisynthVideoProvider"));
|
AVSTRACE(_T("AvisynthVideoProvider: Done creating AvisynthVideoProvider"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////
|
||||||
|
// Destructor
|
||||||
AvisynthVideoProvider::~AvisynthVideoProvider() {
|
AvisynthVideoProvider::~AvisynthVideoProvider() {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider: Destroying AvisynthVideoProvider"));
|
AVSTRACE(_T("AvisynthVideoProvider: Destroying AvisynthVideoProvider"));
|
||||||
RGB32Video = NULL;
|
RGB32Video = NULL;
|
||||||
|
@ -90,6 +95,9 @@ AvisynthVideoProvider::~AvisynthVideoProvider() {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider: AvisynthVideoProvider destroyed"));
|
AVSTRACE(_T("AvisynthVideoProvider: AvisynthVideoProvider destroyed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////
|
||||||
|
// Refresh subtitles
|
||||||
void AvisynthVideoProvider::RefreshSubtitles() {
|
void AvisynthVideoProvider::RefreshSubtitles() {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::RefreshSubtitles: Refreshing subtitles"));
|
AVSTRACE(_T("AvisynthVideoProvider::RefreshSubtitles: Refreshing subtitles"));
|
||||||
ResizedVideo = NULL;
|
ResizedVideo = NULL;
|
||||||
|
@ -101,6 +109,9 @@ void AvisynthVideoProvider::RefreshSubtitles() {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::RefreshSubtitles: Subtitles refreshed"));
|
AVSTRACE(_T("AvisynthVideoProvider::RefreshSubtitles: Subtitles refreshed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// Set Display Aspect Ratio
|
||||||
void AvisynthVideoProvider::SetDAR(double _dar) {
|
void AvisynthVideoProvider::SetDAR(double _dar) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::SetDAR: Setting DAR"));
|
AVSTRACE(_T("AvisynthVideoProvider::SetDAR: Setting DAR"));
|
||||||
dar = _dar;
|
dar = _dar;
|
||||||
|
@ -114,6 +125,9 @@ void AvisynthVideoProvider::SetDAR(double _dar) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::SetDAR: DAR set"));
|
AVSTRACE(_T("AvisynthVideoProvider::SetDAR: DAR set"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////
|
||||||
|
// Set Zoom
|
||||||
void AvisynthVideoProvider::SetZoom(double _zoom) {
|
void AvisynthVideoProvider::SetZoom(double _zoom) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::SetZoom: Setting zoom"));
|
AVSTRACE(_T("AvisynthVideoProvider::SetZoom: Setting zoom"));
|
||||||
zoom = _zoom;
|
zoom = _zoom;
|
||||||
|
@ -127,6 +141,9 @@ void AvisynthVideoProvider::SetZoom(double _zoom) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::SetZoom: Zoom set"));
|
AVSTRACE(_T("AvisynthVideoProvider::SetZoom: Zoom set"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////
|
||||||
|
// Actually open the video into Avisynth
|
||||||
PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priority) {
|
PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priority) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening video"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening video"));
|
||||||
wxMutexLocker lock(AviSynthMutex);
|
wxMutexLocker lock(AviSynthMutex);
|
||||||
|
@ -142,12 +159,14 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
|
||||||
// Prepare filename
|
// Prepare filename
|
||||||
char *videoFilename = env->SaveString(_filename.mb_str(wxConvLocal));
|
char *videoFilename = env->SaveString(_filename.mb_str(wxConvLocal));
|
||||||
|
|
||||||
// Load depending on extension
|
// Avisynth file, just import it
|
||||||
if (extension == _T(".avs")) {
|
if (extension == _T(".avs")) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening .avs file with Import"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening .avs file with Import"));
|
||||||
script = env->Invoke("Import", videoFilename);
|
script = env->Invoke("Import", videoFilename);
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Finished"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Finished"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open avi file with AviSource
|
||||||
else if (extension == _T(".avi")) {
|
else if (extension == _T(".avi")) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening .avi file with AviSource"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening .avi file with AviSource"));
|
||||||
try {
|
try {
|
||||||
|
@ -155,41 +174,79 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
|
||||||
AVSValue args[2] = { videoFilename, false };
|
AVSValue args[2] = { videoFilename, false };
|
||||||
script = env->Invoke("AviSource", AVSValue(args,2), argnames);
|
script = env->Invoke("AviSource", AVSValue(args,2), argnames);
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened .avi file without audio"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened .avi file without audio"));
|
||||||
} catch (AvisynthError &) {
|
}
|
||||||
|
|
||||||
|
// On Failure, fallback to DSS
|
||||||
|
catch (AvisynthError &) {
|
||||||
AVSTRACE(_T("Failed to open .avi file with AviSource, switching to DirectShowSource"));
|
AVSTRACE(_T("Failed to open .avi file with AviSource, switching to DirectShowSource"));
|
||||||
goto directshowOpen;
|
goto directshowOpen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (extension == _T(".d2v") && env->FunctionExists("mpeg2dec3_Mpeg2Source") && mpeg2dec3_priority) { //prefer mpeg2dec3
|
|
||||||
|
// Open d2v with mpeg2dec3
|
||||||
|
else if (extension == _T(".d2v") && env->FunctionExists("mpeg2dec3_Mpeg2Source") && mpeg2dec3_priority) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening .d2v file with mpeg2dec3_Mpeg2Source"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening .d2v file with mpeg2dec3_Mpeg2Source"));
|
||||||
script = env->Invoke("mpeg2dec3_Mpeg2Source", videoFilename);
|
script = env->Invoke("mpeg2dec3_Mpeg2Source", videoFilename);
|
||||||
}
|
}
|
||||||
else if (extension == _T(".d2v") && env->FunctionExists("Mpeg2Source")) { //try other mpeg2source
|
|
||||||
|
// If that fails, try opening it with other mpeg2source
|
||||||
|
else if (extension == _T(".d2v") && env->FunctionExists("Mpeg2Source")) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening .d2v file with other Mpeg2Source"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening .d2v file with other Mpeg2Source"));
|
||||||
script = env->Invoke("Mpeg2Source", videoFilename);
|
script = env->Invoke("Mpeg2Source", videoFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some other format, such as mkv, mp4, ogm... try DirectShowSource
|
||||||
else {
|
else {
|
||||||
directshowOpen:
|
directshowOpen:
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening file with DirectShowSource"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening file with DirectShowSource"));
|
||||||
|
|
||||||
if (env->FunctionExists("DirectShowSource")) {
|
// Try loading DirectShowSource2
|
||||||
const char *argnames[3] = { 0, "video", "audio" };
|
bool dss2 = false;
|
||||||
AVSValue args[3] = { videoFilename, true, false };
|
if (env->FunctionExists("dss2")) dss2 = true;
|
||||||
script = env->Invoke("DirectShowSource", AVSValue(args,3), argnames);
|
if (!dss2) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with DSS without audio"));
|
wxFileName dss2path(AegisubApp::folderName + _T("avss.dll"));
|
||||||
usedDirectshow = true;
|
if (dss2path.FileExists()) {
|
||||||
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading DirectShowSource2"));
|
||||||
|
env->Invoke("LoadPlugin",env->SaveString(dss2path.GetFullPath().mb_str(wxConvLocal)));
|
||||||
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loaded DirectShowSource2"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: DSS function not found"));
|
// If DSS2 loaded properly, try using it
|
||||||
throw AvisynthError("No function suitable for opening the video found");
|
dss2 = false;
|
||||||
|
if (env->FunctionExists("dss2")) {
|
||||||
|
AVSTRACE(_T("visynthVideoProvider::OpenVideo: Invoking DSS2"));
|
||||||
|
script = env->Invoke("DSS2", videoFilename);
|
||||||
|
AVSTRACE(_T("visynthVideoProvider::OpenVideo: Successfully opened file with DSS2"));
|
||||||
|
dss2 = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (AvisynthError &err) {
|
// Try DirectShowSource
|
||||||
|
if (!dss2) {
|
||||||
|
if (env->FunctionExists("DirectShowSource")) {
|
||||||
|
const char *argnames[3] = { 0, "video", "audio" };
|
||||||
|
AVSValue args[3] = { videoFilename, true, false };
|
||||||
|
script = env->Invoke("DirectShowSource", AVSValue(args,3), argnames);
|
||||||
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with DSS without audio"));
|
||||||
|
usedDirectshow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failed to find a suitable function
|
||||||
|
else {
|
||||||
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: DSS function not found"));
|
||||||
|
throw AvisynthError("No function suitable for opening the video found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Catch errors
|
||||||
|
catch (AvisynthError &err) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Avisynth error: ") + wxString(err.msg,wxConvLocal));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Avisynth error: ") + wxString(err.msg,wxConvLocal));
|
||||||
throw _T("AviSynth error: ") + wxString(err.msg,wxConvLocal);
|
throw _T("AviSynth error: ") + wxString(err.msg,wxConvLocal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if video was loaded properly
|
||||||
if (!script.AsClip()->GetVideoInfo().HasVideo()) {
|
if (!script.AsClip()->GetVideoInfo().HasVideo()) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: No suitable video found"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: No suitable video found"));
|
||||||
throw _T("No usable video found in ") + _filename;
|
throw _T("No usable video found in ") + _filename;
|
||||||
|
@ -207,6 +264,9 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
|
||||||
return (env->Invoke("Cache", script)).AsClip();
|
return (env->Invoke("Cache", script)).AsClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
// Apply VSFilter subtitles, or whatever is appropriate
|
||||||
PClip AvisynthVideoProvider::ApplySubtitles(wxString _filename, PClip videosource) {
|
PClip AvisynthVideoProvider::ApplySubtitles(wxString _filename, PClip videosource) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::ApplySutitles: Applying subtitles"));
|
AVSTRACE(_T("AvisynthVideoProvider::ApplySutitles: Applying subtitles"));
|
||||||
wxMutexLocker lock(AviSynthMutex);
|
wxMutexLocker lock(AviSynthMutex);
|
||||||
|
@ -232,6 +292,9 @@ PClip AvisynthVideoProvider::ApplySubtitles(wxString _filename, PClip videosourc
|
||||||
return (env->Invoke("Cache", script)).AsClip();
|
return (env->Invoke("Cache", script)).AsClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Apply Display Aspect Ratio + Zoom
|
||||||
PClip AvisynthVideoProvider::ApplyDARZoom(double _zoom, double _dar, PClip videosource) {
|
PClip AvisynthVideoProvider::ApplyDARZoom(double _zoom, double _dar, PClip videosource) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::ApplyDARZoom: Applying DAR zoom"));
|
AVSTRACE(_T("AvisynthVideoProvider::ApplyDARZoom: Applying DAR zoom"));
|
||||||
wxMutexLocker lock(AviSynthMutex);
|
wxMutexLocker lock(AviSynthMutex);
|
||||||
|
@ -263,6 +326,9 @@ PClip AvisynthVideoProvider::ApplyDARZoom(double _zoom, double _dar, PClip video
|
||||||
return (env->Invoke("Cache",script)).AsClip();
|
return (env->Invoke("Cache",script)).AsClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// Actually get a frame
|
||||||
wxBitmap AvisynthVideoProvider::GetFrame(int n, bool force) {
|
wxBitmap AvisynthVideoProvider::GetFrame(int n, bool force) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::GetFrame"));
|
AVSTRACE(_T("AvisynthVideoProvider::GetFrame"));
|
||||||
if (n != last_fnum || force) {
|
if (n != last_fnum || force) {
|
||||||
|
@ -331,6 +397,9 @@ wxBitmap AvisynthVideoProvider::GetFrame(int n, bool force) {
|
||||||
return wxBitmap(last_frame);
|
return wxBitmap(last_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
// Get a frame intensity as floats
|
||||||
void AvisynthVideoProvider::GetFloatFrame(float* Buffer, int n) {
|
void AvisynthVideoProvider::GetFloatFrame(float* Buffer, int n) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::GetFloatFrame"));
|
AVSTRACE(_T("AvisynthVideoProvider::GetFloatFrame"));
|
||||||
wxMutexLocker lock(AviSynthMutex);
|
wxMutexLocker lock(AviSynthMutex);
|
||||||
|
@ -351,6 +420,9 @@ void AvisynthVideoProvider::GetFloatFrame(float* Buffer, int n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
// Load VSFilter
|
||||||
void AvisynthVideoProvider::LoadVSFilter() {
|
void AvisynthVideoProvider::LoadVSFilter() {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Loading VSFilter"));
|
AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Loading VSFilter"));
|
||||||
// Loading an avisynth plugin multiple times does almost nothing
|
// Loading an avisynth plugin multiple times does almost nothing
|
||||||
|
|
Loading…
Reference in New Issue