Grok  9.5.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
grk::CodeStreamCompress Class Reference

#include <CodeStreamCompress.h>

Inheritance diagram for grk::CodeStreamCompress:
grk::CodeStream grk::ICodeStreamCompress

Public Member Functions

 CodeStreamCompress (IBufferedStream *stream)
 
virtual ~CodeStreamCompress ()
 
bool startCompress (void)
 
bool initCompress (grk_cparameters *p_param, GrkImage *p_image)
 
bool compress (grk_plugin_tile *tile)
 
bool compressTile (uint16_t tileIndex, uint8_t *p_data, uint64_t data_size)
 
bool endCompress (void)
 
- Public Member Functions inherited from grk::CodeStream
 CodeStream (IBufferedStream *stream)
 
virtual ~CodeStream ()
 
TileProcessorcurrentProcessor (void)
 
IBufferedStreamgetStream ()
 
GrkImagegetHeaderImage (void)
 
grk_plugin_tilegetCurrentPluginTile ()
 
CodingParamsgetCodingParams (void)
 
- Public Member Functions inherited from grk::ICodeStreamCompress
virtual ~ICodeStreamCompress ()=default
 

Static Public Member Functions

static char * convertProgressionOrder (GRK_PROG_ORDER prg_order)
 
static uint16_t getPocSize (uint32_t numComponents, uint32_t l_nb_poc)
 

Private Member Functions

bool init_header_writing (void)
 
bool get_end_header (void)
 
bool writeTilePart (TileProcessor *tileProcessor)
 
bool writeTileParts (TileProcessor *tileProcessor)
 
bool updateRates (void)
 
bool compressValidation (void)
 
bool mct_validation (void)
 
bool write_soc ()
 Writes the SOC marker (Start Of Codestream) More...
 
bool write_siz ()
 Writes the SIZ marker (image and tile size) More...
 
bool write_cap ()
 Writes the CAP marker. More...
 
bool write_com ()
 Writes the COM marker (comment) More...
 
bool write_cod ()
 Writes the COD marker (Coding style default) More...
 
bool compare_coc (uint32_t first_comp_no, uint32_t second_comp_no)
 Compares 2 COC markers (Coding style component) More...
 
bool write_coc (uint32_t comp_no, IBufferedStream *stream)
 Writes the COC marker (Coding style component) More...
 
bool write_coc (uint32_t comp_no)
 
bool write_qcd ()
 Writes the QCD marker (quantization default) More...
 
bool compare_qcc (uint32_t first_comp_no, uint32_t second_comp_no)
 Compare QCC markers (quantization component) More...
 
bool write_qcc (uint16_t tileIndex, uint32_t comp_no, IBufferedStream *stream)
 Writes the QCC marker (quantization component) More...
 
bool write_qcc (uint32_t comp_no)
 
bool writePoc ()
 Writes the POC marker (Progression Order Change) More...
 
bool write_tlm_end ()
 End writing the updated tlm. More...
 
bool write_tlm_begin ()
 Begin writing the TLM marker (Tile Length Marker) More...
 
bool compare_SPCod_SPCoc (uint32_t first_comp_no, uint32_t second_comp_no)
 Compare 2 a SPCod/ SPCoc elements, i.e. More...
 
bool write_SPCod_SPCoc (uint32_t comp_no)
 Writes a SPCod or SPCoc element, i.e. More...
 
uint32_t get_SPCod_SPCoc_size (uint32_t comp_no)
 Gets the size taken by writing a SPCod or SPCoc for the given tile and component. More...
 
uint32_t get_SQcd_SQcc_size (uint32_t comp_no)
 Gets the size taken by writing SQcd or SQcc element, i.e. More...
 
bool compare_SQcd_SQcc (uint32_t first_comp_no, uint32_t second_comp_no)
 Compares 2 SQcd or SQcc element, i.e. More...
 
bool write_SQcd_SQcc (uint32_t comp_no)
 Writes a SQcd or SQcc element, i.e. More...
 
bool write_mct_record (grk_mct_data *p_mct_record, IBufferedStream *stream)
 Writes the MCT marker (Multiple Component Transform) More...
 
bool write_mcc_record (grk_simple_mcc_decorrelation_data *p_mcc_record, IBufferedStream *stream)
 Writes the MCC marker (Multiple Component Collection) More...
 
bool write_mco ()
 Writes the MCO marker (Multiple component transformation ordering) More...
 
bool write_cbd ()
 Writes the CBD marker (Component bit depth definition) More...
 
bool write_all_coc ()
 Writes COC marker for each component. More...
 
