rs_convert.spec revision f1001ad7dea3814e499cf28e6d0d95852244edc6
1be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet#
220b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet# Copyright (C) 2015 The Android Open Source Project
3be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet#
4be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet# Licensed under the Apache License, Version 2.0 (the "License");
5be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet# you may not use this file except in compliance with the License.
6be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet# You may obtain a copy of the License at
7be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet#
8be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet#      http://www.apache.org/licenses/LICENSE-2.0
9be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet#
10be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet# Unless required by applicable law or agreed to in writing, software
11be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet# distributed under the License is distributed on an "AS IS" BASIS,
12be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet# See the License for the specific language governing permissions and
14be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet# limitations under the License.
15be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet#
16be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
17be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletheader:
1820b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletsummary: Conversion Functions
19be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletdescription:
206386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouillet The functions below convert from a numerical vector type to another, of from one color
216386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouillet representation to another.
22be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
23be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
24be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: convert_#3#1
25be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletversion: 9
26be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: const
27be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletw: 2, 3, 4
28be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillett: u8, u16, u32, i8, i16, i32, f32
29be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillett: u8, u16, u32, i8, i16, i32, f32
30be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: #3#1
31be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletarg: #2#1 v, compatible(#3)
3220b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletsummary: Convert numerical vectors
33be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletdescription:
346386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouillet Converts a vector from one numerical type to another.  The conversion are done entry per entry.
35be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
366386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouillet E.g calling <code>a = convert_short3(b);</code> is equivalent to doing
3720b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet <code>a.x = (short)b.x; a.y = (short)b.y; a.z = (short)b.z;</code>.
38be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
3920b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet Converting floating point values to integer types truncates.
4020b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet
4120b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet Converting numbers too large to fit the destination type yields undefined results.
42be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet For example, converting a float that contains 1.0e18 to a short is undefined.
43be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet Use @clamp() to avoid this.
44be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
45be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
46be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: convert_#3#1
47be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletversion: 21
48be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: const
49be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletw: 2, 3, 4
50be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillett: u64, i64, f64
51be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillett: u64, i64, f64
52be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: #3#1
53be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletarg: #2#1 v, compatible(#3)
54be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
55be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
56be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: convert_#3#1
57be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletversion: 21
58be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: const
59be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletw: 2, 3, 4
60be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillett: u64, i64, f64
61be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillett: u8, u16, u32, i8, i16, i32, f32
62be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: #3#1
63be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletarg: #2#1 v, compatible(#3)
64be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
65be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
66be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: convert_#3#1
67be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletversion: 21
68be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: const
69be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletw: 2, 3, 4
70be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillett: u8, u16, u32, i8, i16, i32, f32
71be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillett: u64, i64, f64
72be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: #3#1
73be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletarg: #2#1 v, compatible(#3)
74be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
75be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
76be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: rsPackColorTo8888
77be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: const
78be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: uchar4
7920b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletarg: float r, "Red component."
8020b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletarg: float g, "Green component."
8120b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletarg: float b, "Blue component."
8220b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletsummary: Create a uchar4 RGBA from floats
83be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletdescription:
84f1001ad7dea3814e499cf28e6d0d95852244edc6Jean-Luc Brouillet Packs three or four floating point RGBA values into a uchar4.
85f1001ad7dea3814e499cf28e6d0d95852244edc6Jean-Luc Brouillet
86f1001ad7dea3814e499cf28e6d0d95852244edc6Jean-Luc Brouillet The input values are typically between 0.0 and 1.0 inclusive.  For input values outside
87f1001ad7dea3814e499cf28e6d0d95852244edc6Jean-Luc Brouillet of this range, the resulting outputs will be clamped to be between 0 and 255.  As this
88f1001ad7dea3814e499cf28e6d0d95852244edc6Jean-Luc Brouillet clamping may be done after the input is multiplied by 255.f and converted to an integer,
89f1001ad7dea3814e499cf28e6d0d95852244edc6Jean-Luc Brouillet input numbers greater than INT_MAX/255.f or less than INT_MIN/255.f can result in
90f1001ad7dea3814e499cf28e6d0d95852244edc6Jean-Luc Brouillet undefined behavior.
91be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
926386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouillet If the alpha component is not specified, it is assumed to be 1.0, i.e. the result will
936386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouillet have an alpha set to 255.
94be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillettest: none
95be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
96be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
97be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: rsPackColorTo8888
98be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: const
99be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: uchar4
100be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletarg: float r
101be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletarg: float g
102be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletarg: float b
10320b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletarg: float a, "Alpha component."
104be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillettest: none
105be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
106be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
107be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: rsPackColorTo8888
108be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: const
109be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: uchar4
11020b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletarg: float3 color, "Vector of 3 or 4 floats containing the R, G, B, and A values."
111be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillettest: none
112be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
113be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
114be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: rsPackColorTo8888
115be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: const
116be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: uchar4
117be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletarg: float4 color
118be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillettest: none
119be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
120be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
121be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: rsUnpackColor8888
12220b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet# NOTE: The = below indicates that the generator should not add "overloadable" by default.
12320b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet# We're doing this to stay backward compatible with the unusual declaration used when this
12420b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet# function was introduced.
125be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: =const
126be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: float4
127be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletarg: uchar4 c
12820b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletsummary: Create a float4 RGBA from uchar4
129be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletdescription:
1306386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouillet Unpacks a uchar4 color to float4.  The resulting floats will be between 0.0 and 1.0 inclusive.
131be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillettest: none
132be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
133be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillet
134be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletfunction: rsYuvToRGBA_#2#1
135be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletattrib: const
136be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletw: 4
137be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillett: u8, f32
138be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletret: #2#1
1396386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouilletarg: uchar y, "Luminance component."
1406386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouilletarg: uchar u, "U chrominance component."
1416386ceb3bf25e442513224aaa45691dfe49562d9Jean-Luc Brouilletarg: uchar v, "V chrominance component."
14220b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouilletsummary: Convert a YUV value to RGBA
143be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletdescription:
14420b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet Converts a color from a YUV representation to RGBA.
14520b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet
14620b27d602a4778ed50a83df2147416a35b7c92beJean-Luc Brouillet We currently don't provide a function to do the reverse conversion.
147be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouillettest: none
148be2163801c33d6849ae580d42b919b8803d55095Jean-Luc Brouilletend:
149