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

Function ParseEXRHeaderFromMemory

tutorials/common/image/tinyexr.h:6539–6597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6537}
6538
6539int ParseEXRHeaderFromMemory(EXRHeader *exr_header, const EXRVersion *version,
6540 const unsigned char *memory, size_t size,
6541 const char **err) {
6542 if (memory == NULL || exr_header == NULL) {
6543 tinyexr::SetErrorMessage(
6544 "Invalid argument. `memory` or `exr_header` argument is null in "
6545 "ParseEXRHeaderFromMemory()",
6546 err);
6547
6548 // Invalid argument
6549 return TINYEXR_ERROR_INVALID_ARGUMENT;
6550 }
6551
6552 if (size < tinyexr::kEXRVersionSize) {
6553 tinyexr::SetErrorMessage("Insufficient header/data size.\n", err);
6554 return TINYEXR_ERROR_INVALID_DATA;
6555 }
6556
6557 const unsigned char *marker = memory + tinyexr::kEXRVersionSize;
6558 size_t marker_size = size - tinyexr::kEXRVersionSize;
6559
6560 tinyexr::HeaderInfo info;
6561 info.clear();
6562
6563 int ret;
6564 {
6565 std::string err_str;
6566 ret = ParseEXRHeader(&info, NULL, version, &err_str, marker, marker_size);
6567
6568 if (ret != TINYEXR_SUCCESS) {
6569 if (err && !err_str.empty()) {
6570 tinyexr::SetErrorMessage(err_str, err);
6571 }
6572 }
6573 }
6574
6575 {
6576 std::string warn;
6577 std::string err_str;
6578
6579 if (!ConvertHeader(exr_header, info, &warn, &err_str)) {
6580 // release mem
6581 for (size_t i = 0; i < info.attributes.size(); i++) {
6582 if (info.attributes[i].value) {
6583 free(info.attributes[i].value);
6584 }
6585 }
6586 if (err && !err_str.empty()) {
6587 tinyexr::SetErrorMessage(err_str, err);
6588 }
6589 ret = TINYEXR_ERROR_INVALID_HEADER;
6590 }
6591 }
6592
6593 exr_header->multipart = version->multipart ? 1 : 0;
6594 exr_header->non_image = version->non_image ? 1 : 0;
6595
6596 return ret;

Callers 2

LoadEXRFromMemoryFunction · 0.85
ParseEXRHeaderFromFileFunction · 0.85

Calls 6

SetErrorMessageFunction · 0.85
ParseEXRHeaderFunction · 0.85
ConvertHeaderFunction · 0.85
clearMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected