Coverage Report

Created: 2025-07-16 07:53

/usr/local/include/OpenEXR/ImfVersion.h
Line
Count
Source (jump to first uncovered line)
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
18
OPENEXR_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
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
74
isTiled (int version)
75
{
76
    return !!(version & TILED_FLAG);
77
}
78
inline bool
79
isMultiPart (int version)
80
0
{
81
0
    return !!(version & MULTI_PART_FILE_FLAG);
82
0
}
83
inline bool
84
isNonImage (int version)
85
0
{
86
0
    return !!(version & NON_IMAGE_FLAG);
87
0
}
88
inline int
89
makeTiled (int version)
90
0
{
91
0
    return version | TILED_FLAG;
92
0
}
93
inline int
94
makeNotTiled (int version)
95
0
{
96
0
    return version & ~TILED_FLAG;
97
0
}
98
inline int
99
getVersion (int version)
100
0
{
101
0
    return version & VERSION_NUMBER_FIELD;
102
0
}
103
inline int
104
getFlags (int version)
105
0
{
106
0
    return version & VERSION_FLAGS_FIELD;
107
0
}
108
inline bool
109
supportsFlags (int flags)
110
0
{
111
0
    return !(flags & ~ALL_FLAGS);
112
0
}
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
119
IMF_EXPORT
120
bool isImfMagic (const char bytes[4]);
121
122
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
123
124
#endif