bool write_all_qcc ()
 Writes QCC marker for each component. More...
 
bool write_regions ()
 Writes regions of interests. More...
 
bool write_rgn (uint16_t tile_no, uint32_t comp_no, uint32_t nb_comps)
 Writes the RGN marker (Region Of Interest) More...
 
bool write_eoc ()
 Writes the EOC marker (End of Codestream) More...
 
bool write_mct_data_group ()
 Writes the CBD-MCT-MCC-MCO markers (Multi components transform) More...
 
bool getNumTileParts (uint16_t *p_nb_tile_parts, GrkImage *image)
 Calculates the total number of tile parts needed by the compressor to compress such an image. More...
 
uint64_t getNumTilePartsForProgression (uint32_t pino, uint16_t tileno)
 Gets the number of tile parts used for the given change of progression (if any) and the given tile. More...
 
bool validateProgressionOrders (const grk_progression *progressions, uint32_t numProgressions, uint8_t numResolutions, uint16_t numcomps, uint16_t numlayers)
 Validate progression orders. More...
 
bool init_mct_encoding (TileCodingParams *p_tcp, GrkImage *p_image)
 

Private Attributes

CompressorState m_compressorState
 

Additional Inherited Members

- Protected Member Functions inherited from grk::CodeStream
bool exec (std::vector< PROCEDURE_FUNC > &p_procedure_list)
 
- Protected Attributes inherited from grk::CodeStream
CodingParams m_cp
 
CodeStreamInfocodeStreamInfo
 
std::vector< PROCEDURE_FUNCm_procedure_list
 
std::vector< PROCEDURE_FUNCm_validation_list
 
GrkImagem_headerImage
 
TileProcessorm_currentTileProcessor
 
IBufferedStreamm_stream
 
std::map< uint32_t, TileProcessor * > m_processors
 
bool m_multiTile
 
grk_plugin_tilecurrent_plugin_tile
 

Constructor & Destructor Documentation

◆ CodeStreamCompress()

grk::CodeStreamCompress::CodeStreamCompress ( IBufferedStream stream)

◆ ~CodeStreamCompress()

grk::CodeStreamCompress::~CodeStreamCompress ( )
virtual

Member Function Documentation

◆ compare_coc()

bool grk::CodeStreamCompress::compare_coc ( uint32_t  first_comp_no,
uint32_t  second_comp_no 
)
private

Compares 2 COC markers (Coding style component)

Parameters
first_comp_nothe index of the first component to compare.
second_comp_nothe index of the second component to compare.
Returns
true if equals

◆ compare_qcc()

bool grk::CodeStreamCompress::compare_qcc ( uint32_t  first_comp_no,
uint32_t  second_comp_no 
)
private

Compare QCC markers (quantization component)

Parameters
first_comp_nothe index of the first component to compare.
second_comp_nothe index of the second component to compare.
Returns
true if equals.

◆ compare_SPCod_SPCoc()

bool grk::CodeStreamCompress::compare_SPCod_SPCoc ( uint32_t  first_comp_no,
uint32_t  second_comp_no 
)
private

Compare 2 a SPCod/ SPCoc elements, i.e.

the coding style of a given component of a tile.

Parameters
first_comp_noThe 1st component number to compare.
second_comp_noThe 1st component number to compare.
Returns
true if SPCdod are equals.

References J2K_CCP_CSTY_PRT.

◆ compare_SQcd_SQcc()

bool grk::CodeStreamCompress::compare_SQcd_SQcc ( uint32_t  first_comp_no,
uint32_t  second_comp_no 
)
private

Compares 2 SQcd or SQcc element, i.e.

the quantization values of a band in the QCD or QCC.

Parameters
first_comp_nothe first component number to compare.
second_comp_nothe second component number to compare.
Returns
true if equals.

References J2K_CCP_QNTSTY_NOQNT, and J2K_CCP_QNTSTY_SIQNT.

◆ compress()

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

◆ compressTile()

bool grk::CodeStreamCompress::compressTile ( uint16_t  tileIndex,
uint8_t *  p_data,
uint64_t  data_size 
)
virtual

◆ compressValidation()

bool grk::CodeStreamCompress::compressValidation ( void  )
private

References grk::GRK_ERROR(), and GRK_J2K_MAXRLVLS.

Referenced by startCompress().

◆ convertProgressionOrder()

char * grk::CodeStreamCompress::convertProgressionOrder ( GRK_PROG_ORDER  prg_order)
static

◆ endCompress()

