MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / DecodeChunk

Function DecodeChunk

Source/ThirdParty/tinyexr/tinyexr.h:5063–5428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5061}
5062
5063static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header,
5064 const OffsetData& offset_data,
5065 const unsigned char *head, const size_t size,
5066 std::string *err) {
5067 int num_channels = exr_header->num_channels;
5068
5069 int num_scanline_blocks = 1;
5070 if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) {
5071 num_scanline_blocks = 16;
5072 } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) {
5073 num_scanline_blocks = 32;
5074 } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) {
5075 num_scanline_blocks = 16;
5076
5077#if TINYEXR_USE_ZFP
5078 tinyexr::ZFPCompressionParam zfp_compression_param;
5079 if (!FindZFPCompressionParam(&zfp_compression_param,
5080 exr_header->custom_attributes,
5081 int(exr_header->num_custom_attributes), err)) {
5082 return TINYEXR_ERROR_INVALID_HEADER;
5083 }
5084#endif
5085 }
5086
5087 if (exr_header->data_window.max_x < exr_header->data_window.min_x ||
5088 exr_header->data_window.max_y < exr_header->data_window.min_y) {
5089 if (err) {
5090 (*err) += "Invalid data window.\n";
5091 }
5092 return TINYEXR_ERROR_INVALID_DATA;
5093 }
5094
5095 tinyexr_int64 data_width =
5096 static_cast<tinyexr_int64>(exr_header->data_window.max_x) - static_cast<tinyexr_int64>(exr_header->data_window.min_x) + static_cast<tinyexr_int64>(1);
5097 tinyexr_int64 data_height =
5098 static_cast<tinyexr_int64>(exr_header->data_window.max_y) - static_cast<tinyexr_int64>(exr_header->data_window.min_y) + static_cast<tinyexr_int64>(1);
5099
5100 if (data_width <= 0) {
5101 if (err) {
5102 (*err) += "Invalid data window width.\n";
5103 }
5104 return TINYEXR_ERROR_INVALID_DATA;
5105 }
5106
5107 if (data_height <= 0) {
5108 if (err) {
5109 (*err) += "Invalid data window height.\n";
5110 }
5111 return TINYEXR_ERROR_INVALID_DATA;
5112 }
5113
5114 // Do not allow too large data_width and data_height. header invalid?
5115 {
5116 if ((data_width > TINYEXR_DIMENSION_THRESHOLD) || (data_height > TINYEXR_DIMENSION_THRESHOLD)) {
5117 if (err) {
5118 std::stringstream ss;
5119 ss << "data_with or data_height too large. data_width: " << data_width
5120 << ", "

Callers 2

DecodeEXRImageFunction · 0.85

Calls 13

FindZFPCompressionParamFunction · 0.85
ComputeChannelLayoutFunction · 0.85
InitEXRImageFunction · 0.85
LevelSizeFunction · 0.85
DecodeTiledLevelFunction · 0.85
AllocateImageFunction · 0.85
memcpyFunction · 0.85
swap4Function · 0.85
DecodePixelDataFunction · 0.85
emplace_backMethod · 0.80
maxFunction · 0.50
strMethod · 0.45

Tested by

no test coverage detected