From 9fdca96f8bd2211a99fe88e57b70cbecefa20b6d Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 8 Jul 2024 20:27:14 +0200 Subject: Re-enable compiler warnings C4244 and C4396 except for lltracerecording.h and llunittype.h for now --- indra/llimage/llimagefilter.cpp | 114 ++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 57 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagefilter.cpp b/indra/llimage/llimagefilter.cpp index 0d15906afd..bfcb1f76de 100644 --- a/indra/llimage/llimagefilter.cpp +++ b/indra/llimage/llimagefilter.cpp @@ -253,7 +253,7 @@ void LLImageFilter::executeFilter(LLPointer raw_image) bool abs_value = (mFilterData[i][index++].asReal() > 0.0); for (S32 k = 0; k < NUM_VALUES_IN_MAT3; k++) for (S32 j = 0; j < NUM_VALUES_IN_MAT3; j++) - kernel.mMatrix[k][j] = mFilterData[i][index++].asReal(); + kernel.mMatrix[k][j] = (F32)mFilterData[i][index++].asReal(); convolve(kernel,normalize,abs_value); } else if (filter_name == "colortransform") @@ -262,7 +262,7 @@ void LLImageFilter::executeFilter(LLPointer raw_image) S32 index = 1; for (S32 k = 0; k < NUM_VALUES_IN_MAT3; k++) for (S32 j = 0; j < NUM_VALUES_IN_MAT3; j++) - transform.mMatrix[k][j] = mFilterData[i][index++].asReal(); + transform.mMatrix[k][j] = (F32)mFilterData[i][index++].asReal(); transform.transpose(); colorTransform(transform); } @@ -279,32 +279,32 @@ void LLImageFilter::executeFilter(LLPointer raw_image) void LLImageFilter::blendStencil(F32 alpha, U8* pixel, U8 red, U8 green, U8 blue) { - F32 inv_alpha = 1.0 - alpha; + F32 inv_alpha = 1.0f - alpha; switch (mStencilBlendMode) { case STENCIL_BLEND_MODE_BLEND: // Classic blend of incoming color with the background image - pixel[VRED] = inv_alpha * pixel[VRED] + alpha * red; - pixel[VGREEN] = inv_alpha * pixel[VGREEN] + alpha * green; - pixel[VBLUE] = inv_alpha * pixel[VBLUE] + alpha * blue; + pixel[VRED] = (U8)(inv_alpha * pixel[VRED] + alpha * red); + pixel[VGREEN] = (U8)(inv_alpha * pixel[VGREEN] + alpha * green); + pixel[VBLUE] = (U8)(inv_alpha * pixel[VBLUE] + alpha * blue); break; case STENCIL_BLEND_MODE_ADD: // Add incoming color to the background image - pixel[VRED] = llclampb(pixel[VRED] + alpha * red); - pixel[VGREEN] = llclampb(pixel[VGREEN] + alpha * green); - pixel[VBLUE] = llclampb(pixel[VBLUE] + alpha * blue); + pixel[VRED] = (U8)llclampb(pixel[VRED] + alpha * red); + pixel[VGREEN] = (U8)llclampb(pixel[VGREEN] + alpha * green); + pixel[VBLUE] = (U8)llclampb(pixel[VBLUE] + alpha * blue); break; case STENCIL_BLEND_MODE_ABACK: // Add back background image to the incoming color - pixel[VRED] = llclampb(inv_alpha * pixel[VRED] + red); - pixel[VGREEN] = llclampb(inv_alpha * pixel[VGREEN] + green); - pixel[VBLUE] = llclampb(inv_alpha * pixel[VBLUE] + blue); + pixel[VRED] = (U8)llclampb(inv_alpha * pixel[VRED] + red); + pixel[VGREEN] = (U8)llclampb(inv_alpha * pixel[VGREEN] + green); + pixel[VBLUE] = (U8)llclampb(inv_alpha * pixel[VBLUE] + blue); break; case STENCIL_BLEND_MODE_FADE: // Fade incoming color to black - pixel[VRED] = alpha * red; - pixel[VGREEN] = alpha * green; - pixel[VBLUE] = alpha * blue; + pixel[VRED] = (U8)(alpha * red); + pixel[VGREEN] = (U8)(alpha * green); + pixel[VBLUE] = (U8)(alpha * blue); break; } } @@ -348,7 +348,7 @@ void LLImageFilter::colorTransform(const LLMatrix3 &transform) dst.clamp(0.0f,255.0f); // Blend result - blendStencil(getStencilAlpha(i,j), dst_data, dst.mV[VRED], dst.mV[VGREEN], dst.mV[VBLUE]); + blendStencil(getStencilAlpha(i,j), dst_data, (U8)dst.mV[VRED], (U8)dst.mV[VGREEN], (U8)dst.mV[VBLUE]); dst_data += components; } } @@ -463,7 +463,7 @@ void LLImageFilter::convolve(const LLMatrix3 &kernel, bool normalize, bool abs_v dst.clamp(0.0f,255.0f); // Blend result - blendStencil(getStencilAlpha(i,j), dst_data, dst.mV[VRED], dst.mV[VGREEN], dst.mV[VBLUE]); + blendStencil(getStencilAlpha(i,j), dst_data, (U8)dst.mV[VRED], (U8)dst.mV[VGREEN], (U8)dst.mV[VBLUE]); // Next pixel dst_data += components; @@ -499,7 +499,7 @@ void LLImageFilter::filterScreen(EScreenMode mode, const F32 wave_length, const S32 width = mImage->getWidth(); S32 height = mImage->getHeight(); - F32 wave_length_pixels = wave_length * (F32)(height) / 2.0; + F32 wave_length_pixels = wave_length * (F32)(height) / 2.0f; F32 sin = sinf(angle*DEG_TO_RAD); F32 cos = cosf(angle*DEG_TO_RAD); @@ -507,7 +507,7 @@ void LLImageFilter::filterScreen(EScreenMode mode, const F32 wave_length, const U8 gamma[256]; for (S32 i = 0; i < 256; i++) { - F32 gamma_i = llclampf((float)(powf((float)(i)/255.0,1.0/4.0))); + F32 gamma_i = llclampf((float)(powf((float)(i)/255.0f,1.0f/4.0f))); gamma[i] = (U8)(255.0 * gamma_i); } @@ -525,11 +525,11 @@ void LLImageFilter::filterScreen(EScreenMode mode, const F32 wave_length, const case SCREEN_MODE_2DSINE: di = cos*i + sin*j; dj = -sin*i + cos*j; - value = (sinf(2*F_PI*di/wave_length_pixels)*sinf(2*F_PI*dj/wave_length_pixels)+1.0)*255.0/2.0; + value = (sinf(2*F_PI*di/wave_length_pixels)*sinf(2*F_PI*dj/wave_length_pixels)+1.0f)*255.0f/2.0f; break; case SCREEN_MODE_LINE: dj = sin*i - cos*j; - value = (sinf(2*F_PI*dj/wave_length_pixels)+1.0)*255.0/2.0; + value = (sinf(2*F_PI*dj/wave_length_pixels)+1.0f)*255.0f/2.0f; break; } U8 dst_value = (dst_data[VRED] >= (U8)(value) ? gamma[dst_data[VRED] - (U8)(value)] : 0); @@ -556,16 +556,16 @@ void LLImageFilter::setStencil(EStencilShape shape, EStencilBlendMode mode, F32 mStencilCenterX = (S32)(mImage->getWidth() + params[0] * (F32)(mImage->getHeight()))/2; mStencilCenterY = (S32)(mImage->getHeight() + params[1] * (F32)(mImage->getHeight()))/2; mStencilWidth = (S32)(params[2] * (F32)(mImage->getHeight()))/2; - mStencilGamma = (params[3] <= 0.0 ? 1.0 : params[3]); + mStencilGamma = (params[3] <= 0.0f ? 1.0f : params[3]); - mStencilWavelength = (params[0] <= 0.0 ? 10.0 : params[0] * (F32)(mImage->getHeight()) / 2.0); + mStencilWavelength = (params[0] <= 0.0f ? 10.0f : params[0] * (F32)(mImage->getHeight()) / 2.0f); mStencilSine = sinf(params[1]*DEG_TO_RAD); mStencilCosine = cosf(params[1]*DEG_TO_RAD); - mStencilStartX = ((F32)(mImage->getWidth()) + params[0] * (F32)(mImage->getHeight()))/2.0; - mStencilStartY = ((F32)(mImage->getHeight()) + params[1] * (F32)(mImage->getHeight()))/2.0; - F32 end_x = ((F32)(mImage->getWidth()) + params[2] * (F32)(mImage->getHeight()))/2.0; - F32 end_y = ((F32)(mImage->getHeight()) + params[3] * (F32)(mImage->getHeight()))/2.0; + mStencilStartX = ((F32)(mImage->getWidth()) + params[0] * (F32)(mImage->getHeight()))/2.0f; + mStencilStartY = ((F32)(mImage->getHeight()) + params[1] * (F32)(mImage->getHeight()))/2.0f; + F32 end_x = ((F32)(mImage->getWidth()) + params[2] * (F32)(mImage->getHeight()))/2.0f; + F32 end_y = ((F32)(mImage->getHeight()) + params[3] * (F32)(mImage->getHeight()))/2.0f; mStencilGradX = end_x - mStencilStartX; mStencilGradY = end_y - mStencilStartY; mStencilGradN = mStencilGradX*mStencilGradX + mStencilGradY*mStencilGradY; @@ -578,14 +578,14 @@ F32 LLImageFilter::getStencilAlpha(S32 i, S32 j) { // alpha is a modified gaussian value, with a center and fading in a circular pattern toward the edges // The gamma parameter controls the intensity of the drop down from alpha 1.0 (center) to 0.0 - F32 d_center_square = (i - mStencilCenterX)*(i - mStencilCenterX) + (j - mStencilCenterY)*(j - mStencilCenterY); + F32 d_center_square = (F32)((i - mStencilCenterX)*(i - mStencilCenterX) + (j - mStencilCenterY)*(j - mStencilCenterY)); alpha = powf(F_E, -(powf((d_center_square/(mStencilWidth*mStencilWidth)),mStencilGamma)/2.0f)); } else if (mStencilShape == STENCIL_SHAPE_SCAN_LINES) { // alpha varies according to a squared sine function. F32 d = mStencilSine*i - mStencilCosine*j; - alpha = (sinf(2*F_PI*d/mStencilWavelength) > 0.0 ? 1.0 : 0.0); + alpha = (sinf(2*F_PI*d/mStencilWavelength) > 0.0f ? 1.0f : 0.0f); } else if (mStencilShape == STENCIL_SHAPE_GRADIENT) { @@ -756,11 +756,11 @@ void LLImageFilter::filterGamma(F32 gamma, const LLColor3& alpha) for (S32 i = 0; i < 256; i++) { - F32 gamma_i = llclampf((float)(powf((float)(i)/255.0,1.0/gamma))); + F32 gamma_i = llclampf((float)(powf((float)(i)/255.0f,1.0f/gamma))); // Blend in with alpha values - gamma_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * 255.0 * gamma_i); - gamma_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * 255.0 * gamma_i); - gamma_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * 255.0 * gamma_i); + gamma_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * 255.0f * gamma_i); + gamma_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * 255.0f * gamma_i); + gamma_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * 255.0f * gamma_i); } colorCorrect(gamma_red_lut,gamma_green_lut,gamma_blue_lut); @@ -808,23 +808,23 @@ void LLImageFilter::filterLinearize(F32 tail, const LLColor3& alpha) { U8 value_i = (i < min_v ? 0 : 255); // Blend in with alpha values - linear_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); - linear_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); - linear_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); + linear_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); + linear_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); + linear_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); } } else { // Linearize between min and max - F32 slope = 255.0 / (F32)(max_v - min_v); + F32 slope = 255.0f / (F32)(max_v - min_v); F32 translate = -min_v * slope; for (S32 i = 0; i < 256; i++) { U8 value_i = (U8)(llclampb((S32)(slope*i + translate))); // Blend in with alpha values - linear_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); - linear_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); - linear_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); + linear_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); + linear_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); + linear_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); } } @@ -863,9 +863,9 @@ void LLImageFilter::filterEqualize(S32 nb_classes, const LLColor3& alpha) for (S32 i = 0; i < 256; i++) { // Blend in current_value with alpha values - equalize_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * current_value); - equalize_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * current_value); - equalize_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * current_value); + equalize_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * current_value); + equalize_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * current_value); + equalize_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * current_value); if (cumulated_histo[i] >= current_count) { current_count += delta_count; @@ -884,15 +884,15 @@ void LLImageFilter::filterColorize(const LLColor3& color, const LLColor3& alpha) U8 green_lut[256]; U8 blue_lut[256]; - F32 red_composite = 255.0 * alpha.mV[0] * color.mV[0]; - F32 green_composite = 255.0 * alpha.mV[1] * color.mV[1]; - F32 blue_composite = 255.0 * alpha.mV[2] * color.mV[2]; + F32 red_composite = 255.0f * alpha.mV[0] * color.mV[0]; + F32 green_composite = 255.0f * alpha.mV[1] * color.mV[1]; + F32 blue_composite = 255.0f * alpha.mV[2] * color.mV[2]; for (S32 i = 0; i < 256; i++) { - red_lut[i] = (U8)(llclampb((S32)((1.0 - alpha.mV[0]) * (F32)(i) + red_composite))); - green_lut[i] = (U8)(llclampb((S32)((1.0 - alpha.mV[1]) * (F32)(i) + green_composite))); - blue_lut[i] = (U8)(llclampb((S32)((1.0 - alpha.mV[2]) * (F32)(i) + blue_composite))); + red_lut[i] = (U8)(llclampb((S32)((1.0f - alpha.mV[0]) * (F32)(i) + red_composite))); + green_lut[i] = (U8)(llclampb((S32)((1.0f - alpha.mV[1]) * (F32)(i) + green_composite))); + blue_lut[i] = (U8)(llclampb((S32)((1.0f - alpha.mV[2]) * (F32)(i) + blue_composite))); } colorCorrect(red_lut,green_lut,blue_lut); @@ -904,15 +904,15 @@ void LLImageFilter::filterContrast(F32 slope, const LLColor3& alpha) U8 contrast_green_lut[256]; U8 contrast_blue_lut[256]; - F32 translate = 128.0 * (1.0 - slope); + F32 translate = 128.0f * (1.0f - slope); for (S32 i = 0; i < 256; i++) { U8 value_i = (U8)(llclampb((S32)(slope*i + translate))); // Blend in with alpha values - contrast_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); - contrast_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); - contrast_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); + contrast_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); + contrast_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); + contrast_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); } colorCorrect(contrast_red_lut,contrast_green_lut,contrast_blue_lut); @@ -924,15 +924,15 @@ void LLImageFilter::filterBrightness(F32 add, const LLColor3& alpha) U8 brightness_green_lut[256]; U8 brightness_blue_lut[256]; - S32 add_value = (S32)(add * 255.0); + S32 add_value = (S32)(add * 255.0f); for (S32 i = 0; i < 256; i++) { U8 value_i = (U8)(llclampb(i + add_value)); // Blend in with alpha values - brightness_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); - brightness_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); - brightness_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); + brightness_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); + brightness_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); + brightness_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); } colorCorrect(brightness_red_lut,brightness_green_lut,brightness_blue_lut); -- cgit v1.2.3 From 2f83b0aed2ad123b86faad5b4cb1b55abc0a3a85 Mon Sep 17 00:00:00 2001 From: TommyTheTerrible <81168766+TommyTheTerrible@users.noreply.github.com> Date: Tue, 16 Jul 2024 21:02:57 -0400 Subject: Fix: Update calcDataSizeJ2C to pyramid-base file size estimation (#2032) * Fix: Update calcDataSizeJ2C to pyramid-base file size estimation Used the loop from the previous LayerFactored method to create a more accurate file size estimation by walking up the pyramid tiles. Sizes are much larger in many cases and eliminate partial decoder issues with OpenJPEG. KDU not tested but expected to produce better files as well. Should also stop decode failures on tiny or very rectangular dimensions. --------- Co-authored-by: Andrey Lihatskiy --- indra/llimage/llimagej2c.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 0058b91b0f..5dfd8cd947 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -278,13 +278,20 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r S32 nb_layers = 1; 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) { + if (nb_layers <= (5 - discard_level)) + totalbytes += (S32)(s * comp * precision * rate); 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; @@ -297,7 +304,9 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r 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(bytes, calcHeaderSizeJ2C()); + 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; } -- cgit v1.2.3 From 6535ce51fd1e3f2b0efdc650310ec75a7638f6f9 Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Thu, 18 Jul 2024 09:48:24 +0200 Subject: Remove unnecessary code and (re-)add some more compile time constants (#2057) --- indra/llimage/llimage.h | 42 +++++++++++++++++++++--------------------- indra/llimage/llimagej2c.cpp | 22 +++------------------- 2 files changed, 24 insertions(+), 40 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 42eecbb97c..8b966b8ea3 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -32,37 +32,37 @@ #include "llpointer.h" #include "lltrace.h" -const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2 -const S32 MAX_IMAGE_MIP = 12; // 4096x4096 +constexpr S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2 +constexpr S32 MAX_IMAGE_MIP = 12; // 4096x4096 // *TODO : Use MAX_IMAGE_MIP as max discard level and modify j2c management so that the number // of levels is read from the header's file, not inferred from its size. -const S32 MAX_DISCARD_LEVEL = 5; +constexpr S32 MAX_DISCARD_LEVEL = 5; // JPEG2000 size constraints // Those are declared here as they are germane to other image constraints used in the viewer // and declared right here. Some come from the JPEG2000 spec, some conventions specific to SL. -const S32 MAX_DECOMPOSITION_LEVELS = 32; // Number of decomposition levels cannot exceed 32 according to jpeg2000 spec -const S32 MIN_DECOMPOSITION_LEVELS = 5; // the SL viewer will *crash* trying to decode images with fewer than 5 decomposition levels (unless image is small that is) -const S32 MAX_PRECINCT_SIZE = 4096; // No reason to be bigger than MAX_IMAGE_SIZE -const S32 MIN_PRECINCT_SIZE = 4; // Can't be smaller than MIN_BLOCK_SIZE -const S32 MAX_BLOCK_SIZE = 64; // Max total block size is 4096, hence 64x64 when using square blocks -const S32 MIN_BLOCK_SIZE = 4; // Min block dim is 4 according to jpeg2000 spec -const S32 MIN_LAYER_SIZE = 2000; // Size of the first quality layer (after header). Must be > to FIRST_PACKET_SIZE!! -const S32 MAX_NB_LAYERS = 64; // Max number of layers we'll entertain in SL (practical limit) - -const S32 MIN_IMAGE_SIZE = (1< to FIRST_PACKET_SIZE!! +constexpr S32 MAX_NB_LAYERS = 64; // Max number of layers we'll entertain in SL (practical limit) + +constexpr S32 MIN_IMAGE_SIZE = (1< 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() -- cgit v1.2.3 From bffd4a12b8e6677d8cd8bec2e38909e5200b69dd Mon Sep 17 00:00:00 2001 From: TommyTheTerrible <81168766+TommyTheTerrible@users.noreply.github.com> Date: Sat, 20 Jul 2024 06:37:23 -0400 Subject: calcDataSizeJ2C adjusted to use maximum possible components (#2073) Previous pyramid walking calculation (#2032) assumed the incoming components variable can be accurate but unfortunately the needs_aux is only set to true if the face has an alpha mask setting. Without this information we must assume the J2C files have the maximum component size of four so that alpha channels are found when decoding both the color and aux textures. --- indra/llimage/llimagej2c.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 29449a5d2e..42f3e92257 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -276,14 +276,15 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r // 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 + constexpr S32 max_components = 4; // assumed the file has four components; three color and alpha S32 nb_layers = 1; const S32 surface = w*h; S32 s = 64*64; - S32 totalbytes = (S32)(s * comp * precision * rate); // first level computed before loop + S32 totalbytes = (S32)(s * max_components * precision * rate); // first level computed before loop while (surface > s) { if (nb_layers <= (5 - discard_level)) - totalbytes += (S32)(s * comp * precision * rate); + totalbytes += (S32)(s * max_components * precision * rate); nb_layers++; s *= 4; } -- cgit v1.2.3 From b5e306f7d89e82984a37824a3640bd67a5c45d61 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Wed, 14 Aug 2024 11:01:02 -0400 Subject: Enable /permissive- on MSVC for better standards conformance (#2251) * Enable /permissive- on MSVC for better C++ conformance and fix related errors * Clean up left over warning suppressions from old library or msvc versions --- indra/llimage/llimagejpeg.h | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagejpeg.h b/indra/llimage/llimagejpeg.h index add6657117..012b87a42d 100644 --- a/indra/llimage/llimagejpeg.h +++ b/indra/llimage/llimagejpeg.h @@ -31,7 +31,6 @@ #include "llimage.h" -#include "llwin32headerslean.h" extern "C" { #ifdef LL_USESYSTEMLIBS # include -- cgit v1.2.3 From 9f7dd0177201fe080c287144b99a70125be1fb2b Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Tue, 20 Aug 2024 17:41:48 +0200 Subject: Clean up boost includes and remove compiler warning pragma for unreachable code in PCH (#2361) --- indra/llimage/llimagej2c.cpp | 1 - indra/llimage/llimagej2c.h | 1 - 2 files changed, 2 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 42f3e92257..4ec95bbcc3 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -31,7 +31,6 @@ #include "llmath.h" #include "llmemory.h" #include "llsd.h" -#include // Declare the prototype for this factory function here. It is implemented in // other files which define a LLImageJ2CImpl subclass, but only ONE static diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index 2a32e10bac..19744a7f87 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -30,7 +30,6 @@ #include "llimage.h" #include "llassettype.h" #include "llmetricperformancetester.h" -#include // JPEG2000 : compression rate used in j2c conversion. const F32 DEFAULT_COMPRESSION_RATE = 1.f/8.f; -- cgit v1.2.3