bool grk::CodeStreamCompress::endCompress ( void  )
virtual

◆ get_end_header()

bool grk::CodeStreamCompress::get_end_header ( void  )
private

◆ get_SPCod_SPCoc_size()

uint32_t grk::CodeStreamCompress::get_SPCod_SPCoc_size ( uint32_t  comp_no)
private

Gets the size taken by writing a SPCod or SPCoc for the given tile and component.

Parameters
comp_nothe component being outputted.
Returns
the number of bytes taken by the SPCod element.

References J2K_CCP_CSTY_PRT, and grk::SPCod_SPCoc_len.

◆ get_SQcd_SQcc_size()

uint32_t grk::CodeStreamCompress::get_SQcd_SQcc_size ( uint32_t  comp_no)
private

Gets the size taken by writing SQcd or SQcc element, i.e.

the quantization values of a band in the QCD or QCC.

Parameters
comp_nothe component being output.
Returns
the number of bytes taken by the SPCod element.

References J2K_CCP_QNTSTY_NOQNT, and J2K_CCP_QNTSTY_SIQNT.

◆ getNumTileParts()

bool grk::CodeStreamCompress::getNumTileParts ( uint16_t *  p_nb_tile_parts,
GrkImage image 
)
private

Calculates the total number of tile parts needed by the compressor to compress such an image.

If not enough memory is available, then the function return false.

Parameters
p_nb_tile_partstotal number of tile parts in whole image.
imageimage to compress.
Returns
true if the function was successful, false else.

References grk::GRK_ERROR(), grk::maxTilePartsPerTileJ2K, and grk::maxTotalTilePartsJ2K.

◆ getNumTilePartsForProgression()

uint64_t grk::CodeStreamCompress::getNumTilePartsForProgression ( uint32_t  pino,
uint16_t  tileno 
)
private

Gets the number of tile parts used for the given change of progression (if any) and the given tile.

Parameters
pinothe offset of the given poc (i.e. its position in the coding parameter).
tilenothe given tile.
Returns
the number of tile parts.

References grk::maxTilePartsPerTileJ2K.

◆ getPocSize()

uint16_t grk::CodeStreamCompress::getPocSize ( uint32_t  numComponents,
uint32_t  l_nb_poc 
)
static

◆ init_header_writing()

bool grk::CodeStreamCompress::init_header_writing ( void  )
private

References GRK_EXTENSION_MCT, and GRK_PROFILE_PART2.

Referenced by startCompress().

◆ init_mct_encoding()

bool grk::CodeStreamCompress::init_mct_encoding ( TileCodingParams p_tcp,
GrkImage p_image 
)
private

◆ initCompress()

bool grk::CodeStreamCompress::initCompress ( grk_cparameters p_param,
GrkImage p_image 
)
virtual

Implements grk::ICodeStreamCompress.

