12 # include <vcl_msvc_warnings.h> 16 unsigned int num_blocks_x,
unsigned int num_blocks_y,
17 unsigned int num_bands,
const std::string& i_mode )
18 : num_blocks_x( num_blocks_x ),
19 num_blocks_y( num_blocks_y ),
20 num_bands( num_bands ),
45 void* val = std::malloc( width );
47 if ( stream->
read( val, width ) != width )
return false;
50 TPXCD = *((vxl_byte*)val);
51 }
else if ( width == 2 ){
52 TPXCD = *((vxl_uint_16*)val);
53 }
else if ( width == 4 ){
54 TPXCD = *((vxl_uint_32*)val);
57 else if ( width == 8 ){
58 TPXCD = *((vxl_uint_64*)val);
60 #endif //VXL_HAS_INT64 76 if ( stream->
read( (
void*)(&
BMR_n_BND_m[i][j][b]), 4 ) != 4 )
return false;
96 if ( stream->
read( (
void*)(&
TMR_n_BND_m[i][j][b]), 4 ) != 4 )
return false;
112 unsigned int block_y,
115 int band_to_use =
i_mode ==
"S" ? band : 0;
118 band_to_use < static_cast<int>(
BMR_n_BND_m[block_x][band_to_use].size()) );
119 assert( ( band < 0 &&
i_mode !=
"S" ) ||
120 ( band >= 0 &&
i_mode ==
"S" ) );
125 unsigned int block_y,
128 int band_to_use =
i_mode ==
"S" ? band : 0;
131 band_to_use < static_cast<int>(
TMR_n_BND_m[block_x][band_to_use].size()) );
132 assert( ( band < 0 &&
i_mode !=
"S" ) ||
133 ( band >= 0 &&
i_mode ==
"S" ) );
137 #if VXL_LITTLE_ENDIAN 140 void swap16(
char *a,
unsigned n)
142 for (
unsigned i = 0; i < n * 2; i += 2)
144 std::swap( a[i+0], a[i+1] );
149 void swap32(
char *a,
unsigned n)
151 for (
unsigned i = 0; i < n * 4; i += 4)
153 std::swap( a[i+0], a[i+3] );
154 std::swap( a[i+1], a[i+2] );
159 void swap64(
char *a,
unsigned n)
161 for (
unsigned i = 0; i < n * 8; i += 8)
163 std::swap( a[i+0], a[i+7] );
164 std::swap( a[i+1], a[i+6] );
165 std::swap( a[i+2], a[i+5] );
166 std::swap( a[i+3], a[i+4] );
175 #if VXL_LITTLE_ENDIAN 179 (void)size_of_a_in_bytes;
181 #endif //VXL_LITTLE_ENDIAN 185 unsigned int bytesPerSample )
187 #if VXL_LITTLE_ENDIAN 188 switch ( bytesPerSample )
190 case 8:
swap64( a, size_of_a_in_bytes / 8 );
break;
191 case 4:
swap32( a, size_of_a_in_bytes / 4 );
break;
192 case 2: swap16( a, size_of_a_in_bytes / 2 );
break;
197 (void)size_of_a_in_bytes;
198 (void)bytesPerSample;
199 #endif //VXL_LITTLE_ENDIAN 204 int band_to_use =
i_mode ==
"S" ? band : 0;
207 band_to_use < static_cast<int>(
BMR_n_BND_m[block_x][band_to_use].size()) );
208 if (band_to_use >= static_cast<int>(
BMR_n_BND_m[block_x][band_to_use].size()) )
215 int band_to_use =
i_mode ==
"S" ? band : 0;
218 band_to_use < static_cast<int>(
TMR_n_BND_m[block_x][band_to_use].size()) );
219 if (band_to_use >= static_cast<int>(
TMR_n_BND_m[block_x][band_to_use].size()) )
221 return pad_pixel( block_x, block_y, band ) != 0xFFFFFFFF;
Stream interface for VIL image loaders.
vxl_uint_32 blocked_image_data_offset() const
std::vector< std::vector< std::vector< vxl_uint_32 > > > BMR_n_BND_m
virtual vil_streampos read(void *buf, vil_streampos n)=0
Read n bytes into buf. Returns number of bytes read.
static void maybe_endian_swap(char *a, unsigned sizeOfAInBytes, vil_pixel_format pixFormat)
vil_nitf2_data_mask_table(unsigned int numBlocksX, unsigned int numBlocksY, unsigned int numBands, const std::string &imode)
Stream interface for VIL image loaders.
unsigned int num_blocks_x
vxl_uint_32 block_band_has_pad(unsigned int block_x, unsigned int block_y, int band=-1) const
unsigned int num_blocks_y
vxl_uint_32 block_band_offset(unsigned int block_x, unsigned int block_y, int band=-1) const
if imode == "S", then the band argument is used and I will return the offset to 'band' if imode !...
std::vector< std::vector< std::vector< vxl_uint_32 > > > TMR_n_BND_m
bool parse(vil_stream *stream)
vxl_uint_32 pad_pixel(unsigned int block_x, unsigned int block_y, int band) const
band argument is ignored if imode != "S"...
vxl_uint_32 block_band_present(unsigned int block_x, unsigned int block_y, int band=-1) const
Returns true iff this block is present in the data. False otherwise.