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

Function ParseEXRHeaderFromMemory

third-party/tinyexr/tinyexr.h:6460–6518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6458}
6459
6460int ParseEXRHeaderFromMemory(EXRHeader *exr_header, const EXRVersion *version,
6461 const unsigned char *memory, size_t size,
6462 const char **err) {
6463 if (memory == NULL || exr_header == NULL) {
6464 tinyexr::SetErrorMessage(
6465 "Invalid argument. `memory` or `exr_header` argument is null in "
6466 "ParseEXRHeaderFromMemory()",
6467 err);
6468
6469 // Invalid argument
6470 return TINYEXR_ERROR_INVALID_ARGUMENT;
6471 }
6472
6473 if (size < tinyexr::kEXRVersionSize) {
6474 tinyexr::SetErrorMessage("Insufficient header/data size.\n", err);
6475 return TINYEXR_ERROR_INVALID_DATA;
6476 }
6477
6478 const unsigned char *marker = memory + tinyexr::kEXRVersionSize;
6479 size_t marker_size = size - tinyexr::kEXRVersionSize;
6480
6481 tinyexr::HeaderInfo info;
6482 info.clear();
6483
6484 int ret;
6485 {
6486 std::string err_str;
6487 ret = ParseEXRHeader(&info, NULL, version, &err_str, marker, marker_size);
6488
6489 if (ret != TINYEXR_SUCCESS) {
6490 if (err && !err_str.empty()) {
6491 tinyexr::SetErrorMessage(err_str, err);
6492 }
6493 }
6494 }
6495
6496 {
6497 std::string warn;
6498 std::string err_str;
6499
6500 if (!ConvertHeader(exr_header, info, &warn, &err_str)) {
6501 // release mem
6502 for (size_t i = 0; i < info.attributes.size(); i++) {
6503 if (info.attributes[i].value) {
6504 free(info.attributes[i].value);
6505 }
6506 }
6507 if (err && !err_str.empty()) {
6508 tinyexr::SetErrorMessage(err_str, err);
6509 }
6510 ret = TINYEXR_ERROR_INVALID_HEADER;
6511 }
6512 }
6513
6514 exr_header->multipart = version->multipart ? 1 : 0;
6515 exr_header->non_image = version->non_image ? 1 : 0;
6516
6517 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