References _grk_cparameters::allocationByQuality, _grk_cparameters::allocationByRateDistoration, grk::mct::calculate_norms(), _grk_cparameters::cblk_sty, _grk_cparameters::cblockh_init, _grk_cparameters::cblockw_init, _grk_image::color_space, grk::CodingParams::comment, _grk_cparameters::comment, grk::CodingParams::comment_len, _grk_cparameters::comment_len, _grk_progression::compE, _grk_progression::compS, _grk_image::comps, grk::GrkImage::copyHeader(), _grk_cparameters::csty, _grk_image_comp::data, _grk_image_comp::dx, _grk_image_comp::dy, _grk_cparameters::enableTilePartGeneration, grk::floorlog2(), GRK_CLRSPC_EYCC, GRK_CLRSPC_SYCC, grk::GRK_ERROR(), GRK_EXTENSION_MCT, GRK_EXTENSION_NONE, GRK_IS_BROADCAST, GRK_IS_CINEMA, GRK_IS_IMF, GRK_IS_PART2, GRK_IS_STORAGE, GRK_J2K_MAXRLVLS, GRK_JPH_RSIZ_FLAG, GRK_MAX_COMMENT_LENGTH, GRK_PROFILE_CINEMA_S2K, GRK_PROFILE_CINEMA_S4K, GRK_PROFILE_NONE, GRK_PROFILE_PART2, grk_version(), grk::GRK_WARN(), grk::grkFree(), grk::grkMalloc(), _grk_image_comp::h, init_mct_encoding(), _grk_cparameters::irreversible, _grk_cparameters::is_binary_comment, grk::Profile::is_broadcast_compliant(), grk::Profile::is_cinema_compliant(), grk::Profile::is_imf_compliant(), grk::CodingParams::isBinaryComment, _grk_cparameters::isHT, J2K_CCP_CSTY_PRT, J2K_CCP_QNTSTY_NOQNT, J2K_CCP_QNTSTY_SEQNT, J2K_CP_CSTY_PRT, _grk_progression::layE, _grk_cparameters::layer_distortion, _grk_cparameters::layer_rate, grk::EncodingParams::m_allocationByFixedQuality, grk::EncodingParams::m_allocationByRateDistortion, grk::CodingParams::m_coding_params, grk::CodeStream::m_cp, grk::EncodingParams::m_enableTilePartGeneration, grk::CodingParams::m_enc, grk::CodeStream::m_headerImage, grk::EncodingParams::m_max_comp_size, grk::EncodingParams::m_newTilePartProgressionDivider, _grk_cparameters::max_comp_size, _grk_cparameters::max_cs_size, grk::maxNumComponentsJ2K, _grk_cparameters::mct, _grk_cparameters::mct_data, _grk_cparameters::newTilePartProgressionDivider, grk::CodingParams::num_comments, _grk_cparameters::num_comments, _grk_image::numcomps, _grk_cparameters::numgbits, _grk_cparameters::numlayers, _grk_cparameters::numpocs, _grk_cparameters::numresolution, _grk_cparameters::prch_init, _grk_cparameters::prcw_init, _grk_image_comp::prec, _grk_cparameters::prog_order, _grk_cparameters::progression, grk::EncodingParams::rateControlAlgorithm, _grk_cparameters::rateControlAlgorithm, _grk_cparameters::res_spec, _grk_progression::resE, _grk_progression::resS, _grk_cparameters::roi_compno, _grk_cparameters::roi_shift, grk::CodingParams::rsiz, _grk_cparameters::rsiz, grk::Profile::set_broadcast_parameters(), grk::Profile::set_cinema_parameters(), grk::Profile::set_imf_parameters(), _grk_image_comp::sgnd, _grk_progression::specifiedCompressionPocProg, grk::CodingParams::t_grid_height, grk::CodingParams::t_grid_width, grk::CodingParams::t_height, _grk_cparameters::t_height, grk::CodingParams::t_width, _grk_cparameters::t_width, grk::TileCodingParams::tccps, grk::CodingParams::tcps, _grk_cparameters::tile_size_on, _grk_progression::tileno, grk::CodingParams::tx0, _grk_cparameters::tx0, grk::CodingParams::ty0, _grk_cparameters::ty0, validateProgressionOrders(), _grk_image_comp::w, grk::EncodingParams::writePLT, _grk_cparameters::writePLT, grk::EncodingParams::writeTLM, _grk_cparameters::writeTLM, _grk_image::x0, _grk_image::x1, _grk_image::y0, and _grk_image::y1.

Referenced by grk::FileFormatCompress::initCompress().

◆ mct_validation()

bool grk::CodeStreamCompress::mct_validation ( void  )
private

◆ startCompress()

bool grk::CodeStreamCompress::startCompress ( void  )
virtual

◆ updateRates()

bool grk::CodeStreamCompress::updateRates ( void  )
private

◆ validateProgressionOrders()

bool grk::CodeStreamCompress::validateProgressionOrders ( const grk_progression progressions,
uint32_t  numProgressions,
uint8_t  numResolutions,
uint16_t  numcomps,
uint16_t  numlayers 
)
private

Validate progression orders.

Parameters
progressionsprogression orders.
numProgressionsnumber of progression orders.
numResolutionsnumber of resolutions.
numcompsnumber of components
numlayersnumber of layers.
Returns
true if the pocs are valid.

References grk::GRK_ERROR(), and _grk_progression::resS.

Referenced by initCompress().

◆ write_all_coc()

bool grk::CodeStreamCompress::write_all_coc ( )
private

Writes COC marker for each component.

◆ write_all_qcc()

bool grk::CodeStreamCompress::write_all_qcc ( )
private

Writes QCC marker for each component.

◆ write_cap()

bool grk::CodeStreamCompress::write_cap ( )
private

Writes the CAP marker.

◆ write_cbd()

bool grk::CodeStreamCompress::write_cbd ( )
private

Writes the CBD marker (Component bit depth definition)

References J2K_MS_CBD.

◆ write_coc() [1/2]

bool grk::CodeStreamCompress::write_coc ( uint32_t  comp_no)
private

References grk::cod_coc_len, and J2K_MS_COC.

◆ write_coc() [2/2]

bool grk::CodeStreamCompress::write_coc ( uint32_t  comp_no,
IBufferedStream stream 
)
private

