|
|
PDS_JP2
|
A JP2_Encoder encodes image pixel data into a JPEG2000 JP2 file. More...
#include <JP2_Encoder.hh>

Public Member Functions | |
| JP2_Encoder () | |
| ~JP2_Encoder () | |
| std::string | source () const |
| Get the PDS image data source pathname. | |
| JP2_Encoder & | source (const std::string &pathname) |
| Set the pathname to the PDS image data source. | |
| std::string | destination () const |
| Get the destination JP2 file pathname. | |
| JP2_Encoder & | destination (const std::string &pathname) |
| Set the destination JP2 file pathname. | |
| std::string | PDS_label_pathname () const |
| Get the PDS/JP2 label file pathname. | |
| JP2_Encoder & | PDS_label_pathname (const std::string &pathname) |
| Set the PDS/JP2 label file pathname. | |
| std::streamoff | image_data_location () const |
| Get the location of the image data in the source file. | |
| JP2_Encoder & | image_data_location (std::streamoff file_offset) |
| Set the location of the image data in the source file. | |
| unsigned int | image_bands () const |
| Get the number of bands (components) in the PDS image. | |
| JP2_Encoder & | image_bands (unsigned int bands) |
| Set the number of bands (components) in the PDS image. | |
| const Size_2D | image_size () const |
| Get the size of the source PDS image data. | |
| JP2_Encoder & | image_size (const Size_2D &size) |
| Set the size of the source PDS image data. | |
| unsigned int | pixel_bytes () const |
| Get the number of bytes per pixel. | |
| JP2_Encoder & | pixel_bytes (unsigned int bytes_per_pixel) |
| Set the number of bytes per pixel. | |
| unsigned int | pixel_bits () const |
| Get the pixel precision. | |
| JP2_Encoder & | pixel_bits (unsigned int bits_per_pixel) |
| Set the number of bits per pixel. | |
| bool | signed_data () const |
| Get the signedness of the pixel data. | |
| JP2_Encoder & | signed_data (bool data_is_signed) |
| Set the signedness of the data. | |
| bool | MSB_data () const |
| Test if the source data will be treated as MSB ordered. | |
| JP2_Encoder & | MSB_data (bool data_is_MSB) |
| Set the source data byte ordering. | |
| bool | swap_pixel_bytes () const |
| Test if multi-byte pixels will be reordered before being sent to the JPEG2000 codestream generation machinery. | |
| JP2_Encoder & | swap_pixel_bytes (bool swap_data) |
| Set if multi-byte pixels will be reordered before being sent to the JPEG2000 codestream generation machinery. | |
| unsigned int | line_prefix_bytes () const |
| Get the number of bytes preceeding each line of image pixel data. | |
| JP2_Encoder & | line_prefix_bytes (unsigned int prefix_bytes) |
| Set the number of bytes preceeding each line of image pixel data. | |
| unsigned int | line_suffix_bytes () const |
| Get the number of bytes following each line of image pixel data. | |
| JP2_Encoder & | line_suffix_bytes (unsigned int suffix_bytes) |
| Set the number of bytes following each line of image pixel data. | |
| const Size_2D | tile_size () const |
| Get the size of the JP2 image tiles. | |
| JP2_Encoder & | tile_size (const Size_2D &size) |
| Set the size of the JP2 image tiles. | |
| unsigned int | resolution_levels () const |
| Get the total number of codestream resolution levels. | |
| JP2_Encoder & | resolution_levels (unsigned int resolution_levels) |
| Set the total number of codestream resolution levels. | |
| unsigned int | quality_layers () const |
| Get the number of codestream quality layers. | |
| JP2_Encoder & | quality_layers (unsigned int quality_layers) |
| Set the number of codestream quality layers. | |
| double | bit_rate () const |
| Get the codestream compression bit-rate. | |
| JP2_Encoder & | bit_rate (double rate) |
| Set the codestream compression bit-rate. | |
| std::string | progression_order () const |
| Get the codestream progression order descriptor. | |
| JP2_Encoder & | progression_order (const std::string &progression) |
| Set the codestream progression order. | |
| const std::vector< Size_2D > | precinct_sizes () const |
| Get the precinct sizes for each resolution level. | |
| const Size_2D | precinct_size (unsigned int resolution_level=0) const |
| Get the precinct size for a given resolution level. | |
| JP2_Encoder & | precinct_sizes (const std::vector< Size_2D > &sizes) |
| Set the precinct sizes for each resolution level. | |
| JP2_Encoder & | precinct_size (const Size_2D &size, unsigned int resolution_level=0) |
| Set the precinct size for a given resolution level. | |
| const Size_2D | code_block_size () const |
| Get the code block size. | |
| JP2_Encoder & | code_block_size (const Size_2D &size) |
| Set the code block size. | |
| JP2_Box::JP2_Box_List & | added_boxes () |
| Get the list of user specified data boxes added to the JP2 file. | |
| JP2_Encoder & | add_box (JP2_Box *box) |
| Add a data box to the JP2 file. | |
| bool | remove_box (JP2_Box *box) |
| Remove a data box from the list of user specified boxes. | |
| const unsigned char * | producer_UUID () const |
| Get the product producer signature UUID value. | |
| JP2_Encoder & | producer_UUID (const unsigned char *id) |
| Set the product producer signature UUID value. | |
| std::string | comment () const |
| Get the codestream comment. | |
| JP2_Encoder & | comment (const std::string &text) |
| Set comment text to be added to the codestream. | |
| bool | ready () const |
| Test if the encoder is ready to compress the image data. | |
| std::string | reasons () const |
| Get a description of the reasons that the encoder is not ready. | |
| int | needs () const |
| Indicates what the encoder needs to do its job. | |
| JP2_Encoder_Error * | encoder_error () const |
| Get the JP2_Encoder_Error describing the last encoder error that occurred. | |
| long long | encode () |
| Encode the image source to a JPEG2000 JP2 destination. | |
| void | open () |
| Open the source JP2 file. | |
| long long | write_header () |
| Write the required metadata boxes to the JP2 file. | |
| long long | write_user_boxes () |
| Write user specified boxes to the JP2 file. | |
| long long | write_codestream () |
| Generate the compressed image data JPEG2000 codestream and write it to the JP2 file. | |
| JP2_Encoder & | incremental_flush_bytes (long long bytes) |
| Set the rate at which compressed image data will be written to the output JP2 file. | |
| long long | incremental_flush_bytes () const |
| Get the rate at which compressed image data will be written to the output JP2 file. | |
| JP2_Encoder & | incremental_flush_lines (unsigned int lines) |
| Set the rate at which compressed image data will be written to the output JP2 file. | |
| int | incremental_flush_lines () const |
| Get the rate at which compressed image data will be written to the output JP2 file. | |
| long long | close () |
| int | invalid_precinct_size (const std::vector< Size_2D > &sizes) |
| Check for valid precinct sizes. | |
Static Public Attributes | |
| static const char *const | ID |
| Class identification name with source code version and date. | |
| static const unsigned int | DEFAULT_RESOLUTION_LEVELS = 6 |
| Default number of resolution levels. | |
| static const unsigned int | MAX_RESOLUTION_LEVELS = 32 |
| Maximum number of resolution levels. | |
| static const unsigned int | MAX_QUALITY_LAYERS = 16384 |
| Maximum number of quality layers. | |
| static const char *const | UUID_INFO_BOX_NAME = "uinf" |
| PDS label reference information UUID Info JP2 container box name. | |
| static const char *const | UUID_BOX_NAME = "ulst" |
| Data provider UUID JP2 box name. | |
| static const int | UUID_SIZE = 16 |
| Size of the UUID data content. | |
| static const char *const | URL_BOX_NAME = "url " |
| PDS label relative filename URL JP2 box name. | |
| static const int | MIN_STRIPE_HEIGHT = 256 |
| Image data stripe minimum and maximum number of lines. | |
| static const int | MAX_STRIPE_HEIGHT = 8192 |
| static const int | NEEDS_SOURCE = 1 << 0 |
| What the encoder needs to do its job. | |
| static const int | NEEDS_DESTINATION = 1 << 1 |
| static const int | NEEDS_IMAGE = 1 << 2 |
| static const int | ENCODER_EXCEPTION = 66 |
| JP2_Encoder_Error exception signal value. | |
Protected Member Functions | |
| void | read_stripe (std::istream &source, int band, int line, int lines, kdu_int16 *buffer) |
| Fill an image data buffer with pixel data from a source stream. | |
| void | read_stripe (std::istream &source, int band, int line, int lines, kdu_int32 *buffer) |
| Fill an image data buffer with pixel data from a source stream. | |
Protected Attributes | |
| std::string | Image_Source |
| Image source pathname. | |
| std::string | JP2_Pathname |
| Image destination pathname. | |
| std::streamoff | Image_Offset |
| Image data location as a byte offset within the source file. | |
| unsigned int | Image_Bands |
| Total image bands (components). | |
| Size_2D | Image_Size |
| unsigned int | Line_Prefix_Bytes |
| The number of bytes preceeding and following each line of pixel bytes. | |
| unsigned int | Line_Suffix_Bytes |
| unsigned int | Pixel_Bytes |
| Pixel datum size in bytes. | |
| unsigned int | Pixel_Bits |
| Pixel precision bits. | |
| bool | Signed_Data |
| Whether pixel data is to be treated as signed. | |
| JP2_Box::JP2_Box_List | Added_Boxes |
| std::string | PDS_Label_Pathname |
| PDS label file pathname to be placed in a UUID Info URL box. | |
| unsigned char * | Producer_UUID |
| The UUID to be placed in a UUID List box inside a UUID Info box. | |
| std::string | Comment |
| Comment segment to be added to the codestream. | |
| bool | Swap_Pixel_Bytes |
| Whether pixel bytes should be reordered before be encoded. | |
| unsigned int | Resolution_Levels |
| The number of resolution levels to encode. | |
| unsigned int | Quality_Layers |
| double | Bit_Rate |
| std::string | Progression_Order |
| The codestream progression order to be used. | |
| Size_2D | Tile_Size |
| Tile size for codestream structure organization. | |
| std::vector< Size_2D > | Precinct_Sizes |
| Precinct sizes for codestream structure organization within tiles. | |
| Size_2D | Code_Block_Size |
| Code block size for codestream packet encoding within precincts. | |
| long long | Incremental_Flush_Bytes |
A JP2_Encoder encodes image pixel data into a JPEG2000 JP2 file.
After a JP2_Encoder is constructed it must be configured. The encoder must be configured with at least an input image data source file, an output JP2 destination file and the image data characterization with at least the image size and number of pixel bytes or pixel bits. By default the image data is assumed to be located at the beginning the source file, has one band (i.e. component), is unsigned, is MSB ordered (if multi-byte) and has no line prefix or suffix bytes.
The JP2_Encoder can also be configured with various JPEG2000 codestream organization information. By default the codestream will be untiled, have DEFAULT_RESOLUTION_LEVELS resolution levels, use Precint-Component-Resolution-Level progression order, have a 64x64 code block size and use precinct sizes determined by the underlying codestream generation machinery.
Once the JP2_Encoder is ready encoding can be started to generate the JP2 file from the image data source. Lossless image data compression will be used to generate the JPEG2000 codestream. A JP2_Encoder may be reused with or without reconfiguration between uses.
This implementation employs the Kakadu Software libraries.
| JP2_Encoder | ( | ) |
References Bit_Rate, Code_Block_Size, DEFAULT_RESOLUTION_LEVELS, Image_Bands, Image_Offset, Image_Size, Image_Source, INCREMENTAL_FLUSH_BYTES, Incremental_Flush_Bytes, JP2_Pathname, Line_Prefix_Bytes, Line_Suffix_Bytes, PDS_Label_Pathname, Pixel_Bits, Pixel_Bytes, Precinct_Sizes, Producer_UUID, PROGRESSION_ORDER, Progression_Order, Quality_Layers, Resolution_Levels, Signed_Data, Swap_Pixel_Bytes, and Tile_Size.
Referenced by comment(), destination(), image_bands(), image_data_location(), incremental_flush_bytes(), line_prefix_bytes(), line_suffix_bytes(), PDS_label_pathname(), swap_pixel_bytes(), and tile_size().
| ~JP2_Encoder | ( | ) |
References Producer_UUID.
|
inline |
Get the PDS image data source pathname.
References Image_Source.
Referenced by main(), read_stripe(), and read_stripe().
| JP2_Encoder & source | ( | const std::string & | pathname | ) |
Set the pathname to the PDS image data source.
N.B.: If the source has already been opened and the pathname is different than the previous pathname, the source is closed.
| pathname | The image data source pathname. |
References close(), and Image_Source.
|
inline |
Get the destination JP2 file pathname.
References JP2_Pathname.
|
inline |
Set the destination JP2 file pathname.
| pathname | The destination file pathname string. |
References JP2_Encoder(), and JP2_Pathname.
|
inline |
Get the PDS/JP2 label file pathname.
References PDS_Label_Pathname.
|
inline |
Set the PDS/JP2 label file pathname.
Only the filename portion of the pathname is used for the relative filename URL reference when the user boxes are written to the JP2 file.
| pathname | The PDS/JP2 label file pathname string. If NULL no label filename reference URL box or producer signature UUUID box will be included in the JP2 file. |
References JP2_Encoder(), and PDS_Label_Pathname.
|
inline |
Get the location of the image data in the source file.
References Image_Offset.
|
inline |
Set the location of the image data in the source file.
| file_offset | The byte offset where the image data starts in the source file. |
References Image_Offset, and JP2_Encoder().
|
inline |
Get the number of bands (components) in the PDS image.
References Image_Bands.
|
inline |
Set the number of bands (components) in the PDS image.
| bands | The number of bands in the PDS image. |
References Image_Bands, and JP2_Encoder().
|
inline |
Get the size of the source PDS image data.
References Image_Size.
| JP2_Encoder & image_size | ( | const Size_2D & | size | ) |
Set the size of the source PDS image data.
| size | A Size_2D object containing the image width and height. |
| invalid_argument | If either the image width or height is zero. |
References Size_2D::Height, ID, Image_Size, and Size_2D::Width.
|
inline |
Get the number of bytes per pixel.
References Pixel_Bytes.
Referenced by pixel_bits().
| JP2_Encoder & pixel_bytes | ( | unsigned int | bytes_per_pixel | ) |
Set the number of bytes per pixel.
N.B.: If the number of pixel bytes is 1 the data will be set to unsigned.
| bytes_per_pixel | The number of bytes per pixel. Only the values 1, 2 and 4 are allowed. |
| invalid_argument | If the argument is not 1, 2 or 4. |
| length_error | If the number of pixel bytes is less than are needed to hold the pixel bits. |
References ID, Pixel_Bits, Pixel_Bytes, and signed_data().
|
inline |
Get the pixel precision.
References Pixel_Bits.
| JP2_Encoder & pixel_bits | ( | unsigned int | bits_per_pixel | ) |
Set the number of bits per pixel.
The number of pixel bytes is enlarged, if necessary, to accommodate all the pixel bits.
N.B.: If the number of pixel bits is less than the number of bits in the pixel bytes the data will be set to unsigned.
| bits_per_pixel | The number of bits per pixel. The maximum value is 32. |
| invalid_argument | If the argument is greater than 32. |
References ID, Pixel_Bits, Pixel_Bytes, pixel_bytes(), and signed_data().
|
inline |
Get the signedness of the pixel data.
References Signed_Data.
Referenced by pixel_bits(), and pixel_bytes().
| JP2_Encoder & signed_data | ( | bool | data_is_signed | ) |
Set the signedness of the data.
N.B.: If the number of pixel bytes is 1, or the number of pixel bits is less than the number of bits in the pixel bytes, then the data is unsigned by definition. In such cases the argument will be forced to false.
| data_is_signed | true if the data is to be treated as signed; false otherwise. |
References Pixel_Bits, Pixel_Bytes, and Signed_Data.
| bool MSB_data | ( | ) | const |
Test if the source data will be treated as MSB ordered.
pixel byte swapping has been enabled, or the host system is high endian and pixel byte swapping has not been enabled; false otherwise. References Swap_Pixel_Bytes.
| JP2_Encoder & MSB_data | ( | bool | data_is_MSB | ) |
Set the source data byte ordering.
N.B.: The pixel byte swapping state is set by this method: If the host system is not high endian and the source data is MSB ordered, or the host system is high endian and the source data is LSB ordered, pixel byte swapping will be enabled; otherwise pixel byte swapping will be disabled.
| data_is_MSB | true if the source data is MSB ordered; false if the source data is LSB ordered. |
References Swap_Pixel_Bytes.
|
inline |
Test if multi-byte pixels will be reordered before being sent to the JPEG2000 codestream generation machinery.
References Swap_Pixel_Bytes.
|
inline |
Set if multi-byte pixels will be reordered before being sent to the JPEG2000 codestream generation machinery.
| swap_data | true if multi-byte pixels are to be reordered; false otherwise. |
References JP2_Encoder(), and Swap_Pixel_Bytes.
|
inline |
Get the number of bytes preceeding each line of image pixel data.
References Line_Prefix_Bytes.
|
inline |
Set the number of bytes preceeding each line of image pixel data.
| prefix_bytes | The number of line prefix bytes. |
References JP2_Encoder(), and Line_Prefix_Bytes.
|
inline |
Get the number of bytes following each line of image pixel data.
References Line_Suffix_Bytes.
|
inline |
Set the number of bytes following each line of image pixel data.
| suffix_bytes | The number of line suffix bytes. |
References JP2_Encoder(), and Line_Suffix_Bytes.
|
inline |
Get the size of the JP2 image tiles.
References Tile_Size.
|
inline |
Set the size of the JP2 image tiles.
If the tile width is zero the width of the image will be use. If the tile height is zero height of the image will be used.
| size | A Size_2D object containing the JP2 tiles width and height. |
References JP2_Encoder(), and Tile_Size.
|
inline |
Get the total number of codestream resolution levels.
N.B.: The number of resolution levels is one more than the number of JPEG2000 decomposition levels.
References Resolution_Levels.
Referenced by resolution_levels().
| JP2_Encoder & resolution_levels | ( | unsigned int | resolution_levels | ) |
Set the total number of codestream resolution levels.
N.B.: The number of resolution levels is one more than the number of JPEG2000 decomposition levels.
| resolution_levels | The total number of codestream resolution levels. |
| invalid_argument | If the specified number of resolution levels is greater than the MAX_RESOLUTION_LEVELS allowed. |
References ID, MAX_RESOLUTION_LEVELS, Precinct_Sizes, Resolution_Levels, and resolution_levels().
|
inline |
Get the number of codestream quality layers.
References Quality_Layers.
Referenced by quality_layers().
| JP2_Encoder & quality_layers | ( | unsigned int | quality_layers | ) |
Set the number of codestream quality layers.
The default number of quality layers is 1. The maximum number of layers is MAX_QUALITY_LAYERS (16384).
| quality_layers | The number of codestream quality layers. A value of zero will be set to 1. |
| invalid_argument | If the specified number of quality layers is greater than the maximum of the MAX_QUALITY_LAYERS allowed. |
References ID, MAX_QUALITY_LAYERS, Quality_Layers, and quality_layers().
|
inline |
Get the codestream compression bit-rate.
References Bit_Rate.
| JP2_Encoder & bit_rate | ( | double | rate | ) |
Set the codestream compression bit-rate.
The compression bit-rate is expressed in terms of the ratio between the total number of compressed bits (including headers) and the product of the largest horizontal and vertical image component dimensions. This may also be thought of as the number of bits per pixel used in the compressed codestream.
| rate | The codestream compression bit-rate. A value of zero means that loss-less, reversible compression is to be used. A value less than zero is set to zero. |
References Bit_Rate.
|
inline |
Get the codestream progression order descriptor.
References Progression_Order.
| JP2_Encoder & progression_order | ( | const std::string & | progression | ) |
Set the codestream progression order.
The progression order is described by a string which specifies the order in which the JPEG2000 codestream is written. A JPEG2000 codestream has Position (image area), Component (image band), Resolution and Layer (quality) dimensions. The codestream progression order is specified as the first letters of each dimension in the order in which they are to be written; the first dimension specified varies the most slowly while the last dimension specified varies the most quickly.
The default progression order is set at compile time by the value of the DEFAULT_PROGRESSION_ORDER symbol.
| progression | A string specifying the progression order. |
| invalid_argument | If the progression order string is not four characters containing 'P', 'C', 'R' and 'L' in some order. |
References ID, and Progression_Order.
|
inline |
Get the precinct sizes for each resolution level.
References Precinct_Sizes.
| const Size_2D precinct_size | ( | unsigned int | resolution_level = 0 | ) | const |
Get the precinct size for a given resolution level.
| resolution_level | The resoultion level index (0-based) for which the precinct size is to be obtained. |
| invalid_argument | If the resolution level is greater than or equal to the number of resolution levels. |
References ID, and Precinct_Sizes.
| JP2_Encoder & precinct_sizes | ( | const std::vector< Size_2D > & | sizes | ) |
Set the precinct sizes for each resolution level.
Each precinct size dimension must be a non-zero power of two.
If the number of precinct sizes is greater than the number of resolution levels the excess size values will be ignored. If the number of precinct sizes is less than the number of resolution levels the last size will be used for the sizes of all remaining resolution levels.
| sizes | A list (vector<Size_2D>) of precinct sizes in resolution number order. |
| invalid_argument | If any precinct size dimension is not a non-zero power of two. |
References ID, invalid_precinct_size(), Precinct_Sizes, and Resolution_Levels.
| JP2_Encoder & precinct_size | ( | const Size_2D & | size, |
| unsigned int | resolution_level = 0 ) |
Set the precinct size for a given resolution level.
| size | A precinct size (Size_2D) for the resolution level. |
| resolution_level | The resoultion level index (0-based) for which the precinct size is to be obtained. |
| invalid_argument | If the resolution level is greater than or equal to the number of resolution levels. |
References Size_2D::Height, ID, UA::HiRISE::power_of_2(), Precinct_Sizes, Resolution_Levels, and Size_2D::Width.
|
inline |
Get the code block size.
References Code_Block_Size.
| JP2_Encoder & code_block_size | ( | const Size_2D & | size | ) |
Set the code block size.
| size | The size (Size_2D) of the code block. |
| invalid_argument | If either dimension is 0 or greater than 64. |
References Code_Block_Size, Size_2D::Height, ID, and Size_2D::Width.
|
inline |
Get the list of user specified data boxes added to the JP2 file.
added to the JP2 file, or that were added if the file has already been written. References Added_Boxes.
| JP2_Encoder & add_box | ( | JP2_Box * | box | ) |
Add a data box to the JP2 file.
The box is placed on the list of user specified
boxes that will be added to included in the JP2 file when it is written.
| box | A JP2_Box pointer. |
References Added_Boxes.
| bool remove_box | ( | JP2_Box * | box | ) |
Remove a data box from the list of user specified boxes.
| box | A JP2_Box pointer. |
References Added_Boxes.
|
inline |
Get the product producer signature UUID value.
References Producer_UUID.
| JP2_Encoder & producer_UUID | ( | const unsigned char * | id | ) |
Set the product producer signature UUID value.
The producer signature UUID value is intended to provide a unique identifier for the product. The UUID will be placed in a UUID List box inside a UUID Info box.
N.B.: A producer signature will only be included in the JP2 file if a PDS label
pathname has been specified.
| id | An array of UUID_SIZE (16) characters (N.B.: This is not a null-terminated character string) containing the product producer UUID value. If NULL no product producer signature is to be used. |
References Producer_UUID, and UUID_SIZE.
|
inline |
Get the codestream comment.
References Comment.
|
inline |
Set comment text to be added to the codestream.
| text | A string to be added to the codestream as a comment. If the string is empty no comment will be added to the codestream. |
References Comment, and JP2_Encoder().
| bool ready | ( | ) | const |
Test if the encoder is ready to compress the image data.
References Image_Bands, Image_Size, Image_Source, JP2_Pathname, and Pixel_Bytes.
Referenced by open().
| string reasons | ( | ) | const |
Get a description of the reasons that the encoder is not ready.
needs. This will be the empty string if the encoder is ready to compress image data. References Image_Bands, Image_Size, Image_Source, JP2_Pathname, and Pixel_Bytes.
Referenced by open().
| int needs | ( | ) | const |
Indicates what the encoder needs to do its job.
The returned bit flag value will be zero if the encoder has all the required user-supplied information. Otherwise it will have one or more of the following bits set:
source PDS file pathname has not been specified. destination PDS/JP2 file pathname has not been specified. size, number of bands and bytes per pixel - has not been completely defined. @return A bit flag value.
References Image_Bands, Image_Size, Image_Source, JP2_Pathname, NEEDS_DESTINATION, NEEDS_IMAGE, NEEDS_SOURCE, and Pixel_Bytes.
| JP2_Encoder_Error * encoder_error | ( | ) | const |
Get the JP2_Encoder_Error describing the last encoder error that occurred.
The JP2_Encoder_Error contains a Message string data member describing the last error. This will be the empty string if no error has occurred.
Referenced by main().
| long long encode | ( | ) |
Encode the image source to a JPEG2000 JP2 destination.
This function is the main workhorse of the class. It is responsible for doing the actual work of generating a JP2 file.
The destination JP2 file is opened. The JP2 metadata boxes are written to the file, including the required header boxes and any user
boxes that have been added and the box to contain a producer
signature UUID and PDS label filename URL if this has been specified. The source pixel data is written to a codestream box. The completed JP2 file is then closed.
References close(), open(), write_codestream(), write_header(), and write_user_boxes().
Referenced by main().
| void open | ( | ) |
Open the source JP2 file.
References ID, JP2_Pathname, ready(), and reasons().
Referenced by encode(), and write_header().
| long long write_header | ( | ) |
Write the required metadata boxes to the JP2 file.
References Bit_Rate, Code_Block_Size, Comment, DEFAULT_RESOLUTION_LEVELS, ID, Image_Bands, Image_Size, incremental_flush_lines(), open(), Pixel_Bits, Pixel_Bytes, Precinct_Sizes, Progression_Order, Quality_Layers, Resolution_Levels, Signed_Data, and Tile_Size.
Referenced by encode(), write_codestream(), and write_user_boxes().
| long long write_user_boxes | ( | ) |
Write user specified boxes to the JP2 file.
If a PDS label
filename has been specified a UUID Info box containing a UUID box with producer signature and a URL box with a relative file reference to the PDS label filename is written to the JP2 file.
References Added_Boxes, PDS_Label_Pathname, Producer_UUID, JP2_Box::type_code(), URL_BOX_NAME, UUID_BOX_NAME, UUID_INFO_BOX_NAME, UUID_SIZE, and write_header().
Referenced by encode().
| long long write_codestream | ( | ) |
Generate the compressed image data JPEG2000 codestream and write it to the JP2 file.
References Bit_Rate, ENCODER_EXCEPTION, ID, Image_Bands, Image_Size, Image_Source, incremental_flush_lines(), MAX_STRIPE_HEIGHT, MIN_STRIPE_HEIGHT, Pixel_Bits, Pixel_Bytes, Quality_Layers, read_stripe(), and write_header().
Referenced by encode().
|
inline |
Set the rate at which compressed image data will be written to the output JP2 file.
Incremental codestream flushing is when the compressed image data that has accumulated in memory is periodically written to the output JP2 file during the process of codestream
generation. Incremental codestream flushing is desirable to avoid retaining the entire codestream in memory when a large image is being processed; the memory requirements to hold the entire codestream may be more than the system can provide. The rate of codestream flushing is controlled by the number of image lines that have been compressed since the last flush or the start of compression. Since the issue of incremental codestream flushing is the amount of system memory that is used this method allows the rate to be expressed in terms of bytes. This should be as large as possible, or zero to disable incremental flushing, to allow for the most efficient compression operations as possible.
However, incremental flushing may not actually occur at the requested rate, or may not occur at all, depending on the progression order and other codestream organization issues. In addition, incremental flushing may generate additional JPEG2000 tile-part segments beyond the initial tile-part segment for each tile, and each of these additional tile-parts will require that additional space be reserved in the tile-part length segments of the main header. Since the actual number of tile-parts generated by incremental flushing depends on the data and thus will not be known until the codestream generation has been completed - at which time the reserved space for the tile-part length segments are overwritten with the actual location information
The default flush rate is set at compile time by the value of the INCREMENTAL_FLUSH_BYTES symbol.
| bytes | The requested maximum amount of memory to use in generating the compressed image data codestream before the codestream will be flushed to the output JP2 file. If zero incremental flushing is disabled. |
References Incremental_Flush_Bytes, and JP2_Encoder().
|
inline |
Get the rate at which compressed image data will be written to the output JP2 file.
References Incremental_Flush_Bytes.
Referenced by incremental_flush_lines().
| JP2_Encoder & incremental_flush_lines | ( | unsigned int | lines | ) |
Set the rate at which compressed image data will be written to the output JP2 file.
The incremental flush rate is set in terms of the number of image lines to compress before flushing the codestream from memory to the JP2 file. This will set the maximum flush bytes.
Warning: Since the determining the maximum flush bytes from a number of image lines depends on the image width and number of pixel bytes if these have not yet been set the maximum flush bytes will be set to zero thus disabling incremental flushing.
| lines | The number of image lines to compress before flushing the codestream. If zero incremental flushing is disabled. |
References Image_Size, incremental_flush_bytes(), and Pixel_Bytes.
| int incremental_flush_lines | ( | ) | const |
Get the rate at which compressed image data will be written to the output JP2 file.
The incremental flush rate, in terms of the number of image lines, is determined by the requested maximum flush bytes. If the maximum flush bytes is zero or the size of an image band is greater than or equal to the maximum flush bytes the flush lines will be zero (no incremental flusing will occur). Otherwise the number of flush lines is set to the height of an image tile. If number of bytes in these image lines for a single band is greater than the maximum flush bytes the number of flush lines is reduced by 1024 until the number of bytes in the lines is less than or equal to the maximum flush bytes.
References Image_Size, Incremental_Flush_Bytes, Pixel_Bytes, and Tile_Size.
Referenced by write_codestream(), and write_header().
| int invalid_precinct_size | ( | const std::vector< Size_2D > & | sizes | ) |
Check for valid precinct sizes.
Valid precinct sizes are non-zero powers of 2.
| sizes | A vector of precinct Size_2D values. |
References UA::HiRISE::power_of_2().
Referenced by precinct_sizes().
|
protected |
Fill an image data buffer with pixel data from a source stream.
The lines of source image data starting with the specified line of the specified band are read into the buffer as a contiguous sequence of bytes.
| source | An istream that has been opened on the source file. |
| band | The index of the image band from which pixel data is to be read. |
| line | The starting index of the image line from which pixel data it to be read. |
| lines | The number of image lines to read. |
| buffer | Buffer storage to hold at least lines * image_width pixels where each pixel is stored as a 16-bit signed integer. |
References ID, Image_Offset, Image_Size, Line_Prefix_Bytes, Line_Suffix_Bytes, Pixel_Bits, Pixel_Bytes, Signed_Data, source(), and Swap_Pixel_Bytes.
Referenced by write_codestream().
|
protected |
Fill an image data buffer with pixel data from a source stream.
The lines of source image data starting with the specified line of the specified band are read into the buffer as a contiguous sequence of bytes.
| source | An istream that has been opened on the source file. |
| band | The index of the image band from which pixel data is to be read. |
| line | The starting index of the image line from which pixel data it to be read. |
| lines | The number of image lines to read. |
| buffer | Buffer storage to hold at least lines * image_width pixels where each pixel is stored as a 32-bit signed integer. |
References ID, Image_Offset, Image_Size, Line_Prefix_Bytes, Line_Suffix_Bytes, Pixel_Bits, Pixel_Bytes, Signed_Data, source(), and Swap_Pixel_Bytes.
|
static |
Class identification name with source code version and date.
Referenced by code_block_size(), image_size(), open(), pixel_bits(), pixel_bytes(), precinct_size(), precinct_size(), precinct_sizes(), progression_order(), quality_layers(), read_stripe(), read_stripe(), resolution_levels(), write_codestream(), and write_header().
|
static |
Default number of resolution levels.
Referenced by JP2_Encoder(), and write_header().
|
static |
Maximum number of resolution levels.
Referenced by resolution_levels().
|
static |
Maximum number of quality layers.
Referenced by quality_layers().
|
static |
PDS label reference information UUID Info JP2 container box name.
Referenced by write_user_boxes().
|
static |
Data provider UUID JP2 box name.
Referenced by write_user_boxes().
|
static |
Size of the UUID data content.
Referenced by producer_UUID(), and write_user_boxes().
|
static |
PDS label relative filename URL JP2 box name.
Referenced by write_user_boxes().
|
static |
Image data stripe minimum and maximum number of lines.
Referenced by write_codestream().
|
static |
Referenced by write_codestream().
|
static |
|
static |
Referenced by needs().
|
static |
Referenced by needs().
|
static |
JP2_Encoder_Error exception signal value.
Referenced by write_codestream().
|
protected |
Image source pathname.
Referenced by JP2_Encoder(), needs(), ready(), reasons(), source(), source(), and write_codestream().
|
protected |
Image destination pathname.
Referenced by destination(), destination(), JP2_Encoder(), needs(), open(), ready(), and reasons().
|
protected |
Image data location as a byte offset within the source file.
Referenced by image_data_location(), image_data_location(), JP2_Encoder(), read_stripe(), and read_stripe().
|
protected |
Total image bands (components).
Referenced by image_bands(), image_bands(), JP2_Encoder(), needs(), ready(), reasons(), write_codestream(), and write_header().
|
protected |
|
protected |
The number of bytes preceeding and following each line of pixel bytes.
The line prefix and suffix bytes are to be skipped when the image data is being read.
Referenced by JP2_Encoder(), line_prefix_bytes(), line_prefix_bytes(), read_stripe(), and read_stripe().
|
protected |
Referenced by JP2_Encoder(), line_suffix_bytes(), line_suffix_bytes(), read_stripe(), and read_stripe().
|
protected |
Pixel datum size in bytes.
Referenced by incremental_flush_lines(), incremental_flush_lines(), JP2_Encoder(), needs(), pixel_bits(), pixel_bytes(), pixel_bytes(), read_stripe(), read_stripe(), ready(), reasons(), signed_data(), write_codestream(), and write_header().
|
protected |
Pixel precision bits.
Referenced by JP2_Encoder(), pixel_bits(), pixel_bits(), pixel_bytes(), read_stripe(), read_stripe(), signed_data(), write_codestream(), and write_header().
|
protected |
Whether pixel data is to be treated as signed.
Referenced by JP2_Encoder(), read_stripe(), read_stripe(), signed_data(), signed_data(), and write_header().
|
protected |
Referenced by add_box(), added_boxes(), remove_box(), and write_user_boxes().
|
protected |
PDS label file pathname to be placed in a UUID Info URL box.
Referenced by JP2_Encoder(), PDS_label_pathname(), PDS_label_pathname(), and write_user_boxes().
|
protected |
The UUID to be placed in a UUID List box inside a UUID Info box.
Referenced by JP2_Encoder(), producer_UUID(), producer_UUID(), write_user_boxes(), and ~JP2_Encoder().
|
protected |
Comment segment to be added to the codestream.
Referenced by comment(), comment(), and write_header().
|
protected |
Whether pixel bytes should be reordered before be encoded.
Referenced by JP2_Encoder(), MSB_data(), MSB_data(), read_stripe(), read_stripe(), swap_pixel_bytes(), and swap_pixel_bytes().
|
protected |
The number of resolution levels to encode.
N.B.: The number of resolution levels is one more than the number of JPEG2000 decomposition levels.
Referenced by JP2_Encoder(), precinct_size(), precinct_sizes(), resolution_levels(), resolution_levels(), and write_header().
|
protected |
Referenced by JP2_Encoder(), quality_layers(), quality_layers(), write_codestream(), and write_header().
|
protected |
Referenced by bit_rate(), bit_rate(), JP2_Encoder(), write_codestream(), and write_header().
|
protected |
The codestream progression order to be used.
Referenced by JP2_Encoder(), progression_order(), progression_order(), and write_header().
|
protected |
Tile size for codestream structure organization.
Referenced by incremental_flush_lines(), JP2_Encoder(), tile_size(), tile_size(), and write_header().
|
protected |
Precinct sizes for codestream structure organization within tiles.
Referenced by JP2_Encoder(), precinct_size(), precinct_size(), precinct_sizes(), precinct_sizes(), resolution_levels(), and write_header().
|
protected |
Code block size for codestream packet encoding within precincts.
Referenced by code_block_size(), code_block_size(), JP2_Encoder(), and write_header().
|
protected |
Referenced by incremental_flush_bytes(), incremental_flush_bytes(), incremental_flush_lines(), and JP2_Encoder().