• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 The LibYuv project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef LIBYUV_SOURCE_ROW_H_
12 #define LIBYUV_SOURCE_ROW_H_
13 
14 #include "libyuv/basic_types.h"
15 
16 // The following are available on all x86 platforms
17 #if (defined(WIN32) || defined(__x86_64__) || defined(__i386__)) \
18     && !defined(COVERAGE_ENABLED) && !defined(TARGET_IPHONE_SIMULATOR)
19 #define HAS_ARGBTOYROW_SSSE3
20 #define HAS_BG24TOARGBROW_SSSE3
21 #define HAS_RAWTOARGBROW_SSSE3
22 #define HAS_RGB24TOYROW_SSSE3
23 #define HAS_RAWTOYROW_SSSE3
24 #define HAS_RGB24TOUVROW_SSSE3
25 #define HAS_RAWTOUVROW_SSSE3
26 #endif
27 
28 // The following are available only on Windows
29 #if defined(WIN32) \
30     && !defined(COVERAGE_ENABLED) && !defined(TARGET_IPHONE_SIMULATOR)
31 #define HAS_BGRATOYROW_SSSE3
32 #define HAS_ABGRTOYROW_SSSE3
33 #define HAS_ARGBTOUVROW_SSSE3
34 #define HAS_BGRATOUVROW_SSSE3
35 #define HAS_ABGRTOUVROW_SSSE3
36 #endif
37 
38 extern "C" {
39 #ifdef HAS_ARGBTOYROW_SSSE3
40 void ARGBToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix);
41 void BGRAToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix);
42 void ABGRToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix);
43 void ARGBToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb,
44                        uint8* dst_u, uint8* dst_v, int width);
45 void BGRAToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb,
46                        uint8* dst_u, uint8* dst_v, int width);
47 void ABGRToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb,
48                        uint8* dst_u, uint8* dst_v, int width);
49 #endif
50 #if defined(HAS_BG24TOARGBROW_SSSE3) && defined(HAS_ARGBTOYROW_SSSE3)
51 #define HASRGB24TOYROW_SSSE3
52 #endif
53 #ifdef HASRGB24TOYROW_SSSE3
54 void RGB24ToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix);
55 void RAWToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix);
56 void RGB24ToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb,
57                         uint8* dst_u, uint8* dst_v, int width);
58 void RAWToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb,
59                       uint8* dst_u, uint8* dst_v, int width);
60 #endif
61 void ARGBToYRow_C(const uint8* src_argb, uint8* dst_y, int pix);
62 void BGRAToYRow_C(const uint8* src_argb, uint8* dst_y, int pix);
63 void ABGRToYRow_C(const uint8* src_argb, uint8* dst_y, int pix);
64 void RGB24ToYRow_C(const uint8* src_argb, uint8* dst_y, int pix);
65 void RAWToYRow_C(const uint8* src_argb, uint8* dst_y, int pix);
66 void ARGBToUVRow_C(const uint8* src_argb0, int src_stride_argb,
67                    uint8* dst_u, uint8* dst_v, int width);
68 void BGRAToUVRow_C(const uint8* src_argb0, int src_stride_argb,
69                    uint8* dst_u, uint8* dst_v, int width);
70 void ABGRToUVRow_C(const uint8* src_argb0, int src_stride_argb,
71                    uint8* dst_u, uint8* dst_v, int width);
72 void RGB24ToUVRow_C(const uint8* src_argb0, int src_stride_argb,
73                     uint8* dst_u, uint8* dst_v, int width);
74 void RAWToUVRow_C(const uint8* src_argb0, int src_stride_argb,
75                   uint8* dst_u, uint8* dst_v, int width);
76 
77 #ifdef HAS_BG24TOARGBROW_SSSE3
78 void BG24ToARGBRow_SSSE3(const uint8* src_bg24, uint8* dst_argb, int pix);
79 void RAWToARGBRow_SSSE3(const uint8* src_bg24, uint8* dst_argb, int pix);
80 #endif
81 void BG24ToARGBRow_C(const uint8* src_bg24, uint8* dst_argb, int pix);
82 void RAWToARGBRow_C(const uint8* src_bg24, uint8* dst_argb, int pix);
83 
84 #if defined(_MSC_VER)
85 #define SIMD_ALIGNED(var) __declspec(align(16)) var
86 #define TALIGN16(t, var) static __declspec(align(16)) t _ ## var
87 #else
88 #define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
89 #define TALIGN16(t, var) t var __attribute__((aligned(16)))
90 #endif
91 
92 #ifdef OSX
93 extern SIMD_ALIGNED(const int16 kCoefficientsRgbY[768][4]);
94 extern SIMD_ALIGNED(const int16 kCoefficientsBgraY[768][4]);
95 extern SIMD_ALIGNED(const int16 kCoefficientsAbgrY[768][4]);
96 #else
97 extern SIMD_ALIGNED(const int16 _kCoefficientsRgbY[768][4]);
98 extern SIMD_ALIGNED(const int16 _kCoefficientsBgraY[768][4]);
99 extern SIMD_ALIGNED(const int16 _kCoefficientsAbgrY[768][4]);
100 #endif
101 void FastConvertYUVToRGB32Row(const uint8* y_buf,
102                               const uint8* u_buf,
103                               const uint8* v_buf,
104                               uint8* rgb_buf,
105                               int width);
106 
107 void FastConvertYUVToBGRARow(const uint8* y_buf,
108                              const uint8* u_buf,
109                              const uint8* v_buf,
110                              uint8* rgb_buf,
111                              int width);
112 
113 void FastConvertYUVToABGRRow(const uint8* y_buf,
114                              const uint8* u_buf,
115                              const uint8* v_buf,
116                              uint8* rgb_buf,
117                              int width);
118 
119 void FastConvertYUV444ToRGB32Row(const uint8* y_buf,
120                                  const uint8* u_buf,
121                                  const uint8* v_buf,
122                                  uint8* rgb_buf,
123                                  int width);
124 
125 void FastConvertYToRGB32Row(const uint8* y_buf,
126                             uint8* rgb_buf,
127                             int width);
128 
129 // Method to force C version.
130 //#define USE_MMX 0
131 //#define USE_SSE2 0
132 
133 #if !defined(USE_MMX)
134 // Windows, Mac and Linux use MMX
135 #if defined(__i386__) || defined(_MSC_VER)
136 #define USE_MMX 1
137 #else
138 #define USE_MMX 0
139 #endif
140 #endif
141 
142 #if !defined(USE_SSE2)
143 #if defined(__SSE2__) || defined(ARCH_CPU_X86_64) || _M_IX86_FP==2
144 #define USE_SSE2 1
145 #else
146 #define USE_SSE2 0
147 #endif
148 #endif
149 
150 // x64 uses MMX2 (SSE) so emms is not required.
151 // Warning C4799: function has no EMMS instruction.
152 // EMMS() is slow and should be called by the calling function once per image.
153 #if USE_MMX && !defined(ARCH_CPU_X86_64)
154 #if defined(_MSC_VER)
155 #define EMMS() __asm emms
156 #pragma warning(disable: 4799)
157 #else
158 #define EMMS() asm("emms")
159 #endif
160 #else
161 #define EMMS()
162 #endif
163 
164 
165 }  // extern "C"
166 
167 #endif  // LIBYUV_SOURCE_ROW_H_
168