improve export progress
This commit is contained in:
parent
4899513194
commit
5e4dbe7063
|
@ -113,13 +113,22 @@ class DivCSPlayer {
|
|||
|
||||
struct DivCSProgress {
|
||||
int stage, count, total;
|
||||
int optStage, findTotal;
|
||||
int optCurrent, optTotal;
|
||||
int findCurrent, expandCurrent;
|
||||
int origCurrent, origCount;
|
||||
DivCSProgress():
|
||||
stage(0),
|
||||
count(0),
|
||||
total(0),
|
||||
optStage(0),
|
||||
findTotal(0),
|
||||
optCurrent(0),
|
||||
optTotal(0) {}
|
||||
optTotal(0),
|
||||
findCurrent(0),
|
||||
expandCurrent(0),
|
||||
origCurrent(0),
|
||||
origCount(0) {}
|
||||
};
|
||||
|
||||
struct DivCSOptions {
|
||||
|
|
|
@ -846,10 +846,18 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
|
||||
matches.clear();
|
||||
|
||||
if (progress!=NULL) {
|
||||
progress->findTotal=stream->size();
|
||||
progress->optStage=0;
|
||||
}
|
||||
|
||||
// fast match algorithm
|
||||
// search for small matches, and then find bigger ones
|
||||
logD("finding possible matches");
|
||||
for (size_t i=0; i<stream->size(); i+=8) {
|
||||
if (!(i&2047)) {
|
||||
if (progress!=NULL) progress->findCurrent=i;
|
||||
}
|
||||
bool storedOrig=false;
|
||||
for (size_t j=i+matchSize; j<stream->size(); j+=8) {
|
||||
if (memcmp(&buf[i],&buf[j],matchSize)==0) {
|
||||
|
@ -870,6 +878,9 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
if (progress!=NULL) {
|
||||
if ((int)matches.size()>progress->optTotal) progress->optTotal=matches.size();
|
||||
progress->optCurrent=matches.size();
|
||||
progress->origCount=origs.size();
|
||||
progress->findCurrent=stream->size();
|
||||
progress->optStage=1;
|
||||
}
|
||||
|
||||
// quit if there isn't anything
|
||||
|
@ -877,7 +888,12 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
|
||||
// search for bigger matches
|
||||
for (size_t i=0; i<matches.size(); i++) {
|
||||
if ((i&8191)==0) logV("match %d of %d",i,(int)matches.size());
|
||||
if ((i&8191)==0) {
|
||||
logV("match %d of %d",i,(int)matches.size());
|
||||
}
|
||||
if ((i&1023)==0) {
|
||||
if (progress!=NULL) progress->expandCurrent=i;
|
||||
}
|
||||
BlockMatch& b=matches[i];
|
||||
|
||||
size_t finalLen=b.len;
|
||||
|
@ -900,6 +916,11 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
b.len=finalLen;
|
||||
}
|
||||
|
||||
if (progress!=NULL) {
|
||||
progress->expandCurrent=matches.size();
|
||||
progress->optStage=2;
|
||||
}
|
||||
|
||||
// new code MAN... WHY...
|
||||
// basically the workflow should be:
|
||||
// - test every block position
|
||||
|
@ -910,6 +931,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
// - pick largest benefit from list
|
||||
// - make sub-blocks!!!
|
||||
logD("testing %d match groups for benefit",(int)origs.size());
|
||||
size_t origIndex=0;
|
||||
for (size_t i: origs) {
|
||||
size_t orig=matches[i].orig;
|
||||
size_t minSize=MIN_MATCH_SIZE;
|
||||
|
@ -919,6 +941,10 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
|
||||
testMatches.clear();
|
||||
|
||||
if (progress!=NULL) progress->origCurrent=origIndex;
|
||||
|
||||
origIndex++;
|
||||
|
||||
// collect matches with this orig value
|
||||
for (size_t j=i; j<matches.size(); j++) {
|
||||
if (matches[j].orig!=orig) break;
|
||||
|
@ -1018,6 +1044,11 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
size_t bestOrig=matches[bestBenefit.index].orig;
|
||||
logI("match count %d",(int)workMatches.size());
|
||||
|
||||
if (progress!=NULL) {
|
||||
progress->optStage=3;
|
||||
progress->origCurrent=origs.size();
|
||||
}
|
||||
|
||||
// make sub-block
|
||||
size_t subBlockID=subBlocks.size();
|
||||
logV("new sub-block %d",(int)subBlockID);
|
||||
|
|
|
@ -6065,7 +6065,11 @@ bool FurnaceGUI::loop() {
|
|||
} else {
|
||||
WAKE_UP;
|
||||
ImGui::Text("Exporting...");
|
||||
ImGui::Text("%d/%d",csProgress.optCurrent,csProgress.optTotal);
|
||||
ImGui::Text("opt stage: %d",csProgress.optStage);
|
||||
ImGui::Text("pass: %d/%d",csProgress.optCurrent,csProgress.optTotal);
|
||||
ImGui::Text("find: %d/%d",csProgress.findCurrent,csProgress.findTotal);
|
||||
ImGui::Text("expand: %d/%d",csProgress.expandCurrent,csProgress.optCurrent);
|
||||
ImGui::Text("benefit: %d/%d",csProgress.origCurrent,csProgress.origCount);
|
||||
|
||||
// check whether we're done
|
||||
if (csExportDone) {
|
||||
|
|
Loading…
Reference in a new issue