Cleaned up provider creation interface
Originally committed to SVN as r148.
This commit is contained in:
parent
9b395f283d
commit
360147d4ea
8 changed files with 37 additions and 20 deletions
|
@ -14,7 +14,7 @@
|
|||
#include <wx/rawbmp.h>
|
||||
#include "subs_grid.h"
|
||||
#include "frame_main.h"
|
||||
#include "video_provider_avs.h"
|
||||
#include "video_provider.h"
|
||||
#include "video_display.h"
|
||||
#include "video_box.h"
|
||||
#include "ass_file.h"
|
||||
|
@ -75,8 +75,7 @@ void FrameMain::OnVideoTrackPoints(wxCommandEvent &event) {
|
|||
if( !config.FeatureNumber ) return;
|
||||
|
||||
// Get Video
|
||||
bool usedDirectshow;
|
||||
VideoProvider *movie = new AvisynthVideoProvider(videoBox->videoDisplay->videoName, wxString(_T("")), 1.0,usedDirectshow);
|
||||
VideoProvider *movie = VideoProvider::GetProvider(videoBox->videoDisplay->videoName, wxString(_T("")));
|
||||
|
||||
// Create Tracker
|
||||
if( curline->Tracker ) delete curline->Tracker;
|
||||
|
|
|
@ -163,6 +163,8 @@ void VideoDisplay::SetVideo(const wxString &filename) {
|
|||
// Choose a provider
|
||||
bool usedDirectshow = false;
|
||||
provider = VideoProvider::GetProvider(filename,GetTempWorkFile());
|
||||
provider->SetZoom(zoomValue);
|
||||
provider->SetDAR(GetARFromType(arType));
|
||||
|
||||
// Set keyframes
|
||||
wxString ext = filename.Right(4).Lower();
|
||||
|
@ -484,17 +486,20 @@ void VideoDisplay::SetZoomPos(int value) {
|
|||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
// Sets zoom level
|
||||
//////////////////////////
|
||||
// Calculate aspect ratio
|
||||
double VideoDisplay::GetARFromType(int type) {
|
||||
if (type == 0) return (double)provider->GetSourceWidth()/(double)provider->GetSourceHeight();
|
||||
if (type == 1) return 4.0/3.0;
|
||||
if (type == 2) return 16.0/9.0;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////
|
||||
// Sets aspect ratio
|
||||
void VideoDisplay::SetAspectRatio(int value) {
|
||||
if (provider) {
|
||||
if (value == 0)
|
||||
provider->SetDAR((float)provider->GetSourceWidth()/(float)provider->GetSourceHeight());
|
||||
else if (value == 1)
|
||||
provider->SetDAR(4.0/3.0);
|
||||
else if (value == 2)
|
||||
provider->SetDAR(16.0/9.0);
|
||||
|
||||
provider->SetDAR(GetARFromType(value));
|
||||
arType = value;
|
||||
UpdateSize();
|
||||
RefreshVideo();
|
||||
|
|
|
@ -131,6 +131,7 @@ public:
|
|||
void RefreshVideo();
|
||||
void DrawText( wxPoint Pos, wxString Text );
|
||||
void UpdatePositionDisplay();
|
||||
double GetARFromType(int type);
|
||||
void SetAspectRatio(int type);
|
||||
void SetZoom(double value);
|
||||
int GetAspectRatio() { return arType; }
|
||||
|
|
|
@ -62,9 +62,13 @@ VideoProvider *VideoProvider::GetProvider(wxString video,wxString subtitles) {
|
|||
#ifdef USE_LAVC
|
||||
if (Options.AsBool(_T("Use ffmpeg"))) {
|
||||
try {
|
||||
provider = new LAVCVideoProvider(video,subtitles,1.0);
|
||||
provider = new LAVCVideoProvider(video,subtitles);
|
||||
}
|
||||
catch (...) {
|
||||
// Delete old provider
|
||||
delete provider;
|
||||
|
||||
// Try to fallback to avisynth
|
||||
if (avisynthAvailable) {
|
||||
wxMessageBox(_T("Failed loading FFmpeg decoder for video, falling back to Avisynth."),_T("FFmpeg error."));
|
||||
provider = NULL;
|
||||
|
@ -79,7 +83,15 @@ VideoProvider *VideoProvider::GetProvider(wxString video,wxString subtitles) {
|
|||
// Use avisynth provider
|
||||
#ifdef __WINDOWS__
|
||||
bool usedDirectshow = false;
|
||||
if (!provider) provider = new AvisynthVideoProvider(video,subtitles,1.0,usedDirectshow);
|
||||
if (!provider) {
|
||||
try {
|
||||
provider = new AvisynthVideoProvider(video,subtitles,usedDirectshow);
|
||||
}
|
||||
catch (...) {
|
||||
delete provider;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Return provider
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#ifdef __WINDOWS__
|
||||
|
||||
|
||||
AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfilename, double _zoom, bool &usedDirectshow) {
|
||||
AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfilename, bool &usedDirectshow) {
|
||||
bool mpeg2dec3_priority = true;
|
||||
RGB32Video = NULL;
|
||||
SubtitledVideo = NULL;
|
||||
|
@ -53,7 +53,7 @@ AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, wxString _subfi
|
|||
last_fnum = -1;
|
||||
|
||||
subfilename = _subfilename;
|
||||
zoom = _zoom;
|
||||
zoom = 1.0;
|
||||
|
||||
LoadVSFilter();
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ private:
|
|||
void LoadVSFilter();
|
||||
|
||||
public:
|
||||
AvisynthVideoProvider(wxString _filename, wxString _subfilename, double _zoom, bool &usedDirectshow);
|
||||
AvisynthVideoProvider(wxString _filename, wxString _subfilename, bool &usedDirectshow);
|
||||
~AvisynthVideoProvider();
|
||||
|
||||
void RefreshSubtitles();
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
///////////////
|
||||
// Constructor
|
||||
LAVCVideoProvider::LAVCVideoProvider(wxString filename, wxString subfilename, double _zoom) {
|
||||
LAVCVideoProvider::LAVCVideoProvider(wxString filename, wxString subfilename) {
|
||||
// Init variables
|
||||
codecContext = NULL;
|
||||
formatContext = NULL;
|
||||
|
@ -57,7 +57,7 @@ LAVCVideoProvider::LAVCVideoProvider(wxString filename, wxString subfilename, do
|
|||
buffer1Size = 0;
|
||||
buffer2Size = 0;
|
||||
vidStream = -1;
|
||||
zoom = _zoom;
|
||||
zoom = 1.0;
|
||||
validFrame = false;
|
||||
|
||||
// Register types
|
||||
|
|
|
@ -87,7 +87,7 @@ private:
|
|||
wxBitmap AVFrameToWX(AVFrame *frame);
|
||||
|
||||
public:
|
||||
LAVCVideoProvider(wxString filename, wxString subfilename, double zoom);
|
||||
LAVCVideoProvider(wxString filename, wxString subfilename);
|
||||
~LAVCVideoProvider();
|
||||
|
||||
void RefreshSubtitles();
|
||||
|
|
Loading…
Reference in a new issue