prevent overflow when compressing large images.
This commit is contained in:
parent
283cdabc64
commit
e1d5bda3e9
@ -42,7 +42,7 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
|||||||
MyOutputHandler(const char * name) : total(0), progress(0), percentage(0), stream(new nv::StdOutputStream(name)) {}
|
MyOutputHandler(const char * name) : total(0), progress(0), percentage(0), stream(new nv::StdOutputStream(name)) {}
|
||||||
virtual ~MyOutputHandler() { delete stream; }
|
virtual ~MyOutputHandler() { delete stream; }
|
||||||
|
|
||||||
virtual void setTotal(int t)
|
virtual void setTotal(int64 t)
|
||||||
{
|
{
|
||||||
total = t + 128;
|
total = t + 128;
|
||||||
}
|
}
|
||||||
@ -63,9 +63,11 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
|||||||
stream->serialize(const_cast<void *>(data), size);
|
stream->serialize(const_cast<void *>(data), size);
|
||||||
|
|
||||||
progress += size;
|
progress += size;
|
||||||
int p = (100 * progress) / total;
|
int p = int((100 * progress) / total);
|
||||||
if (verbose && p != percentage)
|
if (verbose && p != percentage)
|
||||||
{
|
{
|
||||||
|
nvCheck(p >= 0);
|
||||||
|
|
||||||
percentage = p;
|
percentage = p;
|
||||||
printf("\r%d%%", percentage);
|
printf("\r%d%%", percentage);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -74,8 +76,8 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int total;
|
int64 total;
|
||||||
int progress;
|
int64 progress;
|
||||||
int percentage;
|
int percentage;
|
||||||
bool verbose;
|
bool verbose;
|
||||||
nv::StdOutputStream * stream;
|
nv::StdOutputStream * stream;
|
||||||
|
Loading…
Reference in New Issue
Block a user