MCPcopy Create free account
hub / github.com/OpenPathGuidingLibrary/openpgl / ReconstructLineOffsets

Function ReconstructLineOffsets

third-party/tinyexr/tinyexr.h:5430–5466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5428}
5429
5430static bool ReconstructLineOffsets(
5431 std::vector<tinyexr::tinyexr_uint64> *offsets, size_t n,
5432 const unsigned char *head, const unsigned char *marker, const size_t size) {
5433 if (head >= marker) {
5434 return false;
5435 }
5436 if (offsets->size() != n) {
5437 return false;
5438 }
5439
5440 for (size_t i = 0; i < n; i++) {
5441 size_t offset = static_cast<size_t>(marker - head);
5442 // Offset should not exceed whole EXR file/data size.
5443 if ((offset + sizeof(tinyexr::tinyexr_uint64)) >= size) {
5444 return false;
5445 }
5446
5447 int y;
5448 unsigned int data_len;
5449
5450 memcpy(&y, marker, sizeof(int));
5451 memcpy(&data_len, marker + 4, sizeof(unsigned int));
5452
5453 if (data_len >= size) {
5454 return false;
5455 }
5456
5457 tinyexr::swap4(&y);
5458 tinyexr::swap4(&data_len);
5459
5460 (*offsets)[i] = offset;
5461
5462 marker += data_len + 8; // 8 = 4 bytes(y) + 4 bytes(data_len)
5463 }
5464
5465 return true;
5466}
5467
5468
5469static int FloorLog2(unsigned x) {

Callers 1

DecodeEXRImageFunction · 0.85

Calls 2

swap4Function · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected