Apply the export transform when sending subtitles to the provider on the video worker thread rather than the GUI thread

Originally committed to SVN as r4849.
This commit is contained in:
Thomas Goyne 2010-11-18 06:15:41 +00:00
parent c571f64f86
commit 3d85cacae0
3 changed files with 10 additions and 8 deletions

View file

@ -131,9 +131,9 @@ wxArrayString AssExporter::GetAllFilterNames() {
/// @param export_dialog
/// @return
///
AssFile *AssExporter::ExportTransform(wxWindow *export_dialog) {
AssFile *AssExporter::ExportTransform(wxWindow *export_dialog,bool copy) {
// Copy
AssFile *Subs = new AssFile(*OriginalSubs);
AssFile *Subs = copy ? new AssFile(*OriginalSubs) : OriginalSubs;
// Run filters
for (FilterList::iterator cur=Filters.begin();cur!=Filters.end();cur++) {
@ -151,7 +151,7 @@ AssFile *AssExporter::ExportTransform(wxWindow *export_dialog) {
/// @param export_dialog
///
void AssExporter::Export(wxString filename, wxString charset, wxWindow *export_dialog) {
std::auto_ptr<AssFile> Subs(ExportTransform(export_dialog));
std::auto_ptr<AssFile> Subs(ExportTransform(export_dialog,true));
Subs->Save(filename,false,false,charset);
}

View file

@ -93,7 +93,7 @@ public:
void AddAutoFilters();
void DrawSettings(wxWindow *parent,wxSizer *AddTo);
void Export(wxString file, wxString charset, wxWindow *export_dialog=NULL);
AssFile *ExportTransform(wxWindow *export_dialog=NULL);
AssFile *ExportTransform(wxWindow *export_dialog=NULL,bool copy=false);
wxSizer *GetSettingsSizer(wxString name);
/// @brief DOCME

View file

@ -86,6 +86,10 @@ std::tr1::shared_ptr<AegiVideoFrame> ThreadedFrameSource::ProcFrame(int frameNum
// other lines will probably not be viewed before the file changes
// again), and if it's a different frame, export the entire file.
if (singleFrame == -1) {
AssExporter exporter(subs.get());
exporter.AddAutoFilters();
exporter.ExportTransform();
singleFrame = frameNum;
// Copying a nontrivially sized AssFile is fairly slow, so
// instead muck around with its innards to just temporarily
@ -173,14 +177,12 @@ ThreadedFrameSource::~ThreadedFrameSource() {
}
void ThreadedFrameSource::LoadSubtitles(AssFile *subs) throw() {
AssExporter exporter(subs);
exporter.AddAutoFilters();
AssFile *exported = exporter.ExportTransform();
subs = new AssFile(*subs);
wxMutexLocker locker(jobMutex);
// Set nextSubs and let the worker thread move it to subs so that we don't
// have to lock fileMutex on the GUI thread, as that can be locked for
// extended periods of time with slow-rendering subtitles
nextSubs.reset(exported);
nextSubs.reset(subs);
}
void ThreadedFrameSource::RequestFrame(int frame, double time) throw() {