Grok  7.6.6
Public Attributes | List of all members
grk::FileFormat Class Reference

JPEG 2000 file format reader/writer. More...

#include <FileFormat.h>

Inheritance diagram for grk::FileFormat:
grk::ICodeStream

Public Attributes

CodeStreamcodeStream
 handle to the J2K codec
More...
 
std::vector< jp2_procedure > * m_validation_list
 list of validation procedures More...
 
std::vector< jp2_procedure > * m_procedure_list
 list of execution procedures More...
 
uint32_t w
 
uint32_t h
 
uint16_t numcomps
 
uint8_t bpc
 
uint8_t C
 
uint8_t UnkC
 
uint8_t IPR
 
uint8_t meth
 
uint8_t approx
 
GRK_ENUM_COLOUR_SPACE enumcs
 
uint8_t precedence
 
uint32_t brand
 
uint32_t minversion
 
uint32_t numcl
 
uint32_t * cl
 
ComponentInfocomps
 
uint64_t j2k_codestream_offset
 
bool needs_xl_jp2c_box_length
 
uint32_t jp2_state
 
uint32_t jp2_img_state
 
grk_color color
 
bool has_capture_resolution
 
double capture_resolution [2]
 
bool has_display_resolution
 
double display_resolution [2]
 
grk_buf xml
 
UUIDBox uuids [JP2_MAX_NUM_UUIDS]
 
uint32_t numUuids
 
AsocBox root_asoc
 
bool m_headerError
 

Local static functions

 FileFormat (bool isDecoder, BufferedStream *stream)
 
 ~FileFormat ()
 
bool read_header (grk_header_info *header_info)
 Main header reading function handler. More...
 
GrkImageget_image (uint16_t tileIndex)
 
GrkImageget_image (void)
 
void init_decompress (grk_dparameters *p_param)
 Set up decompressor function handler. More...
 
bool set_decompress_window (grk_rect_u32 window)
 Sets the given area to be decompressed, relative to image origin. More...
 
bool decompress (grk_plugin_tile *tile)
 
bool end_decompress (void)
 Reading function used after code stream if necessary. More...
 
bool init_compress (grk_cparameters *p_param, GrkImage *p_image)
 
bool start_compress (void)
 
bool compress (grk_plugin_tile *tile)
 
bool compress_tile (uint16_t tile_index, uint8_t *p_data, uint64_t data_size)
 
bool end_compress (void)
 
bool decompress_tile (uint16_t tile_index)
 decompress tile More...
 
void dump (uint32_t flag, FILE *out_stream)
 
grk_codestream_info_v2get_cstr_info (void)
 
grk_codestream_indexget_cstr_index (void)
 
uint32_t read_asoc (AsocBox *parent, uint8_t **header_data, uint32_t *header_data_size, uint32_t asocSize)
 
bool read_header_procedure (void)
 
bool default_validation (void)
 
bool read_box_hdr (FileFormatBox *box, uint32_t *p_number_bytes_read, BufferedStream *stream)
 
bool read_ihdr (uint8_t *p_image_header_data, uint32_t image_header_size)
 
uint8_t * write_ihdr (uint32_t *p_nb_bytes_written)
 
uint8_t * write_buffer (uint32_t boxId, grk_buf *buffer, uint32_t *p_nb_bytes_written)
 
bool read_xml (uint8_t *p_xml_data, uint32_t xml_size)
 
uint8_t * write_xml (uint32_t *p_nb_bytes_written)
 
bool read_uuid (uint8_t *p_header_data, uint32_t header_size)
 
double calc_res (uint16_t num, uint16_t den, uint8_t exponent)
 
bool read_res_box (uint32_t *id, uint32_t *num, uint32_t *den, uint32_t *exponent, uint8_t **p_resolution_data)
 
bool read_res (uint8_t *p_resolution_data, uint32_t resolution_size)
 
void find_cf (double x, uint32_t *num, uint32_t *den)
 
void write_res_box (double resx, double resy, uint32_t box_id, uint8_t **current_res_ptr)
 
uint8_t * write_res (uint32_t *p_nb_bytes_written)
 
uint8_t * write_bpc (uint32_t *p_nb_bytes_written)
 
bool read_bpc (uint8_t *p_bpc_header_data, uint32_t bpc_header_size)
 
uint8_t * write_channel_definition (uint32_t *p_nb_bytes_written)
 
void apply_channel_definition (GrkImage *image, grk_color *color)
 
bool read_channel_definition (uint8_t *p_cdef_header_data, uint32_t cdef_header_size)
 
uint8_t * write_colr (uint32_t *p_nb_bytes_written)
 
bool read_colr (uint8_t *p_colr_header_data, uint32_t colr_header_size)
 
bool check_color (GrkImage *image, grk_color *color)
 
bool apply_palette_clr (GrkImage *image, grk_color *color)
 
bool read_component_mapping (uint8_t *component_mapping_header_data, uint32_t component_mapping_header_size)
 
uint8_t * write_component_mapping (uint32_t *p_nb_bytes_written)
 
uint8_t * write_palette_clr (uint32_t *p_nb_bytes_written)
 
bool read_palette_clr (uint8_t *p_pclr_header_data, uint32_t pclr_header_size)
 
bool write_jp2h (void)
 
bool write_uuids (void)
 
bool write_ftyp (void)
 
bool write_jp2c (void)
 
bool write_jp (void)
 
bool exec (std::vector< jp2_procedure > *procs)
 Executes the given procedures on the given codec. More...
 
const BoxReadHandlerfind_handler (uint32_t id)
 
const BoxReadHandlerimg_find_handler (uint32_t id)
 Finds the image execution function related to the given box id. More...
 
bool read_jp (uint8_t *p_header_data, uint32_t header_size)
 Reads a JPEG 2000 file signature box. More...
 
bool read_ftyp (uint8_t *p_header_data, uint32_t header_size)
 Reads a a FTYP box - File type box. More...
 
bool skip_jp2c (void)
 
bool read_jp2h (uint8_t *p_header_data, uint32_t header_size)
 Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box). More...
 
bool read_box (FileFormatBox *box, uint8_t *p_data, uint32_t *p_number_bytes_read, uint64_t p_box_max_size)
 
void serializeAsoc (AsocBox *asoc, grk_asoc *serial_asocs, uint32_t *num_asocs, uint32_t level)
 
static void free_color (grk_color *color)
 
static void alloc_palette (grk_color *color, uint8_t num_channels, uint16_t num_entries)
 
static void free_palette_clr (grk_color *color)
 
bool applyColour (GrkImage *img)
 

Additional Inherited Members

- Public Member Functions inherited from grk::ICodeStream
virtual ~ICodeStream ()
 

Detailed Description

JPEG 2000 file format reader/writer.

Constructor & Destructor Documentation

◆ FileFormat()

grk::FileFormat::FileFormat ( bool  isDecoder,
BufferedStream stream 
)

◆ ~FileFormat()

grk::FileFormat::~FileFormat ( )

Member Function Documentation

◆ alloc_palette()

void grk::FileFormat::alloc_palette ( grk_color color,
uint8_t  num_channels,
uint16_t  num_entries 
)
static

◆ apply_channel_definition()

void grk::FileFormat::apply_channel_definition ( GrkImage image,
grk_color color 
)

◆ apply_palette_clr()

bool grk::FileFormat::apply_palette_clr ( GrkImage image,
grk_color color 
)

◆ applyColour()

bool grk::FileFormat::applyColour ( GrkImage img)
private

◆ calc_res()

double grk::FileFormat::calc_res ( uint16_t  num,
uint16_t  den,
uint8_t  exponent 
)

Referenced by read_res().

◆ check_color()

bool grk::FileFormat::check_color ( GrkImage image,
grk_color color 
)

◆ compress()

bool grk::FileFormat::compress ( grk_plugin_tile tile)
virtual

◆ compress_tile()

bool grk::FileFormat::compress_tile ( uint16_t  tile_index,
uint8_t *  p_data,
uint64_t  data_size 
)
virtual

◆ decompress()

bool grk::FileFormat::decompress ( grk_plugin_tile tile)
virtual

◆ decompress_tile()

bool grk::FileFormat::decompress_tile ( uint16_t  tile_index)
virtual

◆ default_validation()

bool grk::FileFormat::default_validation ( void  )

◆ dump()

void grk::FileFormat::dump ( uint32_t  flag,
FILE *  out_stream 
)
virtual

Implements grk::ICodeStream.

References codeStream, and grk::j2k_dump().

◆ end_compress()

bool grk::FileFormat::end_compress ( void  )
virtual

◆ end_decompress()

bool grk::FileFormat::end_decompress ( void  )
virtual

Reading function used after code stream if necessary.

Implements grk::ICodeStream.

References codeStream, grk::CodeStream::end_decompress(), grk::jp2_exec(), grk::jp2_init_end_header_reading(), and m_procedure_list.

◆ exec()

bool grk::FileFormat::exec ( std::vector< jp2_procedure > *  procs)

Executes the given procedures on the given codec.

Parameters
procsthe list of procedures to execute
Returns
true if all the procedures were successfully executed.

Referenced by grk::jp2_exec().

