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 | |
fbarchard@google.com | 2b9c210 | 2012-03-22 22:36:44 +0000 | [diff] [blame] | 11 | #include "source/row.h" |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 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 | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 20 | // This module is for GCC x86 and x64 |
| 21 | #if (defined(__x86_64__) || defined(__i386__)) && !defined(YUV_DISABLE_ASM) |
| 22 | |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 23 | // GCC 4.2 on OSX has link error when passing static or const to inline. |
| 24 | // TODO(fbarchard): Use static const when gcc 4.2 support is dropped. |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 25 | #ifdef __APPLE__ |
| 26 | #define CONST |
| 27 | #else |
| 28 | #define CONST static const |
| 29 | #endif |
| 30 | |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 31 | #ifdef HAS_ARGBTOYROW_SSSE3 |
| 32 | |
| 33 | // Constants for ARGB |
| 34 | CONST vec8 kARGBToY = { |
| 35 | 13, 65, 33, 0, 13, 65, 33, 0, 13, 65, 33, 0, 13, 65, 33, 0 |
| 36 | }; |
| 37 | |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 38 | CONST vec8 kARGBToU = { |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 39 | 112, -74, -38, 0, 112, -74, -38, 0, 112, -74, -38, 0, 112, -74, -38, 0 |
| 40 | }; |
| 41 | |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 42 | CONST vec8 kARGBToV = { |
| 43 | -18, -94, 112, 0, -18, -94, 112, 0, -18, -94, 112, 0, -18, -94, 112, 0, |
| 44 | }; |
| 45 | |
| 46 | // Constants for BGRA |
| 47 | CONST vec8 kBGRAToY = { |
| 48 | 0, 33, 65, 13, 0, 33, 65, 13, 0, 33, 65, 13, 0, 33, 65, 13 |
| 49 | }; |
| 50 | |
| 51 | CONST vec8 kBGRAToU = { |
| 52 | 0, -38, -74, 112, 0, -38, -74, 112, 0, -38, -74, 112, 0, -38, -74, 112 |
| 53 | }; |
| 54 | |
| 55 | CONST vec8 kBGRAToV = { |
| 56 | 0, 112, -94, -18, 0, 112, -94, -18, 0, 112, -94, -18, 0, 112, -94, -18 |
| 57 | }; |
| 58 | |
| 59 | // Constants for ABGR |
| 60 | CONST vec8 kABGRToY = { |
| 61 | 33, 65, 13, 0, 33, 65, 13, 0, 33, 65, 13, 0, 33, 65, 13, 0 |
| 62 | }; |
| 63 | |
| 64 | CONST vec8 kABGRToU = { |
| 65 | -38, -74, 112, 0, -38, -74, 112, 0, -38, -74, 112, 0, -38, -74, 112, 0 |
| 66 | }; |
| 67 | |
| 68 | CONST vec8 kABGRToV = { |
| 69 | 112, -94, -18, 0, 112, -94, -18, 0, 112, -94, -18, 0, 112, -94, -18, 0 |
| 70 | }; |
| 71 | |
| 72 | CONST uvec8 kAddY16 = { |
| 73 | 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u, 16u |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 74 | }; |
fbarchard@google.com | 2430e04 | 2011-11-11 21:57:06 +0000 | [diff] [blame] | 75 | |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 76 | CONST uvec8 kAddUV128 = { |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 77 | 128u, 128u, 128u, 128u, 128u, 128u, 128u, 128u, |
| 78 | 128u, 128u, 128u, 128u, 128u, 128u, 128u, 128u |
| 79 | }; |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 80 | |
fbarchard@google.com | ba1f526 | 2012-01-12 19:22:41 +0000 | [diff] [blame] | 81 | // Shuffle table for converting RGB24 to ARGB. |
| 82 | CONST uvec8 kShuffleMaskRGB24ToARGB = { |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 83 | 0u, 1u, 2u, 12u, 3u, 4u, 5u, 13u, 6u, 7u, 8u, 14u, 9u, 10u, 11u, 15u |
| 84 | }; |
| 85 | |
| 86 | // Shuffle table for converting RAW to ARGB. |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 87 | CONST uvec8 kShuffleMaskRAWToARGB = { |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 88 | 2u, 1u, 0u, 12u, 5u, 4u, 3u, 13u, 8u, 7u, 6u, 14u, 11u, 10u, 9u, 15u |
| 89 | }; |
| 90 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 91 | // Shuffle table for converting ABGR to ARGB. |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 92 | CONST uvec8 kShuffleMaskABGRToARGB = { |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 93 | 2u, 1u, 0u, 3u, 6u, 5u, 4u, 7u, 10u, 9u, 8u, 11u, 14u, 13u, 12u, 15u |
| 94 | }; |
| 95 | |
| 96 | // Shuffle table for converting BGRA to ARGB. |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 97 | CONST uvec8 kShuffleMaskBGRAToARGB = { |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 98 | 3u, 2u, 1u, 0u, 7u, 6u, 5u, 4u, 11u, 10u, 9u, 8u, 15u, 14u, 13u, 12u |
| 99 | }; |
| 100 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 101 | // Shuffle table for converting ARGB to RGB24. |
| 102 | CONST uvec8 kShuffleMaskARGBToRGB24 = { |
| 103 | 0u, 1u, 2u, 4u, 5u, 6u, 8u, 9u, 10u, 12u, 13u, 14u, 128u, 128u, 128u, 128u |
| 104 | }; |
| 105 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 106 | // Shuffle table for converting ARGB to RAW. |
| 107 | CONST uvec8 kShuffleMaskARGBToRAW = { |
fbarchard@google.com | f3fb7b6 | 2012-03-29 23:19:34 +0000 | [diff] [blame^] | 108 | 2u, 1u, 0u, 6u, 5u, 4u, 10u, 9u, 8u, 14u, 13u, 12u, 128u, 128u, 128u, 128u |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 109 | }; |
| 110 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 111 | void I400ToARGBRow_SSE2(const uint8* src_y, uint8* dst_argb, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 112 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 113 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 114 | "pslld $0x18,%%xmm5 \n" |
| 115 | "1: \n" |
| 116 | "movq (%0),%%xmm0 \n" |
| 117 | "lea 0x8(%0),%0 \n" |
| 118 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 119 | "movdqa %%xmm0,%%xmm1 \n" |
| 120 | "punpcklwd %%xmm0,%%xmm0 \n" |
| 121 | "punpckhwd %%xmm1,%%xmm1 \n" |
| 122 | "por %%xmm5,%%xmm0 \n" |
| 123 | "por %%xmm5,%%xmm1 \n" |
| 124 | "movdqa %%xmm0,(%1) \n" |
| 125 | "movdqa %%xmm1,0x10(%1) \n" |
| 126 | "lea 0x20(%1),%1 \n" |
| 127 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 128 | "jg 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 129 | : "+r"(src_y), // %0 |
| 130 | "+r"(dst_argb), // %1 |
| 131 | "+r"(pix) // %2 |
| 132 | : |
| 133 | : "memory", "cc" |
| 134 | #if defined(__SSE2__) |
| 135 | , "xmm0", "xmm1", "xmm5" |
| 136 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 137 | ); |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 138 | } |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 139 | |
| 140 | void ABGRToARGBRow_SSSE3(const uint8* src_abgr, uint8* dst_argb, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 141 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 142 | "movdqa %3,%%xmm5 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 143 | "sub %0,%1 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 144 | "1: \n" |
| 145 | "movdqa (%0),%%xmm0 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 146 | "pshufb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 147 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 148 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 149 | "lea 0x10(%0),%0 \n" |
| 150 | "jg 1b \n" |
| 151 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 152 | : "+r"(src_abgr), // %0 |
| 153 | "+r"(dst_argb), // %1 |
| 154 | "+r"(pix) // %2 |
| 155 | : "m"(kShuffleMaskABGRToARGB) // %3 |
| 156 | : "memory", "cc" |
| 157 | #if defined(__SSE2__) |
| 158 | , "xmm0", "xmm5" |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 159 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 160 | ); |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | void BGRAToARGBRow_SSSE3(const uint8* src_bgra, uint8* dst_argb, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 164 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 165 | "movdqa %3,%%xmm5 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 166 | "sub %0,%1 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 167 | "1: \n" |
| 168 | "movdqa (%0),%%xmm0 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 169 | "pshufb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 170 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 171 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 172 | "lea 0x10(%0),%0 \n" |
| 173 | "jg 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 174 | : "+r"(src_bgra), // %0 |
| 175 | "+r"(dst_argb), // %1 |
| 176 | "+r"(pix) // %2 |
| 177 | : "m"(kShuffleMaskBGRAToARGB) // %3 |
| 178 | : "memory", "cc" |
| 179 | #if defined(__SSE2__) |
| 180 | , "xmm0", "xmm5" |
| 181 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 182 | ); |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 183 | } |
| 184 | |
fbarchard@google.com | ba1f526 | 2012-01-12 19:22:41 +0000 | [diff] [blame] | 185 | void RGB24ToARGBRow_SSSE3(const uint8* src_rgb24, uint8* dst_argb, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 186 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 187 | "pcmpeqb %%xmm5,%%xmm5 \n" // generate mask 0xff000000 |
| 188 | "pslld $0x18,%%xmm5 \n" |
| 189 | "movdqa %3,%%xmm4 \n" |
| 190 | "1: \n" |
| 191 | "movdqu (%0),%%xmm0 \n" |
| 192 | "movdqu 0x10(%0),%%xmm1 \n" |
| 193 | "movdqu 0x20(%0),%%xmm3 \n" |
| 194 | "lea 0x30(%0),%0 \n" |
| 195 | "movdqa %%xmm3,%%xmm2 \n" |
| 196 | "palignr $0x8,%%xmm1,%%xmm2 \n" |
| 197 | "pshufb %%xmm4,%%xmm2 \n" |
| 198 | "por %%xmm5,%%xmm2 \n" |
| 199 | "palignr $0xc,%%xmm0,%%xmm1 \n" |
| 200 | "pshufb %%xmm4,%%xmm0 \n" |
| 201 | "movdqa %%xmm2,0x20(%1) \n" |
| 202 | "por %%xmm5,%%xmm0 \n" |
| 203 | "pshufb %%xmm4,%%xmm1 \n" |
| 204 | "movdqa %%xmm0,(%1) \n" |
| 205 | "por %%xmm5,%%xmm1 \n" |
| 206 | "palignr $0x4,%%xmm3,%%xmm3 \n" |
| 207 | "pshufb %%xmm4,%%xmm3 \n" |
| 208 | "movdqa %%xmm1,0x10(%1) \n" |
| 209 | "por %%xmm5,%%xmm3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 210 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 211 | "movdqa %%xmm3,0x30(%1) \n" |
| 212 | "lea 0x40(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 213 | "jg 1b \n" |
fbarchard@google.com | ba1f526 | 2012-01-12 19:22:41 +0000 | [diff] [blame] | 214 | : "+r"(src_rgb24), // %0 |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 215 | "+r"(dst_argb), // %1 |
| 216 | "+r"(pix) // %2 |
fbarchard@google.com | ba1f526 | 2012-01-12 19:22:41 +0000 | [diff] [blame] | 217 | : "m"(kShuffleMaskRGB24ToARGB) // %3 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 218 | : "memory", "cc" |
| 219 | #if defined(__SSE2__) |
| 220 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 221 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 222 | ); |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 223 | } |
| 224 | |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 225 | void RAWToARGBRow_SSSE3(const uint8* src_raw, uint8* dst_argb, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 226 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 227 | "pcmpeqb %%xmm5,%%xmm5 \n" // generate mask 0xff000000 |
| 228 | "pslld $0x18,%%xmm5 \n" |
| 229 | "movdqa %3,%%xmm4 \n" |
| 230 | "1: \n" |
| 231 | "movdqu (%0),%%xmm0 \n" |
| 232 | "movdqu 0x10(%0),%%xmm1 \n" |
| 233 | "movdqu 0x20(%0),%%xmm3 \n" |
| 234 | "lea 0x30(%0),%0 \n" |
| 235 | "movdqa %%xmm3,%%xmm2 \n" |
| 236 | "palignr $0x8,%%xmm1,%%xmm2 \n" |
| 237 | "pshufb %%xmm4,%%xmm2 \n" |
| 238 | "por %%xmm5,%%xmm2 \n" |
| 239 | "palignr $0xc,%%xmm0,%%xmm1 \n" |
| 240 | "pshufb %%xmm4,%%xmm0 \n" |
| 241 | "movdqa %%xmm2,0x20(%1) \n" |
| 242 | "por %%xmm5,%%xmm0 \n" |
| 243 | "pshufb %%xmm4,%%xmm1 \n" |
| 244 | "movdqa %%xmm0,(%1) \n" |
| 245 | "por %%xmm5,%%xmm1 \n" |
| 246 | "palignr $0x4,%%xmm3,%%xmm3 \n" |
| 247 | "pshufb %%xmm4,%%xmm3 \n" |
| 248 | "movdqa %%xmm1,0x10(%1) \n" |
| 249 | "por %%xmm5,%%xmm3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 250 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 251 | "movdqa %%xmm3,0x30(%1) \n" |
| 252 | "lea 0x40(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 253 | "jg 1b \n" |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 254 | : "+r"(src_raw), // %0 |
| 255 | "+r"(dst_argb), // %1 |
| 256 | "+r"(pix) // %2 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 257 | : "m"(kShuffleMaskRAWToARGB) // %3 |
| 258 | : "memory", "cc" |
| 259 | #if defined(__SSE2__) |
| 260 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 261 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 262 | ); |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 263 | } |
| 264 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 265 | void RGB565ToARGBRow_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 266 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 267 | "mov $0x1080108,%%eax \n" |
| 268 | "movd %%eax,%%xmm5 \n" |
| 269 | "pshufd $0x0,%%xmm5,%%xmm5 \n" |
| 270 | "mov $0x20082008,%%eax \n" |
| 271 | "movd %%eax,%%xmm6 \n" |
| 272 | "pshufd $0x0,%%xmm6,%%xmm6 \n" |
| 273 | "pcmpeqb %%xmm3,%%xmm3 \n" |
| 274 | "psllw $0xb,%%xmm3 \n" |
| 275 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 276 | "psllw $0xa,%%xmm4 \n" |
| 277 | "psrlw $0x5,%%xmm4 \n" |
| 278 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 279 | "psllw $0x8,%%xmm7 \n" |
| 280 | "sub %0,%1 \n" |
| 281 | "sub %0,%1 \n" |
| 282 | "1: \n" |
| 283 | "movdqu (%0),%%xmm0 \n" |
| 284 | "movdqa %%xmm0,%%xmm1 \n" |
| 285 | "movdqa %%xmm0,%%xmm2 \n" |
| 286 | "pand %%xmm3,%%xmm1 \n" |
| 287 | "psllw $0xb,%%xmm2 \n" |
| 288 | "pmulhuw %%xmm5,%%xmm1 \n" |
| 289 | "pmulhuw %%xmm5,%%xmm2 \n" |
| 290 | "psllw $0x8,%%xmm1 \n" |
| 291 | "por %%xmm2,%%xmm1 \n" |
| 292 | "pand %%xmm4,%%xmm0 \n" |
| 293 | "pmulhuw %%xmm6,%%xmm0 \n" |
| 294 | "por %%xmm7,%%xmm0 \n" |
| 295 | "movdqa %%xmm1,%%xmm2 \n" |
| 296 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 297 | "punpckhbw %%xmm0,%%xmm2 \n" |
| 298 | "movdqa %%xmm1,(%1,%0,2) \n" |
| 299 | "movdqa %%xmm2,0x10(%1,%0,2) \n" |
| 300 | "lea 0x10(%0),%0 \n" |
| 301 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 302 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 303 | : "+r"(src), // %0 |
| 304 | "+r"(dst), // %1 |
| 305 | "+r"(pix) // %2 |
| 306 | : |
| 307 | : "memory", "cc", "eax" |
| 308 | #if defined(__SSE2__) |
| 309 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 310 | #endif |
| 311 | ); |
| 312 | } |
| 313 | |
| 314 | void ARGB1555ToARGBRow_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 315 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 316 | "mov $0x1080108,%%eax \n" |
| 317 | "movd %%eax,%%xmm5 \n" |
| 318 | "pshufd $0x0,%%xmm5,%%xmm5 \n" |
| 319 | "mov $0x42004200,%%eax \n" |
| 320 | "movd %%eax,%%xmm6 \n" |
| 321 | "pshufd $0x0,%%xmm6,%%xmm6 \n" |
| 322 | "pcmpeqb %%xmm3,%%xmm3 \n" |
| 323 | "psllw $0xb,%%xmm3 \n" |
| 324 | "movdqa %%xmm3,%%xmm4 \n" |
| 325 | "psrlw $0x6,%%xmm4 \n" |
| 326 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 327 | "psllw $0x8,%%xmm7 \n" |
| 328 | "sub %0,%1 \n" |
| 329 | "sub %0,%1 \n" |
| 330 | "1: \n" |
| 331 | "movdqu (%0),%%xmm0 \n" |
| 332 | "movdqa %%xmm0,%%xmm1 \n" |
| 333 | "movdqa %%xmm0,%%xmm2 \n" |
| 334 | "psllw $0x1,%%xmm1 \n" |
| 335 | "psllw $0xb,%%xmm2 \n" |
| 336 | "pand %%xmm3,%%xmm1 \n" |
| 337 | "pmulhuw %%xmm5,%%xmm2 \n" |
| 338 | "pmulhuw %%xmm5,%%xmm1 \n" |
| 339 | "psllw $0x8,%%xmm1 \n" |
| 340 | "por %%xmm2,%%xmm1 \n" |
| 341 | "movdqa %%xmm0,%%xmm2 \n" |
| 342 | "pand %%xmm4,%%xmm0 \n" |
| 343 | "psraw $0x8,%%xmm2 \n" |
| 344 | "pmulhuw %%xmm6,%%xmm0 \n" |
| 345 | "pand %%xmm7,%%xmm2 \n" |
| 346 | "por %%xmm2,%%xmm0 \n" |
| 347 | "movdqa %%xmm1,%%xmm2 \n" |
| 348 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 349 | "punpckhbw %%xmm0,%%xmm2 \n" |
| 350 | "movdqa %%xmm1,(%1,%0,2) \n" |
| 351 | "movdqa %%xmm2,0x10(%1,%0,2) \n" |
| 352 | "lea 0x10(%0),%0 \n" |
| 353 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 354 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 355 | : "+r"(src), // %0 |
| 356 | "+r"(dst), // %1 |
| 357 | "+r"(pix) // %2 |
| 358 | : |
| 359 | : "memory", "cc", "eax" |
| 360 | #if defined(__SSE2__) |
| 361 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 362 | #endif |
| 363 | ); |
| 364 | } |
| 365 | |
| 366 | void ARGB4444ToARGBRow_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 367 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 368 | "mov $0xf0f0f0f,%%eax \n" |
| 369 | "movd %%eax,%%xmm4 \n" |
| 370 | "pshufd $0x0,%%xmm4,%%xmm4 \n" |
| 371 | "movdqa %%xmm4,%%xmm5 \n" |
| 372 | "pslld $0x4,%%xmm5 \n" |
| 373 | "sub %0,%1 \n" |
| 374 | "sub %0,%1 \n" |
| 375 | "1: \n" |
| 376 | "movdqu (%0),%%xmm0 \n" |
| 377 | "movdqa %%xmm0,%%xmm2 \n" |
| 378 | "pand %%xmm4,%%xmm0 \n" |
| 379 | "pand %%xmm5,%%xmm2 \n" |
| 380 | "movdqa %%xmm0,%%xmm1 \n" |
| 381 | "movdqa %%xmm2,%%xmm3 \n" |
| 382 | "psllw $0x4,%%xmm1 \n" |
| 383 | "psrlw $0x4,%%xmm3 \n" |
| 384 | "por %%xmm1,%%xmm0 \n" |
| 385 | "por %%xmm3,%%xmm2 \n" |
| 386 | "movdqa %%xmm0,%%xmm1 \n" |
| 387 | "punpcklbw %%xmm2,%%xmm0 \n" |
| 388 | "punpckhbw %%xmm2,%%xmm1 \n" |
| 389 | "movdqa %%xmm0,(%1,%0,2) \n" |
| 390 | "movdqa %%xmm1,0x10(%1,%0,2) \n" |
| 391 | "lea 0x10(%0),%0 \n" |
| 392 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 393 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 394 | : "+r"(src), // %0 |
| 395 | "+r"(dst), // %1 |
| 396 | "+r"(pix) // %2 |
| 397 | : |
| 398 | : "memory", "cc", "eax" |
| 399 | #if defined(__SSE2__) |
| 400 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 401 | #endif |
| 402 | ); |
| 403 | } |
| 404 | |
| 405 | void ARGBToRGB24Row_SSSE3(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 406 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 407 | "movdqa %3,%%xmm6 \n" |
| 408 | "1: \n" |
| 409 | "movdqa (%0),%%xmm0 \n" |
| 410 | "movdqa 0x10(%0),%%xmm1 \n" |
| 411 | "movdqa 0x20(%0),%%xmm2 \n" |
| 412 | "movdqa 0x30(%0),%%xmm3 \n" |
| 413 | "lea 0x40(%0),%0 \n" |
| 414 | "pshufb %%xmm6,%%xmm0 \n" |
| 415 | "pshufb %%xmm6,%%xmm1 \n" |
| 416 | "pshufb %%xmm6,%%xmm2 \n" |
| 417 | "pshufb %%xmm6,%%xmm3 \n" |
| 418 | "movdqa %%xmm1,%%xmm4 \n" |
| 419 | "psrldq $0x4,%%xmm1 \n" |
| 420 | "pslldq $0xc,%%xmm4 \n" |
| 421 | "movdqa %%xmm2,%%xmm5 \n" |
| 422 | "por %%xmm4,%%xmm0 \n" |
| 423 | "pslldq $0x8,%%xmm5 \n" |
| 424 | "movdqa %%xmm0,(%1) \n" |
| 425 | "por %%xmm5,%%xmm1 \n" |
| 426 | "psrldq $0x8,%%xmm2 \n" |
| 427 | "pslldq $0x4,%%xmm3 \n" |
| 428 | "por %%xmm3,%%xmm2 \n" |
| 429 | "movdqa %%xmm1,0x10(%1) \n" |
| 430 | "movdqa %%xmm2,0x20(%1) \n" |
| 431 | "lea 0x30(%1),%1 \n" |
| 432 | "sub $0x10,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 433 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 434 | : "+r"(src), // %0 |
| 435 | "+r"(dst), // %1 |
| 436 | "+r"(pix) // %2 |
| 437 | : "m"(kShuffleMaskARGBToRGB24) // %3 |
| 438 | : "memory", "cc" |
| 439 | #if defined(__SSE2__) |
| 440 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6" |
| 441 | #endif |
| 442 | ); |
| 443 | } |
| 444 | |
| 445 | void ARGBToRAWRow_SSSE3(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 446 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 447 | "movdqa %3,%%xmm6 \n" |
| 448 | "1: \n" |
| 449 | "movdqa (%0),%%xmm0 \n" |
| 450 | "movdqa 0x10(%0),%%xmm1 \n" |
| 451 | "movdqa 0x20(%0),%%xmm2 \n" |
| 452 | "movdqa 0x30(%0),%%xmm3 \n" |
| 453 | "lea 0x40(%0),%0 \n" |
| 454 | "pshufb %%xmm6,%%xmm0 \n" |
| 455 | "pshufb %%xmm6,%%xmm1 \n" |
| 456 | "pshufb %%xmm6,%%xmm2 \n" |
| 457 | "pshufb %%xmm6,%%xmm3 \n" |
| 458 | "movdqa %%xmm1,%%xmm4 \n" |
| 459 | "psrldq $0x4,%%xmm1 \n" |
| 460 | "pslldq $0xc,%%xmm4 \n" |
| 461 | "movdqa %%xmm2,%%xmm5 \n" |
| 462 | "por %%xmm4,%%xmm0 \n" |
| 463 | "pslldq $0x8,%%xmm5 \n" |
| 464 | "movdqa %%xmm0,(%1) \n" |
| 465 | "por %%xmm5,%%xmm1 \n" |
| 466 | "psrldq $0x8,%%xmm2 \n" |
| 467 | "pslldq $0x4,%%xmm3 \n" |
| 468 | "por %%xmm3,%%xmm2 \n" |
| 469 | "movdqa %%xmm1,0x10(%1) \n" |
| 470 | "movdqa %%xmm2,0x20(%1) \n" |
| 471 | "lea 0x30(%1),%1 \n" |
| 472 | "sub $0x10,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 473 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 474 | : "+r"(src), // %0 |
| 475 | "+r"(dst), // %1 |
| 476 | "+r"(pix) // %2 |
| 477 | : "m"(kShuffleMaskARGBToRAW) // %3 |
| 478 | : "memory", "cc" |
| 479 | #if defined(__SSE2__) |
| 480 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6" |
| 481 | #endif |
| 482 | ); |
| 483 | } |
| 484 | |
| 485 | void ARGBToRGB565Row_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 486 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 487 | "pcmpeqb %%xmm3,%%xmm3 \n" |
| 488 | "psrld $0x1b,%%xmm3 \n" |
| 489 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 490 | "psrld $0x1a,%%xmm4 \n" |
| 491 | "pslld $0x5,%%xmm4 \n" |
| 492 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 493 | "pslld $0xb,%%xmm5 \n" |
| 494 | "1: \n" |
| 495 | "movdqa (%0),%%xmm0 \n" |
| 496 | "movdqa %%xmm0,%%xmm1 \n" |
| 497 | "movdqa %%xmm0,%%xmm2 \n" |
| 498 | "pslld $0x8,%%xmm0 \n" |
| 499 | "psrld $0x3,%%xmm1 \n" |
| 500 | "psrld $0x5,%%xmm2 \n" |
| 501 | "psrad $0x10,%%xmm0 \n" |
| 502 | "pand %%xmm3,%%xmm1 \n" |
| 503 | "pand %%xmm4,%%xmm2 \n" |
| 504 | "pand %%xmm5,%%xmm0 \n" |
| 505 | "por %%xmm2,%%xmm1 \n" |
| 506 | "por %%xmm1,%%xmm0 \n" |
| 507 | "packssdw %%xmm0,%%xmm0 \n" |
| 508 | "lea 0x10(%0),%0 \n" |
| 509 | "movq %%xmm0,(%1) \n" |
| 510 | "lea 0x8(%1),%1 \n" |
| 511 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 512 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 513 | : "+r"(src), // %0 |
| 514 | "+r"(dst), // %1 |
| 515 | "+r"(pix) // %2 |
| 516 | : |
| 517 | : "memory", "cc" |
| 518 | #if defined(__SSE2__) |
| 519 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 520 | #endif |
| 521 | ); |
| 522 | } |
| 523 | |
| 524 | void ARGBToARGB1555Row_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 525 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 526 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 527 | "psrld $0x1b,%%xmm4 \n" |
| 528 | "movdqa %%xmm4,%%xmm5 \n" |
| 529 | "pslld $0x5,%%xmm5 \n" |
| 530 | "movdqa %%xmm4,%%xmm6 \n" |
| 531 | "pslld $0xa,%%xmm6 \n" |
| 532 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 533 | "pslld $0xf,%%xmm7 \n" |
| 534 | "1: \n" |
| 535 | "movdqa (%0),%%xmm0 \n" |
| 536 | "movdqa %%xmm0,%%xmm1 \n" |
| 537 | "movdqa %%xmm0,%%xmm2 \n" |
| 538 | "movdqa %%xmm0,%%xmm3 \n" |
| 539 | "psrad $0x10,%%xmm0 \n" |
| 540 | "psrld $0x3,%%xmm1 \n" |
| 541 | "psrld $0x6,%%xmm2 \n" |
| 542 | "psrld $0x9,%%xmm3 \n" |
| 543 | "pand %%xmm7,%%xmm0 \n" |
| 544 | "pand %%xmm4,%%xmm1 \n" |
| 545 | "pand %%xmm5,%%xmm2 \n" |
| 546 | "pand %%xmm6,%%xmm3 \n" |
| 547 | "por %%xmm1,%%xmm0 \n" |
| 548 | "por %%xmm3,%%xmm2 \n" |
| 549 | "por %%xmm2,%%xmm0 \n" |
| 550 | "packssdw %%xmm0,%%xmm0 \n" |
| 551 | "lea 0x10(%0),%0 \n" |
| 552 | "movq %%xmm0,(%1) \n" |
| 553 | "lea 0x8(%1),%1 \n" |
| 554 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 555 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 556 | : "+r"(src), // %0 |
| 557 | "+r"(dst), // %1 |
| 558 | "+r"(pix) // %2 |
| 559 | : |
| 560 | : "memory", "cc" |
| 561 | #if defined(__SSE2__) |
| 562 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 563 | #endif |
| 564 | ); |
| 565 | } |
| 566 | |
| 567 | void ARGBToARGB4444Row_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 568 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 569 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 570 | "psllw $0xc,%%xmm4 \n" |
| 571 | "movdqa %%xmm4,%%xmm3 \n" |
| 572 | "psrlw $0x8,%%xmm3 \n" |
| 573 | "1: \n" |
| 574 | "movdqa (%0),%%xmm0 \n" |
| 575 | "movdqa %%xmm0,%%xmm1 \n" |
| 576 | "pand %%xmm3,%%xmm0 \n" |
| 577 | "pand %%xmm4,%%xmm1 \n" |
| 578 | "psrlq $0x4,%%xmm0 \n" |
| 579 | "psrlq $0x8,%%xmm1 \n" |
| 580 | "por %%xmm1,%%xmm0 \n" |
| 581 | "packuswb %%xmm0,%%xmm0 \n" |
| 582 | "lea 0x10(%0),%0 \n" |
| 583 | "movq %%xmm0,(%1) \n" |
| 584 | "lea 0x8(%1),%1 \n" |
| 585 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 586 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 587 | : "+r"(src), // %0 |
| 588 | "+r"(dst), // %1 |
| 589 | "+r"(pix) // %2 |
| 590 | : |
| 591 | : "memory", "cc" |
| 592 | #if defined(__SSE2__) |
| 593 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" |
| 594 | #endif |
| 595 | ); |
| 596 | } |
| 597 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 598 | void ARGBToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 599 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 600 | "movdqa %4,%%xmm5 \n" |
| 601 | "movdqa %3,%%xmm4 \n" |
| 602 | "1: \n" |
| 603 | "movdqa (%0),%%xmm0 \n" |
| 604 | "movdqa 0x10(%0),%%xmm1 \n" |
| 605 | "movdqa 0x20(%0),%%xmm2 \n" |
| 606 | "movdqa 0x30(%0),%%xmm3 \n" |
| 607 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 608 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 609 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 610 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 611 | "lea 0x40(%0),%0 \n" |
| 612 | "phaddw %%xmm1,%%xmm0 \n" |
| 613 | "phaddw %%xmm3,%%xmm2 \n" |
| 614 | "psrlw $0x7,%%xmm0 \n" |
| 615 | "psrlw $0x7,%%xmm2 \n" |
| 616 | "packuswb %%xmm2,%%xmm0 \n" |
| 617 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 618 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 619 | "movdqa %%xmm0,(%1) \n" |
| 620 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 621 | "jg 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 622 | : "+r"(src_argb), // %0 |
| 623 | "+r"(dst_y), // %1 |
| 624 | "+r"(pix) // %2 |
| 625 | : "m"(kARGBToY), // %3 |
| 626 | "m"(kAddY16) // %4 |
| 627 | : "memory", "cc" |
| 628 | #if defined(__SSE2__) |
| 629 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 630 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 631 | ); |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 632 | } |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 633 | |
| 634 | void ARGBToYRow_Unaligned_SSSE3(const uint8* src_argb, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 635 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 636 | "movdqa %4,%%xmm5 \n" |
| 637 | "movdqa %3,%%xmm4 \n" |
| 638 | "1: \n" |
| 639 | "movdqu (%0),%%xmm0 \n" |
| 640 | "movdqu 0x10(%0),%%xmm1 \n" |
| 641 | "movdqu 0x20(%0),%%xmm2 \n" |
| 642 | "movdqu 0x30(%0),%%xmm3 \n" |
| 643 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 644 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 645 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 646 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 647 | "lea 0x40(%0),%0 \n" |
| 648 | "phaddw %%xmm1,%%xmm0 \n" |
| 649 | "phaddw %%xmm3,%%xmm2 \n" |
| 650 | "psrlw $0x7,%%xmm0 \n" |
| 651 | "psrlw $0x7,%%xmm2 \n" |
| 652 | "packuswb %%xmm2,%%xmm0 \n" |
| 653 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 654 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 655 | "movdqu %%xmm0,(%1) \n" |
| 656 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 657 | "jg 1b \n" |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 658 | : "+r"(src_argb), // %0 |
| 659 | "+r"(dst_y), // %1 |
| 660 | "+r"(pix) // %2 |
| 661 | : "m"(kARGBToY), // %3 |
| 662 | "m"(kAddY16) // %4 |
| 663 | : "memory", "cc" |
| 664 | #if defined(__SSE2__) |
| 665 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 666 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 667 | ); |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 668 | } |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 669 | |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 670 | // TODO(fbarchard): pass xmm constants to single block of assembly. |
| 671 | // fpic on GCC 4.2 for OSX runs out of GPR registers. "m" effectively takes |
| 672 | // 3 registers - ebx, ebp and eax. "m" can be passed with 3 normal registers, |
| 673 | // or 4 if stack frame is disabled. Doing 2 assembly blocks is a work around |
| 674 | // and considered unsafe. |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 675 | void ARGBToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb, |
| 676 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 677 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 678 | "movdqa %0,%%xmm4 \n" |
| 679 | "movdqa %1,%%xmm3 \n" |
| 680 | "movdqa %2,%%xmm5 \n" |
fbarchard@google.com | d93d448 | 2011-11-10 18:26:20 +0000 | [diff] [blame] | 681 | : |
| 682 | : "m"(kARGBToU), // %0 |
| 683 | "m"(kARGBToV), // %1 |
| 684 | "m"(kAddUV128) // %2 |
| 685 | : |
| 686 | #if defined(__SSE2__) |
| 687 | "xmm3", "xmm4", "xmm5" |
| 688 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 689 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 690 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 691 | "sub %1,%2 \n" |
| 692 | "1: \n" |
| 693 | "movdqa (%0),%%xmm0 \n" |
| 694 | "movdqa 0x10(%0),%%xmm1 \n" |
| 695 | "movdqa 0x20(%0),%%xmm2 \n" |
| 696 | "movdqa 0x30(%0),%%xmm6 \n" |
| 697 | "pavgb (%0,%4,1),%%xmm0 \n" |
| 698 | "pavgb 0x10(%0,%4,1),%%xmm1 \n" |
| 699 | "pavgb 0x20(%0,%4,1),%%xmm2 \n" |
| 700 | "pavgb 0x30(%0,%4,1),%%xmm6 \n" |
| 701 | "lea 0x40(%0),%0 \n" |
| 702 | "movdqa %%xmm0,%%xmm7 \n" |
| 703 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 704 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 705 | "pavgb %%xmm7,%%xmm0 \n" |
| 706 | "movdqa %%xmm2,%%xmm7 \n" |
| 707 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 708 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 709 | "pavgb %%xmm7,%%xmm2 \n" |
| 710 | "movdqa %%xmm0,%%xmm1 \n" |
| 711 | "movdqa %%xmm2,%%xmm6 \n" |
| 712 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 713 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 714 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 715 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 716 | "phaddw %%xmm2,%%xmm0 \n" |
| 717 | "phaddw %%xmm6,%%xmm1 \n" |
| 718 | "psraw $0x8,%%xmm0 \n" |
| 719 | "psraw $0x8,%%xmm1 \n" |
| 720 | "packsswb %%xmm1,%%xmm0 \n" |
| 721 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 722 | "sub $0x10,%3 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 723 | "movlps %%xmm0,(%1) \n" |
| 724 | "movhps %%xmm0,(%1,%2,1) \n" |
| 725 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 726 | "jg 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 727 | : "+r"(src_argb0), // %0 |
| 728 | "+r"(dst_u), // %1 |
| 729 | "+r"(dst_v), // %2 |
| 730 | "+rm"(width) // %3 |
fbarchard@google.com | d93d448 | 2011-11-10 18:26:20 +0000 | [diff] [blame] | 731 | : "r"(static_cast<intptr_t>(src_stride_argb)) |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 732 | : "memory", "cc" |
| 733 | #if defined(__SSE2__) |
fbarchard@google.com | d93d448 | 2011-11-10 18:26:20 +0000 | [diff] [blame] | 734 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 735 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 736 | ); |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 737 | } |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 738 | |
| 739 | void ARGBToUVRow_Unaligned_SSSE3(const uint8* src_argb0, int src_stride_argb, |
| 740 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 741 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 742 | "movdqa %0,%%xmm4 \n" |
| 743 | "movdqa %1,%%xmm3 \n" |
| 744 | "movdqa %2,%%xmm5 \n" |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 745 | : |
| 746 | : "m"(kARGBToU), // %0 |
| 747 | "m"(kARGBToV), // %1 |
| 748 | "m"(kAddUV128) // %2 |
| 749 | : |
| 750 | #if defined(__SSE2__) |
| 751 | "xmm3", "xmm4", "xmm5" |
| 752 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 753 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 754 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 755 | "sub %1,%2 \n" |
| 756 | "1: \n" |
| 757 | "movdqu (%0),%%xmm0 \n" |
| 758 | "movdqu 0x10(%0),%%xmm1 \n" |
| 759 | "movdqu 0x20(%0),%%xmm2 \n" |
| 760 | "movdqu 0x30(%0),%%xmm6 \n" |
| 761 | "movdqu (%0,%4,1),%%xmm7 \n" |
| 762 | "pavgb %%xmm7,%%xmm0 \n" |
| 763 | "movdqu 0x10(%0,%4,1),%%xmm7 \n" |
| 764 | "pavgb %%xmm7,%%xmm1 \n" |
| 765 | "movdqu 0x20(%0,%4,1),%%xmm7 \n" |
| 766 | "pavgb %%xmm7,%%xmm2 \n" |
| 767 | "movdqu 0x30(%0,%4,1),%%xmm7 \n" |
| 768 | "pavgb %%xmm7,%%xmm6 \n" |
| 769 | "lea 0x40(%0),%0 \n" |
| 770 | "movdqa %%xmm0,%%xmm7 \n" |
| 771 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 772 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 773 | "pavgb %%xmm7,%%xmm0 \n" |
| 774 | "movdqa %%xmm2,%%xmm7 \n" |
| 775 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 776 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 777 | "pavgb %%xmm7,%%xmm2 \n" |
| 778 | "movdqa %%xmm0,%%xmm1 \n" |
| 779 | "movdqa %%xmm2,%%xmm6 \n" |
| 780 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 781 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 782 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 783 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 784 | "phaddw %%xmm2,%%xmm0 \n" |
| 785 | "phaddw %%xmm6,%%xmm1 \n" |
| 786 | "psraw $0x8,%%xmm0 \n" |
| 787 | "psraw $0x8,%%xmm1 \n" |
| 788 | "packsswb %%xmm1,%%xmm0 \n" |
| 789 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 790 | "sub $0x10,%3 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 791 | "movlps %%xmm0,(%1) \n" |
| 792 | "movhps %%xmm0,(%1,%2,1) \n" |
| 793 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 794 | "jg 1b \n" |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 795 | : "+r"(src_argb0), // %0 |
| 796 | "+r"(dst_u), // %1 |
| 797 | "+r"(dst_v), // %2 |
| 798 | "+rm"(width) // %3 |
| 799 | : "r"(static_cast<intptr_t>(src_stride_argb)) |
| 800 | : "memory", "cc" |
| 801 | #if defined(__SSE2__) |
| 802 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 803 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 804 | ); |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 805 | } |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 806 | |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 807 | void BGRAToYRow_SSSE3(const uint8* src_bgra, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 808 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 809 | "movdqa %4,%%xmm5 \n" |
| 810 | "movdqa %3,%%xmm4 \n" |
| 811 | "1: \n" |
| 812 | "movdqa (%0),%%xmm0 \n" |
| 813 | "movdqa 0x10(%0),%%xmm1 \n" |
| 814 | "movdqa 0x20(%0),%%xmm2 \n" |
| 815 | "movdqa 0x30(%0),%%xmm3 \n" |
| 816 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 817 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 818 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 819 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 820 | "lea 0x40(%0),%0 \n" |
| 821 | "phaddw %%xmm1,%%xmm0 \n" |
| 822 | "phaddw %%xmm3,%%xmm2 \n" |
| 823 | "psrlw $0x7,%%xmm0 \n" |
| 824 | "psrlw $0x7,%%xmm2 \n" |
| 825 | "packuswb %%xmm2,%%xmm0 \n" |
| 826 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 827 | "sub $0x10,%2 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 828 | "movdqa %%xmm0,(%1) \n" |
| 829 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 830 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 831 | : "+r"(src_bgra), // %0 |
| 832 | "+r"(dst_y), // %1 |
| 833 | "+r"(pix) // %2 |
| 834 | : "m"(kBGRAToY), // %3 |
| 835 | "m"(kAddY16) // %4 |
| 836 | : "memory", "cc" |
| 837 | #if defined(__SSE2__) |
| 838 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 839 | #endif |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 840 | ); |
| 841 | } |
| 842 | |
| 843 | void BGRAToYRow_Unaligned_SSSE3(const uint8* src_bgra, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 844 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 845 | "movdqa %4,%%xmm5 \n" |
| 846 | "movdqa %3,%%xmm4 \n" |
| 847 | "1: \n" |
| 848 | "movdqu (%0),%%xmm0 \n" |
| 849 | "movdqu 0x10(%0),%%xmm1 \n" |
| 850 | "movdqu 0x20(%0),%%xmm2 \n" |
| 851 | "movdqu 0x30(%0),%%xmm3 \n" |
| 852 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 853 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 854 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 855 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 856 | "lea 0x40(%0),%0 \n" |
| 857 | "phaddw %%xmm1,%%xmm0 \n" |
| 858 | "phaddw %%xmm3,%%xmm2 \n" |
| 859 | "psrlw $0x7,%%xmm0 \n" |
| 860 | "psrlw $0x7,%%xmm2 \n" |
| 861 | "packuswb %%xmm2,%%xmm0 \n" |
| 862 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 863 | "sub $0x10,%2 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 864 | "movdqu %%xmm0,(%1) \n" |
| 865 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 866 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 867 | : "+r"(src_bgra), // %0 |
| 868 | "+r"(dst_y), // %1 |
| 869 | "+r"(pix) // %2 |
| 870 | : "m"(kBGRAToY), // %3 |
| 871 | "m"(kAddY16) // %4 |
| 872 | : "memory", "cc" |
| 873 | #if defined(__SSE2__) |
| 874 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 875 | #endif |
| 876 | ); |
| 877 | } |
| 878 | |
| 879 | void BGRAToUVRow_SSSE3(const uint8* src_bgra0, int src_stride_bgra, |
| 880 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 881 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 882 | "movdqa %0,%%xmm4 \n" |
| 883 | "movdqa %1,%%xmm3 \n" |
| 884 | "movdqa %2,%%xmm5 \n" |
| 885 | : |
| 886 | : "m"(kBGRAToU), // %0 |
| 887 | "m"(kBGRAToV), // %1 |
| 888 | "m"(kAddUV128) // %2 |
| 889 | : |
| 890 | #if defined(__SSE2__) |
| 891 | "xmm3", "xmm4", "xmm5" |
| 892 | #endif |
| 893 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 894 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 895 | "sub %1,%2 \n" |
| 896 | "1: \n" |
| 897 | "movdqa (%0),%%xmm0 \n" |
| 898 | "movdqa 0x10(%0),%%xmm1 \n" |
| 899 | "movdqa 0x20(%0),%%xmm2 \n" |
| 900 | "movdqa 0x30(%0),%%xmm6 \n" |
| 901 | "pavgb (%0,%4,1),%%xmm0 \n" |
| 902 | "pavgb 0x10(%0,%4,1),%%xmm1 \n" |
| 903 | "pavgb 0x20(%0,%4,1),%%xmm2 \n" |
| 904 | "pavgb 0x30(%0,%4,1),%%xmm6 \n" |
| 905 | "lea 0x40(%0),%0 \n" |
| 906 | "movdqa %%xmm0,%%xmm7 \n" |
| 907 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 908 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 909 | "pavgb %%xmm7,%%xmm0 \n" |
| 910 | "movdqa %%xmm2,%%xmm7 \n" |
| 911 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 912 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 913 | "pavgb %%xmm7,%%xmm2 \n" |
| 914 | "movdqa %%xmm0,%%xmm1 \n" |
| 915 | "movdqa %%xmm2,%%xmm6 \n" |
| 916 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 917 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 918 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 919 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 920 | "phaddw %%xmm2,%%xmm0 \n" |
| 921 | "phaddw %%xmm6,%%xmm1 \n" |
| 922 | "psraw $0x8,%%xmm0 \n" |
| 923 | "psraw $0x8,%%xmm1 \n" |
| 924 | "packsswb %%xmm1,%%xmm0 \n" |
| 925 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 926 | "sub $0x10,%3 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 927 | "movlps %%xmm0,(%1) \n" |
| 928 | "movhps %%xmm0,(%1,%2,1) \n" |
| 929 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 930 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 931 | : "+r"(src_bgra0), // %0 |
| 932 | "+r"(dst_u), // %1 |
| 933 | "+r"(dst_v), // %2 |
| 934 | "+rm"(width) // %3 |
| 935 | : "r"(static_cast<intptr_t>(src_stride_bgra)) |
| 936 | : "memory", "cc" |
| 937 | #if defined(__SSE2__) |
| 938 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 939 | #endif |
| 940 | ); |
| 941 | } |
| 942 | |
| 943 | void BGRAToUVRow_Unaligned_SSSE3(const uint8* src_bgra0, int src_stride_bgra, |
| 944 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 945 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 946 | "movdqa %0,%%xmm4 \n" |
| 947 | "movdqa %1,%%xmm3 \n" |
| 948 | "movdqa %2,%%xmm5 \n" |
| 949 | : |
| 950 | : "m"(kBGRAToU), // %0 |
| 951 | "m"(kBGRAToV), // %1 |
| 952 | "m"(kAddUV128) // %2 |
| 953 | : |
| 954 | #if defined(__SSE2__) |
| 955 | "xmm3", "xmm4", "xmm5" |
| 956 | #endif |
| 957 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 958 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 959 | "sub %1,%2 \n" |
| 960 | "1: \n" |
| 961 | "movdqu (%0),%%xmm0 \n" |
| 962 | "movdqu 0x10(%0),%%xmm1 \n" |
| 963 | "movdqu 0x20(%0),%%xmm2 \n" |
| 964 | "movdqu 0x30(%0),%%xmm6 \n" |
| 965 | "movdqu (%0,%4,1),%%xmm7 \n" |
| 966 | "pavgb %%xmm7,%%xmm0 \n" |
| 967 | "movdqu 0x10(%0,%4,1),%%xmm7 \n" |
| 968 | "pavgb %%xmm7,%%xmm1 \n" |
| 969 | "movdqu 0x20(%0,%4,1),%%xmm7 \n" |
| 970 | "pavgb %%xmm7,%%xmm2 \n" |
| 971 | "movdqu 0x30(%0,%4,1),%%xmm7 \n" |
| 972 | "pavgb %%xmm7,%%xmm6 \n" |
| 973 | "lea 0x40(%0),%0 \n" |
| 974 | "movdqa %%xmm0,%%xmm7 \n" |
| 975 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 976 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 977 | "pavgb %%xmm7,%%xmm0 \n" |
| 978 | "movdqa %%xmm2,%%xmm7 \n" |
| 979 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 980 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 981 | "pavgb %%xmm7,%%xmm2 \n" |
| 982 | "movdqa %%xmm0,%%xmm1 \n" |
| 983 | "movdqa %%xmm2,%%xmm6 \n" |
| 984 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 985 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 986 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 987 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 988 | "phaddw %%xmm2,%%xmm0 \n" |
| 989 | "phaddw %%xmm6,%%xmm1 \n" |
| 990 | "psraw $0x8,%%xmm0 \n" |
| 991 | "psraw $0x8,%%xmm1 \n" |
| 992 | "packsswb %%xmm1,%%xmm0 \n" |
| 993 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 994 | "sub $0x10,%3 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 995 | "movlps %%xmm0,(%1) \n" |
| 996 | "movhps %%xmm0,(%1,%2,1) \n" |
| 997 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 998 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 999 | : "+r"(src_bgra0), // %0 |
| 1000 | "+r"(dst_u), // %1 |
| 1001 | "+r"(dst_v), // %2 |
| 1002 | "+rm"(width) // %3 |
| 1003 | : "r"(static_cast<intptr_t>(src_stride_bgra)) |
| 1004 | : "memory", "cc" |
| 1005 | #if defined(__SSE2__) |
| 1006 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 1007 | #endif |
| 1008 | ); |
| 1009 | } |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1010 | |
| 1011 | void ABGRToYRow_SSSE3(const uint8* src_abgr, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1012 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1013 | "movdqa %4,%%xmm5 \n" |
| 1014 | "movdqa %3,%%xmm4 \n" |
| 1015 | "1: \n" |
| 1016 | "movdqa (%0),%%xmm0 \n" |
| 1017 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1018 | "movdqa 0x20(%0),%%xmm2 \n" |
| 1019 | "movdqa 0x30(%0),%%xmm3 \n" |
| 1020 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 1021 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 1022 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 1023 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 1024 | "lea 0x40(%0),%0 \n" |
| 1025 | "phaddw %%xmm1,%%xmm0 \n" |
| 1026 | "phaddw %%xmm3,%%xmm2 \n" |
| 1027 | "psrlw $0x7,%%xmm0 \n" |
| 1028 | "psrlw $0x7,%%xmm2 \n" |
| 1029 | "packuswb %%xmm2,%%xmm0 \n" |
| 1030 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1031 | "sub $0x10,%2 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1032 | "movdqa %%xmm0,(%1) \n" |
| 1033 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1034 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1035 | : "+r"(src_abgr), // %0 |
| 1036 | "+r"(dst_y), // %1 |
| 1037 | "+r"(pix) // %2 |
| 1038 | : "m"(kABGRToY), // %3 |
| 1039 | "m"(kAddY16) // %4 |
| 1040 | : "memory", "cc" |
| 1041 | #if defined(__SSE2__) |
| 1042 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1043 | #endif |
| 1044 | ); |
| 1045 | } |
| 1046 | |
| 1047 | void ABGRToYRow_Unaligned_SSSE3(const uint8* src_abgr, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1048 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1049 | "movdqa %4,%%xmm5 \n" |
| 1050 | "movdqa %3,%%xmm4 \n" |
| 1051 | "1: \n" |
| 1052 | "movdqu (%0),%%xmm0 \n" |
| 1053 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1054 | "movdqu 0x20(%0),%%xmm2 \n" |
| 1055 | "movdqu 0x30(%0),%%xmm3 \n" |
| 1056 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 1057 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 1058 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 1059 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 1060 | "lea 0x40(%0),%0 \n" |
| 1061 | "phaddw %%xmm1,%%xmm0 \n" |
| 1062 | "phaddw %%xmm3,%%xmm2 \n" |
| 1063 | "psrlw $0x7,%%xmm0 \n" |
| 1064 | "psrlw $0x7,%%xmm2 \n" |
| 1065 | "packuswb %%xmm2,%%xmm0 \n" |
| 1066 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1067 | "sub $0x10,%2 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1068 | "movdqu %%xmm0,(%1) \n" |
| 1069 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1070 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1071 | : "+r"(src_abgr), // %0 |
| 1072 | "+r"(dst_y), // %1 |
| 1073 | "+r"(pix) // %2 |
| 1074 | : "m"(kABGRToY), // %3 |
| 1075 | "m"(kAddY16) // %4 |
| 1076 | : "memory", "cc" |
| 1077 | #if defined(__SSE2__) |
| 1078 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1079 | #endif |
| 1080 | ); |
| 1081 | } |
| 1082 | |
| 1083 | void ABGRToUVRow_SSSE3(const uint8* src_abgr0, int src_stride_abgr, |
| 1084 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1085 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1086 | "movdqa %0,%%xmm4 \n" |
| 1087 | "movdqa %1,%%xmm3 \n" |
| 1088 | "movdqa %2,%%xmm5 \n" |
| 1089 | : |
| 1090 | : "m"(kABGRToU), // %0 |
| 1091 | "m"(kABGRToV), // %1 |
| 1092 | "m"(kAddUV128) // %2 |
| 1093 | : |
| 1094 | #if defined(__SSE2__) |
| 1095 | "xmm3", "xmm4", "xmm5" |
| 1096 | #endif |
| 1097 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1098 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1099 | "sub %1,%2 \n" |
| 1100 | "1: \n" |
| 1101 | "movdqa (%0),%%xmm0 \n" |
| 1102 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1103 | "movdqa 0x20(%0),%%xmm2 \n" |
| 1104 | "movdqa 0x30(%0),%%xmm6 \n" |
| 1105 | "pavgb (%0,%4,1),%%xmm0 \n" |
| 1106 | "pavgb 0x10(%0,%4,1),%%xmm1 \n" |
| 1107 | "pavgb 0x20(%0,%4,1),%%xmm2 \n" |
| 1108 | "pavgb 0x30(%0,%4,1),%%xmm6 \n" |
| 1109 | "lea 0x40(%0),%0 \n" |
| 1110 | "movdqa %%xmm0,%%xmm7 \n" |
| 1111 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 1112 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 1113 | "pavgb %%xmm7,%%xmm0 \n" |
| 1114 | "movdqa %%xmm2,%%xmm7 \n" |
| 1115 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 1116 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 1117 | "pavgb %%xmm7,%%xmm2 \n" |
| 1118 | "movdqa %%xmm0,%%xmm1 \n" |
| 1119 | "movdqa %%xmm2,%%xmm6 \n" |
| 1120 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 1121 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 1122 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 1123 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 1124 | "phaddw %%xmm2,%%xmm0 \n" |
| 1125 | "phaddw %%xmm6,%%xmm1 \n" |
| 1126 | "psraw $0x8,%%xmm0 \n" |
| 1127 | "psraw $0x8,%%xmm1 \n" |
| 1128 | "packsswb %%xmm1,%%xmm0 \n" |
| 1129 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1130 | "sub $0x10,%3 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1131 | "movlps %%xmm0,(%1) \n" |
| 1132 | "movhps %%xmm0,(%1,%2,1) \n" |
| 1133 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1134 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1135 | : "+r"(src_abgr0), // %0 |
| 1136 | "+r"(dst_u), // %1 |
| 1137 | "+r"(dst_v), // %2 |
| 1138 | "+rm"(width) // %3 |
| 1139 | : "r"(static_cast<intptr_t>(src_stride_abgr)) |
| 1140 | : "memory", "cc" |
| 1141 | #if defined(__SSE2__) |
| 1142 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 1143 | #endif |
| 1144 | ); |
| 1145 | } |
| 1146 | |
| 1147 | void ABGRToUVRow_Unaligned_SSSE3(const uint8* src_abgr0, int src_stride_abgr, |
| 1148 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1149 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1150 | "movdqa %0,%%xmm4 \n" |
| 1151 | "movdqa %1,%%xmm3 \n" |
| 1152 | "movdqa %2,%%xmm5 \n" |
| 1153 | : |
| 1154 | : "m"(kABGRToU), // %0 |
| 1155 | "m"(kABGRToV), // %1 |
| 1156 | "m"(kAddUV128) // %2 |
| 1157 | : |
| 1158 | #if defined(__SSE2__) |
| 1159 | "xmm3", "xmm4", "xmm5" |
| 1160 | #endif |
| 1161 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1162 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1163 | "sub %1,%2 \n" |
| 1164 | "1: \n" |
| 1165 | "movdqu (%0),%%xmm0 \n" |
| 1166 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1167 | "movdqu 0x20(%0),%%xmm2 \n" |
| 1168 | "movdqu 0x30(%0),%%xmm6 \n" |
| 1169 | "movdqu (%0,%4,1),%%xmm7 \n" |
| 1170 | "pavgb %%xmm7,%%xmm0 \n" |
| 1171 | "movdqu 0x10(%0,%4,1),%%xmm7 \n" |
| 1172 | "pavgb %%xmm7,%%xmm1 \n" |
| 1173 | "movdqu 0x20(%0,%4,1),%%xmm7 \n" |
| 1174 | "pavgb %%xmm7,%%xmm2 \n" |
| 1175 | "movdqu 0x30(%0,%4,1),%%xmm7 \n" |
| 1176 | "pavgb %%xmm7,%%xmm6 \n" |
| 1177 | "lea 0x40(%0),%0 \n" |
| 1178 | "movdqa %%xmm0,%%xmm7 \n" |
| 1179 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 1180 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 1181 | "pavgb %%xmm7,%%xmm0 \n" |
| 1182 | "movdqa %%xmm2,%%xmm7 \n" |
| 1183 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 1184 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 1185 | "pavgb %%xmm7,%%xmm2 \n" |
| 1186 | "movdqa %%xmm0,%%xmm1 \n" |
| 1187 | "movdqa %%xmm2,%%xmm6 \n" |
| 1188 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 1189 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 1190 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 1191 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 1192 | "phaddw %%xmm2,%%xmm0 \n" |
| 1193 | "phaddw %%xmm6,%%xmm1 \n" |
| 1194 | "psraw $0x8,%%xmm0 \n" |
| 1195 | "psraw $0x8,%%xmm1 \n" |
| 1196 | "packsswb %%xmm1,%%xmm0 \n" |
| 1197 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1198 | "sub $0x10,%3 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1199 | "movlps %%xmm0,(%1) \n" |
| 1200 | "movhps %%xmm0,(%1,%2,1) \n" |
| 1201 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1202 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1203 | : "+r"(src_abgr0), // %0 |
| 1204 | "+r"(dst_u), // %1 |
| 1205 | "+r"(dst_v), // %2 |
| 1206 | "+rm"(width) // %3 |
| 1207 | : "r"(static_cast<intptr_t>(src_stride_abgr)) |
| 1208 | : "memory", "cc" |
| 1209 | #if defined(__SSE2__) |
| 1210 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 1211 | #endif |
| 1212 | ); |
| 1213 | } |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1214 | |
| 1215 | #endif // HAS_ARGBTOYROW_SSSE3 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1216 | |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1217 | #ifdef HAS_I420TOARGBROW_SSSE3 |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1218 | #define UB 127 /* min(63,static_cast<int8>(2.018 * 64)) */ |
| 1219 | #define UG -25 /* static_cast<int8>(-0.391 * 64 - 0.5) */ |
| 1220 | #define UR 0 |
| 1221 | |
| 1222 | #define VB 0 |
| 1223 | #define VG -52 /* static_cast<int8>(-0.813 * 64 - 0.5) */ |
| 1224 | #define VR 102 /* static_cast<int8>(1.596 * 64 + 0.5) */ |
| 1225 | |
| 1226 | // Bias |
| 1227 | #define BB UB * 128 + VB * 128 |
| 1228 | #define BG UG * 128 + VG * 128 |
| 1229 | #define BR UR * 128 + VR * 128 |
| 1230 | |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1231 | #define YG 74 /* static_cast<int8>(1.164 * 64 + 0.5) */ |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1232 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1233 | #if defined(__APPLE__) || defined(__x86_64__) |
| 1234 | #define OMITFP |
| 1235 | #else |
| 1236 | #define OMITFP __attribute__((optimize("omit-frame-pointer"))) |
| 1237 | #endif |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 1238 | |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1239 | struct { |
| 1240 | vec8 kUVToB; |
| 1241 | vec8 kUVToG; |
| 1242 | vec8 kUVToR; |
| 1243 | vec16 kUVBiasB; |
| 1244 | vec16 kUVBiasG; |
| 1245 | vec16 kUVBiasR; |
| 1246 | vec16 kYSub16; |
| 1247 | vec16 kYToRgb; |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1248 | } CONST SIMD_ALIGNED(kYuvConstants) = { |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1249 | { UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB }, |
| 1250 | { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG }, |
| 1251 | { UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR }, |
| 1252 | { BB, BB, BB, BB, BB, BB, BB, BB }, |
| 1253 | { BG, BG, BG, BG, BG, BG, BG, BG }, |
| 1254 | { BR, BR, BR, BR, BR, BR, BR, BR }, |
| 1255 | { 16, 16, 16, 16, 16, 16, 16, 16 }, |
| 1256 | { YG, YG, YG, YG, YG, YG, YG, YG } |
| 1257 | }; |
| 1258 | |
| 1259 | // Convert 8 pixels |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1260 | #define YUVTORGB \ |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1261 | "movd (%1),%%xmm0 \n" \ |
| 1262 | "movd (%1,%2,1),%%xmm1 \n" \ |
| 1263 | "lea 0x4(%1),%1 \n" \ |
| 1264 | "punpcklbw %%xmm1,%%xmm0 \n" \ |
| 1265 | "punpcklwd %%xmm0,%%xmm0 \n" \ |
| 1266 | "movdqa %%xmm0,%%xmm1 \n" \ |
| 1267 | "movdqa %%xmm0,%%xmm2 \n" \ |
| 1268 | "pmaddubsw (%5),%%xmm0 \n" \ |
| 1269 | "pmaddubsw 16(%5),%%xmm1 \n" \ |
| 1270 | "pmaddubsw 32(%5),%%xmm2 \n" \ |
| 1271 | "psubw 48(%5),%%xmm0 \n" \ |
| 1272 | "psubw 64(%5),%%xmm1 \n" \ |
| 1273 | "psubw 80(%5),%%xmm2 \n" \ |
| 1274 | "movq (%0),%%xmm3 \n" \ |
| 1275 | "lea 0x8(%0),%0 \n" \ |
| 1276 | "punpcklbw %%xmm4,%%xmm3 \n" \ |
| 1277 | "psubsw 96(%5),%%xmm3 \n" \ |
| 1278 | "pmullw 112(%5),%%xmm3 \n" \ |
| 1279 | "paddsw %%xmm3,%%xmm0 \n" \ |
| 1280 | "paddsw %%xmm3,%%xmm1 \n" \ |
| 1281 | "paddsw %%xmm3,%%xmm2 \n" \ |
| 1282 | "psraw $0x6,%%xmm0 \n" \ |
| 1283 | "psraw $0x6,%%xmm1 \n" \ |
| 1284 | "psraw $0x6,%%xmm2 \n" \ |
| 1285 | "packuswb %%xmm0,%%xmm0 \n" \ |
| 1286 | "packuswb %%xmm1,%%xmm1 \n" \ |
| 1287 | "packuswb %%xmm2,%%xmm2 \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1288 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1289 | void OMITFP I420ToARGBRow_SSSE3(const uint8* y_buf, |
| 1290 | const uint8* u_buf, |
| 1291 | const uint8* v_buf, |
| 1292 | uint8* rgb_buf, |
| 1293 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1294 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1295 | "sub %1,%2 \n" |
| 1296 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1297 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1298 | "1: \n" |
| 1299 | YUVTORGB |
| 1300 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1301 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1302 | "movdqa %%xmm0,%%xmm1 \n" |
| 1303 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1304 | "punpckhwd %%xmm2,%%xmm1 \n" |
| 1305 | "movdqa %%xmm0,(%3) \n" |
| 1306 | "movdqa %%xmm1,0x10(%3) \n" |
| 1307 | "lea 0x20(%3),%3 \n" |
| 1308 | "sub $0x8,%4 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1309 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1310 | : "+r"(y_buf), // %0 |
| 1311 | "+r"(u_buf), // %1 |
| 1312 | "+r"(v_buf), // %2 |
| 1313 | "+r"(rgb_buf), // %3 |
| 1314 | "+rm"(width) // %4 |
| 1315 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1316 | : "memory", "cc" |
| 1317 | #if defined(__SSE2__) |
| 1318 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1319 | #endif |
| 1320 | ); |
| 1321 | } |
| 1322 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1323 | void OMITFP I420ToBGRARow_SSSE3(const uint8* y_buf, |
| 1324 | const uint8* u_buf, |
| 1325 | const uint8* v_buf, |
| 1326 | uint8* rgb_buf, |
| 1327 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1328 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1329 | "sub %1,%2 \n" |
| 1330 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1331 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1332 | "1: \n" |
| 1333 | YUVTORGB |
| 1334 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1335 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 1336 | "punpcklbw %%xmm2,%%xmm5 \n" |
| 1337 | "movdqa %%xmm5,%%xmm0 \n" |
| 1338 | "punpcklwd %%xmm1,%%xmm5 \n" |
| 1339 | "punpckhwd %%xmm1,%%xmm0 \n" |
| 1340 | "movdqa %%xmm5,(%3) \n" |
| 1341 | "movdqa %%xmm0,0x10(%3) \n" |
| 1342 | "lea 0x20(%3),%3 \n" |
| 1343 | "sub $0x8,%4 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1344 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1345 | : "+r"(y_buf), // %0 |
| 1346 | "+r"(u_buf), // %1 |
| 1347 | "+r"(v_buf), // %2 |
| 1348 | "+r"(rgb_buf), // %3 |
| 1349 | "+rm"(width) // %4 |
| 1350 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1351 | : "memory", "cc" |
| 1352 | #if defined(__SSE2__) |
| 1353 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1354 | #endif |
| 1355 | ); |
| 1356 | } |
| 1357 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1358 | void OMITFP I420ToABGRRow_SSSE3(const uint8* y_buf, |
| 1359 | const uint8* u_buf, |
| 1360 | const uint8* v_buf, |
| 1361 | uint8* rgb_buf, |
| 1362 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1363 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1364 | "sub %1,%2 \n" |
| 1365 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1366 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1367 | "1: \n" |
| 1368 | YUVTORGB |
| 1369 | "punpcklbw %%xmm1,%%xmm2 \n" |
| 1370 | "punpcklbw %%xmm5,%%xmm0 \n" |
| 1371 | "movdqa %%xmm2,%%xmm1 \n" |
| 1372 | "punpcklwd %%xmm0,%%xmm2 \n" |
| 1373 | "punpckhwd %%xmm0,%%xmm1 \n" |
| 1374 | "movdqa %%xmm2,(%3) \n" |
| 1375 | "movdqa %%xmm1,0x10(%3) \n" |
| 1376 | "lea 0x20(%3),%3 \n" |
| 1377 | "sub $0x8,%4 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1378 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1379 | : "+r"(y_buf), // %0 |
| 1380 | "+r"(u_buf), // %1 |
| 1381 | "+r"(v_buf), // %2 |
| 1382 | "+r"(rgb_buf), // %3 |
| 1383 | "+rm"(width) // %4 |
| 1384 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1385 | : "memory", "cc" |
| 1386 | #if defined(__SSE2__) |
| 1387 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1388 | #endif |
| 1389 | ); |
| 1390 | } |
| 1391 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1392 | void OMITFP I444ToARGBRow_SSSE3(const uint8* y_buf, |
| 1393 | const uint8* u_buf, |
| 1394 | const uint8* v_buf, |
| 1395 | uint8* rgb_buf, |
| 1396 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1397 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1398 | "sub %1,%2 \n" |
| 1399 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1400 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1401 | "1: \n" |
| 1402 | "movd (%1),%%xmm0 \n" |
| 1403 | "movd (%1,%2,1),%%xmm1 \n" |
| 1404 | "lea 0x4(%1),%1 \n" |
| 1405 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1406 | "movdqa %%xmm0,%%xmm1 \n" |
| 1407 | "movdqa %%xmm0,%%xmm2 \n" |
| 1408 | "pmaddubsw (%5),%%xmm0 \n" |
| 1409 | "pmaddubsw 16(%5),%%xmm1 \n" |
| 1410 | "pmaddubsw 32(%5),%%xmm2 \n" |
| 1411 | "psubw 48(%5),%%xmm0 \n" |
| 1412 | "psubw 64(%5),%%xmm1 \n" |
| 1413 | "psubw 80(%5),%%xmm2 \n" |
| 1414 | "movd (%0),%%xmm3 \n" |
| 1415 | "lea 0x4(%0),%0 \n" |
| 1416 | "punpcklbw %%xmm4,%%xmm3 \n" |
| 1417 | "psubsw 96(%5),%%xmm3 \n" |
| 1418 | "pmullw 112(%5),%%xmm3 \n" |
| 1419 | "paddsw %%xmm3,%%xmm0 \n" |
| 1420 | "paddsw %%xmm3,%%xmm1 \n" |
| 1421 | "paddsw %%xmm3,%%xmm2 \n" |
| 1422 | "psraw $0x6,%%xmm0 \n" |
| 1423 | "psraw $0x6,%%xmm1 \n" |
| 1424 | "psraw $0x6,%%xmm2 \n" |
| 1425 | "packuswb %%xmm0,%%xmm0 \n" |
| 1426 | "packuswb %%xmm1,%%xmm1 \n" |
| 1427 | "packuswb %%xmm2,%%xmm2 \n" |
| 1428 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1429 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1430 | "punpcklwd %%xmm2,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1431 | "sub $0x4,%4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1432 | "movdqa %%xmm0,(%3) \n" |
| 1433 | "lea 0x10(%3),%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1434 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1435 | : "+r"(y_buf), // %0 |
| 1436 | "+r"(u_buf), // %1 |
| 1437 | "+r"(v_buf), // %2 |
| 1438 | "+r"(rgb_buf), // %3 |
| 1439 | "+rm"(width) // %4 |
| 1440 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1441 | : "memory", "cc" |
| 1442 | #if defined(__SSE2__) |
| 1443 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1444 | #endif |
| 1445 | ); |
| 1446 | } |
| 1447 | #endif |
| 1448 | |
| 1449 | #ifdef HAS_YTOARGBROW_SSE2 |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1450 | void YToARGBRow_SSE2(const uint8* y_buf, |
| 1451 | uint8* rgb_buf, |
| 1452 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1453 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1454 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 1455 | "pslld $0x18,%%xmm4 \n" |
| 1456 | "mov $0x10001000,%%eax \n" |
| 1457 | "movd %%eax,%%xmm3 \n" |
| 1458 | "pshufd $0x0,%%xmm3,%%xmm3 \n" |
| 1459 | "mov $0x012a012a,%%eax \n" |
| 1460 | "movd %%eax,%%xmm2 \n" |
| 1461 | "pshufd $0x0,%%xmm2,%%xmm2 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1462 | "1: \n" |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1463 | // Step 1: Scale Y contribution to 8 G values. G = (y - 16) * 1.164 |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1464 | "movq (%0),%%xmm0 \n" |
| 1465 | "lea 0x8(%0),%0 \n" |
| 1466 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 1467 | "psubusw %%xmm3,%%xmm0 \n" |
| 1468 | "pmulhuw %%xmm2,%%xmm0 \n" |
| 1469 | "packuswb %%xmm0,%%xmm0 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1470 | |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1471 | // Step 2: Weave into ARGB |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1472 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 1473 | "movdqa %%xmm0,%%xmm1 \n" |
| 1474 | "punpcklwd %%xmm0,%%xmm0 \n" |
| 1475 | "punpckhwd %%xmm1,%%xmm1 \n" |
| 1476 | "por %%xmm4,%%xmm0 \n" |
| 1477 | "por %%xmm4,%%xmm1 \n" |
| 1478 | "movdqa %%xmm0,(%1) \n" |
| 1479 | "movdqa %%xmm1,16(%1) \n" |
| 1480 | "lea 32(%1),%1 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1481 | |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1482 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1483 | "jg 1b \n" |
fbarchard@google.com | 3faa0f1 | 2011-10-20 06:04:16 +0000 | [diff] [blame] | 1484 | : "+r"(y_buf), // %0 |
| 1485 | "+r"(rgb_buf), // %1 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1486 | "+rm"(width) // %2 |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1487 | : |
| 1488 | : "memory", "cc", "eax" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1489 | #if defined(__SSE2__) |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1490 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1491 | #endif |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1492 | ); |
mikhal@webrtc.org | 120d5e7 | 2011-10-07 17:57:17 +0000 | [diff] [blame] | 1493 | } |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1494 | #endif |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 1495 | |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1496 | #ifdef HAS_MIRRORROW_SSSE3 |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1497 | // Shuffle table for reversing the bytes. |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1498 | CONST uvec8 kShuffleMirror = { |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1499 | 15u, 14u, 13u, 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u |
| 1500 | }; |
| 1501 | |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1502 | void MirrorRow_SSSE3(const uint8* src, uint8* dst, int width) { |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1503 | intptr_t temp_width = static_cast<intptr_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1504 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1505 | "movdqa %3,%%xmm5 \n" |
| 1506 | "lea -0x10(%0),%0 \n" |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1507 | "1: \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1508 | "movdqa (%0,%2),%%xmm0 \n" |
| 1509 | "pshufb %%xmm5,%%xmm0 \n" |
| 1510 | "sub $0x10,%2 \n" |
| 1511 | "movdqa %%xmm0,(%1) \n" |
| 1512 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1513 | "jg 1b \n" |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1514 | : "+r"(src), // %0 |
| 1515 | "+r"(dst), // %1 |
| 1516 | "+r"(temp_width) // %2 |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1517 | : "m"(kShuffleMirror) // %3 |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1518 | : "memory", "cc" |
| 1519 | #if defined(__SSE2__) |
| 1520 | , "xmm0", "xmm5" |
| 1521 | #endif |
| 1522 | ); |
| 1523 | } |
| 1524 | #endif |
| 1525 | |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1526 | #ifdef HAS_MIRRORROW_SSE2 |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1527 | void MirrorRow_SSE2(const uint8* src, uint8* dst, int width) { |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1528 | intptr_t temp_width = static_cast<intptr_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1529 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1530 | "lea -0x10(%0),%0 \n" |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1531 | "1: \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1532 | "movdqu (%0,%2),%%xmm0 \n" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1533 | "movdqa %%xmm0,%%xmm1 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1534 | "psllw $0x8,%%xmm0 \n" |
| 1535 | "psrlw $0x8,%%xmm1 \n" |
| 1536 | "por %%xmm1,%%xmm0 \n" |
| 1537 | "pshuflw $0x1b,%%xmm0,%%xmm0 \n" |
| 1538 | "pshufhw $0x1b,%%xmm0,%%xmm0 \n" |
| 1539 | "pshufd $0x4e,%%xmm0,%%xmm0 \n" |
| 1540 | "sub $0x10,%2 \n" |
| 1541 | "movdqu %%xmm0,(%1) \n" |
| 1542 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1543 | "jg 1b \n" |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1544 | : "+r"(src), // %0 |
| 1545 | "+r"(dst), // %1 |
| 1546 | "+r"(temp_width) // %2 |
| 1547 | : |
| 1548 | : "memory", "cc" |
| 1549 | #if defined(__SSE2__) |
| 1550 | , "xmm0", "xmm1" |
| 1551 | #endif |
| 1552 | ); |
| 1553 | } |
| 1554 | #endif |
| 1555 | |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1556 | #ifdef HAS_MIRRORROW_UV_SSSE3 |
| 1557 | // Shuffle table for reversing the bytes of UV channels. |
| 1558 | CONST uvec8 kShuffleMirrorUV = { |
| 1559 | 14u, 12u, 10u, 8u, 6u, 4u, 2u, 0u, 15u, 13u, 11u, 9u, 7u, 5u, 3u, 1u |
| 1560 | }; |
| 1561 | void MirrorRowUV_SSSE3(const uint8* src, uint8* dst_u, uint8* dst_v, |
| 1562 | int width) { |
| 1563 | intptr_t temp_width = static_cast<intptr_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1564 | asm volatile ( |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1565 | "movdqa %4,%%xmm1 \n" |
| 1566 | "lea -16(%0,%3,2),%0 \n" |
| 1567 | "sub %1,%2 \n" |
| 1568 | "1: \n" |
| 1569 | "movdqa (%0),%%xmm0 \n" |
| 1570 | "lea -16(%0),%0 \n" |
| 1571 | "pshufb %%xmm1,%%xmm0 \n" |
| 1572 | "sub $8,%3 \n" |
| 1573 | "movlpd %%xmm0,(%1) \n" |
| 1574 | "movhpd %%xmm0,(%1,%2) \n" |
| 1575 | "lea 8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1576 | "jg 1b \n" |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1577 | : "+r"(src), // %0 |
| 1578 | "+r"(dst_u), // %1 |
| 1579 | "+r"(dst_v), // %2 |
| 1580 | "+r"(temp_width) // %3 |
| 1581 | : "m"(kShuffleMirrorUV) // %4 |
| 1582 | : "memory", "cc" |
| 1583 | #if defined(__SSE2__) |
| 1584 | , "xmm0", "xmm1" |
| 1585 | #endif |
| 1586 | ); |
| 1587 | } |
| 1588 | #endif |
| 1589 | |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1590 | #ifdef HAS_SPLITUV_SSE2 |
| 1591 | void SplitUV_SSE2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1592 | asm volatile ( |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1593 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1594 | "psrlw $0x8,%%xmm5 \n" |
| 1595 | "sub %1,%2 \n" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1596 | "1: \n" |
| 1597 | "movdqa (%0),%%xmm0 \n" |
| 1598 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1599 | "lea 0x20(%0),%0 \n" |
| 1600 | "movdqa %%xmm0,%%xmm2 \n" |
| 1601 | "movdqa %%xmm1,%%xmm3 \n" |
| 1602 | "pand %%xmm5,%%xmm0 \n" |
| 1603 | "pand %%xmm5,%%xmm1 \n" |
| 1604 | "packuswb %%xmm1,%%xmm0 \n" |
| 1605 | "psrlw $0x8,%%xmm2 \n" |
| 1606 | "psrlw $0x8,%%xmm3 \n" |
| 1607 | "packuswb %%xmm3,%%xmm2 \n" |
| 1608 | "movdqa %%xmm0,(%1) \n" |
| 1609 | "movdqa %%xmm2,(%1,%2) \n" |
| 1610 | "lea 0x10(%1),%1 \n" |
| 1611 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1612 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1613 | : "+r"(src_uv), // %0 |
| 1614 | "+r"(dst_u), // %1 |
| 1615 | "+r"(dst_v), // %2 |
| 1616 | "+r"(pix) // %3 |
| 1617 | : |
| 1618 | : "memory", "cc" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1619 | #if defined(__SSE2__) |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1620 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1621 | #endif |
| 1622 | ); |
| 1623 | } |
| 1624 | #endif |
| 1625 | |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 1626 | #ifdef HAS_COPYROW_SSE2 |
| 1627 | void CopyRow_SSE2(const uint8* src, uint8* dst, int count) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1628 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1629 | "sub %0,%1 \n" |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 1630 | "1: \n" |
| 1631 | "movdqa (%0),%%xmm0 \n" |
| 1632 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1633 | "movdqa %%xmm0,(%0,%1) \n" |
| 1634 | "movdqa %%xmm1,0x10(%0,%1) \n" |
| 1635 | "lea 0x20(%0),%0 \n" |
| 1636 | "sub $0x20,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1637 | "jg 1b \n" |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 1638 | : "+r"(src), // %0 |
| 1639 | "+r"(dst), // %1 |
| 1640 | "+r"(count) // %2 |
| 1641 | : |
| 1642 | : "memory", "cc" |
| 1643 | #if defined(__SSE2__) |
| 1644 | , "xmm0", "xmm1" |
| 1645 | #endif |
| 1646 | ); |
| 1647 | } |
| 1648 | #endif // HAS_COPYROW_SSE2 |
| 1649 | |
| 1650 | #ifdef HAS_COPYROW_X86 |
| 1651 | void CopyRow_X86(const uint8* src, uint8* dst, int width) { |
| 1652 | size_t width_tmp = static_cast<size_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1653 | asm volatile ( |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 1654 | "shr $0x2,%2 \n" |
| 1655 | "rep movsl \n" |
| 1656 | : "+S"(src), // %0 |
| 1657 | "+D"(dst), // %1 |
| 1658 | "+c"(width_tmp) // %2 |
| 1659 | : |
| 1660 | : "memory", "cc" |
| 1661 | ); |
| 1662 | } |
| 1663 | #endif |
| 1664 | |
fbarchard@google.com | b95dbf2 | 2012-02-11 01:18:30 +0000 | [diff] [blame] | 1665 | #ifdef HAS_YUY2TOYROW_SSE2 |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1666 | void YUY2ToYRow_SSE2(const uint8* src_yuy2, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1667 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1668 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1669 | "psrlw $0x8,%%xmm5 \n" |
| 1670 | "1: \n" |
| 1671 | "movdqa (%0),%%xmm0 \n" |
| 1672 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1673 | "lea 0x20(%0),%0 \n" |
| 1674 | "pand %%xmm5,%%xmm0 \n" |
| 1675 | "pand %%xmm5,%%xmm1 \n" |
| 1676 | "packuswb %%xmm1,%%xmm0 \n" |
| 1677 | "movdqa %%xmm0,(%1) \n" |
| 1678 | "lea 0x10(%1),%1 \n" |
| 1679 | "sub $0x10,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1680 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1681 | : "+r"(src_yuy2), // %0 |
| 1682 | "+r"(dst_y), // %1 |
| 1683 | "+r"(pix) // %2 |
| 1684 | : |
| 1685 | : "memory", "cc" |
| 1686 | #if defined(__SSE2__) |
| 1687 | , "xmm0", "xmm1", "xmm5" |
| 1688 | #endif |
| 1689 | ); |
| 1690 | } |
| 1691 | |
| 1692 | void YUY2ToUVRow_SSE2(const uint8* src_yuy2, int stride_yuy2, |
| 1693 | uint8* dst_u, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1694 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1695 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1696 | "psrlw $0x8,%%xmm5 \n" |
| 1697 | "sub %1,%2 \n" |
| 1698 | "1: \n" |
| 1699 | "movdqa (%0),%%xmm0 \n" |
| 1700 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1701 | "movdqa (%0,%4,1),%%xmm2 \n" |
| 1702 | "movdqa 0x10(%0,%4,1),%%xmm3 \n" |
| 1703 | "lea 0x20(%0),%0 \n" |
| 1704 | "pavgb %%xmm2,%%xmm0 \n" |
| 1705 | "pavgb %%xmm3,%%xmm1 \n" |
| 1706 | "psrlw $0x8,%%xmm0 \n" |
| 1707 | "psrlw $0x8,%%xmm1 \n" |
| 1708 | "packuswb %%xmm1,%%xmm0 \n" |
| 1709 | "movdqa %%xmm0,%%xmm1 \n" |
| 1710 | "pand %%xmm5,%%xmm0 \n" |
| 1711 | "packuswb %%xmm0,%%xmm0 \n" |
| 1712 | "psrlw $0x8,%%xmm1 \n" |
| 1713 | "packuswb %%xmm1,%%xmm1 \n" |
| 1714 | "movq %%xmm0,(%1) \n" |
| 1715 | "movq %%xmm1,(%1,%2) \n" |
| 1716 | "lea 0x8(%1),%1 \n" |
| 1717 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1718 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1719 | : "+r"(src_yuy2), // %0 |
| 1720 | "+r"(dst_u), // %1 |
| 1721 | "+r"(dst_y), // %2 |
| 1722 | "+r"(pix) // %3 |
| 1723 | : "r"(static_cast<intptr_t>(stride_yuy2)) // %4 |
| 1724 | : "memory", "cc" |
| 1725 | #if defined(__SSE2__) |
| 1726 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 1727 | #endif |
| 1728 | ); |
| 1729 | } |
| 1730 | |
fbarchard@google.com | f3fb7b6 | 2012-03-29 23:19:34 +0000 | [diff] [blame^] | 1731 | |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1732 | void YUY2ToYRow_Unaligned_SSE2(const uint8* src_yuy2, |
| 1733 | uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1734 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1735 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1736 | "psrlw $0x8,%%xmm5 \n" |
| 1737 | "1: \n" |
| 1738 | "movdqu (%0),%%xmm0 \n" |
| 1739 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1740 | "lea 0x20(%0),%0 \n" |
| 1741 | "pand %%xmm5,%%xmm0 \n" |
| 1742 | "pand %%xmm5,%%xmm1 \n" |
| 1743 | "packuswb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1744 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1745 | "movdqu %%xmm0,(%1) \n" |
| 1746 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1747 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1748 | : "+r"(src_yuy2), // %0 |
| 1749 | "+r"(dst_y), // %1 |
| 1750 | "+r"(pix) // %2 |
| 1751 | : |
| 1752 | : "memory", "cc" |
| 1753 | #if defined(__SSE2__) |
| 1754 | , "xmm0", "xmm1", "xmm5" |
| 1755 | #endif |
| 1756 | ); |
| 1757 | } |
| 1758 | |
| 1759 | void YUY2ToUVRow_Unaligned_SSE2(const uint8* src_yuy2, |
| 1760 | int stride_yuy2, |
| 1761 | uint8* dst_u, uint8* dst_y, |
| 1762 | int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1763 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1764 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1765 | "psrlw $0x8,%%xmm5 \n" |
| 1766 | "sub %1,%2 \n" |
| 1767 | "1: \n" |
| 1768 | "movdqu (%0),%%xmm0 \n" |
| 1769 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1770 | "movdqu (%0,%4,1),%%xmm2 \n" |
| 1771 | "movdqu 0x10(%0,%4,1),%%xmm3 \n" |
| 1772 | "lea 0x20(%0),%0 \n" |
| 1773 | "pavgb %%xmm2,%%xmm0 \n" |
| 1774 | "pavgb %%xmm3,%%xmm1 \n" |
| 1775 | "psrlw $0x8,%%xmm0 \n" |
| 1776 | "psrlw $0x8,%%xmm1 \n" |
| 1777 | "packuswb %%xmm1,%%xmm0 \n" |
| 1778 | "movdqa %%xmm0,%%xmm1 \n" |
| 1779 | "pand %%xmm5,%%xmm0 \n" |
| 1780 | "packuswb %%xmm0,%%xmm0 \n" |
| 1781 | "psrlw $0x8,%%xmm1 \n" |
| 1782 | "packuswb %%xmm1,%%xmm1 \n" |
| 1783 | "movq %%xmm0,(%1) \n" |
| 1784 | "movq %%xmm1,(%1,%2) \n" |
| 1785 | "lea 0x8(%1),%1 \n" |
| 1786 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1787 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1788 | : "+r"(src_yuy2), // %0 |
| 1789 | "+r"(dst_u), // %1 |
| 1790 | "+r"(dst_y), // %2 |
| 1791 | "+r"(pix) // %3 |
| 1792 | : "r"(static_cast<intptr_t>(stride_yuy2)) // %4 |
| 1793 | : "memory", "cc" |
| 1794 | #if defined(__SSE2__) |
| 1795 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 1796 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1797 | ); |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1798 | } |
| 1799 | |
| 1800 | void UYVYToYRow_SSE2(const uint8* src_uyvy, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1801 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1802 | "1: \n" |
| 1803 | "movdqa (%0),%%xmm0 \n" |
| 1804 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1805 | "lea 0x20(%0),%0 \n" |
| 1806 | "psrlw $0x8,%%xmm0 \n" |
| 1807 | "psrlw $0x8,%%xmm1 \n" |
| 1808 | "packuswb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1809 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1810 | "movdqa %%xmm0,(%1) \n" |
| 1811 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1812 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1813 | : "+r"(src_uyvy), // %0 |
| 1814 | "+r"(dst_y), // %1 |
| 1815 | "+r"(pix) // %2 |
| 1816 | : |
| 1817 | : "memory", "cc" |
| 1818 | #if defined(__SSE2__) |
| 1819 | , "xmm0", "xmm1" |
| 1820 | #endif |
| 1821 | ); |
| 1822 | } |
| 1823 | |
| 1824 | void UYVYToUVRow_SSE2(const uint8* src_uyvy, int stride_uyvy, |
| 1825 | uint8* dst_u, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1826 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1827 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1828 | "psrlw $0x8,%%xmm5 \n" |
| 1829 | "sub %1,%2 \n" |
| 1830 | "1: \n" |
| 1831 | "movdqa (%0),%%xmm0 \n" |
| 1832 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1833 | "movdqa (%0,%4,1),%%xmm2 \n" |
| 1834 | "movdqa 0x10(%0,%4,1),%%xmm3 \n" |
| 1835 | "lea 0x20(%0),%0 \n" |
| 1836 | "pavgb %%xmm2,%%xmm0 \n" |
| 1837 | "pavgb %%xmm3,%%xmm1 \n" |
| 1838 | "pand %%xmm5,%%xmm0 \n" |
| 1839 | "pand %%xmm5,%%xmm1 \n" |
| 1840 | "packuswb %%xmm1,%%xmm0 \n" |
| 1841 | "movdqa %%xmm0,%%xmm1 \n" |
| 1842 | "pand %%xmm5,%%xmm0 \n" |
| 1843 | "packuswb %%xmm0,%%xmm0 \n" |
| 1844 | "psrlw $0x8,%%xmm1 \n" |
| 1845 | "packuswb %%xmm1,%%xmm1 \n" |
| 1846 | "movq %%xmm0,(%1) \n" |
| 1847 | "movq %%xmm1,(%1,%2) \n" |
| 1848 | "lea 0x8(%1),%1 \n" |
| 1849 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1850 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1851 | : "+r"(src_uyvy), // %0 |
| 1852 | "+r"(dst_u), // %1 |
| 1853 | "+r"(dst_y), // %2 |
| 1854 | "+r"(pix) // %3 |
| 1855 | : "r"(static_cast<intptr_t>(stride_uyvy)) // %4 |
| 1856 | : "memory", "cc" |
| 1857 | #if defined(__SSE2__) |
| 1858 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 1859 | #endif |
| 1860 | ); |
| 1861 | } |
| 1862 | |
| 1863 | void UYVYToYRow_Unaligned_SSE2(const uint8* src_uyvy, |
| 1864 | uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1865 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1866 | "1: \n" |
| 1867 | "movdqu (%0),%%xmm0 \n" |
| 1868 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1869 | "lea 0x20(%0),%0 \n" |
| 1870 | "psrlw $0x8,%%xmm0 \n" |
| 1871 | "psrlw $0x8,%%xmm1 \n" |
| 1872 | "packuswb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1873 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1874 | "movdqu %%xmm0,(%1) \n" |
| 1875 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1876 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1877 | : "+r"(src_uyvy), // %0 |
| 1878 | "+r"(dst_y), // %1 |
| 1879 | "+r"(pix) // %2 |
| 1880 | : |
| 1881 | : "memory", "cc" |
| 1882 | #if defined(__SSE2__) |
| 1883 | , "xmm0", "xmm1" |
| 1884 | #endif |
| 1885 | ); |
| 1886 | } |
| 1887 | |
| 1888 | void UYVYToUVRow_Unaligned_SSE2(const uint8* src_uyvy, int stride_uyvy, |
| 1889 | uint8* dst_u, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1890 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1891 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1892 | "psrlw $0x8,%%xmm5 \n" |
| 1893 | "sub %1,%2 \n" |
| 1894 | "1: \n" |
| 1895 | "movdqu (%0),%%xmm0 \n" |
| 1896 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1897 | "movdqu (%0,%4,1),%%xmm2 \n" |
| 1898 | "movdqu 0x10(%0,%4,1),%%xmm3 \n" |
| 1899 | "lea 0x20(%0),%0 \n" |
| 1900 | "pavgb %%xmm2,%%xmm0 \n" |
| 1901 | "pavgb %%xmm3,%%xmm1 \n" |
| 1902 | "pand %%xmm5,%%xmm0 \n" |
| 1903 | "pand %%xmm5,%%xmm1 \n" |
| 1904 | "packuswb %%xmm1,%%xmm0 \n" |
| 1905 | "movdqa %%xmm0,%%xmm1 \n" |
| 1906 | "pand %%xmm5,%%xmm0 \n" |
| 1907 | "packuswb %%xmm0,%%xmm0 \n" |
| 1908 | "psrlw $0x8,%%xmm1 \n" |
| 1909 | "packuswb %%xmm1,%%xmm1 \n" |
| 1910 | "movq %%xmm0,(%1) \n" |
| 1911 | "movq %%xmm1,(%1,%2) \n" |
| 1912 | "lea 0x8(%1),%1 \n" |
| 1913 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1914 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1915 | : "+r"(src_uyvy), // %0 |
| 1916 | "+r"(dst_u), // %1 |
| 1917 | "+r"(dst_y), // %2 |
| 1918 | "+r"(pix) // %3 |
| 1919 | : "r"(static_cast<intptr_t>(stride_uyvy)) // %4 |
| 1920 | : "memory", "cc" |
| 1921 | #if defined(__SSE2__) |
| 1922 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 1923 | #endif |
| 1924 | ); |
| 1925 | } |
fbarchard@google.com | b95dbf2 | 2012-02-11 01:18:30 +0000 | [diff] [blame] | 1926 | #endif // HAS_YUY2TOYROW_SSE2 |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1927 | |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 1928 | #ifdef HAS_ARGBBLENDROW_SSE2 |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 1929 | // Blend 8 pixels at a time |
| 1930 | // Destination aligned to 16 bytes, multiple of 4 pixels |
| 1931 | void ARGBBlendRow_Aligned_SSE2(const uint8* src_argb, uint8* dst_argb, |
| 1932 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1933 | asm volatile ( |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 1934 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 1935 | "psrlw $0xf,%%xmm7 \n" |
| 1936 | "pcmpeqb %%xmm6,%%xmm6 \n" |
| 1937 | "psrlw $0x8,%%xmm6 \n" |
fbarchard@google.com | 2217ced | 2012-03-09 22:44:57 +0000 | [diff] [blame] | 1938 | "pcmpeqb %%xmm5,%%xmm5 \n" |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 1939 | "psllw $0x8,%%xmm5 \n" |
| 1940 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 1941 | "pslld $0x18,%%xmm4 \n" |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 1942 | |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 1943 | // 8 pixel loop |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 1944 | "1: \n" |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 1945 | "movdqu (%0),%%xmm3 \n" // first 4 pixels |
| 1946 | "movdqa %%xmm3,%%xmm0 \n" |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 1947 | "pxor %%xmm4,%%xmm3 \n" |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 1948 | "movdqa (%1),%%xmm2 \n" |
| 1949 | "psrlw $0x8,%%xmm3 \n" |
| 1950 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 1951 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 1952 | "pand %%xmm6,%%xmm2 \n" |
| 1953 | "paddw %%xmm7,%%xmm3 \n" |
| 1954 | "pmullw %%xmm3,%%xmm2 \n" |
| 1955 | "movdqa (%1),%%xmm1 \n" |
| 1956 | "psrlw $0x8,%%xmm1 \n" |
| 1957 | "por %%xmm4,%%xmm0 \n" |
| 1958 | "pmullw %%xmm3,%%xmm1 \n" |
| 1959 | "movdqu 0x10(%0),%%xmm3 \n" |
| 1960 | "lea 0x20(%0),%0 \n" |
| 1961 | "psrlw $0x8,%%xmm2 \n" |
| 1962 | "paddusb %%xmm2,%%xmm0 \n" |
| 1963 | "pand %%xmm5,%%xmm1 \n" |
| 1964 | "paddusb %%xmm1,%%xmm0 \n" |
| 1965 | "sub $0x4,%2 \n" |
| 1966 | "movdqa %%xmm0,(%1) \n" |
| 1967 | "jle 9f \n" |
| 1968 | "movdqa %%xmm3,%%xmm0 \n" // next 4 pixels |
fbarchard@google.com | 976423f | 2012-03-08 18:39:39 +0000 | [diff] [blame] | 1969 | "pxor %%xmm4,%%xmm3 \n" |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 1970 | "movdqa 0x10(%1),%%xmm2 \n" |
| 1971 | "psrlw $0x8,%%xmm3 \n" |
| 1972 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 1973 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 1974 | "pand %%xmm6,%%xmm2 \n" |
| 1975 | "paddw %%xmm7,%%xmm3 \n" |
| 1976 | "pmullw %%xmm3,%%xmm2 \n" |
| 1977 | "movdqa 0x10(%1),%%xmm1 \n" |
| 1978 | "psrlw $0x8,%%xmm1 \n" |
| 1979 | "por %%xmm4,%%xmm0 \n" |
| 1980 | "pmullw %%xmm3,%%xmm1 \n" |
| 1981 | "psrlw $0x8,%%xmm2 \n" |
| 1982 | "paddusb %%xmm2,%%xmm0 \n" |
| 1983 | "pand %%xmm5,%%xmm1 \n" |
| 1984 | "paddusb %%xmm1,%%xmm0 \n" |
| 1985 | "sub $0x4,%2 \n" |
| 1986 | "movdqa %%xmm0,0x10(%1) \n" |
| 1987 | "lea 0x20(%1),%1 \n" |
| 1988 | "jg 1b \n" |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 1989 | "9: \n" |
| 1990 | : "+r"(src_argb), // %0 |
| 1991 | "+r"(dst_argb), // %1 |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 1992 | "+r"(width) // %2 |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 1993 | : |
| 1994 | : "memory", "cc" |
| 1995 | #if defined(__SSE2__) |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 1996 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 1997 | #endif |
| 1998 | ); |
| 1999 | } |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 2000 | |
| 2001 | // Blend 1 pixel at a time, unaligned |
| 2002 | void ARGBBlendRow1_SSE2(const uint8* src_argb, uint8* dst_argb, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2003 | asm volatile ( |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 2004 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 2005 | "psrlw $0xf,%%xmm7 \n" |
| 2006 | "pcmpeqb %%xmm6,%%xmm6 \n" |
| 2007 | "psrlw $0x8,%%xmm6 \n" |
| 2008 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2009 | "psllw $0x8,%%xmm5 \n" |
| 2010 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2011 | "pslld $0x18,%%xmm4 \n" |
| 2012 | |
| 2013 | // 1 pixel loop |
| 2014 | "1: \n" |
| 2015 | "movd (%0),%%xmm3 \n" |
| 2016 | "lea 0x4(%0),%0 \n" |
| 2017 | "movdqa %%xmm3,%%xmm0 \n" |
| 2018 | "pxor %%xmm4,%%xmm3 \n" |
| 2019 | "movd (%1),%%xmm2 \n" |
| 2020 | "psrlw $0x8,%%xmm3 \n" |
| 2021 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 2022 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 2023 | "pand %%xmm6,%%xmm2 \n" |
| 2024 | "paddw %%xmm7,%%xmm3 \n" |
| 2025 | "pmullw %%xmm3,%%xmm2 \n" |
| 2026 | "movd (%1),%%xmm1 \n" |
| 2027 | "psrlw $0x8,%%xmm1 \n" |
| 2028 | "por %%xmm4,%%xmm0 \n" |
| 2029 | "pmullw %%xmm3,%%xmm1 \n" |
| 2030 | "psrlw $0x8,%%xmm2 \n" |
| 2031 | "paddusb %%xmm2,%%xmm0 \n" |
| 2032 | "pand %%xmm5,%%xmm1 \n" |
| 2033 | "paddusb %%xmm1,%%xmm0 \n" |
| 2034 | "sub $0x1,%2 \n" |
| 2035 | "movd %%xmm0,(%1) \n" |
| 2036 | "lea 0x4(%1),%1 \n" |
| 2037 | "jg 1b \n" |
| 2038 | : "+r"(src_argb), // %0 |
| 2039 | "+r"(dst_argb), // %1 |
| 2040 | "+r"(width) // %2 |
| 2041 | : |
| 2042 | : "memory", "cc" |
| 2043 | #if defined(__SSE2__) |
| 2044 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 2045 | #endif |
| 2046 | ); |
| 2047 | } |
| 2048 | |
| 2049 | void ARGBBlendRow_SSE2(const uint8* src_argb, uint8* dst_argb, int width) { |
| 2050 | // Do 1 to 3 pixels to get destination aligned. |
| 2051 | if ((uintptr_t)(dst_argb) & 15) { |
| 2052 | int count = width; |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2053 | if (count > 4 && ((intptr_t)(dst_argb) & 3) == 0) { |
fbarchard@google.com | 91ab139 | 2012-03-15 19:40:07 +0000 | [diff] [blame] | 2054 | count = (-(intptr_t)(dst_argb) >> 2) & 3; |
| 2055 | } |
| 2056 | ARGBBlendRow1_SSE2(src_argb, dst_argb, count); |
| 2057 | src_argb += count * 4; |
| 2058 | dst_argb += count * 4; |
| 2059 | width -= count; |
| 2060 | } |
| 2061 | // Do multiple of 4 pixels |
| 2062 | if (width & ~3) { |
| 2063 | ARGBBlendRow_Aligned_SSE2(src_argb, dst_argb, width & ~3); |
| 2064 | } |
| 2065 | // Do remaining 1 to 3 pixels |
| 2066 | if (width & 3) { |
| 2067 | src_argb += (width & ~3) * 4; |
| 2068 | dst_argb += (width & ~3) * 4; |
| 2069 | width &= 3; |
| 2070 | ARGBBlendRow1_SSE2(src_argb, dst_argb, width); |
| 2071 | } |
| 2072 | } |
| 2073 | |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 2074 | #endif // HAS_ARGBBLENDROW_SSE2 |
| 2075 | |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 2076 | #endif // defined(__x86_64__) || defined(__i386__) |
| 2077 | |
fbarchard@google.com | fe5ff7e | 2011-12-10 07:45:58 +0000 | [diff] [blame] | 2078 | #ifdef __cplusplus |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 2079 | } // extern "C" |
fbarchard@google.com | fe5ff7e | 2011-12-10 07:45:58 +0000 | [diff] [blame] | 2080 | } // namespace libyuv |
| 2081 | #endif |