Better lavc/avisynth selection code (will automatically use what's available, or by option if both are)
Originally committed to SVN as r147.
This commit is contained in:
parent
9481d8424b
commit
9b395f283d
7 changed files with 123 additions and 12 deletions
|
@ -153,6 +153,8 @@ void OptionsManager::LoadDefaults() {
|
||||||
SetBool(_T("Threaded Video"),false);
|
SetBool(_T("Threaded Video"),false);
|
||||||
SetInt(_T("Avisynth MemoryMax"),64);
|
SetInt(_T("Avisynth MemoryMax"),64);
|
||||||
SetBool(_T("Allow Ancient Avisynth"),false);
|
SetBool(_T("Allow Ancient Avisynth"),false);
|
||||||
|
SetBool(_T("Use ffmpeg"),false);
|
||||||
|
|
||||||
SetText(_T("Video resizer"),_T("BilinearResize"));
|
SetText(_T("Video resizer"),_T("BilinearResize"));
|
||||||
SetInt(_T("Video Check Script Res"), 0);
|
SetInt(_T("Video Check Script Res"), 0);
|
||||||
SetInt(_T("Video Default Zoom"), 7);
|
SetInt(_T("Video Default Zoom"), 7);
|
||||||
|
|
|
@ -37,8 +37,7 @@
|
||||||
////////////
|
////////////
|
||||||
// Includes
|
// Includes
|
||||||
#include "video_display.h"
|
#include "video_display.h"
|
||||||
#include "video_provider_avs.h"
|
#include "video_provider.h"
|
||||||
#include "video_provider_lavc.h"
|
|
||||||
#include "vfr.h"
|
#include "vfr.h"
|
||||||
#include "ass_file.h"
|
#include "ass_file.h"
|
||||||
#include "ass_time.h"
|
#include "ass_time.h"
|
||||||
|
@ -140,6 +139,7 @@ void VideoDisplay::UpdateSize() {
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// Sets video filename
|
// Sets video filename
|
||||||
void VideoDisplay::SetVideo(const wxString &filename) {
|
void VideoDisplay::SetVideo(const wxString &filename) {
|
||||||
|
// Unload video
|
||||||
if (filename.IsEmpty()) {
|
if (filename.IsEmpty()) {
|
||||||
delete provider;
|
delete provider;
|
||||||
provider = NULL;
|
provider = NULL;
|
||||||
|
@ -151,19 +151,18 @@ void VideoDisplay::SetVideo(const wxString &filename) {
|
||||||
frame_n = 0;
|
frame_n = 0;
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
// Load video
|
||||||
|
else {
|
||||||
SetVideo(_T(""));
|
SetVideo(_T(""));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
grid->CommitChanges(true);
|
grid->CommitChanges(true);
|
||||||
|
|
||||||
|
// Choose a provider
|
||||||
bool usedDirectshow = false;
|
bool usedDirectshow = false;
|
||||||
|
provider = VideoProvider::GetProvider(filename,GetTempWorkFile());
|
||||||
#ifndef USE_LAVC
|
|
||||||
provider = new AvisynthVideoProvider(filename,GetTempWorkFile(),zoomValue,usedDirectshow);
|
|
||||||
#else
|
|
||||||
provider = new LAVCVideoProvider(filename,GetTempWorkFile(),zoomValue);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set keyframes
|
// Set keyframes
|
||||||
wxString ext = filename.Right(4).Lower();
|
wxString ext = filename.Right(4).Lower();
|
||||||
|
|
87
core/video_provider.cpp
Normal file
87
core/video_provider.cpp
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
// Copyright (c) 2006, Rodrigo Braz Monteiro
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||||
|
// may be used to endorse or promote products derived from this software
|
||||||
|
// without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// AEGISUB
|
||||||
|
//
|
||||||
|
// Website: http://aegisub.cellosoft.com
|
||||||
|
// Contact: mailto:zeratul@cellosoft.com
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
///////////
|
||||||
|
// Headers
|
||||||
|
#include "video_provider_avs.h"
|
||||||
|
#include "video_provider_lavc.h"
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
|
|
||||||
|
////////////////
|
||||||
|
// Get provider
|
||||||
|
VideoProvider *VideoProvider::GetProvider(wxString video,wxString subtitles) {
|
||||||
|
// Check if avisynth is available
|
||||||
|
bool avisynthAvailable = false;
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
try {
|
||||||
|
// If avisynth.dll cannot be loaded, an exception will be thrown and avisynthAvailable will never be set to true
|
||||||
|
AviSynthWrapper avs;
|
||||||
|
avisynthAvailable = true;
|
||||||
|
}
|
||||||
|
catch (...) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Initialize to null
|
||||||
|
VideoProvider *provider = NULL;
|
||||||
|
|
||||||
|
// See if it's OK to use LAVC
|
||||||
|
#ifdef USE_LAVC
|
||||||
|
if (Options.AsBool(_T("Use ffmpeg"))) {
|
||||||
|
try {
|
||||||
|
provider = new LAVCVideoProvider(video,subtitles,1.0);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
if (avisynthAvailable) {
|
||||||
|
wxMessageBox(_T("Failed loading FFmpeg decoder for video, falling back to Avisynth."),_T("FFmpeg error."));
|
||||||
|
provider = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Out of options, rethrow
|
||||||
|
else throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Use avisynth provider
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
bool usedDirectshow = false;
|
||||||
|
if (!provider) provider = new AvisynthVideoProvider(video,subtitles,1.0,usedDirectshow);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Return provider
|
||||||
|
return provider;
|
||||||
|
}
|
|
@ -60,4 +60,6 @@ public:
|
||||||
|
|
||||||
virtual int GetSourceWidth()=0; // Returns the original source width in pixels
|
virtual int GetSourceWidth()=0; // Returns the original source width in pixels
|
||||||
virtual int GetSourceHeight()=0; // Returns the original source height in pixels
|
virtual int GetSourceHeight()=0; // Returns the original source height in pixels
|
||||||
|
|
||||||
|
static VideoProvider *GetProvider(wxString video,wxString subtitles);
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
|
||||||
|
|
||||||
AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfilename, double _zoom, bool &usedDirectshow) {
|
AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfilename, double _zoom, bool &usedDirectshow) {
|
||||||
bool mpeg2dec3_priority = true;
|
bool mpeg2dec3_priority = true;
|
||||||
RGB32Video = NULL;
|
RGB32Video = NULL;
|
||||||
|
@ -281,3 +284,6 @@ void AvisynthVideoProvider::LoadVSFilter() {
|
||||||
throw _T("Couldn't locate VSFilter");
|
throw _T("Couldn't locate VSFilter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -33,9 +33,15 @@
|
||||||
// Contact: mailto:zeratul@cellosoft.com
|
// Contact: mailto:zeratul@cellosoft.com
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef VIDEO_PROVIDER_AVS_H
|
|
||||||
#define VIDEO_PROVIDER_AVS_H
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
///////////
|
||||||
|
// Headers
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
#include "avisynth_wrap.h"
|
#include "avisynth_wrap.h"
|
||||||
#include "video_provider.h"
|
#include "video_provider.h"
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
// Auto-enable LAVC on non-windows
|
||||||
|
#ifndef __WINDOWS__
|
||||||
|
#ifndef USE_LAVC
|
||||||
|
#define USE_LAVC
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// Headers
|
// Headers
|
||||||
#ifdef USE_LAVC
|
#ifdef USE_LAVC
|
||||||
|
|
Loading…
Reference in a new issue