MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / EncodeChunk

Function EncodeChunk

Source/ThirdParty/tinyexr.h:8972–9203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8970}
8971
8972static int EncodeChunk(const EXRImage* exr_image, const EXRHeader* exr_header,
8973 const std::vector<ChannelInfo>& channels,
8974 int num_blocks,
8975 tinyexr_uint64 chunk_offset, // starting offset of current chunk
8976 bool is_multipart,
8977 OffsetData& offset_data, // output block offsets, must be initialized
8978 std::vector<std::vector<unsigned char> >& data_list, // output
8979 tinyexr_uint64& total_size, // output: ending offset of current chunk
8980 std::string* err) {
8981 int num_scanlines = NumScanlines(exr_header->compression_type);
8982
8983 data_list.resize(num_blocks);
8984
8985 std::vector<size_t> channel_offset_list(
8986 static_cast<size_t>(exr_header->num_channels));
8987
8988 int pixel_data_size = 0;
8989 {
8990 size_t channel_offset = 0;
8991 for (size_t c = 0; c < static_cast<size_t>(exr_header->num_channels); c++) {
8992 channel_offset_list[c] = channel_offset;
8993 if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) {
8994 pixel_data_size += sizeof(unsigned short);
8995 channel_offset += sizeof(unsigned short);
8996 } else if (channels[c].requested_pixel_type ==
8997 TINYEXR_PIXELTYPE_FLOAT) {
8998 pixel_data_size += sizeof(float);
8999 channel_offset += sizeof(float);
9000 } else if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_UINT) {
9001 pixel_data_size += sizeof(unsigned int);
9002 channel_offset += sizeof(unsigned int);
9003 } else {
9004 if (err) {
9005 (*err) += "Invalid requested_pixel_type.\n";
9006 }
9007 return TINYEXR_ERROR_INVALID_DATA;
9008 }
9009 }
9010 }
9011
9012 const void* compression_param = 0;
9013#if TINYEXR_USE_ZFP
9014 tinyexr::ZFPCompressionParam zfp_compression_param;
9015
9016 // Use ZFP compression parameter from custom attributes(if such a parameter
9017 // exists)
9018 {
9019 std::string e;
9020 bool ret = tinyexr::FindZFPCompressionParam(
9021 &zfp_compression_param, exr_header->custom_attributes,
9022 exr_header->num_custom_attributes, &e);
9023
9024 if (!ret) {
9025 // Use predefined compression parameter.
9026 zfp_compression_param.type = 0;
9027 zfp_compression_param.rate = 2;
9028 }
9029 compression_param = &zfp_compression_param;

Callers 1

Calls 9

NumScanlinesFunction · 0.85
FindZFPCompressionParamFunction · 0.85
LevelIndexFunction · 0.85
EncodeTiledLevelFunction · 0.85
swap8Function · 0.85
EncodePixelDataFunction · 0.85
swap4Function · 0.85
minFunction · 0.50
maxFunction · 0.50

Tested by

no test coverage detected