MCPcopy Create free account
hub / github.com/RenderKit/embree / ComputeChannelLayout

Function ComputeChannelLayout

tutorials/common/image/tinyexr.h:4323–4349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4321}
4322
4323static bool ComputeChannelLayout(std::vector<size_t> *channel_offset_list,
4324 int *pixel_data_size, size_t *channel_offset,
4325 int num_channels,
4326 const EXRChannelInfo *channels) {
4327 channel_offset_list->resize(static_cast<size_t>(num_channels));
4328
4329 (*pixel_data_size) = 0;
4330 (*channel_offset) = 0;
4331
4332 for (size_t c = 0; c < static_cast<size_t>(num_channels); c++) {
4333 (*channel_offset_list)[c] = (*channel_offset);
4334 if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) {
4335 (*pixel_data_size) += sizeof(unsigned short);
4336 (*channel_offset) += sizeof(unsigned short);
4337 } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) {
4338 (*pixel_data_size) += sizeof(float);
4339 (*channel_offset) += sizeof(float);
4340 } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) {
4341 (*pixel_data_size) += sizeof(unsigned int);
4342 (*channel_offset) += sizeof(unsigned int);
4343 } else {
4344 // ???
4345 return false;
4346 }
4347 }
4348 return true;
4349}
4350
4351// TODO: Simply return nullptr when failed to allocate?
4352static unsigned char **AllocateImage(int num_channels,

Callers 1

DecodeChunkFunction · 0.85

Calls 1

resizeMethod · 0.45

Tested by

no test coverage detected