Grok 20.3.2
grk::CodeStreamCompress Class Reference

#include <CodeStreamCompress.h>

Inheritance diagram for grk::CodeStreamCompress:
grk::CodeStream grk::ICompressor

Public Member Functions

 CodeStreamCompress (IStream *stream)
virtual ~CodeStreamCompress ()=default
bool start (void) override
bool init (grk_cparameters *param, GrkImage *image) override
uint64_t compress (grk_plugin_tile *tile) override
Public Member Functions inherited from grk::CodeStream
 CodeStream (IStream *stream)
virtual ~CodeStream ()
IStreamgetStream ()
GrkImagegetHeaderImage (void)
grk_plugin_tilegetCurrentPluginTile ()
CodingParamsgetCodingParams (void)
virtual grk_io_band_callback getBandCallback () const
virtual void * getBandUserData () const
Public Member Functions inherited from grk::ICompressor
virtual ~ICompressor ()=default
virtual uint64_t compressFrame (GrkImage *image, grk_plugin_tile *tile)
virtual bool finalize (void)

Static Public Member Functions

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

Private Member Functions

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

Private Attributes

uint32_t totalTileParts_

Additional Inherited Members

Protected Member Functions inherited from grk::CodeStream
bool exec (std::vector< PROCEDURE_FUNC > &procedureList)
Protected Attributes inherited from grk::CodeStream
CodingParams cp_
std::vector< PROCEDURE_FUNCprocedureList_
std::vector< PROCEDURE_FUNCvalidationList_
GrkImageheaderImage_
IStreamstream_
std::unordered_map< uint32_t, ITileProcessor * > processors_
grk_plugin_tilecurrent_plugin_tile

Constructor & Destructor Documentation

◆ CodeStreamCompress()

grk::CodeStreamCompress::CodeStreamCompress ( IStream * stream)
explicit

◆ ~CodeStreamCompress()

virtual grk::CodeStreamCompress::~CodeStreamCompress ( )
virtualdefault

Member Function Documentation

◆ compare_coc()

