diff options
Diffstat (limited to 'indra/llkdu/llimagej2ckdu.cpp')
-rw-r--r-- | indra/llkdu/llimagej2ckdu.cpp | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index bf7cfbe071..8e2bd5b2d9 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -163,6 +163,7 @@ private: S32 mNumComponents; bool mUseYCC; kdu_dims mDims; + kdu_push_pull_params mParams; kdu_sample_allocator mAllocator; kdu_tile_comp mComps[4]; kdu_line_buf mLines[4]; @@ -255,7 +256,7 @@ LLImageJ2CKDU::LLImageJ2CKDU() : LLImageJ2CImpl(), mCodeStreamp(), mTPosp(), mTileIndicesp(), - mRawImagep(NULL), + mRawImagep(nullptr), mDecodeState(), mBlocksSize(-1), mPrecinctsSize(-1), @@ -292,17 +293,17 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod // two U32s and a pointer, so it's not as if it would be a huge overhead // to allocate a new one every time. // Also -- why is base.getData() tested specifically here? If that returns - // NULL, shouldn't we bail out of the whole method? + // nullptr, shouldn't we bail out of the whole method? if (!mInputp && base.getData()) { // The compressed data has been loaded // Setup the source for the codestream - mInputp.reset(new LLKDUMemSource(base.getData(), data_size)); + mInputp = std::make_unique<LLKDUMemSource>(base.getData(), data_size); } if (mInputp) { - // This is LLKDUMemSource::reset(), not boost::scoped_ptr::reset(). + // This is LLKDUMemSource::reset(), not std::unique_ptr::reset(). mInputp->reset(); } @@ -312,7 +313,7 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod // *TODO: This seems to be wrong. The base class should have no idea of // how j2c compression works so no good way of computing what's the byte // range to be used. - mCodeStreamp->set_max_bytes(max_bytes,true); + mCodeStreamp->set_max_bytes(max_bytes); // If you want to flip or rotate the image for some reason, change // the resolution, or identify a restricted region of interest, this is @@ -446,8 +447,8 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco mCodeStreamp->change_appearance(false, true, false); // Apply loading discard level and cropping if required - kdu_dims* region_kdu = NULL; - if (region != NULL) + kdu_dims* region_kdu = nullptr; + if (region != nullptr) { region_kdu = new kdu_dims; region_kdu->pos.x = region[0]; @@ -464,7 +465,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco if (region_kdu) { delete region_kdu; - region_kdu = NULL; + region_kdu = nullptr; } // Resize raw_image according to the image to be decoded @@ -475,12 +476,12 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco if (!mTileIndicesp) { - mTileIndicesp.reset(new kdu_dims); + mTileIndicesp = std::make_unique<kdu_dims>(); } mCodeStreamp->get_valid_tiles(*mTileIndicesp); if (!mTPosp) { - mTPosp.reset(new kdu_coords); + mTPosp = std::make_unique<kdu_coords>(); mTPosp->y = 0; mTPosp->x = 0; } @@ -490,7 +491,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco base.setLastError(msg.what()); return false; } - catch (kdu_exception kdu_value) + catch (const kdu_exception& kdu_value) { // KDU internally throws kdu_exception. It's possible that such an // exception might leak out into our code. Catch kdu_exception @@ -581,8 +582,7 @@ bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco kdu_coords offset = tile_dims.pos - dims.pos; int row_gap = channels*dims.size.x; // inter-row separation kdu_byte *buf = buffer + offset.y*row_gap + offset.x*channels; - mDecodeState.reset(new LLKDUDecodeState(tile, buf, row_gap, - mCodeStreamp.get())); + mDecodeState = std::make_unique<LLKDUDecodeState>(tile, buf, row_gap, mCodeStreamp.get()); } // Do the actual processing F32 remaining_time = limit_time ? decode_time - decode_timer.getElapsedTimeF32().value() : 0.0f; @@ -607,7 +607,7 @@ bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco cleanupCodeStream(); return true; // done } - catch (kdu_exception kdu_value) + catch (const kdu_exception& kdu_value) { // KDU internally throws kdu_exception. It's possible that such an // exception might leak out into our code. Catch kdu_exception @@ -810,7 +810,7 @@ bool LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co base.setLastError(msg.what()); return false; } - catch (kdu_exception kdu_value) + catch (const kdu_exception& kdu_value) { // KDU internally throws kdu_exception. It's possible that such an // exception might leak out into our code. Catch kdu_exception @@ -844,7 +844,7 @@ bool LLImageJ2CKDU::getMetadata(LLImageJ2C &base) base.setLastError(msg.what()); return false; } - catch (kdu_exception kdu_value) + catch (const kdu_exception& kdu_value) { // KDU internally throws kdu_exception. It's possible that such an // exception might leak out into our code. Catch kdu_exception @@ -976,8 +976,8 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base) //std::cout << "Parsing discard level = " << discard_level << std::endl; // Create the input codestream object. setupCodeStream(base, true, MODE_FAST); - mCodeStreamp->apply_input_restrictions(0, 4, discard_level, 0, NULL); - mCodeStreamp->set_max_bytes(KDU_LONG_MAX,true); + mCodeStreamp->apply_input_restrictions(0, 4, discard_level, 0, nullptr); + mCodeStreamp->set_max_bytes(KDU_LONG_MAX,false); siz_params *siz_in = mCodeStreamp->access_siz(); // Create the output codestream object. @@ -1073,8 +1073,10 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base) void set_default_colour_weights(kdu_params *siz) { + kdu_params *enc = siz->access_cluster(ENC_params); + assert(enc != nullptr); kdu_params *cod = siz->access_cluster(COD_params); - assert(cod != NULL); + assert(cod != nullptr); bool can_use_ycc = true; bool rev0 = false; @@ -1111,7 +1113,7 @@ void set_default_colour_weights(kdu_params *siz) return; } float weight; - if (cod->get(Clev_weights,0,0,weight) || cod->get(Cband_weights,0,0,weight)) + if (enc->get(Clev_weights,0,0,weight) || enc->get(Cband_weights,0,0,weight)) { // Weights already specified explicitly -> nothing to do return; @@ -1120,17 +1122,16 @@ void set_default_colour_weights(kdu_params *siz) // 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=" + enc->parse_string("Cband_weights:C0=" "{0.0901},{0.2758},{0.2758}," "{0.7018},{0.8378},{0.8378},{1}"); - cod->parse_string("Cband_weights:C1=" + enc->parse_string("Cband_weights:C1=" "{0.0263},{0.0863},{0.0863}," "{0.1362},{0.2564},{0.2564}," "{0.3346},{0.4691},{0.4691}," "{0.5444},{0.6523},{0.6523}," "{0.7078},{0.7797},{0.7797},{1}"); - cod->parse_string("Cband_weights:C2=" + enc->parse_string("Cband_weights:C2=" "{0.0773},{0.1835},{0.1835}," "{0.2598},{0.4130},{0.4130}," "{0.5040},{0.6464},{0.6464}," @@ -1149,7 +1150,7 @@ byte buffer, spacing successive output samples apart by `gap' bytes all necessary level shifting, type conversion, rounding and truncation. */ { int width = src.get_width(); - if (src.get_buf32() != NULL) + if (src.get_buf32() != nullptr) { // Decompressed samples have a 32-bit representation (integer or float) assert(precision >= 8); // Else would have used 16 bit representation kdu_sample32 *sp = src.get_buf32(); @@ -1312,11 +1313,11 @@ LLKDUDecodeState::LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap, mLines[c].pre_create(&mAllocator,mDims.size.x,mReversible[c],use_shorts,0,0); if (res.which() == 0) // No DWT levels used { - mEngines[c] = kdu_decoder(res.access_subband(LL_BAND),&mAllocator,use_shorts); + mEngines[c] = kdu_decoder(res.access_subband(LL_BAND), &mAllocator, mParams, use_shorts); } else { - mEngines[c] = kdu_synthesis(res,&mAllocator,use_shorts); + mEngines[c] = kdu_synthesis(res, &mAllocator, mParams, use_shorts); } } mAllocator.finalize(*codestreamp); // Actually creates buffering resources @@ -1394,7 +1395,7 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod this->codestream = codestream; codestream.get_valid_tiles(valid_tile_indices); tile_idx = valid_tile_indices.pos; - tile = codestream.open_tile(tile_idx,NULL); + tile = codestream.open_tile(tile_idx, nullptr); // Set up the individual components num_components = codestream.get_num_components(true); @@ -1403,7 +1404,7 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod kdc_component_flow_control *comp = components; for (n = 0; n < num_components; n++, comp++) { - comp->line = NULL; + comp->line = nullptr; comp->reader = img_in; kdu_coords subsampling; codestream.get_subsampling(n,subsampling,true); @@ -1420,12 +1421,12 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod 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); + max_buffer_memory = engine.create(codestream, tile, false, nullptr, false, 1, nullptr, nullptr,false); } kdc_flow_control::~kdc_flow_control() { - if (components != NULL) + if (components != nullptr) { delete[] components; } @@ -1452,8 +1453,8 @@ bool kdc_flow_control::advance_components() if (comp->ratio_counter < 0) { found_line = true; - comp->line = engine.exchange_line(n,NULL,NULL); - assert(comp->line != NULL); + comp->line = engine.exchange_line(n,nullptr,nullptr); + assert(comp->line != nullptr); if (comp->line->get_width()) { comp->reader->get(n,*(comp->line),0); @@ -1480,9 +1481,9 @@ void kdc_flow_control::process_components() 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; + assert(comp->line != nullptr); + engine.exchange_line(n,comp->line,nullptr); + comp->line = nullptr; } } } |