From dc00f42dd7ff59143869e17010ed435db009ae12 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 31 Mar 2011 23:00:50 -0700 Subject: STORM-746 : Code formatting and clean up, add comments, no functional changes --- indra/llkdu/llimagej2ckdu.cpp | 404 +++++++++++++++++++++--------------------- indra/llkdu/llkdumem.cpp | 22 +-- indra/llkdu/llkdumem.h | 44 ++--- 3 files changed, 237 insertions(+), 233 deletions(-) (limited to 'indra') diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 10ea5685e8..61b16c80e6 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -34,35 +34,35 @@ class kdc_flow_control { -public: // Member functions - kdc_flow_control(kdu_image_in_base *img_in, kdu_codestream codestream); - ~kdc_flow_control(); - bool advance_components(); - void process_components(); +public: + kdc_flow_control(kdu_image_in_base *img_in, kdu_codestream codestream); + ~kdc_flow_control(); + bool advance_components(); + void process_components(); + +private: -private: // Data - - struct kdc_component_flow_control { - public: // Data - kdu_image_in_base *reader; - int vert_subsampling; - int ratio_counter; /* Initialized to 0, decremented by `count_delta'; + struct kdc_component_flow_control { + public: + kdu_image_in_base *reader; + int vert_subsampling; + int ratio_counter; /* Initialized to 0, decremented by `count_delta'; when < 0, a new line must be processed, after which it is incremented by `vert_subsampling'. */ - int initial_lines; - int remaining_lines; - kdu_line_buf *line; - }; - - kdu_codestream codestream; - kdu_dims valid_tile_indices; - kdu_coords tile_idx; - kdu_tile tile; - int num_components; - kdc_component_flow_control *components; - int count_delta; // Holds the minimum of the `vert_subsampling' fields - kdu_multi_analysis engine; - kdu_long max_buffer_memory; + int initial_lines; + int remaining_lines; + kdu_line_buf *line; + }; + + kdu_codestream codestream; + kdu_dims valid_tile_indices; + kdu_coords tile_idx; + kdu_tile tile; + int num_components; + kdc_component_flow_control *components; + int count_delta; // Holds the minimum of the `vert_subsampling' fields + kdu_multi_analysis engine; + kdu_long max_buffer_memory; }; // @@ -72,7 +72,8 @@ void set_default_colour_weights(kdu_params *siz); const char* engineInfoLLImageJ2CKDU() { - return "KDU v6.4.1"; + std::string version = llformat("KDU %s", KDU_CORE_VERSION); + return version.c_str(); } LLImageJ2CKDU* createLLImageJ2CKDU() @@ -113,8 +114,8 @@ public: kdu_tile_comp mComps[4]; kdu_line_buf mLines[4]; kdu_pull_ifc mEngines[4]; - bool mReversible[4]; // Some components may be reversible and others not. - int mBitDepths[4]; // Original bit-depth may be quite different from 8. + bool mReversible[4]; // Some components may be reversible and others not + int mBitDepths[4]; // Original bit-depth may be quite different from 8 kdu_tile mTile; kdu_byte *mBuf; @@ -153,7 +154,7 @@ class LLKDUMessageError : public kdu_message public: /*virtual*/ void put_text(const char *s); /*virtual*/ void put_text(const kdu_uint16 *s); - /*virtual*/ void flush(bool end_of_message=false); + /*virtual*/ void flush(bool end_of_message = false); static LLKDUMessageError sDefaultMessage; }; @@ -179,7 +180,7 @@ void LLKDUMessageError::put_text(const kdu_uint16 *s) void LLKDUMessageError::flush(bool end_of_message) { - if( end_of_message ) + if (end_of_message) { throw "KDU throwing an exception"; } @@ -210,7 +211,7 @@ void transfer_bytes(kdu_byte *dest, kdu_line_buf &src, int gap, int precision); void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECodeStreamMode mode) { S32 data_size = base.getDataSize(); - S32 max_bytes = base.getMaxBytes() ? base.getMaxBytes() : data_size; + S32 max_bytes = (base.getMaxBytes() ? base.getMaxBytes() : data_size); // // Initialization @@ -247,21 +248,21 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECod // Set the maximum number of bytes to use from the codestream mCodeStreamp->set_max_bytes(max_bytes); - // If you want to flip or rotate the image for some reason, change + // If you want to flip or rotate the image for some reason, change // the resolution, or identify a restricted region of interest, this is // the place to do it. You may use "kdu_codestream::change_appearance" // and "kdu_codestream::apply_input_restrictions" for this purpose. - // If you wish to truncate the code-stream prior to decompression, you + // If you wish to truncate the code-stream prior to decompression, you // may use "kdu_codestream::set_max_bytes". - // If you wish to retain all compressed data so that the material + // If you wish to retain all compressed data so that the material // can be decompressed multiple times, possibly with different appearance // parameters, you should call "kdu_codestream::set_persistent" here. - // There are a variety of other features which must be enabled at + // There are a variety of other features which must be enabled at // this point if you want to take advantage of them. See the // descriptions appearing with the "kdu_codestream" interface functions // in "kdu_compressed.h" for an itemized account of these capabilities. - switch( mode ) + switch (mode) { case MODE_FAST: mCodeStreamp->set_fast(); @@ -343,7 +344,7 @@ BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco kdu_dims dims; mCodeStreamp->get_dims(0,dims); S32 channels = base.getComponents() - first_channel; - if( channels > max_channel_count ) + if (channels > max_channel_count) { channels = max_channel_count; } @@ -426,7 +427,7 @@ BOOL LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco // canvas coordinate system. Comparing the two tells // us where the current tile is in the buffer. S32 channels = base.getComponents() - first_channel; - if( channels > max_channel_count ) + if (channels > max_channel_count) { channels = max_channel_count; } @@ -452,14 +453,14 @@ BOOL LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco return FALSE; } } - catch( const char* msg ) + catch (const char* msg) { base.setLastError(ll_safe_string(msg)); base.decodeFailed(); cleanupCodeStream(); return TRUE; // done } - catch( ... ) + catch (...) { base.setLastError( "Unknown J2C error" ); base.decodeFailed(); @@ -482,28 +483,17 @@ BOOL LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time, BOOL reversible) { - // Collect simple arguments. - bool transpose, vflip, hflip; - bool allow_rate_prediction, mem, quiet, no_weights; - int cpu_iterations; - std::ostream *record_stream; - - transpose = false; - record_stream = NULL; - allow_rate_prediction = true; - no_weights = false; - cpu_iterations = -1; - mem = false; - quiet = false; - vflip = true; - hflip = false; + // Declare and set simple arguments + bool transpose = false; + bool vflip = true; + bool hflip = false; try { - // Set up input image files. + // Set up input image files siz_params siz; - // Should set rate someplace here. + // Should set rate someplace here LLKDUMemIn mem_in(raw_image.getData(), raw_image.getDataSize(), raw_image.getWidth(), @@ -521,12 +511,12 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co siz.set(Sprecision,0,0,8); // Image samples have original bit-depth of 8 siz.set(Ssigned,0,0,false); // Image samples are originally unsigned - kdu_params *siz_ref = &siz; siz_ref->finalize(); - siz_params transformed_siz; // Use this one to construct code-strea + kdu_params *siz_ref = &siz; + siz_ref->finalize(); + siz_params transformed_siz; // Use this one to construct code-stream transformed_siz.copy_from(&siz,-1,-1,-1,0,transpose,false,false); - // Construct the `kdu_codestream' object and parse all remaining arguments. - + // Construct the `kdu_codestream' object and parse all remaining arguments U32 max_output_size = base.getWidth()*base.getHeight()*base.getComponents(); if (max_output_size < 1000) { @@ -538,8 +528,7 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co LLKDUMemTarget output(output_buffer, output_size, base.getWidth()*base.getHeight()*base.getComponents()); if (output_size > max_output_size) { - llerrs << llformat("LLImageJ2C::encode output_size(%d) > max_output_size(%d)", - output_size,max_output_size) << llendl; + llerrs << llformat("LLImageJ2C::encode output_size(%d) > max_output_size(%d)", output_size,max_output_size) << llendl; } kdu_codestream codestream; @@ -558,15 +547,18 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co kdu_long layer_bytes[64]; U32 max_bytes = 0; - if ((num_components >= 3) && !no_weights) + if (num_components >= 3) { + // Note that we always use YCC and not YUV + // *TODO: Verify this doesn't screws up reversible textures (like sculpties) as YCC is not reversible but YUV is... set_default_colour_weights(codestream.access_siz()); } if (reversible) { - // If we're doing reversible, assume we're not using quality layers. + // If we're doing reversible (i.e. lossless compression), assumes we're not using quality layers. // Yes, I know this is incorrect! + // *TODO: Indeed, this is incorrect and unecessary... Try using the regular layer setting... codestream.access_siz()->parse_string("Creversible=yes"); codestream.access_siz()->parse_string("Clayers=1"); num_layer_specs = 1; @@ -577,6 +569,7 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co // Rate is the argument passed into the LLImageJ2C which // specifies the target compression rate. The default is 8:1. // Possibly if max_bytes < 500, we should just use the default setting? + // *TODO: mRate is actually always 8:1 in the viewer. Test different values. Also force to reversible for small (< 500 bytes) textures. if (base.mRate != 0.f) { max_bytes = (U32)(base.mRate*base.getWidth()*base.getHeight()*base.getComponents()); @@ -617,42 +610,39 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co codestream.access_siz()->parse_string(layer_string.c_str()); } } + + // *TODO : Add precinct specification here + //std::string precincts_string = llformat("Cprecincts={128,128}"); + //codestream.access_siz()->parse_string(precincts_string.c_str()); + codestream.access_siz()->finalize_all(); - if (cpu_iterations >= 0) - { - codestream.collect_timing_stats(cpu_iterations); - } codestream.change_appearance(transpose,vflip,hflip); // Now we are ready for sample data processing. - kdc_flow_control *tile = new kdc_flow_control(&mem_in,codestream); - bool done = false; - while (!done) - { - // Process line by line - done = true; - if (tile->advance_components()) - { - done = false; - tile->process_components(); - } - } + kdc_flow_control *tile = new kdc_flow_control(&mem_in,codestream); + bool done = false; + while (!done) + { + // Process line by line + if (tile->advance_components()) + { + tile->process_components(); + } + else + { + done = true; + } + } // Produce the compressed output - codestream.flush(layer_bytes,num_layer_specs); + codestream.flush(layer_bytes,num_layer_specs); // Cleanup - delete tile; - + delete tile; codestream.destroy(); - if (record_stream != NULL) - { - delete record_stream; - } // Now that we're done encoding, create the new data buffer for the compressed // image and stick it there. - base.copyData(output_buffer, output_size); base.updateData(); // set width, height delete[] output_buffer; @@ -674,19 +664,19 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co BOOL LLImageJ2CKDU::getMetadata(LLImageJ2C &base) { // *FIX: kdu calls our callback function if there's an error, and - // then bombs. To regain control, we throw an exception, and + // then bombs. To regain control, we throw an exception, and // catch it here. try { setupCodeStream(base, FALSE, MODE_FAST); return TRUE; } - catch( const char* msg ) + catch (const char* msg) { base.setLastError(ll_safe_string(msg)); return FALSE; } - catch( ... ) + catch (...) { base.setLastError( "Unknown J2C error" ); return FALSE; @@ -699,37 +689,49 @@ void set_default_colour_weights(kdu_params *siz) assert(cod != NULL); bool can_use_ycc = true; - bool rev0=false; - int depth0=0, sub_x0=1, sub_y0=1; - for (int c=0; c < 3; c++) + bool rev0 = false; + int depth0 = 0, sub_x0 = 1, sub_y0 = 1; + for (int c = 0; c < 3; c++) { - int depth=0; siz->get(Sprecision,c,0,depth); - int sub_y=1; siz->get(Ssampling,c,0,sub_y); - int sub_x=1; siz->get(Ssampling,c,1,sub_x); + int depth = 0; siz->get(Sprecision,c,0,depth); + int sub_y = 1; siz->get(Ssampling,c,0,sub_y); + int sub_x = 1; siz->get(Ssampling,c,1,sub_x); kdu_params *coc = cod->access_relation(-1,c); - bool rev=false; coc->get(Creversible,0,0,rev); + bool rev = false; coc->get(Creversible,0,0,rev); if (c == 0) - { rev0=rev; depth0=depth; sub_x0=sub_x; sub_y0=sub_y; } - else if ((rev != rev0) || (depth != depth0) || - (sub_x != sub_x0) || (sub_y != sub_y0)) + { + rev0 = rev; depth0 = depth; sub_x0 = sub_x; sub_y0 = sub_y; + } + else if ((rev != rev0) || (depth != depth0) || + (sub_x != sub_x0) || (sub_y != sub_y0)) + { can_use_ycc = false; + } } if (!can_use_ycc) + { return; + } bool use_ycc; if (!cod->get(Cycc,0,0,use_ycc)) + { cod->set(Cycc,0,0,use_ycc=true); + } if (!use_ycc) + { return; + } float weight; - if (cod->get(Clev_weights,0,0,weight) || - cod->get(Cband_weights,0,0,weight)) - return; // Weights already specified explicitly. + if (cod->get(Clev_weights,0,0,weight) || cod->get(Cband_weights,0,0,weight)) + { + // Weights already specified explicitly -> nothing to do + return; + } - /* These example weights are adapted from numbers generated by Marcus Nadenau - at EPFL, for a viewing distance of 15 cm and a display resolution of - 300 DPI. */ + // These example weights are adapted from numbers generated by Marcus Nadenau + // at EPFL, for a viewing distance of 15 cm and a display resolution of + // 300 DPI. cod->parse_string("Cband_weights:C0=" "{0.0901},{0.2758},{0.2758}," @@ -775,7 +777,7 @@ all necessary level shifting, type conversion, rounding and truncation. */ val += 128; if (val & ((-1)<<8)) { - val = (val<0)?0:255; + val = (val < 0 ? 0 : 255); } *dest = (kdu_byte) val; } @@ -793,7 +795,7 @@ all necessary level shifting, type conversion, rounding and truncation. */ val += 128; if (val & ((-1)<<8)) { - val = (val<0)?0:255; + val = (val < 0 ? 0 : 255); } *dest = (kdu_byte) val; } @@ -816,7 +818,7 @@ all necessary level shifting, type conversion, rounding and truncation. */ val += 128; if (val & ((-1)<<8)) { - val = (val<0)?0:255; + val = (val < 0 ? 0 : 255); } *dest = (kdu_byte) val; } @@ -835,7 +837,7 @@ all necessary level shifting, type conversion, rounding and truncation. */ val += 128; if (val & ((-1)<<8)) { - val = (val<0)?0:(256-(1<codestream = codestream; - codestream.get_valid_tiles(valid_tile_indices); - tile_idx = valid_tile_indices.pos; - tile = codestream.open_tile(tile_idx,NULL); - - // Set up the individual components - num_components = codestream.get_num_components(true); - components = new kdc_component_flow_control[num_components]; - count_delta = 0; - kdc_component_flow_control *comp = components; - for (n = 0; n < num_components; n++, comp++) - { - comp->line = NULL; - comp->reader = img_in; - kdu_coords subsampling; - codestream.get_subsampling(n,subsampling,true); - kdu_dims dims; - codestream.get_tile_dims(tile_idx,n,dims,true); - comp->vert_subsampling = subsampling.y; - if ((n == 0) || (comp->vert_subsampling < count_delta)) - { - count_delta = comp->vert_subsampling; - } - comp->ratio_counter = 0; - comp->remaining_lines = comp->initial_lines = dims.size.y; - } - assert(num_components >= 0); - - tile.set_components_of_interest(num_components); - max_buffer_memory = engine.create(codestream,tile,false,NULL,false,1,NULL,NULL,false); + int n; + + this->codestream = codestream; + codestream.get_valid_tiles(valid_tile_indices); + tile_idx = valid_tile_indices.pos; + tile = codestream.open_tile(tile_idx,NULL); + + // Set up the individual components + num_components = codestream.get_num_components(true); + components = new kdc_component_flow_control[num_components]; + count_delta = 0; + kdc_component_flow_control *comp = components; + for (n = 0; n < num_components; n++, comp++) + { + comp->line = NULL; + comp->reader = img_in; + kdu_coords subsampling; + codestream.get_subsampling(n,subsampling,true); + kdu_dims dims; + codestream.get_tile_dims(tile_idx,n,dims,true); + comp->vert_subsampling = subsampling.y; + if ((n == 0) || (comp->vert_subsampling < count_delta)) + { + count_delta = comp->vert_subsampling; + } + comp->ratio_counter = 0; + comp->remaining_lines = comp->initial_lines = dims.size.y; + } + assert(num_components >= 0); + + tile.set_components_of_interest(num_components); + max_buffer_memory = engine.create(codestream,tile,false,NULL,false,1,NULL,NULL,false); } kdc_flow_control::~kdc_flow_control() { - if (components != NULL) - delete[] components; - if (engine.exists()) - engine.destroy(); + if (components != NULL) + { + delete[] components; + } + if (engine.exists()) + { + engine.destroy(); + } } bool kdc_flow_control::advance_components() { - bool found_line = false; - while (!found_line) - { - bool all_done = true; - kdc_component_flow_control *comp = components; - for (int n = 0; n < num_components; n++, comp++) - { - assert(comp->ratio_counter >= 0); - if (comp->remaining_lines > 0) - { - all_done = false; - comp->ratio_counter -= count_delta; - if (comp->ratio_counter < 0) - { - found_line = true; - comp->line = engine.exchange_line(n,NULL,NULL); - assert(comp->line != NULL); + bool found_line = false; + while (!found_line) + { + bool all_done = true; + kdc_component_flow_control *comp = components; + for (int n = 0; n < num_components; n++, comp++) + { + assert(comp->ratio_counter >= 0); + if (comp->remaining_lines > 0) + { + all_done = false; + comp->ratio_counter -= count_delta; + if (comp->ratio_counter < 0) + { + found_line = true; + comp->line = engine.exchange_line(n,NULL,NULL); + assert(comp->line != NULL); if (comp->line->get_width()) { comp->reader->get(n,*(comp->line),0); } - } - } - } - if (all_done) - { - return false; - } - } - return true; + } + } + } + if (all_done) + { + return false; + } + } + return true; } void kdc_flow_control::process_components() { - kdc_component_flow_control *comp = components; - for (int n = 0; n < num_components; n++, comp++) - { - if (comp->ratio_counter < 0) - { - comp->ratio_counter += comp->vert_subsampling; - assert(comp->ratio_counter >= 0); - assert(comp->remaining_lines > 0); - comp->remaining_lines--; - assert(comp->line != NULL); - engine.exchange_line(n,comp->line,NULL); - comp->line = NULL; - } - } + kdc_component_flow_control *comp = components; + for (int n = 0; n < num_components; n++, comp++) + { + if (comp->ratio_counter < 0) + { + comp->ratio_counter += comp->vert_subsampling; + assert(comp->ratio_counter >= 0); + assert(comp->remaining_lines > 0); + comp->remaining_lines--; + assert(comp->line != NULL); + engine.exchange_line(n,comp->line,NULL); + comp->line = NULL; + } + } } diff --git a/indra/llkdu/llkdumem.cpp b/indra/llkdu/llkdumem.cpp index 1f549cbbe0..0347475559 100644 --- a/indra/llkdu/llkdumem.cpp +++ b/indra/llkdu/llkdumem.cpp @@ -47,12 +47,12 @@ LLKDUMemIn::LLKDUMemIn(const U8 *data, num_components = in_num_components; alignment_bytes = 0; - for (n=0; n<3; ++n) + for (n = 0; n < 3; ++n) { precision[n] = 0; } - for (n=0; n < num_components; ++n) + for (n = 0; n < num_components; ++n) { siz->set(Sdims,n,0,rows); siz->set(Sdims,n,1,cols); @@ -80,12 +80,12 @@ LLKDUMemIn::~LLKDUMemIn() } image_line_buf *tmp; while ((tmp=incomplete_lines) != NULL) - { + { incomplete_lines = tmp->next; delete tmp; } while ((tmp=free_lines) != NULL) - { + { free_lines = tmp->next; delete tmp; } @@ -98,16 +98,16 @@ bool LLKDUMemIn::get(int comp_idx, kdu_line_buf &line, int x_tnum) assert((idx >= 0) && (idx < num_components)); x_tnum = x_tnum*num_components+idx; image_line_buf *scan, *prev=NULL; - for (scan=incomplete_lines; scan != NULL; prev=scan, scan=scan->next) - { + for (scan = incomplete_lines; scan != NULL; prev = scan, scan = scan->next) + { assert(scan->next_x_tnum >= x_tnum); if (scan->next_x_tnum == x_tnum) { break; } - } + } if (scan == NULL) - { // Need to read a new image line. + { // Need to read a new image line. assert(x_tnum == 0); // Must consume in very specific order. if (num_unread_rows == 0) { @@ -134,7 +134,7 @@ bool LLKDUMemIn::get(int comp_idx, kdu_line_buf &line, int x_tnum) num_unread_rows--; scan->accessed_samples = 0; scan->next_x_tnum = 0; - } + } assert((cols-scan->accessed_samples) >= line.get_width()); @@ -161,7 +161,7 @@ bool LLKDUMemIn::get(int comp_idx, kdu_line_buf &line, int x_tnum) } } else - { + { kdu_sample16 *dp = line.get_buf16(); if (line.is_absolute()) { // 16-bit absolute integers @@ -177,7 +177,7 @@ bool LLKDUMemIn::get(int comp_idx, kdu_line_buf &line, int x_tnum) dp->ival = (((kdu_int16)(*sp)) - 128) << (KDU_FIX_POINT-8); } } - } + } scan->next_x_tnum++; if (idx == (num_components-1)) diff --git a/indra/llkdu/llkdumem.h b/indra/llkdu/llkdumem.h index 7064de4408..9d923fc367 100644 --- a/indra/llkdu/llkdumem.h +++ b/indra/llkdu/llkdumem.h @@ -39,7 +39,7 @@ class LLKDUMemSource: public kdu_compressed_source { -public: // Member functions +public: LLKDUMemSource(U8 *input_buffer, U32 size) { mData = input_buffer; @@ -47,11 +47,11 @@ public: // Member functions mCurPos = 0; } - ~LLKDUMemSource() + ~LLKDUMemSource() { } - int read(kdu_byte *buf, int num_bytes) + int read(kdu_byte *buf, int num_bytes) { U32 num_out; num_out = num_bytes; @@ -70,7 +70,7 @@ public: // Member functions mCurPos = 0; } -private: // Data +private: U8 *mData; U32 mSize; U32 mCurPos; @@ -78,7 +78,7 @@ private: // Data class LLKDUMemTarget: public kdu_compressed_target { -public: // Member functions +public: LLKDUMemTarget(U8 *output_buffer, U32 &output_size, const U32 buffer_size) { mData = output_buffer; @@ -87,11 +87,11 @@ public: // Member functions mOutputSize = &output_size; } - ~LLKDUMemTarget() - { + ~LLKDUMemTarget() + { } - bool write(const kdu_byte *buf, int num_bytes) + bool write(const kdu_byte *buf, int num_bytes) { U32 num_out; num_out = num_bytes; @@ -108,7 +108,7 @@ public: // Member functions return true; } -private: // Data +private: U8 *mData; U32 mSize; U32 mCurPos; @@ -117,27 +117,27 @@ private: // Data class LLKDUMemIn : public kdu_image_in_base { -public: // Member functions - LLKDUMemIn(const U8 *data, +public: + LLKDUMemIn(const U8 *data, const U32 size, const U16 rows, const U16 cols, U8 in_num_components, siz_params *siz); - ~LLKDUMemIn(); + ~LLKDUMemIn(); - bool get(int comp_idx, kdu_line_buf &line, int x_tnum); + bool get(int comp_idx, kdu_line_buf &line, int x_tnum); -private: // Data +private: const U8 *mData; - int first_comp_idx; - int num_components; - int rows, cols; - int alignment_bytes; // Number of 0's at end of each line. - int precision[3]; - image_line_buf *incomplete_lines; // Each "sample" represents a full pixel - image_line_buf *free_lines; - int num_unread_rows; + int first_comp_idx; + int num_components; + int rows, cols; + int alignment_bytes; // Number of 0's at end of each line. + int precision[3]; + image_line_buf *incomplete_lines; // Each "sample" represents a full pixel + image_line_buf *free_lines; + int num_unread_rows; U32 mCurPos; U32 mDataSize; -- cgit v1.2.3 From 83ec0cd62f70888c90671ea91cd056ecb6095bc1 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 4 Apr 2011 18:37:32 -0700 Subject: STORM-746 : add new arguments for precincts and blocks on output, region and level on input, add code for input loading restriction --- .../llimage_libtest/llimage_libtest.cpp | 126 +++++++++++++++++++-- indra/llimage/llimagej2c.cpp | 7 ++ indra/llimage/llimagej2c.h | 2 + indra/llimagej2coj/llimagej2coj.cpp | 5 + indra/llimagej2coj/llimagej2coj.h | 1 + indra/llkdu/llimagej2ckdu.cpp | 38 ++++--- indra/llkdu/llimagej2ckdu.h | 3 +- 7 files changed, 161 insertions(+), 21 deletions(-) (limited to 'indra') 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 OR \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 \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" +" 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" +" 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" +" 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 \n" " Log performance data for . Results in .slp\n" " Note: so far, only ImageCompressionTester has been tested.\n" -" -r, --analyzeperformance\n" +" -a, --analyzeperformance\n" " Create a report comparing _baseline.slp with current .slp\n" -" Results in _report.csv" +" Results in _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 image, const std::string &fi } // Load an image from file and return a raw (decompressed) instance of its data -LLPointer load_image(const std::string &src_filename, bool output_stats) +LLPointer load_image(const std::string &src_filename, bool output_stats, bool use_discard_level, int discard_level, bool use_region, int* region) { LLPointer 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 load_image(const std::string &src_filename, bool output_st } LLPointer 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 input_filenames; std::list 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 with -r) -> exit" << std::endl; + std::cout << "Cannot create perf report if no perf gathered (i.e. use argument -log 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 raw_image = load_image(*in_file, image_stats); + LLPointer 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; diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 80fec7f8a0..6b49f3de88 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -139,6 +139,10 @@ BOOL LLImageJ2C::updateData() return res; } +BOOL LLImageJ2C::initDecode(LLImageRaw &raw_image, int discard_level, int* region) +{ + return mImpl->initDecode(*this,raw_image,discard_level,region); +} BOOL LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time) { @@ -251,6 +255,9 @@ S32 LLImageJ2C::calcHeaderSizeJ2C() //static S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate) { + // Note: this only provides an *estimate* of the size in bytes of an image level + // *TODO: find a way to read the true size (when available) and convey the fact + // that the result is an estimate in the other cases if (rate <= 0.f) rate = .125f; while (discard_level > 0) { diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index dd5bec8b2e..7af1c13921 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -56,6 +56,7 @@ public: /*virtual*/ void resetLastError(); /*virtual*/ void setLastError(const std::string& message, const std::string& filename = std::string()); + BOOL initDecode(LLImageRaw &raw_image, int discard_level, int* region); // Encode with comment text BOOL encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time=0.0); @@ -117,6 +118,7 @@ protected: virtual BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count) = 0; virtual BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0, BOOL reversible=FALSE) = 0; + virtual BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL) = 0; friend class LLImageJ2C; }; diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index 13b12c0928..11c826e41a 100644 --- a/indra/llimagej2coj/llimagej2coj.cpp +++ b/indra/llimagej2coj/llimagej2coj.cpp @@ -107,6 +107,11 @@ LLImageJ2COJ::~LLImageJ2COJ() { } +BOOL LLImageJ2COJ::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level, int* region) +{ + // No specific implementaion for this method in the OpenJpeg case + return FALSE; +} BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count) { diff --git a/indra/llimagej2coj/llimagej2coj.h b/indra/llimagej2coj/llimagej2coj.h index 9476665ccb..d5f2f7a2d1 100644 --- a/indra/llimagej2coj/llimagej2coj.h +++ b/indra/llimagej2coj/llimagej2coj.h @@ -39,6 +39,7 @@ protected: /*virtual*/ BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count); /*virtual*/ BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0, BOOL reversible = FALSE); + /*virtual*/ BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL); }; #endif diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 61b16c80e6..e51cfee6eb 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -106,7 +106,11 @@ const char* fallbackEngineInfoLLImageJ2CImpl() class LLKDUDecodeState { public: + LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap); + ~LLKDUDecodeState(); + BOOL processTileDecode(F32 decode_time, BOOL limit_time = TRUE); +private: S32 mNumComponents; BOOL mUseYCC; kdu_dims mDims; @@ -116,20 +120,10 @@ public: kdu_pull_ifc mEngines[4]; bool mReversible[4]; // Some components may be reversible and others not int mBitDepths[4]; // Original bit-depth may be quite different from 8 - + kdu_tile mTile; kdu_byte *mBuf; S32 mRowGap; - - LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap); - ~LLKDUDecodeState(); - BOOL processTileDecode(F32 decode_time, BOOL limit_time = TRUE); - -public: - int *AssignLayerBytes(siz_params *siz, int &num_specs); - - void setupCodeStream(BOOL keep_codestream, LLImageJ2CKDU::ECodeStreamMode mode); - BOOL initDecode(LLImageRaw &raw_image, F32 decode_time, LLImageJ2CKDU::ECodeStreamMode mode, S32 first_channel, S32 max_channel_count ); }; void ll_kdu_error( void ) @@ -327,7 +321,12 @@ void LLImageJ2CKDU::cleanupCodeStream() mTileIndicesp = NULL; } -BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count ) +BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level, int* region) +{ + return initDecode(base,raw_image,0.0f,MODE_FAST,0,4,discard_level,region); +} + +BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level, int* region) { base.resetLastError(); @@ -340,7 +339,20 @@ BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco mRawImagep = &raw_image; mCodeStreamp->change_appearance(false, true, false); - mCodeStreamp->apply_input_restrictions(first_channel,max_channel_count,base.getRawDiscardLevel(),0,NULL); + + // Apply loading discard level and cropping if required + kdu_dims* region_kdu = NULL; + if (region != NULL) + { + region_kdu = new kdu_dims; + region_kdu->pos.x = region[0]; + region_kdu->pos.y = region[1]; + region_kdu->size.x = region[2] - region[0]; + region_kdu->size.y = region[3] - region[1]; + } + int discard = (discard_level != -1 ? discard_level : base.getRawDiscardLevel()); + + mCodeStreamp->apply_input_restrictions( first_channel, max_channel_count, discard, 0, region_kdu); kdu_dims dims; mCodeStreamp->get_dims(0,dims); S32 channels = base.getComponents() - first_channel; diff --git a/indra/llkdu/llimagej2ckdu.h b/indra/llkdu/llimagej2ckdu.h index 5628f69eeb..8231004f2c 100644 --- a/indra/llkdu/llimagej2ckdu.h +++ b/indra/llkdu/llimagej2ckdu.h @@ -58,11 +58,12 @@ protected: /*virtual*/ BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count); /*virtual*/ BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0, BOOL reversible=FALSE); + /*virtual*/ BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL); private: + BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level = -1, int* region = NULL); void setupCodeStream(LLImageJ2C &base, BOOL keep_codestream, ECodeStreamMode mode); void cleanupCodeStream(); - BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count ); // Encode variable LLKDUMemSource *mInputp; -- cgit v1.2.3 From e752e918283acf95c1ed33d92a7bf34bbca83071 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 4 Apr 2011 23:49:40 -0700 Subject: STORM-746 : add precincts and blocks arguments taken into account in j2c output --- .../llimage_libtest/llimage_libtest.cpp | 50 +++++++++++----------- indra/llimage/llimagej2c.cpp | 5 +++ indra/llimage/llimagej2c.h | 2 + indra/llimagej2coj/llimagej2coj.cpp | 8 +++- indra/llimagej2coj/llimagej2coj.h | 1 + indra/llkdu/llimagej2ckdu.cpp | 34 +++++++++++++-- indra/llkdu/llimagej2ckdu.h | 3 ++ 7 files changed, 74 insertions(+), 29 deletions(-) (limited to 'indra') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 10d6ffb685..31d3e18877 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -126,7 +126,7 @@ void output_image_stats(LLPointer image, const std::string &fi } // Load an image from file and return a raw (decompressed) instance of its data -LLPointer load_image(const std::string &src_filename, bool output_stats, bool use_discard_level, int discard_level, bool use_region, int* region) +LLPointer load_image(const std::string &src_filename, int discard_level, int* region, bool output_stats) { LLPointer image = create_image(src_filename); @@ -150,13 +150,11 @@ LLPointer load_image(const std::string &src_filename, bool output_st LLPointer 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)) + if ((image->getCodec() == IMG_CODEC_J2C) && ((discard_level != -1) || (region != NULL))) { - 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); + ((LLImageJ2C*)(image.get()))->initDecode(*raw_image, discard_level, region); } if (!image->decode(raw_image, 0.0f)) @@ -168,10 +166,18 @@ LLPointer load_image(const std::string &src_filename, bool output_st } // Save a raw image instance into a file -bool save_image(const std::string &dest_filename, LLPointer raw_image, bool output_stats) +bool save_image(const std::string &dest_filename, LLPointer raw_image, int blocks_size, int precincts_size, bool output_stats) { LLPointer image = create_image(dest_filename); + // Set the image restriction on load in the case of a j2c image + if ((image->getCodec() == IMG_CODEC_J2C) && ((blocks_size != -1) || (precincts_size != -1))) + { + // 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()))->initEncode(*raw_image, blocks_size, precincts_size); + } + if (!image->encode(raw_image, 0.0f)) { return false; @@ -311,14 +317,10 @@ int main(int argc, char** argv) // 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; + int* region = NULL; + int discard_level = -1; + int precincts_size = -1; + int blocks_size = -1; // Init whatever is necessary ll_init_apr(); @@ -364,6 +366,7 @@ int main(int argc, char** argv) { std::string value_str = argv[arg+1]; int index = 0; + region = new int[4]; while (value_str[0] != '-') // if arg starts with '-', it's the next option { int value = atoi(value_str.c_str()); @@ -375,13 +378,11 @@ int main(int argc, char** argv) break; value_str = argv[arg+1]; // Next argument and loop over } - if (index == 4) - { - use_region = true; - } - else + if (index != 4) { std::cout << "--region arguments invalid" << std::endl; + delete [] region; + region = NULL; } } else if (!strcmp(argv[arg], "--discard_level") || !strcmp(argv[arg], "-d")) @@ -397,8 +398,9 @@ int main(int argc, char** argv) } else { - use_discard_level = true; discard_level = atoi(value_str.c_str()); + // Clamp to the values accepted by the viewer + discard_level = llclamp(discard_level,0,5); } } else if (!strcmp(argv[arg], "--precincts") || !strcmp(argv[arg], "-p")) @@ -414,8 +416,8 @@ int main(int argc, char** argv) } else { - use_precincts = true; precincts_size = atoi(value_str.c_str()); + // *TODO: make sure precincts_size is a power of 2 } } else if (!strcmp(argv[arg], "--blocks") || !strcmp(argv[arg], "-b")) @@ -431,8 +433,8 @@ int main(int argc, char** argv) } else { - use_blocks = true; blocks_size = atoi(value_str.c_str()); + // *TODO: make sure blocks_size is a power of 2 } } else if (!strcmp(argv[arg], "--logmetrics") || !strcmp(argv[arg], "-log")) @@ -497,7 +499,7 @@ int main(int argc, char** argv) for (; in_file != in_end; ++in_file) { // Load file - LLPointer raw_image = load_image(*in_file, image_stats, use_discard_level, discard_level, use_region, region); + LLPointer raw_image = load_image(*in_file, discard_level, region, image_stats); if (!raw_image) { std::cout << "Error: Image " << *in_file << " could not be loaded" << std::endl; @@ -507,7 +509,7 @@ int main(int argc, char** argv) // Save file if (out_file != out_end) { - if (!save_image(*out_file, raw_image, image_stats)) + if (!save_image(*out_file, raw_image, blocks_size, precincts_size, image_stats)) { std::cout << "Error: Image " << *out_file << " could not be saved" << std::endl; } diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 6b49f3de88..a90df0f1c1 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -144,6 +144,11 @@ BOOL LLImageJ2C::initDecode(LLImageRaw &raw_image, int discard_level, int* regio return mImpl->initDecode(*this,raw_image,discard_level,region); } +BOOL LLImageJ2C::initEncode(LLImageRaw &raw_image, int blocks_size, int precincts_size) +{ + return mImpl->initEncode(*this,raw_image,blocks_size,precincts_size); +} + BOOL LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time) { return decodeChannels(raw_imagep, decode_time, 0, 4); diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index 7af1c13921..6bba81aab5 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -57,6 +57,7 @@ public: /*virtual*/ void setLastError(const std::string& message, const std::string& filename = std::string()); BOOL initDecode(LLImageRaw &raw_image, int discard_level, int* region); + BOOL initEncode(LLImageRaw &raw_image, int blocks_size, int precincts_size); // Encode with comment text BOOL encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time=0.0); @@ -119,6 +120,7 @@ protected: virtual BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0, BOOL reversible=FALSE) = 0; virtual BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL) = 0; + virtual BOOL initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size = -1, int precincts_size = -1) = 0; friend class LLImageJ2C; }; diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index 11c826e41a..8288fa1f5c 100644 --- a/indra/llimagej2coj/llimagej2coj.cpp +++ b/indra/llimagej2coj/llimagej2coj.cpp @@ -109,7 +109,13 @@ LLImageJ2COJ::~LLImageJ2COJ() BOOL LLImageJ2COJ::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level, int* region) { - // No specific implementaion for this method in the OpenJpeg case + // No specific implementation for this method in the OpenJpeg case + return FALSE; +} + +BOOL LLImageJ2COJ::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size, int precincts_size) +{ + // No specific implementation for this method in the OpenJpeg case return FALSE; } diff --git a/indra/llimagej2coj/llimagej2coj.h b/indra/llimagej2coj/llimagej2coj.h index d5f2f7a2d1..9c7cc09fcb 100644 --- a/indra/llimagej2coj/llimagej2coj.h +++ b/indra/llimagej2coj/llimagej2coj.h @@ -40,6 +40,7 @@ protected: /*virtual*/ BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0, BOOL reversible = FALSE); /*virtual*/ BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL); + /*virtual*/ BOOL initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size = -1, int precincts_size = -1); }; #endif diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index e51cfee6eb..8d2ed8f8c4 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -190,7 +190,9 @@ mCodeStreamp(NULL), mTPosp(NULL), mTileIndicesp(NULL), mRawImagep(NULL), -mDecodeState(NULL) +mDecodeState(NULL), +mBlocksSize(-1), +mPrecinctsSize(-1) { } @@ -326,6 +328,13 @@ BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int disc return initDecode(base,raw_image,0.0f,MODE_FAST,0,4,discard_level,region); } +BOOL LLImageJ2CKDU::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size, int precincts_size) +{ + mBlocksSize = blocks_size; + mPrecinctsSize = precincts_size; + return TRUE; +} + BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level, int* region) { base.resetLastError(); @@ -623,9 +632,26 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co } } - // *TODO : Add precinct specification here - //std::string precincts_string = llformat("Cprecincts={128,128}"); - //codestream.access_siz()->parse_string(precincts_string.c_str()); + // Set up data ordering, markers, etc... if precincts or blocks specified + if ((mBlocksSize != -1) || (mPrecinctsSize != -1)) + { + if (mPrecinctsSize != -1) + { + std::string precincts_string = llformat("Cprecincts={%d,%d}",mPrecinctsSize,mPrecinctsSize); + codestream.access_siz()->parse_string(precincts_string.c_str()); + } + if (mBlocksSize != -1) + { + std::string blocks_string = llformat("Cblk={%d,%d}",mBlocksSize,mBlocksSize); + codestream.access_siz()->parse_string(blocks_string.c_str()); + } + std::string ordering_string = llformat("Corder=RPCL"); + codestream.access_siz()->parse_string(ordering_string.c_str()); + std::string PLT_string = llformat("ORGgen_plt=yes"); + codestream.access_siz()->parse_string(PLT_string.c_str()); + std::string Parts_string = llformat("ORGtparts=R"); + codestream.access_siz()->parse_string(Parts_string.c_str()); + } codestream.access_siz()->finalize_all(); codestream.change_appearance(transpose,vflip,hflip); diff --git a/indra/llkdu/llimagej2ckdu.h b/indra/llkdu/llimagej2ckdu.h index 8231004f2c..9fce58b762 100644 --- a/indra/llkdu/llimagej2ckdu.h +++ b/indra/llkdu/llimagej2ckdu.h @@ -59,6 +59,7 @@ protected: /*virtual*/ BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0, BOOL reversible=FALSE); /*virtual*/ BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, int discard_level = -1, int* region = NULL); + /*virtual*/ BOOL initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int blocks_size = -1, int precincts_size = -1); private: BOOL initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level = -1, int* region = NULL); @@ -70,6 +71,8 @@ private: kdu_codestream *mCodeStreamp; kdu_coords *mTPosp; // tile position kdu_dims *mTileIndicesp; + int mBlocksSize; + int mPrecinctsSize; // Temporary variables for in-progress decodes... LLImageRaw *mRawImagep; -- cgit v1.2.3 From 379e2e138d801ebf7f13d29512f76298aacf3dc5 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 7 Apr 2011 16:41:57 -0700 Subject: STORM-746 : Fix bug in performance report output --- .../llimage_libtest/llimage_libtest.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 31d3e18877..1466e44324 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -521,25 +521,25 @@ int main(int argc, char** argv) } } - // Stop the perf gathering system if needed - if (LLFastTimer::sMetricLog) - { - LLMetricPerformanceTesterBasic::deleteTester(LLFastTimer::sLogName); - sAllDone = true; - } - // Output perf data if requested by user if (analyze_performance) { - std::cout << "Analyzing performance" << std::endl; - std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp"; std::string current_name = LLFastTimer::sLogName + ".slp"; std::string report_name = LLFastTimer::sLogName + "_report.csv"; + std::cout << "Analyzing performance, check report in : " << report_name << std::endl; + LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline_name, current_name, report_name); } + // Stop the perf gathering system if needed + if (LLFastTimer::sMetricLog) + { + LLMetricPerformanceTesterBasic::deleteTester(LLFastTimer::sLogName); + sAllDone = true; + } + // Cleanup and exit LLImage::cleanupClass(); if (fast_timer_log_thread) -- cgit v1.2.3 From cd363e8c87e176776f5db8fbaf60c264eabdaa3b Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 7 Apr 2011 17:26:10 -0700 Subject: STORM-746 : Clean up typos in comments --- .../integration_tests/llimage_libtest/llimage_libtest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'indra') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 1466e44324..feb63e161d 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -54,20 +54,21 @@ static const char USAGE[] = "\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 \n" -" Crop region on the input file in pixel.\n" +" Crop region applied to the input files in pixels.\n" " Only used for j2c images. Default is no region cropping.\n" " -d, --discard_level \n" -" Discard level max used on input. 0 is high resolution. Max discard level is 5.\n" +" Discard level max used on input. 0 is highest 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" " 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" +" all levels. Note that this option also add PLT and tile markers to the codestream, \n" +" and uses RPCL order. Power of 2 must be used.\n" " Only valid for output j2c images. Default is no precincts used.\n" " -b, --blocks \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" +" be used. Blocks must be smaller than precincts. Like precincts, this option adds\n" +" PLT, tile markers and uses RPCL.\n" " Only valid for output j2c images. Default is 64.\n" " -log, --logmetrics \n" " Log performance data for . Results in .slp\n" @@ -130,7 +131,7 @@ LLPointer load_image(const std::string &src_filename, int discard_le { LLPointer image = create_image(src_filename); - // This just load the image file stream into a buffer. No decoding done. + // This just loads the image file stream into a buffer. No decoding done. if (!image->load(src_filename)) { return NULL; @@ -170,7 +171,7 @@ bool save_image(const std::string &dest_filename, LLPointer raw_imag { LLPointer image = create_image(dest_filename); - // Set the image restriction on load in the case of a j2c image + // Set the image codestream parameters on output in the case of a j2c image if ((image->getCodec() == IMG_CODEC_J2C) && ((blocks_size != -1) || (precincts_size != -1))) { // That method doesn't exist (and likely, doesn't make sense) for any other image file format -- cgit v1.2.3 From 505e5e403d6439f29d60861553656d01522cb241 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 12 Apr 2011 16:06:24 -0700 Subject: EXP-681 : Add MEDIA_EVENT_NAVIGATE_ERROR_PAGE case in LLMediaPluginTest so to pass build on Mac --- indra/test_apps/llplugintest/llmediaplugintest.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra') diff --git a/indra/test_apps/llplugintest/llmediaplugintest.cpp b/indra/test_apps/llplugintest/llmediaplugintest.cpp index e9d4d99753..ee65e0aa87 100644 --- a/indra/test_apps/llplugintest/llmediaplugintest.cpp +++ b/indra/test_apps/llplugintest/llmediaplugintest.cpp @@ -2154,6 +2154,10 @@ void LLMediaPluginTest::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e } break; + case MEDIA_EVENT_NAVIGATE_ERROR_PAGE: + std::cerr << "Media event: MEDIA_EVENT_NAVIGATE_ERROR_PAGE, uri is: " << self->getClickURL() << std::endl; + break; + case MEDIA_EVENT_CLICK_LINK_HREF: { std::cerr << "Media event: MEDIA_EVENT_CLICK_LINK_HREF, uri is " << self->getClickURL() << ", target is " << self->getClickTarget() << std::endl; -- cgit v1.2.3 From 759d72a46c5d487e6881426f90c54c6ae2da4847 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 13 Apr 2011 14:05:31 -0700 Subject: EXP-669 : Refactor code to use correct LLImageFormatted methods to load images of all formats, reviewed by richard --- .../llimage_libtest/llimage_libtest.cpp | 27 +---- indra/llimage/llimage.cpp | 23 +--- indra/newview/llfloaterimagepreview.cpp | 119 +++++---------------- indra/newview/llviewermenufile.cpp | 55 +--------- indra/newview/llviewertexturelist.cpp | 110 +++++-------------- 5 files changed, 59 insertions(+), 275 deletions(-) (limited to 'indra') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 365f5f758c..03a79532c8 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -69,31 +69,8 @@ static bool sAllDone = false; // Create an empty formatted image instance of the correct type from the filename LLPointer create_image(const std::string &filename) { - std::string exten = gDirUtilp->getExtension(filename); - U32 codec = LLImageBase::getCodecFromExtension(exten); - - LLPointer image; - switch (codec) - { - case IMG_CODEC_BMP: - image = new LLImageBMP(); - break; - case IMG_CODEC_TGA: - image = new LLImageTGA(); - break; - case IMG_CODEC_JPEG: - image = new LLImageJPEG(); - break; - case IMG_CODEC_J2C: - image = new LLImageJ2C(); - break; - case IMG_CODEC_PNG: - image = new LLImagePNG(); - break; - default: - return NULL; - } - + std::string exten = gDirUtilp->getExtension(filename); + LLPointer image = LLImageFormatted::createFromExtension(exten); return image; } diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 39211bf7fa..f0d15d9607 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -1254,28 +1254,7 @@ bool LLImageRaw::createFromFile(const std::string &filename, bool j2c_lowest_mip return false; } - LLPointer image; - switch(codec) - { - //case IMG_CODEC_RGB: - case IMG_CODEC_BMP: - image = new LLImageBMP(); - break; - case IMG_CODEC_TGA: - image = new LLImageTGA(); - break; - case IMG_CODEC_JPEG: - image = new LLImageJPEG(); - break; - case IMG_CODEC_J2C: - image = new LLImageJ2C(); - break; - case IMG_CODEC_DXT: - image = new LLImageDXT(); - break; - default: - return false; - } + LLPointer image = LLImageFormatted::createFromType(codec); llassert(image.notNull()); U8 *buffer = image->allocateData(length); diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index c7fbdd5745..d76e7885bc 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -325,122 +325,51 @@ void LLFloaterImagePreview::draw() bool LLFloaterImagePreview::loadImage(const std::string& src_filename) { std::string exten = gDirUtilp->getExtension(src_filename); - - U32 codec = IMG_CODEC_INVALID; - std::string temp_str; - if( exten == "bmp") - { - codec = IMG_CODEC_BMP; - } - else if( exten == "tga") - { - codec = IMG_CODEC_TGA; - } - else if( exten == "jpg" || exten == "jpeg") - { - codec = IMG_CODEC_JPEG; - } - else if( exten == "png" ) - { - codec = IMG_CODEC_PNG; - } + U32 codec = LLImageBase::getCodecFromExtension(exten); LLImageDimensionsInfo image_info; - if(!image_info.load(src_filename,codec)) + if (!image_info.load(src_filename,codec)) { mImageLoadError = image_info.getLastError(); return false; } S32 max_width = gSavedSettings.getS32("max_texture_dimension_X"); - S32 max_heigh = gSavedSettings.getS32("max_texture_dimension_Y"); + S32 max_height = gSavedSettings.getS32("max_texture_dimension_Y"); - if(image_info.getWidth() > max_width|| image_info.getHeight() > max_heigh) + if ((image_info.getWidth() > max_width) || (image_info.getHeight() > max_height)) { LLStringUtil::format_map_t args; args["WIDTH"] = llformat("%d", max_width); - args["HEIGHT"] = llformat("%d", max_heigh); + args["HEIGHT"] = llformat("%d", max_height); mImageLoadError = LLTrans::getString("texture_load_dimensions_error", args); return false; } - + // Load the image + LLPointer image = LLImageFormatted::createFromType(codec); + if (image.isNull()) + { + return false; + } + if (!image->load(src_filename)) + { + return false; + } + // Decompress or expand it in a raw image structure LLPointer raw_image = new LLImageRaw; - - switch (codec) + if (!image->decode(raw_image, 0.0f)) { - case IMG_CODEC_BMP: - { - LLPointer bmp_image = new LLImageBMP; - - if (!bmp_image->load(src_filename)) - { - return false; - } - - if (!bmp_image->decode(raw_image, 0.0f)) - { - return false; - } - } - break; - case IMG_CODEC_TGA: - { - LLPointer tga_image = new LLImageTGA; - - if (!tga_image->load(src_filename)) - { - return false; - } - - if (!tga_image->decode(raw_image)) - { - return false; - } - - if( (tga_image->getComponents() != 3) && - (tga_image->getComponents() != 4) ) - { - tga_image->setLastError( "Image files with less than 3 or more than 4 components are not supported." ); - return false; - } - } - break; - case IMG_CODEC_JPEG: - { - LLPointer jpeg_image = new LLImageJPEG; - - if (!jpeg_image->load(src_filename)) - { - return false; - } - - if (!jpeg_image->decode(raw_image, 0.0f)) - { - return false; - } - } - break; - case IMG_CODEC_PNG: - { - LLPointer png_image = new LLImagePNG; - - if (!png_image->load(src_filename)) - { - return false; - } - - if (!png_image->decode(raw_image, 0.0f)) - { - return false; - } - } - break; - default: return false; } - + // Check the image constraints + if ((image->getComponents() != 3) && (image->getComponents() != 4)) + { + image->setLastError("Image files with less than 3 or more than 4 components are not supported."); + return false; + } + raw_image->biasedScaleToPowerOfTwo(1024); mRawImagep = raw_image; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index fda291f3c1..2cf8dbec89 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -493,6 +493,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, LLSD args; std::string exten = gDirUtilp->getExtension(src_filename); + U32 codec = LLImageBase::getCodecFromExtension(exten); LLAssetType::EType asset_type = LLAssetType::AT_NONE; std::string error_message; @@ -510,66 +511,20 @@ void upload_new_resource(const std::string& src_filename, std::string name, upload_error(error_message, "NoFileExtension", filename, args); return; } - else if( exten == "bmp") + else if (codec != IMG_CODEC_INVALID) { + // It's an image file, the upload procedure is the same for all asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerTextureList::createUploadFile(src_filename, - filename, - IMG_CODEC_BMP )) + if (!LLViewerTextureList::createUploadFile(src_filename, filename, codec )) { error_message = llformat( "Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImage::getLastError().c_str()); + src_filename.c_str(), LLImage::getLastError().c_str()); args["FILE"] = src_filename; args["ERROR"] = LLImage::getLastError(); upload_error(error_message, "ProblemWithFile", filename, args); return; } } - else if( exten == "tga") - { - asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerTextureList::createUploadFile(src_filename, - filename, - IMG_CODEC_TGA )) - { - error_message = llformat("Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImage::getLastError().c_str()); - args["FILE"] = src_filename; - args["ERROR"] = LLImage::getLastError(); - upload_error(error_message, "ProblemWithFile", filename, args); - return; - } - } - else if( exten == "jpg" || exten == "jpeg") - { - asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerTextureList::createUploadFile(src_filename, - filename, - IMG_CODEC_JPEG )) - { - error_message = llformat("Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImage::getLastError().c_str()); - args["FILE"] = src_filename; - args["ERROR"] = LLImage::getLastError(); - upload_error(error_message, "ProblemWithFile", filename, args); - return; - } - } - else if( exten == "png") - { - asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerTextureList::createUploadFile(src_filename, - filename, - IMG_CODEC_PNG )) - { - error_message = llformat("Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImage::getLastError().c_str()); - args["FILE"] = src_filename; - args["ERROR"] = LLImage::getLastError(); - upload_error(error_message, "ProblemWithFile", filename, args); - return; - } - } else if(exten == "wav") { asset_type = LLAssetType::AT_SOUND; // tag it as audio diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 06f6ff23c2..5afed721ac 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -927,99 +927,43 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) BOOL LLViewerTextureList::createUploadFile(const std::string& filename, const std::string& out_filename, const U8 codec) -{ - // First, load the image. +{ + // Load the image + LLPointer image = LLImageFormatted::createFromType(codec); + if (image.isNull()) + { + return FALSE; + } + if (!image->load(filename)) + { + return FALSE; + } + // Decompress or expand it in a raw image structure LLPointer raw_image = new LLImageRaw; - - switch (codec) + if (!image->decode(raw_image, 0.0f)) { - case IMG_CODEC_BMP: - { - LLPointer bmp_image = new LLImageBMP; - - if (!bmp_image->load(filename)) - { - return FALSE; - } - - if (!bmp_image->decode(raw_image, 0.0f)) - { - return FALSE; - } - } - break; - case IMG_CODEC_TGA: - { - LLPointer tga_image = new LLImageTGA; - - if (!tga_image->load(filename)) - { - return FALSE; - } - - if (!tga_image->decode(raw_image)) - { - return FALSE; - } - - if( (tga_image->getComponents() != 3) && - (tga_image->getComponents() != 4) ) - { - tga_image->setLastError( "Image files with less than 3 or more than 4 components are not supported." ); - return FALSE; - } - } - break; - case IMG_CODEC_JPEG: - { - LLPointer jpeg_image = new LLImageJPEG; - - if (!jpeg_image->load(filename)) - { - return FALSE; - } - - if (!jpeg_image->decode(raw_image, 0.0f)) - { - return FALSE; - } - } - break; - case IMG_CODEC_PNG: - { - LLPointer png_image = new LLImagePNG; - - if (!png_image->load(filename)) - { - return FALSE; - } - - if (!png_image->decode(raw_image, 0.0f)) - { - return FALSE; - } - } - break; - default: - return FALSE; + return FALSE; } - - LLPointer compressedImage = convertToUploadFile(raw_image); - - if( !compressedImage->save(out_filename) ) + // Check the image constraints + if ((image->getComponents() != 3) && (image->getComponents() != 4)) { - llinfos << "Couldn't create output file " << out_filename << llendl; + image->setLastError("Image files with less than 3 or more than 4 components are not supported."); return FALSE; } - - // test to see if the encode and save worked. + // Convert to j2c (JPEG2000) and save the file locally + LLPointer compressedImage = convertToUploadFile(raw_image); + if (!compressedImage->save(out_filename)) + { + llinfos << "Couldn't create output file : " << out_filename << llendl; + return FALSE; + } + // Test to see if the encode and save worked LLPointer integrity_test = new LLImageJ2C; - if( !integrity_test->loadAndValidate( out_filename ) ) + if (!integrity_test->loadAndValidate( out_filename )) { - llinfos << "Image: " << out_filename << " is corrupt." << llendl; + llinfos << "Image file : " << out_filename << " is corrupt" << llendl; return FALSE; } - return TRUE; } -- cgit v1.2.3 From 8c7d9bbd064c605b756ebf4752eaefad25ee6f4f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 14 Apr 2011 09:28:34 -0700 Subject: EXP-663 : Fix memory leak introduced in precincts handling --- indra/llkdu/llimagej2ckdu.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 8d2ed8f8c4..5b2c045841 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -361,17 +361,23 @@ BOOL LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco } int discard = (discard_level != -1 ? discard_level : base.getRawDiscardLevel()); + // Apply loading restrictions mCodeStreamp->apply_input_restrictions( first_channel, max_channel_count, discard, 0, region_kdu); + + // Clean-up + if (region_kdu) + { + delete region_kdu; + region_kdu = NULL; + } + // Resize raw_image according to the image to be decoded kdu_dims dims; mCodeStreamp->get_dims(0,dims); S32 channels = base.getComponents() - first_channel; - if (channels > max_channel_count) - { - channels = max_channel_count; - } + channels = llmin(channels,max_channel_count); raw_image.resize(dims.size.x, dims.size.y, channels); + // llinfos << "Resizing raw_image to " << dims.size.x << ":" << dims.size.y << llendl; - // llinfos << "Resizing to " << dims.size.x << ":" << dims.size.y << llendl; if (!mTileIndicesp) { mTileIndicesp = new kdu_dims; -- cgit v1.2.3 From 6f6cebbf5dc37b36c9875b2620259541f5f60aca Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 15 Apr 2011 17:53:16 -0700 Subject: EXP-672, EXP-673 : Fix bug in encoding small textures (16x16 and under) --- .../llimage_libtest/llimage_libtest.cpp | 23 ++++++++++++++++------ indra/llkdu/llimagej2ckdu.cpp | 23 +++++++++------------- 2 files changed, 26 insertions(+), 20 deletions(-) (limited to 'indra') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 0151016862..60ddf63b21 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -70,6 +70,9 @@ static const char USAGE[] = "\n" " be used. Blocks must be smaller than precincts. Like precincts, this option adds\n" " PLT, tile markers and uses RPCL.\n" " Only valid for output j2c images. Default is 64.\n" +" -rev, --reversible\n" +" Set the compression to be lossless (reversible in j2c parlance).\n" +" Only valid for output j2c images.\n" " -log, --logmetrics \n" " Log performance data for . Results in .slp\n" " Note: so far, only ImageCompressionTester has been tested.\n" @@ -144,16 +147,20 @@ LLPointer load_image(const std::string &src_filename, int discard_le } // Save a raw image instance into a file -bool save_image(const std::string &dest_filename, LLPointer raw_image, int blocks_size, int precincts_size, bool output_stats) +bool save_image(const std::string &dest_filename, LLPointer raw_image, int blocks_size, int precincts_size, bool reversible, bool output_stats) { LLPointer image = create_image(dest_filename); // Set the image codestream parameters on output in the case of a j2c image - if ((image->getCodec() == IMG_CODEC_J2C) && ((blocks_size != -1) || (precincts_size != -1))) + if (image->getCodec() == IMG_CODEC_J2C) { // 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()))->initEncode(*raw_image, blocks_size, precincts_size); + if ((blocks_size != -1) || (precincts_size != -1)) + { + ((LLImageJ2C*)(image.get()))->initEncode(*raw_image, blocks_size, precincts_size); + } + ((LLImageJ2C*)(image.get()))->setReversible(reversible); } if (!image->encode(raw_image, 0.0f)) @@ -299,6 +306,7 @@ int main(int argc, char** argv) int discard_level = -1; int precincts_size = -1; int blocks_size = -1; + bool reversible = false; // Init whatever is necessary ll_init_apr(); @@ -415,6 +423,10 @@ int main(int argc, char** argv) // *TODO: make sure blocks_size is a power of 2 } } + else if (!strcmp(argv[arg], "--reversible") || !strcmp(argv[arg], "-rev")) + { + reversible = true; + } else if (!strcmp(argv[arg], "--logmetrics") || !strcmp(argv[arg], "-log")) { // '--logmetrics' needs to be specified with a named test metric argument @@ -474,7 +486,7 @@ int main(int argc, char** argv) std::list::iterator out_file = output_filenames.begin(); std::list::iterator in_end = input_filenames.end(); std::list::iterator out_end = output_filenames.end(); - for (; in_file != in_end; ++in_file) + for (; in_file != in_end; ++in_file, ++out_file) { // Load file LLPointer raw_image = load_image(*in_file, discard_level, region, image_stats); @@ -487,7 +499,7 @@ int main(int argc, char** argv) // Save file if (out_file != out_end) { - if (!save_image(*out_file, raw_image, blocks_size, precincts_size, image_stats)) + if (!save_image(*out_file, raw_image, blocks_size, precincts_size, reversible, image_stats)) { std::cout << "Error: Image " << *out_file << " could not be saved" << std::endl; } @@ -495,7 +507,6 @@ int main(int argc, char** argv) { std::cout << *in_file << " -> " << *out_file << std::endl; } - ++out_file; } } diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 5b2c045841..ae456a48be 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -545,18 +545,10 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co // Construct the `kdu_codestream' object and parse all remaining arguments U32 max_output_size = base.getWidth()*base.getHeight()*base.getComponents(); - if (max_output_size < 1000) - { - max_output_size = 1000; - } + max_output_size = (max_output_size < 1000 ? 1000 : max_output_size); U8 *output_buffer = new U8[max_output_size]; - - U32 output_size = max_output_size; // gets modified - LLKDUMemTarget output(output_buffer, output_size, base.getWidth()*base.getHeight()*base.getComponents()); - if (output_size > max_output_size) - { - llerrs << llformat("LLImageJ2C::encode output_size(%d) > max_output_size(%d)", output_size,max_output_size) << llendl; - } + U32 output_size = 0; // Address updated by LLKDUMemTarget to give the final compressed buffer size + LLKDUMemTarget output(output_buffer, output_size, max_output_size); kdu_codestream codestream; codestream.create(&transformed_siz,&output); @@ -583,10 +575,13 @@ BOOL LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co if (reversible) { - // If we're doing reversible (i.e. lossless compression), assumes we're not using quality layers. - // Yes, I know this is incorrect! - // *TODO: Indeed, this is incorrect and unecessary... Try using the regular layer setting... codestream.access_siz()->parse_string("Creversible=yes"); + // *TODO: we should use yuv in reversible mode and one level since those images are small. + // Don't turn this on now though as both create problems on decoding for the moment + //codestream.access_siz()->parse_string("Clevels=1"); + //codestream.access_siz()->parse_string("Cycc=no"); + // If we're doing reversible (i.e. lossless compression), assumes we're not using quality layers. + // *TODO: this is incorrect and unecessary. Try using the regular layer setting. codestream.access_siz()->parse_string("Clayers=1"); num_layer_specs = 1; layer_bytes[0] = 0; -- cgit v1.2.3 From 09594214f5eb7c41f69d2db7b735f05fd59140b1 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Fri, 15 Apr 2011 18:11:04 -0700 Subject: EXP-679 As a linden executive, I would like to evaluate the success of basic mode against various metrics --- indra/newview/lllogininstance.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'indra') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index abcd8588dc..36c5d12897 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -558,6 +558,18 @@ void LLLoginInstance::constructAuthParams(LLPointer user_credentia requested_options.append("buddy-list"); requested_options.append("newuser-config"); requested_options.append("ui-config"); + + //send this info to login.cgi for stats gathering + //since viewerstats isn't reliable enough + if (gSavedSettings.getString("SessionSettingsFile").empty()) + { + requested_options.append("advanced-mode"); + } + else + { + requested_options.append("basic-mode"); + } + #endif requested_options.append("max-agent-groups"); requested_options.append("map-server-url"); -- cgit v1.2.3 From 8d2943c5ddd08ce7a40d42325206f882c99f497a Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 18 Apr 2011 14:08:29 -0700 Subject: Fixed debug information format for mac to allow breakpoints to work under Xcode. --- indra/cmake/Variables.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake index 77dd34d122..b6710300bb 100644 --- a/indra/cmake/Variables.cmake +++ b/indra/cmake/Variables.cmake @@ -102,7 +102,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5) set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk) set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "4.2") - set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "DWARF with dSYM File") + set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf-with-dsym) # NOTE: To attempt an i386/PPC Universal build, add this on the configure line: # -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc' -- cgit v1.2.3 From 2411a107e717816629817a9f2fe85d3c7cb254ab Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Mon, 18 Apr 2011 14:22:23 -0700 Subject: EXP-628 Inventory floater may be opened by SLApp EXP-630 My appearance floater may be opened by SLApp EXP-633 Search floater can be opened by SLApps --- indra/newview/app_settings/settings.xml | 33 ++++++++++++++++ indra/newview/app_settings/settings_minimal.xml | 33 ++++++++++++++++ indra/newview/llappearancemgr.cpp | 6 +++ indra/newview/llfloatersearch.cpp | 7 ++++ indra/newview/llviewerinventory.cpp | 6 +++ .../newview/skins/default/xui/en/notifications.xml | 44 +++++++++++++++++++++- 6 files changed, 128 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index b602362cd0..f2a0e5ac19 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -12585,6 +12585,39 @@ Boolean Value 1 + + EnableInventory + + Comment + Enable opening inventory from web link + Persist + 1 + Type + Boolean + Value + 1 + + EnableSearch + + Comment + Enable opening search from web link + Persist + 1 + Type + Boolean + Value + 1 + + EnableAppearance + + Comment + Enable opening appearance from web link + Persist + 1 + Type + Boolean + Value + 1 SearchFromAddressBar diff --git a/indra/newview/app_settings/settings_minimal.xml b/indra/newview/app_settings/settings_minimal.xml index 490da2c9d4..bc97ec00e9 100644 --- a/indra/newview/app_settings/settings_minimal.xml +++ b/indra/newview/app_settings/settings_minimal.xml @@ -303,6 +303,39 @@ Value 0 + EnableInventory + + Comment + Enable opening inventory from web link + Persist + 1 + Type + Boolean + Value + 0 + + EnableSearch + + Comment + Enable opening search from web link + Persist + 1 + Type + Boolean + Value + 0 + + EnableAppearance + + Comment + Enable opening appearance from web link + Persist + 1 + Type + Boolean + Value + 0 + DoubleClickShowWorldMap Comment diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 1cf552e42c..f9e850899a 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -110,6 +110,12 @@ public: { // support secondlife:///app/appearance/show, but for now we just // make all secondlife:///app/appearance SLapps behave this way + if (!LLUI::sSettingGroups["config"]->getBOOL("EnableAppearance")) + { + LLNotificationsUtil::add("NoAppearance", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); + return true; + } + LLSideTray::getInstance()->showPanel("sidepanel_appearance", LLSD()); return true; } diff --git a/indra/newview/llfloatersearch.cpp b/indra/newview/llfloatersearch.cpp index 2041fac8d8..d5806e375c 100644 --- a/indra/newview/llfloatersearch.cpp +++ b/indra/newview/llfloatersearch.cpp @@ -31,6 +31,7 @@ #include "llfloaterreg.h" #include "llfloatersearch.h" #include "llmediactrl.h" +#include "llnotificationsutil.h" #include "lllogininstance.h" #include "lluri.h" #include "llagent.h" @@ -46,6 +47,12 @@ public: LLSearchHandler() : LLCommandHandler("search", UNTRUSTED_THROTTLE) { } bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web) { + if (!LLUI::sSettingGroups["config"]->getBOOL("EnableSearch")) + { + LLNotificationsUtil::add("NoSearch", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); + return true; + } + const size_t parts = tokens.size(); // get the (optional) category for the search diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 519514d99c..68011ebf07 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -183,6 +183,12 @@ public: return false; } + if (!LLUI::sSettingGroups["config"]->getBOOL("EnableInventory")) + { + LLNotificationsUtil::add("NoInventory", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); + return true; + } + // support secondlife:///app/inventory/show if (params[0].asString() == "show") { diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 8f5a95a504..cd25a2a8dd 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -7213,7 +7213,49 @@ The site at '<nolink>[HOST_NAME]</nolink>' in realm ' yestext="Quit" notext="Don't Quit"/> - + + + fail + confirm + Viewing inventory is only available in Advanced mode. Would you like to logout and change modes? + + + + + fail + confirm + The appearance editor is only available in Advanced mode. Would you like to logout and change modes? + + + + + fail + confirm + Search is only available in Advanced mode. Would you like to logout and change modes? + + + - Your CPU speed does not meet the minimum requirements. -- cgit v1.2.3 From 64d20b8b745c184464c2a2f0795aeff0124ea3c5 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 19 Apr 2011 11:13:36 -0700 Subject: EXP-631 FIX -- REGRESSION - Clicking people button in Basic mode does not toggle the People panel to close EXP-640 FIX -- [PUBLIC] Ctrl+I doesn't close side tray LLSideTray::hidePanel now checks if the parent is the side tray or if it is a child to a detached tab to determine what panel to attempt to close. Reviewed by Leyla --- indra/newview/llsidetray.cpp | 99 ++++++++++++++++++++++++++++---------------- indra/newview/llsidetray.h | 2 +- 2 files changed, 64 insertions(+), 37 deletions(-) (limited to 'indra') diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index 4f18ee1da2..e4c2293938 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -1192,6 +1192,38 @@ void LLSideTray::reshape(S32 width, S32 height, BOOL called_from_parent) arrange(); } +// This is just LLView::findChildView specialized to restrict the search to LLPanels. +// Optimization for EXT-4068 to avoid searching down to the individual item level +// when inventories are large. +LLPanel *findChildPanel(LLPanel *panel, const std::string& name, bool recurse) +{ + for (LLView::child_list_const_iter_t child_it = panel->beginChild(); + child_it != panel->endChild(); ++child_it) + { + LLPanel *child_panel = dynamic_cast(*child_it); + if (!child_panel) + continue; + if (child_panel->getName() == name) + return child_panel; + } + if (recurse) + { + for (LLView::child_list_const_iter_t child_it = panel->beginChild(); + child_it != panel->endChild(); ++child_it) + { + LLPanel *child_panel = dynamic_cast(*child_it); + if (!child_panel) + continue; + LLPanel *found_panel = findChildPanel(child_panel,name,recurse); + if (found_panel) + { + return found_panel; + } + } + } + return NULL; +} + /** * Activate tab with "panel_name" panel * if no such tab - return false, otherwise true. @@ -1221,23 +1253,50 @@ LLPanel* LLSideTray::showPanel (const std::string& panel_name, const LLSD& para return new_panel; } -void LLSideTray::hidePanel(const std::string& panel_name) +bool LLSideTray::hidePanel(const std::string& panel_name) { + bool panelHidden = false; + LLPanel* panelp = getPanel(panel_name); + if (panelp) { - if(isTabAttached(panel_name)) + LLView* parentp = panelp->getParent(); + + // Collapse the side bar if the panel or the panel's parent is an attached tab + if (isTabAttached(panel_name) || (parentp && isTabAttached(parentp->getName()))) { collapseSideBar(); + panelHidden = true; } else { - LLFloaterReg::hideInstance("side_bar_tab", panel_name); + panelHidden = LLFloaterReg::hideInstance("side_bar_tab", panel_name); + + if (!panelHidden) + { + // Look up the panel in the list of detached tabs. + for (child_vector_const_iter_t child_it = mDetachedTabs.begin(); child_it != mDetachedTabs.end(); ++child_it) + { + LLPanel *detached_panel = dynamic_cast(*child_it); + + if (detached_panel) + { + // Hide this detached panel if it is a parent of our panel + if (findChildPanel(detached_panel, panel_name, true) != NULL) + { + panelHidden = LLFloaterReg::hideInstance("side_bar_tab", detached_panel->getName()); + break; + } + } + } + } } } + + return panelHidden; } - void LLSideTray::togglePanel(LLPanel* &sub_panel, const std::string& panel_name, const LLSD& params) { if(!sub_panel) @@ -1255,38 +1314,6 @@ void LLSideTray::togglePanel(LLPanel* &sub_panel, const std::string& panel_name, } } -// This is just LLView::findChildView specialized to restrict the search to LLPanels. -// Optimization for EXT-4068 to avoid searching down to the individual item level -// when inventories are large. -LLPanel *findChildPanel(LLPanel *panel, const std::string& name, bool recurse) -{ - for (LLView::child_list_const_iter_t child_it = panel->beginChild(); - child_it != panel->endChild(); ++child_it) - { - LLPanel *child_panel = dynamic_cast(*child_it); - if (!child_panel) - continue; - if (child_panel->getName() == name) - return child_panel; - } - if (recurse) - { - for (LLView::child_list_const_iter_t child_it = panel->beginChild(); - child_it != panel->endChild(); ++child_it) - { - LLPanel *child_panel = dynamic_cast(*child_it); - if (!child_panel) - continue; - LLPanel *found_panel = findChildPanel(child_panel,name,recurse); - if (found_panel) - { - return found_panel; - } - } - } - return NULL; -} - LLPanel* LLSideTray::getPanel(const std::string& panel_name) { // Look up the panel in the list of detached tabs. diff --git a/indra/newview/llsidetray.h b/indra/newview/llsidetray.h index 1dddd9e9bc..46765bfbcc 100644 --- a/indra/newview/llsidetray.h +++ b/indra/newview/llsidetray.h @@ -104,7 +104,7 @@ public: */ LLPanel* showPanel (const std::string& panel_name, const LLSD& params = LLSD()); - void hidePanel (const std::string& panel_name); + bool hidePanel (const std::string& panel_name); /** * Toggling Side Tray tab which contains "sub_panel" child of "panel_name" panel. -- cgit v1.2.3 From 3f37b76a4a00f0696ea5a3881810bd04eccbba18 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Tue, 19 Apr 2011 13:48:51 -0700 Subject: fixing destination tooltip --- indra/newview/skins/minimal/xui/en/panel_bottomtray.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/skins/minimal/xui/en/panel_bottomtray.xml b/indra/newview/skins/minimal/xui/en/panel_bottomtray.xml index 0145de8be9..a250f95e4f 100644 --- a/indra/newview/skins/minimal/xui/en/panel_bottomtray.xml +++ b/indra/newview/skins/minimal/xui/en/panel_bottomtray.xml @@ -163,7 +163,7 @@ layout="topleft" left="0" name="destination_btn" - tool_tip="Shows people window" + tool_tip="Shows destinations window" top="5" is_toggle="true" use_ellipses="true" -- cgit v1.2.3 From f9cda66629d372fd3453e6244a381c1f60661931 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 19 Apr 2011 14:00:37 -0700 Subject: EXP-728 : Fix crash when taking large unconstrained snapshots + code cleanup --- indra/newview/llviewerwindow.cpp | 154 +++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 78 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8ce15c7dfc..a6404058b0 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3967,7 +3967,9 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p return rawSnapshot(raw, preview_width, preview_height, FALSE, FALSE, show_ui, do_rebuild, type); } -// Saves the image from the screen to the specified filename and path. +// Saves the image from the screen to a raw image +// Since the required size might be bigger than the available screen, this method rerenders the scene in parts (called subimages) and copy +// the results over to the final raw image. BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect, BOOL is_texture, BOOL show_ui, BOOL do_rebuild, ESnapshotType type, S32 max_size) { @@ -3985,8 +3987,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei // Hide all the UI widgets first and draw a frame BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI) ? TRUE : FALSE; - show_ui = show_ui ? TRUE : FALSE; - if ( prev_draw_ui != show_ui) { LLPipeline::toggleRenderDebugFeature((void*)LLPipeline::RENDER_DEBUG_FEATURE_UI); @@ -4006,55 +4006,49 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei // from window LLRect window_rect = show_ui ? getWindowRectRaw() : getWorldViewRectRaw(); - S32 snapshot_width = window_rect.getWidth(); + S32 snapshot_width = window_rect.getWidth(); S32 snapshot_height = window_rect.getHeight(); // SNAPSHOT - S32 window_width = snapshot_width; + S32 window_width = snapshot_width; S32 window_height = snapshot_height; + // Note: Scaling of the UI is currently *not* supported so we limit the output size if UI is requested if (show_ui) { - image_width = llmin(image_width, window_width); + // If the user wants the UI, limit the output size to the available screen size + image_width = llmin(image_width, window_width); image_height = llmin(image_height, window_height); } F32 scale_factor = 1.0f ; - if(!keep_window_aspect) //image cropping - { + if (!keep_window_aspect || (image_width > window_width) || (image_height > window_height)) + { + // if image cropping or need to enlarge the scene, compute a scale_factor F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ; - snapshot_width = (S32)(ratio * image_width) ; + snapshot_width = (S32)(ratio * image_width) ; snapshot_height = (S32)(ratio * image_height) ; scale_factor = llmax(1.0f, 1.0f / ratio) ; } - else //the scene(window) proportion needs to be maintained. - { - if(image_width > window_width || image_height > window_height) //need to enlarge the scene - { - F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ; - snapshot_width = (S32)(ratio * image_width) ; - snapshot_height = (S32)(ratio * image_height) ; - scale_factor = llmax(1.0f, 1.0f / ratio) ; - } - } if (show_ui && scale_factor > 1.f) { + // Note: we should never get there... llwarns << "over scaling UI not supported." << llendl; } - S32 buffer_x_offset = llfloor(((window_width - snapshot_width) * scale_factor) / 2.f); + S32 buffer_x_offset = llfloor(((window_width - snapshot_width) * scale_factor) / 2.f); S32 buffer_y_offset = llfloor(((window_height - snapshot_height) * scale_factor) / 2.f); - S32 image_buffer_x = llfloor(snapshot_width*scale_factor) ; - S32 image_buffer_y = llfloor(snapshot_height *scale_factor) ; + S32 image_buffer_x = llfloor(snapshot_width * scale_factor) ; + S32 image_buffer_y = llfloor(snapshot_height * scale_factor) ; - if(image_buffer_x > max_size || image_buffer_y > max_size) //boundary check to avoid memory overflow + if ((image_buffer_x > max_size) || (image_buffer_y > max_size)) // boundary check to avoid memory overflow { scale_factor *= llmin((F32)max_size / image_buffer_x, (F32)max_size / image_buffer_y) ; - image_buffer_x = llfloor(snapshot_width*scale_factor) ; - image_buffer_y = llfloor(snapshot_height *scale_factor) ; + image_buffer_x = llfloor(snapshot_width * scale_factor) ; + image_buffer_y = llfloor(snapshot_height * scale_factor) ; } - if(image_buffer_x > 0 && image_buffer_y > 0) + if ((image_buffer_x > 0) && (image_buffer_y > 0)) { raw->resize(image_buffer_x, image_buffer_y, 3); } @@ -4062,7 +4056,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei { return FALSE ; } - if(raw->isBufferInvalid()) + if (raw->isBufferInvalid()) { return FALSE ; } @@ -4070,6 +4064,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei BOOL high_res = scale_factor >= 2.f; // Font scaling is slow, only do so if rez is much higher if (high_res && show_ui) { + // Note: we should never get there... llwarns << "High res UI snapshot not supported. " << llendl; /*send_agent_pause(); //rescale fonts @@ -4084,6 +4079,8 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei gObjectList.generatePickList(*LLViewerCamera::getInstance()); + // Subimages are in fact partial rendering of the final view. This happens when the final view is bigger than the screen. + // In most common cases, scale_factor is 1 and there's no more than 1 iteration on x and y for (int subimage_y = 0; subimage_y < scale_factor; ++subimage_y) { S32 subimage_y_offset = llclamp(buffer_y_offset - (subimage_y * window_height), 0, window_height);; @@ -4097,69 +4094,70 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei gDisplaySwapBuffers = FALSE; gDepthDirty = TRUE; - const U32 subfield = subimage_x+(subimage_y*llceil(scale_factor)); - - if (LLPipeline::sRenderDeferred) - { - display(do_rebuild, scale_factor, subfield, TRUE); - } - else - { - display(do_rebuild, scale_factor, subfield, TRUE); - // Required for showing the GUI in snapshots and performing bloom composite overlay - // Call even if show_ui is FALSE - render_ui(scale_factor, subfield); - } - S32 subimage_x_offset = llclamp(buffer_x_offset - (subimage_x * window_width), 0, window_width); // handle fractional rows U32 read_width = llmax(0, (window_width - subimage_x_offset) - llmax(0, (window_width * (subimage_x + 1)) - (buffer_x_offset + raw->getWidth()))); - for(U32 out_y = 0; out_y < read_height ; out_y++) + + // Skip rendering and sampling altogether if either width or height is degenerated to 0 (common in cropping cases) + if (read_width && read_height) { - S32 output_buffer_offset = ( - (out_y * (raw->getWidth())) // ...plus iterated y... - + (window_width * subimage_x) // ...plus subimage start in x... - + (raw->getWidth() * window_height * subimage_y) // ...plus subimage start in y... - - output_buffer_offset_x // ...minus buffer padding x... - - (output_buffer_offset_y * (raw->getWidth())) // ...minus buffer padding y... - ) * raw->getComponents(); + const U32 subfield = subimage_x+(subimage_y*llceil(scale_factor)); + display(do_rebuild, scale_factor, subfield, TRUE); - // Ping the wathdog thread every 100 lines to keep us alive (arbitrary number, feel free to change) - if (out_y % 100 == 0) + if (!LLPipeline::sRenderDeferred) { - LLAppViewer::instance()->pingMainloopTimeout("LLViewerWindow::rawSnapshot"); + // Required for showing the GUI in snapshots and performing bloom composite overlay + // Call even if show_ui is FALSE + render_ui(scale_factor, subfield); } - if (type == SNAPSHOT_TYPE_COLOR) + for (U32 out_y = 0; out_y < read_height ; out_y++) { - glReadPixels( - subimage_x_offset, out_y + subimage_y_offset, - read_width, 1, - GL_RGB, GL_UNSIGNED_BYTE, - raw->getData() + output_buffer_offset - ); - } - else // SNAPSHOT_TYPE_DEPTH - { - LLPointer depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values - glReadPixels( - subimage_x_offset, out_y + subimage_y_offset, - read_width, 1, - GL_DEPTH_COMPONENT, GL_FLOAT, - depth_line_buffer->getData()// current output pixel is beginning of buffer... - ); - - for (S32 i = 0; i < (S32)read_width; i++) + S32 output_buffer_offset = ( + (out_y * (raw->getWidth())) // ...plus iterated y... + + (window_width * subimage_x) // ...plus subimage start in x... + + (raw->getWidth() * window_height * subimage_y) // ...plus subimage start in y... + - output_buffer_offset_x // ...minus buffer padding x... + - (output_buffer_offset_y * (raw->getWidth())) // ...minus buffer padding y... + ) * raw->getComponents(); + + // Ping the watchdog thread every 100 lines to keep us alive (arbitrary number, feel free to change) + if (out_y % 100 == 0) { - F32 depth_float = *(F32*)(depth_line_buffer->getData() + (i * sizeof(F32))); - - F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2)); - U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar()); - //write converted scanline out to result image - for(S32 j = 0; j < raw->getComponents(); j++) + LLAppViewer::instance()->pingMainloopTimeout("LLViewerWindow::rawSnapshot"); + } + + if (type == SNAPSHOT_TYPE_COLOR) + { + glReadPixels( + subimage_x_offset, out_y + subimage_y_offset, + read_width, 1, + GL_RGB, GL_UNSIGNED_BYTE, + raw->getData() + output_buffer_offset + ); + } + else // SNAPSHOT_TYPE_DEPTH + { + LLPointer depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values + glReadPixels( + subimage_x_offset, out_y + subimage_y_offset, + read_width, 1, + GL_DEPTH_COMPONENT, GL_FLOAT, + depth_line_buffer->getData()// current output pixel is beginning of buffer... + ); + + for (S32 i = 0; i < (S32)read_width; i++) { - *(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + j) = depth_byte; + F32 depth_float = *(F32*)(depth_line_buffer->getData() + (i * sizeof(F32))); + + F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2)); + U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar()); + // write converted scanline out to result image + for (S32 j = 0; j < raw->getComponents(); j++) + { + *(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + j) = depth_byte; + } } } } -- cgit v1.2.3 From 609523d6f7c9b656eada861084bf49f0c5e77e19 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Tue, 19 Apr 2011 15:35:31 -0700 Subject: EXP-635 Action buttons missing on IM floater --- .../minimal/xui/en/panel_im_control_panel.xml | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'indra') diff --git a/indra/newview/skins/minimal/xui/en/panel_im_control_panel.xml b/indra/newview/skins/minimal/xui/en/panel_im_control_panel.xml index 53def54aca..c3f46f11e0 100644 --- a/indra/newview/skins/minimal/xui/en/panel_im_control_panel.xml +++ b/indra/newview/skins/minimal/xui/en/panel_im_control_panel.xml @@ -23,5 +23,69 @@ orientation="vertical" top_pad="5" width="145"> + + - - - + + + - - - - - - + + + + + diff --git a/indra/newview/skins/minimal/xui/en/panel_adhoc_control_panel.xml b/indra/newview/skins/minimal/xui/en/panel_adhoc_control_panel.xml index 5730adab8a..39d1a90850 100644 --- a/indra/newview/skins/minimal/xui/en/panel_adhoc_control_panel.xml +++ b/indra/newview/skins/minimal/xui/en/panel_adhoc_control_panel.xml @@ -42,5 +42,40 @@ show_speaking_indicator="false" width="147" /> + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 8c4555d54fc7c8686ffd139425f4c346576cac50 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 21 Apr 2011 18:04:38 -0700 Subject: Backed out changeset: e7b38729ad6d --- indra/newview/app_settings/settings_minimal.xml | 8 +- .../skins/default/xui/en/panel_bottomtray.xml | 1060 ++++++++++---------- .../minimal/xui/en/panel_adhoc_control_panel.xml | 35 - .../skins/minimal/xui/en/panel_bottomtray.xml | 38 - .../minimal/xui/en/panel_im_control_panel.xml | 33 - 5 files changed, 534 insertions(+), 640 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings_minimal.xml b/indra/newview/app_settings/settings_minimal.xml index 60aecb279c..bc97ec00e9 100644 --- a/indra/newview/app_settings/settings_minimal.xml +++ b/indra/newview/app_settings/settings_minimal.xml @@ -52,7 +52,7 @@ Type Boolean Value - 1 + 0 HelpURLFormat @@ -124,7 +124,7 @@ Type Boolean Value - 0 + 1 VoiceDisableMic @@ -133,7 +133,7 @@ Type Boolean Value - 0 + 1 ScriptsCanShowUI @@ -290,7 +290,7 @@ Type Boolean Value - 1 + 0 EnableAvatarShare diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray.xml b/indra/newview/skins/default/xui/en/panel_bottomtray.xml index c57f09c32f..c8882fd02c 100644 --- a/indra/newview/skins/default/xui/en/panel_bottomtray.xml +++ b/indra/newview/skins/default/xui/en/panel_bottomtray.xml @@ -1,530 +1,530 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/minimal/xui/en/panel_adhoc_control_panel.xml b/indra/newview/skins/minimal/xui/en/panel_adhoc_control_panel.xml index 39d1a90850..5730adab8a 100644 --- a/indra/newview/skins/minimal/xui/en/panel_adhoc_control_panel.xml +++ b/indra/newview/skins/minimal/xui/en/panel_adhoc_control_panel.xml @@ -42,40 +42,5 @@ show_speaking_indicator="false" width="147" /> - -