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