summaryrefslogtreecommitdiff
path: root/indra/integration_tests/llimage_libtest/llimage_libtest.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2011-04-04 18:37:32 -0700
committerMerov Linden <merov@lindenlab.com>2011-04-04 18:37:32 -0700
commit83ec0cd62f70888c90671ea91cd056ecb6095bc1 (patch)
tree3bfd13782f0b056e61249f17a057d5bf7ee6f882 /indra/integration_tests/llimage_libtest/llimage_libtest.cpp
parentdc00f42dd7ff59143869e17010ed435db009ae12 (diff)
STORM-746 : add new arguments for precincts and blocks on output, region and level on input, add code for input loading restriction
Diffstat (limited to 'indra/integration_tests/llimage_libtest/llimage_libtest.cpp')
-rw-r--r--indra/integration_tests/llimage_libtest/llimage_libtest.cpp126
1 files changed, 119 insertions, 7 deletions
diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp
index 365f5f758c..10d6ffb685 100644
--- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp
+++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp
@@ -53,12 +53,28 @@ 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"
+" -r, --region <x0, y0, x1, y1>\n"
+" Crop region on the input file in pixel.\n"
+" Only used for j2c images. Default is no region cropping.\n"
+" -d, --discard_level <n>\n"
+" Discard level max used on input. 0 is high resolution. Max discard level is 5.\n"
+" This allows the input image to be clamped in resolution when loading.\n"
+" Only valid for j2c images. Default is no discard.\n"
+" -p, --precincts <n>\n"
+" Dimension of precincts in pixels. Precincts are assumed square and identical for\n"
+" all levels. Note that this oprion also uses PLT and tile markers, \n"
+" as well as RPCL order. Power of 2 must be used.\n"
+" Only valid for output j2c images. Default is no precincts used.\n"
+" -b, --blocks <n>\n"
+" Dimension of coding blocks in pixels. Blocks are assumed square. Power of 2 must\n"
+" be used. Blocks must be smaller than precincts.\n"
+" Only valid for output j2c images. Default is 64.\n"
" -log, --logmetrics <metric>\n"
" Log performance data for <metric>. Results in <metric>.slp\n"
" Note: so far, only ImageCompressionTester has been tested.\n"
-" -r, --analyzeperformance\n"
+" -a, --analyzeperformance\n"
" Create a report comparing <metric>_baseline.slp with current <metric>.slp\n"
-" Results in <metric>_report.csv"
+" Results in <metric>_report.csv\n"
" -s, --image-stats\n"
" Output stats for each input and output image.\n"
"\n";
@@ -110,10 +126,11 @@ void output_image_stats(LLPointer<LLImageFormatted> image, const std::string &fi
}
// Load an image from file and return a raw (decompressed) instance of its data
-LLPointer<LLImageRaw> load_image(const std::string &src_filename, bool output_stats)
+LLPointer<LLImageRaw> load_image(const std::string &src_filename, bool output_stats, bool use_discard_level, int discard_level, bool use_region, int* region)
{
LLPointer<LLImageFormatted> image = create_image(src_filename);
-
+
+ // This just load the image file stream into a buffer. No decoding done.
if (!image->load(src_filename))
{
return NULL;
@@ -131,6 +148,17 @@ LLPointer<LLImageRaw> load_image(const std::string &src_filename, bool output_st
}
LLPointer<LLImageRaw> raw_image = new LLImageRaw;
+
+ // Set the image restriction on load in the case of a j2c image
+ if ((image->getCodec() == IMG_CODEC_J2C) && (use_discard_level || use_region))
+ {
+ int discard = (use_discard_level ? discard_level : -1);
+ int* reg = (use_region ? region : NULL);
+ // That method doesn't exist (and likely, doesn't make sense) for any other image file format
+ // hence the required cryptic cast.
+ ((LLImageJ2C*)(image.get()))->initDecode(*raw_image, discard, reg);
+ }
+
if (!image->decode(raw_image, 0.0f))
{
return NULL;
@@ -280,8 +308,17 @@ int main(int argc, char** argv)
// List of input and output files
std::list<std::string> input_filenames;
std::list<std::string> output_filenames;
+ // Other optional parsed arguments
bool analyze_performance = false;
bool image_stats = false;
+ bool use_region = false;
+ int region[4];
+ bool use_discard_level = false;
+ int discard_level = 0;
+ bool use_precincts = false;
+ int precincts_size;
+ bool use_blocks = false;
+ int blocks_size;
// Init whatever is necessary
ll_init_apr();
@@ -323,6 +360,81 @@ int main(int argc, char** argv)
file_name = argv[arg+1]; // Next argument and loop over
}
}
+ else if ((!strcmp(argv[arg], "--region") || !strcmp(argv[arg], "-r")) && arg < argc-1)
+ {
+ std::string value_str = argv[arg+1];
+ int index = 0;
+ while (value_str[0] != '-') // if arg starts with '-', it's the next option
+ {
+ int value = atoi(value_str.c_str());
+ region[index++] = value;
+ arg += 1; // Definitely skip that arg now we know it's a number
+ if ((arg + 1) == argc) // Break out of the loop if we reach the end of the arg list
+ break;
+ if (index == 4) // Break out of the loop if we captured 4 values already
+ break;
+ value_str = argv[arg+1]; // Next argument and loop over
+ }
+ if (index == 4)
+ {
+ use_region = true;
+ }
+ else
+ {
+ std::cout << "--region arguments invalid" << std::endl;
+ }
+ }
+ else if (!strcmp(argv[arg], "--discard_level") || !strcmp(argv[arg], "-d"))
+ {
+ std::string value_str;
+ if ((arg + 1) < argc)
+ {
+ value_str = argv[arg+1];
+ }
+ if (((arg + 1) >= argc) || (value_str[0] == '-'))
+ {
+ std::cout << "No valid --discard_level argument given, discard_level ignored" << std::endl;
+ }
+ else
+ {
+ use_discard_level = true;
+ discard_level = atoi(value_str.c_str());
+ }
+ }
+ else if (!strcmp(argv[arg], "--precincts") || !strcmp(argv[arg], "-p"))
+ {
+ std::string value_str;
+ if ((arg + 1) < argc)
+ {
+ value_str = argv[arg+1];
+ }
+ if (((arg + 1) >= argc) || (value_str[0] == '-'))
+ {
+ std::cout << "No valid --precincts argument given, precincts ignored" << std::endl;
+ }
+ else
+ {
+ use_precincts = true;
+ precincts_size = atoi(value_str.c_str());
+ }
+ }
+ else if (!strcmp(argv[arg], "--blocks") || !strcmp(argv[arg], "-b"))
+ {
+ std::string value_str;
+ if ((arg + 1) < argc)
+ {
+ value_str = argv[arg+1];
+ }
+ if (((arg + 1) >= argc) || (value_str[0] == '-'))
+ {
+ std::cout << "No valid --blocks argument given, blocks ignored" << std::endl;
+ }
+ else
+ {
+ use_blocks = true;
+ blocks_size = atoi(value_str.c_str());
+ }
+ }
else if (!strcmp(argv[arg], "--logmetrics") || !strcmp(argv[arg], "-log"))
{
// '--logmetrics' needs to be specified with a named test metric argument
@@ -346,7 +458,7 @@ int main(int argc, char** argv)
break;
}
}
- else if (!strcmp(argv[arg], "--analyzeperformance") || !strcmp(argv[arg], "-r"))
+ else if (!strcmp(argv[arg], "--analyzeperformance") || !strcmp(argv[arg], "-a"))
{
analyze_performance = true;
}
@@ -364,7 +476,7 @@ int main(int argc, char** argv)
}
if (analyze_performance && !LLFastTimer::sMetricLog)
{
- std::cout << "Cannot create perf report if no perf gathered (i.e. use argument -log <perf> with -r) -> exit" << std::endl;
+ std::cout << "Cannot create perf report if no perf gathered (i.e. use argument -log <perf> with -a) -> exit" << std::endl;
return 0;
}
@@ -385,7 +497,7 @@ int main(int argc, char** argv)
for (; in_file != in_end; ++in_file)
{
// Load file
- LLPointer<LLImageRaw> raw_image = load_image(*in_file, image_stats);
+ LLPointer<LLImageRaw> raw_image = load_image(*in_file, image_stats, use_discard_level, discard_level, use_region, region);
if (!raw_image)
{
std::cout << "Error: Image " << *in_file << " could not be loaded" << std::endl;