| 4432 | |
| 4433 | |
| 4434 | static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, |
| 4435 | const EXRVersion *version, std::string *err, |
| 4436 | const unsigned char *buf, size_t size) { |
| 4437 | const char *marker = reinterpret_cast<const char *>(&buf[0]); |
| 4438 | |
| 4439 | if (empty_header) { |
| 4440 | (*empty_header) = false; |
| 4441 | } |
| 4442 | |
| 4443 | if (version->multipart) { |
| 4444 | if (size > 0 && marker[0] == '\0') { |
| 4445 | // End of header list. |
| 4446 | if (empty_header) { |
| 4447 | (*empty_header) = true; |
| 4448 | } |
| 4449 | return TINYEXR_SUCCESS; |
| 4450 | } |
| 4451 | } |
| 4452 | |
| 4453 | // According to the spec, the header of every OpenEXR file must contain at |
| 4454 | // least the following attributes: |
| 4455 | // |
| 4456 | // channels chlist |
| 4457 | // compression compression |
| 4458 | // dataWindow box2i |
| 4459 | // displayWindow box2i |
| 4460 | // lineOrder lineOrder |
| 4461 | // pixelAspectRatio float |
| 4462 | // screenWindowCenter v2f |
| 4463 | // screenWindowWidth float |
| 4464 | bool has_channels = false; |
| 4465 | bool has_compression = false; |
| 4466 | bool has_data_window = false; |
| 4467 | bool has_display_window = false; |
| 4468 | bool has_line_order = false; |
| 4469 | bool has_pixel_aspect_ratio = false; |
| 4470 | bool has_screen_window_center = false; |
| 4471 | bool has_screen_window_width = false; |
| 4472 | bool has_name = false; |
| 4473 | bool has_type = false; |
| 4474 | |
| 4475 | info->name.clear(); |
| 4476 | info->type.clear(); |
| 4477 | |
| 4478 | info->data_window.min_x = 0; |
| 4479 | info->data_window.min_y = 0; |
| 4480 | info->data_window.max_x = 0; |
| 4481 | info->data_window.max_y = 0; |
| 4482 | info->line_order = 0; // @fixme |
| 4483 | info->display_window.min_x = 0; |
| 4484 | info->display_window.min_y = 0; |
| 4485 | info->display_window.max_x = 0; |
| 4486 | info->display_window.max_y = 0; |
| 4487 | info->screen_window_center[0] = 0.0f; |
| 4488 | info->screen_window_center[1] = 0.0f; |
| 4489 | info->screen_window_width = -1.0f; |
| 4490 | info->pixel_aspect_ratio = -1.0f; |
| 4491 | |