2007-01-21 07:30:19 +01:00
|
|
|
// Copyright (c) 2005-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.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2007-01-21 07:30:19 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file video_context.cpp
|
|
|
|
/// @brief Keep track of loaded video and video displays
|
|
|
|
/// @ingroup video
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
////////////
|
|
|
|
// Includes
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <wx/clipbrd.h>
|
|
|
|
#include <wx/config.h>
|
|
|
|
#include <wx/filename.h>
|
|
|
|
#include <wx/image.h>
|
|
|
|
#endif
|
|
|
|
|
2007-09-12 01:22:26 +02:00
|
|
|
#ifdef __APPLE__
|
2007-04-22 04:24:27 +02:00
|
|
|
#include <OpenGL/GL.h>
|
|
|
|
#include <OpenGL/glu.h>
|
|
|
|
#else
|
2007-01-22 23:57:45 +01:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glu.h>
|
2007-04-22 04:24:27 +02:00
|
|
|
#endif
|
2009-09-10 15:06:40 +02:00
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
#include "ass_dialogue.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "ass_exporter.h"
|
|
|
|
#include "ass_file.h"
|
2007-01-21 07:30:19 +01:00
|
|
|
#include "ass_style.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "ass_time.h"
|
2007-01-21 07:30:19 +01:00
|
|
|
#include "audio_display.h"
|
2010-05-19 02:44:37 +02:00
|
|
|
#include "mkv_wrap.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "options.h"
|
2007-06-21 00:23:55 +02:00
|
|
|
#include "standard_paths.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "subs_edit_box.h"
|
|
|
|
#include "subs_grid.h"
|
|
|
|
#include "subtitles_provider_manager.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "vfr.h"
|
|
|
|
#include "video_box.h"
|
|
|
|
#include "video_context.h"
|
|
|
|
#include "video_display.h"
|
|
|
|
#include "video_provider_manager.h"
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
///////
|
|
|
|
// IDs
|
|
|
|
enum {
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-01-21 07:30:19 +01:00
|
|
|
VIDEO_PLAY_TIMER = 1300
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
// Event table
|
|
|
|
BEGIN_EVENT_TABLE(VideoContext, wxEvtHandler)
|
|
|
|
EVT_TIMER(VIDEO_PLAY_TIMER,VideoContext::OnPlayTimer)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// DOCME
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext *VideoContext::instance = NULL;
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Constructor
|
|
|
|
///
|
2010-05-19 02:44:37 +02:00
|
|
|
VideoContext::VideoContext()
|
2010-05-20 10:55:58 +02:00
|
|
|
: ownGlContext(false)
|
|
|
|
, glContext(NULL)
|
2010-05-19 02:44:37 +02:00
|
|
|
, provider(NULL)
|
|
|
|
, subsProvider(NULL)
|
|
|
|
, keyFramesLoaded(false)
|
|
|
|
, overKeyFramesLoaded(false)
|
2010-05-20 10:55:58 +02:00
|
|
|
, startFrame(-1)
|
|
|
|
, endFrame(-1)
|
|
|
|
, playNextFrame(-1)
|
|
|
|
, nextFrame(-1)
|
|
|
|
, loaded(false)
|
|
|
|
, isPlaying(false)
|
|
|
|
, keepAudioSync(true)
|
|
|
|
, w(-1)
|
|
|
|
, h(-1)
|
2010-05-19 02:44:37 +02:00
|
|
|
, frame_n(0)
|
|
|
|
, length(0)
|
|
|
|
, fps(0)
|
|
|
|
, arValue(1.)
|
2010-05-20 10:55:58 +02:00
|
|
|
, arType(0)
|
2010-05-19 02:44:37 +02:00
|
|
|
, hasSubtitles(false)
|
2010-05-20 10:55:58 +02:00
|
|
|
, grid(NULL)
|
|
|
|
, curLine(NULL)
|
|
|
|
, audio(NULL)
|
2010-05-19 02:44:37 +02:00
|
|
|
{
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Destructor
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext::~VideoContext () {
|
|
|
|
Reset();
|
2009-07-14 04:00:56 +02:00
|
|
|
if (ownGlContext)
|
|
|
|
delete glContext;
|
2007-01-21 07:30:19 +01:00
|
|
|
glContext = NULL;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Get Instance
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext *VideoContext::Get() {
|
2007-01-23 21:50:41 +01:00
|
|
|
if (!instance) {
|
|
|
|
instance = new VideoContext;
|
|
|
|
}
|
2007-01-21 07:30:19 +01:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Clear
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::Clear() {
|
|
|
|
instance->audio = NULL;
|
|
|
|
delete instance;
|
|
|
|
instance = NULL;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Reset
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::Reset() {
|
2009-12-01 01:32:43 +01:00
|
|
|
loaded = false;
|
2007-06-21 00:23:55 +02:00
|
|
|
StandardPaths::SetPathValue(_T("?video"),_T(""));
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
KeyFrames.Clear();
|
|
|
|
keyFramesLoaded = false;
|
|
|
|
|
|
|
|
// Remove temporary audio provider
|
|
|
|
if (audio && audio->temporary) {
|
|
|
|
delete audio->provider;
|
|
|
|
audio->provider = NULL;
|
|
|
|
delete audio->player;
|
|
|
|
audio->player = NULL;
|
|
|
|
audio->temporary = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove video data
|
|
|
|
frame_n = 0;
|
2009-05-01 00:13:10 +02:00
|
|
|
length = 0;
|
|
|
|
fps = 0;
|
2007-01-21 07:30:19 +01:00
|
|
|
keyFramesLoaded = false;
|
|
|
|
overKeyFramesLoaded = false;
|
|
|
|
isPlaying = false;
|
|
|
|
nextFrame = -1;
|
2007-06-28 22:29:56 +02:00
|
|
|
curLine = NULL;
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
// Update displays
|
|
|
|
UpdateDisplays(true);
|
|
|
|
|
|
|
|
// Clean up video data
|
|
|
|
wxRemoveFile(tempfile);
|
|
|
|
tempfile = _T("");
|
|
|
|
videoName = _T("");
|
|
|
|
tempFrame.Clear();
|
|
|
|
|
|
|
|
// Remove provider
|
2007-04-08 21:27:46 +02:00
|
|
|
if (provider) {
|
|
|
|
delete provider;
|
|
|
|
provider = NULL;
|
|
|
|
}
|
2009-05-15 14:44:36 +02:00
|
|
|
delete subsProvider;
|
2007-01-21 07:30:19 +01:00
|
|
|
subsProvider = NULL;
|
2007-04-08 21:27:46 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Reload video
|
|
|
|
///
|
2007-04-08 21:27:46 +02:00
|
|
|
void VideoContext::Reload() {
|
|
|
|
if (IsLoaded()) {
|
|
|
|
wxString name = videoName;
|
|
|
|
int n = frame_n;
|
|
|
|
SetVideo(_T(""));
|
|
|
|
SetVideo(name);
|
|
|
|
JumpToFrame(n);
|
|
|
|
}
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Sets video filename
|
|
|
|
/// @param filename
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::SetVideo(const wxString &filename) {
|
|
|
|
// Unload video
|
|
|
|
Reset();
|
2009-10-06 18:12:23 +02:00
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
// Load video
|
|
|
|
if (!filename.IsEmpty()) {
|
|
|
|
try {
|
|
|
|
grid->CommitChanges(true);
|
|
|
|
|
2007-01-27 08:13:29 +01:00
|
|
|
// Set GL context
|
|
|
|
GetGLContext(displayList.front())->SetCurrent(*displayList.front());
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
// Choose a provider
|
2009-07-20 02:39:38 +02:00
|
|
|
provider = VideoProviderFactoryManager::GetProvider(filename);
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
// Get subtitles provider
|
2007-01-23 01:38:59 +01:00
|
|
|
try {
|
2009-05-15 14:44:36 +02:00
|
|
|
subsProvider = SubtitlesProviderFactoryManager::GetProvider();
|
2007-01-23 01:38:59 +01:00
|
|
|
}
|
|
|
|
catch (wxString err) { wxMessageBox(_T("Error while loading subtitles provider: ") + err,_T("Subtitles provider")); }
|
|
|
|
catch (const wchar_t *err) { wxMessageBox(_T("Error while loading subtitles provider: ") + wxString(err),_T("Subtitles provider")); }
|
2007-01-21 07:30:19 +01:00
|
|
|
|
2008-07-15 02:08:05 +02:00
|
|
|
KeyFrames.Clear();
|
|
|
|
// load keyframes if available
|
|
|
|
if (provider->AreKeyFramesLoaded()) {
|
|
|
|
KeyFrames = provider->GetKeyFrames();
|
|
|
|
keyFramesLoaded = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
keyFramesLoaded = false;
|
|
|
|
}
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
// Set frame rate
|
|
|
|
fps = provider->GetFPS();
|
2009-07-23 04:06:47 +02:00
|
|
|
// does this provider need special vfr treatment?
|
|
|
|
if (provider->NeedsVFRHack()) {
|
|
|
|
// FIXME:
|
|
|
|
// Unfortunately, this hack does not actually work for the one
|
|
|
|
// provider that needs it (Avisynth). Go figure.
|
|
|
|
bool isVfr = provider->IsVFR();
|
|
|
|
if (!isVfr || provider->IsNativelyByFrames()) {
|
|
|
|
VFR_Input.SetCFR(fps);
|
|
|
|
if (VFR_Output.GetFrameRateType() != VFR) VFR_Output.SetCFR(fps);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FrameRate temp = provider->GetTrueFrameRate();
|
|
|
|
provider->OverrideFrameTimeList(temp.GetFrameTimeList());
|
|
|
|
}
|
2009-06-24 20:16:03 +02:00
|
|
|
}
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
// Gather video parameters
|
|
|
|
length = provider->GetFrameCount();
|
|
|
|
w = provider->GetWidth();
|
|
|
|
h = provider->GetHeight();
|
|
|
|
|
|
|
|
// Set filename
|
|
|
|
videoName = filename;
|
|
|
|
Options.AddToRecentList(filename,_T("Recent vid"));
|
2007-06-21 00:23:55 +02:00
|
|
|
wxFileName fn(filename);
|
|
|
|
StandardPaths::SetPathValue(_T("?video"),fn.GetPath());
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
// Get frame
|
|
|
|
frame_n = 0;
|
2007-07-29 11:06:38 +02:00
|
|
|
|
|
|
|
// Show warning
|
2008-03-26 00:42:39 +01:00
|
|
|
wxString warning = provider->GetWarning().c_str();
|
2007-07-29 11:06:38 +02:00
|
|
|
if (!warning.IsEmpty()) wxMessageBox(warning,_T("Warning"),wxICON_WARNING | wxOK);
|
2010-02-14 23:02:33 +01:00
|
|
|
|
2010-05-19 02:44:37 +02:00
|
|
|
hasSubtitles = false;
|
|
|
|
if (filename.Right(4).Lower() == L".mkv") {
|
|
|
|
hasSubtitles = MatroskaWrapper::HasSubtitles(filename);
|
|
|
|
}
|
|
|
|
|
2010-02-14 23:02:33 +01:00
|
|
|
UpdateDisplays(true);
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
catch (wxString &e) {
|
|
|
|
wxMessageBox(e,_T("Error setting video"),wxICON_ERROR | wxOK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loaded = provider != NULL;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Add new display
|
|
|
|
/// @param display
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::AddDisplay(VideoDisplay *display) {
|
|
|
|
for (std::list<VideoDisplay*>::iterator cur=displayList.begin();cur!=displayList.end();cur++) {
|
|
|
|
if ((*cur) == display) return;
|
|
|
|
}
|
|
|
|
displayList.push_back(display);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Remove display
|
|
|
|
/// @param display
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::RemoveDisplay(VideoDisplay *display) {
|
|
|
|
displayList.remove(display);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Update displays
|
|
|
|
/// @param full
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::UpdateDisplays(bool full) {
|
|
|
|
for (std::list<VideoDisplay*>::iterator cur=displayList.begin();cur!=displayList.end();cur++) {
|
|
|
|
VideoDisplay *display = *cur;
|
2007-01-23 05:42:08 +01:00
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
if (full) {
|
|
|
|
display->UpdateSize();
|
2009-10-05 06:22:28 +02:00
|
|
|
display->SetFrameRange(0,GetLength()-1);
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
2009-10-05 06:22:28 +02:00
|
|
|
display->SetFrame(GetFrameN());
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
2008-01-14 02:18:24 +01:00
|
|
|
|
|
|
|
// Update audio display
|
2008-01-15 23:51:16 +01:00
|
|
|
if (audio && audio->loaded && audio->IsShownOnScreen()) {
|
2008-01-14 02:18:24 +01:00
|
|
|
if (Options.AsBool(_T("Audio Draw Video Position"))) {
|
|
|
|
audio->UpdateImage(false);
|
|
|
|
}
|
|
|
|
}
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Refresh subtitles
|
|
|
|
/// @param video
|
|
|
|
/// @param subtitles
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::Refresh (bool video, bool subtitles) {
|
2007-07-27 06:50:15 +02:00
|
|
|
// Update subtitles
|
2007-01-21 07:30:19 +01:00
|
|
|
if (subtitles && subsProvider) {
|
2007-07-27 06:50:15 +02:00
|
|
|
// Re-export
|
2007-01-21 07:30:19 +01:00
|
|
|
AssExporter exporter(grid->ass);
|
|
|
|
exporter.AddAutoFilters();
|
2009-04-26 02:11:29 +02:00
|
|
|
try {
|
|
|
|
subsProvider->LoadSubtitles(exporter.ExportTransform());
|
|
|
|
}
|
|
|
|
catch (wxString err) { wxMessageBox(_T("Error while invoking subtitles provider: ") + err,_T("Subtitles provider")); }
|
|
|
|
catch (const wchar_t *err) { wxMessageBox(_T("Error while invoking subtitles provider: ") + wxString(err),_T("Subtitles provider")); }
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Jump to frame
|
|
|
|
JumpToFrame(frame_n);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Jumps to a frame and update display
|
|
|
|
/// @param n
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::JumpToFrame(int n) {
|
|
|
|
// Loaded?
|
|
|
|
if (!loaded) return;
|
|
|
|
|
|
|
|
// Prevent intervention during playback
|
|
|
|
if (isPlaying && n != playNextFrame) return;
|
|
|
|
|
2009-12-01 01:32:43 +01:00
|
|
|
// Set frame number
|
|
|
|
frame_n = n;
|
2007-04-08 01:45:46 +02:00
|
|
|
|
2009-12-01 01:32:43 +01:00
|
|
|
// Display
|
|
|
|
UpdateDisplays(false);
|
2007-01-21 07:30:19 +01:00
|
|
|
|
2009-12-01 01:32:43 +01:00
|
|
|
// Update grid
|
|
|
|
if (!isPlaying && Options.AsBool(_T("Highlight subs in frame"))) grid->Refresh(false);
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Jumps to a specific time
|
|
|
|
/// @param ms
|
|
|
|
/// @param exact
|
|
|
|
///
|
2007-04-07 05:12:55 +02:00
|
|
|
void VideoContext::JumpToTime(int ms,bool exact) {
|
|
|
|
int frame;
|
|
|
|
if (exact) frame = VFR_Output.PFrameAtTime(ms);
|
|
|
|
else frame = VFR_Output.GetFrameAtTime(ms);
|
|
|
|
JumpToFrame(frame);
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get GL context
|
|
|
|
/// @param canvas
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
wxGLContext *VideoContext::GetGLContext(wxGLCanvas *canvas) {
|
2009-07-14 04:00:56 +02:00
|
|
|
if (!glContext) {
|
|
|
|
glContext = new wxGLContext(canvas);
|
|
|
|
ownGlContext = true;
|
|
|
|
}
|
2007-01-21 07:30:19 +01:00
|
|
|
return glContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Requests a new frame
|
|
|
|
/// @param n
|
|
|
|
/// @param raw
|
|
|
|
/// @return
|
|
|
|
///
|
2007-04-08 00:03:06 +02:00
|
|
|
AegiVideoFrame VideoContext::GetFrame(int n,bool raw) {
|
2007-04-03 04:55:43 +02:00
|
|
|
// Current frame if -1
|
|
|
|
if (n == -1) n = frame_n;
|
|
|
|
|
|
|
|
// Get frame
|
2009-07-20 05:50:25 +02:00
|
|
|
AegiVideoFrame frame = provider->GetFrame(n);
|
2007-04-03 04:55:43 +02:00
|
|
|
|
|
|
|
// Raster subtitles if available/necessary
|
2009-05-15 14:44:36 +02:00
|
|
|
if (!raw && subsProvider) {
|
2007-04-08 20:12:51 +02:00
|
|
|
tempFrame.CopyFrom(frame);
|
2010-04-22 03:09:16 +02:00
|
|
|
try {
|
|
|
|
subsProvider->DrawSubtitles(tempFrame,VFR_Input.GetTimeAtFrame(n,true,true)/1000.0);
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
wxLogError(L"Subtitle rendering for the current frame failed.\n");
|
|
|
|
}
|
2007-04-03 04:55:43 +02:00
|
|
|
return tempFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return pure frame
|
2007-04-08 20:12:51 +02:00
|
|
|
else return frame;
|
2007-04-03 04:55:43 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Save snapshot
|
|
|
|
/// @param raw
|
|
|
|
///
|
2007-04-08 00:03:06 +02:00
|
|
|
void VideoContext::SaveSnapshot(bool raw) {
|
2007-01-21 07:30:19 +01:00
|
|
|
// Get folder
|
2008-09-06 11:33:14 +02:00
|
|
|
wxString option = Options.AsText(_T("Video Screenshot Path"));
|
2007-01-21 07:30:19 +01:00
|
|
|
wxFileName videoFile(videoName);
|
|
|
|
wxString basepath;
|
2008-01-10 23:28:47 +01:00
|
|
|
// Is it a path specifier and not an actual fixed path?
|
2007-06-21 02:46:50 +02:00
|
|
|
if (option[0] == _T('?')) {
|
2008-01-10 23:28:47 +01:00
|
|
|
// If dummy video is loaded, we can't save to the video location
|
2008-01-11 00:22:49 +01:00
|
|
|
if (option.StartsWith(_T("?video")) && (videoName.Find(_T("?dummy")) != wxNOT_FOUND)) {
|
2008-01-10 23:28:47 +01:00
|
|
|
// So try the script location instead
|
|
|
|
option = _T("?script");
|
|
|
|
}
|
|
|
|
// Find out where the ?specifier points to
|
2007-06-21 02:46:50 +02:00
|
|
|
basepath = StandardPaths::DecodePath(option);
|
2008-01-10 23:28:47 +01:00
|
|
|
// If whereever that is isn't defined, we can't save there
|
|
|
|
if ((basepath == _T("\\")) || (basepath == _T("/"))) {
|
|
|
|
// So save to the current user's home dir instead
|
|
|
|
basepath = wxGetHomeDir();
|
|
|
|
}
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
2008-01-10 23:28:47 +01:00
|
|
|
// Actual fixed (possibly relative) path, decode it
|
2007-06-21 02:46:50 +02:00
|
|
|
else basepath = DecodeRelativePath(option,StandardPaths::DecodePath(_T("?user/")));
|
2007-01-21 07:30:19 +01:00
|
|
|
basepath += _T("/") + videoFile.GetName();
|
|
|
|
|
|
|
|
// Get full path
|
|
|
|
int session_shot_count = 1;
|
|
|
|
wxString path;
|
|
|
|
while (1) {
|
|
|
|
path = basepath + wxString::Format(_T("_%03i_%i.png"),session_shot_count,frame_n);
|
|
|
|
++session_shot_count;
|
|
|
|
wxFileName tryPath(path);
|
|
|
|
if (!tryPath.FileExists()) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save
|
2007-04-08 00:03:06 +02:00
|
|
|
GetFrame(frame_n,raw).GetImage().SaveFile(path,wxBITMAP_TYPE_PNG);
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Get dimensions of script
|
|
|
|
/// @param sw
|
|
|
|
/// @param sh
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::GetScriptSize(int &sw,int &sh) {
|
|
|
|
grid->ass->GetResolution(sw,sh);
|
|
|
|
}
|
|
|
|
|
2010-02-17 20:04:41 +01:00
|
|
|
/// @brief Play the next frame, possibly with audio
|
|
|
|
/// @return
|
|
|
|
///
|
|
|
|
void VideoContext::PlayNextFrame() {
|
|
|
|
if (isPlaying)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int thisFrame = frame_n;
|
|
|
|
JumpToFrame(frame_n + 1);
|
|
|
|
// Start playing audio
|
|
|
|
if (Options.AsBool(_T("Audio Plays When Stepping Video")))
|
|
|
|
audio->Play(VFR_Output.GetTimeAtFrame(thisFrame),VFR_Output.GetTimeAtFrame(thisFrame + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Play the previous frame, possibly with audio
|
|
|
|
/// @return
|
|
|
|
///
|
|
|
|
void VideoContext::PlayPrevFrame() {
|
|
|
|
if (isPlaying)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int thisFrame = frame_n;
|
|
|
|
JumpToFrame(frame_n -1);
|
|
|
|
// Start playing audio
|
|
|
|
if (Options.AsBool(_T("Audio Plays When Stepping Video")))
|
|
|
|
audio->Play(VFR_Output.GetTimeAtFrame(thisFrame - 1),VFR_Output.GetTimeAtFrame(thisFrame));
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Play
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::Play() {
|
|
|
|
// Stop if already playing
|
|
|
|
if (isPlaying) {
|
|
|
|
Stop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set variables
|
|
|
|
startFrame = frame_n;
|
|
|
|
endFrame = -1;
|
|
|
|
|
|
|
|
// Start playing audio
|
|
|
|
audio->Play(VFR_Output.GetTimeAtFrame(startFrame),-1);
|
|
|
|
|
2007-03-18 02:20:25 +01:00
|
|
|
//audio->Play will override this if we put it before, so put it after.
|
|
|
|
isPlaying = true;
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
// Start timer
|
2008-01-20 07:14:40 +01:00
|
|
|
playTime.Start();
|
2007-01-21 07:30:19 +01:00
|
|
|
playback.SetOwner(this,VIDEO_PLAY_TIMER);
|
2008-01-20 07:14:40 +01:00
|
|
|
playback.Start(10);
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
2010-02-17 20:04:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Play line
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::PlayLine() {
|
|
|
|
// Get line
|
|
|
|
AssDialogue *curline = grid->GetDialogue(grid->editBox->linen);
|
|
|
|
if (!curline) return;
|
|
|
|
|
|
|
|
// Start playing audio
|
|
|
|
audio->Play(curline->Start.GetMS(),curline->End.GetMS());
|
|
|
|
|
|
|
|
// Set variables
|
|
|
|
isPlaying = true;
|
|
|
|
startFrame = VFR_Output.GetFrameAtTime(curline->Start.GetMS(),true);
|
|
|
|
endFrame = VFR_Output.GetFrameAtTime(curline->End.GetMS(),false);
|
|
|
|
|
|
|
|
// Jump to start
|
|
|
|
playNextFrame = startFrame;
|
|
|
|
JumpToFrame(startFrame);
|
|
|
|
|
|
|
|
// Set other variables
|
2008-01-20 20:51:48 +01:00
|
|
|
playTime.Start();
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
// Start timer
|
|
|
|
playback.SetOwner(this,VIDEO_PLAY_TIMER);
|
2008-01-20 07:14:40 +01:00
|
|
|
playback.Start(10);
|
2007-01-21 07:30:19 +01:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Stop
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::Stop() {
|
|
|
|
if (isPlaying) {
|
|
|
|
playback.Stop();
|
|
|
|
isPlaying = false;
|
|
|
|
audio->Stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Play timer
|
|
|
|
/// @param event
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::OnPlayTimer(wxTimerEvent &event) {
|
|
|
|
// Lock
|
|
|
|
wxMutexError res = playMutex.TryLock();
|
|
|
|
if (res == wxMUTEX_BUSY) return;
|
|
|
|
playMutex.Unlock();
|
|
|
|
wxMutexLocker lock(playMutex);
|
|
|
|
|
|
|
|
// Get time difference
|
2008-01-20 07:14:40 +01:00
|
|
|
int dif = playTime.Time();
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
// Find next frame
|
|
|
|
int startMs = VFR_Output.GetTimeAtFrame(startFrame);
|
|
|
|
int nextFrame = frame_n;
|
|
|
|
int i=0;
|
|
|
|
for (i=0;i<10;i++) {
|
|
|
|
if (nextFrame >= length) break;
|
|
|
|
if (dif < VFR_Output.GetTimeAtFrame(nextFrame) - startMs) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nextFrame++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// End
|
|
|
|
if (nextFrame >= length || (endFrame != -1 && nextFrame > endFrame)) {
|
|
|
|
Stop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Same frame
|
|
|
|
if (nextFrame == frame_n) return;
|
|
|
|
|
|
|
|
// Next frame is before or over 2 frames ahead, so force audio resync
|
2009-04-28 12:23:20 +02:00
|
|
|
if (audio->player && keepAudioSync && (nextFrame < frame_n || nextFrame > frame_n + 2)) audio->player->SetCurrentPosition(audio->GetSampleAtMS(VFR_Output.GetTimeAtFrame(nextFrame)));
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
// Jump to next frame
|
|
|
|
playNextFrame = nextFrame;
|
|
|
|
frame_n = nextFrame;
|
|
|
|
JumpToFrame(nextFrame);
|
|
|
|
|
|
|
|
// Sync audio
|
2007-07-30 06:05:45 +02:00
|
|
|
if (keepAudioSync && nextFrame % 10 == 0 && audio && audio->provider && audio->player) {
|
2007-08-31 16:11:35 +02:00
|
|
|
int64_t audPos = audio->GetSampleAtMS(VFR_Output.GetTimeAtFrame(nextFrame));
|
|
|
|
int64_t curPos = audio->player->GetCurrentPosition();
|
2007-01-21 07:30:19 +01:00
|
|
|
int delta = int(audPos-curPos);
|
|
|
|
if (delta < 0) delta = -delta;
|
|
|
|
int maxDelta = audio->provider->GetSampleRate();
|
|
|
|
if (delta > maxDelta) audio->player->SetCurrentPosition(audPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Get name of temp work file
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
wxString VideoContext::GetTempWorkFile () {
|
|
|
|
if (tempfile.IsEmpty()) {
|
|
|
|
tempfile = wxFileName::CreateTempFileName(_T("aegisub"));
|
|
|
|
wxRemoveFile(tempfile);
|
|
|
|
tempfile += _T(".ass");
|
|
|
|
}
|
|
|
|
return tempfile;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Get keyframes
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
wxArrayInt VideoContext::GetKeyFrames() {
|
|
|
|
if (OverKeyFramesLoaded()) return overKeyFrames;
|
|
|
|
return KeyFrames;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Set keyframes
|
|
|
|
/// @param frames
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::SetKeyFrames(wxArrayInt frames) {
|
|
|
|
KeyFrames = frames;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Set keyframe override
|
|
|
|
/// @param frames
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::SetOverKeyFrames(wxArrayInt frames) {
|
|
|
|
overKeyFrames = frames;
|
|
|
|
overKeyFramesLoaded = true;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Close keyframes
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoContext::CloseOverKeyFrames() {
|
|
|
|
overKeyFrames.Clear();
|
|
|
|
overKeyFramesLoaded = false;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Check if override keyframes are loaded
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
bool VideoContext::OverKeyFramesLoaded() {
|
|
|
|
return overKeyFramesLoaded;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Check if keyframes are loaded
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
bool VideoContext::KeyFramesLoaded() {
|
|
|
|
return overKeyFramesLoaded || keyFramesLoaded;
|
|
|
|
}
|
2007-01-23 07:32:16 +01:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Calculate aspect ratio
|
|
|
|
/// @param type
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-23 07:32:16 +01:00
|
|
|
double VideoContext::GetARFromType(int type) {
|
|
|
|
if (type == 0) return (double)VideoContext::Get()->GetWidth()/(double)VideoContext::Get()->GetHeight();
|
|
|
|
if (type == 1) return 4.0/3.0;
|
|
|
|
if (type == 2) return 16.0/9.0;
|
|
|
|
if (type == 3) return 2.35;
|
|
|
|
return 1.0; //error
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Sets aspect ratio
|
|
|
|
/// @param _type
|
|
|
|
/// @param value
|
|
|
|
///
|
2007-01-23 07:32:16 +01:00
|
|
|
void VideoContext::SetAspectRatio(int _type, double value) {
|
|
|
|
// Get value
|
|
|
|
if (_type != 4) value = GetARFromType(_type);
|
|
|
|
if (value < 0.5) value = 0.5;
|
|
|
|
if (value > 5.0) value = 5.0;
|
|
|
|
|
|
|
|
// Set
|
|
|
|
arType = _type;
|
|
|
|
arValue = value;
|
|
|
|
UpdateDisplays(true);
|
|
|
|
}
|