HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfVersion.h
Go to the documentation of this file.
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 
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 
26 static const int MAGIC = 20000630;
27 
28 //
29 // The second item in each OpenEXR image file, right after the
30 // magic number, is a four-byte file version identifier. Depending
31 // on a file's version identifier, a file reader can enable various
32 // backwards-compatibility switches, or it can quickly reject files
33 // that it cannot read.
34 //
35 // The version identifier is split into an 8-bit version number,
36 // and a 24-bit flags field.
37 //
38 
39 static const int VERSION_NUMBER_FIELD = 0x000000ff;
40 static const int VERSION_FLAGS_FIELD = 0xffffff00;
41 
42 //
43 // Value that goes into VERSION_NUMBER_FIELD.
44 //
45 
46 static const int EXR_VERSION = 2;
47 
48 //
49 // Flags that can go into VERSION_FLAGS_FIELD.
50 // Flags can only occupy the 1 bits in VERSION_FLAGS_FIELD.
51 //
52 
53 static const int TILED_FLAG = 0x00000200; // File is tiled
54 static const int LONG_NAMES_FLAG = 0x00000400; // File contains long
55  // attribute or channel
56  // names
57 static const int NON_IMAGE_FLAG = 0x00000800; // File has at least one part
58  // which is not a regular
59 // scanline image or regular tiled image
60 // (that is, it is a deep format)
61 static const int MULTI_PART_FILE_FLAG = 0x00001000; // File has multiple parts
62 
63 //
64 // Bitwise OR of all known flags.
65 //
66 static const int ALL_FLAGS =
67  TILED_FLAG | LONG_NAMES_FLAG | NON_IMAGE_FLAG | MULTI_PART_FILE_FLAG;
68 
69 //
70 // Utility functions
71 //
72 
73 inline bool
75 {
76  return !!(version & TILED_FLAG);
77 }
78 inline bool
80 {
81  return !!(version & MULTI_PART_FILE_FLAG);
82 }
83 inline bool
85 {
86  return !!(version & NON_IMAGE_FLAG);
87 }
88 inline int
90 {
91  return version | TILED_FLAG;
92 }
93 inline int
95 {
96  return version & ~TILED_FLAG;
97 }
98 inline int
100 {
101  return version & VERSION_NUMBER_FIELD;
102 }
103 inline int
105 {
106  return version & VERSION_FLAGS_FIELD;
107 }
108 inline bool
110 {
111  return !(flags & ~ALL_FLAGS);
112 }
113 
114 //
115 // Given the first four bytes of a file, returns true if the
116 // file is probably an OpenEXR image file, false if not.
117 //
118 
120 bool isImfMagic (const char bytes[4]);
121 
123 
124 #endif
bool isTiled(int version)
Definition: ImfVersion.h:74
GLbitfield flags
Definition: glcorearb.h:1596
int getVersion(int version)
Definition: ImfVersion.h:99
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:83
#define MAGIC
Definition: IMG_Sample.C:40
bool isMultiPart(int version)
Definition: ImfVersion.h:79
bool isNonImage(int version)
Definition: ImfVersion.h:84
int getFlags(int version)
Definition: ImfVersion.h:104
bool supportsFlags(int flags)
Definition: ImfVersion.h:109
IMF_EXPORT bool isImfMagic(const char bytes[4])
#define IMF_EXPORT
Definition: ImfExport.h:54
int makeNotTiled(int version)
Definition: ImfVersion.h:94
GT_API const UT_StringHolder version
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:80
int makeTiled(int version)
Definition: ImfVersion.h:89
Definition: format.h:2459