Chromium Code Reviews| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 int ARGBToNV12(const uint8* src_argb, int src_stride_argb, | 258 int ARGBToNV12(const uint8* src_argb, int src_stride_argb, |
| 259 uint8* dst_y, int dst_stride_y, | 259 uint8* dst_y, int dst_stride_y, |
| 260 uint8* dst_uv, int dst_stride_uv, | 260 uint8* dst_uv, int dst_stride_uv, |
| 261 int width, int height) { | 261 int width, int height) { |
| 262 int y; | 262 int y; |
| 263 int halfwidth = (width + 1) >> 1; | 263 int halfwidth = (width + 1) >> 1; |
| 264 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, | 264 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, |
| 265 uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; | 265 uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; |
| 266 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = | 266 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = |
| 267 ARGBToYRow_C; | 267 ARGBToYRow_C; |
| 268 void (*MergeUVRow_)(const uint8* src_u, const uint8* src_v, uint8* dst_uv, | 268 MergeUVRowFunction MergeUVRow_ = GetOptimizedMergeUVRowFunction(width); |
|
fbarchard1
2016/08/24 23:04:11
change not needed here.
| |
| 269 int width) = MergeUVRow_C; | |
| 270 if (!src_argb || | 269 if (!src_argb || |
| 271 !dst_y || !dst_uv || | 270 !dst_y || !dst_uv || |
| 272 width <= 0 || height == 0) { | 271 width <= 0 || height == 0) { |
| 273 return -1; | 272 return -1; |
| 274 } | 273 } |
| 275 // Negative height means invert the image. | 274 // Negative height means invert the image. |
| 276 if (height < 0) { | 275 if (height < 0) { |
| 277 height = -height; | 276 height = -height; |
| 278 src_argb = src_argb + (height - 1) * src_stride_argb; | 277 src_argb = src_argb + (height - 1) * src_stride_argb; |
| 279 src_stride_argb = -src_stride_argb; | 278 src_stride_argb = -src_stride_argb; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 307 } | 306 } |
| 308 #endif | 307 #endif |
| 309 #if defined(HAS_ARGBTOUVROW_NEON) | 308 #if defined(HAS_ARGBTOUVROW_NEON) |
| 310 if (TestCpuFlag(kCpuHasNEON)) { | 309 if (TestCpuFlag(kCpuHasNEON)) { |
| 311 ARGBToUVRow = ARGBToUVRow_Any_NEON; | 310 ARGBToUVRow = ARGBToUVRow_Any_NEON; |
| 312 if (IS_ALIGNED(width, 16)) { | 311 if (IS_ALIGNED(width, 16)) { |
| 313 ARGBToUVRow = ARGBToUVRow_NEON; | 312 ARGBToUVRow = ARGBToUVRow_NEON; |
| 314 } | 313 } |
| 315 } | 314 } |
| 316 #endif | 315 #endif |
| 317 #if defined(HAS_MERGEUVROW_SSE2) | |
| 318 if (TestCpuFlag(kCpuHasSSE2)) { | |
| 319 MergeUVRow_ = MergeUVRow_Any_SSE2; | |
| 320 if (IS_ALIGNED(halfwidth, 16)) { | |
| 321 MergeUVRow_ = MergeUVRow_SSE2; | |
| 322 } | |
| 323 } | |
| 324 #endif | |
| 325 #if defined(HAS_MERGEUVROW_AVX2) | |
| 326 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 327 MergeUVRow_ = MergeUVRow_Any_AVX2; | |
| 328 if (IS_ALIGNED(halfwidth, 32)) { | |
| 329 MergeUVRow_ = MergeUVRow_AVX2; | |
| 330 } | |
| 331 } | |
| 332 #endif | |
| 333 #if defined(HAS_MERGEUVROW_NEON) | |
| 334 if (TestCpuFlag(kCpuHasNEON)) { | |
| 335 MergeUVRow_ = MergeUVRow_Any_NEON; | |
| 336 if (IS_ALIGNED(halfwidth, 16)) { | |
| 337 MergeUVRow_ = MergeUVRow_NEON; | |
| 338 } | |
| 339 } | |
| 340 #endif | |
| 341 { | 316 { |
| 342 // Allocate a rows of uv. | 317 // Allocate a rows of uv. |
| 343 align_buffer_64(row_u, ((halfwidth + 31) & ~31) * 2); | 318 align_buffer_64(row_u, ((halfwidth + 31) & ~31) * 2); |
| 344 uint8* row_v = row_u + ((halfwidth + 31) & ~31); | 319 uint8* row_v = row_u + ((halfwidth + 31) & ~31); |
| 345 | 320 |
| 346 for (y = 0; y < height - 1; y += 2) { | 321 for (y = 0; y < height - 1; y += 2) { |
| 347 ARGBToUVRow(src_argb, src_stride_argb, row_u, row_v, width); | 322 ARGBToUVRow(src_argb, src_stride_argb, row_u, row_v, width); |
| 348 MergeUVRow_(row_u, row_v, dst_uv, halfwidth); | 323 MergeUVRow_(row_u, row_v, dst_uv, halfwidth); |
| 349 ARGBToYRow(src_argb, dst_y, width); | 324 ARGBToYRow(src_argb, dst_y, width); |
| 350 ARGBToYRow(src_argb + src_stride_argb, dst_y + dst_stride_y, width); | 325 ARGBToYRow(src_argb + src_stride_argb, dst_y + dst_stride_y, width); |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1277 src_argb += src_stride_argb; | 1252 src_argb += src_stride_argb; |
| 1278 dst_yj += dst_stride_yj; | 1253 dst_yj += dst_stride_yj; |
| 1279 } | 1254 } |
| 1280 return 0; | 1255 return 0; |
| 1281 } | 1256 } |
| 1282 | 1257 |
| 1283 #ifdef __cplusplus | 1258 #ifdef __cplusplus |
| 1284 } // extern "C" | 1259 } // extern "C" |
| 1285 } // namespace libyuv | 1260 } // namespace libyuv |
| 1286 #endif | 1261 #endif |
| OLD | NEW |