OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 ARGBToUVRow(src_argb, 0, dst_u, dst_v, width); | 174 ARGBToUVRow(src_argb, 0, dst_u, dst_v, width); |
175 ARGBToYRow(src_argb, dst_y, width); | 175 ARGBToYRow(src_argb, dst_y, width); |
176 src_argb += src_stride_argb; | 176 src_argb += src_stride_argb; |
177 dst_y += dst_stride_y; | 177 dst_y += dst_stride_y; |
178 dst_u += dst_stride_u; | 178 dst_u += dst_stride_u; |
179 dst_v += dst_stride_v; | 179 dst_v += dst_stride_v; |
180 } | 180 } |
181 return 0; | 181 return 0; |
182 } | 182 } |
183 | 183 |
184 // ARGB little endian (bgra in memory) to I411 | |
185 LIBYUV_API | |
186 int ARGBToI411(const uint8* src_argb, int src_stride_argb, | |
187 uint8* dst_y, int dst_stride_y, | |
188 uint8* dst_u, int dst_stride_u, | |
189 uint8* dst_v, int dst_stride_v, | |
190 int width, int height) { | |
191 int y; | |
192 void (*ARGBToUV411Row)(const uint8* src_argb, uint8* dst_u, uint8* dst_v, | |
193 int width) = ARGBToUV411Row_C; | |
194 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = | |
195 ARGBToYRow_C; | |
196 if (!src_argb || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { | |
197 return -1; | |
198 } | |
199 if (height < 0) { | |
200 height = -height; | |
201 src_argb = src_argb + (height - 1) * src_stride_argb; | |
202 src_stride_argb = -src_stride_argb; | |
203 } | |
204 // Coalesce rows. | |
205 if (src_stride_argb == width * 4 && | |
206 dst_stride_y == width && | |
207 dst_stride_u * 4 == width && | |
208 dst_stride_v * 4 == width) { | |
209 width *= height; | |
210 height = 1; | |
211 src_stride_argb = dst_stride_y = dst_stride_u = dst_stride_v = 0; | |
212 } | |
213 #if defined(HAS_ARGBTOYROW_SSSE3) | |
214 if (TestCpuFlag(kCpuHasSSSE3)) { | |
215 ARGBToYRow = ARGBToYRow_Any_SSSE3; | |
216 if (IS_ALIGNED(width, 16)) { | |
217 ARGBToYRow = ARGBToYRow_SSSE3; | |
218 } | |
219 } | |
220 #endif | |
221 #if defined(HAS_ARGBTOYROW_AVX2) | |
222 if (TestCpuFlag(kCpuHasAVX2)) { | |
223 ARGBToYRow = ARGBToYRow_Any_AVX2; | |
224 if (IS_ALIGNED(width, 32)) { | |
225 ARGBToYRow = ARGBToYRow_AVX2; | |
226 } | |
227 } | |
228 #endif | |
229 #if defined(HAS_ARGBTOYROW_NEON) | |
230 if (TestCpuFlag(kCpuHasNEON)) { | |
231 ARGBToYRow = ARGBToYRow_Any_NEON; | |
232 if (IS_ALIGNED(width, 8)) { | |
233 ARGBToYRow = ARGBToYRow_NEON; | |
234 } | |
235 } | |
236 #endif | |
237 #if defined(HAS_ARGBTOUV411ROW_NEON) | |
238 if (TestCpuFlag(kCpuHasNEON)) { | |
239 ARGBToUV411Row = ARGBToUV411Row_Any_NEON; | |
240 if (IS_ALIGNED(width, 32)) { | |
241 ARGBToUV411Row = ARGBToUV411Row_NEON; | |
242 } | |
243 } | |
244 #endif | |
245 | |
246 for (y = 0; y < height; ++y) { | |
247 ARGBToUV411Row(src_argb, dst_u, dst_v, width); | |
248 ARGBToYRow(src_argb, dst_y, width); | |
249 src_argb += src_stride_argb; | |
250 dst_y += dst_stride_y; | |
251 dst_u += dst_stride_u; | |
252 dst_v += dst_stride_v; | |
253 } | |
254 return 0; | |
255 } | |
256 | |
257 LIBYUV_API | 184 LIBYUV_API |
258 int ARGBToNV12(const uint8* src_argb, int src_stride_argb, | 185 int ARGBToNV12(const uint8* src_argb, int src_stride_argb, |
259 uint8* dst_y, int dst_stride_y, | 186 uint8* dst_y, int dst_stride_y, |
260 uint8* dst_uv, int dst_stride_uv, | 187 uint8* dst_uv, int dst_stride_uv, |
261 int width, int height) { | 188 int width, int height) { |
262 int y; | 189 int y; |
263 int halfwidth = (width + 1) >> 1; | 190 int halfwidth = (width + 1) >> 1; |
264 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, | 191 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, |
265 uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; | 192 uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; |
266 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = | 193 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 #if defined(HAS_ARGBTORGB565DITHERROW_NEON) | 832 #if defined(HAS_ARGBTORGB565DITHERROW_NEON) |
906 if (TestCpuFlag(kCpuHasNEON)) { | 833 if (TestCpuFlag(kCpuHasNEON)) { |
907 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_Any_NEON; | 834 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_Any_NEON; |
908 if (IS_ALIGNED(width, 8)) { | 835 if (IS_ALIGNED(width, 8)) { |
909 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_NEON; | 836 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_NEON; |
910 } | 837 } |
911 } | 838 } |
912 #endif | 839 #endif |
913 for (y = 0; y < height; ++y) { | 840 for (y = 0; y < height; ++y) { |
914 ARGBToRGB565DitherRow(src_argb, dst_rgb565, | 841 ARGBToRGB565DitherRow(src_argb, dst_rgb565, |
915 *(uint32*)(dither4x4 + ((y & 3) << 2)), width); | 842 *(uint32*)(dither4x4 + ((y & 3) << 2)), width); /* NOLINT */ |
916 src_argb += src_stride_argb; | 843 src_argb += src_stride_argb; |
917 dst_rgb565 += dst_stride_rgb565; | 844 dst_rgb565 += dst_stride_rgb565; |
918 } | 845 } |
919 return 0; | 846 return 0; |
920 } | 847 } |
921 | 848 |
922 // Convert ARGB To RGB565. | 849 // Convert ARGB To RGB565. |
923 // TODO(fbarchard): Consider using dither function low level with zeros. | 850 // TODO(fbarchard): Consider using dither function low level with zeros. |
924 LIBYUV_API | 851 LIBYUV_API |
925 int ARGBToRGB565(const uint8* src_argb, int src_stride_argb, | 852 int ARGBToRGB565(const uint8* src_argb, int src_stride_argb, |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 src_argb += src_stride_argb; | 1220 src_argb += src_stride_argb; |
1294 dst_yj += dst_stride_yj; | 1221 dst_yj += dst_stride_yj; |
1295 } | 1222 } |
1296 return 0; | 1223 return 0; |
1297 } | 1224 } |
1298 | 1225 |
1299 #ifdef __cplusplus | 1226 #ifdef __cplusplus |
1300 } // extern "C" | 1227 } // extern "C" |
1301 } // namespace libyuv | 1228 } // namespace libyuv |
1302 #endif | 1229 #endif |
OLD | NEW |