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

Function ReconstructLineOffsets

tutorials/common/image/tinyexr.h:5509–5545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5507}
5508
5509static bool ReconstructLineOffsets(
5510 std::vector<tinyexr::tinyexr_uint64> *offsets, size_t n,
5511 const unsigned char *head, const unsigned char *marker, const size_t size) {
5512 if (head >= marker) {
5513 return false;
5514 }
5515 if (offsets->size() != n) {
5516 return false;
5517 }
5518
5519 for (size_t i = 0; i < n; i++) {
5520 size_t offset = static_cast<size_t>(marker - head);
5521 // Offset should not exceed whole EXR file/data size.
5522 if ((offset + sizeof(tinyexr::tinyexr_uint64)) >= size) {
5523 return false;
5524 }
5525
5526 int y;
5527 unsigned int data_len;
5528
5529 memcpy(&y, marker, sizeof(int));
5530 memcpy(&data_len, marker + 4, sizeof(unsigned int));
5531
5532 if (data_len >= size) {
5533 return false;
5534 }
5535
5536 tinyexr::swap4(&y);
5537 tinyexr::swap4(&data_len);
5538
5539 (*offsets)[i] = offset;
5540
5541 marker += data_len + 8; // 8 = 4 bytes(y) + 4 bytes(data_len)
5542 }
5543
5544 return true;
5545}
5546
5547
5548static int FloorLog2(unsigned x) {

Callers 1

DecodeEXRImageFunction · 0.85

Calls 2

swap4Function · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected