vil_nitf2_data_mask_table.h
Go to the documentation of this file.
1 // vil_nitf2: Written by Rob Radtke (rob@) and Harry Voorhees (hlv@) of
2 // Stellar Science Ltd. Co. (stellarscience.com) for
3 // Air Force Research Laboratory, 2005.
4 
5 #ifndef VIL_NITF2_DATA_MASK_TABLE_H
6 #define VIL_NITF2_DATA_MASK_TABLE_H
7 //:
8 // \file
9 
10 #include <vector>
11 #include <string>
12 #include <vxl_config.h>
13 #ifdef _MSC_VER
14 # include <vcl_msvc_warnings.h>
15 #endif
16 #include <vil/vil_pixel_format.h>
17 
18 class vil_stream;
19 
20 //: This class is responsible for parsing a NITF 2.1 data mask table.
21 // When present, a vil_nitf2_image_subheader() will use this class
22 // to extract the table from the file. It reads a vil_stream, via
23 // the parse() method and will return false if it failed.
25 {
26  public:
27  vil_nitf2_data_mask_table( unsigned int numBlocksX, unsigned int numBlocksY,
28  unsigned int numBands, const std::string& imode );
29  bool parse( vil_stream* stream );
30 
31  //: If this function returns true, then you may call \sa block_band_offset()
32  bool has_offset_table() const { return BMR_n_BND_m.size() > 0; }
33 
34  //: If this function returns true, then you may call \sa pad_pixel()
35  bool has_pad_pixel_table() const { return TMR_n_BND_m.size() > 0; }
36 
37  vxl_uint_32 blocked_image_data_offset() const;
38 
39  //: Returns true iff this block is present in the data. False otherwise.
40  // If this returns false, then there is not sense calling block_band_offset
41  // for this band/block combination. It will return 0xFFFFFFFF.
42  // If this returns false, then this entire block/band is considered to be blank.
43  vxl_uint_32 block_band_present( unsigned int block_x, unsigned int block_y, int band = -1) const;
44 
45  //:
46  // if imode == "S", then the band argument is used and I will return the offset to 'band'
47  // if imode != "S", then the band argument is ignored, and I will return the offset to the
48  // beginning of the requested block
49  vxl_uint_32 block_band_offset( unsigned int block_x, unsigned int block_y, int band = -1) const;
50 
51  //:
52  // band argument is ignored if imode != "S"... i.e. all bands have the same pad pixel in that case
53  vxl_uint_32 pad_pixel( unsigned int block_x, unsigned int block_y, int band ) const;
54 
55  vxl_uint_32 block_band_has_pad( unsigned int block_x, unsigned int block_y, int band = -1) const;
56 
57  static void maybe_endian_swap( char* a, unsigned sizeOfAInBytes, vil_pixel_format pixFormat );
58  static void maybe_endian_swap( char* a, unsigned sizeOfAInBytes, unsigned int bytesPerSample );
59  protected:
60  //Blocked Image Data Offset (in bytes)
61  vxl_uint_32 IMDATOFF;
62  //Block Mask Record Length (in bytes)
63  vxl_uint_16 BMRLNTH;
64  //Pad Pixel Mask Record Length (in bytes)
65  vxl_uint_16 TMRLNTH;
66  //Pad Output Pixel Code Length (in bits)
67  vxl_uint_16 TPXCDLNTH;
68  //Pad Output Pixel Code
69  // (it's an integer, but its length is TPXCDLNTH rounded up to the nearest byte)
70 #if VXL_HAS_INT_64
71  vxl_uint_64 TPXCD;
72 #else
73  vxl_uint_32 TPXCD;
74 #endif //VXL_HAS_INT_64
75 
76  //Block n, Band m Offset
77  //indexed BMR_n_BND_m[row][col][band] for i_mode = "S" else
78  //indexed BMR_n_BND_m[row][col]
79  std::vector< std::vector< std::vector< vxl_uint_32 > > > BMR_n_BND_m;
80  //Pad Pixel n, Band m
81  //indexed TMR_n_BND_m[row][col][band] for i_mode = "S" else
82  //indexed TMR_n_BND_m[row][col]
83  std::vector< std::vector< std::vector< vxl_uint_32 > > > TMR_n_BND_m;
84 
85  unsigned int num_blocks_x;
86  unsigned int num_blocks_y;
87  unsigned int num_bands;
88  std::string i_mode;
89 };
90 
91 #endif // VIL_NITF2_DATA_MASK_TABLE_H
vil_pixel_format
Describes the type of the concrete data.
bool has_offset_table() const
If this function returns true, then you may call.
This class is responsible for parsing a NITF 2.1 data mask table.
vxl_uint_32 blocked_image_data_offset() const
std::vector< std::vector< std::vector< vxl_uint_32 > > > BMR_n_BND_m
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.
Definition: vil_stream.h:21
bool has_pad_pixel_table() const
If this function returns true, then you may call.
vxl_uint_32 block_band_has_pad(unsigned int block_x, unsigned int block_y, int band=-1) const
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
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.