bool grk::CodeStreamCompress::compare_coc ( uint16_t first_comp_no,
uint16_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

References compare_SPCod_SPCoc(), and grk::CodeStream::cp_.

Referenced by write_all_coc().

◆ compare_qcc()

bool grk::CodeStreamCompress::compare_qcc ( uint16_t first_comp_no,
uint16_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.

References compare_SQcd_SQcc().

Referenced by write_all_qcc().

◆ compare_SPCod_SPCoc()

bool grk::CodeStreamCompress::compare_SPCod_SPCoc ( uint16_t first_comp_no,
uint16_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 grk::CCP_CSTY_PRECINCT, and grk::CodeStream::cp_.

Referenced by compare_coc().

◆ compare_SQcd_SQcc()

bool grk::CodeStreamCompress::compare_SQcd_SQcc ( uint16_t first_comp_no,
uint16_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 grk::CCP_QNTSTY_NOQNT, grk::CCP_QNTSTY_SIQNT, and grk::CodeStream::cp_.

Referenced by compare_qcc().

◆ compress()

uint64_t grk::CodeStreamCompress::compress ( grk_plugin_tile * tile)
overridevirtual

◆ compressValidation()

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

References grk::CodeStream::cp_, GRK_MAXRLVLS, and grk::grklog.

Referenced by start().

◆ convertProgressionOrder()

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

◆ end()

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

◆ get_SPCod_SPCoc_size()

uint32_t grk::CodeStreamCompress::get_SPCod_SPCoc_size ( uint16_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 grk::CCP_CSTY_PRECINCT, grk::CodeStream::cp_, grk::CodeStream::getHeaderImage(), and grk::SPCodSPCocLen.

Referenced by write_coc(), and write_cod().

◆ get_SQcd_SQcc_size()

uint32_t grk::CodeStreamCompress::get_SQcd_SQcc_size ( uint16_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 grk::CCP_QNTSTY_NOQNT, grk::CCP_QNTSTY_SIQNT, grk::CodeStream::cp_, and grk::CodeStream::getHeaderImage().

Referenced by write_qcc(), and write_qcd().

◆ getNumTileParts()

bool grk::CodeStreamCompress::getNumTileParts ( uint32_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::CodeStream::cp_, getNumTilePartsForProgression(), grk::grklog, grk::maxTilePartsPerTileJ2K, grk::maxTotalTilePartsJ2K, and grk::PacketManager::updateCompressParams().

Referenced by init_header_writing().

◆ getNumTilePartsForProgression()

uint8_t grk::CodeStreamCompress::getNumTilePartsForProgression ( uint32_t prog_iter_num,
uint16_t tileno )
private

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

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

References convertProgressionOrder(), grk::CodeStream::cp_, and grk::maxTilePartsPerTileJ2K.

Referenced by getNumTileParts(), and writeTileParts().

◆ getPocSize()

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

◆ init()

◆ init_header_writing()

◆ init_mct_encoding()

◆ mct_validation()

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

◆ start()

◆ 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::grklog.

Referenced by init().

◆ write_all_coc()

bool grk::CodeStreamCompress::write_all_coc ( )
private

Writes COC marker for each component.

References compare_coc(), grk::CodeStream::getHeaderImage(), and write_coc().

Referenced by init_header_writing().

◆ write_all_qcc()

bool grk::CodeStreamCompress::write_all_qcc ( )
private

Writes QCC marker for each component.

References compare_qcc(), grk::CodeStream::getHeaderImage(), and write_qcc().

Referenced by init_header_writing().

◆ write_cap()

bool grk::CodeStreamCompress::write_cap ( )
private

Writes the CAP marker.

References grk::CodeStream::cp_, and grk::CodeStream::stream_.

Referenced by init_header_writing().

◆ write_cbd()

bool grk::CodeStreamCompress::write_cbd ( )
private

Writes the CBD marker (Component bit depth definition).

References grk::CBD, grk::CodeStream::getHeaderImage(), and grk::CodeStream::stream_.

Referenced by write_mct_data_group().

◆ write_coc() [1/2]

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

◆ write_coc() [2/2]

bool grk::CodeStreamCompress::write_coc ( uint16_t comp_no,
IStream * stream )
private

Writes the COC marker (Coding style component).

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

Referenced by write_all_coc().

◆ write_cod()

bool grk::CodeStreamCompress::write_cod ( )
private

Writes the COD marker (Coding style default).

References grk::COD, grk::CodeStream::cp_, get_SPCod_SPCoc_size(), grk::grklog, grk::CodeStream::stream_, and write_SPCod_SPCoc().

Referenced by init_header_writing().

◆ write_com()

bool grk::CodeStreamCompress::write_com ( )
private

Writes the COM marker (comment).

References grk::COM, grk::CodeStream::cp_, GRK_MAX_COMMENT_LENGTH, grk::grklog, and grk::CodeStream::stream_.

Referenced by init_header_writing().

◆ write_eoc()

bool grk::CodeStreamCompress::write_eoc ( )
private

Writes the EOC marker (End of Codestream).

References grk::EOC, and grk::CodeStream::stream_.

Referenced by end().

◆ write_mcc_record()

◆ write_mco()

bool grk::CodeStreamCompress::write_mco ( )
private

Writes the MCO marker (Multiple component transformation ordering).

References grk::CodeStream::cp_, grk::MCO, and grk::CodeStream::stream_.

Referenced by write_mct_data_group().

◆ write_mct_data_group()

bool grk::CodeStreamCompress::write_mct_data_group ( )
private

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

References grk::CodeStream::cp_, grk::CodeStream::stream_, write_cbd(), write_mcc_record(), write_mco(), and write_mct_record().

Referenced by init_header_writing().

◆ write_mct_record()

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

Writes the MCT marker (Multiple Component Transform).

Parameters
p_mct_recordMCT record
streambuffered stream.

References grk::grk_mct_data::array_type_, grk::grk_mct_data::data_, grk::grk_mct_data::data_size_, grk::grk_mct_data::element_type_, grk::grk_mct_data::index_, grk::MCT, grk::t1_t2::IStreamWriter::write(), and grk::IStream::writeBytes().

Referenced by write_mct_data_group().

◆ write_qcc() [1/2]

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

◆ write_qcc() [2/2]

bool grk::CodeStreamCompress::write_qcc ( uint16_t tile_index,
uint16_t comp_no,
IStream * stream )
private

Writes the QCC marker (quantization component).

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

Referenced by write_all_qcc().

◆ write_qcd()

bool grk::CodeStreamCompress::write_qcd ( )
private

Writes the QCD marker (quantization default).

References get_SQcd_SQcc_size(), grk::grklog, grk::QCD, grk::CodeStream::stream_, and write_SQcd_SQcc().

Referenced by init_header_writing().

◆ write_regions()

bool grk::CodeStreamCompress::write_regions ( )
private

Writes regions of interests.

References grk::CodeStream::cp_, grk::CodeStream::getHeaderImage(), and write_rgn().

Referenced by init_header_writing().

◆ write_rgn()

bool grk::CodeStreamCompress::write_rgn ( uint16_t tile_no,
uint16_t comp_no,
uint16_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 grk::CodeStream::cp_, grk::RGN, and grk::CodeStream::stream_.

Referenced by write_regions().

◆ write_siz()

bool grk::CodeStreamCompress::write_siz ( )
private

Writes the SIZ marker (image and tile size).

References grk::CodeStream::stream_, and grk::SIZMarker::write().

Referenced by init_header_writing().

◆ write_soc()

bool grk::CodeStreamCompress::write_soc ( )
private

Writes the SOC marker (Start Of Codestream).

References grk::SOC, and grk::CodeStream::stream_.

Referenced by init_header_writing().

◆ write_SPCod_SPCoc()

bool grk::CodeStreamCompress::write_SPCod_SPCoc ( uint16_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 grk::CCP_CSTY_PRECINCT, grk::CodeStream::cp_, grk::CodeStream::getHeaderImage(), and grk::CodeStream::stream_.

Referenced by write_coc(), and write_cod().

◆ write_SQcd_SQcc()

bool grk::CodeStreamCompress::write_SQcd_SQcc ( uint16_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 grk::CCP_QNTSTY_NOQNT, grk::CCP_QNTSTY_SIQNT, grk::CodeStream::cp_, grk::CodeStream::getHeaderImage(), and grk::CodeStream::stream_.

Referenced by write_qcc(), and write_qcd().

◆ write_tlm_begin()

bool grk::CodeStreamCompress::write_tlm_begin ( )
private

Begin writing the TLM marker (Tile Length Marker).

References grk::CodeStream::cp_, grk::CodeStream::stream_, and totalTileParts_.

Referenced by init_header_writing().

◆ write_tlm_end()

bool grk::CodeStreamCompress::write_tlm_end ( )
private

End writing the updated tlm.

References grk::CodeStream::cp_.

Referenced by end().

◆ writePoc()

bool grk::CodeStreamCompress::writePoc ( )
private

Writes the POC marker (Progression Order Change).

References grk::CodeStream::cp_, grk::CodeStream::getHeaderImage(), getPocSize(), grk::POC, and grk::CodeStream::stream_.

Referenced by init_header_writing(), and writeTilePart().

◆ writeTilePart()

◆ writeTileParts()

Member Data Documentation

◆ totalTileParts_

uint32_t grk::CodeStreamCompress::totalTileParts_
private

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