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

Function WriteChannelInfo

tutorials/common/image/tinyexr.h:1341–1381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1339}
1340
1341static void WriteChannelInfo(std::vector<unsigned char> &data,
1342 const std::vector<ChannelInfo> &channels) {
1343 size_t sz = 0;
1344
1345 // Calculate total size.
1346 for (size_t c = 0; c < channels.size(); c++) {
1347 sz += channels[c].name.length() + 1; // +1 for \0
1348 sz += 16; // 4 * int
1349 }
1350 data.resize(sz + 1);
1351
1352 unsigned char *p = &data.at(0);
1353
1354 for (size_t c = 0; c < channels.size(); c++) {
1355 memcpy(p, channels[c].name.c_str(), channels[c].name.length());
1356 p += channels[c].name.length();
1357 (*p) = '\0';
1358 p++;
1359
1360 int pixel_type = channels[c].requested_pixel_type;
1361 int x_sampling = channels[c].x_sampling;
1362 int y_sampling = channels[c].y_sampling;
1363 tinyexr::swap4(&pixel_type);
1364 tinyexr::swap4(&x_sampling);
1365 tinyexr::swap4(&y_sampling);
1366
1367 memcpy(p, &pixel_type, sizeof(int));
1368 p += sizeof(int);
1369
1370 (*p) = channels[c].p_linear;
1371 p += 4;
1372
1373 memcpy(p, &x_sampling, sizeof(int));
1374 p += sizeof(int);
1375
1376 memcpy(p, &y_sampling, sizeof(int));
1377 p += sizeof(int);
1378 }
1379
1380 (*p) = '\0';
1381}
1382
1383static bool CompressZip(unsigned char *dst,
1384 tinyexr::tinyexr_uint64 &compressedSize,

Callers 1

Calls 5

swap4Function · 0.85
sizeMethod · 0.45
resizeMethod · 0.45
atMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected