From 1ef083244ad8cc603b50c1d737d8efb4ed14bb17 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 25 Apr 2011 22:37:15 -0700 Subject: EXP-664 : Add JPEG2000 compression settings for test, fix one crash on compression, enhanced error handling on image upload --- indra/newview/app_settings/settings.xml | 33 +++++++++++++++++++++++++++++++++ indra/newview/llviewertexturelist.cpp | 31 ++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f2a0e5ac19..24c495a0ef 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4295,6 +4295,39 @@ Value 0.25 + Jpeg2000AdvancedCompression + + Comment + Use advanced Jpeg2000 compression options (precincts, blocks, ordering, markers) + Persist + 1 + Type + Boolean + Value + 0 + + Jpeg2000PrecinctsSize + + Comment + Size of image precincts. Assumed square and same for all levels. Must be power of 2. + Persist + 1 + Type + S32 + Value + 256 + + Jpeg2000BlocksSize + + Comment + Size of encoding blocks. Assumed square and same for all levels. Must be power of 2. Max 64, Min 4. + Persist + 1 + Type + S32 + Value + 64 + KeepAspectForSnapshot Comment diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 5afed721ac..182cba0e8c 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -932,16 +932,19 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename, LLPointer image = LLImageFormatted::createFromType(codec); if (image.isNull()) { + image->setLastError("Couldn't open the image to be uploaded."); return FALSE; } if (!image->load(filename)) { + image->setLastError("Couldn't load the image to be uploaded."); return FALSE; } // Decompress or expand it in a raw image structure LLPointer raw_image = new LLImageRaw; if (!image->decode(raw_image, 0.0f)) { + image->setLastError("Couldn't decode the image to be uploaded."); return FALSE; } // Check the image constraints @@ -952,8 +955,15 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename, } // Convert to j2c (JPEG2000) and save the file locally LLPointer compressedImage = convertToUploadFile(raw_image); + if (compressedImage.isNull()) + { + image->setLastError("Couldn't convert the image to jpeg2000."); + llinfos << "Couldn't convert to j2c, file : " << filename << llendl; + return FALSE; + } if (!compressedImage->save(out_filename)) { + image->setLastError("Couldn't create the jpeg2000 image for upload."); llinfos << "Couldn't create output file : " << out_filename << llendl; return FALSE; } @@ -961,6 +971,7 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename, LLPointer integrity_test = new LLImageJ2C; if (!integrity_test->loadAndValidate( out_filename )) { + image->setLastError("The created jpeg2000 image is corrupt."); llinfos << "Image file : " << out_filename << " is corrupt" << llendl; return FALSE; } @@ -978,7 +989,25 @@ LLPointer LLViewerTextureList::convertToUploadFile(LLPointergetWidth() * raw_image->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF)) compressedImage->setReversible(TRUE); - compressedImage->encode(raw_image, 0.0f); + + if (gSavedSettings.getBOOL("Jpeg2000AdvancedCompression")) + { + // This test option will create jpeg2000 images with precincts for each level, RPCL ordering + // and PLT markers. The block size is also optionally modifiable. + // Note: the images hence created are compatible with older versions of the viewer. + // Read the blocks and precincts size settings + S32 block_size = gSavedSettings.getS32("Jpeg2000BlocksSize"); + S32 precinct_size = gSavedSettings.getS32("Jpeg2000PrecinctsSize"); + llinfos << "Advanced JPEG2000 Compression: precinct = " << precinct_size << ", block = " << block_size << llendl; + compressedImage->initEncode(*raw_image, block_size, precinct_size); + } + + if (!compressedImage->encode(raw_image, 0.0f)) + { + llinfos << "convertToUploadFile : encode returns with error!!" << llendl; + // Clear up the pointer so we don't leak that one + compressedImage = NULL; + } return compressedImage; } -- cgit v1.2.3 From c03eb76bcf66665ee8a7618dbec0d13e3fc66c32 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 4 May 2011 23:20:15 -0700 Subject: EXP-664 : Fix call to initialization encoding --- indra/newview/llviewertexturelist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 182cba0e8c..8cf9b98d5d 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -999,7 +999,7 @@ LLPointer LLViewerTextureList::convertToUploadFile(LLPointer