summaryrefslogtreecommitdiff
path: root/indra/llimage/llimagej2c.cpp
diff options
context:
space:
mode:
authorAnsariel Hiller <Ansariel@users.noreply.github.com>2024-07-18 09:48:24 +0200
committerGitHub <noreply@github.com>2024-07-18 10:48:24 +0300
commit6535ce51fd1e3f2b0efdc650310ec75a7638f6f9 (patch)
treee8142b794b297c407f760824951e6db997b9c510 /indra/llimage/llimagej2c.cpp
parentef9a494134458f3464b250c87da9e247d775989c (diff)
Remove unnecessary code and (re-)add some more compile time constants (#2057)
Diffstat (limited to 'indra/llimage/llimagej2c.cpp')
-rw-r--r--indra/llimage/llimagej2c.cpp22
1 files changed, 3 insertions, 19 deletions
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 5dfd8cd947..29449a5d2e 100644
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -275,10 +275,10 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r
// For details about the equation used here, see https://wiki.lindenlab.com/wiki/THX1138_KDU_Improvements#Byte_Range_Study
// Estimate the number of layers. This is consistent with what's done for j2c encoding in LLImageJ2CKDU::encodeImpl().
+ constexpr S32 precision = 8; // assumed bitrate per component channel, might change in future for HDR support
S32 nb_layers = 1;
- S32 surface = w*h;
+ const S32 surface = w*h;
S32 s = 64*64;
- S32 precision = 8; // assumed bitrate per component channel, might change in future for HDR support
S32 totalbytes = (S32)(s * comp * precision * rate); // first level computed before loop
while (surface > s)
{
@@ -287,27 +287,11 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r
nb_layers++;
s *= 4;
}
- F32 layer_factor = 3.0f * (7 - llclamp(nb_layers,1,6));
totalbytes /= 8; // to bytes
totalbytes += calcHeaderSizeJ2C(); // header
- // Compute w/pow(2,discard_level) and h/pow(2,discard_level)
- w >>= discard_level;
- h >>= discard_level;
- w = llmax(w, 1);
- h = llmax(h, 1);
-
- // Temporary: compute both new and old range and pick one according to the settings TextureNewByteRange
- // *TODO: Take the old code out once we have enough tests done
- S32 bytes;
- S32 new_bytes = (S32) (sqrt((F32)(w*h))*(F32)(comp)*rate*1000.f/layer_factor);
- S32 old_bytes = (S32)((F32)(w*h*comp)*rate);
- bytes = (LLImage::useNewByteRange() && (new_bytes < old_bytes) ? new_bytes : old_bytes);
- bytes = llmax(totalbytes, calcHeaderSizeJ2C());
- //LL_WARNS() << "calcDataSizeJ2C w-h-c-d-p " << w << "-" << h << "-" << comp << "-" << discard_level << "-" << precision
- // << " Pyramid: " << (S32)totalbytes << " LayerFactored: " << new_bytes << " WJCR: " << old_bytes << LL_ENDL;
- return bytes;
+ return totalbytes;
}
S32 LLImageJ2C::calcHeaderSize()