Definition in file vil_nitf2_image.h.
#include <vcl_vector.h>
#include <vcl_cassert.h>
#include <vil/vil_stream.h>
#include "vil_nitf2_image_subheader.h"
#include "vil_nitf2_header.h"
#include <vil/vil_file_format.h>
Go to the source code of this file.
Classes | |
| class | vil_nitf2_file_format |
| class | vil_nitf2_image |
| Class for reading NITF 2.1 imagery files. More... | |
Functions | |
| template<class T> | |
| T | get_bits (const T *in_val, unsigned int i0, unsigned int ni) |
| This function does a lot of work for. | |
| template<class T> | |
| T * | byte_align_data (T *in_data, unsigned int num_samples, unsigned int in_bits_per_sample, T *out_data) |
| This function will byte align the data in in_data and store the result in out_data. | |
| template<> | |
| bool * | byte_align_data< bool > (bool *in_data, unsigned int num_samples, unsigned int in_bits_per_sample, bool *out_data) |
|
||||||||||||||||||||||||
|
This function will byte align the data in in_data and store the result in out_data. For example, let's say that you had in_data is of type unsigned char and contains the following data: 110010111001111010000110. In other words: in_data[0] = 203 (11001011) in_data[1] = 158 (10011110) in_data[2] = 134 (10000110) Let's further say you called this function like this: byte_align_data( in_data, 8, 3, out_data ). Then, when the function finished, out_data would look like this: out_data[0] = 6 (00000110) out_data[1] = 2 (00000010) out_data[2] = 7 (00000111) out_data[3] = 1 (00000001) out_data[4] = 7 (00000111) out_data[5] = 2 (00000010) out_data[6] = 0 (00000000) out_data[7] = 6 (00000110) Basically, what the function did was group the bitstream into groups of three and then store all of the values into out_data. It had to zero pad all the values (on the MSB side) to get them into out_data. That's why out_data is bigger. This function works with other unsigned types of data too. For example, let's say in_data was of type unsigned int and contained the following bits: 0100110010111000 0111101100000000 1111000011110000 (note that this bitstream is shown in big endian notation, that will not be the case if you are on a little endian machine -- this is just for illustration) in other words: in_data[0] = 19640 (0100110010111000) [shown in big endian for illustrative purposes only] in_data[1] = 31488 (0111101100000000) [shown in big endian for illustrative purposes only] in_data[2] = 61680 (1111000011110000) [shown in big endian for illustrative purposes only] Let's further say, you called this function like this byte_align_data( in_data, 4, 12, out_data ). Then out_data would be aligned along two byte (sixteen bit) boundaries and would look like this: out_data[0] = 1227 (0000010011001011) [shown in big endian for illustrative purposes only] out_data[1] = 2171 (0000100001111011) [shown in big endian for illustrative purposes only] out_data[2] = 15 (0000000000001111) [shown in big endian for illustrative purposes only] out_data[3] = 240 (0000000011110000) [shown in big endian for illustrative purposes only] Because of the fact that this function uses bit shifting operators, and the behavior of the vcl_right shift operator is implementation specific when applied to a negative number, you should probably only use this function on unsigned data.
Note that there is a specialization for the bool case which just casts it to an 8 bit quantity then calls this same function. This is because the logic in get_bits<> doesn't work for the bool case. Definition at line 313 of file vil_nitf2_image.h. |
|
||||||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
This function does a lot of work for.
Definition at line 231 of file vil_nitf2_image.h. |
1.4.4