forked from mia/Aegisub
Prevented parsed data from staying in memory, greatly reducing RAM usage
Originally committed to SVN as r91.
This commit is contained in:
parent
a82f60fe72
commit
e41b6f9988
14 changed files with 53 additions and 24 deletions
|
@ -96,12 +96,7 @@ AssDialogue::~AssDialogue () {
|
|||
/////////
|
||||
// Clear
|
||||
void AssDialogue::Clear () {
|
||||
using std::vector;
|
||||
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
||||
delete *cur;
|
||||
}
|
||||
Blocks.clear();
|
||||
|
||||
ClearBlocks();
|
||||
if( Tracker )
|
||||
{
|
||||
delete Tracker;
|
||||
|
@ -115,6 +110,17 @@ void AssDialogue::Clear () {
|
|||
}
|
||||
|
||||
|
||||
////////////////
|
||||
// Clear blocks
|
||||
void AssDialogue::ClearBlocks() {
|
||||
using std::vector;
|
||||
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
||||
delete *cur;
|
||||
}
|
||||
Blocks.clear();
|
||||
}
|
||||
|
||||
|
||||
//////////////////
|
||||
// Parse ASS Data
|
||||
bool AssDialogue::Parse(bool IsSSA) {
|
||||
|
@ -392,8 +398,7 @@ void AssDialogue::ParseSRTTags () {
|
|||
Text.Replace(_T("}{"),_T(""));
|
||||
|
||||
// Update all stuff
|
||||
ParseASSTags();
|
||||
if (total > 0) UpdateText();
|
||||
//if (total > 0) UpdateText();
|
||||
UpdateData();
|
||||
}
|
||||
|
||||
|
@ -402,10 +407,7 @@ void AssDialogue::ParseSRTTags () {
|
|||
// Parse ASS tags
|
||||
void AssDialogue::ParseASSTags () {
|
||||
// Clear blocks
|
||||
for (size_t i=0;i<Blocks.size();i++) {
|
||||
delete Blocks.at(i);
|
||||
}
|
||||
Blocks.clear();
|
||||
ClearBlocks();
|
||||
|
||||
// Is drawing?
|
||||
int drawingLevel = 0;
|
||||
|
@ -490,6 +492,7 @@ void AssDialogue::ParseASSTags () {
|
|||
void AssDialogue::StripTags () {
|
||||
using std::list;
|
||||
using std::vector;
|
||||
ParseASSTags();
|
||||
vector<AssDialogueBlock*>::iterator next;
|
||||
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur=next) {
|
||||
next = cur;
|
||||
|
@ -501,6 +504,7 @@ void AssDialogue::StripTags () {
|
|||
}
|
||||
UpdateText();
|
||||
UpdateData();
|
||||
ClearBlocks();
|
||||
}
|
||||
|
||||
|
||||
|
@ -521,6 +525,7 @@ void AssDialogue::ConvertTagsToSRT () {
|
|||
bool temp;
|
||||
|
||||
// Iterate through blocks
|
||||
ParseASSTags();
|
||||
for (size_t i=0;i<Blocks.size();i++) {
|
||||
curBlock = AssDialogueBlock::GetAsOverride(Blocks.at(i));
|
||||
if (curBlock) {
|
||||
|
@ -594,6 +599,7 @@ void AssDialogue::ConvertTagsToSRT () {
|
|||
|
||||
Text = final;
|
||||
UpdateData();
|
||||
ClearBlocks();
|
||||
}
|
||||
|
||||
|
||||
|
@ -665,12 +671,14 @@ wxString AssDialogue::GetMarginString(int which) {
|
|||
void AssDialogue::ProcessParameters(void (*callback)(wxString tagName,int par_n,AssOverrideParameter *param,void *userData),void *userData) {
|
||||
// Apply for all override blocks
|
||||
AssDialogueBlockOverride *curBlock;
|
||||
//ParseASSTags();
|
||||
for (std::vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
||||
if ((*cur)->type == BLOCK_OVERRIDE) {
|
||||
curBlock = static_cast<AssDialogueBlockOverride*> (*cur);
|
||||
curBlock->ProcessParameters(callback,userData);
|
||||
}
|
||||
}
|
||||
//ClearBlocks();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ public:
|
|||
void ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter*,void *userData),void *userData=NULL); // Callback to process parameters
|
||||
wxString GetSSAText();
|
||||
bool CollidesWith(AssDialogue *target); // Checks if two lines collide
|
||||
void ClearBlocks();
|
||||
|
||||
AssDialogue();
|
||||
AssDialogue(wxString data,bool IsSSA=false);
|
||||
|
|
|
@ -343,7 +343,7 @@ void AssFile::LoadTXT (wxString _filename,wxString encoding) {
|
|||
line->Start.SetMS(0);
|
||||
line->End.SetMS(0);
|
||||
line->UpdateData();
|
||||
line->ParseASSTags();
|
||||
//line->ParseASSTags();
|
||||
|
||||
// Adds line
|
||||
Line.push_back(line);
|
||||
|
@ -561,7 +561,7 @@ int AssFile::AddLine (wxString data,wxString group,int lasttime,bool &IsSSA) {
|
|||
if ((data.Left(9) == _T("Dialogue:") || data.Left(8) == _T("Comment:"))) {
|
||||
AssDialogue *diag = new AssDialogue(data,IsSSA);
|
||||
lasttime = diag->Start.GetMS();
|
||||
diag->ParseASSTags();
|
||||
//diag->ParseASSTags();
|
||||
entry = diag;
|
||||
entry->StartMS = lasttime;
|
||||
entry->group = group;
|
||||
|
|
|
@ -142,7 +142,7 @@ void AudioKaraoke::Commit() {
|
|||
finalText += wxString::Format(_T("{%s%i}"), syl->tag, syl->length) + syl->contents;
|
||||
}
|
||||
diag->Text = finalText;
|
||||
diag->ParseASSTags();
|
||||
//diag->ParseASSTags();
|
||||
} else {
|
||||
wxLogDebug(_T("Updating karaoke without rebuild"));
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
|
@ -185,7 +185,7 @@ void AudioKaraoke::AutoSplit() {
|
|||
must_rebuild = true;
|
||||
AssDialogue newDiag(diag->data);
|
||||
newDiag.Text = newText;
|
||||
newDiag.ParseASSTags();
|
||||
//newDiag.ParseASSTags();
|
||||
ParseDialogue(&newDiag);
|
||||
}
|
||||
|
||||
|
@ -205,6 +205,7 @@ bool AudioKaraoke::ParseDialogue(AssDialogue *curDiag) {
|
|||
int pos = 0;
|
||||
temp.length = 0;
|
||||
temp.position = 0;
|
||||
curDiag->ParseASSTags();
|
||||
size_t n = curDiag->Blocks.size();
|
||||
bool foundOne = false;
|
||||
bool foundBlock = false;
|
||||
|
@ -245,6 +246,7 @@ bool AudioKaraoke::ParseDialogue(AssDialogue *curDiag) {
|
|||
// Last syllable
|
||||
if (foundBlock) syllables.push_back(temp);
|
||||
return foundBlock;
|
||||
curDiag->ClearBlocks();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1314,6 +1314,7 @@ void AutomationScript::process_lines(AssFile *input)
|
|||
wxString ktext = _T("");
|
||||
wxString ktext_stripped = _T("");
|
||||
|
||||
dia->ParseASSTags();
|
||||
for (std::vector<AssDialogueBlock*>::iterator block = dia->Blocks.begin(); block != dia->Blocks.end(); block++) {
|
||||
|
||||
switch ((*block)->type) {
|
||||
|
@ -1374,6 +1375,7 @@ void AutomationScript::process_lines(AssFile *input)
|
|||
}
|
||||
|
||||
}
|
||||
dia->ClearBlocks();
|
||||
|
||||
// add the final karaoke block to the table
|
||||
// (even if there's no karaoke in the line, there's always at least one karaoke block)
|
||||
|
@ -1552,7 +1554,7 @@ void AutomationScript::process_lines(AssFile *input)
|
|||
e->Comment = kind == _T("comment");
|
||||
lua_settop(L, -11);
|
||||
e->StartMS = e->Start.GetMS();
|
||||
e->ParseASSTags();
|
||||
//e->ParseASSTags();
|
||||
e->UpdateData();
|
||||
input->Line.push_back(e);
|
||||
wxLogDebug(_T("Produced new dialogue event in output subs"));
|
||||
|
|
|
@ -384,6 +384,7 @@ void BaseGrid::DrawImage(wxDC &dc) {
|
|||
}
|
||||
}
|
||||
}
|
||||
curDiag->ClearBlocks();
|
||||
}
|
||||
|
||||
// Show overrides
|
||||
|
|
|
@ -38,6 +38,7 @@ Please visit http://aegisub.net to download latest version
|
|||
- Selected comments are now highlighted in a different color (AMZ)
|
||||
- Added a volume slider bar to audio mode (AMZ)
|
||||
- Fixed behavior of deleting and joining lines on subtitles grid (AMZ)
|
||||
- Fixed some internal workings, which should make Aegisub use considerably less RAM (especially for large Karaoke files, 3x less RAM usage measured) (AMZ)
|
||||
|
||||
|
||||
= 1.09 beta - 2006.01.16 ===========================
|
||||
|
|
|
@ -194,6 +194,7 @@ void DialogResample::OnResample (wxCommandEvent &event) {
|
|||
// Update
|
||||
curDiag->UpdateText();
|
||||
curDiag->UpdateData();
|
||||
curDiag->ClearBlocks();
|
||||
continue;
|
||||
}
|
||||
catch (wchar_t *err) {
|
||||
|
|
|
@ -363,7 +363,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
|
|||
|
||||
// Update
|
||||
AssDialogue *cur = grid->GetDialogue(curLine);
|
||||
cur->ParseASSTags();
|
||||
//cur->ParseASSTags();
|
||||
cur->UpdateData();
|
||||
|
||||
// Commit
|
||||
|
@ -454,7 +454,7 @@ void SearchReplaceEngine::ReplaceAll() {
|
|||
if (replaced) {
|
||||
AssDialogue *cur = grid->GetDialogue(i);
|
||||
cur->UpdateData();
|
||||
cur->ParseASSTags();
|
||||
//cur->ParseASSTags();
|
||||
grid->SetRowToLine(i,cur);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -548,6 +548,7 @@ void DialogSpellCheck::ComputeAction(int action) {
|
|||
|
||||
bool DialogSpellCheck::LineComputation() {
|
||||
AssDialogueBlockPlain *curPlain;
|
||||
current_line->ParseASSTags();
|
||||
size_t size_blocks = current_line->Blocks.size();
|
||||
for (size_t i=(curBlockNumber+1);i<size_blocks;i++) {
|
||||
curPlain = AssDialogueBlock::GetAsPlain(current_line->Blocks.at(i));
|
||||
|
@ -559,10 +560,12 @@ bool DialogSpellCheck::LineComputation() {
|
|||
}
|
||||
curPlain = 0;
|
||||
curBlockNumber = -1;
|
||||
current_line->ClearBlocks();
|
||||
return false;
|
||||
}
|
||||
|
||||
void DialogSpellCheck::BlockStore() {
|
||||
current_line->ParseASSTags();
|
||||
AssDialogueBlockPlain *curPlain = AssDialogueBlock::GetAsPlain(current_line->Blocks.at(curBlockNumber));
|
||||
if (curPlain) {
|
||||
curPlain->text = current_block;
|
||||
|
@ -572,6 +575,7 @@ void DialogSpellCheck::BlockStore() {
|
|||
subs->FlagAsModified();
|
||||
}
|
||||
curPlain = 0;
|
||||
current_line->ClearBlocks();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -145,6 +145,7 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
|||
|
||||
// Count blocks
|
||||
int nblocks = 0;
|
||||
current->ParseASSTags();
|
||||
size_t size_blocks = current->Blocks.size();
|
||||
for (size_t i=0;i<size_blocks;i++) {
|
||||
if (current->Blocks.at(i)->type == BLOCK_PLAIN) nblocks++;
|
||||
|
@ -207,6 +208,7 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
|||
}
|
||||
OrigText->SetDefaultStyle(Normal);
|
||||
TransText->SetDefaultStyle(Normal);
|
||||
current->ClearBlocks();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -298,6 +300,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
|||
if (Hotkeys.IsPressed(_T("Translation Assistant Accept")) || Hotkeys.IsPressed(_T("Translation Assistant Preview"))) {
|
||||
// Store
|
||||
AssDialogue *cur = grid->GetDialogue(curline);
|
||||
cur->ParseASSTags();
|
||||
int nblock = -1;
|
||||
for (unsigned int i=0;i<cur->Blocks.size();i++) {
|
||||
if (cur->Blocks.at(i)->type == BLOCK_PLAIN) nblock++;
|
||||
|
@ -310,6 +313,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
|||
// Update line
|
||||
cur->UpdateText();
|
||||
cur->UpdateData();
|
||||
cur->ClearBlocks();
|
||||
grid->SetRowToLine(curline,cur);
|
||||
subs->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
|
@ -331,6 +335,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
|||
using std::vector;
|
||||
AssDialogueBlock *curBlock;
|
||||
int pos = -1;
|
||||
current->ParseASSTags();
|
||||
for (vector<AssDialogueBlock*>::iterator cur=current->Blocks.begin();cur!=current->Blocks.end();cur++) {
|
||||
curBlock = *cur;
|
||||
if (curBlock->type == BLOCK_PLAIN) {
|
||||
|
@ -340,6 +345,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
current->ClearBlocks();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -256,11 +256,13 @@ void AssTransformFramerateFilter::TransformFrameRate(AssFile *subs) {
|
|||
data.ko = 0;
|
||||
|
||||
// Process stuff
|
||||
curDialogue->ParseASSTags();
|
||||
curDialogue->ProcessParameters(TransformTimeTags,&data);
|
||||
curDialogue->Start.SetMS(Input->CorrectTimeAtFrame(Output->CorrectFrameAtTime(curDialogue->Start.GetMS(),true),true));
|
||||
curDialogue->End.SetMS(Input->CorrectTimeAtFrame(Output->CorrectFrameAtTime(curDialogue->End.GetMS(),false),false));
|
||||
curDialogue->UpdateText();
|
||||
curDialogue->UpdateData();
|
||||
curDialogue->ClearBlocks();
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -874,7 +874,7 @@ void SubsEditBox::CommitText() {
|
|||
// Update line
|
||||
if (cur) {
|
||||
cur->Text = TextEdit->GetValue();
|
||||
cur->ParseASSTags();
|
||||
//cur->ParseASSTags();
|
||||
cur->UpdateData();
|
||||
grid->SetRowToLine(linen,cur);
|
||||
audio->SetDialogue(grid,cur,linen);
|
||||
|
@ -1353,6 +1353,7 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
|
|||
|
||||
// Commit changes and shift selection
|
||||
SetText(line->Text);
|
||||
line->ClearBlocks();
|
||||
TextEdit->SetSelection(selstart+shift,selend+shift);
|
||||
TextEdit->SetFocus();
|
||||
}
|
||||
|
|
|
@ -739,7 +739,7 @@ void SubtitlesGrid::On122Recombine(wxCommandEvent &event) {
|
|||
while (n1->Text.Right(2) == _T("\\N") || n1->Text.Right(2) == _T("\\n"))
|
||||
n1->Text = n1->Text.Mid(0,n1->Text.Length()-2);
|
||||
n2->Start = n1->Start;
|
||||
n1->ParseASSTags();
|
||||
//n1->ParseASSTags();
|
||||
n1->UpdateData();
|
||||
n2->UpdateData();
|
||||
|
||||
|
@ -778,7 +778,7 @@ void SubtitlesGrid::On112Recombine(wxCommandEvent &event) {
|
|||
while (n2->Text.Right(2) == _T("\\N") || n2->Text.Right(2) == _T("\\n"))
|
||||
n2->Text = n2->Text.Mid(0,n2->Text.Length()-2);
|
||||
n1->End = n2->End;
|
||||
n2->ParseASSTags();
|
||||
//n2->ParseASSTags();
|
||||
n1->UpdateData();
|
||||
n2->UpdateData();
|
||||
|
||||
|
@ -1307,8 +1307,8 @@ void SubtitlesGrid::SplitLine(int n,int pos,int mode) {
|
|||
wxString orig = n1->Text;
|
||||
n1->Text = orig.Left(pos);
|
||||
n2->Text = orig.Mid(pos);
|
||||
n1->ParseASSTags();
|
||||
n2->ParseASSTags();
|
||||
//n1->ParseASSTags();
|
||||
//n2->ParseASSTags();
|
||||
|
||||
// Modify time
|
||||
if (mode == 1) {
|
||||
|
|
Loading…
Reference in a new issue