mirror of https://github.com/odrling/Aegisub
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
|
@ -153,6 +153,8 @@ void OptionsManager::LoadDefaults() {
|
|||
SetBool(_T("Threaded Video"),false);
|
||||
SetInt(_T("Avisynth MemoryMax"),64);
|
||||
SetBool(_T("Allow Ancient Avisynth"),false);
|
||||
SetBool(_T("Use ffmpeg"),false);
|
||||
|
||||
SetText(_T("Video resizer"),_T("BilinearResize"));
|
||||
SetInt(_T("Video Check Script Res"), 0);
|
||||
SetInt(_T("Video Default Zoom"), 7);
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
////////////
|
||||
// Includes
|
||||
#include "video_display.h"
|
||||
#include "video_provider_avs.h"
|
||||
#include "video_provider_lavc.h"
|
||||
#include "video_provider.h"
|
||||
#include "vfr.h"
|
||||
#include "ass_file.h"
|
||||
#include "ass_time.h"
|
||||
|
@ -140,6 +139,7 @@ void VideoDisplay::UpdateSize() {
|
|||
///////////////////////
|
||||
// Sets video filename
|
||||
void VideoDisplay::SetVideo(const wxString &filename) {
|
||||
// Unload video
|
||||
if (filename.IsEmpty()) {
|
||||
delete provider;
|
||||
provider = NULL;
|
||||
|
@ -151,20 +151,19 @@ void VideoDisplay::SetVideo(const wxString &filename) {
|
|||
frame_n = 0;
|
||||
|
||||
Reset();
|
||||
} else {
|
||||
}
|
||||
|
||||
// Load video
|
||||
else {
|
||||
SetVideo(_T(""));
|
||||
|
||||
try {
|
||||
grid->CommitChanges(true);
|
||||
|
||||
// Choose a provider
|
||||
bool usedDirectshow = false;
|
||||
|
||||
#ifndef USE_LAVC
|
||||
provider = new AvisynthVideoProvider(filename,GetTempWorkFile(),zoomValue,usedDirectshow);
|
||||
#else
|
||||
provider = new LAVCVideoProvider(filename,GetTempWorkFile(),zoomValue);
|
||||
#endif
|
||||
|
||||
provider = VideoProvider::GetProvider(filename,GetTempWorkFile());
|
||||
|
||||
// Set keyframes
|
||||
wxString ext = filename.Right(4).Lower();
|
||||
if (ext == _T(".avi")) KeyFrames = VFWWrapper::GetKeyFrames(filename);
|
||||
|
|
|
@ -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 GetSourceHeight()=0; // Returns the original source height in pixels
|
||||
|
||||
static VideoProvider *GetProvider(wxString video,wxString subtitles);
|
||||
};
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
#include "main.h"
|
||||
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
|
||||
AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfilename, double _zoom, bool &usedDirectshow) {
|
||||
bool mpeg2dec3_priority = true;
|
||||
RGB32Video = NULL;
|
||||
|
@ -281,3 +284,6 @@ void AvisynthVideoProvider::LoadVSFilter() {
|
|||
throw _T("Couldn't locate VSFilter");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,9 +33,15 @@
|
|||
// 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 "video_provider.h"
|
||||
|
||||
|
|
|
@ -36,6 +36,15 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// Auto-enable LAVC on non-windows
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef USE_LAVC
|
||||
#define USE_LAVC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifdef USE_LAVC
|
||||
|
|
Loading…
Reference in New Issue