Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "media/base/simd/filter_yuv.h" | 26 #include "media/base/simd/filter_yuv.h" | 
| 27 | 27 | 
| 28 #if defined(ARCH_CPU_X86_FAMILY) | 28 #if defined(ARCH_CPU_X86_FAMILY) | 
| 29 #if defined(COMPILER_MSVC) | 29 #if defined(COMPILER_MSVC) | 
| 30 #include <intrin.h> | 30 #include <intrin.h> | 
| 31 #else | 31 #else | 
| 32 #include <mmintrin.h> | 32 #include <mmintrin.h> | 
| 33 #endif | 33 #endif | 
| 34 #endif | 34 #endif | 
| 35 | 35 | 
| 36 // Assembly functions are declared without namespace. | |
| 37 extern "C" { | |
| 38 void EmptyRegisterState_MMX(void); | |
| 
 
scherkus (not reviewing)
2013/02/01 01:13:17
nit: we don't typically put the void type in for p
 
wolenetz
2013/02/01 02:42:07
Done.
 
 | |
| 39 } // extern "C" | |
| 40 | |
| 36 namespace media { | 41 namespace media { | 
| 37 | 42 | 
| 38 static FilterYUVRowsProc ChooseFilterYUVRowsProc() { | 43 static FilterYUVRowsProc ChooseFilterYUVRowsProc() { | 
| 39 #if defined(ARCH_CPU_X86_FAMILY) | 44 #if defined(ARCH_CPU_X86_FAMILY) | 
| 40 base::CPU cpu; | 45 base::CPU cpu; | 
| 41 if (cpu.has_sse2()) | 46 if (cpu.has_sse2()) | 
| 42 return &FilterYUVRows_SSE2; | 47 return &FilterYUVRows_SSE2; | 
| 48 | |
| 49 #if !defined(MEDIA_DO_NOT_USE_MMX_INTRINSICS) | |
| 43 if (cpu.has_mmx()) | 50 if (cpu.has_mmx()) | 
| 44 return &FilterYUVRows_MMX; | 51 return &FilterYUVRows_MMX; | 
| 45 #endif | 52 #endif // !defined(MEDIA_DO_NOT_USE_MMX_INTRINSICS) | 
| 53 #endif // defined(ARCH_CPU_X86_FAMILY) | |
| 46 return &FilterYUVRows_C; | 54 return &FilterYUVRows_C; | 
| 47 } | 55 } | 
| 48 | 56 | 
| 49 static ConvertYUVToRGB32RowProc ChooseConvertYUVToRGB32RowProc() { | 57 static ConvertYUVToRGB32RowProc ChooseConvertYUVToRGB32RowProc() { | 
| 50 #if defined(ARCH_CPU_X86_FAMILY) | 58 #if defined(ARCH_CPU_X86_FAMILY) | 
| 51 base::CPU cpu; | 59 base::CPU cpu; | 
| 52 if (cpu.has_sse()) | 60 if (cpu.has_sse()) | 
| 53 return &ConvertYUVToRGB32Row_SSE; | 61 return &ConvertYUVToRGB32Row_SSE; | 
| 54 if (cpu.has_mmx()) | 62 if (cpu.has_mmx()) | 
| 55 return &ConvertYUVToRGB32Row_MMX; | 63 return &ConvertYUVToRGB32Row_MMX; | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 // Empty SIMD registers state after using them. | 98 // Empty SIMD registers state after using them. | 
| 91 void EmptyRegisterState() { | 99 void EmptyRegisterState() { | 
| 92 #if defined(ARCH_CPU_X86_FAMILY) | 100 #if defined(ARCH_CPU_X86_FAMILY) | 
| 93 static bool checked = false; | 101 static bool checked = false; | 
| 94 static bool has_mmx = false; | 102 static bool has_mmx = false; | 
| 95 if (!checked) { | 103 if (!checked) { | 
| 96 base::CPU cpu; | 104 base::CPU cpu; | 
| 97 has_mmx = cpu.has_mmx(); | 105 has_mmx = cpu.has_mmx(); | 
| 98 checked = true; | 106 checked = true; | 
| 99 } | 107 } | 
| 100 if (has_mmx) | 108 | 
| 109 if (has_mmx) { | |
| 110 #if defined(MEDIA_DO_NOT_USE_MMX_INTRINSICS) | |
| 111 EmptyRegisterState_MMX(); | |
| 112 #else | |
| 101 _mm_empty(); | 113 _mm_empty(); | 
| 102 #endif | 114 #endif // defined(MEDIA_DO_NOT_USE_MMX_INTRINSICS) | 
| 115 } | |
| 116 | |
| 117 #endif // defined(ARCH_CPU_X86_FAMILY) | |
| 103 } | 118 } | 
| 104 | 119 | 
| 105 // 16.16 fixed point arithmetic | 120 // 16.16 fixed point arithmetic | 
| 106 const int kFractionBits = 16; | 121 const int kFractionBits = 16; | 
| 107 const int kFractionMax = 1 << kFractionBits; | 122 const int kFractionMax = 1 << kFractionBits; | 
| 108 const int kFractionMask = ((1 << kFractionBits) - 1); | 123 const int kFractionMask = ((1 << kFractionBits) - 1); | 
| 109 | 124 | 
| 110 // Scale a frame of YUV to 32 bit ARGB. | 125 // Scale a frame of YUV to 32 bit ARGB. | 
| 111 void ScaleYUVToRGB32(const uint8* y_buf, | 126 void ScaleYUVToRGB32(const uint8* y_buf, | 
| 112 const uint8* u_buf, | 127 const uint8* u_buf, | 
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 else | 597 else | 
| 583 convert_proc = &ConvertYUVToRGB32_C; | 598 convert_proc = &ConvertYUVToRGB32_C; | 
| 584 } | 599 } | 
| 585 | 600 | 
| 586 convert_proc(yplane, uplane, vplane, rgbframe, | 601 convert_proc(yplane, uplane, vplane, rgbframe, | 
| 587 width, height, ystride, uvstride, rgbstride, yuv_type); | 602 width, height, ystride, uvstride, rgbstride, yuv_type); | 
| 588 #endif | 603 #endif | 
| 589 } | 604 } | 
| 590 | 605 | 
| 591 } // namespace media | 606 } // namespace media | 
| OLD | NEW |