/src/openexr/src/lib/OpenEXR/ImfGenericOutputFile.cpp
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 | | #include "ImfGenericOutputFile.h" |
7 | | |
8 | | #include "ImfBoxAttribute.h" |
9 | | #include "ImfChromaticitiesAttribute.h" |
10 | | #include "ImfFloatAttribute.h" |
11 | | #include "ImfHeader.h" |
12 | | #include "ImfIO.h" |
13 | | #include "ImfTimeCodeAttribute.h" |
14 | | #include "ImfVersion.h" |
15 | | #include "ImfXdr.h" |
16 | | |
17 | | #include "ImfMisc.h" |
18 | | #include "ImfPartType.h" |
19 | | |
20 | | OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
21 | | |
22 | | using namespace std; |
23 | | |
24 | | GenericOutputFile::~GenericOutputFile () |
25 | 0 | {} |
26 | | |
27 | | GenericOutputFile::GenericOutputFile () |
28 | 0 | {} |
29 | | |
30 | | void |
31 | | GenericOutputFile::writeMagicNumberAndVersionField ( |
32 | | OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, const Header& header) |
33 | 0 | { |
34 | 0 | OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write< |
35 | 0 | OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, MAGIC); |
36 | |
|
37 | 0 | int version = EXR_VERSION; |
38 | |
|
39 | 0 | if (header.hasType () && isDeepData (header.type ())) |
40 | 0 | { |
41 | 0 | version |= NON_IMAGE_FLAG; |
42 | 0 | } |
43 | 0 | else |
44 | 0 | { |
45 | | // (TODO) we may want to check something else in function signature |
46 | | // instead of hasTileDescription()? |
47 | 0 | if (header.hasTileDescription ()) version |= TILED_FLAG; |
48 | 0 | } |
49 | |
|
50 | 0 | if (usesLongNames (header)) version |= LONG_NAMES_FLAG; |
51 | |
|
52 | 0 | OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write< |
53 | 0 | OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, version); |
54 | 0 | } |
55 | | |
56 | | void |
57 | | GenericOutputFile::writeMagicNumberAndVersionField ( |
58 | | OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, |
59 | | const Header* headers, |
60 | | int parts) |
61 | 0 | { |
62 | 0 | OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write< |
63 | 0 | OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, MAGIC); |
64 | |
|
65 | 0 | int version = EXR_VERSION; |
66 | |
|
67 | 0 | if (parts == 1) |
68 | 0 | { |
69 | 0 | if (headers[0].type () == TILEDIMAGE) version |= TILED_FLAG; |
70 | 0 | } |
71 | 0 | else { version |= MULTI_PART_FILE_FLAG; } |
72 | |
|
73 | 0 | for (int i = 0; i < parts; i++) |
74 | 0 | { |
75 | 0 | if (usesLongNames (headers[i])) version |= LONG_NAMES_FLAG; |
76 | |
|
77 | 0 | if (headers[i].hasType () && isImage (headers[i].type ()) == false) |
78 | 0 | version |= NON_IMAGE_FLAG; |
79 | 0 | } |
80 | |
|
81 | 0 | OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write< |
82 | 0 | OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, version); |
83 | 0 | } |
84 | | |
85 | | OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |