CodeStreamCompress.h
Go to the documentation of this file.
/*
* Copyright (C) 2016-2023 Grok Image Compression Inc.
*
* This source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This source code incorporates work covered by the BSD 2-clause license.
* Please see the LICENSE file in the root directory for details.
*
*/
#pragma once
namespace grk
{
class CodeStream;
class CodeStreamCompress : public CodeStream, public ICodeStreamCompress
{
public:
CodeStreamCompress(BufferedStream* stream);
virtual ~CodeStreamCompress();
static char* convertProgressionOrder(GRK_PROG_ORDER prg_order);
static uint16_t getPocSize(uint32_t numComponents, uint32_t l_nb_poc);
bool start(void);
bool init(grk_cparameters* p_param, GrkImage* p_image);
bool compress(grk_plugin_tile* tile);
private:
bool init_header_writing(void);
bool cacheEndOfHeader(void);
bool end(void);
bool writeTilePart(TileProcessor* tileProcessor);
bool writeTileParts(TileProcessor* tileProcessor);
bool updateRates(void);
bool compressValidation(void);
bool mct_validation(void);
bool write_soc();
bool write_siz();
bool write_cap();
bool write_com();
bool write_cod();
bool compare_coc(uint32_t first_comp_no, uint32_t second_comp_no);
bool write_coc(uint32_t comp_no, BufferedStream* stream);
bool write_coc(uint32_t comp_no);
bool write_qcd();
bool compare_qcc(uint32_t first_comp_no, uint32_t second_comp_no);
bool write_qcc(uint16_t tileIndex, uint32_t comp_no, BufferedStream* stream);
bool write_qcc(uint32_t comp_no);
bool writePoc();
bool write_tlm_end();
bool write_tlm_begin();
bool compare_SPCod_SPCoc(uint32_t first_comp_no, uint32_t second_comp_no);
bool write_SPCod_SPCoc(uint32_t comp_no);
uint32_t get_SPCod_SPCoc_size(uint32_t comp_no);
uint32_t get_SQcd_SQcc_size(uint32_t comp_no);
bool compare_SQcd_SQcc(uint32_t first_comp_no, uint32_t second_comp_no);
bool write_SQcd_SQcc(uint32_t comp_no);
bool write_mct_record(grk_mct_data* p_mct_record, BufferedStream* stream);
bool write_mcc_record(grk_simple_mcc_decorrelation_data* p_mcc_record, BufferedStream* stream);
bool write_mco();
bool write_cbd();
bool write_all_coc();
bool write_all_qcc();
bool write_regions();
bool write_rgn(uint16_t tile_no, uint32_t comp_no, uint32_t nb_comps);
bool write_eoc();
bool write_mct_data_group();
bool getNumTileParts(uint16_t* p_nb_tile_parts, GrkImage* image);
uint64_t getNumTilePartsForProgression(uint32_t pino, uint16_t tileno);
bool validateProgressionOrders(const grk_progression* progressions, uint32_t numProgressions,
uint8_t numResolutions, uint16_t numcomps, uint16_t numlayers);
bool init_mct_encoding(TileCodingParams* p_tcp, GrkImage* p_image);
CompressorState compressorState_;
};
} // namespace grk
grk::CodeStreamCompress
Definition CodeStreamCompress.h:29
grk::CodeStreamCompress::write_regions
bool write_regions()
Writes regions of interests.
Definition CodeStreamCompress.cpp:1316
grk::CodeStreamCompress::get_SPCod_SPCoc_size
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.
Definition CodeStreamCompress.cpp:1498
grk::CodeStreamCompress::write_siz
bool write_siz()
Writes the SIZ marker (image and tile size)
Definition CodeStreamCompress.cpp:1022
grk::CodeStreamCompress::start
bool start(void)
Definition CodeStreamCompress.cpp:97
grk::CodeStreamCompress::init
bool init(grk_cparameters *p_param, GrkImage *p_image)
Definition CodeStreamCompress.cpp:115
grk::CodeStreamCompress::compare_SQcd_SQcc
bool compare_SQcd_SQcc(uint32_t first_comp_no, uint32_t second_comp_no)
Compares 2 SQcd or SQcc element, i.e.
Definition CodeStreamCompress.cpp:1588
grk::CodeStreamCompress::init_mct_encoding
bool init_mct_encoding(TileCodingParams *p_tcp, GrkImage *p_image)
Definition CodeStreamCompress.cpp:1727
grk::CodeStreamCompress::compare_qcc
bool compare_qcc(uint32_t first_comp_no, uint32_t second_comp_no)
Compare QCC markers (quantization component)
Definition CodeStreamCompress.cpp:1193
grk::CodeStreamCompress::compressValidation
bool compressValidation(void)
Definition CodeStreamCompress.cpp:992
grk::CodeStreamCompress::writeTilePart
bool writeTilePart(TileProcessor *tileProcessor)
Definition CodeStreamCompress.cpp:816
grk::CodeStreamCompress::~CodeStreamCompress
virtual ~CodeStreamCompress()
Definition CodeStreamCompress.cpp:62
grk::CodeStreamCompress::compare_coc
bool compare_coc(uint32_t first_comp_no, uint32_t second_comp_no)
Compares 2 COC markers (Coding style component)
Definition CodeStreamCompress.cpp:1131
grk::CodeStreamCompress::write_com
bool write_com()
Writes the COM marker (comment)
Definition CodeStreamCompress.cpp:1033
grk::CodeStreamCompress::write_all_qcc
bool write_all_qcc()
Writes QCC marker for each component.
Definition CodeStreamCompress.cpp:1303
grk::CodeStreamCompress::mct_validation
bool mct_validation(void)
Definition CodeStreamCompress.cpp:73
grk::CodeStreamCompress::getNumTileParts
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.
Definition CodeStreamCompress.cpp:1938
grk::CodeStreamCompress::convertProgressionOrder
static char * convertProgressionOrder(GRK_PROG_ORDER prg_order)
Definition CodeStreamCompress.cpp:63
grk::CodeStreamCompress::write_cbd
bool write_cbd()
Writes the CBD marker (Component bit depth definition)
Definition CodeStreamCompress.cpp:1456
grk::CodeStreamCompress::write_SQcd_SQcc
bool write_SQcd_SQcc(uint32_t comp_no)
Writes a SQcd or SQcc element, i.e.
Definition CodeStreamCompress.cpp:1625
grk::CodeStreamCompress::write_qcd
bool write_qcd()
Writes the QCD marker (quantization default)
Definition CodeStreamCompress.cpp:1141
grk::CodeStreamCompress::compressorState_
CompressorState compressorState_
Definition CodeStreamCompress.h:314
grk::CodeStreamCompress::write_mco
bool write_mco()
Writes the MCO marker (Multiple component transformation ordering)
Definition CodeStreamCompress.cpp:1426
grk::CodeStreamCompress::write_rgn
bool write_rgn(uint16_t tile_no, uint32_t comp_no, uint32_t nb_comps)
Writes the RGN marker (Region Of Interest)
Definition CodeStreamCompress.cpp:707
grk::CodeStreamCompress::write_mcc_record
bool write_mcc_record(grk_simple_mcc_decorrelation_data *p_mcc_record, BufferedStream *stream)
Writes the MCC marker (Multiple Component Collection)
Definition CodeStreamCompress.cpp:1330
grk::CodeStreamCompress::cacheEndOfHeader
bool cacheEndOfHeader(void)
Definition CodeStreamCompress.cpp:777
grk::CodeStreamCompress::writePoc
bool writePoc()
Writes the POC marker (Progression Order Change)
Definition CodeStreamCompress.cpp:1197
grk::CodeStreamCompress::write_all_coc
bool write_all_coc()
Writes COC marker for each component.
Definition CodeStreamCompress.cpp:1289
grk::CodeStreamCompress::getPocSize
static uint16_t getPocSize(uint32_t numComponents, uint32_t l_nb_poc)
Definition CodeStreamCompress.cpp:1655
grk::CodeStreamCompress::write_tlm_end
bool write_tlm_end()
End writing the updated tlm.
Definition CodeStreamCompress.cpp:1494
grk::CodeStreamCompress::writeTileParts
bool writeTileParts(TileProcessor *tileProcessor)
Definition CodeStreamCompress.cpp:866
grk::CodeStreamCompress::write_mct_data_group
bool write_mct_data_group()
Writes the CBD-MCT-MCC-MCO markers (Multi components transform)
Definition CodeStreamCompress.cpp:1264
grk::CodeStreamCompress::write_cod
bool write_cod()
Writes the COD marker (Coding style default)
Definition CodeStreamCompress.cpp:1066
grk::CodeStreamCompress::write_tlm_begin
bool write_tlm_begin()
Begin writing the TLM marker (Tile Length Marker)
Definition CodeStreamCompress.cpp:1487
grk::CodeStreamCompress::write_eoc
bool write_eoc()
Writes the EOC marker (End of Codestream)
Definition CodeStreamCompress.cpp:741
grk::CodeStreamCompress::write_coc
bool write_coc(uint32_t comp_no, BufferedStream *stream)
Writes the COC marker (Coding style component)
grk::CodeStreamCompress::end
bool end(void)
Definition CodeStreamCompress.cpp:697
grk::CodeStreamCompress::write_qcc
bool write_qcc(uint16_t tileIndex, uint32_t comp_no, BufferedStream *stream)
Writes the QCC marker (quantization component)
grk::CodeStreamCompress::init_header_writing
bool init_header_writing(void)
Definition CodeStreamCompress.cpp:783
grk::CodeStreamCompress::write_mct_record
bool write_mct_record(grk_mct_data *p_mct_record, BufferedStream *stream)
Writes the MCT marker (Multiple Component Transform)
Definition CodeStreamCompress.cpp:748
grk::CodeStreamCompress::write_SPCod_SPCoc
bool write_SPCod_SPCoc(uint32_t comp_no)
Writes a SPCod or SPCoc element, i.e.
Definition CodeStreamCompress.cpp:1539
grk::CodeStreamCompress::compare_SPCod_SPCoc
bool compare_SPCod_SPCoc(uint32_t first_comp_no, uint32_t second_comp_no)
Compare 2 a SPCod/ SPCoc elements, i.e.
Definition CodeStreamCompress.cpp:1510
grk::CodeStreamCompress::get_SQcd_SQcc_size
uint32_t get_SQcd_SQcc_size(uint32_t comp_no)
Gets the size taken by writing SQcd or SQcc element, i.e.
Definition CodeStreamCompress.cpp:1577
grk::CodeStreamCompress::getNumTilePartsForProgression
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.
Definition CodeStreamCompress.cpp:1877
grk::CodeStreamCompress::updateRates
bool updateRates(void)
Definition CodeStreamCompress.cpp:915
grk::CodeStreamCompress::validateProgressionOrders
bool validateProgressionOrders(const grk_progression *progressions, uint32_t numProgressions, uint8_t numResolutions, uint16_t numcomps, uint16_t numlayers)
Validate progression orders.
Definition CodeStreamCompress.cpp:1661
grk::CodeStreamCompress::write_cap
bool write_cap()
Writes the CAP marker.
Definition CodeStreamCompress.cpp:1028
grk::CodeStreamCompress::compress
bool compress(grk_plugin_tile *tile)
Definition CodeStreamCompress.cpp:621
grk::CodeStreamCompress::write_soc
bool write_soc()
Writes the SOC marker (Start Of Codestream)
Definition CodeStreamCompress.cpp:1018
grk::CodeStream
Definition CodeStream.h:133
grk::GrkImage
Definition GrkImage.h:25
GRK_PROG_ORDER
enum _GRK_PROG_ORDER GRK_PROG_ORDER
Progression order.
grk
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
grk::grk_read
void grk_read(const uint8_t *buffer, TYPE *value, uint32_t numBytes)
Definition BufferedStream.h:239
_grk_cparameters
Compress parameters.
Definition grok.h:912
_grk_plugin_tile
Plugin tile.
Definition grok.h:739
_grk_progression
Progression order change.
Definition grok.h:135
grk::BufferedStream
Definition BufferedStream.h:35
grk::CompressorState
Definition CodingParams.h:341
grk::ICodeStreamCompress
Definition CodeStream.h:107
grk::TileCodingParams
Tile coding parameters : this structure is used to store coding/decoding parameters common to all til...
Definition CodingParams.h:122
grk::TileProcessor
Definition TileProcessor.h:78
grk::grk_mct_data
MCT data.
Definition CodingParams.h:96
grk::grk_simple_mcc_decorrelation_data
MCC decorrelation data.
Definition CodingParams.h:108