mirror of https://github.com/odrling/Aegisub
Added progress bar to matroska parsing
Originally committed to SVN as r122.
This commit is contained in:
parent
57b6834d13
commit
5cc37edf38
|
@ -38,6 +38,7 @@
|
||||||
// Headers
|
// Headers
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "mkv_wrap.h"
|
#include "mkv_wrap.h"
|
||||||
|
#include "dialog_progress.h"
|
||||||
|
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
|
@ -144,15 +145,36 @@ void MatroskaWrapper::Parse() {
|
||||||
// Mask other tracks away
|
// Mask other tracks away
|
||||||
mkv_SetTrackMask(file, ~(1 << track));
|
mkv_SetTrackMask(file, ~(1 << track));
|
||||||
|
|
||||||
|
// Progress bar
|
||||||
|
int totalTime = double(segInfo->Duration) / timecodeScale;
|
||||||
|
volatile bool canceled = false;
|
||||||
|
DialogProgress *progress = new DialogProgress(NULL,_("Parsing Matroska"),&canceled,_("Reading keyframe and timecode data from Matroska file."),0,totalTime);
|
||||||
|
progress->Show();
|
||||||
|
progress->SetProgress(0,1);
|
||||||
|
|
||||||
// Read frames
|
// Read frames
|
||||||
int frameN = 0;
|
int frameN = 0;
|
||||||
while (mkv_ReadFrame(file,0,&rt,&startTime,&endTime,&filePos,&frameSize,&frameFlags) == 0) {
|
while (mkv_ReadFrame(file,0,&rt,&startTime,&endTime,&filePos,&frameSize,&frameFlags) == 0) {
|
||||||
|
// Read value
|
||||||
|
double curTime = double(startTime) / timecodeScale;
|
||||||
if (!(frameFlags & FRAME_GAP)) {
|
if (!(frameFlags & FRAME_GAP)) {
|
||||||
frames.push_back(MkvFrame((frameFlags & FRAME_KF) != 0,double(startTime) / timecodeScale));
|
frames.push_back(MkvFrame((frameFlags & FRAME_KF) != 0,curTime));
|
||||||
frameN++;
|
frameN++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cancelled?
|
||||||
|
if (canceled) {
|
||||||
|
Close();
|
||||||
|
throw _T("Canceled");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update progress
|
||||||
|
progress->SetProgress(curTime,totalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clean up progress
|
||||||
|
if (!canceled) progress->Destroy();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue