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

View file

@ -37,8 +37,6 @@
/////////// ///////////
// Headers // Headers
#include <wx/wxprec.h> #include <wx/wxprec.h>
#include "audio_provider_avs.h"
#include "audio_provider_lavc.h"
#include "audio_provider_ram.h" #include "audio_provider_ram.h"
#include "audio_provider_hd.h" #include "audio_provider_hd.h"
#include "options.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 // Get provider
AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay *display, VideoProvider *vprovider,int cache) { AudioProvider *AudioProviderFactory::GetAudioProvider(wxString filename, int cache) {
// Prepare provider // Prepare provider
AudioProvider *provider = NULL; AudioProvider *provider = NULL;
// Select provider // List of providers
#if USE_LAVC == 1 wxArrayString list = GetFactoryList(Options.AsText(_T("Audio provider")));
if (!provider) provider = new LAVCAudioProvider(filename, vprovider);
#endif
#ifdef __WINDOWS__ // None available
if (!provider) provider = new AvisynthAudioProvider(filename); if (list.Count() == 0) throw _T("No audio providers are available.");
#endif
// No provider found // Get provider
if (!provider) { wxString error;
throw _T("Could not initialize any audio provider."); 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 // Change provider to RAM/HD cache if needed
if (cache == -1) cache = Options.AsInt(_T("Audio Cache")); if (cache == -1) cache = Options.AsInt(_T("Audio Cache"));
if (cache) { if (cache) {
@ -203,23 +233,6 @@ AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay *
} }
///////////////////////// //////////
// Get audio with volume // Static
void AudioProvider::GetAudioWithVolume(void *buf, __int64 start, __int64 count, double volume) { std::map<wxString,AudioProviderFactory*>* AegisubFactory<AudioProviderFactory>::factories=NULL;
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;
}
}
}

View file

@ -40,6 +40,7 @@
/////////// ///////////
// Headers // Headers
#include <wx/wxprec.h> #include <wx/wxprec.h>
#include "factory.h"
////////////// //////////////
@ -71,11 +72,23 @@ public:
virtual void GetAudio(void *buf, __int64 start, __int64 count)=0; virtual void GetAudio(void *buf, __int64 start, __int64 count)=0;
void GetAudioWithVolume(void *buf, __int64 start, __int64 count, double volume); void GetAudioWithVolume(void *buf, __int64 start, __int64 count, double volume);
int GetChannels();
__int64 GetNumSamples(); __int64 GetNumSamples();
int GetSampleRate(); int GetSampleRate();
int GetBytesPerSample(); int GetBytesPerSample();
int GetChannels();
void GetWaveForm(int *min,int *peak,__int64 start,int w,int h,int samples,float scale); 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 // Headers
#include <wx/wxprec.h> #include <wx/wxprec.h>
#ifdef __WINDOWS__ #ifdef __WINDOWS__
#include <wx/filename.h> #include <wx/filename.h>
#include <Mmreg.h> #include <Mmreg.h>
#include <time.h>
#include "audio_provider.h"
#include "avisynth_wrap.h" #include "avisynth_wrap.h"
#include "utils.h" #include "utils.h"
#include "audio_provider_avs.h"
#include "options.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 // Constructor
AvisynthAudioProvider::AvisynthAudioProvider(wxString _filename) { AvisynthAudioProvider::AvisynthAudioProvider(wxString _filename) {

View file

@ -35,38 +35,3 @@
#pragma once #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 // Headers
#include "setup.h" #define EMULATE_INTTYPES
#if USE_LAVC == 1
#include <wx/wxprec.h> #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 "utils.h"
#include "audio_provider_lavc.h"
#include "video_provider_lavc.h"
#include "options.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) : lavcfile(NULL), codecContext(NULL), rsct(NULL), buffer(NULL)
{ {
try { 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. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
@ -36,32 +36,21 @@
#pragma once #pragma once
#include "setup.h"
#if USE_LAVC == 1
#define EMULATE_INTTYPES //////////////
#include "audio_provider.h" // Prototypes
#include "lavc_file.h" class VideoBox;
class FrameMain;
class LAVCAudioProvider : public AudioProvider {
//////////////////////////////
// Detached video frame class
class DialogDetachedVideo : public wxFrame {
private: private:
LAVCFile *lavcfile; VideoBox *videoBox;
FrameMain *parent;
AVCodecContext *codecContext;
ReSampleContext *rsct;
float resample_ratio;
AVStream *stream;
int audStream;
int16_t *buffer;
void Destroy();
public: public:
LAVCAudioProvider(wxString _filename, VideoProvider *vpro); DialogDetachedVideo(FrameMain *parent);
virtual ~LAVCAudioProvider(); ~DialogDetachedVideo();
virtual void GetAudio(void *buf, __int64 start, __int64 count);
}; };
#endif /* USE_LAVC */

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -146,7 +146,7 @@ public:
SubsEditBox(wxWindow *parent,SubtitlesGrid *gridp); 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 SetStyleFlag (wxString tag,wxString preValue=_T(""),int pos=-1);
void SetSplitLineMode(wxSize size=wxSize(-1,-1)); void SetSplitLineMode(wxSize size=wxSize(-1,-1));

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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