Basic (and somewhat broken) detached video dialog implemented.

Originally committed to SVN as r881.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-23 04:42:08 +00:00
parent 52060ceb03
commit 02bf068052
20 changed files with 337 additions and 202 deletions

View file

@ -759,7 +759,7 @@ void AudioDisplay::SetFile(wxString file, VideoProvider *vprovider) {
SetFile(_T(""));
try {
// Get provider
provider = AudioProvider::GetAudioProvider(file, this, vprovider);
provider = AudioProviderFactory::GetAudioProvider(file);
// Get player
player = AudioPlayer::GetAudioPlayer();
@ -861,7 +861,7 @@ void AudioDisplay::Play(int start,int end) {
if (VideoContext::Get()->IsLoaded()) {
try {
// Get provider
provider = AudioProvider::GetAudioProvider(VideoContext::Get()->videoName, this, VideoContext::Get()->GetProvider(),0);
provider = AudioProviderFactory::GetAudioProvider(VideoContext::Get()->videoName, 0);
// Get player
player = AudioPlayer::GetAudioPlayer();

View file

@ -37,8 +37,6 @@
///////////
// Headers
#include <wx/wxprec.h>
#include "audio_provider_avs.h"
#include "audio_provider_lavc.h"
#include "audio_provider_ram.h"
#include "audio_provider_hd.h"
#include "options.h"
@ -160,26 +158,58 @@ void AudioProvider::GetWaveForm(int *min,int *peak,__int64 start,int w,int h,int
}
/////////////////////////
// Get audio with volume
void AudioProvider::GetAudioWithVolume(void *buf, __int64 start, __int64 count, double volume) {
GetAudio(buf,start,count);
if (volume == 1.0) return;
if (bytes_per_sample == 2) {
// Read raw samples
short *buffer = (short*) buf;
int value;
// Modify
for (__int64 i=0;i<count;i++) {
value = (int)(buffer[i]*volume+0.5);
if (value < -0x8000) value = -0x8000;
if (value > 0x7FFF) value = 0x7FFF;
buffer[i] = value;
}
}
}
////////////////
// Get provider
AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay *display, VideoProvider *vprovider,int cache) {
AudioProvider *AudioProviderFactory::GetAudioProvider(wxString filename, int cache) {
// Prepare provider
AudioProvider *provider = NULL;
// Select provider
#if USE_LAVC == 1
if (!provider) provider = new LAVCAudioProvider(filename, vprovider);
#endif
// List of providers
wxArrayString list = GetFactoryList(Options.AsText(_T("Audio provider")));
#ifdef __WINDOWS__
if (!provider) provider = new AvisynthAudioProvider(filename);
#endif
// None available
if (list.Count() == 0) throw _T("No audio providers are available.");
// No provider found
if (!provider) {
throw _T("Could not initialize any audio provider.");
// Get provider
wxString error;
for (unsigned int i=0;i<list.Count();i++) {
try {
AudioProvider *prov = GetFactory(list[i])->CreateProvider(filename);
if (prov) {
provider = prov;
break;
}
}
catch (wxString err) { error += list[i] + _T(" factory: ") + err + _T("\n"); }
catch (const wxChar *err) { error += list[i] + _T(" factory: ") + wxString(err) + _T("\n"); }
catch (...) { error += list[i] + _T(" factory: Unknown error\n"); }
}
// Failed
if (!provider) throw error;
// Change provider to RAM/HD cache if needed
if (cache == -1) cache = Options.AsInt(_T("Audio Cache"));
if (cache) {
@ -203,23 +233,6 @@ AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay *
}
/////////////////////////
// Get audio with volume
void AudioProvider::GetAudioWithVolume(void *buf, __int64 start, __int64 count, double volume) {
GetAudio(buf,start,count);
if (volume == 1.0) return;
if (bytes_per_sample == 2) {
// Read raw samples
short *buffer = (short*) buf;
int value;
// Modify
for (__int64 i=0;i<count;i++) {
value = (int)(buffer[i]*volume+0.5);
if (value < -0x8000) value = -0x8000;
if (value > 0x7FFF) value = 0x7FFF;
buffer[i] = value;
}
}
}
//////////
// Static
std::map<wxString,AudioProviderFactory*>* AegisubFactory<AudioProviderFactory>::factories=NULL;

View file

@ -40,6 +40,7 @@
///////////
// Headers
#include <wx/wxprec.h>
#include "factory.h"
//////////////
@ -71,11 +72,23 @@ public:
virtual void GetAudio(void *buf, __int64 start, __int64 count)=0;
void GetAudioWithVolume(void *buf, __int64 start, __int64 count, double volume);
int GetChannels();
__int64 GetNumSamples();
int GetSampleRate();
int GetBytesPerSample();
int GetChannels();
void GetWaveForm(int *min,int *peak,__int64 start,int w,int h,int samples,float scale);
static AudioProvider *GetAudioProvider(wxString filename, AudioDisplay *display, VideoProvider *vprovider,int cache=-1);
};
///////////
// Factory
class AudioProviderFactory : public AegisubFactory<AudioProviderFactory> {
protected:
virtual AudioProvider *CreateProvider(wxString filename)=0;
AudioProviderFactory(wxString name) { RegisterFactory(name); }
public:
virtual ~AudioProviderFactory() {}
static AudioProvider *GetAudioProvider(wxString filename, int cache=-1);
};

View file

@ -38,15 +38,47 @@
// Headers
#include <wx/wxprec.h>
#ifdef __WINDOWS__
#include <wx/filename.h>
#include <Mmreg.h>
#include <time.h>
#include "audio_provider.h"
#include "avisynth_wrap.h"
#include "utils.h"
#include "audio_provider_avs.h"
#include "options.h"
////////////////////////
// Audio provider class
class AvisynthAudioProvider : public AudioProvider, public AviSynthWrapper {
private:
wxString filename;
PClip clip;
void LoadFromClip(AVSValue clip);
void OpenAVSAudio();
void SetFile();
void Unload();
public:
AvisynthAudioProvider(wxString _filename);
~AvisynthAudioProvider();
wxString GetFilename();
void GetAudio(void *buf, __int64 start, __int64 count);
void GetWaveForm(int *min,int *peak,__int64 start,int w,int h,int samples,float scale);
};
///////////
// Factory
class AvisynthAudioProviderFactory : public AudioProviderFactory {
public:
AudioProvider *CreateProvider(wxString file) { return new AvisynthAudioProvider(file); }
AvisynthAudioProviderFactory() : AudioProviderFactory(_T("avisynth")) {}
} registerAVSaudio;
//////////////
// Constructor
AvisynthAudioProvider::AvisynthAudioProvider(wxString _filename) {

View file

@ -35,38 +35,3 @@
#pragma once
///////////
// Headers
#include <wx/wxprec.h>
#ifdef __WINDOWS__
#include <time.h>
#include "avisynth_wrap.h"
#include "audio_provider.h"
////////////////////////
// Audio provider class
class AvisynthAudioProvider : public AudioProvider, public AviSynthWrapper {
private:
wxString filename;
PClip clip;
void LoadFromClip(AVSValue clip);
void OpenAVSAudio();
void SetFile();
void Unload();
public:
AvisynthAudioProvider(wxString _filename);
~AvisynthAudioProvider();
wxString GetFilename();
void GetAudio(void *buf, __int64 start, __int64 count);
void GetWaveForm(int *min,int *peak,__int64 start,int w,int h,int samples,float scale);
};
#endif

View file

@ -36,15 +36,53 @@
///////////
// Headers
#include "setup.h"
#if USE_LAVC == 1
#define EMULATE_INTTYPES
#include <wx/wxprec.h>
#include <ffmpeg/avcodec.h>
#include <ffmpeg/avformat.h>
#include "mkv_wrap.h"
#include "lavc_file.h"
#include "audio_provider.h"
#include "lavc_file.h"
#include "utils.h"
#include "audio_provider_lavc.h"
#include "video_provider_lavc.h"
#include "options.h"
LAVCAudioProvider::LAVCAudioProvider(wxString _filename, VideoProvider *vpro)
///////////////////////
// LAVC Audio Provider
class LAVCAudioProvider : public AudioProvider {
private:
LAVCFile *lavcfile;
AVCodecContext *codecContext;
ReSampleContext *rsct;
float resample_ratio;
AVStream *stream;
int audStream;
int16_t *buffer;
void Destroy();
public:
LAVCAudioProvider(wxString _filename);
virtual ~LAVCAudioProvider();
virtual void GetAudio(void *buf, __int64 start, __int64 count);
};
///////////
// Factory
class LAVCAudioProviderFactory : public AudioProviderFactory {
public:
AudioProvider *CreateProvider(wxString file) { return new LAVCAudioProvider(file); }
AvisynthAudioProviderFactory() : AudioProviderFactory(_T("lavc")) {}
} registerLAVCaudio;
///////////////
// Constructor
LAVCAudioProvider::LAVCAudioProvider(wxString _filename)
: lavcfile(NULL), codecContext(NULL), rsct(NULL), buffer(NULL)
{
try {

View file

@ -0,0 +1,75 @@
// Copyright (c) 2007, 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 <wx/wxprec.h>
#include "dialog_detached_video.h"
#include "video_box.h"
#include "video_context.h"
#include "frame_main.h"
///////////////
// Constructor
DialogDetachedVideo::DialogDetachedVideo(FrameMain *par)
: wxFrame(par,-1,_("Detached Video"))
{
// Set parent
parent = par;
// Set a background panel
wxPanel *panel = new wxPanel(this,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
// Video area;
videoBox = new VideoBox(panel);
// Set sizer
wxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
mainSizer->Add(videoBox,1,wxEXPAND | wxALL,5);
panel->SetSizer(mainSizer);
// Update
parent->SetDisplayMode(0,-1);
}
/////////////
// Destructor
DialogDetachedVideo::~DialogDetachedVideo() {
parent->detachedVideo = NULL;
parent->SetDisplayMode(1,-1);
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2005, Rodrigo Braz Monteiro
// Copyright (c) 2007, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -36,32 +36,21 @@
#pragma once
#include "setup.h"
#if USE_LAVC == 1
#define EMULATE_INTTYPES
#include "audio_provider.h"
#include "lavc_file.h"
//////////////
// Prototypes
class VideoBox;
class FrameMain;
class LAVCAudioProvider : public AudioProvider {
//////////////////////////////
// Detached video frame class
class DialogDetachedVideo : public wxFrame {
private:
LAVCFile *lavcfile;
AVCodecContext *codecContext;
ReSampleContext *rsct;
float resample_ratio;
AVStream *stream;
int audStream;
int16_t *buffer;
void Destroy();
VideoBox *videoBox;
FrameMain *parent;
public:
LAVCAudioProvider(wxString _filename, VideoProvider *vpro);
virtual ~LAVCAudioProvider();
virtual void GetAudio(void *buf, __int64 start, __int64 count);
DialogDetachedVideo(FrameMain *parent);
~DialogDetachedVideo();
};
#endif /* USE_LAVC */

View file

@ -68,6 +68,7 @@
#include "text_file_writer.h"
#include "auto4_base.h"
#include "dialog_version_check.h"
#include "dialog_detached_video.h"
/////////////////////////
@ -104,7 +105,9 @@ FrameMain::FrameMain (wxArrayString args)
SetIcon(wxICON(wxicon));
// Contents
curMode = -1;
showVideo = true;
showAudio = true;
detachedVideo = NULL;
InitContents();
Show();
@ -359,6 +362,7 @@ void FrameMain::InitMenu() {
wxMenuItem *RecentKeyframesParent = new wxMenuItem(videoMenu, Menu_File_Recent_Keyframes_Parent, _("Recent"), _T(""), wxITEM_NORMAL, RecentKeyframes);
videoMenu->Append(RecentKeyframesParent);
videoMenu->AppendSeparator();
videoMenu->Append(Menu_Video_Detach, _("Detach Video"), _("Detach video, displaying it in a separate Window."));
wxMenu *ZoomMenu = new wxMenu;
wxMenuItem *ZoomParent = new wxMenuItem(subtitlesMenu,Menu_View_Zoom,_("Set Zoom"),_T(""),wxITEM_NORMAL,ZoomMenu);
ZoomParent->SetBitmap(wxBITMAP(blank_button));
@ -475,24 +479,27 @@ void FrameMain::InitContents() {
//SetSizer(MainSizer);
// Set display
SetDisplayMode(0);
SetDisplayMode(0,0);
Layout();
}
/////////////////////////
// Deinitialize controls
void FrameMain::DeInitContents() {
//ghetto hack to free all AssFile junk properly, eliminates lots of memory leaks
if (detachedVideo) detachedVideo->Destroy();
AssFile::StackReset();
delete AssFile::top;
delete EditBox;
delete videoBox;
}
//////////////////
// Update toolbar
void FrameMain::UpdateToolbar() {
// Collect flags
bool isVideo = (curMode == 1) || (curMode == 2);
bool isVideo = showVideo;
HasSelection = true;
int selRows = SubsBox->GetNumberSelection();
@ -711,59 +718,28 @@ int FrameMain::TryToCloseSubs(bool enableCancel) {
////////////////////
// Set display mode
// ----------------
// 0: subs only
// 1: video
// 2: audio
void FrameMain::SetDisplayMode(int mode) {
void FrameMain::SetDisplayMode(int _showVid,int _showAudio) {
// Stop
Freeze();
VideoContext::Get()->Stop();
if (mode != curMode) {
// Automatic mode
bool showVid=false, showAudio=false;
if (mode == -1) {
// See what's loaded
if (VideoContext::Get()->IsLoaded()) showVid = true;
if (audioBox->loaded) showAudio = true;
// Set mode
if (!showVid && !showAudio) mode = 0;
if (showVid && !showAudio) mode = 1;
if (showVid && showAudio) mode = 2;
if (!showVid && showAudio) mode = 3;
}
// Automatic
if (_showVid == -1) _showVid = VideoContext::Get()->IsLoaded() ? 1 : 0;
if (_showAudio == -1) _showAudio = audioBox->loaded ? 1 : 0;
// Subs only
else if (mode == 0) {
showVid = false;
showAudio = false;
}
// Video only
else if (mode == 1) {
showVid = true;
showAudio = false;
}
// Video+Audio
else if (mode == 2) {
showVid = true;
showAudio = true;
}
// Audio only
else if (mode == 3) {
showVid = false;
showAudio = true;
}
// Set display
TopSizer->Show(videoBox,showVid,true);
ToolSizer->Show(audioBox,showAudio,true);
// See if anything changed
if (_showVid == (showVideo?1:0) && _showAudio == (showAudio?1:0)) {
Thaw();
return;
}
showAudio = _showAudio == 1;
showVideo = _showVid == 1;
// Set display
TopSizer->Show(videoBox,showVideo,true);
ToolSizer->Show(audioBox,showAudio,true);
// Update
curMode = mode;
UpdateToolbar();
EditBox->SetSplitLineMode();
MainSizer->CalcMin();
@ -772,6 +748,7 @@ void FrameMain::SetDisplayMode(int mode) {
MainSizer->Layout();
Layout();
Show(true);
VideoContext::Get()->UpdateDisplays(true);
Thaw();
}
@ -911,7 +888,7 @@ void FrameMain::SynchronizeProject(bool fromSubs) {
}
// Display
SetDisplayMode(-1);
SetDisplayMode(-1,-1);
}
// Store data on subs
@ -1024,7 +1001,7 @@ void FrameMain::LoadVideo(wxString file,bool autoload) {
}
SubsBox->CommitChanges(true);
SetDisplayMode(-1);
SetDisplayMode(-1,-1);
EditBox->UpdateFrameTiming();
}
@ -1036,7 +1013,7 @@ void FrameMain::LoadAudio(wxString filename,bool FromVideo) {
VideoContext::Get()->Stop();
try {
audioBox->SetFile(filename,FromVideo);
SetDisplayMode(-1);
SetDisplayMode(-1,-1);
}
catch (const wchar_t *error) {
wxString err(error);

View file

@ -53,6 +53,7 @@ class SubtitlesGrid;
class SubsEditBox;
class AudioBox;
class VideoBox;
class DialogDetachedVideo;
class AegisubFileDropTarget;
namespace Automation4 { class FeatureMacro; class ScriptManager; };
@ -65,7 +66,7 @@ class FrameMain: public wxFrame {
friend class SubtitlesGrid;
private:
int curMode;
bool showVideo,showAudio;
bool HasSelection;
bool menuCreated;
wxTimer AutoSave;
@ -157,6 +158,7 @@ private:
void OnSetARFull (wxCommandEvent &event);
void OnSetAR235 (wxCommandEvent &event);
void OnSetARCustom (wxCommandEvent &event);
void OnDetachVideo (wxCommandEvent &event);
void OnOpenAudio (wxCommandEvent &event);
void OnOpenAudioFromVideo (wxCommandEvent &event);
@ -231,7 +233,6 @@ private:
void LoadSubtitles(wxString filename,wxString charset=_T(""));
bool SaveSubtitles(bool saveas=false,bool withCharset=false);
int TryToCloseSubs(bool enableCancel=true);
void SetDisplayMode(int mode);
wxMenuItem *RebuildMenuItem(wxMenu *menu,int id,wxBitmap bmp1,wxBitmap bmp2,bool state);
void MenuItemEnable(int id,bool state,wxBitmap &bmp1,wxBitmap &bmp2);
@ -242,6 +243,7 @@ public:
SubsEditBox *EditBox;
AudioBox *audioBox;
VideoBox *videoBox;
DialogDetachedVideo *detachedVideo;
wxBoxSizer *MainSizer;
wxBoxSizer *TopSizer;
@ -260,6 +262,7 @@ public:
void SetAccelerators();
void InitMenu();
void UpdateToolbar();
void SetDisplayMode(int showVid,int showAudio);
DECLARE_EVENT_TABLE()
};
@ -311,6 +314,7 @@ enum {
Menu_Video_AR_Custom,
Menu_Video_Select_Visible,
Menu_Video_Play,
Menu_Video_Detach,
Menu_Audio_Open_File,
Menu_Audio_Open_From_Video,

View file

@ -85,6 +85,7 @@
#include "auto4_base.h"
#include "dialog_automation.h"
#include "dialog_version_check.h"
#include "dialog_detached_video.h"
////////////////////
@ -136,6 +137,7 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
EVT_MENU(Menu_Video_AR_Custom, FrameMain::OnSetARCustom)
EVT_MENU(Menu_Video_JumpTo, FrameMain::OnJumpTo)
EVT_MENU(Menu_Video_Select_Visible, FrameMain::OnSelectVisible)
EVT_MENU(Menu_Video_Detach, FrameMain::OnDetachVideo)
EVT_MENU(Menu_Audio_Open_File, FrameMain::OnOpenAudio)
EVT_MENU(Menu_Audio_Open_From_Video, FrameMain::OnOpenAudioFromVideo)
@ -264,10 +266,10 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
MenuBar->Enable(Menu_View_Standard,aud && vid);
// Select option
if (curMode == 0) MenuBar->Check(Menu_View_Subs,true);
if (curMode == 1) MenuBar->Check(Menu_View_Video,true);
if (curMode == 2) MenuBar->Check(Menu_View_Standard,true);
if (curMode == 3) MenuBar->Check(Menu_View_Audio,true);
if (!showVideo && !showAudio) MenuBar->Check(Menu_View_Subs,true);
else if (showVideo && !showAudio) MenuBar->Check(Menu_View_Video,true);
else if (showAudio && !showVideo) MenuBar->Check(Menu_View_Standard,true);
else MenuBar->Check(Menu_View_Audio,true);
}
// Video menu
@ -848,11 +850,18 @@ void FrameMain::OnZoomOut (wxCommandEvent &event) {
}
void FrameMain::OnSetZoom(wxCommandEvent &event) {
//videoBox->videoDisplay->SetZoomPos(event.GetValue());
videoBox->videoDisplay->SetZoomPos(videoBox->videoDisplay->zoomBox->GetSelection());
}
////////////////
// Detach video
void FrameMain::OnDetachVideo(wxCommandEvent &event) {
detachedVideo = new DialogDetachedVideo(this);
detachedVideo->Show();
}
///////////////////////
// Open jump to dialog
void FrameMain::OnJumpTo(wxCommandEvent& WXUNUSED(event)) {
@ -1183,7 +1192,7 @@ void FrameMain::OnReplace(wxCommandEvent &event) {
void FrameMain::OnSetARDefault (wxCommandEvent &event) {
VideoContext::Get()->Stop();
videoBox->videoDisplay->SetAspectRatio(0);
SetDisplayMode(-1);
SetDisplayMode(-1,-1);
}
@ -1192,7 +1201,7 @@ void FrameMain::OnSetARDefault (wxCommandEvent &event) {
void FrameMain::OnSetARFull (wxCommandEvent &event) {
VideoContext::Get()->Stop();
videoBox->videoDisplay->SetAspectRatio(1);
SetDisplayMode(-1);
SetDisplayMode(-1,-1);
}
@ -1201,7 +1210,7 @@ void FrameMain::OnSetARFull (wxCommandEvent &event) {
void FrameMain::OnSetARWide (wxCommandEvent &event) {
VideoContext::Get()->Stop();
videoBox->videoDisplay->SetAspectRatio(2);
SetDisplayMode(-1);
SetDisplayMode(-1,-1);
}
@ -1210,7 +1219,7 @@ void FrameMain::OnSetARWide (wxCommandEvent &event) {
void FrameMain::OnSetAR235 (wxCommandEvent &event) {
VideoContext::Get()->Stop();
videoBox->videoDisplay->SetAspectRatio(3);
SetDisplayMode(-1);
SetDisplayMode(-1,-1);
}
@ -1260,7 +1269,7 @@ void FrameMain::OnSetARCustom (wxCommandEvent &event) {
// Set value
else {
videoBox->videoDisplay->SetAspectRatio(4,numval);
SetDisplayMode(-1);
SetDisplayMode(-1,-1);
}
}
@ -1558,7 +1567,7 @@ void FrameMain::OnChooseLanguage (wxCommandEvent &event) {
// View standard
void FrameMain::OnViewStandard (wxCommandEvent &event) {
if (!audioBox->audioDisplay->loaded || !VideoContext::Get()->IsLoaded()) return;
SetDisplayMode(2);
SetDisplayMode(1,1);
}
@ -1566,7 +1575,7 @@ void FrameMain::OnViewStandard (wxCommandEvent &event) {
// View video
void FrameMain::OnViewVideo (wxCommandEvent &event) {
if (!VideoContext::Get()->IsLoaded()) return;
SetDisplayMode(1);
SetDisplayMode(1,0);
}
@ -1574,14 +1583,14 @@ void FrameMain::OnViewVideo (wxCommandEvent &event) {
// View audio
void FrameMain::OnViewAudio (wxCommandEvent &event) {
if (!audioBox->audioDisplay->loaded) return;
SetDisplayMode(3);
SetDisplayMode(0,1);
}
/////////////
// View subs
void FrameMain::OnViewSubs (wxCommandEvent &event) {
SetDisplayMode(0);
SetDisplayMode(0,0);
}

View file

@ -163,6 +163,7 @@ void OptionsManager::LoadDefaults() {
// Audio Advanced
SetModificationType(MOD_AUTOMATIC);
SetInt(_T("Audio Cache"),1);
SetText(_T("Audio Provider"),_T("avisynth"));
SetText(_T("Audio Downmixer"),_T("ConvertToMono"));
SetText(_T("Audio HD Cache Location"),_T("default"));
SetText(_T("Audio HD Cache Name"),_T("audio%02i.tmp"));

View file

@ -895,7 +895,7 @@ int SubsEditBox::BlockAtPos(int pos) {
////////////////
// Set override
void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos) {
void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos,bool getFocus) {
// Selection
int selstart, selend;
if (forcePos != -1) {
@ -1201,7 +1201,7 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
TextEdit->SetTextTo(line->Text);
delete line;
TextEdit->SetSelectionU(selstart+shift,selend+shift);
TextEdit->SetFocus();
if (getFocus) TextEdit->SetFocus();
}

View file

@ -146,7 +146,7 @@ public:
SubsEditBox(wxWindow *parent,SubtitlesGrid *gridp);
void SetOverride (wxString tag,wxString preValue=_T(""),int pos=-1);
void SetOverride (wxString tag,wxString preValue=_T(""),int pos=-1,bool getFocus=true);
void SetStyleFlag (wxString tag,wxString preValue=_T(""),int pos=-1);
void SetSplitLineMode(wxSize size=wxSize(-1,-1));

View file

@ -309,15 +309,22 @@ void VideoContext::RemoveDisplay(VideoDisplay *display) {
// Update displays
void VideoContext::UpdateDisplays(bool full) {
for (std::list<VideoDisplay*>::iterator cur=displayList.begin();cur!=displayList.end();cur++) {
// Get display
VideoDisplay *display = *cur;
// Update slider
if (full) {
display->UpdateSize();
display->ControlSlider->SetRange(0,GetLength()-1);
}
display->ControlSlider->SetValue(GetFrameN());
display->ControlSlider->Update();
//display->ControlSlider->Update();
display->UpdatePositionDisplay();
// If not shown, don't update the display itself
if (!display->IsShownOnScreen()) continue;
// Update controls
display->Refresh();
display->Update();
}

View file

@ -81,6 +81,7 @@ BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas)
EVT_KEY_DOWN(VideoDisplay::OnKey)
EVT_LEAVE_WINDOW(VideoDisplay::OnMouseLeave)
EVT_PAINT(VideoDisplay::OnPaint)
EVT_SIZE(VideoDisplay::OnSizeEvent)
EVT_ERASE_BACKGROUND(VideoDisplay::OnEraseBackground)
EVT_MENU(VIDEO_MENU_COPY_TO_CLIPBOARD,VideoDisplay::OnCopyToClipboard)
@ -91,7 +92,7 @@ END_EVENT_TABLE()
//////////////
// Parameters
int attribList[2] = { WX_GL_RGBA , 0 };
int attribList[3] = { WX_GL_RGBA , WX_GL_DOUBLEBUFFER, 0 };
///////////////
// Constructor
@ -129,7 +130,7 @@ VideoDisplay::~VideoDisplay () {
// Render
void VideoDisplay::Render() {
// Is shown?
if (!GetParent()->IsShown()) return;
if (!IsShownOnScreen()) return;
// Set GL context
VideoContext *context = VideoContext::Get();
@ -245,16 +246,21 @@ void VideoDisplay::Reset() {
}
/////////////////
// OnPaint event
///////////////
// Paint event
void VideoDisplay::OnPaint(wxPaintEvent& event) {
wxPaintDC dc(this);
// Draw frame
Render();
}
//////////////
// Size Event
void VideoDisplay::OnSizeEvent(wxSizeEvent &event) {
Refresh(false);
}
///////////////
// Mouse stuff
void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {

View file

@ -78,6 +78,7 @@ private:
void OnSaveSnapshot(wxCommandEvent &event);
void OnCopyCoords(wxCommandEvent &event);
void OnEraseBackground(wxEraseEvent &event) {}
void OnSizeEvent(wxSizeEvent &event);
public:
VideoDisplayVisual *visual;

View file

@ -910,7 +910,7 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
curY = (y - startY + origY) * sh / h;
if (realTime) {
AssLimitToVisibleFilter::SetFrame(frame_n);
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),curX,curY),0);
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),curX,curY),0,false);
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
}
@ -934,7 +934,7 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
if (realTime) {
AssLimitToVisibleFilter::SetFrame(frame_n);
wxString param = PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle));
grid->editBox->SetOverride(_T("\\frz"),param,0);
grid->editBox->SetOverride(_T("\\frz"),param,0,false);
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
}
@ -965,8 +965,8 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
// Update
if (realTime) {
AssLimitToVisibleFilter::SetFrame(frame_n);
grid->editBox->SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0);
grid->editBox->SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle2)),0);
grid->editBox->SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0,false);
grid->editBox->SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle2)),0,false);
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
}
@ -989,8 +989,8 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
// Update
if (realTime) {
AssLimitToVisibleFilter::SetFrame(frame_n);
grid->editBox->SetOverride(_T("\\fscx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleX)),0);
grid->editBox->SetOverride(_T("\\fscy"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleY)),0);
grid->editBox->SetOverride(_T("\\fscx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleX)),0,false);
grid->editBox->SetOverride(_T("\\fscy"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleY)),0,false);
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
}
@ -1018,7 +1018,7 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
// Update
if (realTime) {
AssLimitToVisibleFilter::SetFrame(frame_n);
grid->editBox->SetOverride(_T("\\clip"),wxString::Format(_T("(%i,%i,%i,%i)"),curX,curY,curX2,curY2),0);
grid->editBox->SetOverride(_T("\\clip"),wxString::Format(_T("(%i,%i,%i,%i)"),curX,curY,curX2,curY2),0,false);
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
}
@ -1031,29 +1031,29 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
// Finished dragging subtitles
if (hold == 1) {
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),curX,curY),0);
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),curX,curY),0,false);
}
// Finished rotating Z
else if (hold == 2) {
grid->editBox->SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0);
grid->editBox->SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0,false);
}
// Finished rotating XY
else if (hold == 3) {
grid->editBox->SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0);
grid->editBox->SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle2)),0);
grid->editBox->SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0,false);
grid->editBox->SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle2)),0,false);
}
// Finished scaling
else if (hold == 4) {
grid->editBox->SetOverride(_T("\\fscx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleX)),0);
grid->editBox->SetOverride(_T("\\fscy"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleY)),0);
grid->editBox->SetOverride(_T("\\fscx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleX)),0,false);
grid->editBox->SetOverride(_T("\\fscy"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleY)),0,false);
}
// Finished clipping
else if (hold == 5) {
grid->editBox->SetOverride(_T("\\clip"),wxString::Format(_T("(%i,%i,%i,%i)"),curX,curY,curX2,curY2),0);
grid->editBox->SetOverride(_T("\\clip"),wxString::Format(_T("(%i,%i,%i,%i)"),curX,curY,curX2,curY2),0,false);
}
// Commit
@ -1074,7 +1074,7 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
// Double click
if (mode == 0 && event.LeftDClick()) {
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),vx,vy),0);
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),vx,vy),0,false);
grid->editBox->CommitText();
grid->ass->FlagAsModified();
grid->CommitChanges(false,true);

View file

@ -37,6 +37,7 @@
///////////
// Headers
#include <wx/wxprec.h>
#ifdef __WINDOWS__
#include <wx/filename.h>
#include <wx/msw/registry.h>
#include <wx/filename.h>
@ -521,3 +522,6 @@ void AvisynthVideoProvider::OverrideFrameTimeList(wxArrayInt list) {
frameTime = list;
num_frames = frameTime.Count();
}
#endif

View file

@ -37,6 +37,9 @@
///////////
// Headers
#pragma warning(disable: 4995)
#include <wx/wxprec.h>
#ifdef __WINDOWS__
#include <wx/image.h>
#include <dshow.h>
#include <atlbase.h>
#include <atlcom.h>
@ -45,8 +48,6 @@
#include <windows.h>
#include <tchar.h>
#include <initguid.h>
#include <wx/wxprec.h>
#include <wx/image.h>
#include "video_provider.h"
#include "utils.h"
#include "vfr.h"
@ -585,4 +586,4 @@ void DirectShowVideoProvider::OverrideFrameTimeList(wxArrayInt list) {
num_frames = frameTime.Count();
}
#endif