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

Function ReconstructLineOffsets

Source/ThirdParty/tinyexr.h:6950–6986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6948}
6949
6950static bool ReconstructLineOffsets(
6951 std::vector<tinyexr::tinyexr_uint64> *offsets, size_t n,
6952 const unsigned char *head, const unsigned char *marker, const size_t size) {
6953 if (head >= marker) {
6954 return false;
6955 }
6956 if (offsets->size() != n) {
6957 return false;
6958 }
6959
6960 for (size_t i = 0; i < n; i++) {
6961 size_t offset = static_cast<size_t>(marker - head);
6962 // Offset should not exceed whole EXR file/data size.
6963 if ((offset + sizeof(tinyexr::tinyexr_uint64)) >= size) {
6964 return false;
6965 }
6966
6967 int y;
6968 unsigned int data_len;
6969
6970 memcpy(&y, marker, sizeof(int));
6971 memcpy(&data_len, marker + 4, sizeof(unsigned int));
6972
6973 if (data_len >= size) {
6974 return false;
6975 }
6976
6977 tinyexr::swap4(&y);
6978 tinyexr::swap4(&data_len);
6979
6980 (*offsets)[i] = offset;
6981
6982 marker += data_len + 8; // 8 = 4 bytes(y) + 4 bytes(data_len)
6983 }
6984
6985 return true;
6986}
6987
6988
6989static int FloorLog2(unsigned x) {

Callers 1

DecodeEXRImageFunction · 0.85

Calls 1

swap4Function · 0.85

Tested by

no test coverage detected