◆ find_cf()

void grk::FileFormat::find_cf ( double  x,
uint32_t *  num,
uint32_t *  den 
)

References MAX.

Referenced by write_res_box().

◆ find_handler()

const BoxReadHandler * grk::FileFormat::find_handler ( uint32_t  id)

References grk::jp2_header.

◆ free_color()

void grk::FileFormat::free_color ( grk_color color)
static

◆ free_palette_clr()

void grk::FileFormat::free_palette_clr ( grk_color color)
static

◆ get_cstr_index()

grk_codestream_index * grk::FileFormat::get_cstr_index ( void  )
virtual

◆ get_cstr_info()

grk_codestream_info_v2 * grk::FileFormat::get_cstr_info ( void  )
virtual

◆ get_image() [1/2]

GrkImage * grk::FileFormat::get_image ( uint16_t  tileIndex)
virtual

◆ get_image() [2/2]

GrkImage * grk::FileFormat::get_image ( void  )
virtual

◆ img_find_handler()

const BoxReadHandler * grk::FileFormat::img_find_handler ( uint32_t  id)

Finds the image execution function related to the given box id.

Parameters
idthe id of the handler to fetch.
Returns
the given handler or nullptr if it could not be found.

References grk::jp2_img_header.

◆ init_compress()

bool grk::FileFormat::init_compress ( grk_cparameters p_param,
GrkImage p_image 
)
virtual

Implements grk::ICodeStream.

References approx, _grk_channel_description::asoc, _grk_image_comp::association, grk::ComponentInfo::bpc, bpc, brand, C, capture_resolution, _grk_cparameters::capture_resolution, _grk_cparameters::capture_resolution_from_file, grk_color::channel_definition, cl, _grk_channel_description::cn, codeStream, color, _grk_image::color, _grk_image::color_space, comps, _grk_image::comps, _grk_channel_definition::descriptions, display_resolution, _grk_cparameters::display_resolution, enumcs, GRK_CLRSPC_CMYK, GRK_CLRSPC_DEFAULT_CIE, GRK_CLRSPC_EYCC, GRK_CLRSPC_GRAY, GRK_CLRSPC_ICC, GRK_CLRSPC_SRGB, GRK_CLRSPC_SYCC, GRK_COMPONENT_TYPE_COLOUR, GRK_ENUM_CLRSPC_CIE, GRK_ENUM_CLRSPC_CMYK, GRK_ENUM_CLRSPC_EYCC, GRK_ENUM_CLRSPC_GRAY, GRK_ENUM_CLRSPC_SRGB, GRK_ENUM_CLRSPC_SYCC, GRK_ENUM_CLRSPC_UNKNOWN, grk::GRK_ERROR(), grk::grk_malloc(), grk::GRK_WARN(), h, has_capture_resolution, has_display_resolution, grk_color::icc_profile_buf, grk_color::icc_profile_len, grk::CodeStream::init_compress(), IPR, _grk_image::iptc_buf, _grk_image::iptc_len, grk::IPTC_UUID, JP2_JP2, meth, minversion, _grk_channel_definition::num_channel_descriptions, numcl, numcomps, _grk_image::numcomps, numUuids, grk_color::palette, _grk_image_comp::prec, precedence, _grk_image_comp::sgnd, _grk_channel_description::typ, _grk_image_comp::type, UnkC, uuids, w, _grk_cparameters::write_capture_resolution, _grk_cparameters::write_capture_resolution_from_file, _grk_cparameters::write_display_resolution, _grk_image::x0, _grk_image::x1, _grk_image::xmp_buf, _grk_image::xmp_len, grk::XMP_UUID, _grk_image::y0, and _grk_image::y1.

◆ init_decompress()

void grk::FileFormat::init_decompress ( grk_dparameters p_param)
virtual

Set up decompressor function handler.

Implements grk::ICodeStream.

References codeStream, color, grk_color::has_colour_specification_box, and grk::CodeStream::init_decompress().

◆ read_asoc()

uint32_t grk::FileFormat::read_asoc ( AsocBox parent,
uint8_t **  header_data,
uint32_t *  header_data_size,
uint32_t  asocSize 
)

◆ read_box()

bool grk::FileFormat::read_box ( FileFormatBox box,
uint8_t *  p_data,
uint32_t *  p_number_bytes_read,
uint64_t  p_box_max_size 
)

◆ read_box_hdr()

bool grk::FileFormat::read_box_hdr ( FileFormatBox box,
uint32_t *  p_number_bytes_read,
BufferedStream stream 
)

◆ read_bpc()

bool grk::FileFormat::read_bpc ( uint8_t *  p_bpc_header_data,
uint32_t  bpc_header_size 
)

◆ read_channel_definition()

bool grk::FileFormat::read_channel_definition ( uint8_t *  p_cdef_header_data,
uint32_t  cdef_header_size 
)

◆ read_colr()

bool grk::FileFormat::read_colr ( uint8_t *  p_colr_header_data,
uint32_t  colr_header_size 
)

◆ read_component_mapping()

bool grk::FileFormat::read_component_mapping ( uint8_t *  component_mapping_header_data,
uint32_t  component_mapping_header_size 
)

◆ read_ftyp()

bool grk::FileFormat::read_ftyp ( uint8_t *  p_header_data,
uint32_t  header_size 
)

Reads a a FTYP box - File type box.

Parameters
p_header_datathe data contained in the FTYP box.
header_sizethe size of the data contained in the FTYP box.
Returns
true if the FTYP box is valid.

References brand, cl, grk::grk_calloc(), grk::GRK_ERROR(), jp2_state, grk::JP2_STATE_FILE_TYPE, grk::JP2_STATE_SIGNATURE, minversion, and numcl.

Referenced by grk::jp2_read_ftyp().

◆ read_header()

bool grk::FileFormat::read_header ( grk_header_info header_info)
virtual

◆ read_header_procedure()

bool grk::FileFormat::read_header_procedure ( void  )

◆ read_ihdr()

bool grk::FileFormat::read_ihdr ( uint8_t *  p_image_header_data,
uint32_t  image_header_size 
)

◆ read_jp()

bool grk::FileFormat::read_jp ( uint8_t *  p_header_data,
uint32_t  header_size 
)

Reads a JPEG 2000 file signature box.

Parameters
p_header_datathe data contained in the signature box.
header_sizethe size of the data contained in the signature box.
Returns
true if the file signature box is valid.

References grk::GRK_ERROR(), jp2_state, grk::JP2_STATE_NONE, and grk::JP2_STATE_SIGNATURE.

Referenced by grk::jp2_read_jp().

◆ read_jp2h()

bool grk::FileFormat::read_jp2h ( uint8_t *  p_header_data,
uint32_t  header_size 
)

Reads the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).

Parameters
p_header_datathe data contained in the file header box.
header_sizethe size of the data contained in the file header box.
Returns
true if the JP2 Header box was successfully recognized.

References grk::GRK_ERROR(), JP2_IHDR, grk::jp2_img_find_handler(), jp2_img_state, grk::JP2_IMG_STATE_NONE, grk::JP2_IMG_STATE_UNKNOWN, jp2_state, grk::JP2_STATE_FILE_TYPE, grk::JP2_STATE_HEADER, grk::FileFormatBox::length, read_box(), and grk::FileFormatBox::type.

Referenced by grk::jp2_read_jp2h().

◆ read_palette_clr()

bool grk::FileFormat::read_palette_clr ( uint8_t *  p_pclr_header_data,
uint32_t  pclr_header_size 
)

◆ read_res()

bool grk::FileFormat::read_res ( uint8_t *  p_resolution_data,
uint32_t  resolution_size 
)

◆ read_res_box()

bool grk::FileFormat::read_res_box ( uint32_t *  id,
uint32_t *  num,
uint32_t *  den,
uint32_t *  exponent,
uint8_t **  p_resolution_data 
)

Referenced by read_res().

◆ read_uuid()

bool grk::FileFormat::read_uuid ( uint8_t *  p_header_data,
uint32_t  header_size 
)

◆ read_xml()

bool grk::FileFormat::read_xml ( uint8_t *  p_xml_data,
uint32_t  xml_size 
)

◆ serializeAsoc()

void grk::FileFormat::serializeAsoc ( AsocBox asoc,
grk_asoc serial_asocs,
uint32_t *  num_asocs,
uint32_t  level 
)

◆ set_decompress_window()

bool grk::FileFormat::set_decompress_window ( grk_rect_u32  window)
virtual

Sets the given area to be decompressed, relative to image origin.

This function should be called right after grk_read_header and before any tile header reading.

Parameters
p_imageimage
windowdecompress window
Returns
true if the area could be set.

Implements grk::ICodeStream.

References codeStream, and grk::CodeStream::set_decompress_window().

◆ skip_jp2c()

bool grk::FileFormat::skip_jp2c ( void  )

◆ start_compress()

bool grk::FileFormat::start_compress ( void  )
virtual

◆ write_bpc()

uint8_t * grk::FileFormat::write_bpc ( uint32_t *  p_nb_bytes_written)

◆ write_buffer()

