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

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

Issue 15151002: Streamline SIMD targets in media.gyp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add Win64 hack. Created 7 years, 7 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/base/yuv_convert_unittest.cc » ('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 22 matching lines...) Expand all
33 #endif 33 #endif
34 #endif 34 #endif
35 35
36 // Assembly functions are declared without namespace. 36 // Assembly functions are declared without namespace.
37 extern "C" { 37 extern "C" {
38 void EmptyRegisterState_MMX(); 38 void EmptyRegisterState_MMX();
39 } // extern "C" 39 } // extern "C"
40 40
41 namespace media { 41 namespace media {
42 42
43 typedef void (*FilterYUVRowsProc)(uint8*, const uint8*, const uint8*, int, int);
44
45 typedef void (*ConvertYUVToRGB32Proc)(const uint8*,
46 const uint8*,
47 const uint8*,
48 uint8*,
49 int,
50 int,
51 int,
52 int,
53 int,
54 YUVType);
55
56 typedef void (*ConvertYUVAToARGBProc)(const uint8*,
57 const uint8*,
58 const uint8*,
59 const uint8*,
60 uint8*,
61 int,
62 int,
63 int,
64 int,
65 int,
66 int,
67 YUVType);
68
69 typedef void (*ConvertYUVToRGB32RowProc)(const uint8*,
70 const uint8*,
71 const uint8*,
72 uint8*,
73 ptrdiff_t);
74
75 typedef void (*ConvertYUVAToARGBRowProc)(const uint8*,
76 const uint8*,
77 const uint8*,
78 const uint8*,
79 uint8*,
80 ptrdiff_t);
81
82 typedef void (*ScaleYUVToRGB32RowProc)(const uint8*,
83 const uint8*,
84 const uint8*,
85 uint8*,
86 ptrdiff_t,
87 ptrdiff_t);
88
43 static FilterYUVRowsProc ChooseFilterYUVRowsProc() { 89 static FilterYUVRowsProc ChooseFilterYUVRowsProc() {
44 #if defined(ARCH_CPU_X86_FAMILY) 90 #if defined(ARCH_CPU_X86_FAMILY)
45 base::CPU cpu; 91 base::CPU cpu;
46 if (cpu.has_sse2()) 92 if (cpu.has_sse2())
47 return &FilterYUVRows_SSE2; 93 return &FilterYUVRows_SSE2;
48 94
49 #if defined(MEDIA_MMX_INTRINSICS_AVAILABLE) 95 #if defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
50 if (cpu.has_mmx()) 96 if (cpu.has_mmx())
51 return &FilterYUVRows_MMX; 97 return &FilterYUVRows_MMX;
52 #endif // defined(MEDIA_MMX_INTRINSICS_AVAILABLE) 98 #endif // defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
53 #endif // defined(ARCH_CPU_X86_FAMILY) 99 #endif // defined(ARCH_CPU_X86_FAMILY)
54 return &FilterYUVRows_C; 100 return &FilterYUVRows_C;
55 } 101 }
56 102
57 static ConvertYUVToRGB32RowProc ChooseConvertYUVToRGB32RowProc() { 103 static ConvertYUVToRGB32RowProc ChooseConvertYUVToRGB32RowProc() {
58 #if defined(ARCH_CPU_X86_FAMILY) 104 #if defined(ARCH_CPU_X86_FAMILY)
59 base::CPU cpu; 105 base::CPU cpu;
60 if (cpu.has_sse()) 106 if (cpu.has_sse())
61 return &ConvertYUVToRGB32Row_SSE; 107 return &ConvertYUVToRGB32Row_SSE;
62 if (cpu.has_mmx()) 108 if (cpu.has_mmx())
63 return &ConvertYUVToRGB32Row_MMX; 109 return &ConvertYUVToRGB32Row_MMX;
64 #endif 110 #endif
65 return &ConvertYUVToRGB32Row_C; 111 return &ConvertYUVToRGB32Row_C;
66 } 112 }
67 113
68 static ScaleYUVToRGB32RowProc ChooseScaleYUVToRGB32RowProc() { 114 static ScaleYUVToRGB32RowProc ChooseScaleYUVToRGB32RowProc() {
115 #if defined(ARCH_CPU_X86_FAMILY)
116 base::CPU cpu;
69 #if defined(ARCH_CPU_X86_64) 117 #if defined(ARCH_CPU_X86_64)
70 // Use 64-bits version if possible. 118 // Use 64-bits version if possible.
71 return &ScaleYUVToRGB32Row_SSE2_X64; 119 // TODO(dalecurtis): Fix this to directly return X64 version. All x64 procs
72 #elif defined(ARCH_CPU_X86_FAMILY) 120 // have SSE2, this is a hack to prevent MSVC from optimizing exports out in
73 base::CPU cpu; 121 // the shared library build which are used by unittests.
122 if (cpu.has_sse2())
123 return &ScaleYUVToRGB32Row_SSE2_X64;
124 #endif // defined(ARCH_CPU_X86_64)
74 // Choose the best one on 32-bits system. 125 // Choose the best one on 32-bits system.
75 if (cpu.has_sse()) 126 if (cpu.has_sse())
76 return &ScaleYUVToRGB32Row_SSE; 127 return &ScaleYUVToRGB32Row_SSE;
77 if (cpu.has_mmx()) 128 if (cpu.has_mmx())
78 return &ScaleYUVToRGB32Row_MMX; 129 return &ScaleYUVToRGB32Row_MMX;
79 #endif // defined(ARCH_CPU_X86_64) 130 #endif // defined(ARCH_CPU_X86_FAMILY)
80 return &ScaleYUVToRGB32Row_C; 131 return &ScaleYUVToRGB32Row_C;
81 } 132 }
82 133
83 static ScaleYUVToRGB32RowProc ChooseLinearScaleYUVToRGB32RowProc() { 134 static ScaleYUVToRGB32RowProc ChooseLinearScaleYUVToRGB32RowProc() {
135 #if defined(ARCH_CPU_X86_FAMILY)
136 base::CPU cpu;
84 #if defined(ARCH_CPU_X86_64) 137 #if defined(ARCH_CPU_X86_64)
85 // Use 64-bits version if possible. 138 // Use 64-bits version if possible.
86 return &LinearScaleYUVToRGB32Row_MMX_X64; 139 // TODO(dalecurtis): Fix this to directly return X64 version. All x64 procs
87 #elif defined(ARCH_CPU_X86_FAMILY) 140 // have SSE2, this is a hack to prevent MSVC from optimizing exports out in
88 base::CPU cpu; 141 // the shared library build which are used by unittests.
142 if (cpu.has_sse2())
143 return &LinearScaleYUVToRGB32Row_MMX_X64;
144 #endif // defined(ARCH_CPU_X86_64)
89 // 32-bits system. 145 // 32-bits system.
90 if (cpu.has_sse()) 146 if (cpu.has_sse())
91 return &LinearScaleYUVToRGB32Row_SSE; 147 return &LinearScaleYUVToRGB32Row_SSE;
92 if (cpu.has_mmx()) 148 if (cpu.has_mmx())
93 return &LinearScaleYUVToRGB32Row_MMX; 149 return &LinearScaleYUVToRGB32Row_MMX;
94 #endif // defined(ARCH_CPU_X86_64) 150 #endif // defined(ARCH_CPU_X86_FAMILY)
95 return &LinearScaleYUVToRGB32Row_C; 151 return &LinearScaleYUVToRGB32Row_C;
96 } 152 }
97 153
98 // Empty SIMD registers state after using them. 154 // Empty SIMD registers state after using them.
99 void EmptyRegisterState() { 155 void EmptyRegisterState() {
100 #if defined(ARCH_CPU_X86_FAMILY) 156 #if defined(ARCH_CPU_X86_FAMILY)
101 static bool checked = false; 157 static bool checked = false;
102 static bool has_mmx = false; 158 static bool has_mmx = false;
103 if (!checked) { 159 if (!checked) {
104 base::CPU cpu; 160 base::CPU cpu;
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 convert_proc = &ConvertYUVAToARGB_MMX; 683 convert_proc = &ConvertYUVAToARGB_MMX;
628 else 684 else
629 convert_proc = &ConvertYUVAToARGB_C; 685 convert_proc = &ConvertYUVAToARGB_C;
630 } 686 }
631 convert_proc(yplane, uplane, vplane, aplane, rgbframe, 687 convert_proc(yplane, uplane, vplane, aplane, rgbframe,
632 width, height, ystride, uvstride, astride, rgbstride, yuv_type); 688 width, height, ystride, uvstride, astride, rgbstride, yuv_type);
633 #endif 689 #endif
634 } 690 }
635 691
636 } // namespace media 692 } // namespace media
OLDNEW
« no previous file with comments | « media/base/yuv_convert.h ('k') | media/base/yuv_convert_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698