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 |
fbarchard@google.com | d2f4413 | 2012-04-04 21:53:27 +0000 | [diff] [blame] | 21 | #if !defined(YUV_DISABLE_ASM) && (defined(__x86_64__) || defined(__i386__)) |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 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" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 115 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 116 | "1: \n" |
| 117 | "movq (%0),%%xmm0 \n" |
| 118 | "lea 0x8(%0),%0 \n" |
| 119 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 120 | "movdqa %%xmm0,%%xmm1 \n" |
| 121 | "punpcklwd %%xmm0,%%xmm0 \n" |
| 122 | "punpckhwd %%xmm1,%%xmm1 \n" |
| 123 | "por %%xmm5,%%xmm0 \n" |
| 124 | "por %%xmm5,%%xmm1 \n" |
| 125 | "movdqa %%xmm0,(%1) \n" |
| 126 | "movdqa %%xmm1,0x10(%1) \n" |
| 127 | "lea 0x20(%1),%1 \n" |
| 128 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 129 | "jg 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 130 | : "+r"(src_y), // %0 |
| 131 | "+r"(dst_argb), // %1 |
| 132 | "+r"(pix) // %2 |
| 133 | : |
| 134 | : "memory", "cc" |
| 135 | #if defined(__SSE2__) |
| 136 | , "xmm0", "xmm1", "xmm5" |
| 137 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 138 | ); |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 139 | } |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 140 | |
| 141 | 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] | 142 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 143 | "movdqa %3,%%xmm5 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 144 | "sub %0,%1 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 145 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 146 | "1: \n" |
| 147 | "movdqa (%0),%%xmm0 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 148 | "pshufb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 149 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 150 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 151 | "lea 0x10(%0),%0 \n" |
| 152 | "jg 1b \n" |
| 153 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 154 | : "+r"(src_abgr), // %0 |
| 155 | "+r"(dst_argb), // %1 |
| 156 | "+r"(pix) // %2 |
| 157 | : "m"(kShuffleMaskABGRToARGB) // %3 |
| 158 | : "memory", "cc" |
| 159 | #if defined(__SSE2__) |
| 160 | , "xmm0", "xmm5" |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 161 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 162 | ); |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | 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] | 166 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 167 | "movdqa %3,%%xmm5 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 168 | "sub %0,%1 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 169 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 170 | "1: \n" |
| 171 | "movdqa (%0),%%xmm0 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 172 | "pshufb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 173 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 174 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 175 | "lea 0x10(%0),%0 \n" |
| 176 | "jg 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 177 | : "+r"(src_bgra), // %0 |
| 178 | "+r"(dst_argb), // %1 |
| 179 | "+r"(pix) // %2 |
| 180 | : "m"(kShuffleMaskBGRAToARGB) // %3 |
| 181 | : "memory", "cc" |
| 182 | #if defined(__SSE2__) |
| 183 | , "xmm0", "xmm5" |
| 184 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 185 | ); |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 186 | } |
| 187 | |
fbarchard@google.com | ba1f526 | 2012-01-12 19:22:41 +0000 | [diff] [blame] | 188 | 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] | 189 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 190 | "pcmpeqb %%xmm5,%%xmm5 \n" // generate mask 0xff000000 |
| 191 | "pslld $0x18,%%xmm5 \n" |
| 192 | "movdqa %3,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 193 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 194 | "1: \n" |
| 195 | "movdqu (%0),%%xmm0 \n" |
| 196 | "movdqu 0x10(%0),%%xmm1 \n" |
| 197 | "movdqu 0x20(%0),%%xmm3 \n" |
| 198 | "lea 0x30(%0),%0 \n" |
| 199 | "movdqa %%xmm3,%%xmm2 \n" |
| 200 | "palignr $0x8,%%xmm1,%%xmm2 \n" |
| 201 | "pshufb %%xmm4,%%xmm2 \n" |
| 202 | "por %%xmm5,%%xmm2 \n" |
| 203 | "palignr $0xc,%%xmm0,%%xmm1 \n" |
| 204 | "pshufb %%xmm4,%%xmm0 \n" |
| 205 | "movdqa %%xmm2,0x20(%1) \n" |
| 206 | "por %%xmm5,%%xmm0 \n" |
| 207 | "pshufb %%xmm4,%%xmm1 \n" |
| 208 | "movdqa %%xmm0,(%1) \n" |
| 209 | "por %%xmm5,%%xmm1 \n" |
| 210 | "palignr $0x4,%%xmm3,%%xmm3 \n" |
| 211 | "pshufb %%xmm4,%%xmm3 \n" |
| 212 | "movdqa %%xmm1,0x10(%1) \n" |
| 213 | "por %%xmm5,%%xmm3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 214 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 215 | "movdqa %%xmm3,0x30(%1) \n" |
| 216 | "lea 0x40(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 217 | "jg 1b \n" |
fbarchard@google.com | ba1f526 | 2012-01-12 19:22:41 +0000 | [diff] [blame] | 218 | : "+r"(src_rgb24), // %0 |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 219 | "+r"(dst_argb), // %1 |
| 220 | "+r"(pix) // %2 |
fbarchard@google.com | ba1f526 | 2012-01-12 19:22:41 +0000 | [diff] [blame] | 221 | : "m"(kShuffleMaskRGB24ToARGB) // %3 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 222 | : "memory", "cc" |
| 223 | #if defined(__SSE2__) |
| 224 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 225 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 226 | ); |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 227 | } |
| 228 | |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 229 | 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] | 230 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 231 | "pcmpeqb %%xmm5,%%xmm5 \n" // generate mask 0xff000000 |
| 232 | "pslld $0x18,%%xmm5 \n" |
| 233 | "movdqa %3,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 234 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 235 | "1: \n" |
| 236 | "movdqu (%0),%%xmm0 \n" |
| 237 | "movdqu 0x10(%0),%%xmm1 \n" |
| 238 | "movdqu 0x20(%0),%%xmm3 \n" |
| 239 | "lea 0x30(%0),%0 \n" |
| 240 | "movdqa %%xmm3,%%xmm2 \n" |
| 241 | "palignr $0x8,%%xmm1,%%xmm2 \n" |
| 242 | "pshufb %%xmm4,%%xmm2 \n" |
| 243 | "por %%xmm5,%%xmm2 \n" |
| 244 | "palignr $0xc,%%xmm0,%%xmm1 \n" |
| 245 | "pshufb %%xmm4,%%xmm0 \n" |
| 246 | "movdqa %%xmm2,0x20(%1) \n" |
| 247 | "por %%xmm5,%%xmm0 \n" |
| 248 | "pshufb %%xmm4,%%xmm1 \n" |
| 249 | "movdqa %%xmm0,(%1) \n" |
| 250 | "por %%xmm5,%%xmm1 \n" |
| 251 | "palignr $0x4,%%xmm3,%%xmm3 \n" |
| 252 | "pshufb %%xmm4,%%xmm3 \n" |
| 253 | "movdqa %%xmm1,0x10(%1) \n" |
| 254 | "por %%xmm5,%%xmm3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 255 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 256 | "movdqa %%xmm3,0x30(%1) \n" |
| 257 | "lea 0x40(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 258 | "jg 1b \n" |
fbarchard@google.com | 9394ed9 | 2011-10-31 21:36:47 +0000 | [diff] [blame] | 259 | : "+r"(src_raw), // %0 |
| 260 | "+r"(dst_argb), // %1 |
| 261 | "+r"(pix) // %2 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 262 | : "m"(kShuffleMaskRAWToARGB) // %3 |
| 263 | : "memory", "cc" |
| 264 | #if defined(__SSE2__) |
| 265 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 266 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 267 | ); |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 268 | } |
| 269 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 270 | void RGB565ToARGBRow_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 271 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 272 | "mov $0x1080108,%%eax \n" |
| 273 | "movd %%eax,%%xmm5 \n" |
| 274 | "pshufd $0x0,%%xmm5,%%xmm5 \n" |
| 275 | "mov $0x20082008,%%eax \n" |
| 276 | "movd %%eax,%%xmm6 \n" |
| 277 | "pshufd $0x0,%%xmm6,%%xmm6 \n" |
| 278 | "pcmpeqb %%xmm3,%%xmm3 \n" |
| 279 | "psllw $0xb,%%xmm3 \n" |
| 280 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 281 | "psllw $0xa,%%xmm4 \n" |
| 282 | "psrlw $0x5,%%xmm4 \n" |
| 283 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 284 | "psllw $0x8,%%xmm7 \n" |
| 285 | "sub %0,%1 \n" |
| 286 | "sub %0,%1 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 287 | ".p2align 4 \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 288 | "1: \n" |
| 289 | "movdqu (%0),%%xmm0 \n" |
| 290 | "movdqa %%xmm0,%%xmm1 \n" |
| 291 | "movdqa %%xmm0,%%xmm2 \n" |
| 292 | "pand %%xmm3,%%xmm1 \n" |
| 293 | "psllw $0xb,%%xmm2 \n" |
| 294 | "pmulhuw %%xmm5,%%xmm1 \n" |
| 295 | "pmulhuw %%xmm5,%%xmm2 \n" |
| 296 | "psllw $0x8,%%xmm1 \n" |
| 297 | "por %%xmm2,%%xmm1 \n" |
| 298 | "pand %%xmm4,%%xmm0 \n" |
| 299 | "pmulhuw %%xmm6,%%xmm0 \n" |
| 300 | "por %%xmm7,%%xmm0 \n" |
| 301 | "movdqa %%xmm1,%%xmm2 \n" |
| 302 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 303 | "punpckhbw %%xmm0,%%xmm2 \n" |
| 304 | "movdqa %%xmm1,(%1,%0,2) \n" |
| 305 | "movdqa %%xmm2,0x10(%1,%0,2) \n" |
| 306 | "lea 0x10(%0),%0 \n" |
| 307 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 308 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 309 | : "+r"(src), // %0 |
| 310 | "+r"(dst), // %1 |
| 311 | "+r"(pix) // %2 |
| 312 | : |
| 313 | : "memory", "cc", "eax" |
| 314 | #if defined(__SSE2__) |
| 315 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 316 | #endif |
| 317 | ); |
| 318 | } |
| 319 | |
| 320 | void ARGB1555ToARGBRow_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 321 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 322 | "mov $0x1080108,%%eax \n" |
| 323 | "movd %%eax,%%xmm5 \n" |
| 324 | "pshufd $0x0,%%xmm5,%%xmm5 \n" |
| 325 | "mov $0x42004200,%%eax \n" |
| 326 | "movd %%eax,%%xmm6 \n" |
| 327 | "pshufd $0x0,%%xmm6,%%xmm6 \n" |
| 328 | "pcmpeqb %%xmm3,%%xmm3 \n" |
| 329 | "psllw $0xb,%%xmm3 \n" |
| 330 | "movdqa %%xmm3,%%xmm4 \n" |
| 331 | "psrlw $0x6,%%xmm4 \n" |
| 332 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 333 | "psllw $0x8,%%xmm7 \n" |
| 334 | "sub %0,%1 \n" |
| 335 | "sub %0,%1 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 336 | ".p2align 4 \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 337 | "1: \n" |
| 338 | "movdqu (%0),%%xmm0 \n" |
| 339 | "movdqa %%xmm0,%%xmm1 \n" |
| 340 | "movdqa %%xmm0,%%xmm2 \n" |
| 341 | "psllw $0x1,%%xmm1 \n" |
| 342 | "psllw $0xb,%%xmm2 \n" |
| 343 | "pand %%xmm3,%%xmm1 \n" |
| 344 | "pmulhuw %%xmm5,%%xmm2 \n" |
| 345 | "pmulhuw %%xmm5,%%xmm1 \n" |
| 346 | "psllw $0x8,%%xmm1 \n" |
| 347 | "por %%xmm2,%%xmm1 \n" |
| 348 | "movdqa %%xmm0,%%xmm2 \n" |
| 349 | "pand %%xmm4,%%xmm0 \n" |
| 350 | "psraw $0x8,%%xmm2 \n" |
| 351 | "pmulhuw %%xmm6,%%xmm0 \n" |
| 352 | "pand %%xmm7,%%xmm2 \n" |
| 353 | "por %%xmm2,%%xmm0 \n" |
| 354 | "movdqa %%xmm1,%%xmm2 \n" |
| 355 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 356 | "punpckhbw %%xmm0,%%xmm2 \n" |
| 357 | "movdqa %%xmm1,(%1,%0,2) \n" |
| 358 | "movdqa %%xmm2,0x10(%1,%0,2) \n" |
| 359 | "lea 0x10(%0),%0 \n" |
| 360 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 361 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 362 | : "+r"(src), // %0 |
| 363 | "+r"(dst), // %1 |
| 364 | "+r"(pix) // %2 |
| 365 | : |
| 366 | : "memory", "cc", "eax" |
| 367 | #if defined(__SSE2__) |
| 368 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 369 | #endif |
| 370 | ); |
| 371 | } |
| 372 | |
| 373 | void ARGB4444ToARGBRow_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 374 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 375 | "mov $0xf0f0f0f,%%eax \n" |
| 376 | "movd %%eax,%%xmm4 \n" |
| 377 | "pshufd $0x0,%%xmm4,%%xmm4 \n" |
| 378 | "movdqa %%xmm4,%%xmm5 \n" |
| 379 | "pslld $0x4,%%xmm5 \n" |
| 380 | "sub %0,%1 \n" |
| 381 | "sub %0,%1 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 382 | ".p2align 4 \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 383 | "1: \n" |
| 384 | "movdqu (%0),%%xmm0 \n" |
| 385 | "movdqa %%xmm0,%%xmm2 \n" |
| 386 | "pand %%xmm4,%%xmm0 \n" |
| 387 | "pand %%xmm5,%%xmm2 \n" |
| 388 | "movdqa %%xmm0,%%xmm1 \n" |
| 389 | "movdqa %%xmm2,%%xmm3 \n" |
| 390 | "psllw $0x4,%%xmm1 \n" |
| 391 | "psrlw $0x4,%%xmm3 \n" |
| 392 | "por %%xmm1,%%xmm0 \n" |
| 393 | "por %%xmm3,%%xmm2 \n" |
| 394 | "movdqa %%xmm0,%%xmm1 \n" |
| 395 | "punpcklbw %%xmm2,%%xmm0 \n" |
| 396 | "punpckhbw %%xmm2,%%xmm1 \n" |
| 397 | "movdqa %%xmm0,(%1,%0,2) \n" |
| 398 | "movdqa %%xmm1,0x10(%1,%0,2) \n" |
| 399 | "lea 0x10(%0),%0 \n" |
| 400 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 401 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 402 | : "+r"(src), // %0 |
| 403 | "+r"(dst), // %1 |
| 404 | "+r"(pix) // %2 |
| 405 | : |
| 406 | : "memory", "cc", "eax" |
| 407 | #if defined(__SSE2__) |
| 408 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 409 | #endif |
| 410 | ); |
| 411 | } |
| 412 | |
| 413 | void ARGBToRGB24Row_SSSE3(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 414 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 415 | "movdqa %3,%%xmm6 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 416 | ".p2align 4 \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 417 | "1: \n" |
| 418 | "movdqa (%0),%%xmm0 \n" |
| 419 | "movdqa 0x10(%0),%%xmm1 \n" |
| 420 | "movdqa 0x20(%0),%%xmm2 \n" |
| 421 | "movdqa 0x30(%0),%%xmm3 \n" |
| 422 | "lea 0x40(%0),%0 \n" |
| 423 | "pshufb %%xmm6,%%xmm0 \n" |
| 424 | "pshufb %%xmm6,%%xmm1 \n" |
| 425 | "pshufb %%xmm6,%%xmm2 \n" |
| 426 | "pshufb %%xmm6,%%xmm3 \n" |
| 427 | "movdqa %%xmm1,%%xmm4 \n" |
| 428 | "psrldq $0x4,%%xmm1 \n" |
| 429 | "pslldq $0xc,%%xmm4 \n" |
| 430 | "movdqa %%xmm2,%%xmm5 \n" |
| 431 | "por %%xmm4,%%xmm0 \n" |
| 432 | "pslldq $0x8,%%xmm5 \n" |
| 433 | "movdqa %%xmm0,(%1) \n" |
| 434 | "por %%xmm5,%%xmm1 \n" |
| 435 | "psrldq $0x8,%%xmm2 \n" |
| 436 | "pslldq $0x4,%%xmm3 \n" |
| 437 | "por %%xmm3,%%xmm2 \n" |
| 438 | "movdqa %%xmm1,0x10(%1) \n" |
| 439 | "movdqa %%xmm2,0x20(%1) \n" |
| 440 | "lea 0x30(%1),%1 \n" |
| 441 | "sub $0x10,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 442 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 443 | : "+r"(src), // %0 |
| 444 | "+r"(dst), // %1 |
| 445 | "+r"(pix) // %2 |
| 446 | : "m"(kShuffleMaskARGBToRGB24) // %3 |
| 447 | : "memory", "cc" |
| 448 | #if defined(__SSE2__) |
| 449 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6" |
| 450 | #endif |
| 451 | ); |
| 452 | } |
| 453 | |
| 454 | void ARGBToRAWRow_SSSE3(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 455 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 456 | "movdqa %3,%%xmm6 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 457 | ".p2align 4 \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 458 | "1: \n" |
| 459 | "movdqa (%0),%%xmm0 \n" |
| 460 | "movdqa 0x10(%0),%%xmm1 \n" |
| 461 | "movdqa 0x20(%0),%%xmm2 \n" |
| 462 | "movdqa 0x30(%0),%%xmm3 \n" |
| 463 | "lea 0x40(%0),%0 \n" |
| 464 | "pshufb %%xmm6,%%xmm0 \n" |
| 465 | "pshufb %%xmm6,%%xmm1 \n" |
| 466 | "pshufb %%xmm6,%%xmm2 \n" |
| 467 | "pshufb %%xmm6,%%xmm3 \n" |
| 468 | "movdqa %%xmm1,%%xmm4 \n" |
| 469 | "psrldq $0x4,%%xmm1 \n" |
| 470 | "pslldq $0xc,%%xmm4 \n" |
| 471 | "movdqa %%xmm2,%%xmm5 \n" |
| 472 | "por %%xmm4,%%xmm0 \n" |
| 473 | "pslldq $0x8,%%xmm5 \n" |
| 474 | "movdqa %%xmm0,(%1) \n" |
| 475 | "por %%xmm5,%%xmm1 \n" |
| 476 | "psrldq $0x8,%%xmm2 \n" |
| 477 | "pslldq $0x4,%%xmm3 \n" |
| 478 | "por %%xmm3,%%xmm2 \n" |
| 479 | "movdqa %%xmm1,0x10(%1) \n" |
| 480 | "movdqa %%xmm2,0x20(%1) \n" |
| 481 | "lea 0x30(%1),%1 \n" |
| 482 | "sub $0x10,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 483 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 484 | : "+r"(src), // %0 |
| 485 | "+r"(dst), // %1 |
| 486 | "+r"(pix) // %2 |
| 487 | : "m"(kShuffleMaskARGBToRAW) // %3 |
| 488 | : "memory", "cc" |
| 489 | #if defined(__SSE2__) |
| 490 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6" |
| 491 | #endif |
| 492 | ); |
| 493 | } |
| 494 | |
| 495 | void ARGBToRGB565Row_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 496 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 497 | "pcmpeqb %%xmm3,%%xmm3 \n" |
| 498 | "psrld $0x1b,%%xmm3 \n" |
| 499 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 500 | "psrld $0x1a,%%xmm4 \n" |
| 501 | "pslld $0x5,%%xmm4 \n" |
| 502 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 503 | "pslld $0xb,%%xmm5 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 504 | ".p2align 4 \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 505 | "1: \n" |
| 506 | "movdqa (%0),%%xmm0 \n" |
| 507 | "movdqa %%xmm0,%%xmm1 \n" |
| 508 | "movdqa %%xmm0,%%xmm2 \n" |
| 509 | "pslld $0x8,%%xmm0 \n" |
| 510 | "psrld $0x3,%%xmm1 \n" |
| 511 | "psrld $0x5,%%xmm2 \n" |
| 512 | "psrad $0x10,%%xmm0 \n" |
| 513 | "pand %%xmm3,%%xmm1 \n" |
| 514 | "pand %%xmm4,%%xmm2 \n" |
| 515 | "pand %%xmm5,%%xmm0 \n" |
| 516 | "por %%xmm2,%%xmm1 \n" |
| 517 | "por %%xmm1,%%xmm0 \n" |
| 518 | "packssdw %%xmm0,%%xmm0 \n" |
| 519 | "lea 0x10(%0),%0 \n" |
| 520 | "movq %%xmm0,(%1) \n" |
| 521 | "lea 0x8(%1),%1 \n" |
| 522 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 523 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 524 | : "+r"(src), // %0 |
| 525 | "+r"(dst), // %1 |
| 526 | "+r"(pix) // %2 |
| 527 | : |
| 528 | : "memory", "cc" |
| 529 | #if defined(__SSE2__) |
| 530 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 531 | #endif |
| 532 | ); |
| 533 | } |
| 534 | |
| 535 | void ARGBToARGB1555Row_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 536 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 537 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 538 | "psrld $0x1b,%%xmm4 \n" |
| 539 | "movdqa %%xmm4,%%xmm5 \n" |
| 540 | "pslld $0x5,%%xmm5 \n" |
| 541 | "movdqa %%xmm4,%%xmm6 \n" |
| 542 | "pslld $0xa,%%xmm6 \n" |
| 543 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 544 | "pslld $0xf,%%xmm7 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 545 | ".p2align 4 \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 546 | "1: \n" |
| 547 | "movdqa (%0),%%xmm0 \n" |
| 548 | "movdqa %%xmm0,%%xmm1 \n" |
| 549 | "movdqa %%xmm0,%%xmm2 \n" |
| 550 | "movdqa %%xmm0,%%xmm3 \n" |
| 551 | "psrad $0x10,%%xmm0 \n" |
| 552 | "psrld $0x3,%%xmm1 \n" |
| 553 | "psrld $0x6,%%xmm2 \n" |
| 554 | "psrld $0x9,%%xmm3 \n" |
| 555 | "pand %%xmm7,%%xmm0 \n" |
| 556 | "pand %%xmm4,%%xmm1 \n" |
| 557 | "pand %%xmm5,%%xmm2 \n" |
| 558 | "pand %%xmm6,%%xmm3 \n" |
| 559 | "por %%xmm1,%%xmm0 \n" |
| 560 | "por %%xmm3,%%xmm2 \n" |
| 561 | "por %%xmm2,%%xmm0 \n" |
| 562 | "packssdw %%xmm0,%%xmm0 \n" |
| 563 | "lea 0x10(%0),%0 \n" |
| 564 | "movq %%xmm0,(%1) \n" |
| 565 | "lea 0x8(%1),%1 \n" |
| 566 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 567 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 568 | : "+r"(src), // %0 |
| 569 | "+r"(dst), // %1 |
| 570 | "+r"(pix) // %2 |
| 571 | : |
| 572 | : "memory", "cc" |
| 573 | #if defined(__SSE2__) |
| 574 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 575 | #endif |
| 576 | ); |
| 577 | } |
| 578 | |
| 579 | void ARGBToARGB4444Row_SSE2(const uint8* src, uint8* dst, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 580 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 581 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 582 | "psllw $0xc,%%xmm4 \n" |
| 583 | "movdqa %%xmm4,%%xmm3 \n" |
| 584 | "psrlw $0x8,%%xmm3 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 585 | ".p2align 4 \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 586 | "1: \n" |
| 587 | "movdqa (%0),%%xmm0 \n" |
| 588 | "movdqa %%xmm0,%%xmm1 \n" |
| 589 | "pand %%xmm3,%%xmm0 \n" |
| 590 | "pand %%xmm4,%%xmm1 \n" |
| 591 | "psrlq $0x4,%%xmm0 \n" |
| 592 | "psrlq $0x8,%%xmm1 \n" |
| 593 | "por %%xmm1,%%xmm0 \n" |
| 594 | "packuswb %%xmm0,%%xmm0 \n" |
| 595 | "lea 0x10(%0),%0 \n" |
| 596 | "movq %%xmm0,(%1) \n" |
| 597 | "lea 0x8(%1),%1 \n" |
| 598 | "sub $0x4,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 599 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 600 | : "+r"(src), // %0 |
| 601 | "+r"(dst), // %1 |
| 602 | "+r"(pix) // %2 |
| 603 | : |
| 604 | : "memory", "cc" |
| 605 | #if defined(__SSE2__) |
| 606 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" |
| 607 | #endif |
| 608 | ); |
| 609 | } |
| 610 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 611 | 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] | 612 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 613 | "movdqa %4,%%xmm5 \n" |
| 614 | "movdqa %3,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 615 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 616 | "1: \n" |
| 617 | "movdqa (%0),%%xmm0 \n" |
| 618 | "movdqa 0x10(%0),%%xmm1 \n" |
| 619 | "movdqa 0x20(%0),%%xmm2 \n" |
| 620 | "movdqa 0x30(%0),%%xmm3 \n" |
| 621 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 622 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 623 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 624 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 625 | "lea 0x40(%0),%0 \n" |
| 626 | "phaddw %%xmm1,%%xmm0 \n" |
| 627 | "phaddw %%xmm3,%%xmm2 \n" |
| 628 | "psrlw $0x7,%%xmm0 \n" |
| 629 | "psrlw $0x7,%%xmm2 \n" |
| 630 | "packuswb %%xmm2,%%xmm0 \n" |
| 631 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 632 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 633 | "movdqa %%xmm0,(%1) \n" |
| 634 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 635 | "jg 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 636 | : "+r"(src_argb), // %0 |
| 637 | "+r"(dst_y), // %1 |
| 638 | "+r"(pix) // %2 |
| 639 | : "m"(kARGBToY), // %3 |
| 640 | "m"(kAddY16) // %4 |
| 641 | : "memory", "cc" |
| 642 | #if defined(__SSE2__) |
| 643 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 644 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 645 | ); |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 646 | } |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 647 | |
| 648 | 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] | 649 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 650 | "movdqa %4,%%xmm5 \n" |
| 651 | "movdqa %3,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 652 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 653 | "1: \n" |
| 654 | "movdqu (%0),%%xmm0 \n" |
| 655 | "movdqu 0x10(%0),%%xmm1 \n" |
| 656 | "movdqu 0x20(%0),%%xmm2 \n" |
| 657 | "movdqu 0x30(%0),%%xmm3 \n" |
| 658 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 659 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 660 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 661 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 662 | "lea 0x40(%0),%0 \n" |
| 663 | "phaddw %%xmm1,%%xmm0 \n" |
| 664 | "phaddw %%xmm3,%%xmm2 \n" |
| 665 | "psrlw $0x7,%%xmm0 \n" |
| 666 | "psrlw $0x7,%%xmm2 \n" |
| 667 | "packuswb %%xmm2,%%xmm0 \n" |
| 668 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 669 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 670 | "movdqu %%xmm0,(%1) \n" |
| 671 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 672 | "jg 1b \n" |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 673 | : "+r"(src_argb), // %0 |
| 674 | "+r"(dst_y), // %1 |
| 675 | "+r"(pix) // %2 |
| 676 | : "m"(kARGBToY), // %3 |
| 677 | "m"(kAddY16) // %4 |
| 678 | : "memory", "cc" |
| 679 | #if defined(__SSE2__) |
| 680 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 681 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 682 | ); |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 683 | } |
fbarchard@google.com | 585a126 | 2011-10-28 23:51:08 +0000 | [diff] [blame] | 684 | |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 685 | // TODO(fbarchard): pass xmm constants to single block of assembly. |
| 686 | // fpic on GCC 4.2 for OSX runs out of GPR registers. "m" effectively takes |
| 687 | // 3 registers - ebx, ebp and eax. "m" can be passed with 3 normal registers, |
| 688 | // or 4 if stack frame is disabled. Doing 2 assembly blocks is a work around |
| 689 | // and considered unsafe. |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 690 | void ARGBToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb, |
| 691 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 692 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 693 | "movdqa %0,%%xmm4 \n" |
| 694 | "movdqa %1,%%xmm3 \n" |
| 695 | "movdqa %2,%%xmm5 \n" |
fbarchard@google.com | d93d448 | 2011-11-10 18:26:20 +0000 | [diff] [blame] | 696 | : |
fbarchard@google.com | f2d84dd | 2012-05-14 20:23:35 +0000 | [diff] [blame^] | 697 | : "m"(kARGBToU), // %0 |
| 698 | "m"(kARGBToV), // %1 |
| 699 | "m"(kAddUV128) // %2 |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 700 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 701 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 702 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 703 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 704 | "1: \n" |
| 705 | "movdqa (%0),%%xmm0 \n" |
| 706 | "movdqa 0x10(%0),%%xmm1 \n" |
| 707 | "movdqa 0x20(%0),%%xmm2 \n" |
| 708 | "movdqa 0x30(%0),%%xmm6 \n" |
| 709 | "pavgb (%0,%4,1),%%xmm0 \n" |
| 710 | "pavgb 0x10(%0,%4,1),%%xmm1 \n" |
| 711 | "pavgb 0x20(%0,%4,1),%%xmm2 \n" |
| 712 | "pavgb 0x30(%0,%4,1),%%xmm6 \n" |
| 713 | "lea 0x40(%0),%0 \n" |
| 714 | "movdqa %%xmm0,%%xmm7 \n" |
| 715 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 716 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 717 | "pavgb %%xmm7,%%xmm0 \n" |
| 718 | "movdqa %%xmm2,%%xmm7 \n" |
| 719 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 720 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 721 | "pavgb %%xmm7,%%xmm2 \n" |
| 722 | "movdqa %%xmm0,%%xmm1 \n" |
| 723 | "movdqa %%xmm2,%%xmm6 \n" |
| 724 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 725 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 726 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 727 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 728 | "phaddw %%xmm2,%%xmm0 \n" |
| 729 | "phaddw %%xmm6,%%xmm1 \n" |
| 730 | "psraw $0x8,%%xmm0 \n" |
| 731 | "psraw $0x8,%%xmm1 \n" |
| 732 | "packsswb %%xmm1,%%xmm0 \n" |
| 733 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 734 | "sub $0x10,%3 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 735 | "movlps %%xmm0,(%1) \n" |
| 736 | "movhps %%xmm0,(%1,%2,1) \n" |
| 737 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 738 | "jg 1b \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 739 | : "+r"(src_argb0), // %0 |
| 740 | "+r"(dst_u), // %1 |
| 741 | "+r"(dst_v), // %2 |
| 742 | "+rm"(width) // %3 |
fbarchard@google.com | d93d448 | 2011-11-10 18:26:20 +0000 | [diff] [blame] | 743 | : "r"(static_cast<intptr_t>(src_stride_argb)) |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 744 | : "memory", "cc" |
| 745 | #if defined(__SSE2__) |
fbarchard@google.com | d93d448 | 2011-11-10 18:26:20 +0000 | [diff] [blame] | 746 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 747 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 748 | ); |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 749 | } |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 750 | |
| 751 | void ARGBToUVRow_Unaligned_SSSE3(const uint8* src_argb0, int src_stride_argb, |
| 752 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 753 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 754 | "movdqa %0,%%xmm4 \n" |
| 755 | "movdqa %1,%%xmm3 \n" |
| 756 | "movdqa %2,%%xmm5 \n" |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 757 | : |
| 758 | : "m"(kARGBToU), // %0 |
| 759 | "m"(kARGBToV), // %1 |
| 760 | "m"(kAddUV128) // %2 |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 761 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 762 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 763 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 764 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 765 | "1: \n" |
| 766 | "movdqu (%0),%%xmm0 \n" |
| 767 | "movdqu 0x10(%0),%%xmm1 \n" |
| 768 | "movdqu 0x20(%0),%%xmm2 \n" |
| 769 | "movdqu 0x30(%0),%%xmm6 \n" |
| 770 | "movdqu (%0,%4,1),%%xmm7 \n" |
| 771 | "pavgb %%xmm7,%%xmm0 \n" |
| 772 | "movdqu 0x10(%0,%4,1),%%xmm7 \n" |
| 773 | "pavgb %%xmm7,%%xmm1 \n" |
| 774 | "movdqu 0x20(%0,%4,1),%%xmm7 \n" |
| 775 | "pavgb %%xmm7,%%xmm2 \n" |
| 776 | "movdqu 0x30(%0,%4,1),%%xmm7 \n" |
| 777 | "pavgb %%xmm7,%%xmm6 \n" |
| 778 | "lea 0x40(%0),%0 \n" |
| 779 | "movdqa %%xmm0,%%xmm7 \n" |
| 780 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 781 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 782 | "pavgb %%xmm7,%%xmm0 \n" |
| 783 | "movdqa %%xmm2,%%xmm7 \n" |
| 784 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 785 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 786 | "pavgb %%xmm7,%%xmm2 \n" |
| 787 | "movdqa %%xmm0,%%xmm1 \n" |
| 788 | "movdqa %%xmm2,%%xmm6 \n" |
| 789 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 790 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 791 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 792 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 793 | "phaddw %%xmm2,%%xmm0 \n" |
| 794 | "phaddw %%xmm6,%%xmm1 \n" |
| 795 | "psraw $0x8,%%xmm0 \n" |
| 796 | "psraw $0x8,%%xmm1 \n" |
| 797 | "packsswb %%xmm1,%%xmm0 \n" |
| 798 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 799 | "sub $0x10,%3 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 800 | "movlps %%xmm0,(%1) \n" |
| 801 | "movhps %%xmm0,(%1,%2,1) \n" |
| 802 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 803 | "jg 1b \n" |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 804 | : "+r"(src_argb0), // %0 |
| 805 | "+r"(dst_u), // %1 |
| 806 | "+r"(dst_v), // %2 |
| 807 | "+rm"(width) // %3 |
| 808 | : "r"(static_cast<intptr_t>(src_stride_argb)) |
| 809 | : "memory", "cc" |
| 810 | #if defined(__SSE2__) |
| 811 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 812 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 813 | ); |
fbarchard@google.com | b5b27d1 | 2012-01-28 08:44:35 +0000 | [diff] [blame] | 814 | } |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 815 | |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 816 | 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] | 817 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 818 | "movdqa %4,%%xmm5 \n" |
| 819 | "movdqa %3,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 820 | ".p2align 4 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 821 | "1: \n" |
| 822 | "movdqa (%0),%%xmm0 \n" |
| 823 | "movdqa 0x10(%0),%%xmm1 \n" |
| 824 | "movdqa 0x20(%0),%%xmm2 \n" |
| 825 | "movdqa 0x30(%0),%%xmm3 \n" |
| 826 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 827 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 828 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 829 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 830 | "lea 0x40(%0),%0 \n" |
| 831 | "phaddw %%xmm1,%%xmm0 \n" |
| 832 | "phaddw %%xmm3,%%xmm2 \n" |
| 833 | "psrlw $0x7,%%xmm0 \n" |
| 834 | "psrlw $0x7,%%xmm2 \n" |
| 835 | "packuswb %%xmm2,%%xmm0 \n" |
| 836 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 837 | "sub $0x10,%2 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 838 | "movdqa %%xmm0,(%1) \n" |
| 839 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 840 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 841 | : "+r"(src_bgra), // %0 |
| 842 | "+r"(dst_y), // %1 |
| 843 | "+r"(pix) // %2 |
| 844 | : "m"(kBGRAToY), // %3 |
| 845 | "m"(kAddY16) // %4 |
| 846 | : "memory", "cc" |
| 847 | #if defined(__SSE2__) |
| 848 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 849 | #endif |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 850 | ); |
| 851 | } |
| 852 | |
| 853 | 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] | 854 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 855 | "movdqa %4,%%xmm5 \n" |
| 856 | "movdqa %3,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 857 | ".p2align 4 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 858 | "1: \n" |
| 859 | "movdqu (%0),%%xmm0 \n" |
| 860 | "movdqu 0x10(%0),%%xmm1 \n" |
| 861 | "movdqu 0x20(%0),%%xmm2 \n" |
| 862 | "movdqu 0x30(%0),%%xmm3 \n" |
| 863 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 864 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 865 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 866 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 867 | "lea 0x40(%0),%0 \n" |
| 868 | "phaddw %%xmm1,%%xmm0 \n" |
| 869 | "phaddw %%xmm3,%%xmm2 \n" |
| 870 | "psrlw $0x7,%%xmm0 \n" |
| 871 | "psrlw $0x7,%%xmm2 \n" |
| 872 | "packuswb %%xmm2,%%xmm0 \n" |
| 873 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 874 | "sub $0x10,%2 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 875 | "movdqu %%xmm0,(%1) \n" |
| 876 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 877 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 878 | : "+r"(src_bgra), // %0 |
| 879 | "+r"(dst_y), // %1 |
| 880 | "+r"(pix) // %2 |
| 881 | : "m"(kBGRAToY), // %3 |
| 882 | "m"(kAddY16) // %4 |
| 883 | : "memory", "cc" |
| 884 | #if defined(__SSE2__) |
| 885 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 886 | #endif |
| 887 | ); |
| 888 | } |
| 889 | |
| 890 | void BGRAToUVRow_SSSE3(const uint8* src_bgra0, int src_stride_bgra, |
| 891 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 892 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 893 | "movdqa %0,%%xmm4 \n" |
| 894 | "movdqa %1,%%xmm3 \n" |
| 895 | "movdqa %2,%%xmm5 \n" |
| 896 | : |
| 897 | : "m"(kBGRAToU), // %0 |
| 898 | "m"(kBGRAToV), // %1 |
| 899 | "m"(kAddUV128) // %2 |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 900 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 901 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 902 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 903 | ".p2align 4 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 904 | "1: \n" |
| 905 | "movdqa (%0),%%xmm0 \n" |
| 906 | "movdqa 0x10(%0),%%xmm1 \n" |
| 907 | "movdqa 0x20(%0),%%xmm2 \n" |
| 908 | "movdqa 0x30(%0),%%xmm6 \n" |
| 909 | "pavgb (%0,%4,1),%%xmm0 \n" |
| 910 | "pavgb 0x10(%0,%4,1),%%xmm1 \n" |
| 911 | "pavgb 0x20(%0,%4,1),%%xmm2 \n" |
| 912 | "pavgb 0x30(%0,%4,1),%%xmm6 \n" |
| 913 | "lea 0x40(%0),%0 \n" |
| 914 | "movdqa %%xmm0,%%xmm7 \n" |
| 915 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 916 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 917 | "pavgb %%xmm7,%%xmm0 \n" |
| 918 | "movdqa %%xmm2,%%xmm7 \n" |
| 919 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 920 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 921 | "pavgb %%xmm7,%%xmm2 \n" |
| 922 | "movdqa %%xmm0,%%xmm1 \n" |
| 923 | "movdqa %%xmm2,%%xmm6 \n" |
| 924 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 925 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 926 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 927 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 928 | "phaddw %%xmm2,%%xmm0 \n" |
| 929 | "phaddw %%xmm6,%%xmm1 \n" |
| 930 | "psraw $0x8,%%xmm0 \n" |
| 931 | "psraw $0x8,%%xmm1 \n" |
| 932 | "packsswb %%xmm1,%%xmm0 \n" |
| 933 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 934 | "sub $0x10,%3 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 935 | "movlps %%xmm0,(%1) \n" |
| 936 | "movhps %%xmm0,(%1,%2,1) \n" |
| 937 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 938 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 939 | : "+r"(src_bgra0), // %0 |
| 940 | "+r"(dst_u), // %1 |
| 941 | "+r"(dst_v), // %2 |
| 942 | "+rm"(width) // %3 |
| 943 | : "r"(static_cast<intptr_t>(src_stride_bgra)) |
| 944 | : "memory", "cc" |
| 945 | #if defined(__SSE2__) |
| 946 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 947 | #endif |
| 948 | ); |
| 949 | } |
| 950 | |
| 951 | void BGRAToUVRow_Unaligned_SSSE3(const uint8* src_bgra0, int src_stride_bgra, |
| 952 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 953 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 954 | "movdqa %0,%%xmm4 \n" |
| 955 | "movdqa %1,%%xmm3 \n" |
| 956 | "movdqa %2,%%xmm5 \n" |
| 957 | : |
| 958 | : "m"(kBGRAToU), // %0 |
| 959 | "m"(kBGRAToV), // %1 |
| 960 | "m"(kAddUV128) // %2 |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 961 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 962 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 963 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 964 | ".p2align 4 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 965 | "1: \n" |
| 966 | "movdqu (%0),%%xmm0 \n" |
| 967 | "movdqu 0x10(%0),%%xmm1 \n" |
| 968 | "movdqu 0x20(%0),%%xmm2 \n" |
| 969 | "movdqu 0x30(%0),%%xmm6 \n" |
| 970 | "movdqu (%0,%4,1),%%xmm7 \n" |
| 971 | "pavgb %%xmm7,%%xmm0 \n" |
| 972 | "movdqu 0x10(%0,%4,1),%%xmm7 \n" |
| 973 | "pavgb %%xmm7,%%xmm1 \n" |
| 974 | "movdqu 0x20(%0,%4,1),%%xmm7 \n" |
| 975 | "pavgb %%xmm7,%%xmm2 \n" |
| 976 | "movdqu 0x30(%0,%4,1),%%xmm7 \n" |
| 977 | "pavgb %%xmm7,%%xmm6 \n" |
| 978 | "lea 0x40(%0),%0 \n" |
| 979 | "movdqa %%xmm0,%%xmm7 \n" |
| 980 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 981 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 982 | "pavgb %%xmm7,%%xmm0 \n" |
| 983 | "movdqa %%xmm2,%%xmm7 \n" |
| 984 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 985 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 986 | "pavgb %%xmm7,%%xmm2 \n" |
| 987 | "movdqa %%xmm0,%%xmm1 \n" |
| 988 | "movdqa %%xmm2,%%xmm6 \n" |
| 989 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 990 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 991 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 992 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 993 | "phaddw %%xmm2,%%xmm0 \n" |
| 994 | "phaddw %%xmm6,%%xmm1 \n" |
| 995 | "psraw $0x8,%%xmm0 \n" |
| 996 | "psraw $0x8,%%xmm1 \n" |
| 997 | "packsswb %%xmm1,%%xmm0 \n" |
| 998 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 999 | "sub $0x10,%3 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1000 | "movlps %%xmm0,(%1) \n" |
| 1001 | "movhps %%xmm0,(%1,%2,1) \n" |
| 1002 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1003 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1004 | : "+r"(src_bgra0), // %0 |
| 1005 | "+r"(dst_u), // %1 |
| 1006 | "+r"(dst_v), // %2 |
| 1007 | "+rm"(width) // %3 |
| 1008 | : "r"(static_cast<intptr_t>(src_stride_bgra)) |
| 1009 | : "memory", "cc" |
| 1010 | #if defined(__SSE2__) |
| 1011 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 1012 | #endif |
| 1013 | ); |
| 1014 | } |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1015 | |
| 1016 | 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] | 1017 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1018 | "movdqa %4,%%xmm5 \n" |
| 1019 | "movdqa %3,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1020 | ".p2align 4 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1021 | "1: \n" |
| 1022 | "movdqa (%0),%%xmm0 \n" |
| 1023 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1024 | "movdqa 0x20(%0),%%xmm2 \n" |
| 1025 | "movdqa 0x30(%0),%%xmm3 \n" |
| 1026 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 1027 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 1028 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 1029 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 1030 | "lea 0x40(%0),%0 \n" |
| 1031 | "phaddw %%xmm1,%%xmm0 \n" |
| 1032 | "phaddw %%xmm3,%%xmm2 \n" |
| 1033 | "psrlw $0x7,%%xmm0 \n" |
| 1034 | "psrlw $0x7,%%xmm2 \n" |
| 1035 | "packuswb %%xmm2,%%xmm0 \n" |
| 1036 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1037 | "sub $0x10,%2 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1038 | "movdqa %%xmm0,(%1) \n" |
| 1039 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1040 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1041 | : "+r"(src_abgr), // %0 |
| 1042 | "+r"(dst_y), // %1 |
| 1043 | "+r"(pix) // %2 |
| 1044 | : "m"(kABGRToY), // %3 |
| 1045 | "m"(kAddY16) // %4 |
| 1046 | : "memory", "cc" |
| 1047 | #if defined(__SSE2__) |
| 1048 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1049 | #endif |
| 1050 | ); |
| 1051 | } |
| 1052 | |
| 1053 | 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] | 1054 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1055 | "movdqa %4,%%xmm5 \n" |
| 1056 | "movdqa %3,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1057 | ".p2align 4 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1058 | "1: \n" |
| 1059 | "movdqu (%0),%%xmm0 \n" |
| 1060 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1061 | "movdqu 0x20(%0),%%xmm2 \n" |
| 1062 | "movdqu 0x30(%0),%%xmm3 \n" |
| 1063 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 1064 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 1065 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 1066 | "pmaddubsw %%xmm4,%%xmm3 \n" |
| 1067 | "lea 0x40(%0),%0 \n" |
| 1068 | "phaddw %%xmm1,%%xmm0 \n" |
| 1069 | "phaddw %%xmm3,%%xmm2 \n" |
| 1070 | "psrlw $0x7,%%xmm0 \n" |
| 1071 | "psrlw $0x7,%%xmm2 \n" |
| 1072 | "packuswb %%xmm2,%%xmm0 \n" |
| 1073 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1074 | "sub $0x10,%2 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1075 | "movdqu %%xmm0,(%1) \n" |
| 1076 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1077 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1078 | : "+r"(src_abgr), // %0 |
| 1079 | "+r"(dst_y), // %1 |
| 1080 | "+r"(pix) // %2 |
| 1081 | : "m"(kABGRToY), // %3 |
| 1082 | "m"(kAddY16) // %4 |
| 1083 | : "memory", "cc" |
| 1084 | #if defined(__SSE2__) |
| 1085 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1086 | #endif |
| 1087 | ); |
| 1088 | } |
| 1089 | |
| 1090 | void ABGRToUVRow_SSSE3(const uint8* src_abgr0, int src_stride_abgr, |
| 1091 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1092 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1093 | "movdqa %0,%%xmm4 \n" |
| 1094 | "movdqa %1,%%xmm3 \n" |
| 1095 | "movdqa %2,%%xmm5 \n" |
| 1096 | : |
| 1097 | : "m"(kABGRToU), // %0 |
| 1098 | "m"(kABGRToV), // %1 |
| 1099 | "m"(kAddUV128) // %2 |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1100 | ); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1101 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1102 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1103 | ".p2align 4 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1104 | "1: \n" |
| 1105 | "movdqa (%0),%%xmm0 \n" |
| 1106 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1107 | "movdqa 0x20(%0),%%xmm2 \n" |
| 1108 | "movdqa 0x30(%0),%%xmm6 \n" |
| 1109 | "pavgb (%0,%4,1),%%xmm0 \n" |
| 1110 | "pavgb 0x10(%0,%4,1),%%xmm1 \n" |
| 1111 | "pavgb 0x20(%0,%4,1),%%xmm2 \n" |
| 1112 | "pavgb 0x30(%0,%4,1),%%xmm6 \n" |
| 1113 | "lea 0x40(%0),%0 \n" |
| 1114 | "movdqa %%xmm0,%%xmm7 \n" |
| 1115 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 1116 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 1117 | "pavgb %%xmm7,%%xmm0 \n" |
| 1118 | "movdqa %%xmm2,%%xmm7 \n" |
| 1119 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 1120 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 1121 | "pavgb %%xmm7,%%xmm2 \n" |
| 1122 | "movdqa %%xmm0,%%xmm1 \n" |
| 1123 | "movdqa %%xmm2,%%xmm6 \n" |
| 1124 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 1125 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 1126 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 1127 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 1128 | "phaddw %%xmm2,%%xmm0 \n" |
| 1129 | "phaddw %%xmm6,%%xmm1 \n" |
| 1130 | "psraw $0x8,%%xmm0 \n" |
| 1131 | "psraw $0x8,%%xmm1 \n" |
| 1132 | "packsswb %%xmm1,%%xmm0 \n" |
| 1133 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1134 | "sub $0x10,%3 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1135 | "movlps %%xmm0,(%1) \n" |
| 1136 | "movhps %%xmm0,(%1,%2,1) \n" |
| 1137 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1138 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1139 | : "+r"(src_abgr0), // %0 |
| 1140 | "+r"(dst_u), // %1 |
| 1141 | "+r"(dst_v), // %2 |
| 1142 | "+rm"(width) // %3 |
| 1143 | : "r"(static_cast<intptr_t>(src_stride_abgr)) |
| 1144 | : "memory", "cc" |
| 1145 | #if defined(__SSE2__) |
| 1146 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 1147 | #endif |
| 1148 | ); |
| 1149 | } |
| 1150 | |
| 1151 | void ABGRToUVRow_Unaligned_SSSE3(const uint8* src_abgr0, int src_stride_abgr, |
| 1152 | uint8* dst_u, uint8* dst_v, int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1153 | asm volatile ( |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1154 | "movdqa %0,%%xmm4 \n" |
| 1155 | "movdqa %1,%%xmm3 \n" |
| 1156 | "movdqa %2,%%xmm5 \n" |
| 1157 | : |
| 1158 | : "m"(kABGRToU), // %0 |
| 1159 | "m"(kABGRToV), // %1 |
| 1160 | "m"(kAddUV128) // %2 |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 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" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1164 | ".p2align 4 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1165 | "1: \n" |
| 1166 | "movdqu (%0),%%xmm0 \n" |
| 1167 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1168 | "movdqu 0x20(%0),%%xmm2 \n" |
| 1169 | "movdqu 0x30(%0),%%xmm6 \n" |
| 1170 | "movdqu (%0,%4,1),%%xmm7 \n" |
| 1171 | "pavgb %%xmm7,%%xmm0 \n" |
| 1172 | "movdqu 0x10(%0,%4,1),%%xmm7 \n" |
| 1173 | "pavgb %%xmm7,%%xmm1 \n" |
| 1174 | "movdqu 0x20(%0,%4,1),%%xmm7 \n" |
| 1175 | "pavgb %%xmm7,%%xmm2 \n" |
| 1176 | "movdqu 0x30(%0,%4,1),%%xmm7 \n" |
| 1177 | "pavgb %%xmm7,%%xmm6 \n" |
| 1178 | "lea 0x40(%0),%0 \n" |
| 1179 | "movdqa %%xmm0,%%xmm7 \n" |
| 1180 | "shufps $0x88,%%xmm1,%%xmm0 \n" |
| 1181 | "shufps $0xdd,%%xmm1,%%xmm7 \n" |
| 1182 | "pavgb %%xmm7,%%xmm0 \n" |
| 1183 | "movdqa %%xmm2,%%xmm7 \n" |
| 1184 | "shufps $0x88,%%xmm6,%%xmm2 \n" |
| 1185 | "shufps $0xdd,%%xmm6,%%xmm7 \n" |
| 1186 | "pavgb %%xmm7,%%xmm2 \n" |
| 1187 | "movdqa %%xmm0,%%xmm1 \n" |
| 1188 | "movdqa %%xmm2,%%xmm6 \n" |
| 1189 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 1190 | "pmaddubsw %%xmm4,%%xmm2 \n" |
| 1191 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 1192 | "pmaddubsw %%xmm3,%%xmm6 \n" |
| 1193 | "phaddw %%xmm2,%%xmm0 \n" |
| 1194 | "phaddw %%xmm6,%%xmm1 \n" |
| 1195 | "psraw $0x8,%%xmm0 \n" |
| 1196 | "psraw $0x8,%%xmm1 \n" |
| 1197 | "packsswb %%xmm1,%%xmm0 \n" |
| 1198 | "paddb %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1199 | "sub $0x10,%3 \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1200 | "movlps %%xmm0,(%1) \n" |
| 1201 | "movhps %%xmm0,(%1,%2,1) \n" |
| 1202 | "lea 0x8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1203 | "jg 1b \n" |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1204 | : "+r"(src_abgr0), // %0 |
| 1205 | "+r"(dst_u), // %1 |
| 1206 | "+r"(dst_v), // %2 |
| 1207 | "+rm"(width) // %3 |
| 1208 | : "r"(static_cast<intptr_t>(src_stride_abgr)) |
| 1209 | : "memory", "cc" |
| 1210 | #if defined(__SSE2__) |
| 1211 | , "xmm0", "xmm1", "xmm2", "xmm6", "xmm7" |
| 1212 | #endif |
| 1213 | ); |
| 1214 | } |
fbarchard@google.com | 714050a | 2012-02-17 22:59:56 +0000 | [diff] [blame] | 1215 | |
| 1216 | #endif // HAS_ARGBTOYROW_SSSE3 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1217 | |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1218 | #ifdef HAS_I420TOARGBROW_SSSE3 |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1219 | #define UB 127 /* min(63,static_cast<int8>(2.018 * 64)) */ |
| 1220 | #define UG -25 /* static_cast<int8>(-0.391 * 64 - 0.5) */ |
| 1221 | #define UR 0 |
| 1222 | |
| 1223 | #define VB 0 |
| 1224 | #define VG -52 /* static_cast<int8>(-0.813 * 64 - 0.5) */ |
| 1225 | #define VR 102 /* static_cast<int8>(1.596 * 64 + 0.5) */ |
| 1226 | |
| 1227 | // Bias |
| 1228 | #define BB UB * 128 + VB * 128 |
| 1229 | #define BG UG * 128 + VG * 128 |
| 1230 | #define BR UR * 128 + VR * 128 |
| 1231 | |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1232 | #define YG 74 /* static_cast<int8>(1.164 * 64 + 0.5) */ |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1233 | |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1234 | #if defined(__APPLE__) || defined(__x86_64__) |
| 1235 | #define OMITFP |
| 1236 | #else |
| 1237 | #define OMITFP __attribute__((optimize("omit-frame-pointer"))) |
| 1238 | #endif |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 1239 | |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1240 | struct { |
| 1241 | vec8 kUVToB; |
| 1242 | vec8 kUVToG; |
| 1243 | vec8 kUVToR; |
| 1244 | vec16 kUVBiasB; |
| 1245 | vec16 kUVBiasG; |
| 1246 | vec16 kUVBiasR; |
| 1247 | vec16 kYSub16; |
| 1248 | vec16 kYToRgb; |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1249 | } CONST SIMD_ALIGNED(kYuvConstants) = { |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1250 | { UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB }, |
| 1251 | { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG }, |
| 1252 | { UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR }, |
| 1253 | { BB, BB, BB, BB, BB, BB, BB, BB }, |
| 1254 | { BG, BG, BG, BG, BG, BG, BG, BG }, |
| 1255 | { BR, BR, BR, BR, BR, BR, BR, BR }, |
| 1256 | { 16, 16, 16, 16, 16, 16, 16, 16 }, |
| 1257 | { YG, YG, YG, YG, YG, YG, YG, YG } |
| 1258 | }; |
| 1259 | |
| 1260 | // Convert 8 pixels |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1261 | #define YUVTORGB \ |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1262 | "movd (%1),%%xmm0 \n" \ |
| 1263 | "movd (%1,%2,1),%%xmm1 \n" \ |
| 1264 | "lea 0x4(%1),%1 \n" \ |
| 1265 | "punpcklbw %%xmm1,%%xmm0 \n" \ |
| 1266 | "punpcklwd %%xmm0,%%xmm0 \n" \ |
| 1267 | "movdqa %%xmm0,%%xmm1 \n" \ |
| 1268 | "movdqa %%xmm0,%%xmm2 \n" \ |
| 1269 | "pmaddubsw (%5),%%xmm0 \n" \ |
| 1270 | "pmaddubsw 16(%5),%%xmm1 \n" \ |
| 1271 | "pmaddubsw 32(%5),%%xmm2 \n" \ |
| 1272 | "psubw 48(%5),%%xmm0 \n" \ |
| 1273 | "psubw 64(%5),%%xmm1 \n" \ |
| 1274 | "psubw 80(%5),%%xmm2 \n" \ |
| 1275 | "movq (%0),%%xmm3 \n" \ |
| 1276 | "lea 0x8(%0),%0 \n" \ |
| 1277 | "punpcklbw %%xmm4,%%xmm3 \n" \ |
| 1278 | "psubsw 96(%5),%%xmm3 \n" \ |
| 1279 | "pmullw 112(%5),%%xmm3 \n" \ |
| 1280 | "paddsw %%xmm3,%%xmm0 \n" \ |
| 1281 | "paddsw %%xmm3,%%xmm1 \n" \ |
| 1282 | "paddsw %%xmm3,%%xmm2 \n" \ |
| 1283 | "psraw $0x6,%%xmm0 \n" \ |
| 1284 | "psraw $0x6,%%xmm1 \n" \ |
| 1285 | "psraw $0x6,%%xmm2 \n" \ |
| 1286 | "packuswb %%xmm0,%%xmm0 \n" \ |
| 1287 | "packuswb %%xmm1,%%xmm1 \n" \ |
| 1288 | "packuswb %%xmm2,%%xmm2 \n" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1289 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1290 | void OMITFP I420ToARGBRow_SSSE3(const uint8* y_buf, |
| 1291 | const uint8* u_buf, |
| 1292 | const uint8* v_buf, |
| 1293 | uint8* rgb_buf, |
| 1294 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1295 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1296 | "sub %1,%2 \n" |
| 1297 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1298 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1299 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1300 | "1: \n" |
| 1301 | YUVTORGB |
| 1302 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1303 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1304 | "movdqa %%xmm0,%%xmm1 \n" |
| 1305 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1306 | "punpckhwd %%xmm2,%%xmm1 \n" |
| 1307 | "movdqa %%xmm0,(%3) \n" |
| 1308 | "movdqa %%xmm1,0x10(%3) \n" |
| 1309 | "lea 0x20(%3),%3 \n" |
| 1310 | "sub $0x8,%4 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1311 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1312 | : "+r"(y_buf), // %0 |
| 1313 | "+r"(u_buf), // %1 |
| 1314 | "+r"(v_buf), // %2 |
| 1315 | "+r"(rgb_buf), // %3 |
| 1316 | "+rm"(width) // %4 |
| 1317 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1318 | : "memory", "cc" |
| 1319 | #if defined(__SSE2__) |
| 1320 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1321 | #endif |
| 1322 | ); |
| 1323 | } |
| 1324 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1325 | void OMITFP I420ToBGRARow_SSSE3(const uint8* y_buf, |
| 1326 | const uint8* u_buf, |
| 1327 | const uint8* v_buf, |
| 1328 | uint8* rgb_buf, |
| 1329 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1330 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1331 | "sub %1,%2 \n" |
| 1332 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1333 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1334 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1335 | "1: \n" |
| 1336 | YUVTORGB |
| 1337 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1338 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 1339 | "punpcklbw %%xmm2,%%xmm5 \n" |
| 1340 | "movdqa %%xmm5,%%xmm0 \n" |
| 1341 | "punpcklwd %%xmm1,%%xmm5 \n" |
| 1342 | "punpckhwd %%xmm1,%%xmm0 \n" |
| 1343 | "movdqa %%xmm5,(%3) \n" |
| 1344 | "movdqa %%xmm0,0x10(%3) \n" |
| 1345 | "lea 0x20(%3),%3 \n" |
| 1346 | "sub $0x8,%4 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1347 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1348 | : "+r"(y_buf), // %0 |
| 1349 | "+r"(u_buf), // %1 |
| 1350 | "+r"(v_buf), // %2 |
| 1351 | "+r"(rgb_buf), // %3 |
| 1352 | "+rm"(width) // %4 |
| 1353 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1354 | : "memory", "cc" |
| 1355 | #if defined(__SSE2__) |
| 1356 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1357 | #endif |
| 1358 | ); |
| 1359 | } |
| 1360 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1361 | void OMITFP I420ToABGRRow_SSSE3(const uint8* y_buf, |
| 1362 | const uint8* u_buf, |
| 1363 | const uint8* v_buf, |
| 1364 | uint8* rgb_buf, |
| 1365 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1366 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1367 | "sub %1,%2 \n" |
| 1368 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1369 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1370 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1371 | "1: \n" |
| 1372 | YUVTORGB |
| 1373 | "punpcklbw %%xmm1,%%xmm2 \n" |
| 1374 | "punpcklbw %%xmm5,%%xmm0 \n" |
| 1375 | "movdqa %%xmm2,%%xmm1 \n" |
| 1376 | "punpcklwd %%xmm0,%%xmm2 \n" |
| 1377 | "punpckhwd %%xmm0,%%xmm1 \n" |
| 1378 | "movdqa %%xmm2,(%3) \n" |
| 1379 | "movdqa %%xmm1,0x10(%3) \n" |
| 1380 | "lea 0x20(%3),%3 \n" |
| 1381 | "sub $0x8,%4 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1382 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1383 | : "+r"(y_buf), // %0 |
| 1384 | "+r"(u_buf), // %1 |
| 1385 | "+r"(v_buf), // %2 |
| 1386 | "+r"(rgb_buf), // %3 |
| 1387 | "+rm"(width) // %4 |
| 1388 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1389 | : "memory", "cc" |
| 1390 | #if defined(__SSE2__) |
| 1391 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1392 | #endif |
| 1393 | ); |
| 1394 | } |
| 1395 | |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1396 | void OMITFP I420ToARGBRow_Unaligned_SSSE3(const uint8* y_buf, |
| 1397 | const uint8* u_buf, |
| 1398 | const uint8* v_buf, |
| 1399 | uint8* rgb_buf, |
| 1400 | int width) { |
| 1401 | asm volatile ( |
| 1402 | "sub %1,%2 \n" |
| 1403 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1404 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1405 | ".p2align 4 \n" |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1406 | "1: \n" |
| 1407 | YUVTORGB |
| 1408 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1409 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1410 | "movdqa %%xmm0,%%xmm1 \n" |
| 1411 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1412 | "punpckhwd %%xmm2,%%xmm1 \n" |
| 1413 | "movdqu %%xmm0,(%3) \n" |
| 1414 | "movdqu %%xmm1,0x10(%3) \n" |
| 1415 | "lea 0x20(%3),%3 \n" |
| 1416 | "sub $0x8,%4 \n" |
| 1417 | "jg 1b \n" |
| 1418 | : "+r"(y_buf), // %0 |
| 1419 | "+r"(u_buf), // %1 |
| 1420 | "+r"(v_buf), // %2 |
| 1421 | "+r"(rgb_buf), // %3 |
| 1422 | "+rm"(width) // %4 |
| 1423 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1424 | : "memory", "cc" |
| 1425 | #if defined(__SSE2__) |
| 1426 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1427 | #endif |
| 1428 | ); |
| 1429 | } |
| 1430 | |
| 1431 | void OMITFP I420ToBGRARow_Unaligned_SSSE3(const uint8* y_buf, |
| 1432 | const uint8* u_buf, |
| 1433 | const uint8* v_buf, |
| 1434 | uint8* rgb_buf, |
| 1435 | int width) { |
| 1436 | asm volatile ( |
| 1437 | "sub %1,%2 \n" |
| 1438 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1439 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1440 | ".p2align 4 \n" |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1441 | "1: \n" |
| 1442 | YUVTORGB |
| 1443 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1444 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 1445 | "punpcklbw %%xmm2,%%xmm5 \n" |
| 1446 | "movdqa %%xmm5,%%xmm0 \n" |
| 1447 | "punpcklwd %%xmm1,%%xmm5 \n" |
| 1448 | "punpckhwd %%xmm1,%%xmm0 \n" |
| 1449 | "movdqu %%xmm5,(%3) \n" |
| 1450 | "movdqu %%xmm0,0x10(%3) \n" |
| 1451 | "lea 0x20(%3),%3 \n" |
| 1452 | "sub $0x8,%4 \n" |
| 1453 | "jg 1b \n" |
| 1454 | : "+r"(y_buf), // %0 |
| 1455 | "+r"(u_buf), // %1 |
| 1456 | "+r"(v_buf), // %2 |
| 1457 | "+r"(rgb_buf), // %3 |
| 1458 | "+rm"(width) // %4 |
| 1459 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1460 | : "memory", "cc" |
| 1461 | #if defined(__SSE2__) |
| 1462 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1463 | #endif |
| 1464 | ); |
| 1465 | } |
| 1466 | |
| 1467 | void OMITFP I420ToABGRRow_Unaligned_SSSE3(const uint8* y_buf, |
| 1468 | const uint8* u_buf, |
| 1469 | const uint8* v_buf, |
| 1470 | uint8* rgb_buf, |
| 1471 | int width) { |
| 1472 | asm volatile ( |
| 1473 | "sub %1,%2 \n" |
| 1474 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1475 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1476 | ".p2align 4 \n" |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1477 | "1: \n" |
| 1478 | YUVTORGB |
| 1479 | "punpcklbw %%xmm1,%%xmm2 \n" |
| 1480 | "punpcklbw %%xmm5,%%xmm0 \n" |
| 1481 | "movdqa %%xmm2,%%xmm1 \n" |
| 1482 | "punpcklwd %%xmm0,%%xmm2 \n" |
| 1483 | "punpckhwd %%xmm0,%%xmm1 \n" |
| 1484 | "movdqu %%xmm2,(%3) \n" |
| 1485 | "movdqu %%xmm1,0x10(%3) \n" |
| 1486 | "lea 0x20(%3),%3 \n" |
| 1487 | "sub $0x8,%4 \n" |
| 1488 | "jg 1b \n" |
| 1489 | : "+r"(y_buf), // %0 |
| 1490 | "+r"(u_buf), // %1 |
| 1491 | "+r"(v_buf), // %2 |
| 1492 | "+r"(rgb_buf), // %3 |
| 1493 | "+rm"(width) // %4 |
| 1494 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1495 | : "memory", "cc" |
| 1496 | #if defined(__SSE2__) |
| 1497 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1498 | #endif |
| 1499 | ); |
| 1500 | } |
| 1501 | |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1502 | void OMITFP I444ToARGBRow_SSSE3(const uint8* y_buf, |
| 1503 | const uint8* u_buf, |
| 1504 | const uint8* v_buf, |
| 1505 | uint8* rgb_buf, |
| 1506 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1507 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1508 | "sub %1,%2 \n" |
| 1509 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1510 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1511 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1512 | "1: \n" |
| 1513 | "movd (%1),%%xmm0 \n" |
| 1514 | "movd (%1,%2,1),%%xmm1 \n" |
| 1515 | "lea 0x4(%1),%1 \n" |
| 1516 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1517 | "movdqa %%xmm0,%%xmm1 \n" |
| 1518 | "movdqa %%xmm0,%%xmm2 \n" |
| 1519 | "pmaddubsw (%5),%%xmm0 \n" |
| 1520 | "pmaddubsw 16(%5),%%xmm1 \n" |
| 1521 | "pmaddubsw 32(%5),%%xmm2 \n" |
| 1522 | "psubw 48(%5),%%xmm0 \n" |
| 1523 | "psubw 64(%5),%%xmm1 \n" |
| 1524 | "psubw 80(%5),%%xmm2 \n" |
| 1525 | "movd (%0),%%xmm3 \n" |
| 1526 | "lea 0x4(%0),%0 \n" |
| 1527 | "punpcklbw %%xmm4,%%xmm3 \n" |
| 1528 | "psubsw 96(%5),%%xmm3 \n" |
| 1529 | "pmullw 112(%5),%%xmm3 \n" |
| 1530 | "paddsw %%xmm3,%%xmm0 \n" |
| 1531 | "paddsw %%xmm3,%%xmm1 \n" |
| 1532 | "paddsw %%xmm3,%%xmm2 \n" |
| 1533 | "psraw $0x6,%%xmm0 \n" |
| 1534 | "psraw $0x6,%%xmm1 \n" |
| 1535 | "psraw $0x6,%%xmm2 \n" |
| 1536 | "packuswb %%xmm0,%%xmm0 \n" |
| 1537 | "packuswb %%xmm1,%%xmm1 \n" |
| 1538 | "packuswb %%xmm2,%%xmm2 \n" |
| 1539 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1540 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1541 | "punpcklwd %%xmm2,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1542 | "sub $0x4,%4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1543 | "movdqa %%xmm0,(%3) \n" |
| 1544 | "lea 0x10(%3),%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1545 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1546 | : "+r"(y_buf), // %0 |
| 1547 | "+r"(u_buf), // %1 |
| 1548 | "+r"(v_buf), // %2 |
| 1549 | "+r"(rgb_buf), // %3 |
| 1550 | "+rm"(width) // %4 |
| 1551 | : "r"(&kYuvConstants.kUVToB) // %5 |
| 1552 | : "memory", "cc" |
| 1553 | #if defined(__SSE2__) |
| 1554 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1555 | #endif |
| 1556 | ); |
| 1557 | } |
| 1558 | #endif |
| 1559 | |
| 1560 | #ifdef HAS_YTOARGBROW_SSE2 |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1561 | void YToARGBRow_SSE2(const uint8* y_buf, |
| 1562 | uint8* rgb_buf, |
| 1563 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1564 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1565 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 1566 | "pslld $0x18,%%xmm4 \n" |
| 1567 | "mov $0x10001000,%%eax \n" |
| 1568 | "movd %%eax,%%xmm3 \n" |
| 1569 | "pshufd $0x0,%%xmm3,%%xmm3 \n" |
| 1570 | "mov $0x012a012a,%%eax \n" |
| 1571 | "movd %%eax,%%xmm2 \n" |
| 1572 | "pshufd $0x0,%%xmm2,%%xmm2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1573 | ".p2align 4 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1574 | "1: \n" |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1575 | // 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] | 1576 | "movq (%0),%%xmm0 \n" |
| 1577 | "lea 0x8(%0),%0 \n" |
| 1578 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 1579 | "psubusw %%xmm3,%%xmm0 \n" |
| 1580 | "pmulhuw %%xmm2,%%xmm0 \n" |
| 1581 | "packuswb %%xmm0,%%xmm0 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1582 | |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1583 | // Step 2: Weave into ARGB |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1584 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 1585 | "movdqa %%xmm0,%%xmm1 \n" |
| 1586 | "punpcklwd %%xmm0,%%xmm0 \n" |
| 1587 | "punpckhwd %%xmm1,%%xmm1 \n" |
| 1588 | "por %%xmm4,%%xmm0 \n" |
| 1589 | "por %%xmm4,%%xmm1 \n" |
| 1590 | "movdqa %%xmm0,(%1) \n" |
| 1591 | "movdqa %%xmm1,16(%1) \n" |
| 1592 | "lea 32(%1),%1 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1593 | |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1594 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1595 | "jg 1b \n" |
fbarchard@google.com | 3faa0f1 | 2011-10-20 06:04:16 +0000 | [diff] [blame] | 1596 | : "+r"(y_buf), // %0 |
| 1597 | "+r"(rgb_buf), // %1 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1598 | "+rm"(width) // %2 |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1599 | : |
| 1600 | : "memory", "cc", "eax" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1601 | #if defined(__SSE2__) |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1602 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1603 | #endif |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1604 | ); |
mikhal@webrtc.org | 120d5e7 | 2011-10-07 17:57:17 +0000 | [diff] [blame] | 1605 | } |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1606 | #endif |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 1607 | |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1608 | #ifdef HAS_MIRRORROW_SSSE3 |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1609 | // Shuffle table for reversing the bytes. |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1610 | CONST uvec8 kShuffleMirror = { |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1611 | 15u, 14u, 13u, 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u |
| 1612 | }; |
| 1613 | |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1614 | void MirrorRow_SSSE3(const uint8* src, uint8* dst, int width) { |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1615 | intptr_t temp_width = static_cast<intptr_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1616 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1617 | "movdqa %3,%%xmm5 \n" |
| 1618 | "lea -0x10(%0),%0 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1619 | ".p2align 4 \n" |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1620 | "1: \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1621 | "movdqa (%0,%2),%%xmm0 \n" |
| 1622 | "pshufb %%xmm5,%%xmm0 \n" |
| 1623 | "sub $0x10,%2 \n" |
| 1624 | "movdqa %%xmm0,(%1) \n" |
| 1625 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1626 | "jg 1b \n" |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1627 | : "+r"(src), // %0 |
| 1628 | "+r"(dst), // %1 |
| 1629 | "+r"(temp_width) // %2 |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1630 | : "m"(kShuffleMirror) // %3 |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1631 | : "memory", "cc" |
| 1632 | #if defined(__SSE2__) |
| 1633 | , "xmm0", "xmm5" |
| 1634 | #endif |
| 1635 | ); |
| 1636 | } |
| 1637 | #endif |
| 1638 | |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1639 | #ifdef HAS_MIRRORROW_SSE2 |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1640 | void MirrorRow_SSE2(const uint8* src, uint8* dst, int width) { |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1641 | intptr_t temp_width = static_cast<intptr_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1642 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1643 | "lea -0x10(%0),%0 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1644 | ".p2align 4 \n" |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1645 | "1: \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1646 | "movdqu (%0,%2),%%xmm0 \n" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1647 | "movdqa %%xmm0,%%xmm1 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1648 | "psllw $0x8,%%xmm0 \n" |
| 1649 | "psrlw $0x8,%%xmm1 \n" |
| 1650 | "por %%xmm1,%%xmm0 \n" |
| 1651 | "pshuflw $0x1b,%%xmm0,%%xmm0 \n" |
| 1652 | "pshufhw $0x1b,%%xmm0,%%xmm0 \n" |
| 1653 | "pshufd $0x4e,%%xmm0,%%xmm0 \n" |
| 1654 | "sub $0x10,%2 \n" |
| 1655 | "movdqu %%xmm0,(%1) \n" |
| 1656 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1657 | "jg 1b \n" |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1658 | : "+r"(src), // %0 |
| 1659 | "+r"(dst), // %1 |
| 1660 | "+r"(temp_width) // %2 |
| 1661 | : |
| 1662 | : "memory", "cc" |
| 1663 | #if defined(__SSE2__) |
| 1664 | , "xmm0", "xmm1" |
| 1665 | #endif |
| 1666 | ); |
| 1667 | } |
| 1668 | #endif |
| 1669 | |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1670 | #ifdef HAS_MIRRORROW_UV_SSSE3 |
| 1671 | // Shuffle table for reversing the bytes of UV channels. |
| 1672 | CONST uvec8 kShuffleMirrorUV = { |
| 1673 | 14u, 12u, 10u, 8u, 6u, 4u, 2u, 0u, 15u, 13u, 11u, 9u, 7u, 5u, 3u, 1u |
| 1674 | }; |
| 1675 | void MirrorRowUV_SSSE3(const uint8* src, uint8* dst_u, uint8* dst_v, |
| 1676 | int width) { |
| 1677 | intptr_t temp_width = static_cast<intptr_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1678 | asm volatile ( |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1679 | "movdqa %4,%%xmm1 \n" |
| 1680 | "lea -16(%0,%3,2),%0 \n" |
| 1681 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1682 | ".p2align 4 \n" |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1683 | "1: \n" |
| 1684 | "movdqa (%0),%%xmm0 \n" |
| 1685 | "lea -16(%0),%0 \n" |
| 1686 | "pshufb %%xmm1,%%xmm0 \n" |
| 1687 | "sub $8,%3 \n" |
| 1688 | "movlpd %%xmm0,(%1) \n" |
| 1689 | "movhpd %%xmm0,(%1,%2) \n" |
| 1690 | "lea 8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1691 | "jg 1b \n" |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1692 | : "+r"(src), // %0 |
| 1693 | "+r"(dst_u), // %1 |
| 1694 | "+r"(dst_v), // %2 |
| 1695 | "+r"(temp_width) // %3 |
| 1696 | : "m"(kShuffleMirrorUV) // %4 |
| 1697 | : "memory", "cc" |
| 1698 | #if defined(__SSE2__) |
| 1699 | , "xmm0", "xmm1" |
| 1700 | #endif |
| 1701 | ); |
| 1702 | } |
| 1703 | #endif |
| 1704 | |
fbarchard@google.com | 5566302 | 2012-04-26 00:01:41 +0000 | [diff] [blame] | 1705 | #ifdef HAS_ADDROW_SSE2 |
| 1706 | // dst and width aligned to 16 |
| 1707 | void AddRow_SSE2(const uint8* src, uint16* dst, int width) { |
| 1708 | asm volatile ( |
| 1709 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1710 | ".p2align 4 \n" |
fbarchard@google.com | 5566302 | 2012-04-26 00:01:41 +0000 | [diff] [blame] | 1711 | "1: \n" |
| 1712 | "movdqu (%0),%%xmm2 \n" |
| 1713 | "lea 0x10(%0),%0 \n" |
| 1714 | "movdqa (%1),%%xmm0 \n" |
| 1715 | "movdqa 0x10(%1),%%xmm1 \n" |
| 1716 | "movdqa %%xmm2,%%xmm3 \n" |
| 1717 | "punpcklbw %%xmm4,%%xmm2 \n" |
| 1718 | "punpckhbw %%xmm4,%%xmm3 \n" |
| 1719 | "paddusw %%xmm2,%%xmm0 \n" |
| 1720 | "paddusw %%xmm3,%%xmm1 \n" |
| 1721 | "sub $0x10,%2 \n" |
| 1722 | "movdqa %%xmm0,(%1) \n" |
| 1723 | "movdqa %%xmm1,0x10(%1) \n" |
| 1724 | "lea 0x20(%1),%1 \n" |
| 1725 | "jg 1b \n" |
| 1726 | : "+r"(src), // %0 |
| 1727 | "+r"(dst), // %1 |
| 1728 | "+r"(width) // %2 |
| 1729 | : |
| 1730 | : "memory", "cc" |
| 1731 | #if defined(__SSE2__) |
| 1732 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" |
| 1733 | #endif |
| 1734 | ); |
| 1735 | } |
| 1736 | |
| 1737 | // dst and width aligned to 16 |
| 1738 | void SubRow_SSE2(const uint8* src, uint16* dst, int width) { |
| 1739 | asm volatile ( |
| 1740 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1741 | ".p2align 4 \n" |
fbarchard@google.com | 5566302 | 2012-04-26 00:01:41 +0000 | [diff] [blame] | 1742 | "1: \n" |
| 1743 | "movdqu (%0),%%xmm2 \n" |
| 1744 | "lea 0x10(%0),%0 \n" |
| 1745 | "movdqa (%1),%%xmm0 \n" |
| 1746 | "movdqa 0x10(%1),%%xmm1 \n" |
| 1747 | "movdqa %%xmm2,%%xmm3 \n" |
| 1748 | "punpcklbw %%xmm4,%%xmm2 \n" |
| 1749 | "punpckhbw %%xmm4,%%xmm3 \n" |
| 1750 | "psubusw %%xmm2,%%xmm0 \n" |
| 1751 | "psubusw %%xmm3,%%xmm1 \n" |
| 1752 | "sub $0x10,%2 \n" |
| 1753 | "movdqa %%xmm0,(%1) \n" |
| 1754 | "movdqa %%xmm1,0x10(%1) \n" |
| 1755 | "lea 0x20(%1),%1 \n" |
| 1756 | "jg 1b \n" |
| 1757 | : "+r"(src), // %0 |
| 1758 | "+r"(dst), // %1 |
| 1759 | "+r"(width) // %2 |
| 1760 | : |
| 1761 | : "memory", "cc" |
| 1762 | #if defined(__SSE2__) |
| 1763 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" |
| 1764 | #endif |
| 1765 | ); |
| 1766 | } |
| 1767 | #endif // HAS_ADDROW_SSE2 |
| 1768 | |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1769 | #ifdef HAS_SPLITUV_SSE2 |
| 1770 | 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] | 1771 | asm volatile ( |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1772 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1773 | "psrlw $0x8,%%xmm5 \n" |
| 1774 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1775 | ".p2align 4 \n" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1776 | "1: \n" |
| 1777 | "movdqa (%0),%%xmm0 \n" |
| 1778 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1779 | "lea 0x20(%0),%0 \n" |
| 1780 | "movdqa %%xmm0,%%xmm2 \n" |
| 1781 | "movdqa %%xmm1,%%xmm3 \n" |
| 1782 | "pand %%xmm5,%%xmm0 \n" |
| 1783 | "pand %%xmm5,%%xmm1 \n" |
| 1784 | "packuswb %%xmm1,%%xmm0 \n" |
| 1785 | "psrlw $0x8,%%xmm2 \n" |
| 1786 | "psrlw $0x8,%%xmm3 \n" |
| 1787 | "packuswb %%xmm3,%%xmm2 \n" |
| 1788 | "movdqa %%xmm0,(%1) \n" |
| 1789 | "movdqa %%xmm2,(%1,%2) \n" |
| 1790 | "lea 0x10(%1),%1 \n" |
| 1791 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1792 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1793 | : "+r"(src_uv), // %0 |
| 1794 | "+r"(dst_u), // %1 |
| 1795 | "+r"(dst_v), // %2 |
| 1796 | "+r"(pix) // %3 |
| 1797 | : |
| 1798 | : "memory", "cc" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1799 | #if defined(__SSE2__) |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1800 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1801 | #endif |
| 1802 | ); |
| 1803 | } |
| 1804 | #endif |
| 1805 | |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 1806 | #ifdef HAS_COPYROW_SSE2 |
| 1807 | void CopyRow_SSE2(const uint8* src, uint8* dst, int count) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1808 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1809 | "sub %0,%1 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 1810 | ".p2align 4 \n" |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 1811 | "1: \n" |
| 1812 | "movdqa (%0),%%xmm0 \n" |
| 1813 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1814 | "movdqa %%xmm0,(%0,%1) \n" |
| 1815 | "movdqa %%xmm1,0x10(%0,%1) \n" |
| 1816 | "lea 0x20(%0),%0 \n" |
| 1817 | "sub $0x20,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1818 | "jg 1b \n" |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 1819 | : "+r"(src), // %0 |
| 1820 | "+r"(dst), // %1 |
| 1821 | "+r"(count) // %2 |
| 1822 | : |
| 1823 | : "memory", "cc" |
| 1824 | #if defined(__SSE2__) |
| 1825 | , "xmm0", "xmm1" |
| 1826 | #endif |
| 1827 | ); |
| 1828 | } |
| 1829 | #endif // HAS_COPYROW_SSE2 |
| 1830 | |
| 1831 | #ifdef HAS_COPYROW_X86 |
| 1832 | void CopyRow_X86(const uint8* src, uint8* dst, int width) { |
| 1833 | size_t width_tmp = static_cast<size_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1834 | asm volatile ( |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 1835 | "shr $0x2,%2 \n" |
| 1836 | "rep movsl \n" |
| 1837 | : "+S"(src), // %0 |
| 1838 | "+D"(dst), // %1 |
| 1839 | "+c"(width_tmp) // %2 |
| 1840 | : |
| 1841 | : "memory", "cc" |
| 1842 | ); |
| 1843 | } |
| 1844 | #endif |
| 1845 | |
fbarchard@google.com | b95dbf2 | 2012-02-11 01:18:30 +0000 | [diff] [blame] | 1846 | #ifdef HAS_YUY2TOYROW_SSE2 |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1847 | 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] | 1848 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1849 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1850 | "psrlw $0x8,%%xmm5 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1851 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1852 | "1: \n" |
| 1853 | "movdqa (%0),%%xmm0 \n" |
| 1854 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1855 | "lea 0x20(%0),%0 \n" |
| 1856 | "pand %%xmm5,%%xmm0 \n" |
| 1857 | "pand %%xmm5,%%xmm1 \n" |
| 1858 | "packuswb %%xmm1,%%xmm0 \n" |
| 1859 | "movdqa %%xmm0,(%1) \n" |
| 1860 | "lea 0x10(%1),%1 \n" |
| 1861 | "sub $0x10,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1862 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1863 | : "+r"(src_yuy2), // %0 |
| 1864 | "+r"(dst_y), // %1 |
| 1865 | "+r"(pix) // %2 |
| 1866 | : |
| 1867 | : "memory", "cc" |
| 1868 | #if defined(__SSE2__) |
| 1869 | , "xmm0", "xmm1", "xmm5" |
| 1870 | #endif |
| 1871 | ); |
| 1872 | } |
| 1873 | |
| 1874 | void YUY2ToUVRow_SSE2(const uint8* src_yuy2, int stride_yuy2, |
| 1875 | uint8* dst_u, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1876 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1877 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1878 | "psrlw $0x8,%%xmm5 \n" |
| 1879 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1880 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1881 | "1: \n" |
| 1882 | "movdqa (%0),%%xmm0 \n" |
| 1883 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1884 | "movdqa (%0,%4,1),%%xmm2 \n" |
| 1885 | "movdqa 0x10(%0,%4,1),%%xmm3 \n" |
| 1886 | "lea 0x20(%0),%0 \n" |
| 1887 | "pavgb %%xmm2,%%xmm0 \n" |
| 1888 | "pavgb %%xmm3,%%xmm1 \n" |
| 1889 | "psrlw $0x8,%%xmm0 \n" |
| 1890 | "psrlw $0x8,%%xmm1 \n" |
| 1891 | "packuswb %%xmm1,%%xmm0 \n" |
| 1892 | "movdqa %%xmm0,%%xmm1 \n" |
| 1893 | "pand %%xmm5,%%xmm0 \n" |
| 1894 | "packuswb %%xmm0,%%xmm0 \n" |
| 1895 | "psrlw $0x8,%%xmm1 \n" |
| 1896 | "packuswb %%xmm1,%%xmm1 \n" |
| 1897 | "movq %%xmm0,(%1) \n" |
| 1898 | "movq %%xmm1,(%1,%2) \n" |
| 1899 | "lea 0x8(%1),%1 \n" |
| 1900 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1901 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1902 | : "+r"(src_yuy2), // %0 |
| 1903 | "+r"(dst_u), // %1 |
| 1904 | "+r"(dst_y), // %2 |
| 1905 | "+r"(pix) // %3 |
| 1906 | : "r"(static_cast<intptr_t>(stride_yuy2)) // %4 |
| 1907 | : "memory", "cc" |
| 1908 | #if defined(__SSE2__) |
| 1909 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 1910 | #endif |
| 1911 | ); |
| 1912 | } |
| 1913 | |
fbarchard@google.com | f3fb7b6 | 2012-03-29 23:19:34 +0000 | [diff] [blame] | 1914 | |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1915 | void YUY2ToYRow_Unaligned_SSE2(const uint8* src_yuy2, |
| 1916 | uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1917 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1918 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1919 | "psrlw $0x8,%%xmm5 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1920 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1921 | "1: \n" |
| 1922 | "movdqu (%0),%%xmm0 \n" |
| 1923 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1924 | "lea 0x20(%0),%0 \n" |
| 1925 | "pand %%xmm5,%%xmm0 \n" |
| 1926 | "pand %%xmm5,%%xmm1 \n" |
| 1927 | "packuswb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1928 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1929 | "movdqu %%xmm0,(%1) \n" |
| 1930 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1931 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1932 | : "+r"(src_yuy2), // %0 |
| 1933 | "+r"(dst_y), // %1 |
| 1934 | "+r"(pix) // %2 |
| 1935 | : |
| 1936 | : "memory", "cc" |
| 1937 | #if defined(__SSE2__) |
| 1938 | , "xmm0", "xmm1", "xmm5" |
| 1939 | #endif |
| 1940 | ); |
| 1941 | } |
| 1942 | |
| 1943 | void YUY2ToUVRow_Unaligned_SSE2(const uint8* src_yuy2, |
| 1944 | int stride_yuy2, |
| 1945 | uint8* dst_u, uint8* dst_y, |
| 1946 | int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1947 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1948 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1949 | "psrlw $0x8,%%xmm5 \n" |
| 1950 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1951 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1952 | "1: \n" |
| 1953 | "movdqu (%0),%%xmm0 \n" |
| 1954 | "movdqu 0x10(%0),%%xmm1 \n" |
| 1955 | "movdqu (%0,%4,1),%%xmm2 \n" |
| 1956 | "movdqu 0x10(%0,%4,1),%%xmm3 \n" |
| 1957 | "lea 0x20(%0),%0 \n" |
| 1958 | "pavgb %%xmm2,%%xmm0 \n" |
| 1959 | "pavgb %%xmm3,%%xmm1 \n" |
| 1960 | "psrlw $0x8,%%xmm0 \n" |
| 1961 | "psrlw $0x8,%%xmm1 \n" |
| 1962 | "packuswb %%xmm1,%%xmm0 \n" |
| 1963 | "movdqa %%xmm0,%%xmm1 \n" |
| 1964 | "pand %%xmm5,%%xmm0 \n" |
| 1965 | "packuswb %%xmm0,%%xmm0 \n" |
| 1966 | "psrlw $0x8,%%xmm1 \n" |
| 1967 | "packuswb %%xmm1,%%xmm1 \n" |
| 1968 | "movq %%xmm0,(%1) \n" |
| 1969 | "movq %%xmm1,(%1,%2) \n" |
| 1970 | "lea 0x8(%1),%1 \n" |
| 1971 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1972 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1973 | : "+r"(src_yuy2), // %0 |
| 1974 | "+r"(dst_u), // %1 |
| 1975 | "+r"(dst_y), // %2 |
| 1976 | "+r"(pix) // %3 |
| 1977 | : "r"(static_cast<intptr_t>(stride_yuy2)) // %4 |
| 1978 | : "memory", "cc" |
| 1979 | #if defined(__SSE2__) |
| 1980 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 1981 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1982 | ); |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1983 | } |
| 1984 | |
| 1985 | 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] | 1986 | asm volatile ( |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1987 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1988 | "1: \n" |
| 1989 | "movdqa (%0),%%xmm0 \n" |
| 1990 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1991 | "lea 0x20(%0),%0 \n" |
| 1992 | "psrlw $0x8,%%xmm0 \n" |
| 1993 | "psrlw $0x8,%%xmm1 \n" |
| 1994 | "packuswb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1995 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1996 | "movdqa %%xmm0,(%1) \n" |
| 1997 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1998 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1999 | : "+r"(src_uyvy), // %0 |
| 2000 | "+r"(dst_y), // %1 |
| 2001 | "+r"(pix) // %2 |
| 2002 | : |
| 2003 | : "memory", "cc" |
| 2004 | #if defined(__SSE2__) |
| 2005 | , "xmm0", "xmm1" |
| 2006 | #endif |
| 2007 | ); |
| 2008 | } |
| 2009 | |
| 2010 | void UYVYToUVRow_SSE2(const uint8* src_uyvy, int stride_uyvy, |
| 2011 | uint8* dst_u, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2012 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2013 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2014 | "psrlw $0x8,%%xmm5 \n" |
| 2015 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2016 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2017 | "1: \n" |
| 2018 | "movdqa (%0),%%xmm0 \n" |
| 2019 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2020 | "movdqa (%0,%4,1),%%xmm2 \n" |
| 2021 | "movdqa 0x10(%0,%4,1),%%xmm3 \n" |
| 2022 | "lea 0x20(%0),%0 \n" |
| 2023 | "pavgb %%xmm2,%%xmm0 \n" |
| 2024 | "pavgb %%xmm3,%%xmm1 \n" |
| 2025 | "pand %%xmm5,%%xmm0 \n" |
| 2026 | "pand %%xmm5,%%xmm1 \n" |
| 2027 | "packuswb %%xmm1,%%xmm0 \n" |
| 2028 | "movdqa %%xmm0,%%xmm1 \n" |
| 2029 | "pand %%xmm5,%%xmm0 \n" |
| 2030 | "packuswb %%xmm0,%%xmm0 \n" |
| 2031 | "psrlw $0x8,%%xmm1 \n" |
| 2032 | "packuswb %%xmm1,%%xmm1 \n" |
| 2033 | "movq %%xmm0,(%1) \n" |
| 2034 | "movq %%xmm1,(%1,%2) \n" |
| 2035 | "lea 0x8(%1),%1 \n" |
| 2036 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2037 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2038 | : "+r"(src_uyvy), // %0 |
| 2039 | "+r"(dst_u), // %1 |
| 2040 | "+r"(dst_y), // %2 |
| 2041 | "+r"(pix) // %3 |
| 2042 | : "r"(static_cast<intptr_t>(stride_uyvy)) // %4 |
| 2043 | : "memory", "cc" |
| 2044 | #if defined(__SSE2__) |
| 2045 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 2046 | #endif |
| 2047 | ); |
| 2048 | } |
| 2049 | |
| 2050 | void UYVYToYRow_Unaligned_SSE2(const uint8* src_uyvy, |
| 2051 | uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2052 | asm volatile ( |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2053 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2054 | "1: \n" |
| 2055 | "movdqu (%0),%%xmm0 \n" |
| 2056 | "movdqu 0x10(%0),%%xmm1 \n" |
| 2057 | "lea 0x20(%0),%0 \n" |
| 2058 | "psrlw $0x8,%%xmm0 \n" |
| 2059 | "psrlw $0x8,%%xmm1 \n" |
| 2060 | "packuswb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2061 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2062 | "movdqu %%xmm0,(%1) \n" |
| 2063 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2064 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2065 | : "+r"(src_uyvy), // %0 |
| 2066 | "+r"(dst_y), // %1 |
| 2067 | "+r"(pix) // %2 |
| 2068 | : |
| 2069 | : "memory", "cc" |
| 2070 | #if defined(__SSE2__) |
| 2071 | , "xmm0", "xmm1" |
| 2072 | #endif |
| 2073 | ); |
| 2074 | } |
| 2075 | |
| 2076 | void UYVYToUVRow_Unaligned_SSE2(const uint8* src_uyvy, int stride_uyvy, |
| 2077 | uint8* dst_u, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2078 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2079 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2080 | "psrlw $0x8,%%xmm5 \n" |
| 2081 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2082 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2083 | "1: \n" |
| 2084 | "movdqu (%0),%%xmm0 \n" |
| 2085 | "movdqu 0x10(%0),%%xmm1 \n" |
| 2086 | "movdqu (%0,%4,1),%%xmm2 \n" |
| 2087 | "movdqu 0x10(%0,%4,1),%%xmm3 \n" |
| 2088 | "lea 0x20(%0),%0 \n" |
| 2089 | "pavgb %%xmm2,%%xmm0 \n" |
| 2090 | "pavgb %%xmm3,%%xmm1 \n" |
| 2091 | "pand %%xmm5,%%xmm0 \n" |
| 2092 | "pand %%xmm5,%%xmm1 \n" |
| 2093 | "packuswb %%xmm1,%%xmm0 \n" |
| 2094 | "movdqa %%xmm0,%%xmm1 \n" |
| 2095 | "pand %%xmm5,%%xmm0 \n" |
| 2096 | "packuswb %%xmm0,%%xmm0 \n" |
| 2097 | "psrlw $0x8,%%xmm1 \n" |
| 2098 | "packuswb %%xmm1,%%xmm1 \n" |
| 2099 | "movq %%xmm0,(%1) \n" |
| 2100 | "movq %%xmm1,(%1,%2) \n" |
| 2101 | "lea 0x8(%1),%1 \n" |
| 2102 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2103 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2104 | : "+r"(src_uyvy), // %0 |
| 2105 | "+r"(dst_u), // %1 |
| 2106 | "+r"(dst_y), // %2 |
| 2107 | "+r"(pix) // %3 |
| 2108 | : "r"(static_cast<intptr_t>(stride_uyvy)) // %4 |
| 2109 | : "memory", "cc" |
| 2110 | #if defined(__SSE2__) |
| 2111 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 2112 | #endif |
| 2113 | ); |
| 2114 | } |
fbarchard@google.com | b95dbf2 | 2012-02-11 01:18:30 +0000 | [diff] [blame] | 2115 | #endif // HAS_YUY2TOYROW_SSE2 |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2116 | |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 2117 | #ifdef HAS_ARGBBLENDROW_SSE2 |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2118 | // Blend 8 pixels at a time. |
| 2119 | // src_argb0 unaligned. |
| 2120 | // src_argb1 and dst_argb aligned to 16 bytes. |
| 2121 | // width must be multiple of 4 pixels. |
fbarchard@google.com | d2f4413 | 2012-04-04 21:53:27 +0000 | [diff] [blame] | 2122 | void ARGBBlendRow_Aligned_SSE2(const uint8* src_argb0, const uint8* src_argb1, |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2123 | uint8* dst_argb, int width) { |
| 2124 | asm volatile ( |
| 2125 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 2126 | "psrlw $0xf,%%xmm7 \n" |
| 2127 | "pcmpeqb %%xmm6,%%xmm6 \n" |
| 2128 | "psrlw $0x8,%%xmm6 \n" |
| 2129 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2130 | "psllw $0x8,%%xmm5 \n" |
| 2131 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2132 | "pslld $0x18,%%xmm4 \n" |
| 2133 | |
| 2134 | // 8 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2135 | ".p2align 4 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2136 | "1: \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2137 | "movdqu (%0),%%xmm3 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2138 | "movdqa %%xmm3,%%xmm0 \n" |
| 2139 | "pxor %%xmm4,%%xmm3 \n" |
fbarchard@google.com | 1702ec7 | 2012-04-05 01:15:12 +0000 | [diff] [blame] | 2140 | "movdqu (%1),%%xmm2 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2141 | "psrlw $0x8,%%xmm3 \n" |
| 2142 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 2143 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 2144 | "pand %%xmm6,%%xmm2 \n" |
| 2145 | "paddw %%xmm7,%%xmm3 \n" |
| 2146 | "pmullw %%xmm3,%%xmm2 \n" |
fbarchard@google.com | 1702ec7 | 2012-04-05 01:15:12 +0000 | [diff] [blame] | 2147 | "movdqu (%1),%%xmm1 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2148 | "psrlw $0x8,%%xmm1 \n" |
| 2149 | "por %%xmm4,%%xmm0 \n" |
| 2150 | "pmullw %%xmm3,%%xmm1 \n" |
| 2151 | "movdqu 0x10(%0),%%xmm3 \n" |
| 2152 | "lea 0x20(%0),%0 \n" |
| 2153 | "psrlw $0x8,%%xmm2 \n" |
| 2154 | "paddusb %%xmm2,%%xmm0 \n" |
| 2155 | "pand %%xmm5,%%xmm1 \n" |
| 2156 | "paddusb %%xmm1,%%xmm0 \n" |
| 2157 | "sub $0x4,%3 \n" |
| 2158 | "movdqa %%xmm0,(%2) \n" |
| 2159 | "jle 9f \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2160 | "movdqa %%xmm3,%%xmm0 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2161 | "pxor %%xmm4,%%xmm3 \n" |
fbarchard@google.com | 1702ec7 | 2012-04-05 01:15:12 +0000 | [diff] [blame] | 2162 | "movdqu 0x10(%1),%%xmm2 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2163 | "psrlw $0x8,%%xmm3 \n" |
| 2164 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 2165 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 2166 | "pand %%xmm6,%%xmm2 \n" |
| 2167 | "paddw %%xmm7,%%xmm3 \n" |
| 2168 | "pmullw %%xmm3,%%xmm2 \n" |
fbarchard@google.com | 1702ec7 | 2012-04-05 01:15:12 +0000 | [diff] [blame] | 2169 | "movdqu 0x10(%1),%%xmm1 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2170 | "lea 0x20(%1),%1 \n" |
| 2171 | "psrlw $0x8,%%xmm1 \n" |
| 2172 | "por %%xmm4,%%xmm0 \n" |
| 2173 | "pmullw %%xmm3,%%xmm1 \n" |
| 2174 | "psrlw $0x8,%%xmm2 \n" |
| 2175 | "paddusb %%xmm2,%%xmm0 \n" |
| 2176 | "pand %%xmm5,%%xmm1 \n" |
| 2177 | "paddusb %%xmm1,%%xmm0 \n" |
| 2178 | "sub $0x4,%3 \n" |
| 2179 | "movdqa %%xmm0,0x10(%2) \n" |
| 2180 | "lea 0x20(%2),%2 \n" |
| 2181 | "jg 1b \n" |
| 2182 | "9: \n" |
| 2183 | : "+r"(src_argb0), // %0 |
| 2184 | "+r"(src_argb1), // %1 |
| 2185 | "+r"(dst_argb), // %2 |
| 2186 | "+r"(width) // %3 |
| 2187 | : |
| 2188 | : "memory", "cc" |
| 2189 | #if defined(__SSE2__) |
| 2190 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 2191 | #endif |
| 2192 | ); |
| 2193 | } |
fbarchard@google.com | da5cc42 | 2012-04-24 06:01:32 +0000 | [diff] [blame] | 2194 | #endif // HAS_ARGBBLENDROW_SSE2 |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2195 | |
fbarchard@google.com | da5cc42 | 2012-04-24 06:01:32 +0000 | [diff] [blame] | 2196 | #ifdef HAS_ARGBBLENDROW1_SSE2 |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2197 | // Blend 1 pixel at a time, unaligned |
fbarchard@google.com | d2f4413 | 2012-04-04 21:53:27 +0000 | [diff] [blame] | 2198 | void ARGBBlendRow1_SSE2(const uint8* src_argb0, const uint8* src_argb1, |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2199 | uint8* dst_argb, int width) { |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2200 | asm volatile ( |
| 2201 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 2202 | "psrlw $0xf,%%xmm7 \n" |
| 2203 | "pcmpeqb %%xmm6,%%xmm6 \n" |
| 2204 | "psrlw $0x8,%%xmm6 \n" |
| 2205 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2206 | "psllw $0x8,%%xmm5 \n" |
| 2207 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2208 | "pslld $0x18,%%xmm4 \n" |
| 2209 | |
| 2210 | // 1 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2211 | ".p2align 4 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2212 | "1: \n" |
| 2213 | "movd (%0),%%xmm3 \n" |
| 2214 | "lea 0x4(%0),%0 \n" |
| 2215 | "movdqa %%xmm3,%%xmm0 \n" |
| 2216 | "pxor %%xmm4,%%xmm3 \n" |
| 2217 | "movd (%1),%%xmm2 \n" |
| 2218 | "psrlw $0x8,%%xmm3 \n" |
| 2219 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 2220 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 2221 | "pand %%xmm6,%%xmm2 \n" |
| 2222 | "paddw %%xmm7,%%xmm3 \n" |
| 2223 | "pmullw %%xmm3,%%xmm2 \n" |
| 2224 | "movd (%1),%%xmm1 \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2225 | "lea 0x4(%1),%1 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2226 | "psrlw $0x8,%%xmm1 \n" |
| 2227 | "por %%xmm4,%%xmm0 \n" |
| 2228 | "pmullw %%xmm3,%%xmm1 \n" |
| 2229 | "psrlw $0x8,%%xmm2 \n" |
| 2230 | "paddusb %%xmm2,%%xmm0 \n" |
| 2231 | "pand %%xmm5,%%xmm1 \n" |
| 2232 | "paddusb %%xmm1,%%xmm0 \n" |
| 2233 | "sub $0x1,%3 \n" |
| 2234 | "movd %%xmm0,(%2) \n" |
| 2235 | "lea 0x4(%2),%2 \n" |
| 2236 | "jg 1b \n" |
| 2237 | : "+r"(src_argb0), // %0 |
| 2238 | "+r"(src_argb1), // %1 |
| 2239 | "+r"(dst_argb), // %2 |
| 2240 | "+r"(width) // %3 |
| 2241 | : |
| 2242 | : "memory", "cc" |
| 2243 | #if defined(__SSE2__) |
| 2244 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 2245 | #endif |
| 2246 | ); |
| 2247 | } |
fbarchard@google.com | da5cc42 | 2012-04-24 06:01:32 +0000 | [diff] [blame] | 2248 | #endif // HAS_ARGBBLENDROW1_SSE2 |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2249 | |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2250 | #ifdef HAS_ARGBBLENDROW_SSSE3 |
| 2251 | // Shuffle table for reversing the bytes. |
| 2252 | CONST uvec8 kShuffleAlpha = { |
| 2253 | 3u, 0x80, 3u, 0x80, 7u, 0x80, 7u, 0x80, |
| 2254 | 11u, 0x80, 11u, 0x80, 15u, 0x80, 15u, 0x80 |
| 2255 | }; |
| 2256 | void ARGBBlendRow_Aligned_SSSE3(const uint8* src_argb0, const uint8* src_argb1, |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2257 | uint8* dst_argb, int width) { |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2258 | asm volatile ( |
| 2259 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 2260 | "psrlw $0xf,%%xmm7 \n" |
| 2261 | "pcmpeqb %%xmm6,%%xmm6 \n" |
| 2262 | "psrlw $0x8,%%xmm6 \n" |
| 2263 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2264 | "psllw $0x8,%%xmm5 \n" |
| 2265 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2266 | "pslld $0x18,%%xmm4 \n" |
| 2267 | |
| 2268 | // 8 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2269 | ".p2align 4 \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2270 | "1: \n" |
| 2271 | "movdqu (%0),%%xmm3 \n" |
| 2272 | "movdqa %%xmm3,%%xmm0 \n" |
| 2273 | "pxor %%xmm4,%%xmm3 \n" |
| 2274 | "pshufb %4,%%xmm3 \n" |
| 2275 | "movdqu (%1),%%xmm2 \n" |
| 2276 | "pand %%xmm6,%%xmm2 \n" |
| 2277 | "paddw %%xmm7,%%xmm3 \n" |
| 2278 | "pmullw %%xmm3,%%xmm2 \n" |
| 2279 | "movdqu (%1),%%xmm1 \n" |
| 2280 | "psrlw $0x8,%%xmm1 \n" |
| 2281 | "por %%xmm4,%%xmm0 \n" |
| 2282 | "pmullw %%xmm3,%%xmm1 \n" |
| 2283 | "movdqu 0x10(%0),%%xmm3 \n" |
| 2284 | "lea 0x20(%0),%0 \n" |
| 2285 | "psrlw $0x8,%%xmm2 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2286 | "paddusb %%xmm2,%%xmm0 \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2287 | "pand %%xmm5,%%xmm1 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2288 | "paddusb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2289 | "sub $0x4,%3 \n" |
| 2290 | "movdqa %%xmm0,(%2) \n" |
| 2291 | "jle 9f \n" |
| 2292 | "movdqa %%xmm3,%%xmm0 \n" |
| 2293 | "pxor %%xmm4,%%xmm3 \n" |
| 2294 | "movdqu 0x10(%1),%%xmm2 \n" |
| 2295 | "pshufb %4,%%xmm3 \n" |
| 2296 | "pand %%xmm6,%%xmm2 \n" |
| 2297 | "paddw %%xmm7,%%xmm3 \n" |
| 2298 | "pmullw %%xmm3,%%xmm2 \n" |
| 2299 | "movdqu 0x10(%1),%%xmm1 \n" |
| 2300 | "lea 0x20(%1),%1 \n" |
| 2301 | "psrlw $0x8,%%xmm1 \n" |
| 2302 | "por %%xmm4,%%xmm0 \n" |
| 2303 | "pmullw %%xmm3,%%xmm1 \n" |
| 2304 | "psrlw $0x8,%%xmm2 \n" |
| 2305 | "paddusb %%xmm2,%%xmm0 \n" |
| 2306 | "pand %%xmm5,%%xmm1 \n" |
| 2307 | "paddusb %%xmm1,%%xmm0 \n" |
| 2308 | "sub $0x4,%3 \n" |
| 2309 | "movdqa %%xmm0,0x10(%2) \n" |
| 2310 | "lea 0x20(%2),%2 \n" |
| 2311 | "jg 1b \n" |
| 2312 | "9: \n" |
| 2313 | : "+r"(src_argb0), // %0 |
| 2314 | "+r"(src_argb1), // %1 |
| 2315 | "+r"(dst_argb), // %2 |
| 2316 | "+r"(width) // %3 |
| 2317 | : "m"(kShuffleAlpha) // %4 |
| 2318 | : "memory", "cc" |
| 2319 | #if defined(__SSE2__) |
| 2320 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 2321 | #endif |
| 2322 | ); |
| 2323 | } |
| 2324 | #endif // HAS_ARGBBLENDROW_SSSE3 |
| 2325 | |
fbarchard@google.com | 5ff3a8f | 2012-04-24 19:43:45 +0000 | [diff] [blame] | 2326 | |
| 2327 | #ifdef HAS_ARGBBLENDROW1_SSSE3 |
| 2328 | // Blend 1 pixel at a time, unaligned |
| 2329 | void ARGBBlendRow1_SSSE3(const uint8* src_argb0, const uint8* src_argb1, |
| 2330 | uint8* dst_argb, int width) { |
| 2331 | asm volatile ( |
| 2332 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 2333 | "psrlw $0xf,%%xmm7 \n" |
| 2334 | "pcmpeqb %%xmm6,%%xmm6 \n" |
| 2335 | "psrlw $0x8,%%xmm6 \n" |
| 2336 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2337 | "psllw $0x8,%%xmm5 \n" |
| 2338 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2339 | "pslld $0x18,%%xmm4 \n" |
| 2340 | |
| 2341 | // 1 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2342 | ".p2align 4 \n" |
fbarchard@google.com | 5ff3a8f | 2012-04-24 19:43:45 +0000 | [diff] [blame] | 2343 | "1: \n" |
| 2344 | "movd (%0),%%xmm3 \n" |
| 2345 | "lea 0x4(%0),%0 \n" |
| 2346 | "movdqa %%xmm3,%%xmm0 \n" |
| 2347 | "pxor %%xmm4,%%xmm3 \n" |
| 2348 | "movd (%1),%%xmm2 \n" |
| 2349 | "pshufb %4,%%xmm3 \n" |
| 2350 | "pand %%xmm6,%%xmm2 \n" |
| 2351 | "paddw %%xmm7,%%xmm3 \n" |
| 2352 | "pmullw %%xmm3,%%xmm2 \n" |
| 2353 | "movd (%1),%%xmm1 \n" |
| 2354 | "lea 0x4(%1),%1 \n" |
| 2355 | "psrlw $0x8,%%xmm1 \n" |
| 2356 | "por %%xmm4,%%xmm0 \n" |
| 2357 | "pmullw %%xmm3,%%xmm1 \n" |
| 2358 | "psrlw $0x8,%%xmm2 \n" |
| 2359 | "paddusb %%xmm2,%%xmm0 \n" |
| 2360 | "pand %%xmm5,%%xmm1 \n" |
| 2361 | "paddusb %%xmm1,%%xmm0 \n" |
| 2362 | "sub $0x1,%3 \n" |
| 2363 | "movd %%xmm0,(%2) \n" |
| 2364 | "lea 0x4(%2),%2 \n" |
| 2365 | "jg 1b \n" |
| 2366 | : "+r"(src_argb0), // %0 |
| 2367 | "+r"(src_argb1), // %1 |
| 2368 | "+r"(dst_argb), // %2 |
| 2369 | "+r"(width) // %3 |
| 2370 | : "m"(kShuffleAlpha) // %4 |
| 2371 | : "memory", "cc" |
| 2372 | #if defined(__SSE2__) |
| 2373 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 2374 | #endif |
| 2375 | ); |
| 2376 | } |
| 2377 | #endif // HAS_ARGBBLENDROW1_SSSE3 |
| 2378 | |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2379 | #ifdef HAS_ARGBATTENUATE_SSE2 |
| 2380 | // Attenuate 4 pixels at a time. |
| 2381 | // aligned to 16 bytes |
| 2382 | void ARGBAttenuateRow_SSE2(const uint8* src_argb, uint8* dst_argb, int width) { |
| 2383 | asm volatile ( |
| 2384 | "sub %0,%1 \n" |
| 2385 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2386 | "pslld $0x18,%%xmm4 \n" |
| 2387 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2388 | "psrld $0x8,%%xmm5 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2389 | |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2390 | // 4 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2391 | ".p2align 4 \n" |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2392 | "1: \n" |
| 2393 | "movdqa (%0),%%xmm0 \n" |
| 2394 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 2395 | "pshufhw $0xff,%%xmm0,%%xmm2 \n" |
| 2396 | "pshuflw $0xff,%%xmm2,%%xmm2 \n" |
| 2397 | "pmulhuw %%xmm2,%%xmm0 \n" |
| 2398 | "movdqa (%0),%%xmm1 \n" |
| 2399 | "punpckhbw %%xmm1,%%xmm1 \n" |
| 2400 | "pshufhw $0xff,%%xmm1,%%xmm2 \n" |
| 2401 | "pshuflw $0xff,%%xmm2,%%xmm2 \n" |
| 2402 | "pmulhuw %%xmm2,%%xmm1 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2403 | "movdqa (%0),%%xmm2 \n" |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2404 | "psrlw $0x8,%%xmm0 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2405 | "pand %%xmm4,%%xmm2 \n" |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2406 | "psrlw $0x8,%%xmm1 \n" |
| 2407 | "packuswb %%xmm1,%%xmm0 \n" |
| 2408 | "pand %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2409 | "por %%xmm2,%%xmm0 \n" |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2410 | "sub $0x4,%2 \n" |
| 2411 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 2412 | "lea 0x10(%0),%0 \n" |
| 2413 | "jg 1b \n" |
| 2414 | : "+r"(src_argb), // %0 |
| 2415 | "+r"(dst_argb), // %1 |
| 2416 | "+r"(width) // %2 |
| 2417 | : |
| 2418 | : "memory", "cc" |
| 2419 | #if defined(__SSE2__) |
| 2420 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 2421 | #endif |
| 2422 | ); |
| 2423 | } |
| 2424 | #endif // HAS_ARGBATTENUATE_SSE2 |
| 2425 | |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2426 | #ifdef HAS_ARGBATTENUATE_SSSE3 |
| 2427 | // Shuffle table duplicating alpha |
| 2428 | CONST uvec8 kShuffleAlpha0 = { |
| 2429 | 3u, 3u, 3u, 3u, 3u, 3u, 128u, 128u, 7u, 7u, 7u, 7u, 7u, 7u, 128u, 128u, |
| 2430 | }; |
| 2431 | CONST uvec8 kShuffleAlpha1 = { |
| 2432 | 11u, 11u, 11u, 11u, 11u, 11u, 128u, 128u, |
| 2433 | 15u, 15u, 15u, 15u, 15u, 15u, 128u, 128u, |
| 2434 | }; |
| 2435 | // Attenuate 4 pixels at a time. |
| 2436 | // aligned to 16 bytes |
| 2437 | void ARGBAttenuateRow_SSSE3(const uint8* src_argb, uint8* dst_argb, int width) { |
| 2438 | asm volatile ( |
| 2439 | "sub %0,%1 \n" |
| 2440 | "pcmpeqb %%xmm3,%%xmm3 \n" |
| 2441 | "pslld $0x18,%%xmm3 \n" |
| 2442 | "movdqa %3,%%xmm4 \n" |
| 2443 | "movdqa %4,%%xmm5 \n" |
| 2444 | |
| 2445 | // 4 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2446 | ".p2align 4 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2447 | "1: \n" |
| 2448 | "movdqa (%0),%%xmm0 \n" |
| 2449 | "pshufb %%xmm4,%%xmm0 \n" |
| 2450 | "movdqa (%0),%%xmm1 \n" |
| 2451 | "punpcklbw %%xmm1,%%xmm1 \n" |
| 2452 | "pmulhuw %%xmm1,%%xmm0 \n" |
| 2453 | "movdqa (%0),%%xmm1 \n" |
| 2454 | "pshufb %%xmm5,%%xmm1 \n" |
| 2455 | "movdqa (%0),%%xmm2 \n" |
| 2456 | "punpckhbw %%xmm2,%%xmm2 \n" |
| 2457 | "pmulhuw %%xmm2,%%xmm1 \n" |
| 2458 | "movdqa (%0),%%xmm2 \n" |
| 2459 | "pand %%xmm3,%%xmm2 \n" |
| 2460 | "psrlw $0x8,%%xmm0 \n" |
| 2461 | "psrlw $0x8,%%xmm1 \n" |
| 2462 | "packuswb %%xmm1,%%xmm0 \n" |
| 2463 | "por %%xmm2,%%xmm0 \n" |
| 2464 | "sub $0x4,%2 \n" |
| 2465 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 2466 | "lea 0x10(%0),%0 \n" |
| 2467 | "jg 1b \n" |
| 2468 | : "+r"(src_argb), // %0 |
| 2469 | "+r"(dst_argb), // %1 |
| 2470 | "+r"(width) // %2 |
| 2471 | : "m"(kShuffleAlpha0), // %3 |
| 2472 | "m"(kShuffleAlpha1) // %4 |
| 2473 | : "memory", "cc" |
| 2474 | #if defined(__SSE2__) |
| 2475 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 2476 | #endif |
| 2477 | ); |
| 2478 | } |
| 2479 | #endif // HAS_ARGBATTENUATE_SSSE3 |
| 2480 | |
| 2481 | #ifdef HAS_ARGBUNATTENUATE_SSE2 |
| 2482 | // Divide source RGB by alpha and store to destination. |
| 2483 | // b = (b * 255 + (a / 2)) / a; |
| 2484 | // g = (g * 255 + (a / 2)) / a; |
| 2485 | // r = (r * 255 + (a / 2)) / a; |
| 2486 | // Reciprocal method is off by 1 on some values. ie 125 |
| 2487 | // 8.16 fixed point inverse table |
| 2488 | #define T(a) 0x10000 / a |
| 2489 | CONST uint32 fixed_invtbl8[256] = { |
| 2490 | 0x100, 0xffff, T(0x02), T(0x03), T(0x04), T(0x05), T(0x06), T(0x07), |
| 2491 | T(0x08), T(0x09), T(0x0a), T(0x0b), T(0x0c), T(0x0d), T(0x0e), T(0x0f), |
| 2492 | T(0x10), T(0x11), T(0x12), T(0x13), T(0x14), T(0x15), T(0x16), T(0x17), |
| 2493 | T(0x18), T(0x19), T(0x1a), T(0x1b), T(0x1c), T(0x1d), T(0x1e), T(0x1f), |
| 2494 | T(0x20), T(0x21), T(0x22), T(0x23), T(0x24), T(0x25), T(0x26), T(0x27), |
| 2495 | T(0x28), T(0x29), T(0x2a), T(0x2b), T(0x2c), T(0x2d), T(0x2e), T(0x2f), |
| 2496 | T(0x30), T(0x31), T(0x32), T(0x33), T(0x34), T(0x35), T(0x36), T(0x37), |
| 2497 | T(0x38), T(0x39), T(0x3a), T(0x3b), T(0x3c), T(0x3d), T(0x3e), T(0x3f), |
| 2498 | T(0x40), T(0x41), T(0x42), T(0x43), T(0x44), T(0x45), T(0x46), T(0x47), |
| 2499 | T(0x48), T(0x49), T(0x4a), T(0x4b), T(0x4c), T(0x4d), T(0x4e), T(0x4f), |
| 2500 | T(0x50), T(0x51), T(0x52), T(0x53), T(0x54), T(0x55), T(0x56), T(0x57), |
| 2501 | T(0x58), T(0x59), T(0x5a), T(0x5b), T(0x5c), T(0x5d), T(0x5e), T(0x5f), |
| 2502 | T(0x60), T(0x61), T(0x62), T(0x63), T(0x64), T(0x65), T(0x66), T(0x67), |
| 2503 | T(0x68), T(0x69), T(0x6a), T(0x6b), T(0x6c), T(0x6d), T(0x6e), T(0x6f), |
| 2504 | T(0x70), T(0x71), T(0x72), T(0x73), T(0x74), T(0x75), T(0x76), T(0x77), |
| 2505 | T(0x78), T(0x79), T(0x7a), T(0x7b), T(0x7c), T(0x7d), T(0x7e), T(0x7f), |
| 2506 | T(0x80), T(0x81), T(0x82), T(0x83), T(0x84), T(0x85), T(0x86), T(0x87), |
| 2507 | T(0x88), T(0x89), T(0x8a), T(0x8b), T(0x8c), T(0x8d), T(0x8e), T(0x8f), |
| 2508 | T(0x90), T(0x91), T(0x92), T(0x93), T(0x94), T(0x95), T(0x96), T(0x97), |
| 2509 | T(0x98), T(0x99), T(0x9a), T(0x9b), T(0x9c), T(0x9d), T(0x9e), T(0x9f), |
| 2510 | T(0xa0), T(0xa1), T(0xa2), T(0xa3), T(0xa4), T(0xa5), T(0xa6), T(0xa7), |
| 2511 | T(0xa8), T(0xa9), T(0xaa), T(0xab), T(0xac), T(0xad), T(0xae), T(0xaf), |
| 2512 | T(0xb0), T(0xb1), T(0xb2), T(0xb3), T(0xb4), T(0xb5), T(0xb6), T(0xb7), |
| 2513 | T(0xb8), T(0xb9), T(0xba), T(0xbb), T(0xbc), T(0xbd), T(0xbe), T(0xbf), |
| 2514 | T(0xc0), T(0xc1), T(0xc2), T(0xc3), T(0xc4), T(0xc5), T(0xc6), T(0xc7), |
| 2515 | T(0xc8), T(0xc9), T(0xca), T(0xcb), T(0xcc), T(0xcd), T(0xce), T(0xcf), |
| 2516 | T(0xd0), T(0xd1), T(0xd2), T(0xd3), T(0xd4), T(0xd5), T(0xd6), T(0xd7), |
| 2517 | T(0xd8), T(0xd9), T(0xda), T(0xdb), T(0xdc), T(0xdd), T(0xde), T(0xdf), |
| 2518 | T(0xe0), T(0xe1), T(0xe2), T(0xe3), T(0xe4), T(0xe5), T(0xe6), T(0xe7), |
| 2519 | T(0xe8), T(0xe9), T(0xea), T(0xeb), T(0xec), T(0xed), T(0xee), T(0xef), |
| 2520 | T(0xf0), T(0xf1), T(0xf2), T(0xf3), T(0xf4), T(0xf5), T(0xf6), T(0xf7), |
| 2521 | T(0xf8), T(0xf9), T(0xfa), T(0xfb), T(0xfc), T(0xfd), T(0xfe), 0x100 }; |
| 2522 | #undef T |
| 2523 | |
| 2524 | // Unattenuate 4 pixels at a time. |
| 2525 | // aligned to 16 bytes |
| 2526 | void ARGBUnattenuateRow_SSE2(const uint8* src_argb, uint8* dst_argb, |
| 2527 | int width) { |
| 2528 | uintptr_t alpha = 0; |
| 2529 | asm volatile ( |
| 2530 | "sub %0,%1 \n" |
| 2531 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2532 | "pslld $0x18,%%xmm4 \n" |
| 2533 | |
| 2534 | // 4 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2535 | ".p2align 4 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2536 | "1: \n" |
| 2537 | "movdqa (%0),%%xmm0 \n" |
| 2538 | "movzb 0x3(%0),%3 \n" |
| 2539 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 2540 | "movd 0x0(%4,%3,4),%%xmm2 \n" |
| 2541 | "movzb 0x7(%0),%3 \n" |
| 2542 | "movd 0x0(%4,%3,4),%%xmm3 \n" |
| 2543 | "pshuflw $0xc0,%%xmm2,%%xmm2 \n" |
| 2544 | "pshuflw $0xc0,%%xmm3,%%xmm3 \n" |
| 2545 | "movlhps %%xmm3,%%xmm2 \n" |
| 2546 | "pmulhuw %%xmm2,%%xmm0 \n" |
| 2547 | "movdqa (%0),%%xmm1 \n" |
| 2548 | "movzb 0xb(%0),%3 \n" |
| 2549 | "punpckhbw %%xmm1,%%xmm1 \n" |
| 2550 | "movd 0x0(%4,%3,4),%%xmm2 \n" |
| 2551 | "movzb 0xf(%0),%3 \n" |
| 2552 | "movd 0x0(%4,%3,4),%%xmm3 \n" |
| 2553 | "pshuflw $0xc0,%%xmm2,%%xmm2 \n" |
| 2554 | "pshuflw $0xc0,%%xmm3,%%xmm3 \n" |
| 2555 | "movlhps %%xmm3,%%xmm2 \n" |
| 2556 | "pmulhuw %%xmm2,%%xmm1 \n" |
| 2557 | "movdqa (%0),%%xmm2 \n" |
| 2558 | "pand %%xmm4,%%xmm2 \n" |
| 2559 | "packuswb %%xmm1,%%xmm0 \n" |
| 2560 | "por %%xmm2,%%xmm0 \n" |
| 2561 | "sub $0x4,%2 \n" |
| 2562 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 2563 | "lea 0x10(%0),%0 \n" |
| 2564 | "jg 1b \n" |
| 2565 | : "+r"(src_argb), // %0 |
| 2566 | "+r"(dst_argb), // %1 |
| 2567 | "+r"(width), // %2 |
| 2568 | "+r"(alpha) // %3 |
| 2569 | : "r"(fixed_invtbl8) // %4 |
| 2570 | : "memory", "cc" |
| 2571 | #if defined(__SSE2__) |
| 2572 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 2573 | #endif |
| 2574 | ); |
| 2575 | } |
| 2576 | #endif // HAS_ARGBUNATTENUATE_SSE2 |
| 2577 | |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 2578 | #endif // defined(__x86_64__) || defined(__i386__) |
| 2579 | |
fbarchard@google.com | fe5ff7e | 2011-12-10 07:45:58 +0000 | [diff] [blame] | 2580 | #ifdef __cplusplus |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 2581 | } // extern "C" |
fbarchard@google.com | fe5ff7e | 2011-12-10 07:45:58 +0000 | [diff] [blame] | 2582 | } // namespace libyuv |
| 2583 | #endif |