Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: media/base/yuv_convert.cc

Issue 12090114: Replace or exclude MMX intrinsics in yuv_convert_simd_x86 due to lack of VS2010 support for them in… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/yuv_convert.h ('k') | media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Visual Studio 2010 does not support MMX intrinsics on x64.
37 // Some win64 yuv_convert code paths use SSE+MMX yasm, so without rewriting
38 // them, we use yasm EmptyRegisterState_MMX in place of _mm_empty() or
39 // hide the versions implemented with heavy use of MMX intrinsics.
40 // TODO(wolenetz): Use MMX intrinsics when compiling win64 with Visual
41 // Studio 2012? http://crbug.com/173450
42 #if !(defined(ARCH_CPU_X86_64) && defined(COMPILER_MSVC))
43 #define MEDIA_MMX_INTRINSICS_AVAILABLE
44 #endif
45
46 // Assembly functions are declared without namespace.
47 extern "C" {
48 void EmptyRegisterState_MMX();
49 } // extern "C"
50
36 namespace media { 51 namespace media {
37 52
38 static FilterYUVRowsProc ChooseFilterYUVRowsProc() { 53 static FilterYUVRowsProc ChooseFilterYUVRowsProc() {
39 #if defined(ARCH_CPU_X86_FAMILY) 54 #if defined(ARCH_CPU_X86_FAMILY)
40 base::CPU cpu; 55 base::CPU cpu;
41 if (cpu.has_sse2()) 56 if (cpu.has_sse2())
42 return &FilterYUVRows_SSE2; 57 return &FilterYUVRows_SSE2;
58
59 #if defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
43 if (cpu.has_mmx()) 60 if (cpu.has_mmx())
44 return &FilterYUVRows_MMX; 61 return &FilterYUVRows_MMX;
45 #endif 62 #endif // defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
63 #endif // defined(ARCH_CPU_X86_FAMILY)
46 return &FilterYUVRows_C; 64 return &FilterYUVRows_C;
47 } 65 }
48 66
49 static ConvertYUVToRGB32RowProc ChooseConvertYUVToRGB32RowProc() { 67 static ConvertYUVToRGB32RowProc ChooseConvertYUVToRGB32RowProc() {
50 #if defined(ARCH_CPU_X86_FAMILY) 68 #if defined(ARCH_CPU_X86_FAMILY)
51 base::CPU cpu; 69 base::CPU cpu;
52 if (cpu.has_sse()) 70 if (cpu.has_sse())
53 return &ConvertYUVToRGB32Row_SSE; 71 return &ConvertYUVToRGB32Row_SSE;
54 if (cpu.has_mmx()) 72 if (cpu.has_mmx())
55 return &ConvertYUVToRGB32Row_MMX; 73 return &ConvertYUVToRGB32Row_MMX;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Empty SIMD registers state after using them. 108 // Empty SIMD registers state after using them.
91 void EmptyRegisterState() { 109 void EmptyRegisterState() {
92 #if defined(ARCH_CPU_X86_FAMILY) 110 #if defined(ARCH_CPU_X86_FAMILY)
93 static bool checked = false; 111 static bool checked = false;
94 static bool has_mmx = false; 112 static bool has_mmx = false;
95 if (!checked) { 113 if (!checked) {
96 base::CPU cpu; 114 base::CPU cpu;
97 has_mmx = cpu.has_mmx(); 115 has_mmx = cpu.has_mmx();
98 checked = true; 116 checked = true;
99 } 117 }
100 if (has_mmx) 118
119 if (has_mmx) {
120 #if defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
101 _mm_empty(); 121 _mm_empty();
102 #endif 122 #else
123 EmptyRegisterState_MMX();
124 #endif // defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
125 }
126
127 #endif // defined(ARCH_CPU_X86_FAMILY)
103 } 128 }
104 129
105 // 16.16 fixed point arithmetic 130 // 16.16 fixed point arithmetic
106 const int kFractionBits = 16; 131 const int kFractionBits = 16;
107 const int kFractionMax = 1 << kFractionBits; 132 const int kFractionMax = 1 << kFractionBits;
108 const int kFractionMask = ((1 << kFractionBits) - 1); 133 const int kFractionMask = ((1 << kFractionBits) - 1);
109 134
110 // Scale a frame of YUV to 32 bit ARGB. 135 // Scale a frame of YUV to 32 bit ARGB.
111 void ScaleYUVToRGB32(const uint8* y_buf, 136 void ScaleYUVToRGB32(const uint8* y_buf,
112 const uint8* u_buf, 137 const uint8* u_buf,
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 else 607 else
583 convert_proc = &ConvertYUVToRGB32_C; 608 convert_proc = &ConvertYUVToRGB32_C;
584 } 609 }
585 610
586 convert_proc(yplane, uplane, vplane, rgbframe, 611 convert_proc(yplane, uplane, vplane, rgbframe,
587 width, height, ystride, uvstride, rgbstride, yuv_type); 612 width, height, ystride, uvstride, rgbstride, yuv_type);
588 #endif 613 #endif
589 } 614 }
590 615
591 } // namespace media 616 } // namespace media
OLDNEW
« no previous file with comments | « media/base/yuv_convert.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698