Writes the COC marker (Coding style component)

Parameters
comp_nothe index of the component to output.
streambuffered stream.

◆ write_cod()

bool grk::CodeStreamCompress::write_cod ( )
private

Writes the COD marker (Coding style default)

References grk::GRK_ERROR(), and J2K_MS_COD.

◆ write_com()

bool grk::CodeStreamCompress::write_com ( )
private

Writes the COM marker (comment)

References GRK_MAX_COMMENT_LENGTH, grk::GRK_WARN(), and J2K_MS_COM.

◆ write_eoc()

bool grk::CodeStreamCompress::write_eoc ( )
private

Writes the EOC marker (End of Codestream)

References J2K_MS_EOC.

◆ write_mcc_record()

bool grk::CodeStreamCompress::write_mcc_record ( grk_simple_mcc_decorrelation_data p_mcc_record,
IBufferedStream stream 
)
private

◆ write_mco()

bool grk::CodeStreamCompress::write_mco ( )
private

Writes the MCO marker (Multiple component transformation ordering)

References J2K_MS_MCO.

◆ write_mct_data_group()

bool grk::CodeStreamCompress::write_mct_data_group ( )
private

Writes the CBD-MCT-MCC-MCO markers (Multi components transform)

◆ write_mct_record()

bool grk::CodeStreamCompress::write_mct_record ( grk_mct_data p_mct_record,
IBufferedStream stream 
)
private

◆ write_qcc() [1/2]

bool grk::CodeStreamCompress::write_qcc ( uint16_t  tileIndex,
uint32_t  comp_no,
IBufferedStream stream 
)
private

Writes the QCC marker (quantization component)

Parameters
tileIndexcurrent tile index
comp_nothe index of the component to output.
streambuffered stream.

◆ write_qcc() [2/2]

bool grk::CodeStreamCompress::write_qcc ( uint32_t  comp_no)
private

References J2K_MS_QCC.

◆ write_qcd()

bool grk::CodeStreamCompress::write_qcd ( )
private

Writes the QCD marker (quantization default)

References grk::GRK_ERROR(), and J2K_MS_QCD.

◆ write_regions()

bool grk::CodeStreamCompress::write_regions ( )
private

Writes regions of interests.

◆ write_rgn()

bool grk::CodeStreamCompress::write_rgn ( uint16_t  tile_no,
uint32_t  comp_no,
uint32_t  nb_comps 
)
private

Writes the RGN marker (Region Of Interest)

Parameters
tile_nothe tile to output
comp_nothe component to output
nb_compsthe number of components

References J2K_MS_RGN.

◆ write_siz()

bool grk::CodeStreamCompress::write_siz ( )
private

Writes the SIZ marker (image and tile size)

References grk::SIZMarker::write().

◆ write_soc()

bool grk::CodeStreamCompress::write_soc ( )
private

Writes the SOC marker (Start Of Codestream)

References J2K_MS_SOC.

◆ write_SPCod_SPCoc()

bool grk::CodeStreamCompress::write_SPCod_SPCoc ( uint32_t  comp_no)
private

Writes a SPCod or SPCoc element, i.e.

the coding style of a given component of a tile.

Parameters
comp_nothe component number to output.
Returns
true if successful

References J2K_CCP_CSTY_PRT.

◆ write_SQcd_SQcc()

bool grk::CodeStreamCompress::write_SQcd_SQcc ( uint32_t  comp_no)
private

Writes a SQcd or SQcc element, i.e.

the quantization values of a band in the QCD or QCC.

Parameters
comp_nothe component number to output.

References J2K_CCP_QNTSTY_NOQNT, and J2K_CCP_QNTSTY_SIQNT.

◆ write_tlm_begin()

bool grk::CodeStreamCompress::write_tlm_begin ( )
private

Begin writing the TLM marker (Tile Length Marker)

◆ write_tlm_end()

bool grk::CodeStreamCompress::write_tlm_end ( )
private

End writing the updated tlm.

◆ writePoc()

bool grk::CodeStreamCompress::writePoc ( )
private

Writes the POC marker (Progression Order Change)

References J2K_MS_POC.

◆ writeTilePart()

bool grk::CodeStreamCompress::writeTilePart ( TileProcessor tileProcessor)
private

◆ writeTileParts()

bool grk::CodeStreamCompress::writeTileParts ( TileProcessor tileProcessor)
private

Member Data Documentation

◆ m_compressorState

CompressorState grk::CodeStreamCompress::m_compressorState
private

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