Apparently overestimating j2c size is always a bad idea

This commit is contained in:
Siana Gearz
2012-03-31 03:45:22 +02:00
parent 7774fe7f04
commit 01d6095242
2 changed files with 6 additions and 40 deletions

View File

@@ -363,8 +363,12 @@ S32 LLImageJ2C::calcHeaderSizeJ2C()
return FIRST_PACKET_SIZE; // Hack. just needs to be >= actual header size...
}
static S32 cald_data_size_help(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate)
//static
S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate)
{
// Note: this only provides an *estimate* of the size in bytes of an image level
// *TODO: find a way to read the true size (when available) and convey the fact
// that the result is an estimate in the other cases
if (rate <= 0.f) rate = .125f;
while (discard_level > 0)
{
@@ -375,22 +379,7 @@ static S32 cald_data_size_help(S32 w, S32 h, S32 comp, S32 discard_level, F32 ra
discard_level--;
}
S32 bytes = (S32)((F32)(w*h*comp)*rate);
return bytes;
}
//static
S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate)
{
static const LLCachedControl<F32> exponent("SianaJ2CSizeExponent", 1.0f);
static const LLCachedControl<S32> offset("SianaJ2CSizeOffset", 0);
S32 size = cald_data_size_help(w, h, comp, discard_level, rate);
S32 size_d0 = cald_data_size_help(w, h, comp, 0, rate);
llassert_always(size_d0);
S32 bytes = size_d0*pow((double)size/size_d0, (double)exponent) + offset;
bytes = llmax (0, bytes - 600);
bytes = ((bytes + (1000 - 1))/1000)*1000 + 600;
bytes = llmax(bytes, calcHeaderSizeJ2C());
return bytes;
}