uint8_t * grk::FileFormat::write_buffer ( uint32_t  boxId,
grk_buf buffer,
uint32_t *  p_nb_bytes_written 
)

◆ write_channel_definition()

uint8_t * grk::FileFormat::write_channel_definition ( uint32_t *  p_nb_bytes_written)

◆ write_colr()

uint8_t * grk::FileFormat::write_colr ( uint32_t *  p_nb_bytes_written)

◆ write_component_mapping()

uint8_t * grk::FileFormat::write_component_mapping ( uint32_t *  p_nb_bytes_written)

◆ write_ftyp()

bool grk::FileFormat::write_ftyp ( void  )

◆ write_ihdr()

uint8_t * grk::FileFormat::write_ihdr ( uint32_t *  p_nb_bytes_written)

References bpc, C, grk::grk_calloc(), h, IPR, JP2_IHDR, numcomps, UnkC, and w.

Referenced by grk::jp2_write_ihdr().

◆ write_jp()

bool grk::FileFormat::write_jp ( void  )

◆ write_jp2c()

bool grk::FileFormat::write_jp2c ( void  )

◆ write_jp2h()

bool grk::FileFormat::write_jp2h ( void  )

◆ write_palette_clr()

uint8_t * grk::FileFormat::write_palette_clr ( uint32_t *  p_nb_bytes_written)

◆ write_res()

uint8_t * grk::FileFormat::write_res ( uint32_t *  p_nb_bytes_written)

◆ write_res_box()

void grk::FileFormat::write_res_box ( double  resx,
double  resy,
uint32_t  box_id,
uint8_t **  current_res_ptr 
)

References find_cf(), and GRK_RESOLUTION_BOX_SIZE.

Referenced by write_res().

◆ write_uuids()

bool grk::FileFormat::write_uuids ( void  )

◆ write_xml()

uint8_t * grk::FileFormat::write_xml ( uint32_t *  p_nb_bytes_written)

References JP2_XML, write_buffer(), and xml.

Referenced by grk::jp2_write_xml().

Member Data Documentation

◆ approx

uint8_t grk::FileFormat::approx

◆ bpc

uint8_t grk::FileFormat::bpc

◆ brand

uint32_t grk::FileFormat::brand

◆ C

uint8_t grk::FileFormat::C

◆ capture_resolution

double grk::FileFormat::capture_resolution[2]

◆ cl

uint32_t* grk::FileFormat::cl

◆ codeStream

CodeStream* grk::FileFormat::codeStream

◆ color

grk_color grk::FileFormat::color

◆ comps

ComponentInfo* grk::FileFormat::comps

◆ display_resolution

double grk::FileFormat::display_resolution[2]

◆ enumcs

GRK_ENUM_COLOUR_SPACE grk::FileFormat::enumcs

◆ h

uint32_t grk::FileFormat::h

◆ has_capture_resolution

bool grk::FileFormat::has_capture_resolution

◆ has_display_resolution

bool grk::FileFormat::has_display_resolution

◆ IPR

uint8_t grk::FileFormat::IPR

◆ j2k_codestream_offset

uint64_t grk::FileFormat::j2k_codestream_offset

Referenced by skip_jp2c(), and write_jp2c().

◆ jp2_img_state

uint32_t grk::FileFormat::jp2_img_state

Referenced by default_validation(), and read_jp2h().

◆ jp2_state

uint32_t grk::FileFormat::jp2_state

◆ m_headerError

bool grk::FileFormat::m_headerError

Referenced by read_header().

◆ m_procedure_list

std::vector<jp2_procedure>* grk::FileFormat::m_procedure_list

◆ m_validation_list

std::vector<jp2_procedure>* grk::FileFormat::m_validation_list

◆ meth

uint8_t grk::FileFormat::meth

◆ minversion

uint32_t grk::FileFormat::minversion

◆ needs_xl_jp2c_box_length

bool grk::FileFormat::needs_xl_jp2c_box_length

◆ numcl

uint32_t grk::FileFormat::numcl

◆ numcomps

uint16_t grk::FileFormat::numcomps

◆ numUuids

uint32_t grk::FileFormat::numUuids

◆ precedence

uint8_t grk::FileFormat::precedence

◆ root_asoc

AsocBox grk::FileFormat::root_asoc

Referenced by grk::jp2_read_asoc(), and read_header().

◆ UnkC

uint8_t grk::FileFormat::UnkC

◆ uuids

UUIDBox grk::FileFormat::uuids[JP2_MAX_NUM_UUIDS]

◆ w

uint32_t grk::FileFormat::w

◆ xml

grk_buf grk::FileFormat::xml

The documentation for this class was generated from the following files: