aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llimage/llimagej2c.cpp
diff options
context:
space:
mode:
authorMcCabe Maxsted2010-05-07 18:16:10 -0700
committerJacek Antonelli2010-06-19 02:05:24 -0500
commit36b6111ea0b2896134e31c02a87db8687b54ec74 (patch)
tree78241409bd8fd1c91d6be531b17d3baefb80aff5 /linden/indra/llimage/llimagej2c.cpp
parentAdded some missing entries to the logcontrol.xml debug entries, comment out e... (diff)
downloadmeta-impy-36b6111ea0b2896134e31c02a87db8687b54ec74.zip
meta-impy-36b6111ea0b2896134e31c02a87db8687b54ec74.tar.gz
meta-impy-36b6111ea0b2896134e31c02a87db8687b54ec74.tar.bz2
meta-impy-36b6111ea0b2896134e31c02a87db8687b54ec74.tar.xz
Backported llimage changes from Viewer 2.0.0
Diffstat (limited to '')
-rw-r--r--linden/indra/llimage/llimagej2c.cpp50
1 files changed, 46 insertions, 4 deletions
diff --git a/linden/indra/llimage/llimagej2c.cpp b/linden/indra/llimage/llimagej2c.cpp
index 1aae83e..5480c88 100644
--- a/linden/indra/llimage/llimagej2c.cpp
+++ b/linden/indra/llimage/llimagej2c.cpp
@@ -3,7 +3,7 @@
3 * 3 *
4 * $LicenseInfo:firstyear=2001&license=viewergpl$ 4 * $LicenseInfo:firstyear=2001&license=viewergpl$
5 * 5 *
6 * Copyright (c) 2001-2009, Linden Research, Inc. 6 * Copyright (c) 2001-2010, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code 8 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -178,8 +178,8 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C),
178 mMaxBytes(0), 178 mMaxBytes(0),
179 mRawDiscardLevel(-1), 179 mRawDiscardLevel(-1),
180 mRate(0.0f), 180 mRate(0.0f),
181 mReversible(FALSE) 181 mReversible(FALSE),
182 182 mAreaUsedForDataSizeCalcs(0)
183{ 183{
184 //We assume here that if we wanted to create via 184 //We assume here that if we wanted to create via
185 //a dynamic library that the approriate open calls were made 185 //a dynamic library that the approriate open calls were made
@@ -195,6 +195,12 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C),
195 } 195 }
196 196
197 mImpl = j2cimpl_create_func(); 197 mImpl = j2cimpl_create_func();
198
199 // Clear data size table
200 for( S32 i = 0; i <= MAX_DISCARD_LEVEL; i++)
201 { // Array size is MAX_DISCARD_LEVEL+1
202 mDataSizes[i] = 0;
203 }
198} 204}
199 205
200// virtual 206// virtual
@@ -368,9 +374,45 @@ S32 LLImageJ2C::calcHeaderSize()
368 return calcHeaderSizeJ2C(); 374 return calcHeaderSizeJ2C();
369} 375}
370 376
377
378// calcDataSize() returns how many bytes to read
379// to load discard_level (including header and higher discard levels)
371S32 LLImageJ2C::calcDataSize(S32 discard_level) 380S32 LLImageJ2C::calcDataSize(S32 discard_level)
372{ 381{
373 return calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), discard_level, mRate); 382 discard_level = llclamp(discard_level, 0, MAX_DISCARD_LEVEL);
383
384 if ( mAreaUsedForDataSizeCalcs != (getHeight() * getWidth())
385 || mDataSizes[0] == 0)
386 {
387 mAreaUsedForDataSizeCalcs = getHeight() * getWidth();
388
389 S32 level = MAX_DISCARD_LEVEL; // Start at the highest discard
390 while ( level >= 0 )
391 {
392 mDataSizes[level] = calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), level, mRate);
393 level--;
394 }
395
396 /* This is technically a more correct way to calculate the size required
397 for each discard level, since they should include the size needed for
398 lower levels. Unfortunately, this doesn't work well and will lead to
399 download stalls. The true correct way is to parse the header. This will
400 all go away with http textures at some point.
401
402 // Calculate the size for each discard level. Lower levels (higher quality)
403 // contain the cumulative size of higher levels
404 S32 total_size = calcHeaderSizeJ2C();
405
406 S32 level = MAX_DISCARD_LEVEL; // Start at the highest discard
407 while ( level >= 0 )
408 { // Add in this discard level and all before it
409 total_size += calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), level, mRate);
410 mDataSizes[level] = total_size;
411 level--;
412 }
413 */
414 }
415 return mDataSizes[discard_level];
374} 416}
375 417
376S32 LLImageJ2C::calcDiscardLevelBytes(S32 bytes) 418S32 LLImageJ2C::calcDiscardLevelBytes(S32 bytes)