1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2013 Academy of Motion Picture Arts and Sciences
3 // ("A.M.P.A.S."). Portions contributed by others as indicated.
4 // All rights reserved.
5 //
6 // A worldwide, royalty-free, non-exclusive right to copy, modify, create
7 // derivatives, and use, in source and binary forms, is hereby granted,
8 // subject to acceptance of this license. Performance of any of the
9 // aforementioned acts indicates acceptance to be bound by the following
10 // terms and conditions:
11 //
12 //  * Copies of source code, in whole or in part, must retain the
13 //    above copyright notice, this list of conditions and the
14 //    Disclaimer of Warranty.
15 //
16 //  * Use in binary form must retain the above copyright notice,
17 //    this list of conditions and the Disclaimer of Warranty in the
18 //    documentation and/or other materials provided with the distribution.
19 //
20 //  * Nothing in this license shall be deemed to grant any rights to
21 //    trademarks, copyrights, patents, trade secrets or any other
22 //    intellectual property of A.M.P.A.S. or any contributors, except
23 //    as expressly stated herein.
24 //
25 //  * Neither the name "A.M.P.A.S." nor the name of any other
26 //    contributors to this software may be used to endorse or promote
27 //    products derivative of or based on this software without express
28 //    prior written permission of A.M.P.A.S. or the contributors, as
29 //    appropriate.
30 //
31 // This license shall be construed pursuant to the laws of the State of
32 // California, and any disputes related thereto shall be subject to the
33 // jurisdiction of the courts therein.
34 //
35 // Disclaimer of Warranty: THIS SOFTWARE IS PROVIDED BY A.M.P.A.S. AND
36 // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
37 // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
38 // FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED. IN NO
39 // EVENT SHALL A.M.P.A.S., OR ANY CONTRIBUTORS OR DISTRIBUTORS, BE LIABLE
40 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, RESITUTIONARY,
41 // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
42 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
44 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
46 // THE POSSIBILITY OF SUCH DAMAGE.
47 //
48 // WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE ACADEMY
49 // SPECIFICALLY DISCLAIMS ANY REPRESENTATIONS OR WARRANTIES WHATSOEVER
50 // RELATED TO PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS IN THE ACADEMY
51 // COLOR ENCODING SYSTEM, OR APPLICATIONS THEREOF, HELD BY PARTIES OTHER
52 // THAN A.M.P.A.S., WHETHER DISCLOSED OR UNDISCLOSED.
53 ///////////////////////////////////////////////////////////////////////////
54 
55 
56 #ifndef INCLUDED_CTL_SIMD_OP_H
57 #define INCLUDED_CTL_SIMD_OP_H
58 
59 //-----------------------------------------------------------------------------
60 //
61 //	Operations for the SIMD color transformation engine.
62 //
63 //-----------------------------------------------------------------------------
64 
65 namespace Ctl {
66 
67 
68 template <class In1, class In2, class Out>
69 struct BinaryMinusOp
70 {
71     static void
executeBinaryMinusOp72     execute (const In1 &in1, const In2 &in2, Out &out)
73     {
74 	out = Out (in1 - in2);
75     }
76 };
77 
78 
79 template <class In1, class In2, class Out>
80 struct BitAndOp
81 {
82     static void
executeBitAndOp83     execute (const In1 &in1, const In2 &in2, Out &out)
84     {
85 	out = Out (in1 & in2);
86     }
87 };
88 
89 
90 template <class In1, class In2, class Out>
91 struct BoolBitAndOp
92 {
93     static void
executeBoolBitAndOp94     execute (const In1 &in1, const In2 &in2, Out &out)
95     {
96 	out = Out (!!in1 & !!in2);
97     }
98 };
99 
100 
101 template <class In, class Out>
102 struct BitNotOp
103 {
104     static void
executeBitNotOp105     execute (const In &in, Out &out)
106     {
107 	out = Out (~in);
108     }
109 };
110 
111 
112 template <class In1, class In2, class Out>
113 struct BitOrOp
114 {
115     static void
executeBitOrOp116     execute (const In1 &in1, const In2 &in2, Out &out)
117     {
118 	out = Out (in1 | in2);
119     }
120 };
121 
122 
123 template <class In1, class In2, class Out>
124 struct BoolBitOrOp
125 {
126     static void
executeBoolBitOrOp127     execute (const In1 &in1, const In2 &in2, Out &out)
128     {
129 	out = Out (!!in1 | !!in2);
130     }
131 };
132 
133 
134 template <class In1, class In2, class Out>
135 struct BitXorOp
136 {
137     static void
executeBitXorOp138     execute (const In1 &in1, const In2 &in2, Out &out)
139     {
140 	out = Out (in1 ^ in2);
141     }
142 };
143 
144 
145 template <class In1, class In2, class Out>
146 struct BoolBitXorOp
147 {
148     static void
executeBoolBitXorOp149     execute (const In1 &in1, const In2 &in2, Out &out)
150     {
151 	out = Out (!!in1 ^ !!in2);
152     }
153 };
154 
155 
156 template <class In, class Out>
157 struct CopyOp
158 {
159     static void
executeCopyOp160     execute (const In &in, Out &out)
161     {
162 	out = Out (in);
163     }
164 };
165 
166 
167 template <class In1, class In2, class Out>
168 struct DivOp
169 {
170     static void
executeDivOp171     execute (const In1 &in1, const In2 &in2, Out &out)
172     {
173 	out = Out (in1 / in2);
174     }
175 };
176 
177 
178 template <class In1, class In2, class Out>
179 struct IntDivOp
180 {
181     static void
executeIntDivOp182     execute (const In1 &in1, const In2 &in2, Out &out)
183     {
184 	out = (in2 != 0)? Out (in1 / in2): Out (0);
185     }
186 };
187 
188 
189 template <class In1, class In2, class Out>
190 struct EqualOp
191 {
192     static void
executeEqualOp193     execute (const In1 &in1, const In2 &in2, Out &out)
194     {
195 	out = Out (in1 == in2);
196     }
197 };
198 
199 
200 template <class In1, class In2, class Out>
201 struct GreaterEqualOp
202 {
203     static void
executeGreaterEqualOp204     execute (const In1 &in1, const In2 &in2, Out &out)
205     {
206 	out = Out (in1 >= in2);
207     }
208 };
209 
210 
211 template <class In1, class In2, class Out>
212 struct GreaterOp
213 {
214     static void
executeGreaterOp215     execute (const In1 &in1, const In2 &in2, Out &out)
216     {
217 	out = Out (in1 > in2);
218     }
219 };
220 
221 
222 template <class In1, class In2, class Out>
223 struct LeftShiftOp
224 {
225     static void
executeLeftShiftOp226     execute (const In1 &in1, const In2 &in2, Out &out)
227     {
228 	out = Out (in1 << in2);
229     }
230 };
231 
232 
233 template <class In1, class In2, class Out>
234 struct LessEqualOp
235 {
236     static void
executeLessEqualOp237     execute (const In1 &in1, const In2 &in2, Out &out)
238     {
239 	out = Out (in1 <= in2);
240     }
241 };
242 
243 
244 template <class In1, class In2, class Out>
245 struct LessOp
246 {
247     static void
executeLessOp248     execute (const In1 &in1, const In2 &in2, Out &out)
249     {
250 	out = Out (in1 < in2);
251     }
252 };
253 
254 
255 template <class In1, class In2, class Out>
256 struct ModOp
257 {
258     static void
executeModOp259     execute (const In1 &in1, const In2 &in2, Out &out)
260     {
261 	out = Out (in1 % in2);
262     }
263 };
264 
265 
266 template <class In1, class In2, class Out>
267 struct NotEqualOp
268 {
269     static void
executeNotEqualOp270     execute (const In1 &in1, const In2 &in2, Out &out)
271     {
272 	out = Out (in1 != in2);
273     }
274 };
275 
276 
277 template <class In, class Out>
278 struct NotOp
279 {
280     static void
executeNotOp281     execute (const In &in, Out &out)
282     {
283 	out = Out (!in);
284     }
285 };
286 
287 
288 template <class In1, class In2, class Out>
289 struct PlusOp
290 {
291     static void
executePlusOp292     execute (const In1 &in1, const In2 &in2, Out &out)
293     {
294 	out = Out (in1 + in2);
295     }
296 };
297 
298 
299 template <class In1, class In2, class Out>
300 struct RightShiftOp
301 {
302     static void
executeRightShiftOp303     execute (const In1 &in1, const In2 &in2, Out &out)
304     {
305 	out = Out (in1 >> in2);
306     }
307 };
308 
309 
310 template <class In1, class In2, class Out>
311 struct TimesOp
312 {
313     static void
executeTimesOp314     execute (const In1 &in1, const In2 &in2, Out &out)
315     {
316 	out = Out (in1 * in2);
317     }
318 };
319 
320 
321 template <class In, class Out>
322 struct UnaryMinusOp
323 {
324     static void
executeUnaryMinusOp325     execute (const In &in, Out &out)
326     {
327 	out = Out (-in);
328     }
329 };
330 
331 
332 } // namespace Ctl
333 
334 #endif
335