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

Side by Side Diff: media/base/yuv_row.h

Issue 1638008: yuv use a shared table for windows, posix and C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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_unittest.cc ('k') | media/base/yuv_row_posix.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // yuv_row internal functions to handle YUV conversion and scaling to RGB. 5 // yuv_row internal functions to handle YUV conversion and scaling to RGB.
6 // These functions are used from both yuv_convert.cc and yuv_scale.cc. 6 // These functions are used from both yuv_convert.cc and yuv_scale.cc.
7 7
8 // TODO(fbarchard): Write function that can handle rotation and scaling. 8 // TODO(fbarchard): Write function that can handle rotation and scaling.
9 9
10 #ifndef MEDIA_BASE_YUV_ROW_H_ 10 #ifndef MEDIA_BASE_YUV_ROW_H_
11 #define MEDIA_BASE_YUV_ROW_H_ 11 #define MEDIA_BASE_YUV_ROW_H_
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 14
15 extern "C" { 15 extern "C" {
16 // Can only do 1x. 16 // Can only do 1x.
17 // This is the second fastest of the scalers. 17 // This is the second fastest of the scalers.
18 void FastConvertYUVToRGB32Row(const uint8* y_buf, 18 void FastConvertYUVToRGB32Row(const uint8* y_buf,
19 const uint8* u_buf, 19 const uint8* u_buf,
20 const uint8* v_buf, 20 const uint8* v_buf,
21 uint8* rgb_buf, 21 uint8* rgb_buf,
22 int width); 22 int source_width);
23 23
24 // Can do 1x, half size or any scale down by an integer amount. 24 // Can do 1x, half size or any scale down by an integer amount.
25 // Step can be negative (mirroring, rotate 180). 25 // Step can be negative (mirroring, rotate 180).
26 // This is the third fastest of the scalers. 26 // This is the third fastest of the scalers.
27 void ConvertYUVToRGB32Row(const uint8* y_buf, 27 void ConvertYUVToRGB32Row(const uint8* y_buf,
28 const uint8* u_buf, 28 const uint8* u_buf,
29 const uint8* v_buf, 29 const uint8* v_buf,
30 uint8* rgb_buf, 30 uint8* rgb_buf,
31 int width, 31 int source_width,
32 int step); 32 int step);
33 33
34 // Rotate is like Convert, but applies different step to Y versus U and V. 34 // Rotate is like Convert, but applies different step to Y versus U and V.
35 // This allows rotation by 90 or 270, by stepping by stride. 35 // This allows rotation by 90 or 270, by stepping by stride.
36 // This is the forth fastest of the scalers. 36 // This is the forth fastest of the scalers.
37 void RotateConvertYUVToRGB32Row(const uint8* y_buf, 37 void RotateConvertYUVToRGB32Row(const uint8* y_buf,
38 const uint8* u_buf, 38 const uint8* u_buf,
39 const uint8* v_buf, 39 const uint8* v_buf,
40 uint8* rgb_buf, 40 uint8* rgb_buf,
41 int width, 41 int source_width,
42 int ystep, 42 int ystep,
43 int uvstep); 43 int uvstep);
44 44
45 // Doubler does 4 pixels at a time. Each pixel is replicated. 45 // Doubler does 4 pixels at a time. Each pixel is replicated.
46 // This is the fastest of the scalers. 46 // This is the fastest of the scalers.
47 void DoubleYUVToRGB32Row(const uint8* y_buf, 47 void DoubleYUVToRGB32Row(const uint8* y_buf,
48 const uint8* u_buf, 48 const uint8* u_buf,
49 const uint8* v_buf, 49 const uint8* v_buf,
50 uint8* rgb_buf, 50 uint8* rgb_buf,
51 int width); 51 int source_width);
52 52
53 // Handles arbitrary scaling up or down. 53 // Handles arbitrary scaling up or down.
54 // Mirroring is supported, but not 90 or 270 degree rotation. 54 // Mirroring is supported, but not 90 or 270 degree rotation.
55 // Chroma is under sampled every 2 pixels for performance. 55 // Chroma is under sampled every 2 pixels for performance.
56 // This is the slowest of the scalers. 56 // This is the slowest of the scalers.
57 void ScaleYUVToRGB32Row(const uint8* y_buf, 57 void ScaleYUVToRGB32Row(const uint8* y_buf,
58 const uint8* u_buf, 58 const uint8* u_buf,
59 const uint8* v_buf, 59 const uint8* v_buf,
60 uint8* rgb_buf, 60 uint8* rgb_buf,
61 int width, 61 int source_width,
62 int scaled_dx); 62 int source_dx);
63 63
64 void LinearScaleYUVToRGB32Row(const uint8* y_buf, 64 void LinearScaleYUVToRGB32Row(const uint8* y_buf,
65 const uint8* u_buf, 65 const uint8* u_buf,
66 const uint8* v_buf, 66 const uint8* v_buf,
67 uint8* rgb_buf, 67 uint8* rgb_buf,
68 int width, 68 int source_width,
69 int dx); 69 int dx);
70 } // extern "C" 70
71 #if defined(_MSC_VER)
72 #define SIMD_ALIGNED(var) __declspec(align(16)) var
73 #else
74 #define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
75 #endif
76 extern SIMD_ALIGNED(int16 kCoefficientsRgbY[768][4]);
77
78 // Method to force C version.
79 //#define USE_MMX 0
80 //#define USE_SSE2 0
71 81
72 #if !defined(USE_MMX) 82 #if !defined(USE_MMX)
73 // Windows, Mac and Linux/BSD use MMX 83 // Windows, Mac and Linux/BSD use MMX
74 #if defined(__MMX__) || defined(_MSC_VER) 84 #if defined(__MMX__) || defined(_MSC_VER)
75 #define USE_MMX 1 85 #define USE_MMX 1
76 #else 86 #else
77 #define USE_MMX 0 87 #define USE_MMX 0
78 #endif 88 #endif
79 #endif 89 #endif
80 90
81 #if !defined(USE_SSE) 91 #if !defined(USE_SSE2)
82 #if defined(__SSE2__) || defined(ARCH_CPU_X86_64) || _M_IX86_FP==2 92 #if defined(__SSE2__) || defined(ARCH_CPU_X86_64) || _M_IX86_FP==2
83 #define USE_SSE 1 93 #define USE_SSE2 1
84 #else 94 #else
85 #define USE_SSE 0 95 #define USE_SSE2 0
86 #endif 96 #endif
87 #endif 97 #endif
88 98
89 // x64 uses MMX2 (SSE) so emms is not required. 99 // x64 uses MMX2 (SSE) so emms is not required.
100 // Warning C4799: function has no EMMS instruction.
101 // EMMS() is slow and should be called by the calling function once per image.
90 #if USE_MMX && !defined(ARCH_CPU_X86_64) 102 #if USE_MMX && !defined(ARCH_CPU_X86_64)
91 #if defined(_MSC_VER) 103 #if defined(_MSC_VER)
92 #define EMMS() __asm emms 104 #define EMMS() __asm emms
93 #pragma warning(disable: 4799) 105 #pragma warning(disable: 4799)
94 #else 106 #else
95 #define EMMS() asm("emms") 107 #define EMMS() asm("emms")
96 #endif 108 #endif
97 #else 109 #else
98 #define EMMS() 110 #define EMMS()
99 #endif 111 #endif
100 112
113 } // extern "C"
114
101 #endif // MEDIA_BASE_YUV_ROW_H_ 115 #endif // MEDIA_BASE_YUV_ROW_H_
OLDNEW
« no previous file with comments | « media/base/yuv_convert_unittest.cc ('k') | media/base/yuv_row_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698