Coverage Report

Created: 2023-12-08 06:53

/src/freeimage-svn/FreeImage/trunk/Source/OpenEXR/IlmImf/ImfDeepFrameBuffer.cpp
Line
Count
Source (jump to first uncovered line)
1
///////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
4
// Digital Ltd. LLC
5
//
6
// All rights reserved.
7
//
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are
10
// met:
11
// *       Redistributions of source code must retain the above copyright
12
// notice, this list of conditions and the following disclaimer.
13
// *       Redistributions in binary form must reproduce the above
14
// copyright notice, this list of conditions and the following disclaimer
15
// in the documentation and/or other materials provided with the
16
// distribution.
17
// *       Neither the name of Industrial Light & Magic nor the names of
18
// its contributors may be used to endorse or promote products derived
19
// from this software without specific prior written permission.
20
//
21
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
//
33
///////////////////////////////////////////////////////////////////////////
34
35
#include "ImfDeepFrameBuffer.h"
36
#include "Iex.h"
37
38
39
using namespace std;
40
#include "ImfNamespace.h"
41
42
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
43
44
DeepSlice::DeepSlice (PixelType t,
45
                      char *b,
46
                      size_t xst,
47
                      size_t yst,
48
                      size_t spst,
49
                      int xsm,
50
                      int ysm,
51
                      double fv,
52
                      bool xtc,
53
                      bool ytc)
54
:
55
    Slice (t, b, xst, yst, xsm, ysm, fv, xtc, ytc),
56
    sampleStride (spst)
57
0
{
58
    // empty
59
0
}
60
61
62
void
63
DeepFrameBuffer::insert (const char name[], const DeepSlice &slice)
64
0
{
65
0
    if (name[0] == 0)
66
0
    {
67
0
        THROW (IEX_NAMESPACE::ArgExc,
68
0
               "Frame buffer slice name cannot be an empty string.");
69
0
    }
70
71
0
    _map[name] = slice;
72
0
}
73
74
75
void
76
DeepFrameBuffer::insert (const string &name, const DeepSlice &slice)
77
0
{
78
0
    insert (name.c_str(), slice);
79
0
}
80
81
82
DeepSlice &
83
DeepFrameBuffer::operator [] (const char name[])
84
0
{
85
0
    SliceMap::iterator i = _map.find (name);
86
87
0
    if (i == _map.end())
88
0
    {
89
0
        THROW (IEX_NAMESPACE::ArgExc,
90
0
               "Cannot find frame buffer slice \"" << name << "\".");
91
0
    }
92
93
0
    return i->second;
94
0
}
95
96
97
const DeepSlice &
98
DeepFrameBuffer::operator [] (const char name[]) const
99
0
{
100
0
    SliceMap::const_iterator i = _map.find (name);
101
102
0
    if (i == _map.end())
103
0
    {
104
0
        THROW (IEX_NAMESPACE::ArgExc,
105
0
               "Cannot find frame buffer slice \"" << name << "\".");
106
0
    }
107
108
0
    return i->second;
109
0
}
110
111
112
DeepSlice &
113
DeepFrameBuffer::operator [] (const string &name)
114
0
{
115
0
    return this->operator[] (name.c_str());
116
0
}
117
118
119
const DeepSlice &
120
DeepFrameBuffer::operator [] (const string &name) const
121
0
{
122
0
    return this->operator[] (name.c_str());
123
0
}
124
125
126
DeepSlice *
127
DeepFrameBuffer::findSlice (const char name[])
128
0
{
129
0
    SliceMap::iterator i = _map.find (name);
130
0
    return (i == _map.end())? 0: &i->second;
131
0
}
132
133
134
const DeepSlice *
135
DeepFrameBuffer::findSlice (const char name[]) const
136
0
{
137
0
    SliceMap::const_iterator i = _map.find (name);
138
0
    return (i == _map.end())? 0: &i->second;
139
0
}
140
141
142
DeepSlice *
143
DeepFrameBuffer::findSlice (const string &name)
144
0
{
145
0
    return findSlice (name.c_str());
146
0
}
147
148
149
const DeepSlice *
150
DeepFrameBuffer::findSlice (const string &name) const
151
0
{
152
0
    return findSlice (name.c_str());
153
0
}
154
155
156
DeepFrameBuffer::Iterator
157
DeepFrameBuffer::begin ()
158
0
{
159
0
    return _map.begin();
160
0
}
161
162
163
DeepFrameBuffer::ConstIterator
164
DeepFrameBuffer::begin () const
165
0
{
166
0
    return _map.begin();
167
0
}
168
169
170
DeepFrameBuffer::Iterator
171
DeepFrameBuffer::end ()
172
0
{
173
0
    return _map.end();
174
0
}
175
176
177
DeepFrameBuffer::ConstIterator
178
DeepFrameBuffer::end () const
179
0
{
180
0
    return _map.end();
181
0
}
182
183
184
DeepFrameBuffer::Iterator
185
DeepFrameBuffer::find (const char name[])
186
0
{
187
0
    return _map.find (name);
188
0
}
189
190
191
DeepFrameBuffer::ConstIterator
192
DeepFrameBuffer::find (const char name[]) const
193
0
{
194
0
    return _map.find (name);
195
0
}
196
197
198
DeepFrameBuffer::Iterator
199
DeepFrameBuffer::find (const string &name)
200
0
{
201
0
    return find (name.c_str());
202
0
}
203
204
205
DeepFrameBuffer::ConstIterator
206
DeepFrameBuffer::find (const string &name) const
207
0
{
208
0
    return find (name.c_str());
209
0
}
210
211
212
void
213
DeepFrameBuffer::insertSampleCountSlice(const Slice & slice)
214
0
{
215
0
    if (slice.type != UINT)
216
0
    {
217
0
        throw IEX_NAMESPACE::ArgExc("The type of sample count slice should be UINT.");
218
0
    }
219
220
0
    _sampleCounts = slice;
221
0
}
222
223
224
const Slice &
225
DeepFrameBuffer::getSampleCountSlice() const
226
0
{
227
0
    return _sampleCounts;
228
0
}
229
230
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT