47 static ossimTrace traceDebug(
"ossimKakaduCompressor:debug");
55 static const ossimString COMPRESSION_QUALITY[] = {
"unknown",
57 "numerically_lossless",
64 static void transfer_bytes(
65 kdu_core::kdu_line_buf &dest, kdu_core::kdu_byte *src,
66 int num_samples,
int sample_gap,
int src_bits,
int original_bits)
68 if (dest.get_buf16() != 0)
70 kdu_core::kdu_sample16 *dp = dest.get_buf16();
71 kdu_core::kdu_int16 off = ((kdu_core::kdu_int16)(1<<src_bits))>>1;
72 kdu_core::kdu_int16 mask = ~((kdu_core::kdu_int16)((-1)<<src_bits));
73 if (!dest.is_absolute())
75 int shift = KDU_FIX_POINT - src_bits; assert(shift >= 0);
76 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
77 dp->ival = ((((kdu_core::kdu_int16) *src) & mask) - off) << shift;
79 else if (src_bits < original_bits)
81 int shift = original_bits - src_bits;
82 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
83 dp->ival = ((((kdu_core::kdu_int16) *src) & mask) - off) << shift;
85 else if (src_bits > original_bits)
87 int shift = src_bits - original_bits;
89 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
90 dp->ival = ((((kdu_core::kdu_int16) *src) & mask) - off) >> shift;
94 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
95 dp->ival = (((kdu_core::kdu_int16) *src) & mask) - off;
100 kdu_core::kdu_sample32 *dp = dest.get_buf32();
101 kdu_core::kdu_int32 off = ((kdu_core::kdu_int32)(1<<src_bits))>>1;
102 kdu_core::kdu_int32 mask = ~((kdu_core::kdu_int32)((-1)<<src_bits));
103 if (!dest.is_absolute())
105 float scale = 1.0F / (float)(1<<src_bits);
106 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
107 dp->fval = scale * (
float)((((kdu_core::kdu_int32) *src) & mask) - off);
109 else if (src_bits < original_bits)
111 int shift = original_bits - src_bits;
112 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
113 dp->ival = ((((kdu_core::kdu_int32) *src) & mask) - off) << shift;
115 else if (src_bits > original_bits)
117 int shift = src_bits - original_bits;
118 off -= (1<<shift)>>1;
119 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
120 dp->ival = ((((kdu_core::kdu_int32) *src) & mask) - off) >> shift;
124 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
125 dp->ival = (((kdu_core::kdu_int32) *src) & mask) - off;
130 static void transfer_words(
131 kdu_core::kdu_line_buf &dest, kdu_core::kdu_int16 *src,
int num_samples,
132 int sample_gap,
int src_bits,
int original_bits,
135 if (dest.get_buf16() != 0)
137 kdu_core::kdu_sample16 *dp = dest.get_buf16();
138 int upshift = 16-src_bits; assert(upshift >= 0);
139 if (!dest.is_absolute())
142 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
143 dp->ival = ((*src) << upshift) >> (16-KDU_FIX_POINT);
145 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
146 dp->ival = (((*src) << upshift) - 0x8000) >> (16-KDU_FIX_POINT);
151 int downshift = 16-original_bits; assert(downshift >= 0);
154 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
156 dp->ival = ((*src) << upshift) >> downshift;
161 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
163 dp->ival = (((*src) << upshift) - 0x8000) >> downshift;
170 kdu_core::kdu_sample32 *dp = dest.get_buf32();
171 int upshift = 32-src_bits; assert(upshift >= 0);
173 if (!dest.is_absolute())
175 float scale = 1.0F / (((float)(1<<16)) * ((
float)(1<<16)));
177 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
178 dp->fval = scale * (
float)(((kdu_core::kdu_int32) *src)<<upshift);
180 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
181 dp->fval = scale * (
float)((((kdu_core::kdu_int32) *src)<<upshift)-(1<<31));
185 int downshift = 32-original_bits; assert(downshift >= 0);
188 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
190 dp->ival = (((kdu_core::kdu_int32) *src)<<upshift) >> downshift;
193 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
194 dp->ival = ((((kdu_core::kdu_int32) *src)<<upshift)-(1<<31)) >> downshift;
200 int num_samples,
int sample_gap,
int src_bits,
int original_bits,
203 if (dest.get_buf16() != NULL)
205 kdu_core::kdu_sample16 *dp = dest.get_buf16();
206 int upshift = 32-src_bits; assert(upshift >= 0);
207 if (!dest.is_absolute())
210 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
211 dp->ival = (kdu_core::kdu_int16)
212 (((*src) << upshift) >> (32-KDU_FIX_POINT));
214 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
215 dp->ival = (kdu_core::kdu_int16)
216 ((((*src) << upshift)-0x80000000) >> (32-KDU_FIX_POINT));
220 int downshift = 32-original_bits; assert(downshift >= 0);
222 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
223 dp->ival = (kdu_core::kdu_int16)
224 (((*src) << upshift) >> downshift);
226 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
227 dp->ival = (kdu_core::kdu_int16)
228 ((((*src) << upshift) - 0x80000000) >> downshift);
233 kdu_core::kdu_sample32 *dp = dest.get_buf32();
234 int upshift = 32-src_bits; assert(upshift >= 0);
235 if (!dest.is_absolute())
237 float scale = 1.0F / (((float)(1<<16)) * ((
float)(1<<16)));
239 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
240 dp->fval = scale * (
float)((*src)<<upshift);
242 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
243 dp->fval = scale * (
float)(((*src)<<upshift)-(1<<31));
247 int downshift = 32-original_bits; assert(downshift >= 0);
249 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
250 dp->ival = ((*src)<<upshift) >> downshift;
252 for (; num_samples > 0; num_samples--, src+=sample_gap, dp++)
253 dp->ival = (((*src)<<upshift)-(1<<31)) >> downshift;
306 static const char MODULE[] =
"ossimKakaduCompressor::create";
316 <<
"\nscalar: " << scalar
317 <<
"\nbands: " << bands
318 <<
"\nimageRect: " << imageRect
319 <<
"\ntileSize: " << tileSize
329 std::string errMsg = MODULE;
330 errMsg +=
" ERROR: Null stream passed to method!";
336 std::string errMsg = MODULE;
337 errMsg +=
" ERROR: Stream state has error!";
346 std::string errMsg = MODULE;
347 errMsg +=
" ERROR: Reversible processing not possible with 32 bit data!";
355 static_cast<ossim_uint32>(tileSize.
x),
356 static_cast<ossim_uint32>(tileSize.
y));
380 if ( (bands != 1) && (bands != 3) )
386 <<
"Alpha channel being unset! Can only be used with " 387 <<
"one or three band data.\n" 388 <<
"Source image bands: " << bands <<
"\n";
393 kdu_core::siz_params siz;
396 siz.set(Scomponents, 0, 0, static_cast<ossim_int32>( (
m_alpha?bands+1:bands) ) );
399 siz.set(Ssize, 0, 0, static_cast<ossim_int32>(imageRect.
height()));
400 siz.set(Sdims, 0, 0, static_cast<ossim_int32>(imageRect.
height()));
403 siz.set(Ssize, 0, 1, static_cast<ossim_int32>(imageRect.
width()));
404 siz.set(Sdims, 0, 1, static_cast<ossim_int32>(imageRect.
width()));
407 siz.set(Stiles, 0, 0, tileSize.
y);
410 siz.set(Stiles, 0, 1, tileSize.
x);
416 siz.set(Sprecision, 0, 0,
442 <<
"Unable to create thread!\n";
450 kdu_supp::jp2_dimensions dims;
471 kdu_supp::jp2_colour colour =
m_jp2Target->access_colour();
474 colour.init( kdu_supp::JP2_sRGB_SPACE );
478 colour.init( kdu_supp::JP2_sLUM_SPACE );
484 int num_colours =
static_cast<int>( (bands==3)?bands:1 );
485 kdu_supp::jp2_channels channels =
m_jp2Target->access_channels();
486 channels.init(num_colours);
487 for (
int c=0; c < num_colours; ++c)
489 channels.set_colour_mapping(c,c);
496 channels.set_opacity_mapping(0,1);
500 channels.set_opacity_mapping(0,3);
501 channels.set_opacity_mapping(1,3);
502 channels.set_opacity_mapping(2,3);
519 kdu_core::kdu_params* cod =
m_codestream.access_siz()->access_cluster(COD_params);
527 std::vector<ossimString>::const_iterator optionIter =
m_options.begin();
530 m_codestream.access_siz()->parse_string( (*optionIter).c_str() );
596 kdu_core::kdu_coords tileIndex;
600 kdu_core::kdu_tile tile =
m_codestream.open_tile(tileIndex);
602 kdu_core::kdu_dims tile_dims;
611 tile.set_components_of_interest(BANDS);
620 std::vector<kdu_core::kdu_push_ifc> engine(BANDS);
621 std::vector<kdu_core::kdu_line_buf> lineBuf(BANDS);
626 std::vector<ossim_int32> original_bits(BANDS);
629 kdu_core::kdu_tile_comp tc;
630 kdu_core::kdu_resolution res;
633 kdu_core::kdu_sample_allocator allocator;
636 for (band = 0; band < BANDS; ++band)
638 original_bits[band] =
m_codestream.get_bit_depth(band,
true);
640 tc = tile.access_component(band);
641 res = tc.access_resolution();
650 reversible = tc.get_reversible();
651 use_shorts = (tc.get_bit_depth(
true) <= 16);
654 res.get_dims(tile_dims);
656 engine[band] = kdu_core::kdu_analysis(res,
664 lineBuf[band].pre_create(&allocator,
675 for (band = 0; band < BANDS; ++band)
677 lineBuf[band].create();
684 std::vector<kdu_core::kdu_byte*> srcBuf(BANDS);
685 for (band = 0; band < BANDS; ++band)
687 void* p =
const_cast<void*
>(srcTile.
getBuf(band));
688 srcBuf[band] =
static_cast<kdu_core::kdu_byte*
>(p);
695 void* p =
const_cast<void*
>(cp);
696 srcBuf[BANDS-1] =
static_cast<kdu_core::kdu_byte*
>(p);
700 for (band = 0; band < BANDS; ++band)
702 transfer_bytes(lineBuf[band],
707 original_bits[band]);
712 srcBuf[band] = srcBuf[band]+TILE_SAMPS;
726 std::vector<kdu_core::kdu_int16*> srcBuf(BANDS);
727 for (band = 0; band < BANDS; ++band)
729 void* p =
const_cast<void*
>(srcTile.
getBuf(band));
730 srcBuf[band] =
static_cast<kdu_core::kdu_int16*
>(p);
735 for (band = 0; band < BANDS; ++band)
737 transfer_words(lineBuf[band],
748 srcBuf[band] = srcBuf[band]+TILE_SAMPS;
762 std::vector<kdu_core::kdu_int16*> srcBuf(dataBands);
763 for (band = 0; band < dataBands; ++band)
765 void* p =
const_cast<void*
>(srcTile.
getBuf(band));
766 srcBuf[band] =
static_cast<kdu_core::kdu_int16*
>(p);
770 std::vector<kdu_core::kdu_int16> alphaLine(SAMPS);
774 for (band = 0; band < dataBands; ++band)
776 transfer_words(lineBuf[band],
787 srcBuf[band] = srcBuf[band]+TILE_SAMPS;
793 alphaLine[samp] =
static_cast<kdu_core::kdu_int16
>(alphaPtr[samp]*d);
796 transfer_words(lineBuf[band],
806 alphaPtr = alphaPtr+TILE_SAMPS;
813 std::vector<ossim_sint16*> srcBuf(BANDS);
814 for (band = 0; band < BANDS; ++band)
816 void* p =
const_cast<void*
>(srcTile.
getBuf(band));
822 for (band = 0; band < BANDS; ++band)
824 transfer_words(lineBuf[band],
835 srcBuf[band] = srcBuf[band]+TILE_SAMPS;
847 std::vector<kdu_core::kdu_int32*> srcBuf(BANDS);
848 for (band = 0; band < BANDS; ++band)
850 void* p =
const_cast<void*
>(srcTile.
getBuf(band));
851 srcBuf[band] =
static_cast<kdu_core::kdu_int32*
>(p);
856 for (band = 0; band < BANDS; ++band)
869 srcBuf[band] = srcBuf[band]+TILE_SAMPS;
885 std::vector<ossim_float32*> srcBuf(BANDS);
886 for (band = 0; band < BANDS; ++band)
893 for (band = 0; band < BANDS; ++band)
895 kdu_core::kdu_sample32* dp = lineBuf[band].get_buf32();
898 dp[samp].fval = srcBuf[band][samp] - 0.5;
903 srcBuf[band] = srcBuf[band]+TILE_SAMPS;
911 << __FILE__ <<
" " << __LINE__ <<
" Unhandle scalar!\n";
932 for (band = 0; band < BANDS; ++band)
934 engine[band].destroy();
935 lineBuf[band].destroy();
1009 catch ( kdu_core::kdu_exception exc )
1017 e <<
"ossimKakaduNitfReader::~ossimKakaduNitfReader\n" 1018 <<
"Caught exception from kdu_region_decompressor: " << exc <<
"\n";
1021 catch ( std::bad_alloc& )
1025 m_threadEnv->handle_exception(KDU_MEMORY_EXCEPTION);
1028 "Caught exception from kdu_region_decompressor: std::bad_alloc";
1034 "Caught unhandled exception from kdu_region_decompressor";
1116 std::vector<ossimString>::const_iterator i = options.begin();
1117 while ( i != options.end() )
1126 bool consumed =
false;
1128 if ( property.
valid() )
1135 <<
"ossimKakaduCompressor::setProperty DEBUG:" 1137 <<
" values: " <<
property->valueToString() << std::endl;
1145 else if ( (key == LEVELS_KW) || (key ==
"Clevels") )
1147 m_levels =
property->valueToString().toInt32();
1150 else if( (key == REVERSIBLE_KW) || (key ==
"Creversible") )
1155 else if (key == ADD_ALPHA_CHANNEL_KW)
1157 m_alpha =
property->valueToString().toBool();
1160 else if ( key == THREADS_KW)
1162 m_threads =
property->valueToString().toInt32();
1165 else if ( (key ==
"Clayers") ||
1166 (key ==
"Cprecincts") )
1173 option +=
property->valueToString();
1203 vector<ossimString> constraintList;
1206 constraintList.push_back(
1208 constraintList.push_back(
1210 constraintList.push_back(
1212 constraintList.push_back(
1214 constraintList.push_back(
1222 else if (name == LEVELS_KW)
1226 else if (name == REVERSIBLE_KW)
1230 else if (name == ADD_ALPHA_CHANNEL_KW)
1234 else if (name == THREADS_KW)
1243 std::vector<ossimString>& propertyNames)
const 1246 propertyNames.push_back(LEVELS_KW);
1247 propertyNames.push_back(REVERSIBLE_KW);
1248 propertyNames.push_back(THREADS_KW);
1252 const char* prefix)
const 1270 ADD_ALPHA_CHANNEL_KW,
1279 std::vector<ossimString>::size_type
size =
m_options.size();
1297 const char* value = 0;
1305 value = kwl.
find(prefix, LEVELS_KW);
1311 value = kwl.
find(prefix, REVERSIBLE_KW);
1317 value = kwl.
find(prefix, ADD_ALPHA_CHANNEL_KW);
1323 value = kwl.
find(prefix, THREADS_KW);
1334 searchKey +=
"option";
1341 const char* lookup = kwl.
find(key.
c_str());
1356 bool result =
false;
1370 std::vector<ossim_uint8> buf;
1388 static_cast<kdu_core::kdu_byte*>(&buf.front()), static_cast<int>(buf.size()));
1402 bool result =
false;
1411 if ( gml->
write( xmlStr ) )
1415 0x61, 0x73, 0x6F, 0x63
1420 0x6C, 0x62, 0x6C, 0x20
1425 0x78, 0x6D, 0x6C, 0x20
1431 ossim_uint32 boxSize = xmlDataSize + 17 + 8 + 8 + 8 + 8 + 8 + 8;
1435 endian.
swap( boxSize );
1451 endian.
swap( boxSize );
1454 m_jp2Target->write((kdu_core::kdu_byte*)&boxSize, 4);
1455 m_jp2Target->write((
const kdu_core::kdu_byte*)LBL_BOX_ID, 4);
1456 m_jp2Target->write((
const kdu_core::kdu_byte*)
"gml.data", 8);
1459 boxSize = xmlDataSize + 17 + 8 + 8 + 8;
1463 endian.
swap( boxSize );
1465 m_jp2Target->write((kdu_core::kdu_byte*)&boxSize, 4);
1466 m_jp2Target->write((
const kdu_core::kdu_byte*)ASOC_BOX_ID, 4);
1473 endian.
swap( boxSize );
1475 m_jp2Target->write((kdu_core::kdu_byte*)&boxSize, 4);
1476 m_jp2Target->write((
const kdu_core::kdu_byte*)LBL_BOX_ID, 4);
1477 m_jp2Target->write((
const kdu_core::kdu_byte*)
"gml.root-instance", 17);
1480 boxSize = xmlDataSize + 8;
1484 endian.
swap( boxSize );
1486 m_jp2Target->write((kdu_core::kdu_byte*)&boxSize, 4);
1487 m_jp2Target->write((
const kdu_core::kdu_byte*)XML_BOX_ID, 4);
1488 m_jp2Target->write((
const kdu_core::kdu_byte*)xmlStr.str().data(),
1544 static const char MODULE[] =
"ossimKakaduCompressor::initializeCodingParams";
1554 cod->set(Cycc, 0, 0,
false);
1603 static_cast<kdu_core::kdu_long
>(std::ceil( TP * 0.03125 * 0.125 ));
1605 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.0625* 0.125 ));
1607 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.125* 0.125 ));
1609 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.25* 0.125 ));
1611 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.5* 0.125 ));
1613 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.6* 0.125 ));
1615 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.7* 0.125 ));
1617 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.8* 0.125 ));
1619 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.9* 0.125 ));
1621 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.0* 0.125 ));
1623 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.1* 0.125 ));
1625 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.2* 0.125 ));
1627 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.3* 0.125 ));
1629 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.5* 0.125 ));
1631 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.7* 0.125 ));
1633 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 2.0* 0.125 ));
1635 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 2.3* 0.125 ));
1637 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 2.8* 0.125 ));
1639 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 3.5* 0.125 ));
1658 static_cast<kdu_core::kdu_long
>(std::ceil( TP * 0.03125 * 0.125 ));
1660 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.0625* 0.125 ));
1662 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.125* 0.125 ));
1664 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.25* 0.125 ));
1666 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.5* 0.125 ));
1668 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.6* 0.125 ));
1670 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.7* 0.125 ));
1672 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.8* 0.125 ));
1674 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.9* 0.125 ));
1676 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.0* 0.125 ));
1678 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.1* 0.125 ));
1680 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.2* 0.125 ));
1682 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.3* 0.125 ));
1684 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.5* 0.125 ));
1686 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.7* 0.125 ));
1688 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 2.0* 0.125 ));
1690 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 2.3* 0.125 ));
1692 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 2.8* 0.125 ));
1694 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 3.5* 0.125 ));
1713 static_cast<kdu_core::kdu_long
>(std::ceil( TP * 0.03125 * 0.125 ));
1715 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.0625* 0.125 ));
1717 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.125* 0.125 ));
1719 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.25* 0.125 ));
1721 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.5* 0.125 ));
1723 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.6* 0.125 ));
1725 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.7* 0.125 ));
1727 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.8* 0.125 ));
1729 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.9* 0.125 ));
1731 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.0* 0.125 ));
1733 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.1* 0.125 ));
1735 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.2* 0.125 ));
1737 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.3* 0.125 ));
1739 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.5* 0.125 ));
1741 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.7* 0.125 ));
1743 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 2.0* 0.125 ));
1745 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 2.3* 0.125 ));
1747 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 2.8* 0.125 ));
1749 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 3.5* 0.125 ));
1763 static_cast<kdu_core::kdu_long
>(std::ceil( TP * 0.03125 * 0.125 ));
1765 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.0625* 0.125 ));
1767 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.125* 0.125 ));
1769 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.25* 0.125 ));
1771 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.5* 0.125 ));
1773 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.6* 0.125 ));
1775 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.7* 0.125 ));
1777 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.8* 0.125 ));
1779 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.9* 0.125 ));
1781 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 1.0* 0.125 ));
1795 static_cast<kdu_core::kdu_long
>(std::ceil( TP * 0.03125 * 0.125 ));
1797 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.0625 * 0.125 ));
1799 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.125 * 0.125 ));
1801 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.25 * 0.125 ));
1803 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.5 * 0.125 ));
1817 static_cast<kdu_core::kdu_long
>(std::ceil( TP * 0.03125 * 0.125 ));
1819 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.0625 * 0.125 ));
1821 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.125 * 0.125 ));
1823 static_cast<kdu_core::kdu_long
>(std::ceil(TP * 0.25 * 0.125 ));
1834 << MODULE <<
"unhandled compression_quality type! Valid types:\n";
1903 else if (type ==
"lossy")
1907 else if (type ==
"lossy2")
1911 else if (type ==
"lossy3")
1915 else if (type ==
"epje")
1922 <<
"ossimKakaduCompressor::setQualityTypeString WARNING" 1923 <<
"\nUnhandled compression_quality type: " << type
1947 if ( (levels < 1) || (levels > 32) )
1951 cod->set(Clevels, 0, 0, levels);
1969 cod->set(Cblk,0,0,ySize);
1970 cod->set(Cblk,0,1,xSize);
1988 if ( (corder < 0) || (corder > 5) )
1990 corder = Corder_LRCP;
1992 cod->set(Corder,0,0,corder);
2009 if ( (kernel < -1) || (kernel > 1) )
2013 kernel = Ckernels_W5X3;
2017 kernel = Ckernels_W9X7;
2020 cod->set(Ckernels,0,0,kernel);
2032 if ( (layers < 1) || (layers > 16384) )
2036 cod->set(Clayers,0,0,layers);
2054 out <<
"compression_quality=" 2056 <<
"\ncompression_quality=" 2058 <<
"\ncompression_quality=" 2060 <<
"\ncompression_quality=" 2062 <<
"\ncompression_quality=" 2064 <<
"\ncompression_quality=" virtual void valueToString(ossimString &valueResult) const =0
virtual ossim_uint32 getWidth() const
void setQualityLayers(kdu_core::kdu_params *cod, ossim_int32 layers)
Sets the number of quality layers.
virtual void create(ossim::ostream *os, ossimScalarType scalar, ossim_uint32 bands, const ossimIrect &imageRect, const ossimIpt &tileSize, ossim_uint32 tilesToWrite, bool jp2)
Create method.
OSSIM_DLL ossim_uint32 computeLevels(const ossimIrect &rect)
Computes the number of decimation levels to get to the overview stop dimension.
bool m_reversible
Lossless or lossy.
void setReversibleFlag(bool reversible)
Sets the m_reversible flag.
16 bit unsigned integer (12 bits used)
int getNumberOfLayers() const
ossim_uint32 numberOf(const char *str) const
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
virtual ossim_uint32 getNumberOfBands() const
virtual void setLevels(ossim_int32 levels)
Sets the number of levels.
ossim_int32 getLevels() const
Represents serializable keyword/value map.
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
void initialize(ossimNitfJ2klraTag *j2klraTag, ossim_uint32 actualBitsPerPixel) const
Initializes the tag.
bool writeGmlBox(const ossimImageGeometry *geom, const ossimIrect &rect)
Writes the GML box to the jp2.
const char * find(const char *key) const
virtual void finish()
Finish method.
16 bit unsigned integer (14 bits used)
void setQualityTypeString(const ossimString &s)
bool setOrigin(ossim_uint32 origin)
Sets origin:
virtual ossimString getLongName() const
std::vector< ossimString > m_options
Container for kakadu options to pass to kdu_params::parse_string.
ossim_uint32 height() const
virtual ~ossimKakaduCompressor()
destructor
static ossimString toString(bool aValue)
Numeric to string methods.
const ossimIpt & ul() const
void setStream(std::ostream *stream)
Sets the output stream.
virtual ossimDataObjectStatus getDataObjectStatus() const
bool m_alpha
If true write alpha channel.
virtual ossim_uint32 getHeight() const
OSSIM_DLL ossimByteOrder byteOrder()
OSSIM_DLL ossim_uint32 getActualBitsPerPixel(ossimScalarType scalarType)
Get actual bits per pixel for a given scalar type.
ossim_uint32 toUInt32() const
16 bit unsigned integer (13 bits used)
bool getReversibleFlag() const
virtual void initialize()
Initialize the data buffer.
bool write(std::ostream &os)
Write xml doc to stream.
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Pushes this's names onto the list of property names.
std::vector< kdu_core::kdu_long > m_layerByteSizes
Layer sizes provided in 'flush' calls.
ossim_int32 toInt32() const
void push_back(char c)
Equivalent to insert(end(), c).
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
#define RTTI_DEF1_INST(cls, name, b1)
virtual ossimString getClassName() const
ossimRefPtr< ossimImageData > m_normTile
tile to use for normalized float data.
bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
saves the state of the object.
OSSIM_DLL bool isSigned(ossimScalarType scalarType)
void setProgressionOrder(kdu_core::kdu_params *cod, ossim_int32 corder)
Sets progression order.
const char * findPreference(const char *key) const
void setWaveletKernel(kdu_core::kdu_params *cod, ossim_int32 kernel)
Sets the wavelet kernel to use.
signed short ossim_sint16
os2<< "> n<< " > nendobj n
void setThreads(ossim_int32 threads)
Sets the number of threads.
ossimKakaduCompressor()
default constructor
static bool writeJp2GeotiffBox(const ossimFilename &tmpFile, const ossimIrect &rect, const ossimProjection *proj, std::vector< ossim_uint8 > &buf, ossimPixelType pixelType)
Writes a geotiff box to a buffer.
kdu_supp::jp2_target * m_jp2Target
bool toBool() const
String to numeric methods.
kdu_core::kdu_thread_env * m_threadEnv
unsigned int ossim_uint32
ossimKakaduCompressionQuality
32 bit normalized floating point
ossim_int32 m_levels
Reduced resolution levels.
void openJp2Codestream()
Calls "open_codestream" on the m_jp2Target.
bool setLayerBitRate(ossim_uint32 index, ossim_float64 bitRate)
Sets the bitrate from index.
virtual void copyTileToNormalizedBuffer(ossim_float64 *buf) const
Copies entire tile to buf passed in.
bool getAlphaChannelFlag() const
Retrieve the writer's setting for whether or not to add an alpha channel to the output png image...
const ossimIpt & lr() const
void printCompressionQualityTypes(std::ostream &out) const
bool setLevelsO(ossim_uint32 levels)
Sets the number of wavelet levels in the original image.
static ossimString downcase(const ossimString &aString)
ossimKakaduCompressionQuality getQualityType() const
virtual void setAlphaChannelFlag(bool flag)
Set the writer to add an alpha channel to the output.
bool initialize(const ossimImageGeometry *geom, const ossimIrect &rect)
Initializes gml block from geometry file.
ossim_uint32 width() const
virtual void setQualityType(ossimKakaduCompressionQuality type)
Sets the quality type.
static ossimPreferences * instance()
ossimIrect m_imageRect
Layer slopes array provided in 'flush' calls.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
bool writeGeotiffBox(const ossimImageGeometry *geom, const ossimIrect &rect, const ossimFilename &tmpFile, ossimPixelType pixelType)
Writes the geotiff box to the jp2.
ossimString getQualityTypeString() const
virtual bool setProperty(ossimRefPtr< ossimProperty > property)
Will set the property whose name matches the argument "property->getName()".
virtual const ossim_float32 * getFloatBuf() const
virtual bool writeTile(ossimImageData &srcTile)
Write tile method.
virtual ossimScalarType getScalarType() const
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
16 bit unsigned integer (15 bits used)
void transfer_dwords(kdu_core::kdu_line_buf &dest, kdu_core::kdu_int32 *src, int num_samples, int sample_gap, int src_bits, int original_bits, bool is_signed)
ossim_int32 getThreads() const
OSSIM_DLL double defaultMax(ossimScalarType scalarType)
void initializeCodingParams(kdu_core::kdu_params *cod, const ossimIrect &imageRect)
ossimKakaduCompressedTarget * m_target
ossimKakaduCompressionQuality m_qualityType
int m_layerSpecCount
Num specs provided in 'flush' calls.
ossimKakaduCompressedTarget JPEG2000 (J2K) kdu_compressed_target that uses an ostream for writing to ...
virtual const void * getBuf() const
static const char * COMPRESSION_QUALITY_KW
ossim_uint32 area() const
kdu_supp::jp2_family_tgt * m_jp2FamTgt
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
bool setLayersO(ossim_uint32 layers)
Sets the number of layers in the original image.
kdu_core::kdu_thread_queue * m_threadQueue
bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
kdu_core::kdu_codestream m_codestream
virtual const ossim_uint8 * getAlphaBuf() const
void setTlmTileCount(ossim_uint32 tilesToWrite)
void setOptions(const std::vector< ossimString > &options)
Sets the options array.
16 bit unsigned integer (11 bits used)
ossim_int32 m_threads
Number of threads.
virtual const ossimIpt & getOrigin() const
unsigned char ossim_uint8
void setCodeBlockSize(kdu_core::kdu_params *cod, ossim_int32 xSize, ossim_int32 ySize)
Set code block size.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
bool setLayerId(ossim_uint32 index, ossim_uint32 id)
Sets the layer id for index.