1//
2// SPDX-License-Identifier: BSD-3-Clause
3// Copyright (c) Contributors to the OpenEXR Project.
4//
5
6#ifndef INCLUDED_IMF_VERSION_H
7#define INCLUDED_IMF_VERSION_H
8
9//-----------------------------------------------------------------------------
10//
11// Magic and version number.
12//
13//-----------------------------------------------------------------------------
14
15#include "ImfExport.h"
16#include "ImfNamespace.h"
17
18OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
19
20//
21// The MAGIC number is stored in the first four bytes of every
22// OpenEXR image file. This can be used to quickly test whether
23// a given file is an OpenEXR image file (see isImfMagic(), below).
24//
25
26static const int MAGIC = 20000630;
27
28
29//
30// The second item in each OpenEXR image file, right after the
31// magic number, is a four-byte file version identifier. Depending
32// on a file's version identifier, a file reader can enable various
33// backwards-compatibility switches, or it can quickly reject files
34// that it cannot read.
35//
36// The version identifier is split into an 8-bit version number,
37// and a 24-bit flags field.
38//
39
40static const int VERSION_NUMBER_FIELD = 0x000000ff;
41static const int VERSION_FLAGS_FIELD = 0xffffff00;
42
43
44//
45// Value that goes into VERSION_NUMBER_FIELD.
46//
47
48static const int EXR_VERSION = 2;
49
50
51//
52// Flags that can go into VERSION_FLAGS_FIELD.
53// Flags can only occupy the 1 bits in VERSION_FLAGS_FIELD.
54//
55
56static const int TILED_FLAG = 0x00000200; // File is tiled
57static
58const int LONG_NAMES_FLAG = 0x00000400; // File contains long
59 // attribute or channel
60 // names
61static
62const int NON_IMAGE_FLAG = 0x00000800; // File has at least one part
63 // which is not a regular
64 // scanline image or regular tiled image
65 // (that is, it is a deep format)
66static
67const int MULTI_PART_FILE_FLAG = 0x00001000; // File has multiple parts
68
69//
70// Bitwise OR of all known flags.
71//
72static
73const int ALL_FLAGS = TILED_FLAG | LONG_NAMES_FLAG |
74 NON_IMAGE_FLAG | MULTI_PART_FILE_FLAG;
75
76
77//
78// Utility functions
79//
80
81inline bool isTiled (int version) {return !!(version & TILED_FLAG);}
82inline bool isMultiPart (int version) {return !!(version & MULTI_PART_FILE_FLAG); }
83inline bool isNonImage(int version) {return !!(version & NON_IMAGE_FLAG); }
84inline int makeTiled (int version) {return version | TILED_FLAG;}
85inline int makeNotTiled (int version) {return version & ~TILED_FLAG;}
86inline int getVersion (int version) {return version & VERSION_NUMBER_FIELD;}
87inline int getFlags (int version) {return version & VERSION_FLAGS_FIELD;}
88inline bool supportsFlags (int flags) {return !(flags & ~ALL_FLAGS);}
89
90
91//
92// Given the first four bytes of a file, returns true if the
93// file is probably an OpenEXR image file, false if not.
94//
95
96IMF_EXPORT
97bool isImfMagic (const char bytes[4]);
98
99
100OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
101
102
103
104
105
106#endif
107

source code of include/OpenEXR/ImfVersion.h