OpenJPEG experiment, PCH circumcision

This commit is contained in:
siana
2011-03-20 04:44:58 +01:00
parent e70a91311f
commit baac16b5d2
13 changed files with 85 additions and 63 deletions

View File

@@ -196,6 +196,13 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C),
}
mImpl = j2cimpl_create_func();
// Clear data size table
for( S32 i = 0; i <= MAX_DISCARD_LEVEL; i++)
{ // Array size is MAX_DISCARD_LEVEL+1
mDataSizes[i] = 0;
}
}
// virtual
@@ -371,9 +378,44 @@ S32 LLImageJ2C::calcHeaderSize()
return calcHeaderSizeJ2C();
}
// calcDataSize() returns how many bytes to read
// to load discard_level (including header and higher discard levels)
S32 LLImageJ2C::calcDataSize(S32 discard_level)
{
return calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), discard_level, mRate);
discard_level = llclamp(discard_level, 0, MAX_DISCARD_LEVEL);
if ( mAreaUsedForDataSizeCalcs != (getHeight() * getWidth())
|| mDataSizes[0] == 0)
{
mAreaUsedForDataSizeCalcs = getHeight() * getWidth();
S32 level = MAX_DISCARD_LEVEL; // Start at the highest discard
while ( level >= 0 )
{
mDataSizes[level] = calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), level, mRate);
level--;
}
/* This is technically a more correct way to calculate the size required
for each discard level, since they should include the size needed for
lower levels. Unfortunately, this doesn't work well and will lead to
download stalls. The true correct way is to parse the header. This will
all go away with http textures at some point.
// Calculate the size for each discard level. Lower levels (higher quality)
// contain the cumulative size of higher levels
S32 total_size = calcHeaderSizeJ2C();
S32 level = MAX_DISCARD_LEVEL; // Start at the highest discard
while ( level >= 0 )
{ // Add in this discard level and all before it
total_size += calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), level, mRate);
mDataSizes[level] = total_size;
level--;
}
*/
}
return mDataSizes[discard_level];
}
S32 LLImageJ2C::calcDiscardLevelBytes(S32 bytes)

View File

@@ -87,6 +87,8 @@ protected:
void updateRawDiscardLevel();
S32 mMaxBytes; // Maximum number of bytes of data to use...
S32 mDataSizes[MAX_DISCARD_LEVEL+1]; // Size of data required to reach a given level
U32 mAreaUsedForDataSizeCalcs; // Height * width used to calculate mDataSizes
S8 mRawDiscardLevel;
F32 mRate;
BOOL mReversible;