107#if HAVE_SSE_EXTENSIONS
108 const __m128 mmNear = _mm_set1_ps(near_clipping_plane_distance_);
109 const __m128 mmFar = _mm_set1_ps(far_clipping_plane_distance_);
110 const __m128 mmNF = _mm_mul_ps(mmNear, mmFar);
111 const __m128 mmF_N = _mm_sub_ps(mmFar, mmNear);
112 static const __m128 mmOnes = _mm_set1_ps(1);
113 static const __m128 mmZeros = _mm_set1_ps(0);
115 float* depthEnd = depth + width_ * height_;
116 if (!isAligned16(depth))
119 unsigned first = 16 - alignment16(depth);
121 const float near = near_clipping_plane_distance_;
122 const float far = far_clipping_plane_distance_;
123 const float nf = near * far;
124 const float f_n = far - near;
126 while (depth < depthEnd && idx++ < first)
127 if (*depth != 0 && *depth != 1)
128 *depth = nf / (far - *depth * f_n);
133 unsigned last = (width_ * height_ - first) & 15;
134 float* depth2 = depthEnd - last;
135 while (depth2 < depthEnd)
136 if (*depth2 != 0 && *depth2 != 1)
137 *depth2 = nf / (far - *depth2 * f_n);
144 const __m128* mmEnd = (__m128*)depthEnd;
145 __m128* mmDepth = (__m128*)depth;
147 while (mmDepth < mmEnd)
149 __m128 mask = _mm_and_ps(_mm_cmpneq_ps(*mmDepth, mmOnes), _mm_cmpneq_ps(*mmDepth, mmZeros));
150 *mmDepth = _mm_mul_ps(*mmDepth, mmF_N);
151 *mmDepth = _mm_sub_ps(mmFar, *mmDepth);
152 *mmDepth = _mm_div_ps(mmNF, *mmDepth);
153 *mmDepth = _mm_and_ps(*mmDepth, mask);
159 const float near = near_clipping_plane_distance_;
160 const float far = far_clipping_plane_distance_;
161 const float nf = near * far;
162 const float f_n = far - near;
164 const float* depth_end = depth + width_ * height_;
165 while (depth < depth_end)
167 if (*depth != 0 && *depth != 1)
169 *depth = nf / (far - *depth * f_n);
183#if HAVE_SSE_EXTENSIONS
185 const __m128 mmNear = _mm_set1_ps(near_clipping_plane_distance_);
186 const __m128 mmFar = _mm_set1_ps(far_clipping_plane_distance_);
187 const __m128 mmScale = _mm_sub_ps(mmFar, mmNear);
188 float* depthEnd = depth + width_ * height_;
190 if (!isAligned16(depth))
193 unsigned first = 16 - alignment16(depth);
195 const float scale = far_clipping_plane_distance_ - near_clipping_plane_distance_;
196 const float offset = near_clipping_plane_distance_;
197 while (depth < depthEnd && idx++ < first)
198 if (*depth != 0 && *depth != 1.0)
199 *depth = *depth * scale + offset;
204 unsigned last = (width_ * height_ - first) & 15;
205 float* depth2 = depthEnd - last;
206 while (depth2 < depthEnd)
207 if (*depth2 != 0 && *depth != 1.0)
208 *depth2 = *depth2 * scale + offset;
215 const __m128* mmEnd = (__m128*)depthEnd;
216 __m128* mmDepth = (__m128*)depth;
218 while (mmDepth < mmEnd)
220 *mmDepth = _mm_mul_ps(*mmDepth, mmScale);
221 *mmDepth = _mm_add_ps(*mmDepth, mmNear);
222 *mmDepth = _mm_and_ps(*mmDepth, _mm_and_ps(_mm_cmpneq_ps(*mmDepth, mmNear), _mm_cmpneq_ps(*mmDepth, mmFar)));
226 const float* depth_end = depth + width_ * height_;
227 const float scale = far_clipping_plane_distance_ - near_clipping_plane_distance_;
228 const float offset = near_clipping_plane_distance_;
229 while (depth < depth_end)
233 if (*depth != 0 && *depth != 1.0)
235 *depth = *depth * scale + offset;
Parameters(unsigned width, unsigned height, float near_clipping_plane_distance, float far_clipping_plane_distance)
Constructor taking core parameters that are required for all sensors.