diff options
author | Oz Linden <oz@lindenlab.com> | 2013-11-19 17:59:55 -0500 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2013-11-19 17:59:55 -0500 |
commit | 0031e9a97be1bf6e9fe773c23506494d09ce91ae (patch) | |
tree | 220f195c82174b7cc8e94dceb2553e59fe5837a5 /indra/integration_tests/llimage_libtest | |
parent | b7edc965bc77ab21e9a1e3f6b424299a50053529 (diff) | |
parent | ebc9bcbf69f7a519677a6522979a6bf6cbb04bb8 (diff) |
merge up to 3.6.10-release; some of the storm-68 changes lost
Diffstat (limited to 'indra/integration_tests/llimage_libtest')
-rwxr-xr-x[-rw-r--r--] | indra/integration_tests/llimage_libtest/CMakeLists.txt | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/integration_tests/llimage_libtest/llimage_libtest.cpp | 70 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/integration_tests/llimage_libtest/llimage_libtest.h | 0 |
3 files changed, 64 insertions, 9 deletions
diff --git a/indra/integration_tests/llimage_libtest/CMakeLists.txt b/indra/integration_tests/llimage_libtest/CMakeLists.txt index af5c9fb2e7..36a7d38bb7 100644..100755 --- a/indra/integration_tests/llimage_libtest/CMakeLists.txt +++ b/indra/integration_tests/llimage_libtest/CMakeLists.txt @@ -16,6 +16,9 @@ include_directories( ${LLVFS_INCLUDE_DIRS} ${LLIMAGE_INCLUDE_DIRS} ) +include_directories(SYSTEM + ${LLCOMMON_SYSTEM_INCLUDE_DIRS} + ) set(llimage_libtest_SOURCE_FILES llimage_libtest.cpp diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 48e876429d..034c816742 100644..100755 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -54,6 +54,11 @@ static const char USAGE[] = "\n" " -o, --output <file1 .. file2> OR <type>\n" " List of image files to create (assumes same order as for input files)\n" " OR 3 letters file type extension to convert each input file into.\n" +" -load, --load_size <n>\n" +" Portion of the input file to load, in bytes." +" If (load == 0), it will load the whole file." +" If (load == -1), it will load the size relevant to reach the requested discard level (see -d)." +" Only valid for j2c images. Default is 0 (load whole file).\n" " -r, --region <x0, y0, x1, y1>\n" " Crop region applied to the input files in pixels.\n" " Only used for j2c images. Default is no region cropping.\n" @@ -104,22 +109,52 @@ void output_image_stats(LLPointer<LLImageFormatted> image, const std::string &fi // Print out some statistical data on the image std::cout << "Image stats for : " << filename << ", extension : " << image->getExtension() << std::endl; - std::cout << " with : " << (int)(image->getWidth()) << ", height : " << (int)(image->getHeight()) << std::endl; - std::cout << " comp : " << (int)(image->getComponents()) << ", levels : " << (int)(image->getDiscardLevel()) << std::endl; - std::cout << " head : " << (int)(image->calcHeaderSize()) << ", data : " << (int)(image->getDataSize()) << std::endl; + std::cout << " with : " << (int)(image->getWidth()) << ", height : " << (int)(image->getHeight()) << std::endl; + std::cout << " comp : " << (int)(image->getComponents()) << ", levels : " << (int)(image->getLevels()) << std::endl; + std::cout << " head : " << (int)(image->calcHeaderSize()) << ", data : " << (int)(image->getDataSize()) << std::endl; return; } // Load an image from file and return a raw (decompressed) instance of its data -LLPointer<LLImageRaw> load_image(const std::string &src_filename, int discard_level, int* region, bool output_stats) +LLPointer<LLImageRaw> load_image(const std::string &src_filename, int discard_level, int* region, int load_size, bool output_stats) { LLPointer<LLImageFormatted> image = create_image(src_filename); - // This just loads the image file stream into a buffer. No decoding done. - if (!image->load(src_filename)) + // We support partial loading only for j2c images + if (image->getCodec() == IMG_CODEC_J2C) { - return NULL; + // Load the header + if (!image->load(src_filename, 600)) + { + return NULL; + } + S32 h = ((LLImageJ2C*)(image.get()))->calcHeaderSize(); + S32 d = (load_size > 0 ? ((LLImageJ2C*)(image.get()))->calcDiscardLevelBytes(load_size) : 0); + S8 r = ((LLImageJ2C*)(image.get()))->getRawDiscardLevel(); + std::cout << "Merov debug : header = " << h << ", load_size = " << load_size << ", discard level = " << d << ", raw discard level = " << r << std::endl; + for (d = 0; d < MAX_DISCARD_LEVEL; d++) + { + S32 data_size = ((LLImageJ2C*)(image.get()))->calcDataSize(d); + std::cout << "Merov debug : discard_level = " << d << ", data_size = " << data_size << std::endl; + } + if (load_size < 0) + { + load_size = (discard_level != -1 ? ((LLImageJ2C*)(image.get()))->calcDataSize(discard_level) : 0); + } + // Load the requested byte range + if (!image->load(src_filename, load_size)) + { + return NULL; + } + } + else + { + // This just loads the image file stream into a buffer. No decoding done. + if (!image->load(src_filename)) + { + return NULL; + } } if( (image->getComponents() != 3) && (image->getComponents() != 4) ) @@ -205,7 +240,7 @@ void store_input_file(std::list<std::string> &input_filenames, const std::string LLDirIterator iter(dir, name); while (iter.next(next_name)) { - std::string file_name = dir + gDirUtilp->getDirDelimiter() + next_name; + std::string file_name = gDirUtilp->add(dir, next_name); input_filenames.push_back(file_name); } } @@ -310,6 +345,7 @@ int main(int argc, char** argv) bool image_stats = false; int* region = NULL; int discard_level = -1; + int load_size = 0; int precincts_size = -1; int blocks_size = -1; int levels = 0; @@ -396,6 +432,22 @@ int main(int argc, char** argv) discard_level = llclamp(discard_level,0,5); } } + else if (!strcmp(argv[arg], "--load_size") || !strcmp(argv[arg], "-load")) + { + std::string value_str; + if ((arg + 1) < argc) + { + value_str = argv[arg+1]; + } + if (((arg + 1) >= argc) || (value_str[0] == '-')) + { + std::cout << "No valid --load_size argument given, load_size ignored" << std::endl; + } + else + { + load_size = atoi(value_str.c_str()); + } + } else if (!strcmp(argv[arg], "--precincts") || !strcmp(argv[arg], "-p")) { std::string value_str; @@ -510,7 +562,7 @@ int main(int argc, char** argv) for (; in_file != in_end; ++in_file, ++out_file) { // Load file - LLPointer<LLImageRaw> raw_image = load_image(*in_file, discard_level, region, image_stats); + LLPointer<LLImageRaw> raw_image = load_image(*in_file, discard_level, region, load_size, image_stats); if (!raw_image) { std::cout << "Error: Image " << *in_file << " could not be loaded" << std::endl; diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.h b/indra/integration_tests/llimage_libtest/llimage_libtest.h index 63f3d46b50..63f3d46b50 100644..100755 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.h +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.h |