mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 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 | #include "row.h" |
| 12 | |
frkoenig@google.com | c82af4a | 2011-11-11 00:54:34 +0000 | [diff] [blame] | 13 | #include "libyuv/basic_types.h" |
| 14 | |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 15 | extern "C" { |
| 16 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 17 | #ifdef HAS_ARGBTOUVROW_SSSE3 |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 18 | vec8 kARGBToU = { |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 19 | 112, -74, -38, 0, 112, -74, -38, 0, 112, -74, -38, 0, 112, -74, -38, 0 |
| 20 | }; |
| 21 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 22 | uvec8 kARGBToV = { |
fbarchard@google.com | 2430e04 | 2011-11-11 21:57:06 +0000 | [diff] [blame] | 23 | -18, -94, 112, 0, -18, -94, 112, 0, -18, -94, 112, 0, -18, -94, 112, 0 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 24 | }; |
fbarchard@google.com | 2430e04 | 2011-11-11 21:57:06 +0000 | [diff] [blame] | 25 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 26 | uvec8 kAddUV128 = { |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 27 | 128u, 128u, 128u, 128u, 128u, 128u, 128u, 128u, |
| 28 | 128u, 128u, 128u, 128u, 128u, 128u, 128u, 128u |
| 29 | }; |
| 30 | #endif |
| 31 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 32 | #ifdef HAS_ARGBTOYROW_SSSE3 |
| 33 | |
| 34 | // Constant multiplication table for converting ARGB to I400. |
| 35 | vec8 kARGBToY = { |
| 36 | 13, 65, 33, 0, 13, 65, 33, 0, 13, 65, 33, 0, 13, 65, 33, 0 |
| 37 | }; |
| 38 | |
| 39 | uvec8 kAddY16 = { |
| 40 | 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u |
| 41 | }; |
| 42 | |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 43 | // Shuffle table for converting BG24 to ARGB. |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 44 | uvec8 kShuffleMaskBG24ToARGB = { |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 45 | 0u, 1u, 2u, 12u, 3u, 4u, 5u, 13u, 6u, 7u, 8u, 14u, 9u, 10u, 11u, 15u |
| 46 | }; |
| 47 | |
| 48 | // Shuffle table for converting RAW to ARGB. |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 49 | uvec8 kShuffleMaskRAWToARGB = { |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 50 | 2u, 1u, 0u, 12u, 5u, 4u, 3u, 13u, 8u, 7u, 6u, 14u, 11u, 10u, 9u, 15u |
| 51 | }; |
| 52 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 53 | // Shuffle table for converting ABGR to ARGB. |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 54 | uvec8 kShuffleMaskABGRToARGB = { |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 55 | 2u, 1u, 0u, 3u, 6u, 5u, 4u, 7u, 10u, 9u, 8u, 11u, 14u, 13u, 12u, 15u |
| 56 | }; |
| 57 | |
| 58 | // Shuffle table for converting BGRA to ARGB. |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 59 | uvec8 kShuffleMaskBGRAToARGB = { |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 60 | 3u, 2u, 1u, 0u, 7u, 6u, 5u, 4u, 11u, 10u, 9u, 8u, 15u, 14u, 13u, 12u |
| 61 | }; |
| 62 | |
| 63 | void I400ToARGBRow_SSE2(const uint8* src_y, uint8* dst_argb, int pix) { |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 64 | asm volatile ( |
| 65 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 66 | "pslld $0x18,%%xmm5 \n" |
| 67 | "1: \n" |
| 68 | "movq (%0),%%xmm0 \n" |
| 69 | "lea 0x8(%0),%0 \n" |
| 70 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 71 | "movdqa %%xmm0,%%xmm1 \n" |
| 72 | "punpcklwd %%xmm0,%%xmm0 \n" |
| 73 | "punpckhwd %%xmm1,%%xmm1 \n" |
| 74 | "por %%xmm5,%%xmm0 \n" |
| 75 | "por %%xmm5,%%xmm1 \n" |
| 76 | "movdqa %%xmm0,(%1) \n" |
| 77 | "movdqa %%xmm1,0x10(%1) \n" |
| 78 | "lea 0x20(%1),%1 \n" |
| 79 | "sub $0x8,%2 \n" |
| 80 | "ja 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 81 | : "+r"(src_y), // %0 |
| 82 | "+r"(dst_argb), // %1 |
| 83 | "+r"(pix) // %2 |
| 84 | : |
| 85 | : "memory", "cc" |
| 86 | #if defined(__SSE2__) |
| 87 | , "xmm0", "xmm1", "xmm5" |
| 88 | #endif |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 89 | ); |
| 90 | } |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 91 | |
| 92 | void ABGRToARGBRow_SSSE3(const uint8* src_abgr, uint8* dst_argb, int pix) { |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 93 | asm volatile ( |
| 94 | "movdqa %3,%%xmm5 \n" |
| 95 | "1: \n" |
| 96 | "movdqa (%0),%%xmm0 \n" |
| 97 | "lea 0x10(%0),%0 \n" |
| 98 | "pshufb %%xmm5,%%xmm0 \n" |
| 99 | "movdqa %%xmm0,(%1) \n" |
| 100 | "lea 0x10(%1),%1 \n" |
| 101 | "sub $0x4,%2 \n" |
| 102 | "ja 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 103 | : "+r"(src_abgr), // %0 |
| 104 | "+r"(dst_argb), // %1 |
| 105 | "+r"(pix) // %2 |
| 106 | : "m"(kShuffleMaskABGRToARGB) // %3 |
| 107 | : "memory", "cc" |
| 108 | #if defined(__SSE2__) |
| 109 | , "xmm0", "xmm5" |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 110 | #endif |
| 111 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 112 | ); |
| 113 | } |
| 114 | |
| 115 | void BGRAToARGBRow_SSSE3(const uint8* src_bgra, uint8* dst_argb, int pix) { |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 116 | asm volatile ( |
| 117 | "movdqa %3,%%xmm5 \n" |
| 118 | "1: \n" |
| 119 | "movdqa (%0),%%xmm0 \n" |
| 120 | "lea 0x10(%0),%0 \n" |
| 121 | "pshufb %%xmm5,%%xmm0 \n" |
| 122 | "movdqa %%xmm0,(%1) \n" |
| 123 | "lea 0x10(%1),%1 \n" |
| 124 | "sub $0x4,%2 \n" |
| 125 | "ja 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 126 | : "+r"(src_bgra), // %0 |
| 127 | "+r"(dst_argb), // %1 |
| 128 | "+r"(pix) // %2 |
| 129 | : "m"(kShuffleMaskBGRAToARGB) // %3 |
| 130 | : "memory", "cc" |
| 131 | #if defined(__SSE2__) |
| 132 | , "xmm0", "xmm5" |
| 133 | #endif |
| 134 | ); |
| 135 | } |
| 136 | |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 137 | void BG24ToARGBRow_SSSE3(const uint8* src_bg24, uint8* dst_argb, int pix) { |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 138 | asm volatile ( |
| 139 | "pcmpeqb %%xmm5,%%xmm5 \n" // generate mask 0xff000000 |
| 140 | "pslld $0x18,%%xmm5 \n" |
| 141 | "movdqa %3,%%xmm4 \n" |
| 142 | "1: \n" |
| 143 | "movdqa (%0),%%xmm0 \n" |
| 144 | "movdqa 0x10(%0),%%xmm1 \n" |
| 145 | "movdqa 0x20(%0),%%xmm3 \n" |
| 146 | "lea 0x30(%0),%0 \n" |
| 147 | "movdqa %%xmm3,%%xmm2 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 148 | "palignr $0x8,%%xmm1,%%xmm2 \n" |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 149 | "pshufb %%xmm4,%%xmm2 \n" |
| 150 | "por %%xmm5,%%xmm2 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 151 | "palignr $0xc,%%xmm0,%%xmm1 \n" |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 152 | "pshufb %%xmm4,%%xmm0 \n" |
| 153 | "movdqa %%xmm2,0x20(%1) \n" |
| 154 | "por %%xmm5,%%xmm0 \n" |
| 155 | "pshufb %%xmm4,%%xmm1 \n" |
| 156 | "movdqa %%xmm0,(%1) \n" |
| 157 | "por %%xmm5,%%xmm1 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 158 | "palignr $0x4,%%xmm3,%%xmm3 \n" |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 159 | "pshufb %%xmm4,%%xmm3 \n" |
| 160 | "movdqa %%xmm1,0x10(%1) \n" |
| 161 | "por %%xmm5,%%xmm3 \n" |
| 162 | "movdqa %%xmm3,0x30(%1) \n" |
| 163 | "lea 0x40(%1),%1 \n" |
| 164 | "sub $0x10,%2 \n" |
| 165 | "ja 1b \n" |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 166 | : "+r"(src_bg24), // %0 |
| 167 | "+r"(dst_argb), // %1 |
| 168 | "+r"(pix) // %2 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 169 | : "m"(kShuffleMaskBG24ToARGB) // %3 |
| 170 | : "memory", "cc" |
| 171 | #if defined(__SSE2__) |
| 172 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 173 | #endif |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 174 | ); |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 175 | } |
| 176 | |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 177 | void RAWToARGBRow_SSSE3(const uint8* src_raw, uint8* dst_argb, int pix) { |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 178 | asm volatile ( |
| 179 | "pcmpeqb %%xmm5,%%xmm5 \n" // generate mask 0xff000000 |
| 180 | "pslld $0x18,%%xmm5 \n" |
| 181 | "movdqa %3,%%xmm4 \n" |
| 182 | "1: \n" |
| 183 | "movdqa (%0),%%xmm0 \n" |
| 184 | "movdqa 0x10(%0),%%xmm1 \n" |
| 185 | "movdqa 0x20(%0),%%xmm3 \n" |
| 186 | "lea 0x30(%0),%0 \n" |
| 187 | "movdqa %%xmm3,%%xmm2 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 188 | "palignr $0x8,%%xmm1,%%xmm2 \n" |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 189 | "pshufb %%xmm4,%%xmm2 \n" |
| 190 | "por %%xmm5,%%xmm2 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 191 | "palignr $0xc,%%xmm0,%%xmm1 \n" |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 192 | "pshufb %%xmm4,%%xmm0 \n" |
| 193 | "movdqa %%xmm2,0x20(%1) \n" |
| 194 | "por %%xmm5,%%xmm0 \n" |
| 195 | "pshufb %%xmm4,%%xmm1 \n" |
| 196 | "movdqa %%xmm0,(%1) \n" |
| 197 | "por %%xmm5,%%xmm1 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 198 | "palignr $0x4,%%xmm3,%%xmm3 \n" |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 199 | "pshufb %%xmm4,%%xmm3 \n" |
| 200 | "movdqa %%xmm1,0x10(%1) \n" |
| 201 | "por %%xmm5,%%xmm3 \n" |
| 202 | "movdqa %%xmm3,0x30(%1) \n" |
| 203 | "lea 0x40(%1),%1 \n" |
| 204 | "sub $0x10,%2 \n" |
| 205 | "ja 1b \n" |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 206 | : "+r"(src_raw), // %0 |
| 207 | "+r"(dst_argb), // %1 |
| 208 | "+r"(pix) // %2 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 209 | : "m"(kShuffleMaskRAWToARGB) // %3 |
| 210 | : "memory", "cc" |
| 211 | #if defined(__SSE2__) |
| 212 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 213 | #endif |
| 214 | ); |
| 215 | } |
| 216 | |
| 217 | void ARGBToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix) { |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 218 | asm volatile ( |
| 219 | "movdqa %4,%%xmm5 \n" |
| 220 | "movdqa %3,%%xmm4 \n" |
| 221 | "1: \n" |
| 222 | "movdqa (%0),%%xmm0 \n" |
| 223 | "movdqa 0x10(%0),%%xmm1 \n" |
| 224 | "movdqa 0x20(%0),%%xmm2 \n" |
| 225 | "movdqa 0x30(%0),%%xmm3 \n" |
| 226 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 227 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 228 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 229 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 230 | "lea 0x40(%0),%0 \n" |
| 231 | "phaddw %%xmm1,%%xmm0 \n" |
| 232 | "phaddw %%xmm3,%%xmm2 \n" |
| 233 | "psrlw $0x7,%%xmm0 \n" |
| 234 | "psrlw $0x7,%%xmm2 \n" |
| 235 | "packuswb %%xmm2,%%xmm0 \n" |
| 236 | "paddb %%xmm5,%%xmm0 \n" |
| 237 | "movdqa %%xmm0,(%1) \n" |
| 238 | "lea 0x10(%1),%1 \n" |
| 239 | "sub $0x10,%2 \n" |
| 240 | "ja 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 241 | : "+r"(src_argb), // %0 |
| 242 | "+r"(dst_y), // %1 |
| 243 | "+r"(pix) // %2 |
| 244 | : "m"(kARGBToY), // %3 |
| 245 | "m"(kAddY16) // %4 |
| 246 | : "memory", "cc" |
| 247 | #if defined(__SSE2__) |
| 248 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 249 | #endif |
| 250 | |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 251 | ); |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 252 | } |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 253 | #endif |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 254 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 255 | #ifdef HAS_ARGBTOUVROW_SSSE3 |
| 256 | void ARGBToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb, |
| 257 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 258 | asm volatile ( |
| 259 | "movdqa %0,%%xmm4 \n" |
| 260 | "movdqa %1,%%xmm3 \n" |
| 261 | "movdqa %2,%%xmm5 \n" |
fbarchard@google.com | d93d448 | 2011-11-10 18:26:20 +0000 | [diff] [blame] | 262 | : |
| 263 | : "m"(kARGBToU), // %0 |
| 264 | "m"(kARGBToV), // %1 |
| 265 | "m"(kAddUV128) // %2 |
| 266 | : |
| 267 | #if defined(__SSE2__) |
| 268 | "xmm3", "xmm4", "xmm5" |
| 269 | #endif |
| 270 | ); |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 271 | asm volatile ( |
| 272 | "sub %1,%2 \n" |
| 273 | "1: \n" |
| 274 | "movdqa (%0),%%xmm0 \n" |
| 275 | "movdqa 0x10(%0),%%xmm1 \n" |
| 276 | "movdqa 0x20(%0),%%xmm2 \n" |
| 277 | "movdqa 0x30(%0),%%xmm6 \n" |
| 278 | "pavgb (%0,%4,1),%%xmm0 \n" |
| 279 | "pavgb 0x10(%0,%4,1),%%xmm1 \n" |
| 280 | "pavgb 0x20(%0,%4,1),%%xmm2 \n" |
| 281 | "pavgb 0x30(%0,%4,1),%%xmm6 \n" |
| 282 | "lea 0x40(%0),%0 \n" |
| 283 | "movdqa %%xmm0,%%xmm7 \n" |
| 284 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 285 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 286 | "pavgb %%xmm7,%%xmm0 \n" |
| 287 | "movdqa %%xmm2,%%xmm7 \n" |
| 288 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 289 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 290 | "pavgb %%xmm7,%%xmm2 \n" |
| 291 | "movdqa %%xmm0,%%xmm1 \n" |
| 292 | "movdqa %%xmm2,%%xmm6 \n" |
| 293 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 294 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 295 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 296 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 297 | "phaddw %%xmm2,%%xmm0 \n" |
| 298 | "phaddw %%xmm6,%%xmm1 \n" |
| 299 | "psraw $0x8,%%xmm0 \n" |
| 300 | "psraw $0x8,%%xmm1 \n" |
| 301 | "packsswb %%xmm1,%%xmm0 \n" |
| 302 | "paddb %%xmm5,%%xmm0 \n" |
| 303 | "movlps %%xmm0,(%1) \n" |
| 304 | "movhps %%xmm0,(%1,%2,1) \n" |
| 305 | "lea 0x8(%1),%1 \n" |
| 306 | "sub $0x10,%3 \n" |
| 307 | "ja 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 308 | : "+r"(src_argb0), // %0 |
| 309 | "+r"(dst_u), // %1 |
| 310 | "+r"(dst_v), // %2 |
| 311 | "+rm"(width) // %3 |
fbarchard@google.com | d93d448 | 2011-11-10 18:26:20 +0000 | [diff] [blame] | 312 | : "r"(static_cast<intptr_t>(src_stride_argb)) |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 313 | : "memory", "cc" |
| 314 | #if defined(__SSE2__) |
fbarchard@google.com | d93d448 | 2011-11-10 18:26:20 +0000 | [diff] [blame] | 315 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 316 | #endif |
| 317 | ); |
| 318 | } |
| 319 | #endif |
| 320 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 321 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 322 | #ifdef HAS_FASTCONVERTYUVTOARGBROW_SSSE3 |
| 323 | #define UB 127 /* min(63,static_cast<int8>(2.018 * 64)) */ |
| 324 | #define UG -25 /* static_cast<int8>(-0.391 * 64 - 0.5) */ |
| 325 | #define UR 0 |
| 326 | |
| 327 | #define VB 0 |
| 328 | #define VG -52 /* static_cast<int8>(-0.813 * 64 - 0.5) */ |
| 329 | #define VR 102 /* static_cast<int8>(1.596 * 64 + 0.5) */ |
| 330 | |
| 331 | // Bias |
| 332 | #define BB UB * 128 + VB * 128 |
| 333 | #define BG UG * 128 + VG * 128 |
| 334 | #define BR UR * 128 + VR * 128 |
| 335 | |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 336 | #define YG 74 /* static_cast<int8>(1.164 * 64 + 0.5) */ |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 337 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 338 | #if defined(__APPLE__) || defined(__x86_64__) |
| 339 | #define OMITFP |
| 340 | #else |
| 341 | #define OMITFP __attribute__((optimize("omit-frame-pointer"))) |
| 342 | #endif |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 343 | |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 344 | struct { |
| 345 | vec8 kUVToB; |
| 346 | vec8 kUVToG; |
| 347 | vec8 kUVToR; |
| 348 | vec16 kUVBiasB; |
| 349 | vec16 kUVBiasG; |
| 350 | vec16 kUVBiasR; |
| 351 | vec16 kYSub16; |
| 352 | vec16 kYToRgb; |
| 353 | } SIMD_ALIGNED(kYuvConstants) = { |
| 354 | { UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB }, |
| 355 | { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG }, |
| 356 | { UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR }, |
| 357 | { BB, BB, BB, BB, BB, BB, BB, BB }, |
| 358 | { BG, BG, BG, BG, BG, BG, BG, BG }, |
| 359 | { BR, BR, BR, BR, BR, BR, BR, BR }, |
| 360 | { 16, 16, 16, 16, 16, 16, 16, 16 }, |
| 361 | { YG, YG, YG, YG, YG, YG, YG, YG } |
| 362 | }; |
| 363 | |
| 364 | // Convert 8 pixels |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 365 | #define YUVTORGB \ |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 366 | "movd (%1),%%xmm0 \n" \ |
| 367 | "movd (%1,%2,1),%%xmm1 \n" \ |
| 368 | "lea 0x4(%1),%1 \n" \ |
| 369 | "punpcklbw %%xmm1,%%xmm0 \n" \ |
| 370 | "punpcklwd %%xmm0,%%xmm0 \n" \ |
| 371 | "movdqa %%xmm0,%%xmm1 \n" \ |
| 372 | "movdqa %%xmm0,%%xmm2 \n" \ |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 373 | "pmaddubsw (%5),%%xmm0 \n" \ |
| 374 | "pmaddubsw 16(%5),%%xmm1 \n" \ |
| 375 | "pmaddubsw 32(%5),%%xmm2 \n" \ |
| 376 | "psubw 48(%5),%%xmm0 \n" \ |
| 377 | "psubw 64(%5),%%xmm1 \n" \ |
| 378 | "psubw 80(%5),%%xmm2 \n" \ |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 379 | "movq (%0),%%xmm3 \n" \ |
| 380 | "lea 0x8(%0),%0 \n" \ |
| 381 | "punpcklbw %%xmm4,%%xmm3 \n" \ |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 382 | "psubsw 96(%5),%%xmm3 \n" \ |
| 383 | "pmullw 112(%5),%%xmm3 \n" \ |
fbarchard@google.com | bc8f28e | 2011-11-18 21:03:54 +0000 | [diff] [blame] | 384 | "paddsw %%xmm3,%%xmm0 \n" \ |
| 385 | "paddsw %%xmm3,%%xmm1 \n" \ |
| 386 | "paddsw %%xmm3,%%xmm2 \n" \ |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 387 | "psraw $0x6,%%xmm0 \n" \ |
| 388 | "psraw $0x6,%%xmm1 \n" \ |
| 389 | "psraw $0x6,%%xmm2 \n" \ |
| 390 | "packuswb %%xmm0,%%xmm0 \n" \ |
| 391 | "packuswb %%xmm1,%%xmm1 \n" \ |
| 392 | "packuswb %%xmm2,%%xmm2 \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 393 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 394 | void OMITFP FastConvertYUVToARGBRow_SSSE3(const uint8* y_buf, // rdi |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 395 | const uint8* u_buf, // rsi |
| 396 | const uint8* v_buf, // rdx |
| 397 | uint8* rgb_buf, // rcx |
| 398 | int width) { // r8 |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 399 | asm volatile ( |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 400 | "sub %1,%2 \n" |
| 401 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 402 | "pxor %%xmm4,%%xmm4 \n" |
mikhal@webrtc.org | 43575c8 | 2011-10-12 18:49:21 +0000 | [diff] [blame] | 403 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 404 | "1: \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 405 | YUVTORGB |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 406 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 407 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 408 | "movdqa %%xmm0,%%xmm1 \n" |
| 409 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 410 | "movdqa %%xmm0,(%3) \n" |
| 411 | "punpckhwd %%xmm2,%%xmm1 \n" |
| 412 | "movdqa %%xmm1,0x10(%3) \n" |
| 413 | "lea 0x20(%3),%3 \n" |
| 414 | "sub $0x8,%4 \n" |
| 415 | "ja 1b \n" |
fbarchard@google.com | 3faa0f1 | 2011-10-20 06:04:16 +0000 | [diff] [blame] | 416 | : "+r"(y_buf), // %0 |
| 417 | "+r"(u_buf), // %1 |
| 418 | "+r"(v_buf), // %2 |
| 419 | "+r"(rgb_buf), // %3 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 420 | "+rm"(width) // %4 |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 421 | : "r"(&kYuvConstants.kUVToB) // %5 |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 422 | : "memory", "cc" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 423 | #if defined(__SSE2__) |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 424 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 425 | #endif |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 426 | ); |
mikhal@webrtc.org | 43575c8 | 2011-10-12 18:49:21 +0000 | [diff] [blame] | 427 | } |
| 428 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 429 | void OMITFP FastConvertYUVToBGRARow_SSSE3(const uint8* y_buf, // rdi |
| 430 | const uint8* u_buf, // rsi |
| 431 | const uint8* v_buf, // rdx |
| 432 | uint8* rgb_buf, // rcx |
| 433 | int width) { // r8 |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 434 | asm volatile ( |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 435 | "sub %1,%2 \n" |
| 436 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 437 | "pxor %%xmm4,%%xmm4 \n" |
| 438 | |
| 439 | "1: \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 440 | YUVTORGB |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 441 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 442 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 443 | "punpcklbw %%xmm2,%%xmm5 \n" |
| 444 | "movdqa %%xmm5,%%xmm0 \n" |
| 445 | "punpcklwd %%xmm1,%%xmm5 \n" |
| 446 | "movdqa %%xmm5,(%3) \n" |
| 447 | "punpckhwd %%xmm1,%%xmm0 \n" |
| 448 | "movdqa %%xmm0,0x10(%3) \n" |
| 449 | "lea 0x20(%3),%3 \n" |
| 450 | "sub $0x8,%4 \n" |
| 451 | "ja 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 452 | : "+r"(y_buf), // %0 |
| 453 | "+r"(u_buf), // %1 |
| 454 | "+r"(v_buf), // %2 |
| 455 | "+r"(rgb_buf), // %3 |
| 456 | "+rm"(width) // %4 |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 457 | : "r"(&kYuvConstants.kUVToB) // %5 |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 458 | : "memory", "cc" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 459 | #if defined(__SSE2__) |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 460 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 461 | #endif |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 462 | ); |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 463 | } |
| 464 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 465 | void OMITFP FastConvertYUVToABGRRow_SSSE3(const uint8* y_buf, // rdi |
| 466 | const uint8* u_buf, // rsi |
| 467 | const uint8* v_buf, // rdx |
| 468 | uint8* rgb_buf, // rcx |
| 469 | int width) { // r8 |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 470 | asm volatile ( |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 471 | "sub %1,%2 \n" |
| 472 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 473 | "pxor %%xmm4,%%xmm4 \n" |
| 474 | |
| 475 | "1: \n" |
| 476 | YUVTORGB |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 477 | "punpcklbw %%xmm1,%%xmm2 \n" |
| 478 | "punpcklbw %%xmm5,%%xmm0 \n" |
| 479 | "movdqa %%xmm2,%%xmm1 \n" |
| 480 | "punpcklwd %%xmm0,%%xmm2 \n" |
| 481 | "movdqa %%xmm2,(%3) \n" |
| 482 | "punpckhwd %%xmm0,%%xmm1 \n" |
| 483 | "movdqa %%xmm1,0x10(%3) \n" |
| 484 | "lea 0x20(%3),%3 \n" |
| 485 | "sub $0x8,%4 \n" |
| 486 | "ja 1b \n" |
fbarchard@google.com | 3faa0f1 | 2011-10-20 06:04:16 +0000 | [diff] [blame] | 487 | : "+r"(y_buf), // %0 |
| 488 | "+r"(u_buf), // %1 |
| 489 | "+r"(v_buf), // %2 |
| 490 | "+r"(rgb_buf), // %3 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 491 | "+rm"(width) // %4 |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 492 | : "r"(&kYuvConstants.kUVToB) // %5 |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 493 | : "memory", "cc" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 494 | #if defined(__SSE2__) |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 495 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 496 | #endif |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 497 | ); |
mikhal@webrtc.org | 120d5e7 | 2011-10-07 17:57:17 +0000 | [diff] [blame] | 498 | } |
| 499 | |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 500 | void OMITFP FastConvertYUV444ToARGBRow_SSSE3(const uint8* y_buf, // rdi |
| 501 | const uint8* u_buf, // rsi |
| 502 | const uint8* v_buf, // rdx |
| 503 | uint8* rgb_buf, // rcx |
| 504 | int width) { // r8 |
| 505 | asm volatile ( |
| 506 | "sub %1,%2 \n" |
| 507 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 508 | "pxor %%xmm4,%%xmm4 \n" |
| 509 | |
| 510 | "1: \n" |
| 511 | "movd (%1),%%xmm0 \n" |
| 512 | "movd (%1,%2,1),%%xmm1 \n" |
| 513 | "lea 0x4(%1),%1 \n" |
| 514 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 515 | "movdqa %%xmm0,%%xmm1 \n" |
| 516 | "movdqa %%xmm0,%%xmm2 \n" |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 517 | "pmaddubsw (%5),%%xmm0 \n" |
| 518 | "pmaddubsw 16(%5),%%xmm1 \n" |
| 519 | "pmaddubsw 32(%5),%%xmm2 \n" |
| 520 | "psubw 48(%5),%%xmm0 \n" |
| 521 | "psubw 64(%5),%%xmm1 \n" |
| 522 | "psubw 80(%5),%%xmm2 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 523 | "movd (%0),%%xmm3 \n" |
| 524 | "lea 0x4(%0),%0 \n" |
| 525 | "punpcklbw %%xmm4,%%xmm3 \n" |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 526 | "psubsw 96(%5),%%xmm3 \n" |
| 527 | "pmullw 112(%5),%%xmm3 \n" |
fbarchard@google.com | bc8f28e | 2011-11-18 21:03:54 +0000 | [diff] [blame] | 528 | "paddsw %%xmm3,%%xmm0 \n" |
| 529 | "paddsw %%xmm3,%%xmm1 \n" |
| 530 | "paddsw %%xmm3,%%xmm2 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 531 | "psraw $0x6,%%xmm0 \n" |
| 532 | "psraw $0x6,%%xmm1 \n" |
| 533 | "psraw $0x6,%%xmm2 \n" |
| 534 | "packuswb %%xmm0,%%xmm0 \n" |
| 535 | "packuswb %%xmm1,%%xmm1 \n" |
| 536 | "packuswb %%xmm2,%%xmm2 \n" |
| 537 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 538 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 539 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 540 | "movdqa %%xmm0,(%3) \n" |
| 541 | "lea 0x10(%3),%3 \n" |
| 542 | "sub $0x4,%4 \n" |
| 543 | "ja 1b \n" |
| 544 | : "+r"(y_buf), // %0 |
| 545 | "+r"(u_buf), // %1 |
| 546 | "+r"(v_buf), // %2 |
| 547 | "+r"(rgb_buf), // %3 |
| 548 | "+rm"(width) // %4 |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 549 | : "r"(&kYuvConstants.kUVToB) // %5 |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 550 | : "memory", "cc" |
| 551 | #if defined(__SSE2__) |
| 552 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 553 | #endif |
| 554 | ); |
| 555 | } |
| 556 | #endif |
| 557 | |
| 558 | #ifdef HAS_FASTCONVERTYTOARGBROW_SSE2 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 559 | void FastConvertYToARGBRow_SSE2(const uint8* y_buf, // rdi |
| 560 | uint8* rgb_buf, // rcx |
| 561 | int width) { // r8 |
fbarchard@google.com | f7a5048 | 2011-11-10 22:41:20 +0000 | [diff] [blame] | 562 | asm volatile ( |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 563 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 564 | "pslld $0x18,%%xmm5 \n" |
| 565 | "pxor %%xmm4,%%xmm4 \n" |
| 566 | "movdqa %3,%%xmm3 \n" |
| 567 | "movdqa %4,%%xmm2 \n" |
| 568 | |
| 569 | "1: \n" |
| 570 | // Step 1: Scale Y contribution to 8 G values. G = (y - 16) * 1.164 |
| 571 | "movq (%0),%%xmm0 \n" |
| 572 | "lea 0x8(%0),%0 \n" |
| 573 | "punpcklbw %%xmm4,%%xmm0 \n" |
| 574 | "psubsw %%xmm3,%%xmm0 \n" |
| 575 | "pmullw %%xmm2,%%xmm0 \n" |
| 576 | "psraw $0x6,%%xmm0 \n" |
| 577 | "packuswb %%xmm0,%%xmm0 \n" |
| 578 | |
| 579 | // Step 2: Weave into ARGB |
| 580 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 581 | "movdqa %%xmm0,%%xmm1 \n" |
| 582 | "punpcklwd %%xmm0,%%xmm0 \n" |
| 583 | "por %%xmm5,%%xmm0 \n" |
| 584 | "movdqa %%xmm0,(%1) \n" |
| 585 | "punpckhwd %%xmm1,%%xmm1 \n" |
| 586 | "por %%xmm5,%%xmm1 \n" |
| 587 | "movdqa %%xmm1,16(%1) \n" |
| 588 | "lea 32(%1),%1 \n" |
| 589 | |
| 590 | "sub $0x8,%2 \n" |
| 591 | "ja 1b \n" |
fbarchard@google.com | 3faa0f1 | 2011-10-20 06:04:16 +0000 | [diff] [blame] | 592 | : "+r"(y_buf), // %0 |
| 593 | "+r"(rgb_buf), // %1 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 594 | "+rm"(width) // %2 |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 595 | : "m"(kYuvConstants.kYSub16), // %3 |
| 596 | "m"(kYuvConstants.kYToRgb) // %4 |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 597 | : "memory", "cc" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 598 | #if defined(__SSE2__) |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 599 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 600 | #endif |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 601 | ); |
mikhal@webrtc.org | 120d5e7 | 2011-10-07 17:57:17 +0000 | [diff] [blame] | 602 | } |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 603 | #endif |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 604 | |
frkoenig@google.com | e518542 | 2011-11-07 23:07:57 +0000 | [diff] [blame] | 605 | #ifdef HAS_ARGBTOYROW_SSSE3 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 606 | void ABGRToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix) { |
| 607 | SIMD_ALIGNED(uint8 row[kMaxStride]); |
| 608 | ABGRToARGBRow_SSSE3(src_argb, row, pix); |
| 609 | ARGBToYRow_SSSE3(row, dst_y, pix); |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 610 | } |
| 611 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 612 | void BGRAToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix) { |
| 613 | SIMD_ALIGNED(uint8 row[kMaxStride]); |
| 614 | BGRAToARGBRow_SSSE3(src_argb, row, pix); |
| 615 | ARGBToYRow_SSSE3(row, dst_y, pix); |
mikhal@webrtc.org | 43575c8 | 2011-10-12 18:49:21 +0000 | [diff] [blame] | 616 | } |
frkoenig@google.com | e518542 | 2011-11-07 23:07:57 +0000 | [diff] [blame] | 617 | #endif |
mikhal@webrtc.org | 43575c8 | 2011-10-12 18:49:21 +0000 | [diff] [blame] | 618 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 619 | #ifdef HAS_ARGBTOUVROW_SSSE3 |
| 620 | void ABGRToUVRow_SSSE3(const uint8* src_argb, int src_stride_argb, |
| 621 | uint8* dst_u, uint8* dst_v, int pix) { |
| 622 | SIMD_ALIGNED(uint8 row[kMaxStride * 2]); |
| 623 | ABGRToARGBRow_SSSE3(src_argb, row, pix); |
| 624 | ABGRToARGBRow_SSSE3(src_argb + src_stride_argb, row + kMaxStride, pix); |
| 625 | ARGBToUVRow_SSSE3(row, kMaxStride, dst_u, dst_v, pix); |
mikhal@webrtc.org | 43575c8 | 2011-10-12 18:49:21 +0000 | [diff] [blame] | 626 | } |
| 627 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 628 | void BGRAToUVRow_SSSE3(const uint8* src_argb, int src_stride_argb, |
| 629 | uint8* dst_u, uint8* dst_v, int pix) { |
| 630 | SIMD_ALIGNED(uint8 row[kMaxStride * 2]); |
| 631 | BGRAToARGBRow_SSSE3(src_argb, row, pix); |
| 632 | BGRAToARGBRow_SSSE3(src_argb + src_stride_argb, row + kMaxStride, pix); |
| 633 | ARGBToUVRow_SSSE3(row, kMaxStride, dst_u, dst_v, pix); |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 634 | } |
mikhal@webrtc.org | 120d5e7 | 2011-10-07 17:57:17 +0000 | [diff] [blame] | 635 | #endif |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 636 | |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame^] | 637 | #ifdef HAS_REVERSE_ROW_SSSE3 |
| 638 | |
| 639 | // Shuffle table for reversing the bytes. |
| 640 | static const uvec8 kShuffleReverse = { |
| 641 | 15u, 14u, 13u, 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u |
| 642 | }; |
| 643 | |
| 644 | void ReverseRow_SSSE3(const uint8* src, uint8* dst, int width) { |
| 645 | intptr_t temp_width = static_cast<intptr_t>(width); |
| 646 | asm volatile ( |
| 647 | "movdqa %3,%%xmm5 \n" |
| 648 | "lea -0x10(%0,%2,1),%0 \n" |
| 649 | "1: \n" |
| 650 | "movdqa (%0),%%xmm0 \n" |
| 651 | "lea -0x10(%0),%0 \n" |
| 652 | "pshufb %%xmm5,%%xmm0 \n" |
| 653 | "movdqa %%xmm0,(%1) \n" |
| 654 | "lea 0x10(%1),%1 \n" |
| 655 | "sub $0x10,%2 \n" |
| 656 | "ja 1b \n" |
| 657 | : "+r"(src), // %0 |
| 658 | "+r"(dst), // %1 |
| 659 | "+r"(temp_width) // %2 |
| 660 | : "m"(kShuffleReverse) // %3 |
| 661 | : "memory", "cc" |
| 662 | #if defined(__SSE2__) |
| 663 | , "xmm0", "xmm5" |
| 664 | #endif |
| 665 | ); |
| 666 | } |
| 667 | #endif |
| 668 | |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 669 | } // extern "C" |