From 3acf6dc00104a02fe5e0c17035645c7cd58f27c9 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Tue, 27 Mar 2012 16:23:55 +0200 Subject: [PATCH] Another stab at making textures work as they should --- indra/llimage/llimagej2c.cpp | 18 +++++++++--------- indra/llimagej2coj/llimagej2coj.cpp | 11 ++++++++--- indra/newview/app_settings/settings.xml | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 08d1358e7..63d06e338 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -382,16 +382,16 @@ static S32 cald_data_size_help(S32 w, S32 h, S32 comp, S32 discard_level, F32 ra //static S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate) { - static const LLCachedControl exponent("SianaJ2CSizeExponent", 1.0f); - static const LLCachedControl 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); + static const LLCachedControl exponent("SianaJ2CSizeExponent", 1.0f); + static const LLCachedControl 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 = pow(size/size_d0, exponent)*size_d0 + offset; - bytes = llmax (0, bytes - 600); - bytes = ((bytes + (1000 - 1))/1000)*1000 + 600; - return bytes; + 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; + return bytes; } S32 LLImageJ2C::calcHeaderSize() diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index d55a3e738..3f6fb7f2e 100644 --- a/indra/llimagej2coj/llimagej2coj.cpp +++ b/indra/llimagej2coj/llimagej2coj.cpp @@ -149,10 +149,15 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod opj_setup_decoder(dinfo, ¶meters); /* open a byte stream */ -#if 0 +#if 1 std::vector data(base.getData(), base.getData()+base.getDataSize()); - data.push_back((U8)0xFF); - data.push_back((U8)0xD9); + S32 size = data.size(); + if (data[size-1] == 0xFF) { + data.push_back((U8)0xD9); + } else if (data[size-2] != 0xFF || data[size-1] != 0xD9) { + data.push_back((U8)0xFF); + data.push_back((U8)0xD9); + } cio = opj_cio_open((opj_common_ptr)dinfo, &data[0], data.size()); #else cio = opj_cio_open((opj_common_ptr)dinfo, base.getData(), base.getDataSize()); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f14115db6..040eb0664 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -298,7 +298,7 @@ Type S32 Value - 100 + 0 SianaLegacyJ2CSize