| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This webpage shows layout of YV12 and other YUV formats | 5 // This webpage shows layout of YV12 and other YUV formats |
| 6 // http://www.fourcc.org/yuv.php | 6 // http://www.fourcc.org/yuv.php |
| 7 // The actual conversion is best described here | 7 // The actual conversion is best described here |
| 8 // http://en.wikipedia.org/wiki/YUV | 8 // http://en.wikipedia.org/wiki/YUV |
| 9 // An article on optimizing YUV conversion using tables instead of multiplies | 9 // An article on optimizing YUV conversion using tables instead of multiplies |
| 10 // http://lestourtereaux.free.fr/papers/data/yuvrgb.pdf | 10 // http://lestourtereaux.free.fr/papers/data/yuvrgb.pdf |
| 11 // | 11 // |
| 12 // YV12 is a full plane of Y and a half height, half width chroma planes | 12 // YV12 is a full plane of Y and a half height, half width chroma planes |
| 13 // YV16 is a full plane of Y and a full height, half width chroma planes | 13 // YV16 is a full plane of Y and a full height, half width chroma planes |
| 14 // | 14 // |
| 15 // ARGB pixel format is output, which on little endian is stored as BGRA. | 15 // ARGB pixel format is output, which on little endian is stored as BGRA. |
| 16 // The alpha is set to 255, allowing the application to use RGBA or RGB32. | 16 // The alpha is set to 255, allowing the application to use RGBA or RGB32. |
| 17 | 17 |
| 18 #include "media/base/yuv_convert.h" | 18 #include "media/base/yuv_convert.h" |
| 19 | 19 |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "media/base/cpu_features.h" | 21 #include "media/base/cpu_features.h" |
| 22 #include "media/base/simd/convert_rgb_to_yuv.h" |
| 22 #include "media/base/yuv_convert_internal.h" | 23 #include "media/base/yuv_convert_internal.h" |
| 23 #include "media/base/yuv_row.h" | 24 #include "media/base/yuv_row.h" |
| 24 | 25 |
| 25 #if USE_MMX | 26 #if USE_MMX |
| 26 #if defined(_MSC_VER) | 27 #if defined(_MSC_VER) |
| 27 #include <intrin.h> | 28 #include <intrin.h> |
| 28 #else | 29 #else |
| 29 #include <mmintrin.h> | 30 #include <mmintrin.h> |
| 30 #endif | 31 #endif |
| 31 #endif | 32 #endif |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 int ystride, | 363 int ystride, |
| 363 int uvstride) { | 364 int uvstride) { |
| 364 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, | 365 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, |
| 365 int, int, int, int, int) = NULL; | 366 int, int, int, int, int) = NULL; |
| 366 if (!convert_proc) { | 367 if (!convert_proc) { |
| 367 #if defined(ARCH_CPU_ARM_FAMILY) | 368 #if defined(ARCH_CPU_ARM_FAMILY) |
| 368 // For ARM processors, always use C version. | 369 // For ARM processors, always use C version. |
| 369 // TODO(hclam): Implement a NEON version. | 370 // TODO(hclam): Implement a NEON version. |
| 370 convert_proc = &ConvertRGB32ToYUV_C; | 371 convert_proc = &ConvertRGB32ToYUV_C; |
| 371 #else | 372 #else |
| 372 // For x86 processors, check if SSE2 is supported. | 373 // For x86 processors, check if SSSE3 (or SSE2) is supported. |
| 373 if (hasSSE2()) | 374 if (hasSSSE3()) |
| 375 convert_proc = &ConvertRGB32ToYUV_SSSE3; |
| 376 else if (hasSSE2()) |
| 374 convert_proc = &ConvertRGB32ToYUV_SSE2; | 377 convert_proc = &ConvertRGB32ToYUV_SSE2; |
| 375 else | 378 else |
| 376 convert_proc = &ConvertRGB32ToYUV_C; | 379 convert_proc = &ConvertRGB32ToYUV_C; |
| 377 #endif | 380 #endif |
| 378 } | 381 } |
| 379 | 382 |
| 380 convert_proc(rgbframe, yplane, uplane, vplane, width, height, | 383 convert_proc(rgbframe, yplane, uplane, vplane, width, height, |
| 381 rgbstride, ystride, uvstride); | 384 rgbstride, ystride, uvstride); |
| 382 } | 385 } |
| 383 | 386 |
| 384 void ConvertRGB24ToYUV(const uint8* rgbframe, | 387 void ConvertRGB24ToYUV(const uint8* rgbframe, |
| 385 uint8* yplane, | 388 uint8* yplane, |
| 386 uint8* uplane, | 389 uint8* uplane, |
| 387 uint8* vplane, | 390 uint8* vplane, |
| 388 int width, | 391 int width, |
| 389 int height, | 392 int height, |
| 390 int rgbstride, | 393 int rgbstride, |
| 391 int ystride, | 394 int ystride, |
| 392 int uvstride) { | 395 int uvstride) { |
| 396 #if defined(ARCH_CPU_ARM_FAMILY) |
| 393 ConvertRGB24ToYUV_C(rgbframe, yplane, uplane, vplane, width, height, | 397 ConvertRGB24ToYUV_C(rgbframe, yplane, uplane, vplane, width, height, |
| 394 rgbstride, ystride, uvstride); | 398 rgbstride, ystride, uvstride); |
| 399 #else |
| 400 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, |
| 401 int, int, int, int, int) = NULL; |
| 402 if (!convert_proc) { |
| 403 if (hasSSSE3()) |
| 404 convert_proc = &ConvertRGB24ToYUV_SSSE3; |
| 405 else |
| 406 convert_proc = &ConvertRGB24ToYUV_C; |
| 407 } |
| 408 convert_proc(rgbframe, yplane, uplane, vplane, width, height, |
| 409 rgbstride, ystride, uvstride); |
| 410 #endif |
| 395 } | 411 } |
| 396 | 412 |
| 397 void ConvertYUY2ToYUV(const uint8* src, | 413 void ConvertYUY2ToYUV(const uint8* src, |
| 398 uint8* yplane, | 414 uint8* yplane, |
| 399 uint8* uplane, | 415 uint8* uplane, |
| 400 uint8* vplane, | 416 uint8* vplane, |
| 401 int width, | 417 int width, |
| 402 int height) { | 418 int height) { |
| 403 ConvertYUY2ToYUV_C(src, yplane, uplane, vplane, width, height); | 419 ConvertYUY2ToYUV_C(src, yplane, uplane, vplane, width, height); |
| 404 } | 420 } |
| 405 } // namespace media | 421 } // namespace media |
| OLD | NEW |