|
Grok 20.3.2
|
Stores header and data for an image. More...
#include <GrkImage.h>
Public Member Functions | |
| GrkImage () | |
| Constructs a GrkImage. | |
| bool | allocCompositeData (void) |
| Allocate data for tile compositing. | |
| void | copyHeaderTo (GrkImage *dest) const |
| Copies only header of image and its component header. | |
| void | transferDataTo (GrkImage *dest) |
| Transfer data to dest for each component, and null out "this" data. | |
| void | filterComponents (const std::vector< uint16_t > &compsToKeep) |
| GrkImage * | extractFrom (const Tile *tile_src) const |
| Create new image and transfer tile buffer data. | |
| bool | composite (const GrkImage *src) |
| bool | greyToRGB (void) |
| Convert to sRGB. | |
| template<typename T> | |
| bool | applyColourManagement (void) |
| bool | validateICC (void) |
| void | all_components_data_free (void) |
| void | postReadHeader (CodingParams *cp) |
| void | validateColourSpace (void) |
| bool | isSubsampled () const |
| bool | check_color (uint16_t signalledNumComps) |
| void | apply_channel_definition (void) |
| void | applyChannelDefinitionTypes (void) |
| bool | needsChannelDefinitionSwap (void) const |
| void | allocPalette (uint8_t num_channels, uint16_t num_entries) |
| uint32_t | width (void) const |
| uint32_t | height (void) const |
| void | print (void) const |
| bool | componentsEqual (bool checkPrecision) const |
| bool | componentsEqual (uint16_t firstNComponents, bool checkPrecision) const |
| Rect32 | getBounds (void) const |
| Gets unreduced, non-subsampled image bounds. | |
| bool | subsampleAndReduce (uint8_t reduce) |
| Generates subsampled and reduced bounds for components. | |
| bool | compositeInterleaved (const Tile *src, uint32_t yBegin, uint32_t yEnd) |
| bool | postProcess (void) |
| bool | applyColour (void) |
| void | transferDataFrom (const Tile *tile_src_data) |
| bool | isPostProcessNoOp (void) const |
| Check if postProcess would be a no-op for the current image. | |
| template<typename T> | |
| void | convertPrecision (void) |
| template<typename T> | |
| bool | apply_palette_clr () |
| template<typename T> | |
| bool | execUpsample (void) |
| template<typename T> | |
| void | transferDataFrom_T (const Tile *tile_src_data) |
| template<typename T> | |
| bool | compositeInterleaved (uint16_t srcNumComps, grk_image_comp *srcComps) |
| Interleave image data and copy to interleaved composite image. | |
| template<typename T> | |
| bool | applyICC (void) |
Static Public Member Functions | |
| static GrkImage * | create (grk_image *src, uint16_t numcmpts, grk_image_comp *cmptparms, GRK_COLOR_SPACE clrspc, bool doAllocation) |
| Creates a GrkImage. | |
| static bool | allocData (grk_image_comp *imageComp, bool clear) |
| Allocate data for single image component. | |
| static bool | allocData (grk_image_comp *imageComp) |
| Allocate data for single image component. | |
| static void | setDataToNull (grk_image_comp *comp) |
Private Member Functions | |
| ~GrkImage () | |
| Destroys a GrkImage. | |
| template<typename T> | |
| bool | applyColour_T (void) |
| template<typename T> | |
| bool | convertToRGB_T () |
| template<typename T> | |
| bool | compositeInterleaved_T (const Tile *src, uint32_t yBegin, uint32_t yEnd) |
| template<typename T> | |
| bool | postProcess_T (void) |
| std::string | getColourSpaceString (void) const |
| std::string | getICCColourSpaceString (cmsColorSpaceSignature color_space) const |
| bool | isValidICCColourSpace (uint32_t signature) const |
| bool | needsConversionToRGB (void) const |
| bool | isOpacity (uint16_t compno) const |
| bool | generateCompositeBounds (const grk_image_comp *srcComp, uint16_t destCompno, Rect32 *destWin) |
| bool | generateCompositeBounds (const Rect32 &src, uint16_t destCompno, Rect32 *destWin) |
| bool | allComponentsSanityCheck (bool equalPrecision) const |
| return false if : | |
| grk_image * | createRGB (uint16_t numcmpts, uint32_t w, uint32_t h, uint8_t prec) |
| bool | componentsEqual (grk_image_comp *src, grk_image_comp *dest, bool checkPrecision) const |
| template<typename T> | |
| void | scaleComponent (grk_image_comp *component, uint8_t precision) |
| template<typename T> | |
| bool | compositePlanar (uint16_t srcNumComps, grk_image_comp *srcComps) |
| Copy planar image data to planar composite image. | |
| template<typename T> | |
| void | sycc_to_rgb (T offset, T upb, T y, T cb, T cr, T *out_r, T *out_g, T *out_b) |
| template<typename T> | |
| bool | sycc444_to_rgb (void) |
| template<typename T> | |
| bool | sycc422_to_rgb (bool oddFirstX) |
| template<typename T> | |
| bool | sycc420_to_rgb (bool oddFirstX, bool oddFirstY) |
| template<typename T> | |
| bool | color_sycc_to_rgb (bool oddFirstX, bool oddFirstY) |
| template<typename T> | |
| bool | color_cmyk_to_rgb (void) |
| template<typename T> | |
| bool | color_esycc_to_rgb (void) |
| template<typename T> | |
| bool | cieLabToRGB (void) |
Static Private Member Functions | |
| static size_t | sizeOfDataType (grk_data_type type) |
| static void | single_component_data_free (grk_image_comp *comp) |
| static void | copyComponent (grk_image_comp *src, grk_image_comp *dest) |
Private Attributes | |
| friend | GrkObjectWrapperImpl< GrkImage > |
Stores header and data for an image.
| grk::GrkImage::GrkImage | ( | ) |
Constructs a GrkImage.
References grk::singleTileRowsPerStrip.
Referenced by composite(), copyHeaderTo(), create(), extractFrom(), and transferDataTo().
|
private |
Destroys a GrkImage.
This is private because this struct
References all_components_data_free(), grk::grk_aligned_free(), and grk::grk_unref().
| void grk::GrkImage::all_components_data_free | ( | void | ) |
References single_component_data_free().
Referenced by copyHeaderTo(), execUpsample(), greyToRGB(), sycc420_to_rgb(), sycc422_to_rgb(), sycc444_to_rgb(), and ~GrkImage().
|
private |
return false if :
References GRK_MAX_SUPPORTED_IMAGE_PRECISION, and grk::grklog.
Referenced by applyICC(), cieLabToRGB(), color_cmyk_to_rgb(), and color_esycc_to_rgb().
| bool grk::GrkImage::allocCompositeData | ( | void | ) |
Allocate data for tile compositing.
References allocData(), and grk::grklog.
Referenced by grk::CodeStreamDecompress::activateScratch().
|
static |
Allocate data for single image component.
| imageComp | image component |
References allocData().
|
static |
Allocate data for single image component.
| imageComp | image component |
| clear | clear image data if true |
References grk::grk_aligned_malloc(), GRK_INT_16, grk::grk_make_aligned_width(), grk::grklog, single_component_data_free(), and sizeOfDataType().
Referenced by allocCompositeData(), allocData(), apply_palette_clr(), applyICC(), create(), execUpsample(), greyToRGB(), and subsampleAndReduce().
| void grk::GrkImage::allocPalette | ( | uint8_t | num_channels, |
| uint16_t | num_entries ) |
Referenced by grk::FileFormatJP2Family::read_palette_clr().
| void grk::GrkImage::apply_channel_definition | ( | void | ) |
References GRK_CHANNEL_ASSOC_WHOLE_IMAGE, GRK_CHANNEL_TYPE_COLOUR, and grk::grklog.
Referenced by applyColour_T().
| bool grk::GrkImage::apply_palette_clr | ( | ) |
References allocData(), grk::grk_aligned_free(), grk::grklog, and single_component_data_free().
Referenced by applyColour_T().
| void grk::GrkImage::applyChannelDefinitionTypes | ( | void | ) |
Referenced by postReadHeader().
|
inline |
References applyColour_T(), GRK_INT_16, and GRK_INT_32.
Referenced by postProcess_T().
|
private |
References apply_channel_definition(), and apply_palette_clr().
Referenced by applyColour().
| bool grk::GrkImage::applyColourManagement | ( | void | ) |
References applyICC(), cieLabToRGB(), GRK_CLRSPC_CUSTOM_CIE, GRK_CLRSPC_DEFAULT_CIE, GRK_FMT_BMP, GRK_FMT_JPG, GRK_FMT_PNG, GRK_FMT_TIF, GRK_FMT_UNK, grk::grklog, and validateICC().
Referenced by postProcess_T().
| bool grk::GrkImage::applyICC | ( | void | ) |
References allComponentsSanityCheck(), allocData(), GRK_CLRSPC_GRAY, GRK_CLRSPC_SRGB, grk::grklog, grk::hwy_packed_to_planar_16(), grk::hwy_packed_to_planar_8(), grk::hwy_planar_to_packed_16(), grk::hwy_planar_to_packed_8(), setDataToNull(), SIZE_MAX, and validateICC().
Referenced by applyColourManagement(), and grk::CodeStreamCompress::init().
| bool grk::GrkImage::check_color | ( | uint16_t | signalledNumComps | ) |
References grk::grk_calloc(), GRK_CHANNEL_ASSOC_UNASSOCIATED, grk::grk_free(), and grk::grklog.
Referenced by grk::FileFormatJP2Family::readHeader().
|
private |
References allComponentsSanityCheck(), createRGB(), grk::GRK_CIE_D50, grk::GRK_CIE_D65, grk::GRK_CIE_D75, grk::GRK_CIE_F11, grk::GRK_CIE_F2, grk::GRK_CIE_F7, grk::GRK_CIE_SA, grk::GRK_CIE_SC, GRK_CLRSPC_SRGB, GRK_DEFAULT_CIELAB_SPACE, GRK_ENUM_CLRSPC_CIE, grk::grk_unref(), grk::grklog, setDataToNull(), and single_component_data_free().
Referenced by applyColourManagement().
|
private |
References allComponentsSanityCheck(), GRK_CLRSPC_SRGB, grk::grklog, and single_component_data_free().
Referenced by convertToRGB_T().
|
private |
References allComponentsSanityCheck(), GRK_CLRSPC_SRGB, grk::grklog, and grk::hwy_esycc_to_rgb_i32().
Referenced by convertToRGB_T().
|
private |
References GRK_CLRSPC_SRGB, grk::grklog, sycc420_to_rgb(), sycc422_to_rgb(), and sycc444_to_rgb().
Referenced by convertToRGB_T().
| bool grk::GrkImage::componentsEqual | ( | bool | checkPrecision | ) | const |
References componentsEqual().
Referenced by grk::CodeStreamDecompress::activateScratch(), componentsEqual(), and componentsEqual().
|
private |
| bool grk::GrkImage::componentsEqual | ( | uint16_t | firstNComponents, |
| bool | checkPrecision ) const |
References componentsEqual().
| bool grk::GrkImage::composite | ( | const GrkImage * | src | ) |
References compositeInterleaved(), compositePlanar(), GRK_INT_16, GRK_INT_32, and GrkImage().
|
inline |
References compositeInterleaved_T(), GRK_INT_16, and GRK_INT_32.
Referenced by composite().
| bool grk::GrkImage::compositeInterleaved | ( | uint16_t | srcNumComps, |
| grk_image_comp * | srcComps ) |
Interleave image data and copy to interleaved composite image.
| src | source image |
References generateCompositeBounds(), GRK_FMT_PXM, GRK_FMT_TIF, grk::grklog, grk::Rect< T >::height(), grk::Rect< T >::width(), grk::Rect< T >::x0, and grk::Rect< T >::y0.
|
private |
Referenced by compositeInterleaved().
|
private |
Copy planar image data to planar composite image.
| src | source image |
References generateCompositeBounds(), GRK_INT_16, GRK_INT_32, grk::grklog, grk::Rect< T >::height(), grk::Rect< T >::width(), grk::Rect< T >::x0, and grk::Rect< T >::y0.
Referenced by composite().
| void grk::GrkImage::convertPrecision | ( | void | ) |
References grk::clip(), GRK_FMT_JPG, GRK_FMT_PNG, GRK_PREC_MODE_CLIP, GRK_PREC_MODE_SCALE, grk::grklog, and scaleComponent().
Referenced by postProcess_T().
|
private |
References color_cmyk_to_rgb(), color_esycc_to_rgb(), color_sycc_to_rgb(), GRK_CLRSPC_CMYK, GRK_CLRSPC_EYCC, GRK_CLRSPC_SYCC, grk::grklog, and needsConversionToRGB().
Referenced by postProcess_T().
|
staticprivate |
Referenced by execUpsample(), and greyToRGB().
| void grk::GrkImage::copyHeaderTo | ( | GrkImage * | dest | ) | const |
Copies only header of image and its component header.
Copy only header of image and its component header (no data copied) if dest image has data, it will be freed.
No data is copied. If dest has data then it will be freed
| dest | destination @GrkImage |
| dest | the dest image |
References all_components_data_free(), grk::grk_ref(), grk::grk_unref(), and GrkImage().
Referenced by extractFrom(), and grk::CodeStreamCompress::init().
|
static |
Creates a GrkImage.
| src | image source (see grk_image) |
| numcmpts | number of components |
| cmptparms | component parameters |
| clrspc | image color space |
| doAllocation | true if data is to be allocated, otherwise false |
References allocData(), GRK_CHANNEL_ASSOC_COLOUR_1, GRK_CHANNEL_ASSOC_COLOUR_2, GRK_CHANNEL_ASSOC_COLOUR_3, GRK_CHANNEL_ASSOC_UNASSOCIATED, GRK_CHANNEL_TYPE_COLOUR, GRK_CHANNEL_TYPE_UNSPECIFIED, GRK_CLRSPC_CMYK, GrkImage(), and grk::grklog.
Referenced by createRGB(), and grk_image_new().
|
private |
References create(), GRK_CLRSPC_SRGB, and grk::grklog.
Referenced by cieLabToRGB(), sycc420_to_rgb(), sycc422_to_rgb(), and sycc444_to_rgb().
| bool grk::GrkImage::execUpsample | ( | void | ) |
References all_components_data_free(), allocData(), copyComponent(), and grk::grklog.
Referenced by postProcess_T().
Create new image and transfer tile buffer data.
| src | tile source |
References grk::Tile::comps_, copyHeaderTo(), GrkImage(), grk::Tile::numcomps_, grk::TileComponent::windowBounds(), grk::Rect< T >::x0, grk::Rect< T >::x1, grk::Rect< T >::y0, and grk::Rect< T >::y1.
Referenced by grk::TileProcessor::post_decompressT2T1().
| void grk::GrkImage::filterComponents | ( | const std::vector< uint16_t > & | compsToKeep | ) |
References setDataToNull(), and single_component_data_free().
Referenced by grk::CodeStreamDecompress::postProcess().
|
private |
References generateCompositeBounds().
Referenced by compositeInterleaved(), compositePlanar(), and generateCompositeBounds().
|
private |
References grk::Rect< T >::intersection(), and grk::Rect< T >::pan().
| Rect32 grk::GrkImage::getBounds | ( | void | ) | const |
Gets unreduced, non-subsampled image bounds.
Component bounds my differ due to subsampling and reduction
Referenced by grk::PacketManager::getParams().
|
private |
References GRK_CLRSPC_CMYK, GRK_CLRSPC_CUSTOM_CIE, GRK_CLRSPC_DEFAULT_CIE, GRK_CLRSPC_EYCC, GRK_CLRSPC_GRAY, GRK_CLRSPC_ICC, GRK_CLRSPC_SRGB, GRK_CLRSPC_SYCC, and GRK_CLRSPC_UNKNOWN.
Referenced by validateICC().
|
private |
Referenced by validateICC().
| bool grk::GrkImage::greyToRGB | ( | void | ) |
Convert to sRGB.
References all_components_data_free(), allocData(), copyComponent(), GRK_CLRSPC_GRAY, GRK_CLRSPC_SRGB, and sizeOfDataType().
Referenced by postProcess_T().
| uint32_t grk::GrkImage::height | ( | void | ) | const |
Referenced by postReadHeader().
|
private |
References GRK_CHANNEL_TYPE_OPACITY, and GRK_CHANNEL_TYPE_PREMULTIPLIED_OPACITY.
Referenced by postReadHeader().
| bool grk::GrkImage::isPostProcessNoOp | ( | void | ) | const |
Check if postProcess would be a no-op for the current image.
When true, tile-row data can be streamed directly to writeImageBand without running postProcess first.
References GRK_CLRSPC_CUSTOM_CIE, GRK_CLRSPC_DEFAULT_CIE, GRK_CLRSPC_EYCC, GRK_CLRSPC_GRAY, GRK_CLRSPC_SYCC, GRK_FMT_BMP, GRK_FMT_JPG, GRK_FMT_PNG, GRK_FMT_TIF, GRK_FMT_UNK, isSubsampled(), needsChannelDefinitionSwap(), and needsConversionToRGB().
| bool grk::GrkImage::isSubsampled | ( | ) | const |
Referenced by isPostProcessNoOp(), postReadHeader(), and validateICC().
|
private |
Referenced by validateICC().
| bool grk::GrkImage::needsChannelDefinitionSwap | ( | void | ) | const |
References GRK_CHANNEL_ASSOC_WHOLE_IMAGE, and GRK_CHANNEL_TYPE_COLOUR.
Referenced by isPostProcessNoOp().
|
private |
References GRK_CLRSPC_CMYK, GRK_CLRSPC_EYCC, GRK_CLRSPC_SYCC, GRK_FMT_TIF, and GRK_FMT_UNK.
Referenced by convertToRGB_T(), isPostProcessNoOp(), and postReadHeader().
|
inline |
References GRK_INT_16, GRK_INT_32, and postProcess_T().
Referenced by grk::CodeStreamDecompress::postProcess().
|
private |
References applyColour(), applyColourManagement(), convertPrecision(), convertToRGB_T(), execUpsample(), and greyToRGB().
Referenced by postProcess().
| void grk::GrkImage::postReadHeader | ( | CodingParams * | cp | ) |
References applyChannelDefinitionTypes(), grk::ceildivpow2(), grk::CodingParams::codingParams_, grk::CodingParams::dec_, GRK_CLRSPC_EYCC, GRK_CLRSPC_SRGB, GRK_CLRSPC_SYCC, GRK_FMT_BMP, GRK_FMT_PNG, GRK_FMT_PXM, GRK_FMT_TIF, height(), isOpacity(), isSubsampled(), needsConversionToRGB(), grk::DecodingParams::reduce_, grk::singleTileRowsPerStrip, and grk::CodingParams::t_height_.
| void grk::GrkImage::print | ( | void | ) | const |
References grk::grklog.
|
private |
References grk::grklog, grk::hwy_scale_div_i32(), grk::hwy_scale_mul_i32(), and grk::scale.
Referenced by convertPrecision().
|
static |
Referenced by applyICC(), cieLabToRGB(), filterComponents(), single_component_data_free(), and transferDataTo().
|
staticprivate |
References grk::grk_aligned_free(), and setDataToNull().
Referenced by all_components_data_free(), allocData(), apply_palette_clr(), cieLabToRGB(), color_cmyk_to_rgb(), filterComponents(), transferDataFrom_T(), and transferDataTo().
|
staticprivate |
References GRK_DOUBLE, GRK_FLOAT, GRK_INT_16, GRK_INT_32, and GRK_INT_8.
Referenced by allocData(), greyToRGB(), and subsampleAndReduce().
| bool grk::GrkImage::subsampleAndReduce | ( | uint8_t | reduce | ) |
Generates subsampled and reduced bounds for components.
If data has been allocated and the new width or height differ from old with or height respectively, then data is de-allocated
References allocData(), grk::ceildiv(), grk::ceildivpow2(), grk::grklog, sizeOfDataType(), grk::Rect< T >::x0, and grk::Rect< T >::y0.
Referenced by grk::CodeStreamDecompress::differentialUpdate().
|
private |
References all_components_data_free(), createRGB(), GRK_CLRSPC_SRGB, grk::grk_unref(), grk::grklog, and sycc_to_rgb().
Referenced by color_sycc_to_rgb().
|
private |
References all_components_data_free(), createRGB(), GRK_CLRSPC_SRGB, grk::grk_unref(), grk::grklog, and sycc_to_rgb().
Referenced by color_sycc_to_rgb().
|
private |
References all_components_data_free(), createRGB(), GRK_CLRSPC_SRGB, grk::grk_unref(), grk::hwy_sycc444_to_rgb_i32(), and sycc_to_rgb().
Referenced by color_sycc_to_rgb().
|
private |
Referenced by sycc420_to_rgb(), sycc422_to_rgb(), and sycc444_to_rgb().
| void grk::GrkImage::transferDataFrom | ( | const Tile * | tile_src_data | ) |
References GRK_INT_16, GRK_INT_32, and transferDataFrom_T().
Referenced by grk::TileProcessor::post_decompressT2T1().
| void grk::GrkImage::transferDataFrom_T | ( | const Tile * | tile_src_data | ) |
References grk::Tile::comps_, GRK_INT_16, GRK_INT_32, and single_component_data_free().
Referenced by transferDataFrom().
| void grk::GrkImage::transferDataTo | ( | GrkImage * | dest | ) |
Transfer data to dest for each component, and null out "this" data.
Transfer data to dest for each component, and null out this data.
Assumption: "this" and dest have the same number of components
Assumption: this and dest have the same number of components
References GrkImage(), setDataToNull(), and single_component_data_free().
| void grk::GrkImage::validateColourSpace | ( | void | ) |
References GRK_CLRSPC_SYCC, and GRK_CLRSPC_UNKNOWN.
| bool grk::GrkImage::validateICC | ( | void | ) |
References getColourSpaceString(), getICCColourSpaceString(), GRK_CLRSPC_CMYK, GRK_CLRSPC_CUSTOM_CIE, GRK_CLRSPC_DEFAULT_CIE, GRK_CLRSPC_EYCC, GRK_CLRSPC_GRAY, GRK_CLRSPC_ICC, GRK_CLRSPC_SRGB, GRK_CLRSPC_SYCC, GRK_CLRSPC_UNKNOWN, grk::grklog, isSubsampled(), and isValidICCColourSpace().
Referenced by applyColourManagement(), and applyICC().
| uint32_t grk::GrkImage::width | ( | void | ) | const |
|
private |