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" |
fbarchard@google.com | 6d6b770 | 2012-06-04 15:29:15 +0000 | [diff] [blame] | 275 | "mov $0x20802080,%%eax \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 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 | #endif // HAS_ARGBTOYROW_SSSE3 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1216 | |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1217 | #ifdef HAS_I422TOARGBROW_SSSE3 |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1218 | #define UB 127 /* min(63,static_cast<int8>(2.018 * 64)) */ |
| 1219 | #define UG -25 /* static_cast<int8>(-0.391 * 64 - 0.5) */ |
| 1220 | #define UR 0 |
| 1221 | |
| 1222 | #define VB 0 |
| 1223 | #define VG -52 /* static_cast<int8>(-0.813 * 64 - 0.5) */ |
| 1224 | #define VR 102 /* static_cast<int8>(1.596 * 64 + 0.5) */ |
| 1225 | |
| 1226 | // Bias |
| 1227 | #define BB UB * 128 + VB * 128 |
| 1228 | #define BG UG * 128 + VG * 128 |
| 1229 | #define BR UR * 128 + VR * 128 |
| 1230 | |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1231 | #define YG 74 /* static_cast<int8>(1.164 * 64 + 0.5) */ |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1232 | |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1233 | struct { |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1234 | vec8 kUVToB; // 0 |
| 1235 | vec8 kUVToG; // 16 |
| 1236 | vec8 kUVToR; // 32 |
| 1237 | vec16 kUVBiasB; // 48 |
| 1238 | vec16 kUVBiasG; // 64 |
| 1239 | vec16 kUVBiasR; // 80 |
| 1240 | vec16 kYSub16; // 96 |
| 1241 | vec16 kYToRgb; // 112 |
| 1242 | vec8 kVUToB; // 128 |
| 1243 | vec8 kVUToG; // 144 |
| 1244 | vec8 kVUToR; // 160 |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1245 | } CONST SIMD_ALIGNED(kYuvConstants) = { |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1246 | { UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB }, |
| 1247 | { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG }, |
| 1248 | { UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR }, |
| 1249 | { BB, BB, BB, BB, BB, BB, BB, BB }, |
| 1250 | { BG, BG, BG, BG, BG, BG, BG, BG }, |
| 1251 | { BR, BR, BR, BR, BR, BR, BR, BR }, |
| 1252 | { 16, 16, 16, 16, 16, 16, 16, 16 }, |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1253 | { YG, YG, YG, YG, YG, YG, YG, YG }, |
| 1254 | { VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB }, |
| 1255 | { VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG }, |
| 1256 | { VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR } |
fbarchard@google.com | 1c2d8be | 2011-11-17 21:57:54 +0000 | [diff] [blame] | 1257 | }; |
| 1258 | |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1259 | |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1260 | // Read 8 UV from 411 |
| 1261 | #define READYUV444 \ |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1262 | "movq (%[u_buf]),%%xmm0 \n" \ |
| 1263 | "movq (%[u_buf],%[v_buf],1),%%xmm1 \n" \ |
| 1264 | "lea 0x8(%[u_buf]),%[u_buf] \n" \ |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1265 | "punpcklbw %%xmm1,%%xmm0 \n" \ |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1266 | |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1267 | // Read 4 UV from 422, upsample to 8 UV |
| 1268 | #define READYUV422 \ |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1269 | "movd (%[u_buf]),%%xmm0 \n" \ |
| 1270 | "movd (%[u_buf],%[v_buf],1),%%xmm1 \n" \ |
| 1271 | "lea 0x4(%[u_buf]),%[u_buf] \n" \ |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1272 | "punpcklbw %%xmm1,%%xmm0 \n" \ |
| 1273 | "punpcklwd %%xmm0,%%xmm0 \n" \ |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1274 | |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1275 | // Read 2 UV from 411, upsample to 8 UV |
| 1276 | #define READYUV411 \ |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1277 | "movd (%[u_buf]),%%xmm0 \n" \ |
| 1278 | "movd (%[u_buf],%[v_buf],1),%%xmm1 \n" \ |
| 1279 | "lea 0x2(%[u_buf]),%[u_buf] \n" \ |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1280 | "punpcklbw %%xmm1,%%xmm0 \n" \ |
| 1281 | "punpcklwd %%xmm0,%%xmm0 \n" \ |
| 1282 | "punpckldq %%xmm0,%%xmm0 \n" \ |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1283 | |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1284 | // Read 4 UV from NV12, upsample to 8 UV |
| 1285 | #define READNV12 \ |
| 1286 | "movq (%[uv_buf]),%%xmm0 \n" \ |
| 1287 | "lea 0x8(%[uv_buf]),%[uv_buf] \n" \ |
| 1288 | "punpcklbw %%xmm1,%%xmm0 \n" \ |
| 1289 | |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1290 | // Convert 8 pixels: 8 UV and 8 Y |
| 1291 | #define YUVTORGB \ |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1292 | "movdqa %%xmm0,%%xmm1 \n" \ |
| 1293 | "movdqa %%xmm0,%%xmm2 \n" \ |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1294 | "pmaddubsw (%[kYuvConstants]),%%xmm0 \n" \ |
| 1295 | "pmaddubsw 16(%[kYuvConstants]),%%xmm1 \n" \ |
| 1296 | "pmaddubsw 32(%[kYuvConstants]),%%xmm2 \n" \ |
| 1297 | "psubw 48(%[kYuvConstants]),%%xmm0 \n" \ |
| 1298 | "psubw 64(%[kYuvConstants]),%%xmm1 \n" \ |
| 1299 | "psubw 80(%[kYuvConstants]),%%xmm2 \n" \ |
| 1300 | "movq (%[y_buf]),%%xmm3 \n" \ |
| 1301 | "lea 0x8(%[y_buf]),%[y_buf] \n" \ |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1302 | "punpcklbw %%xmm4,%%xmm3 \n" \ |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1303 | "psubsw 96(%[kYuvConstants]),%%xmm3 \n" \ |
| 1304 | "pmullw 112(%[kYuvConstants]),%%xmm3 \n" \ |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1305 | "paddsw %%xmm3,%%xmm0 \n" \ |
| 1306 | "paddsw %%xmm3,%%xmm1 \n" \ |
| 1307 | "paddsw %%xmm3,%%xmm2 \n" \ |
| 1308 | "psraw $0x6,%%xmm0 \n" \ |
| 1309 | "psraw $0x6,%%xmm1 \n" \ |
| 1310 | "psraw $0x6,%%xmm2 \n" \ |
| 1311 | "packuswb %%xmm0,%%xmm0 \n" \ |
| 1312 | "packuswb %%xmm1,%%xmm1 \n" \ |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1313 | "packuswb %%xmm2,%%xmm2 \n" \ |
| 1314 | |
| 1315 | // Convert 8 pixels: 8 VU and 8 Y |
| 1316 | #define YVUTORGB \ |
| 1317 | "movdqa %%xmm0,%%xmm1 \n" \ |
| 1318 | "movdqa %%xmm0,%%xmm2 \n" \ |
| 1319 | "pmaddubsw 128(%[kYuvConstants]),%%xmm0 \n" \ |
| 1320 | "pmaddubsw 144(%[kYuvConstants]),%%xmm1 \n" \ |
| 1321 | "pmaddubsw 160(%[kYuvConstants]),%%xmm2 \n" \ |
| 1322 | "psubw 48(%[kYuvConstants]),%%xmm0 \n" \ |
| 1323 | "psubw 64(%[kYuvConstants]),%%xmm1 \n" \ |
| 1324 | "psubw 80(%[kYuvConstants]),%%xmm2 \n" \ |
| 1325 | "movq (%[y_buf]),%%xmm3 \n" \ |
| 1326 | "lea 0x8(%[y_buf]),%[y_buf] \n" \ |
| 1327 | "punpcklbw %%xmm4,%%xmm3 \n" \ |
| 1328 | "psubsw 96(%[kYuvConstants]),%%xmm3 \n" \ |
| 1329 | "pmullw 112(%[kYuvConstants]),%%xmm3 \n" \ |
| 1330 | "paddsw %%xmm3,%%xmm0 \n" \ |
| 1331 | "paddsw %%xmm3,%%xmm1 \n" \ |
| 1332 | "paddsw %%xmm3,%%xmm2 \n" \ |
| 1333 | "psraw $0x6,%%xmm0 \n" \ |
| 1334 | "psraw $0x6,%%xmm1 \n" \ |
| 1335 | "psraw $0x6,%%xmm2 \n" \ |
| 1336 | "packuswb %%xmm0,%%xmm0 \n" \ |
| 1337 | "packuswb %%xmm1,%%xmm1 \n" \ |
| 1338 | "packuswb %%xmm2,%%xmm2 \n" \ |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1339 | |
| 1340 | void OMITFP I444ToARGBRow_SSSE3(const uint8* y_buf, |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1341 | const uint8* u_buf, |
| 1342 | const uint8* v_buf, |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1343 | uint8* argb_buf, |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1344 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1345 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1346 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1347 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1348 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1349 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1350 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1351 | READYUV444 |
| 1352 | YUVTORGB |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1353 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1354 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1355 | "movdqa %%xmm0,%%xmm1 \n" |
| 1356 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1357 | "punpckhwd %%xmm2,%%xmm1 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1358 | "movdqa %%xmm0,(%[argb_buf]) \n" |
| 1359 | "movdqa %%xmm1,0x10(%[argb_buf]) \n" |
| 1360 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1361 | "sub $0x8,%[width] \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1362 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1363 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1364 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1365 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1366 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1367 | [width]"+rm"(width) // %[width] |
| 1368 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1369 | : "memory", "cc" |
| 1370 | #if defined(__SSE2__) |
| 1371 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1372 | #endif |
| 1373 | ); |
| 1374 | } |
| 1375 | |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1376 | void OMITFP I422ToARGBRow_SSSE3(const uint8* y_buf, |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1377 | const uint8* u_buf, |
| 1378 | const uint8* v_buf, |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1379 | uint8* argb_buf, |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1380 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1381 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1382 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1383 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1384 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1385 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1386 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1387 | READYUV422 |
| 1388 | YUVTORGB |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1389 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1390 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1391 | "movdqa %%xmm0,%%xmm1 \n" |
| 1392 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1393 | "punpckhwd %%xmm2,%%xmm1 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1394 | "movdqa %%xmm0,(%[argb_buf]) \n" |
| 1395 | "movdqa %%xmm1,0x10(%[argb_buf]) \n" |
| 1396 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1397 | "sub $0x8,%[width] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1398 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1399 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1400 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1401 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1402 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1403 | [width]"+rm"(width) // %[width] |
| 1404 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1405 | : "memory", "cc" |
| 1406 | #if defined(__SSE2__) |
| 1407 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1408 | #endif |
| 1409 | ); |
| 1410 | } |
| 1411 | |
| 1412 | void OMITFP I411ToARGBRow_SSSE3(const uint8* y_buf, |
| 1413 | const uint8* u_buf, |
| 1414 | const uint8* v_buf, |
| 1415 | uint8* argb_buf, |
| 1416 | int width) { |
| 1417 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1418 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1419 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1420 | "pxor %%xmm4,%%xmm4 \n" |
| 1421 | ".p2align 4 \n" |
| 1422 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1423 | READYUV411 |
| 1424 | YUVTORGB |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1425 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1426 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1427 | "movdqa %%xmm0,%%xmm1 \n" |
| 1428 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1429 | "punpckhwd %%xmm2,%%xmm1 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1430 | "movdqa %%xmm0,(%[argb_buf]) \n" |
| 1431 | "movdqa %%xmm1,0x10(%[argb_buf]) \n" |
| 1432 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1433 | "sub $0x8,%[width] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1434 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1435 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1436 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1437 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1438 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1439 | [width]"+rm"(width) // %[width] |
| 1440 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
| 1441 | : "memory", "cc" |
| 1442 | #if defined(__SSE2__) |
| 1443 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1444 | #endif |
| 1445 | ); |
| 1446 | } |
| 1447 | |
| 1448 | void OMITFP NV12ToARGBRow_SSSE3(const uint8* y_buf, |
| 1449 | const uint8* uv_buf, |
| 1450 | uint8* argb_buf, |
| 1451 | int width) { |
| 1452 | asm volatile ( |
| 1453 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1454 | "pxor %%xmm4,%%xmm4 \n" |
| 1455 | ".p2align 4 \n" |
| 1456 | "1: \n" |
| 1457 | READNV12 |
| 1458 | YUVTORGB |
| 1459 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1460 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1461 | "movdqa %%xmm0,%%xmm1 \n" |
| 1462 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1463 | "punpckhwd %%xmm2,%%xmm1 \n" |
| 1464 | "movdqa %%xmm0,(%[argb_buf]) \n" |
| 1465 | "movdqa %%xmm1,0x10(%[argb_buf]) \n" |
| 1466 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1467 | "sub $0x8,%[width] \n" |
| 1468 | "jg 1b \n" |
| 1469 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1470 | [uv_buf]"+r"(uv_buf), // %[uv_buf] |
| 1471 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1472 | [width]"+rm"(width) // %[width] |
| 1473 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
| 1474 | : "memory", "cc" |
| 1475 | #if defined(__SSE2__) |
| 1476 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1477 | #endif |
| 1478 | ); |
| 1479 | } |
| 1480 | |
| 1481 | void OMITFP NV21ToARGBRow_SSSE3(const uint8* y_buf, |
| 1482 | const uint8* vu_buf, |
| 1483 | uint8* argb_buf, |
| 1484 | int width) { |
| 1485 | asm volatile ( |
| 1486 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1487 | "pxor %%xmm4,%%xmm4 \n" |
| 1488 | ".p2align 4 \n" |
| 1489 | "1: \n" |
| 1490 | READNV12 |
| 1491 | YVUTORGB |
| 1492 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1493 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1494 | "movdqa %%xmm0,%%xmm1 \n" |
| 1495 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1496 | "punpckhwd %%xmm2,%%xmm1 \n" |
| 1497 | "movdqa %%xmm0,(%[argb_buf]) \n" |
| 1498 | "movdqa %%xmm1,0x10(%[argb_buf]) \n" |
| 1499 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1500 | "sub $0x8,%[width] \n" |
| 1501 | "jg 1b \n" |
| 1502 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1503 | [uv_buf]"+r"(vu_buf), // %[uv_buf] |
| 1504 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1505 | [width]"+rm"(width) // %[width] |
| 1506 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1507 | : "memory", "cc" |
| 1508 | #if defined(__SSE2__) |
| 1509 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1510 | #endif |
| 1511 | ); |
| 1512 | } |
| 1513 | |
| 1514 | void OMITFP I444ToARGBRow_Unaligned_SSSE3(const uint8* y_buf, |
| 1515 | const uint8* u_buf, |
| 1516 | const uint8* v_buf, |
| 1517 | uint8* argb_buf, |
| 1518 | int width) { |
| 1519 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1520 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1521 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1522 | "pxor %%xmm4,%%xmm4 \n" |
| 1523 | ".p2align 4 \n" |
| 1524 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1525 | READYUV444 |
| 1526 | YUVTORGB |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1527 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1528 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1529 | "movdqa %%xmm0,%%xmm1 \n" |
| 1530 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1531 | "punpckhwd %%xmm2,%%xmm1 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1532 | "movdqu %%xmm0,(%[argb_buf]) \n" |
| 1533 | "movdqu %%xmm1,0x10(%[argb_buf]) \n" |
| 1534 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1535 | "sub $0x8,%[width] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1536 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1537 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1538 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1539 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1540 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1541 | [width]"+rm"(width) // %[width] |
| 1542 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1543 | : "memory", "cc" |
| 1544 | #if defined(__SSE2__) |
| 1545 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1546 | #endif |
| 1547 | ); |
| 1548 | } |
| 1549 | |
| 1550 | void OMITFP I422ToARGBRow_Unaligned_SSSE3(const uint8* y_buf, |
| 1551 | const uint8* u_buf, |
| 1552 | const uint8* v_buf, |
| 1553 | uint8* argb_buf, |
| 1554 | int width) { |
| 1555 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1556 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1557 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1558 | "pxor %%xmm4,%%xmm4 \n" |
| 1559 | ".p2align 4 \n" |
| 1560 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1561 | READYUV422 |
| 1562 | YUVTORGB |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1563 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1564 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1565 | "movdqa %%xmm0,%%xmm1 \n" |
| 1566 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1567 | "punpckhwd %%xmm2,%%xmm1 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1568 | "movdqu %%xmm0,(%[argb_buf]) \n" |
| 1569 | "movdqu %%xmm1,0x10(%[argb_buf]) \n" |
| 1570 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1571 | "sub $0x8,%[width] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1572 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1573 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1574 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1575 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1576 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1577 | [width]"+rm"(width) // %[width] |
| 1578 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1579 | : "memory", "cc" |
| 1580 | #if defined(__SSE2__) |
| 1581 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1582 | #endif |
| 1583 | ); |
| 1584 | } |
| 1585 | |
| 1586 | void OMITFP I411ToARGBRow_Unaligned_SSSE3(const uint8* y_buf, |
| 1587 | const uint8* u_buf, |
| 1588 | const uint8* v_buf, |
| 1589 | uint8* argb_buf, |
| 1590 | int width) { |
| 1591 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1592 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1593 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1594 | "pxor %%xmm4,%%xmm4 \n" |
| 1595 | ".p2align 4 \n" |
| 1596 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1597 | READYUV411 |
| 1598 | YUVTORGB |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1599 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1600 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1601 | "movdqa %%xmm0,%%xmm1 \n" |
| 1602 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1603 | "punpckhwd %%xmm2,%%xmm1 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1604 | "movdqu %%xmm0,(%[argb_buf]) \n" |
| 1605 | "movdqu %%xmm1,0x10(%[argb_buf]) \n" |
| 1606 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1607 | "sub $0x8,%[width] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1608 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1609 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1610 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1611 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1612 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1613 | [width]"+rm"(width) // %[width] |
| 1614 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
| 1615 | : "memory", "cc" |
| 1616 | #if defined(__SSE2__) |
| 1617 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1618 | #endif |
| 1619 | ); |
| 1620 | } |
| 1621 | |
| 1622 | void OMITFP NV12ToARGBRow_Unaligned_SSSE3(const uint8* y_buf, |
| 1623 | const uint8* uv_buf, |
| 1624 | uint8* argb_buf, |
| 1625 | int width) { |
| 1626 | asm volatile ( |
| 1627 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1628 | "pxor %%xmm4,%%xmm4 \n" |
| 1629 | ".p2align 4 \n" |
| 1630 | "1: \n" |
| 1631 | READNV12 |
| 1632 | YUVTORGB |
| 1633 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1634 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1635 | "movdqa %%xmm0,%%xmm1 \n" |
| 1636 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1637 | "punpckhwd %%xmm2,%%xmm1 \n" |
| 1638 | "movdqu %%xmm0,(%[argb_buf]) \n" |
| 1639 | "movdqu %%xmm1,0x10(%[argb_buf]) \n" |
| 1640 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1641 | "sub $0x8,%[width] \n" |
| 1642 | "jg 1b \n" |
| 1643 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1644 | [uv_buf]"+r"(uv_buf), // %[uv_buf] |
| 1645 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1646 | [width]"+rm"(width) // %[width] |
| 1647 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
| 1648 | : "memory", "cc" |
| 1649 | #if defined(__SSE2__) |
| 1650 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1651 | #endif |
| 1652 | ); |
| 1653 | } |
| 1654 | |
| 1655 | void OMITFP NV21ToARGBRow_Unaligned_SSSE3(const uint8* y_buf, |
| 1656 | const uint8* vu_buf, |
| 1657 | uint8* argb_buf, |
| 1658 | int width) { |
| 1659 | asm volatile ( |
| 1660 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1661 | "pxor %%xmm4,%%xmm4 \n" |
| 1662 | ".p2align 4 \n" |
| 1663 | "1: \n" |
| 1664 | READNV12 |
| 1665 | YVUTORGB |
| 1666 | "punpcklbw %%xmm1,%%xmm0 \n" |
| 1667 | "punpcklbw %%xmm5,%%xmm2 \n" |
| 1668 | "movdqa %%xmm0,%%xmm1 \n" |
| 1669 | "punpcklwd %%xmm2,%%xmm0 \n" |
| 1670 | "punpckhwd %%xmm2,%%xmm1 \n" |
| 1671 | "movdqu %%xmm0,(%[argb_buf]) \n" |
| 1672 | "movdqu %%xmm1,0x10(%[argb_buf]) \n" |
| 1673 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1674 | "sub $0x8,%[width] \n" |
| 1675 | "jg 1b \n" |
| 1676 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1677 | [uv_buf]"+r"(vu_buf), // %[uv_buf] |
| 1678 | [argb_buf]"+r"(argb_buf), // %[argb_buf] |
| 1679 | [width]"+rm"(width) // %[width] |
| 1680 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1681 | : "memory", "cc" |
| 1682 | #if defined(__SSE2__) |
| 1683 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1684 | #endif |
| 1685 | ); |
| 1686 | } |
| 1687 | |
| 1688 | void OMITFP I422ToBGRARow_SSSE3(const uint8* y_buf, |
| 1689 | const uint8* u_buf, |
| 1690 | const uint8* v_buf, |
| 1691 | uint8* bgra_buf, |
| 1692 | int width) { |
| 1693 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1694 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1695 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1696 | "pxor %%xmm4,%%xmm4 \n" |
| 1697 | ".p2align 4 \n" |
| 1698 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1699 | READYUV422 |
| 1700 | YUVTORGB |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1701 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1702 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 1703 | "punpcklbw %%xmm2,%%xmm5 \n" |
| 1704 | "movdqa %%xmm5,%%xmm0 \n" |
| 1705 | "punpcklwd %%xmm1,%%xmm5 \n" |
| 1706 | "punpckhwd %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1707 | "movdqa %%xmm5,(%[argb_buf]) \n" |
| 1708 | "movdqa %%xmm0,0x10(%[argb_buf]) \n" |
| 1709 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1710 | "sub $0x8,%[width] \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1711 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1712 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1713 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1714 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1715 | [argb_buf]"+r"(bgra_buf), // %[argb_buf] |
| 1716 | [width]"+rm"(width) // %[width] |
| 1717 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1718 | : "memory", "cc" |
| 1719 | #if defined(__SSE2__) |
| 1720 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1721 | #endif |
| 1722 | ); |
| 1723 | } |
| 1724 | |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1725 | void OMITFP I422ToABGRRow_SSSE3(const uint8* y_buf, |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1726 | const uint8* u_buf, |
| 1727 | const uint8* v_buf, |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1728 | uint8* abgr_buf, |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1729 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1730 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1731 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1732 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1733 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1734 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1735 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1736 | READYUV422 |
| 1737 | YUVTORGB |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1738 | "punpcklbw %%xmm1,%%xmm2 \n" |
| 1739 | "punpcklbw %%xmm5,%%xmm0 \n" |
| 1740 | "movdqa %%xmm2,%%xmm1 \n" |
| 1741 | "punpcklwd %%xmm0,%%xmm2 \n" |
| 1742 | "punpckhwd %%xmm0,%%xmm1 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1743 | "movdqa %%xmm2,(%[argb_buf]) \n" |
| 1744 | "movdqa %%xmm1,0x10(%[argb_buf]) \n" |
| 1745 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1746 | "sub $0x8,%[width] \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1747 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1748 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1749 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1750 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1751 | [argb_buf]"+r"(abgr_buf), // %[argb_buf] |
| 1752 | [width]"+rm"(width) // %[width] |
| 1753 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1754 | : "memory", "cc" |
| 1755 | #if defined(__SSE2__) |
| 1756 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1757 | #endif |
| 1758 | ); |
| 1759 | } |
| 1760 | |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1761 | void OMITFP I422ToBGRARow_Unaligned_SSSE3(const uint8* y_buf, |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1762 | const uint8* u_buf, |
| 1763 | const uint8* v_buf, |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1764 | uint8* bgra_buf, |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1765 | int width) { |
| 1766 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1767 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1768 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1769 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1770 | ".p2align 4 \n" |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1771 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1772 | READYUV422 |
| 1773 | YUVTORGB |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1774 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1775 | "punpcklbw %%xmm0,%%xmm1 \n" |
| 1776 | "punpcklbw %%xmm2,%%xmm5 \n" |
| 1777 | "movdqa %%xmm5,%%xmm0 \n" |
| 1778 | "punpcklwd %%xmm1,%%xmm5 \n" |
| 1779 | "punpckhwd %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1780 | "movdqu %%xmm5,(%[argb_buf]) \n" |
| 1781 | "movdqu %%xmm0,0x10(%[argb_buf]) \n" |
| 1782 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1783 | "sub $0x8,%[width] \n" |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1784 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1785 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1786 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1787 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1788 | [argb_buf]"+r"(bgra_buf), // %[argb_buf] |
| 1789 | [width]"+rm"(width) // %[width] |
| 1790 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1791 | : "memory", "cc" |
| 1792 | #if defined(__SSE2__) |
| 1793 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1794 | #endif |
| 1795 | ); |
| 1796 | } |
| 1797 | |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1798 | void OMITFP I422ToABGRRow_Unaligned_SSSE3(const uint8* y_buf, |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1799 | const uint8* u_buf, |
| 1800 | const uint8* v_buf, |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1801 | uint8* abgr_buf, |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1802 | int width) { |
| 1803 | asm volatile ( |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1804 | "sub %[u_buf],%[v_buf] \n" |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1805 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1806 | "pxor %%xmm4,%%xmm4 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1807 | ".p2align 4 \n" |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1808 | "1: \n" |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1809 | READYUV422 |
| 1810 | YUVTORGB |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1811 | "punpcklbw %%xmm1,%%xmm2 \n" |
| 1812 | "punpcklbw %%xmm5,%%xmm0 \n" |
| 1813 | "movdqa %%xmm2,%%xmm1 \n" |
| 1814 | "punpcklwd %%xmm0,%%xmm2 \n" |
| 1815 | "punpckhwd %%xmm0,%%xmm1 \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1816 | "movdqu %%xmm2,(%[argb_buf]) \n" |
| 1817 | "movdqu %%xmm1,0x10(%[argb_buf]) \n" |
| 1818 | "lea 0x20(%[argb_buf]),%[argb_buf] \n" |
| 1819 | "sub $0x8,%[width] \n" |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1820 | "jg 1b \n" |
fbarchard@google.com | 2d9fe08 | 2012-06-05 22:11:34 +0000 | [diff] [blame] | 1821 | : [y_buf]"+r"(y_buf), // %[y_buf] |
| 1822 | [u_buf]"+r"(u_buf), // %[u_buf] |
| 1823 | [v_buf]"+r"(v_buf), // %[v_buf] |
| 1824 | [argb_buf]"+r"(abgr_buf), // %[argb_buf] |
| 1825 | [width]"+rm"(width) // %[width] |
| 1826 | : [kYuvConstants]"r"(&kYuvConstants.kUVToB) // %[kYuvConstants] |
fbarchard@google.com | 952a507 | 2012-03-30 18:10:50 +0000 | [diff] [blame] | 1827 | : "memory", "cc" |
| 1828 | #if defined(__SSE2__) |
| 1829 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 1830 | #endif |
| 1831 | ); |
| 1832 | } |
fbarchard@google.com | e214fe3 | 2012-06-04 23:47:11 +0000 | [diff] [blame] | 1833 | #endif // HAS_I422TOARGBROW_SSSE3 |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1834 | |
| 1835 | #ifdef HAS_YTOARGBROW_SSE2 |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 1836 | void YToARGBRow_SSE2(const uint8* y_buf, |
| 1837 | uint8* rgb_buf, |
| 1838 | int width) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1839 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1840 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 1841 | "pslld $0x18,%%xmm4 \n" |
| 1842 | "mov $0x10001000,%%eax \n" |
| 1843 | "movd %%eax,%%xmm3 \n" |
| 1844 | "pshufd $0x0,%%xmm3,%%xmm3 \n" |
| 1845 | "mov $0x012a012a,%%eax \n" |
| 1846 | "movd %%eax,%%xmm2 \n" |
| 1847 | "pshufd $0x0,%%xmm2,%%xmm2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1848 | ".p2align 4 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1849 | "1: \n" |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1850 | // 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] | 1851 | "movq (%0),%%xmm0 \n" |
| 1852 | "lea 0x8(%0),%0 \n" |
| 1853 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 1854 | "psubusw %%xmm3,%%xmm0 \n" |
| 1855 | "pmulhuw %%xmm2,%%xmm0 \n" |
| 1856 | "packuswb %%xmm0,%%xmm0 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1857 | |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1858 | // Step 2: Weave into ARGB |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1859 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 1860 | "movdqa %%xmm0,%%xmm1 \n" |
| 1861 | "punpcklwd %%xmm0,%%xmm0 \n" |
| 1862 | "punpckhwd %%xmm1,%%xmm1 \n" |
| 1863 | "por %%xmm4,%%xmm0 \n" |
| 1864 | "por %%xmm4,%%xmm1 \n" |
| 1865 | "movdqa %%xmm0,(%1) \n" |
| 1866 | "movdqa %%xmm1,16(%1) \n" |
| 1867 | "lea 32(%1),%1 \n" |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1868 | |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1869 | "sub $0x8,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1870 | "jg 1b \n" |
fbarchard@google.com | 3faa0f1 | 2011-10-20 06:04:16 +0000 | [diff] [blame] | 1871 | : "+r"(y_buf), // %0 |
| 1872 | "+r"(rgb_buf), // %1 |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1873 | "+rm"(width) // %2 |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1874 | : |
| 1875 | : "memory", "cc", "eax" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1876 | #if defined(__SSE2__) |
fbarchard@google.com | 8b9759c | 2011-12-14 04:17:39 +0000 | [diff] [blame] | 1877 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" |
fbarchard@google.com | b614976 | 2011-11-07 21:58:52 +0000 | [diff] [blame] | 1878 | #endif |
fbarchard@google.com | 228bdc2 | 2011-11-15 21:58:26 +0000 | [diff] [blame] | 1879 | ); |
mikhal@webrtc.org | 120d5e7 | 2011-10-07 17:57:17 +0000 | [diff] [blame] | 1880 | } |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1881 | #endif // HAS_YTOARGBROW_SSE2 |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 1882 | |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1883 | #ifdef HAS_MIRRORROW_SSSE3 |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1884 | // Shuffle table for reversing the bytes. |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1885 | CONST uvec8 kShuffleMirror = { |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1886 | 15u, 14u, 13u, 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u |
| 1887 | }; |
| 1888 | |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1889 | void MirrorRow_SSSE3(const uint8* src, uint8* dst, int width) { |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1890 | intptr_t temp_width = static_cast<intptr_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1891 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1892 | "movdqa %3,%%xmm5 \n" |
| 1893 | "lea -0x10(%0),%0 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1894 | ".p2align 4 \n" |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1895 | "1: \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1896 | "movdqa (%0,%2),%%xmm0 \n" |
| 1897 | "pshufb %%xmm5,%%xmm0 \n" |
| 1898 | "sub $0x10,%2 \n" |
| 1899 | "movdqa %%xmm0,(%1) \n" |
| 1900 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1901 | "jg 1b \n" |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1902 | : "+r"(src), // %0 |
| 1903 | "+r"(dst), // %1 |
| 1904 | "+r"(temp_width) // %2 |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1905 | : "m"(kShuffleMirror) // %3 |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1906 | : "memory", "cc" |
| 1907 | #if defined(__SSE2__) |
| 1908 | , "xmm0", "xmm5" |
| 1909 | #endif |
| 1910 | ); |
| 1911 | } |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1912 | #endif // HAS_MIRRORROW_SSSE3 |
fbarchard@google.com | 12d0483 | 2011-11-21 23:54:38 +0000 | [diff] [blame] | 1913 | |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1914 | #ifdef HAS_MIRRORROW_SSE2 |
fbarchard@google.com | 42831e0 | 2012-01-21 02:54:17 +0000 | [diff] [blame] | 1915 | void MirrorRow_SSE2(const uint8* src, uint8* dst, int width) { |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1916 | intptr_t temp_width = static_cast<intptr_t>(width); |
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 | "lea -0x10(%0),%0 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1919 | ".p2align 4 \n" |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1920 | "1: \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1921 | "movdqu (%0,%2),%%xmm0 \n" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1922 | "movdqa %%xmm0,%%xmm1 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 1923 | "psllw $0x8,%%xmm0 \n" |
| 1924 | "psrlw $0x8,%%xmm1 \n" |
| 1925 | "por %%xmm1,%%xmm0 \n" |
| 1926 | "pshuflw $0x1b,%%xmm0,%%xmm0 \n" |
| 1927 | "pshufhw $0x1b,%%xmm0,%%xmm0 \n" |
| 1928 | "pshufd $0x4e,%%xmm0,%%xmm0 \n" |
| 1929 | "sub $0x10,%2 \n" |
| 1930 | "movdqu %%xmm0,(%1) \n" |
| 1931 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1932 | "jg 1b \n" |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1933 | : "+r"(src), // %0 |
| 1934 | "+r"(dst), // %1 |
| 1935 | "+r"(temp_width) // %2 |
| 1936 | : |
| 1937 | : "memory", "cc" |
| 1938 | #if defined(__SSE2__) |
| 1939 | , "xmm0", "xmm1" |
| 1940 | #endif |
| 1941 | ); |
| 1942 | } |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1943 | #endif // HAS_MIRRORROW_SSE2 |
fbarchard@google.com | 373cdbd | 2011-12-14 21:10:07 +0000 | [diff] [blame] | 1944 | |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1945 | #ifdef HAS_MIRRORROW_UV_SSSE3 |
| 1946 | // Shuffle table for reversing the bytes of UV channels. |
| 1947 | CONST uvec8 kShuffleMirrorUV = { |
| 1948 | 14u, 12u, 10u, 8u, 6u, 4u, 2u, 0u, 15u, 13u, 11u, 9u, 7u, 5u, 3u, 1u |
| 1949 | }; |
| 1950 | void MirrorRowUV_SSSE3(const uint8* src, uint8* dst_u, uint8* dst_v, |
| 1951 | int width) { |
| 1952 | intptr_t temp_width = static_cast<intptr_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 1953 | asm volatile ( |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1954 | "movdqa %4,%%xmm1 \n" |
| 1955 | "lea -16(%0,%3,2),%0 \n" |
| 1956 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1957 | ".p2align 4 \n" |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1958 | "1: \n" |
| 1959 | "movdqa (%0),%%xmm0 \n" |
| 1960 | "lea -16(%0),%0 \n" |
| 1961 | "pshufb %%xmm1,%%xmm0 \n" |
| 1962 | "sub $8,%3 \n" |
| 1963 | "movlpd %%xmm0,(%1) \n" |
| 1964 | "movhpd %%xmm0,(%1,%2) \n" |
| 1965 | "lea 8(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 1966 | "jg 1b \n" |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1967 | : "+r"(src), // %0 |
| 1968 | "+r"(dst_u), // %1 |
| 1969 | "+r"(dst_v), // %2 |
| 1970 | "+r"(temp_width) // %3 |
| 1971 | : "m"(kShuffleMirrorUV) // %4 |
| 1972 | : "memory", "cc" |
| 1973 | #if defined(__SSE2__) |
| 1974 | , "xmm0", "xmm1" |
| 1975 | #endif |
| 1976 | ); |
| 1977 | } |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 1978 | #endif // HAS_MIRRORROW_UV_SSSE3 |
fbarchard@google.com | 16a9664 | 2012-03-02 22:38:09 +0000 | [diff] [blame] | 1979 | |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1980 | #ifdef HAS_SPLITUV_SSE2 |
| 1981 | 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] | 1982 | asm volatile ( |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1983 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 1984 | "psrlw $0x8,%%xmm5 \n" |
| 1985 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 1986 | ".p2align 4 \n" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 1987 | "1: \n" |
| 1988 | "movdqa (%0),%%xmm0 \n" |
| 1989 | "movdqa 0x10(%0),%%xmm1 \n" |
| 1990 | "lea 0x20(%0),%0 \n" |
| 1991 | "movdqa %%xmm0,%%xmm2 \n" |
| 1992 | "movdqa %%xmm1,%%xmm3 \n" |
| 1993 | "pand %%xmm5,%%xmm0 \n" |
| 1994 | "pand %%xmm5,%%xmm1 \n" |
| 1995 | "packuswb %%xmm1,%%xmm0 \n" |
| 1996 | "psrlw $0x8,%%xmm2 \n" |
| 1997 | "psrlw $0x8,%%xmm3 \n" |
| 1998 | "packuswb %%xmm3,%%xmm2 \n" |
| 1999 | "movdqa %%xmm0,(%1) \n" |
| 2000 | "movdqa %%xmm2,(%1,%2) \n" |
| 2001 | "lea 0x10(%1),%1 \n" |
| 2002 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2003 | "jg 1b \n" |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 2004 | : "+r"(src_uv), // %0 |
| 2005 | "+r"(dst_u), // %1 |
| 2006 | "+r"(dst_v), // %2 |
| 2007 | "+r"(pix) // %3 |
| 2008 | : |
| 2009 | : "memory", "cc" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 2010 | #if defined(__SSE2__) |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 2011 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 2012 | #endif |
| 2013 | ); |
| 2014 | } |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 2015 | #endif // HAS_SPLITUV_SSE2 |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 2016 | |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 2017 | #ifdef HAS_COPYROW_SSE2 |
| 2018 | void CopyRow_SSE2(const uint8* src, uint8* dst, int count) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2019 | asm volatile ( |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 2020 | "sub %0,%1 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2021 | ".p2align 4 \n" |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 2022 | "1: \n" |
| 2023 | "movdqa (%0),%%xmm0 \n" |
| 2024 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2025 | "movdqa %%xmm0,(%0,%1) \n" |
| 2026 | "movdqa %%xmm1,0x10(%0,%1) \n" |
| 2027 | "lea 0x20(%0),%0 \n" |
| 2028 | "sub $0x20,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2029 | "jg 1b \n" |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 2030 | : "+r"(src), // %0 |
| 2031 | "+r"(dst), // %1 |
| 2032 | "+r"(count) // %2 |
| 2033 | : |
| 2034 | : "memory", "cc" |
| 2035 | #if defined(__SSE2__) |
| 2036 | , "xmm0", "xmm1" |
| 2037 | #endif |
| 2038 | ); |
| 2039 | } |
| 2040 | #endif // HAS_COPYROW_SSE2 |
| 2041 | |
| 2042 | #ifdef HAS_COPYROW_X86 |
| 2043 | void CopyRow_X86(const uint8* src, uint8* dst, int width) { |
| 2044 | size_t width_tmp = static_cast<size_t>(width); |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2045 | asm volatile ( |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 2046 | "shr $0x2,%2 \n" |
| 2047 | "rep movsl \n" |
| 2048 | : "+S"(src), // %0 |
| 2049 | "+D"(dst), // %1 |
| 2050 | "+c"(width_tmp) // %2 |
| 2051 | : |
| 2052 | : "memory", "cc" |
| 2053 | ); |
| 2054 | } |
fbarchard@google.com | 4c416e8 | 2012-06-05 15:48:07 +0000 | [diff] [blame] | 2055 | #endif // HAS_COPYROW_X86 |
fbarchard@google.com | 19932f8 | 2012-02-16 22:19:14 +0000 | [diff] [blame] | 2056 | |
fbarchard@google.com | b95dbf2 | 2012-02-11 01:18:30 +0000 | [diff] [blame] | 2057 | #ifdef HAS_YUY2TOYROW_SSE2 |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2058 | 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] | 2059 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2060 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2061 | "psrlw $0x8,%%xmm5 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2062 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2063 | "1: \n" |
| 2064 | "movdqa (%0),%%xmm0 \n" |
| 2065 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2066 | "lea 0x20(%0),%0 \n" |
| 2067 | "pand %%xmm5,%%xmm0 \n" |
| 2068 | "pand %%xmm5,%%xmm1 \n" |
| 2069 | "packuswb %%xmm1,%%xmm0 \n" |
| 2070 | "movdqa %%xmm0,(%1) \n" |
| 2071 | "lea 0x10(%1),%1 \n" |
| 2072 | "sub $0x10,%2 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2073 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2074 | : "+r"(src_yuy2), // %0 |
| 2075 | "+r"(dst_y), // %1 |
| 2076 | "+r"(pix) // %2 |
| 2077 | : |
| 2078 | : "memory", "cc" |
| 2079 | #if defined(__SSE2__) |
| 2080 | , "xmm0", "xmm1", "xmm5" |
| 2081 | #endif |
| 2082 | ); |
| 2083 | } |
| 2084 | |
| 2085 | void YUY2ToUVRow_SSE2(const uint8* src_yuy2, int stride_yuy2, |
| 2086 | uint8* dst_u, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2087 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2088 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2089 | "psrlw $0x8,%%xmm5 \n" |
| 2090 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2091 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2092 | "1: \n" |
| 2093 | "movdqa (%0),%%xmm0 \n" |
| 2094 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2095 | "movdqa (%0,%4,1),%%xmm2 \n" |
| 2096 | "movdqa 0x10(%0,%4,1),%%xmm3 \n" |
| 2097 | "lea 0x20(%0),%0 \n" |
| 2098 | "pavgb %%xmm2,%%xmm0 \n" |
| 2099 | "pavgb %%xmm3,%%xmm1 \n" |
| 2100 | "psrlw $0x8,%%xmm0 \n" |
| 2101 | "psrlw $0x8,%%xmm1 \n" |
| 2102 | "packuswb %%xmm1,%%xmm0 \n" |
| 2103 | "movdqa %%xmm0,%%xmm1 \n" |
| 2104 | "pand %%xmm5,%%xmm0 \n" |
| 2105 | "packuswb %%xmm0,%%xmm0 \n" |
| 2106 | "psrlw $0x8,%%xmm1 \n" |
| 2107 | "packuswb %%xmm1,%%xmm1 \n" |
| 2108 | "movq %%xmm0,(%1) \n" |
| 2109 | "movq %%xmm1,(%1,%2) \n" |
| 2110 | "lea 0x8(%1),%1 \n" |
| 2111 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2112 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2113 | : "+r"(src_yuy2), // %0 |
| 2114 | "+r"(dst_u), // %1 |
| 2115 | "+r"(dst_y), // %2 |
| 2116 | "+r"(pix) // %3 |
| 2117 | : "r"(static_cast<intptr_t>(stride_yuy2)) // %4 |
| 2118 | : "memory", "cc" |
| 2119 | #if defined(__SSE2__) |
| 2120 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 2121 | #endif |
| 2122 | ); |
| 2123 | } |
| 2124 | |
fbarchard@google.com | f3fb7b6 | 2012-03-29 23:19:34 +0000 | [diff] [blame] | 2125 | |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2126 | void YUY2ToYRow_Unaligned_SSE2(const uint8* src_yuy2, |
| 2127 | uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2128 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2129 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2130 | "psrlw $0x8,%%xmm5 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2131 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2132 | "1: \n" |
| 2133 | "movdqu (%0),%%xmm0 \n" |
| 2134 | "movdqu 0x10(%0),%%xmm1 \n" |
| 2135 | "lea 0x20(%0),%0 \n" |
| 2136 | "pand %%xmm5,%%xmm0 \n" |
| 2137 | "pand %%xmm5,%%xmm1 \n" |
| 2138 | "packuswb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2139 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2140 | "movdqu %%xmm0,(%1) \n" |
| 2141 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2142 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2143 | : "+r"(src_yuy2), // %0 |
| 2144 | "+r"(dst_y), // %1 |
| 2145 | "+r"(pix) // %2 |
| 2146 | : |
| 2147 | : "memory", "cc" |
| 2148 | #if defined(__SSE2__) |
| 2149 | , "xmm0", "xmm1", "xmm5" |
| 2150 | #endif |
| 2151 | ); |
| 2152 | } |
| 2153 | |
| 2154 | void YUY2ToUVRow_Unaligned_SSE2(const uint8* src_yuy2, |
| 2155 | int stride_yuy2, |
| 2156 | uint8* dst_u, uint8* dst_y, |
| 2157 | int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2158 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2159 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2160 | "psrlw $0x8,%%xmm5 \n" |
| 2161 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2162 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2163 | "1: \n" |
| 2164 | "movdqu (%0),%%xmm0 \n" |
| 2165 | "movdqu 0x10(%0),%%xmm1 \n" |
| 2166 | "movdqu (%0,%4,1),%%xmm2 \n" |
| 2167 | "movdqu 0x10(%0,%4,1),%%xmm3 \n" |
| 2168 | "lea 0x20(%0),%0 \n" |
| 2169 | "pavgb %%xmm2,%%xmm0 \n" |
| 2170 | "pavgb %%xmm3,%%xmm1 \n" |
| 2171 | "psrlw $0x8,%%xmm0 \n" |
| 2172 | "psrlw $0x8,%%xmm1 \n" |
| 2173 | "packuswb %%xmm1,%%xmm0 \n" |
| 2174 | "movdqa %%xmm0,%%xmm1 \n" |
| 2175 | "pand %%xmm5,%%xmm0 \n" |
| 2176 | "packuswb %%xmm0,%%xmm0 \n" |
| 2177 | "psrlw $0x8,%%xmm1 \n" |
| 2178 | "packuswb %%xmm1,%%xmm1 \n" |
| 2179 | "movq %%xmm0,(%1) \n" |
| 2180 | "movq %%xmm1,(%1,%2) \n" |
| 2181 | "lea 0x8(%1),%1 \n" |
| 2182 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2183 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2184 | : "+r"(src_yuy2), // %0 |
| 2185 | "+r"(dst_u), // %1 |
| 2186 | "+r"(dst_y), // %2 |
| 2187 | "+r"(pix) // %3 |
| 2188 | : "r"(static_cast<intptr_t>(stride_yuy2)) // %4 |
| 2189 | : "memory", "cc" |
| 2190 | #if defined(__SSE2__) |
| 2191 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 2192 | #endif |
fbarchard@google.com | f1b6063 | 2012-02-17 19:27:20 +0000 | [diff] [blame] | 2193 | ); |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2194 | } |
| 2195 | |
| 2196 | 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] | 2197 | asm volatile ( |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2198 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2199 | "1: \n" |
| 2200 | "movdqa (%0),%%xmm0 \n" |
| 2201 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2202 | "lea 0x20(%0),%0 \n" |
| 2203 | "psrlw $0x8,%%xmm0 \n" |
| 2204 | "psrlw $0x8,%%xmm1 \n" |
| 2205 | "packuswb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2206 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2207 | "movdqa %%xmm0,(%1) \n" |
| 2208 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2209 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2210 | : "+r"(src_uyvy), // %0 |
| 2211 | "+r"(dst_y), // %1 |
| 2212 | "+r"(pix) // %2 |
| 2213 | : |
| 2214 | : "memory", "cc" |
| 2215 | #if defined(__SSE2__) |
| 2216 | , "xmm0", "xmm1" |
| 2217 | #endif |
| 2218 | ); |
| 2219 | } |
| 2220 | |
| 2221 | void UYVYToUVRow_SSE2(const uint8* src_uyvy, int stride_uyvy, |
| 2222 | uint8* dst_u, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2223 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2224 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2225 | "psrlw $0x8,%%xmm5 \n" |
| 2226 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2227 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2228 | "1: \n" |
| 2229 | "movdqa (%0),%%xmm0 \n" |
| 2230 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2231 | "movdqa (%0,%4,1),%%xmm2 \n" |
| 2232 | "movdqa 0x10(%0,%4,1),%%xmm3 \n" |
| 2233 | "lea 0x20(%0),%0 \n" |
| 2234 | "pavgb %%xmm2,%%xmm0 \n" |
| 2235 | "pavgb %%xmm3,%%xmm1 \n" |
| 2236 | "pand %%xmm5,%%xmm0 \n" |
| 2237 | "pand %%xmm5,%%xmm1 \n" |
| 2238 | "packuswb %%xmm1,%%xmm0 \n" |
| 2239 | "movdqa %%xmm0,%%xmm1 \n" |
| 2240 | "pand %%xmm5,%%xmm0 \n" |
| 2241 | "packuswb %%xmm0,%%xmm0 \n" |
| 2242 | "psrlw $0x8,%%xmm1 \n" |
| 2243 | "packuswb %%xmm1,%%xmm1 \n" |
| 2244 | "movq %%xmm0,(%1) \n" |
| 2245 | "movq %%xmm1,(%1,%2) \n" |
| 2246 | "lea 0x8(%1),%1 \n" |
| 2247 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2248 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2249 | : "+r"(src_uyvy), // %0 |
| 2250 | "+r"(dst_u), // %1 |
| 2251 | "+r"(dst_y), // %2 |
| 2252 | "+r"(pix) // %3 |
| 2253 | : "r"(static_cast<intptr_t>(stride_uyvy)) // %4 |
| 2254 | : "memory", "cc" |
| 2255 | #if defined(__SSE2__) |
| 2256 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 2257 | #endif |
| 2258 | ); |
| 2259 | } |
| 2260 | |
| 2261 | void UYVYToYRow_Unaligned_SSE2(const uint8* src_uyvy, |
| 2262 | uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2263 | asm volatile ( |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2264 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2265 | "1: \n" |
| 2266 | "movdqu (%0),%%xmm0 \n" |
| 2267 | "movdqu 0x10(%0),%%xmm1 \n" |
| 2268 | "lea 0x20(%0),%0 \n" |
| 2269 | "psrlw $0x8,%%xmm0 \n" |
| 2270 | "psrlw $0x8,%%xmm1 \n" |
| 2271 | "packuswb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2272 | "sub $0x10,%2 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2273 | "movdqu %%xmm0,(%1) \n" |
| 2274 | "lea 0x10(%1),%1 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2275 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2276 | : "+r"(src_uyvy), // %0 |
| 2277 | "+r"(dst_y), // %1 |
| 2278 | "+r"(pix) // %2 |
| 2279 | : |
| 2280 | : "memory", "cc" |
| 2281 | #if defined(__SSE2__) |
| 2282 | , "xmm0", "xmm1" |
| 2283 | #endif |
| 2284 | ); |
| 2285 | } |
| 2286 | |
| 2287 | void UYVYToUVRow_Unaligned_SSE2(const uint8* src_uyvy, int stride_uyvy, |
| 2288 | uint8* dst_u, uint8* dst_y, int pix) { |
fbarchard@google.com | e14b2ab | 2012-03-26 16:15:15 +0000 | [diff] [blame] | 2289 | asm volatile ( |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2290 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2291 | "psrlw $0x8,%%xmm5 \n" |
| 2292 | "sub %1,%2 \n" |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2293 | ".p2align 4 \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2294 | "1: \n" |
| 2295 | "movdqu (%0),%%xmm0 \n" |
| 2296 | "movdqu 0x10(%0),%%xmm1 \n" |
| 2297 | "movdqu (%0,%4,1),%%xmm2 \n" |
| 2298 | "movdqu 0x10(%0,%4,1),%%xmm3 \n" |
| 2299 | "lea 0x20(%0),%0 \n" |
| 2300 | "pavgb %%xmm2,%%xmm0 \n" |
| 2301 | "pavgb %%xmm3,%%xmm1 \n" |
| 2302 | "pand %%xmm5,%%xmm0 \n" |
| 2303 | "pand %%xmm5,%%xmm1 \n" |
| 2304 | "packuswb %%xmm1,%%xmm0 \n" |
| 2305 | "movdqa %%xmm0,%%xmm1 \n" |
| 2306 | "pand %%xmm5,%%xmm0 \n" |
| 2307 | "packuswb %%xmm0,%%xmm0 \n" |
| 2308 | "psrlw $0x8,%%xmm1 \n" |
| 2309 | "packuswb %%xmm1,%%xmm1 \n" |
| 2310 | "movq %%xmm0,(%1) \n" |
| 2311 | "movq %%xmm1,(%1,%2) \n" |
| 2312 | "lea 0x8(%1),%1 \n" |
| 2313 | "sub $0x10,%3 \n" |
fbarchard@google.com | 18184fd | 2012-03-12 18:53:19 +0000 | [diff] [blame] | 2314 | "jg 1b \n" |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2315 | : "+r"(src_uyvy), // %0 |
| 2316 | "+r"(dst_u), // %1 |
| 2317 | "+r"(dst_y), // %2 |
| 2318 | "+r"(pix) // %3 |
| 2319 | : "r"(static_cast<intptr_t>(stride_uyvy)) // %4 |
| 2320 | : "memory", "cc" |
| 2321 | #if defined(__SSE2__) |
| 2322 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5" |
| 2323 | #endif |
| 2324 | ); |
| 2325 | } |
fbarchard@google.com | b95dbf2 | 2012-02-11 01:18:30 +0000 | [diff] [blame] | 2326 | #endif // HAS_YUY2TOYROW_SSE2 |
fbarchard@google.com | e5f3fd4 | 2012-02-06 22:40:32 +0000 | [diff] [blame] | 2327 | |
fbarchard@google.com | ba3aeed | 2012-03-07 18:24:51 +0000 | [diff] [blame] | 2328 | #ifdef HAS_ARGBBLENDROW_SSE2 |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2329 | // Blend 8 pixels at a time. |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2330 | void ARGBBlendRow_SSE2(const uint8* src_argb0, const uint8* src_argb1, |
| 2331 | uint8* dst_argb, int width) { |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2332 | asm volatile ( |
| 2333 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 2334 | "psrlw $0xf,%%xmm7 \n" |
| 2335 | "pcmpeqb %%xmm6,%%xmm6 \n" |
| 2336 | "psrlw $0x8,%%xmm6 \n" |
| 2337 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2338 | "psllw $0x8,%%xmm5 \n" |
| 2339 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2340 | "pslld $0x18,%%xmm4 \n" |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2341 | "sub $0x1,%3 \n" |
| 2342 | "je 91f \n" |
| 2343 | "jl 99f \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2344 | |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2345 | // 1 pixel loop until destination pointer is aligned. |
| 2346 | "10: \n" |
| 2347 | "test $0xf,%2 \n" |
| 2348 | "je 19f \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2349 | "movd (%0),%%xmm3 \n" |
| 2350 | "lea 0x4(%0),%0 \n" |
| 2351 | "movdqa %%xmm3,%%xmm0 \n" |
| 2352 | "pxor %%xmm4,%%xmm3 \n" |
| 2353 | "movd (%1),%%xmm2 \n" |
| 2354 | "psrlw $0x8,%%xmm3 \n" |
| 2355 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 2356 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 2357 | "pand %%xmm6,%%xmm2 \n" |
| 2358 | "paddw %%xmm7,%%xmm3 \n" |
| 2359 | "pmullw %%xmm3,%%xmm2 \n" |
| 2360 | "movd (%1),%%xmm1 \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2361 | "lea 0x4(%1),%1 \n" |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2362 | "psrlw $0x8,%%xmm1 \n" |
| 2363 | "por %%xmm4,%%xmm0 \n" |
| 2364 | "pmullw %%xmm3,%%xmm1 \n" |
| 2365 | "psrlw $0x8,%%xmm2 \n" |
| 2366 | "paddusb %%xmm2,%%xmm0 \n" |
| 2367 | "pand %%xmm5,%%xmm1 \n" |
| 2368 | "paddusb %%xmm1,%%xmm0 \n" |
| 2369 | "sub $0x1,%3 \n" |
| 2370 | "movd %%xmm0,(%2) \n" |
| 2371 | "lea 0x4(%2),%2 \n" |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2372 | "jge 10b \n" |
| 2373 | |
| 2374 | "19: \n" |
fbarchard@google.com | ee22088 | 2012-06-14 00:07:56 +0000 | [diff] [blame^] | 2375 | "add $1-4,%3 \n" |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2376 | "jl 49f \n" |
| 2377 | |
| 2378 | // 8 pixel loop. |
| 2379 | ".p2align 2 \n" |
| 2380 | "41: \n" |
| 2381 | "movdqu (%0),%%xmm3 \n" |
| 2382 | "movdqa %%xmm3,%%xmm0 \n" |
| 2383 | "pxor %%xmm4,%%xmm3 \n" |
| 2384 | "psrlw $0x8,%%xmm3 \n" |
| 2385 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 2386 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 2387 | "movdqu (%1),%%xmm2 \n" |
| 2388 | "pand %%xmm6,%%xmm2 \n" |
| 2389 | "paddw %%xmm7,%%xmm3 \n" |
| 2390 | "pmullw %%xmm3,%%xmm2 \n" |
| 2391 | "movdqu (%1),%%xmm1 \n" |
| 2392 | "psrlw $0x8,%%xmm1 \n" |
| 2393 | "por %%xmm4,%%xmm0 \n" |
| 2394 | "pmullw %%xmm3,%%xmm1 \n" |
| 2395 | "movdqu 0x10(%0),%%xmm3 \n" |
| 2396 | "lea 0x20(%0),%0 \n" |
| 2397 | "psrlw $0x8,%%xmm2 \n" |
| 2398 | "paddusb %%xmm2,%%xmm0 \n" |
| 2399 | "pand %%xmm5,%%xmm1 \n" |
| 2400 | "paddusb %%xmm1,%%xmm0 \n" |
| 2401 | "sub $0x4,%3 \n" |
| 2402 | "movdqa %%xmm0,(%2) \n" |
| 2403 | "jl 49f \n" |
| 2404 | "movdqa %%xmm3,%%xmm0 \n" |
| 2405 | "pxor %%xmm4,%%xmm3 \n" |
| 2406 | "movdqu 0x10(%1),%%xmm2 \n" |
| 2407 | "psrlw $0x8,%%xmm3 \n" |
| 2408 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 2409 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 2410 | "pand %%xmm6,%%xmm2 \n" |
| 2411 | "paddw %%xmm7,%%xmm3 \n" |
| 2412 | "pmullw %%xmm3,%%xmm2 \n" |
| 2413 | "movdqu 0x10(%1),%%xmm1 \n" |
| 2414 | "lea 0x20(%1),%1 \n" |
| 2415 | "psrlw $0x8,%%xmm1 \n" |
| 2416 | "por %%xmm4,%%xmm0 \n" |
| 2417 | "pmullw %%xmm3,%%xmm1 \n" |
| 2418 | "psrlw $0x8,%%xmm2 \n" |
| 2419 | "paddusb %%xmm2,%%xmm0 \n" |
| 2420 | "pand %%xmm5,%%xmm1 \n" |
| 2421 | "paddusb %%xmm1,%%xmm0 \n" |
| 2422 | "sub $0x4,%3 \n" |
| 2423 | "movdqa %%xmm0,0x10(%2) \n" |
| 2424 | "lea 0x20(%2),%2 \n" |
| 2425 | "jge 41b \n" |
| 2426 | |
| 2427 | "49: \n" |
| 2428 | "add $0x3,%3 \n" |
| 2429 | "jl 99f \n" |
| 2430 | |
| 2431 | // 1 pixel loop. |
| 2432 | "91: \n" |
| 2433 | "movd (%0),%%xmm3 \n" |
| 2434 | "lea 0x4(%0),%0 \n" |
| 2435 | "movdqa %%xmm3,%%xmm0 \n" |
| 2436 | "pxor %%xmm4,%%xmm3 \n" |
| 2437 | "movd (%1),%%xmm2 \n" |
| 2438 | "psrlw $0x8,%%xmm3 \n" |
| 2439 | "pshufhw $0xf5,%%xmm3,%%xmm3 \n" |
| 2440 | "pshuflw $0xf5,%%xmm3,%%xmm3 \n" |
| 2441 | "pand %%xmm6,%%xmm2 \n" |
| 2442 | "paddw %%xmm7,%%xmm3 \n" |
| 2443 | "pmullw %%xmm3,%%xmm2 \n" |
| 2444 | "movd (%1),%%xmm1 \n" |
| 2445 | "lea 0x4(%1),%1 \n" |
| 2446 | "psrlw $0x8,%%xmm1 \n" |
| 2447 | "por %%xmm4,%%xmm0 \n" |
| 2448 | "pmullw %%xmm3,%%xmm1 \n" |
| 2449 | "psrlw $0x8,%%xmm2 \n" |
| 2450 | "paddusb %%xmm2,%%xmm0 \n" |
| 2451 | "pand %%xmm5,%%xmm1 \n" |
| 2452 | "paddusb %%xmm1,%%xmm0 \n" |
| 2453 | "sub $0x1,%3 \n" |
| 2454 | "movd %%xmm0,(%2) \n" |
| 2455 | "lea 0x4(%2),%2 \n" |
| 2456 | "jge 91b \n" |
| 2457 | "99: \n" |
| 2458 | : "+r"(src_argb0), // %0 |
| 2459 | "+r"(src_argb1), // %1 |
| 2460 | "+r"(dst_argb), // %2 |
| 2461 | "+r"(width) // %3 |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2462 | : |
| 2463 | : "memory", "cc" |
| 2464 | #if defined(__SSE2__) |
| 2465 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 2466 | #endif |
| 2467 | ); |
| 2468 | } |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2469 | #endif // HAS_ARGBBLENDROW_SSE2 |
fbarchard@google.com | c757f30 | 2012-04-03 00:49:16 +0000 | [diff] [blame] | 2470 | |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2471 | #ifdef HAS_ARGBBLENDROW_SSSE3 |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2472 | // Shuffle table for isolating alpha. |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2473 | CONST uvec8 kShuffleAlpha = { |
| 2474 | 3u, 0x80, 3u, 0x80, 7u, 0x80, 7u, 0x80, |
| 2475 | 11u, 0x80, 11u, 0x80, 15u, 0x80, 15u, 0x80 |
| 2476 | }; |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2477 | |
| 2478 | // Blend 8 pixels at a time |
| 2479 | // Shuffle table for reversing the bytes. |
| 2480 | |
| 2481 | // Same as SSE2, but replaces |
| 2482 | // psrlw xmm3, 8 // alpha |
| 2483 | // pshufhw xmm3, xmm3,0F5h // 8 alpha words |
| 2484 | // pshuflw xmm3, xmm3,0F5h |
| 2485 | // with.. |
| 2486 | // pshufb xmm3, kShuffleAlpha // alpha |
| 2487 | |
| 2488 | void ARGBBlendRow_SSSE3(const uint8* src_argb0, const uint8* src_argb1, |
| 2489 | uint8* dst_argb, int width) { |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2490 | asm volatile ( |
| 2491 | "pcmpeqb %%xmm7,%%xmm7 \n" |
| 2492 | "psrlw $0xf,%%xmm7 \n" |
| 2493 | "pcmpeqb %%xmm6,%%xmm6 \n" |
| 2494 | "psrlw $0x8,%%xmm6 \n" |
| 2495 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2496 | "psllw $0x8,%%xmm5 \n" |
| 2497 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2498 | "pslld $0x18,%%xmm4 \n" |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2499 | "sub $0x1,%3 \n" |
| 2500 | "je 91f \n" |
| 2501 | "jl 99f \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2502 | |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2503 | // 1 pixel loop until destination pointer is aligned. |
| 2504 | "10: \n" |
| 2505 | "test $0xf,%2 \n" |
| 2506 | "je 19f \n" |
| 2507 | "movd (%0),%%xmm3 \n" |
| 2508 | "lea 0x4(%0),%0 \n" |
| 2509 | "movdqa %%xmm3,%%xmm0 \n" |
| 2510 | "pxor %%xmm4,%%xmm3 \n" |
| 2511 | "movd (%1),%%xmm2 \n" |
| 2512 | "pshufb %4,%%xmm3 \n" |
| 2513 | "pand %%xmm6,%%xmm2 \n" |
| 2514 | "paddw %%xmm7,%%xmm3 \n" |
| 2515 | "pmullw %%xmm3,%%xmm2 \n" |
| 2516 | "movd (%1),%%xmm1 \n" |
| 2517 | "lea 0x4(%1),%1 \n" |
| 2518 | "psrlw $0x8,%%xmm1 \n" |
| 2519 | "por %%xmm4,%%xmm0 \n" |
| 2520 | "pmullw %%xmm3,%%xmm1 \n" |
| 2521 | "psrlw $0x8,%%xmm2 \n" |
| 2522 | "paddusb %%xmm2,%%xmm0 \n" |
| 2523 | "pand %%xmm5,%%xmm1 \n" |
| 2524 | "paddusb %%xmm1,%%xmm0 \n" |
| 2525 | "sub $0x1,%3 \n" |
| 2526 | "movd %%xmm0,(%2) \n" |
| 2527 | "lea 0x4(%2),%2 \n" |
| 2528 | "jge 10b \n" |
| 2529 | |
| 2530 | "19: \n" |
fbarchard@google.com | ee22088 | 2012-06-14 00:07:56 +0000 | [diff] [blame^] | 2531 | "add $1-4,%3 \n" |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2532 | "jl 49f \n" |
| 2533 | |
| 2534 | // 8 pixel loop. |
| 2535 | ".p2align 2 \n" |
| 2536 | "41: \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2537 | "movdqu (%0),%%xmm3 \n" |
| 2538 | "movdqa %%xmm3,%%xmm0 \n" |
| 2539 | "pxor %%xmm4,%%xmm3 \n" |
| 2540 | "pshufb %4,%%xmm3 \n" |
| 2541 | "movdqu (%1),%%xmm2 \n" |
| 2542 | "pand %%xmm6,%%xmm2 \n" |
| 2543 | "paddw %%xmm7,%%xmm3 \n" |
| 2544 | "pmullw %%xmm3,%%xmm2 \n" |
| 2545 | "movdqu (%1),%%xmm1 \n" |
| 2546 | "psrlw $0x8,%%xmm1 \n" |
| 2547 | "por %%xmm4,%%xmm0 \n" |
| 2548 | "pmullw %%xmm3,%%xmm1 \n" |
| 2549 | "movdqu 0x10(%0),%%xmm3 \n" |
| 2550 | "lea 0x20(%0),%0 \n" |
| 2551 | "psrlw $0x8,%%xmm2 \n" |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2552 | "paddusb %%xmm2,%%xmm0 \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2553 | "pand %%xmm5,%%xmm1 \n" |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2554 | "paddusb %%xmm1,%%xmm0 \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2555 | "sub $0x4,%3 \n" |
| 2556 | "movdqa %%xmm0,(%2) \n" |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2557 | "jl 49f \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2558 | "movdqa %%xmm3,%%xmm0 \n" |
| 2559 | "pxor %%xmm4,%%xmm3 \n" |
| 2560 | "movdqu 0x10(%1),%%xmm2 \n" |
| 2561 | "pshufb %4,%%xmm3 \n" |
| 2562 | "pand %%xmm6,%%xmm2 \n" |
| 2563 | "paddw %%xmm7,%%xmm3 \n" |
| 2564 | "pmullw %%xmm3,%%xmm2 \n" |
| 2565 | "movdqu 0x10(%1),%%xmm1 \n" |
| 2566 | "lea 0x20(%1),%1 \n" |
| 2567 | "psrlw $0x8,%%xmm1 \n" |
| 2568 | "por %%xmm4,%%xmm0 \n" |
| 2569 | "pmullw %%xmm3,%%xmm1 \n" |
| 2570 | "psrlw $0x8,%%xmm2 \n" |
| 2571 | "paddusb %%xmm2,%%xmm0 \n" |
| 2572 | "pand %%xmm5,%%xmm1 \n" |
| 2573 | "paddusb %%xmm1,%%xmm0 \n" |
| 2574 | "sub $0x4,%3 \n" |
| 2575 | "movdqa %%xmm0,0x10(%2) \n" |
| 2576 | "lea 0x20(%2),%2 \n" |
fbarchard@google.com | bac5f2c | 2012-06-13 23:43:12 +0000 | [diff] [blame] | 2577 | "jge 41b \n" |
| 2578 | |
| 2579 | "49: \n" |
| 2580 | "add $0x3,%3 \n" |
| 2581 | "jl 99f \n" |
| 2582 | |
| 2583 | // 1 pixel loop. |
| 2584 | "91: \n" |
| 2585 | "movd (%0),%%xmm3 \n" |
| 2586 | "lea 0x4(%0),%0 \n" |
| 2587 | "movdqa %%xmm3,%%xmm0 \n" |
| 2588 | "pxor %%xmm4,%%xmm3 \n" |
| 2589 | "movd (%1),%%xmm2 \n" |
| 2590 | "pshufb %4,%%xmm3 \n" |
| 2591 | "pand %%xmm6,%%xmm2 \n" |
| 2592 | "paddw %%xmm7,%%xmm3 \n" |
| 2593 | "pmullw %%xmm3,%%xmm2 \n" |
| 2594 | "movd (%1),%%xmm1 \n" |
| 2595 | "lea 0x4(%1),%1 \n" |
| 2596 | "psrlw $0x8,%%xmm1 \n" |
| 2597 | "por %%xmm4,%%xmm0 \n" |
| 2598 | "pmullw %%xmm3,%%xmm1 \n" |
| 2599 | "psrlw $0x8,%%xmm2 \n" |
| 2600 | "paddusb %%xmm2,%%xmm0 \n" |
| 2601 | "pand %%xmm5,%%xmm1 \n" |
| 2602 | "paddusb %%xmm1,%%xmm0 \n" |
| 2603 | "sub $0x1,%3 \n" |
| 2604 | "movd %%xmm0,(%2) \n" |
| 2605 | "lea 0x4(%2),%2 \n" |
| 2606 | "jge 91b \n" |
| 2607 | "99: \n" |
fbarchard@google.com | 96af870 | 2012-04-06 18:22:27 +0000 | [diff] [blame] | 2608 | : "+r"(src_argb0), // %0 |
| 2609 | "+r"(src_argb1), // %1 |
| 2610 | "+r"(dst_argb), // %2 |
| 2611 | "+r"(width) // %3 |
| 2612 | : "m"(kShuffleAlpha) // %4 |
| 2613 | : "memory", "cc" |
| 2614 | #if defined(__SSE2__) |
| 2615 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
| 2616 | #endif |
| 2617 | ); |
| 2618 | } |
| 2619 | #endif // HAS_ARGBBLENDROW_SSSE3 |
| 2620 | |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2621 | #ifdef HAS_ARGBATTENUATE_SSE2 |
| 2622 | // Attenuate 4 pixels at a time. |
| 2623 | // aligned to 16 bytes |
| 2624 | void ARGBAttenuateRow_SSE2(const uint8* src_argb, uint8* dst_argb, int width) { |
| 2625 | asm volatile ( |
| 2626 | "sub %0,%1 \n" |
| 2627 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2628 | "pslld $0x18,%%xmm4 \n" |
| 2629 | "pcmpeqb %%xmm5,%%xmm5 \n" |
| 2630 | "psrld $0x8,%%xmm5 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2631 | |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2632 | // 4 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2633 | ".p2align 4 \n" |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2634 | "1: \n" |
| 2635 | "movdqa (%0),%%xmm0 \n" |
| 2636 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 2637 | "pshufhw $0xff,%%xmm0,%%xmm2 \n" |
| 2638 | "pshuflw $0xff,%%xmm2,%%xmm2 \n" |
| 2639 | "pmulhuw %%xmm2,%%xmm0 \n" |
| 2640 | "movdqa (%0),%%xmm1 \n" |
| 2641 | "punpckhbw %%xmm1,%%xmm1 \n" |
| 2642 | "pshufhw $0xff,%%xmm1,%%xmm2 \n" |
| 2643 | "pshuflw $0xff,%%xmm2,%%xmm2 \n" |
| 2644 | "pmulhuw %%xmm2,%%xmm1 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2645 | "movdqa (%0),%%xmm2 \n" |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2646 | "psrlw $0x8,%%xmm0 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2647 | "pand %%xmm4,%%xmm2 \n" |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2648 | "psrlw $0x8,%%xmm1 \n" |
| 2649 | "packuswb %%xmm1,%%xmm0 \n" |
| 2650 | "pand %%xmm5,%%xmm0 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2651 | "por %%xmm2,%%xmm0 \n" |
fbarchard@google.com | 8ed5422 | 2012-04-18 17:07:07 +0000 | [diff] [blame] | 2652 | "sub $0x4,%2 \n" |
| 2653 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 2654 | "lea 0x10(%0),%0 \n" |
| 2655 | "jg 1b \n" |
| 2656 | : "+r"(src_argb), // %0 |
| 2657 | "+r"(dst_argb), // %1 |
| 2658 | "+r"(width) // %2 |
| 2659 | : |
| 2660 | : "memory", "cc" |
| 2661 | #if defined(__SSE2__) |
| 2662 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 2663 | #endif |
| 2664 | ); |
| 2665 | } |
| 2666 | #endif // HAS_ARGBATTENUATE_SSE2 |
| 2667 | |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2668 | #ifdef HAS_ARGBATTENUATE_SSSE3 |
| 2669 | // Shuffle table duplicating alpha |
| 2670 | CONST uvec8 kShuffleAlpha0 = { |
| 2671 | 3u, 3u, 3u, 3u, 3u, 3u, 128u, 128u, 7u, 7u, 7u, 7u, 7u, 7u, 128u, 128u, |
| 2672 | }; |
| 2673 | CONST uvec8 kShuffleAlpha1 = { |
| 2674 | 11u, 11u, 11u, 11u, 11u, 11u, 128u, 128u, |
| 2675 | 15u, 15u, 15u, 15u, 15u, 15u, 128u, 128u, |
| 2676 | }; |
| 2677 | // Attenuate 4 pixels at a time. |
| 2678 | // aligned to 16 bytes |
| 2679 | void ARGBAttenuateRow_SSSE3(const uint8* src_argb, uint8* dst_argb, int width) { |
| 2680 | asm volatile ( |
| 2681 | "sub %0,%1 \n" |
| 2682 | "pcmpeqb %%xmm3,%%xmm3 \n" |
| 2683 | "pslld $0x18,%%xmm3 \n" |
| 2684 | "movdqa %3,%%xmm4 \n" |
| 2685 | "movdqa %4,%%xmm5 \n" |
| 2686 | |
| 2687 | // 4 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2688 | ".p2align 4 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2689 | "1: \n" |
| 2690 | "movdqa (%0),%%xmm0 \n" |
| 2691 | "pshufb %%xmm4,%%xmm0 \n" |
| 2692 | "movdqa (%0),%%xmm1 \n" |
| 2693 | "punpcklbw %%xmm1,%%xmm1 \n" |
| 2694 | "pmulhuw %%xmm1,%%xmm0 \n" |
| 2695 | "movdqa (%0),%%xmm1 \n" |
| 2696 | "pshufb %%xmm5,%%xmm1 \n" |
| 2697 | "movdqa (%0),%%xmm2 \n" |
| 2698 | "punpckhbw %%xmm2,%%xmm2 \n" |
| 2699 | "pmulhuw %%xmm2,%%xmm1 \n" |
| 2700 | "movdqa (%0),%%xmm2 \n" |
| 2701 | "pand %%xmm3,%%xmm2 \n" |
| 2702 | "psrlw $0x8,%%xmm0 \n" |
| 2703 | "psrlw $0x8,%%xmm1 \n" |
| 2704 | "packuswb %%xmm1,%%xmm0 \n" |
| 2705 | "por %%xmm2,%%xmm0 \n" |
| 2706 | "sub $0x4,%2 \n" |
| 2707 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 2708 | "lea 0x10(%0),%0 \n" |
| 2709 | "jg 1b \n" |
| 2710 | : "+r"(src_argb), // %0 |
| 2711 | "+r"(dst_argb), // %1 |
| 2712 | "+r"(width) // %2 |
| 2713 | : "m"(kShuffleAlpha0), // %3 |
| 2714 | "m"(kShuffleAlpha1) // %4 |
| 2715 | : "memory", "cc" |
| 2716 | #if defined(__SSE2__) |
| 2717 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 2718 | #endif |
| 2719 | ); |
| 2720 | } |
| 2721 | #endif // HAS_ARGBATTENUATE_SSSE3 |
| 2722 | |
| 2723 | #ifdef HAS_ARGBUNATTENUATE_SSE2 |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2724 | // Unattenuate 4 pixels at a time. |
| 2725 | // aligned to 16 bytes |
| 2726 | void ARGBUnattenuateRow_SSE2(const uint8* src_argb, uint8* dst_argb, |
| 2727 | int width) { |
| 2728 | uintptr_t alpha = 0; |
| 2729 | asm volatile ( |
| 2730 | "sub %0,%1 \n" |
| 2731 | "pcmpeqb %%xmm4,%%xmm4 \n" |
| 2732 | "pslld $0x18,%%xmm4 \n" |
| 2733 | |
| 2734 | // 4 pixel loop |
fbarchard@google.com | 5bf29b5 | 2012-05-02 00:10:16 +0000 | [diff] [blame] | 2735 | ".p2align 4 \n" |
fbarchard@google.com | 810cd91 | 2012-04-20 20:15:27 +0000 | [diff] [blame] | 2736 | "1: \n" |
| 2737 | "movdqa (%0),%%xmm0 \n" |
| 2738 | "movzb 0x3(%0),%3 \n" |
| 2739 | "punpcklbw %%xmm0,%%xmm0 \n" |
| 2740 | "movd 0x0(%4,%3,4),%%xmm2 \n" |
| 2741 | "movzb 0x7(%0),%3 \n" |
| 2742 | "movd 0x0(%4,%3,4),%%xmm3 \n" |
| 2743 | "pshuflw $0xc0,%%xmm2,%%xmm2 \n" |
| 2744 | "pshuflw $0xc0,%%xmm3,%%xmm3 \n" |
| 2745 | "movlhps %%xmm3,%%xmm2 \n" |
| 2746 | "pmulhuw %%xmm2,%%xmm0 \n" |
| 2747 | "movdqa (%0),%%xmm1 \n" |
| 2748 | "movzb 0xb(%0),%3 \n" |
| 2749 | "punpckhbw %%xmm1,%%xmm1 \n" |
| 2750 | "movd 0x0(%4,%3,4),%%xmm2 \n" |
| 2751 | "movzb 0xf(%0),%3 \n" |
| 2752 | "movd 0x0(%4,%3,4),%%xmm3 \n" |
| 2753 | "pshuflw $0xc0,%%xmm2,%%xmm2 \n" |
| 2754 | "pshuflw $0xc0,%%xmm3,%%xmm3 \n" |
| 2755 | "movlhps %%xmm3,%%xmm2 \n" |
| 2756 | "pmulhuw %%xmm2,%%xmm1 \n" |
| 2757 | "movdqa (%0),%%xmm2 \n" |
| 2758 | "pand %%xmm4,%%xmm2 \n" |
| 2759 | "packuswb %%xmm1,%%xmm0 \n" |
| 2760 | "por %%xmm2,%%xmm0 \n" |
| 2761 | "sub $0x4,%2 \n" |
| 2762 | "movdqa %%xmm0,(%0,%1,1) \n" |
| 2763 | "lea 0x10(%0),%0 \n" |
| 2764 | "jg 1b \n" |
| 2765 | : "+r"(src_argb), // %0 |
| 2766 | "+r"(dst_argb), // %1 |
| 2767 | "+r"(width), // %2 |
| 2768 | "+r"(alpha) // %3 |
| 2769 | : "r"(fixed_invtbl8) // %4 |
| 2770 | : "memory", "cc" |
| 2771 | #if defined(__SSE2__) |
| 2772 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 2773 | #endif |
| 2774 | ); |
| 2775 | } |
| 2776 | #endif // HAS_ARGBUNATTENUATE_SSE2 |
| 2777 | |
fbarchard@google.com | ffaea7e | 2012-05-18 19:43:59 +0000 | [diff] [blame] | 2778 | #ifdef HAS_ARGBGRAYROW_SSSE3 |
fbarchard@google.com | 221e602 | 2012-05-21 22:24:41 +0000 | [diff] [blame] | 2779 | // Constant for ARGB color to gray scale. 0.11 * B + 0.59 * G + 0.30 * R |
| 2780 | CONST vec8 kARGBToGray = { |
| 2781 | 14, 76, 38, 0, 14, 76, 38, 0, 14, 76, 38, 0, 14, 76, 38, 0 |
| 2782 | }; |
| 2783 | |
fbarchard@google.com | ffaea7e | 2012-05-18 19:43:59 +0000 | [diff] [blame] | 2784 | // Convert 8 ARGB pixels (64 bytes) to 8 Gray ARGB pixels |
| 2785 | void ARGBGrayRow_SSSE3(uint8* dst_argb, int width) { |
| 2786 | asm volatile ( |
| 2787 | "movdqa %2,%%xmm4 \n" |
fbarchard@google.com | ffaea7e | 2012-05-18 19:43:59 +0000 | [diff] [blame] | 2788 | // 8 pixel loop \n" |
| 2789 | ".p2align 4 \n" |
| 2790 | "1: \n" |
| 2791 | "movdqa (%0),%%xmm0 \n" |
| 2792 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2793 | "pmaddubsw %%xmm4,%%xmm0 \n" |
| 2794 | "pmaddubsw %%xmm4,%%xmm1 \n" |
fbarchard@google.com | ffaea7e | 2012-05-18 19:43:59 +0000 | [diff] [blame] | 2795 | "phaddw %%xmm1,%%xmm0 \n" |
| 2796 | "psrlw $0x7,%%xmm0 \n" |
| 2797 | "packuswb %%xmm0,%%xmm0 \n" |
fbarchard@google.com | 221e602 | 2012-05-21 22:24:41 +0000 | [diff] [blame] | 2798 | "movdqa (%0),%%xmm2 \n" |
| 2799 | "movdqa 0x10(%0),%%xmm3 \n" |
| 2800 | "psrld $0x18,%%xmm2 \n" |
| 2801 | "psrld $0x18,%%xmm3 \n" |
| 2802 | "packuswb %%xmm3,%%xmm2 \n" |
| 2803 | "packuswb %%xmm2,%%xmm2 \n" |
| 2804 | "movdqa %%xmm0,%%xmm3 \n" |
fbarchard@google.com | ffaea7e | 2012-05-18 19:43:59 +0000 | [diff] [blame] | 2805 | "punpcklbw %%xmm0,%%xmm0 \n" |
fbarchard@google.com | 221e602 | 2012-05-21 22:24:41 +0000 | [diff] [blame] | 2806 | "punpcklbw %%xmm2,%%xmm3 \n" |
fbarchard@google.com | ffaea7e | 2012-05-18 19:43:59 +0000 | [diff] [blame] | 2807 | "movdqa %%xmm0,%%xmm1 \n" |
fbarchard@google.com | 221e602 | 2012-05-21 22:24:41 +0000 | [diff] [blame] | 2808 | "punpcklwd %%xmm3,%%xmm0 \n" |
| 2809 | "punpckhwd %%xmm3,%%xmm1 \n" |
fbarchard@google.com | ffaea7e | 2012-05-18 19:43:59 +0000 | [diff] [blame] | 2810 | "sub $0x8,%1 \n" |
| 2811 | "movdqa %%xmm0,(%0) \n" |
| 2812 | "movdqa %%xmm1,0x10(%0) \n" |
| 2813 | "lea 0x20(%0),%0 \n" |
| 2814 | "jg 1b \n" |
fbarchard@google.com | 221e602 | 2012-05-21 22:24:41 +0000 | [diff] [blame] | 2815 | : "+r"(dst_argb), // %0 |
| 2816 | "+r"(width) // %1 |
fbarchard@google.com | ffaea7e | 2012-05-18 19:43:59 +0000 | [diff] [blame] | 2817 | : "m"(kARGBToGray) // %2 |
| 2818 | : "memory", "cc" |
| 2819 | #if defined(__SSE2__) |
fbarchard@google.com | 221e602 | 2012-05-21 22:24:41 +0000 | [diff] [blame] | 2820 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" |
fbarchard@google.com | ffaea7e | 2012-05-18 19:43:59 +0000 | [diff] [blame] | 2821 | #endif |
| 2822 | ); |
| 2823 | } |
| 2824 | #endif // HAS_ARGBGRAYROW_SSSE3 |
fbarchard@google.com | 221e602 | 2012-05-21 22:24:41 +0000 | [diff] [blame] | 2825 | |
| 2826 | #ifdef HAS_ARGBSEPIAROW_SSSE3 |
| 2827 | // b = (r * 35 + g * 68 + b * 17) >> 7 |
| 2828 | // g = (r * 45 + g * 88 + b * 22) >> 7 |
| 2829 | // r = (r * 50 + g * 98 + b * 24) >> 7 |
| 2830 | // Constant for ARGB color to sepia tone |
| 2831 | CONST vec8 kARGBToSepiaB = { |
| 2832 | 17, 68, 35, 0, 17, 68, 35, 0, 17, 68, 35, 0, 17, 68, 35, 0 |
| 2833 | }; |
| 2834 | |
| 2835 | CONST vec8 kARGBToSepiaG = { |
| 2836 | 22, 88, 45, 0, 22, 88, 45, 0, 22, 88, 45, 0, 22, 88, 45, 0 |
| 2837 | }; |
| 2838 | |
| 2839 | CONST vec8 kARGBToSepiaR = { |
| 2840 | 24, 98, 50, 0, 24, 98, 50, 0, 24, 98, 50, 0, 24, 98, 50, 0 |
| 2841 | }; |
| 2842 | |
| 2843 | // Convert 8 ARGB pixels (64 bytes) to 8 Sepia ARGB pixels |
| 2844 | void ARGBSepiaRow_SSSE3(uint8* dst_argb, int width) { |
| 2845 | asm volatile ( |
| 2846 | "movdqa %2,%%xmm2 \n" |
| 2847 | "movdqa %3,%%xmm3 \n" |
| 2848 | "movdqa %4,%%xmm4 \n" |
| 2849 | // 8 pixel loop \n" |
| 2850 | ".p2align 4 \n" |
| 2851 | "1: \n" |
| 2852 | "movdqa (%0),%%xmm0 \n" |
| 2853 | "movdqa 0x10(%0),%%xmm6 \n" |
| 2854 | "pmaddubsw %%xmm2,%%xmm0 \n" |
| 2855 | "pmaddubsw %%xmm2,%%xmm6 \n" |
| 2856 | "phaddw %%xmm6,%%xmm0 \n" |
| 2857 | "psrlw $0x7,%%xmm0 \n" |
| 2858 | "packuswb %%xmm0,%%xmm0 \n" |
| 2859 | "movdqa (%0),%%xmm5 \n" |
| 2860 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2861 | "pmaddubsw %%xmm3,%%xmm5 \n" |
| 2862 | "pmaddubsw %%xmm3,%%xmm1 \n" |
| 2863 | "phaddw %%xmm1,%%xmm5 \n" |
| 2864 | "psrlw $0x7,%%xmm5 \n" |
| 2865 | "packuswb %%xmm5,%%xmm5 \n" |
| 2866 | "punpcklbw %%xmm5,%%xmm0 \n" |
| 2867 | "movdqa (%0),%%xmm5 \n" |
| 2868 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2869 | "pmaddubsw %%xmm4,%%xmm5 \n" |
| 2870 | "pmaddubsw %%xmm4,%%xmm1 \n" |
| 2871 | "phaddw %%xmm1,%%xmm5 \n" |
| 2872 | "psrlw $0x7,%%xmm5 \n" |
| 2873 | "packuswb %%xmm5,%%xmm5 \n" |
| 2874 | "movdqa (%0),%%xmm6 \n" |
| 2875 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2876 | "psrld $0x18,%%xmm6 \n" |
| 2877 | "psrld $0x18,%%xmm1 \n" |
| 2878 | "packuswb %%xmm1,%%xmm6 \n" |
| 2879 | "packuswb %%xmm6,%%xmm6 \n" |
| 2880 | "punpcklbw %%xmm6,%%xmm5 \n" |
| 2881 | "movdqa %%xmm0,%%xmm1 \n" |
| 2882 | "punpcklwd %%xmm5,%%xmm0 \n" |
| 2883 | "punpckhwd %%xmm5,%%xmm1 \n" |
| 2884 | "sub $0x8,%1 \n" |
| 2885 | "movdqa %%xmm0,(%0) \n" |
| 2886 | "movdqa %%xmm1,0x10(%0) \n" |
| 2887 | "lea 0x20(%0),%0 \n" |
| 2888 | "jg 1b \n" |
| 2889 | : "+r"(dst_argb), // %0 |
| 2890 | "+r"(width) // %1 |
| 2891 | : "m"(kARGBToSepiaB), // %2 |
| 2892 | "m"(kARGBToSepiaG), // %3 |
| 2893 | "m"(kARGBToSepiaR) // %4 |
| 2894 | : "memory", "cc" |
| 2895 | #if defined(__SSE2__) |
| 2896 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6" |
| 2897 | #endif |
| 2898 | ); |
| 2899 | } |
| 2900 | #endif // HAS_ARGBSEPIAROW_SSSE3 |
| 2901 | |
fbarchard@google.com | f51e879 | 2012-06-10 02:40:04 +0000 | [diff] [blame] | 2902 | #ifdef HAS_COMPUTECUMULATIVESUMROW_SSE2 |
| 2903 | // Creates a table of cumulative sums where each value is a sum of all values |
| 2904 | // above and to the left of the value, inclusive of the value. |
| 2905 | void ComputeCumulativeSumRow_SSE2(const uint8* row, int32* cumsum, |
fbarchard@google.com | 133adc4 | 2012-06-12 05:46:49 +0000 | [diff] [blame] | 2906 | const int32* previous_cumsum, int width) { |
fbarchard@google.com | f51e879 | 2012-06-10 02:40:04 +0000 | [diff] [blame] | 2907 | asm volatile ( |
| 2908 | "sub %1,%2 \n" |
| 2909 | "pxor %%xmm0,%%xmm0 \n" |
| 2910 | "pxor %%xmm1,%%xmm1 \n" |
| 2911 | "sub $0x4,%3 \n" |
| 2912 | "jl 49f \n" |
| 2913 | "test $0xf,%1 \n" |
| 2914 | "jne 49f \n" |
| 2915 | |
| 2916 | // 4 pixel loop \n" |
| 2917 | ".p2align 2 \n" |
| 2918 | "40: \n" |
| 2919 | "movdqu (%0),%%xmm2 \n" |
| 2920 | "lea 0x10(%0),%0 \n" |
| 2921 | "movdqa %%xmm2,%%xmm4 \n" |
| 2922 | "punpcklbw %%xmm1,%%xmm2 \n" |
| 2923 | "movdqa %%xmm2,%%xmm3 \n" |
| 2924 | "punpcklwd %%xmm1,%%xmm2 \n" |
| 2925 | "punpckhwd %%xmm1,%%xmm3 \n" |
| 2926 | "punpckhbw %%xmm1,%%xmm4 \n" |
| 2927 | "movdqa %%xmm4,%%xmm5 \n" |
| 2928 | "punpcklwd %%xmm1,%%xmm4 \n" |
| 2929 | "punpckhwd %%xmm1,%%xmm5 \n" |
| 2930 | "paddd %%xmm2,%%xmm0 \n" |
| 2931 | "movdqa (%1,%2,1),%%xmm2 \n" |
| 2932 | "paddd %%xmm0,%%xmm2 \n" |
| 2933 | "paddd %%xmm3,%%xmm0 \n" |
| 2934 | "movdqa 0x10(%1,%2,1),%%xmm3 \n" |
| 2935 | "paddd %%xmm0,%%xmm3 \n" |
| 2936 | "paddd %%xmm4,%%xmm0 \n" |
| 2937 | "movdqa 0x20(%1,%2,1),%%xmm4 \n" |
| 2938 | "paddd %%xmm0,%%xmm4 \n" |
| 2939 | "paddd %%xmm5,%%xmm0 \n" |
| 2940 | "movdqa 0x30(%1,%2,1),%%xmm5 \n" |
| 2941 | "paddd %%xmm0,%%xmm5 \n" |
| 2942 | "movdqa %%xmm2,(%1) \n" |
| 2943 | "movdqa %%xmm3,0x10(%1) \n" |
| 2944 | "movdqa %%xmm4,0x20(%1) \n" |
| 2945 | "movdqa %%xmm5,0x30(%1) \n" |
| 2946 | "lea 0x40(%1),%1 \n" |
| 2947 | "sub $0x4,%3 \n" |
| 2948 | "jge 40b \n" |
| 2949 | |
| 2950 | "49: \n" |
| 2951 | "add $0x3,%3 \n" |
| 2952 | "jl 19f \n" |
| 2953 | |
| 2954 | // 1 pixel loop \n" |
| 2955 | ".p2align 2 \n" |
| 2956 | "10: \n" |
| 2957 | "movd (%0),%%xmm2 \n" |
| 2958 | "lea 0x4(%0),%0 \n" |
fbarchard@google.com | f38aefe | 2012-06-12 00:29:29 +0000 | [diff] [blame] | 2959 | "punpcklbw %%xmm1,%%xmm2 \n" |
| 2960 | "punpcklwd %%xmm1,%%xmm2 \n" |
fbarchard@google.com | f51e879 | 2012-06-10 02:40:04 +0000 | [diff] [blame] | 2961 | "paddd %%xmm2,%%xmm0 \n" |
| 2962 | "movdqu (%1,%2,1),%%xmm2 \n" |
| 2963 | "paddd %%xmm0,%%xmm2 \n" |
| 2964 | "movdqu %%xmm2,(%1) \n" |
| 2965 | "lea 0x10(%1),%1 \n" |
| 2966 | "sub $0x1,%3 \n" |
| 2967 | "jge 10b \n" |
| 2968 | |
| 2969 | "19: \n" |
| 2970 | : "+r"(row), // %0 |
| 2971 | "+r"(cumsum), // %1 |
| 2972 | "+r"(previous_cumsum), // %2 |
| 2973 | "+r"(width) // %3 |
| 2974 | : |
| 2975 | : "memory", "cc" |
| 2976 | #if defined(__SSE2__) |
| 2977 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5" |
| 2978 | #endif |
| 2979 | ); |
| 2980 | } |
| 2981 | #endif // HAS_COMPUTECUMULATIVESUMROW_SSE2 |
| 2982 | |
| 2983 | #ifdef HAS_CUMULATIVESUMTOAVERAGE_SSE2 |
| 2984 | void CumulativeSumToAverage_SSE2(const int32* topleft, const int32* botleft, |
| 2985 | int width, int area, uint8* dst, int count) { |
| 2986 | asm volatile ( |
| 2987 | "movd %5,%%xmm4 \n" |
| 2988 | "cvtdq2ps %%xmm4,%%xmm4 \n" |
| 2989 | "rcpss %%xmm4,%%xmm4 \n" |
| 2990 | "pshufd $0x0,%%xmm4,%%xmm4 \n" |
| 2991 | "sub $0x4,%3 \n" |
| 2992 | "jl 49f \n" |
| 2993 | |
| 2994 | // 4 pixel loop \n" |
| 2995 | ".p2align 2 \n" |
| 2996 | "40: \n" |
| 2997 | "movdqa (%0),%%xmm0 \n" |
| 2998 | "movdqa 0x10(%0),%%xmm1 \n" |
| 2999 | "movdqa 0x20(%0),%%xmm2 \n" |
| 3000 | "movdqa 0x30(%0),%%xmm3 \n" |
| 3001 | "psubd (%0,%4,4),%%xmm0 \n" |
| 3002 | "psubd 0x10(%0,%4,4),%%xmm1 \n" |
| 3003 | "psubd 0x20(%0,%4,4),%%xmm2 \n" |
| 3004 | "psubd 0x30(%0,%4,4),%%xmm3 \n" |
| 3005 | "lea 0x40(%0),%0 \n" |
| 3006 | "psubd (%1),%%xmm0 \n" |
| 3007 | "psubd 0x10(%1),%%xmm1 \n" |
| 3008 | "psubd 0x20(%1),%%xmm2 \n" |
| 3009 | "psubd 0x30(%1),%%xmm3 \n" |
| 3010 | "paddd (%1,%4,4),%%xmm0 \n" |
| 3011 | "paddd 0x10(%1,%4,4),%%xmm1 \n" |
| 3012 | "paddd 0x20(%1,%4,4),%%xmm2 \n" |
| 3013 | "paddd 0x30(%1,%4,4),%%xmm3 \n" |
| 3014 | "lea 0x40(%1),%1 \n" |
| 3015 | "cvtdq2ps %%xmm0,%%xmm0 \n" |
| 3016 | "cvtdq2ps %%xmm1,%%xmm1 \n" |
| 3017 | "mulps %%xmm4,%%xmm0 \n" |
| 3018 | "mulps %%xmm4,%%xmm1 \n" |
| 3019 | "cvtdq2ps %%xmm2,%%xmm2 \n" |
| 3020 | "cvtdq2ps %%xmm3,%%xmm3 \n" |
| 3021 | "mulps %%xmm4,%%xmm2 \n" |
| 3022 | "mulps %%xmm4,%%xmm3 \n" |
| 3023 | "cvtps2dq %%xmm0,%%xmm0 \n" |
| 3024 | "cvtps2dq %%xmm1,%%xmm1 \n" |
| 3025 | "cvtps2dq %%xmm2,%%xmm2 \n" |
| 3026 | "cvtps2dq %%xmm3,%%xmm3 \n" |
| 3027 | "packssdw %%xmm1,%%xmm0 \n" |
| 3028 | "packssdw %%xmm3,%%xmm2 \n" |
| 3029 | "packuswb %%xmm2,%%xmm0 \n" |
| 3030 | "movdqu %%xmm0,(%2) \n" |
| 3031 | "lea 0x10(%2),%2 \n" |
| 3032 | "sub $0x4,%3 \n" |
| 3033 | "jge 40b \n" |
| 3034 | |
| 3035 | "49: \n" |
| 3036 | "add $0x3,%3 \n" |
| 3037 | "jl 19f \n" |
| 3038 | |
| 3039 | // 1 pixel loop \n" |
| 3040 | ".p2align 2 \n" |
| 3041 | "10: \n" |
| 3042 | "movdqa (%0),%%xmm0 \n" |
| 3043 | "psubd (%0,%4,4),%%xmm0 \n" |
| 3044 | "lea 0x10(%0),%0 \n" |
| 3045 | "psubd (%1),%%xmm0 \n" |
| 3046 | "paddd (%1,%4,4),%%xmm0 \n" |
| 3047 | "lea 0x10(%1),%1 \n" |
| 3048 | "cvtdq2ps %%xmm0,%%xmm0 \n" |
| 3049 | "mulps %%xmm4,%%xmm0 \n" |
| 3050 | "cvtps2dq %%xmm0,%%xmm0 \n" |
| 3051 | "packssdw %%xmm0,%%xmm0 \n" |
| 3052 | "packuswb %%xmm0,%%xmm0 \n" |
| 3053 | "movd %%xmm0,(%2) \n" |
| 3054 | "lea 0x4(%2),%2 \n" |
| 3055 | "sub $0x1,%3 \n" |
| 3056 | "jge 10b \n" |
| 3057 | "19: \n" |
| 3058 | : "+r"(topleft), // %0 |
| 3059 | "+r"(botleft), // %1 |
| 3060 | "+r"(dst), // %2 |
| 3061 | "+rm"(count) // %3 |
| 3062 | : "r"(static_cast<intptr_t>(width)), // %4 |
| 3063 | "rm"(area) // %5 |
| 3064 | : "memory", "cc" |
| 3065 | #if defined(__SSE2__) |
| 3066 | , "xmm0", "xmm1", "xmm2", "xmm3", "xmm4" |
| 3067 | #endif |
| 3068 | ); |
| 3069 | } |
| 3070 | #endif // HAS_CUMULATIVESUMTOAVERAGE_SSE2 |
| 3071 | |
| 3072 | |
fbarchard@google.com | 2d11d43 | 2012-02-16 02:50:39 +0000 | [diff] [blame] | 3073 | #endif // defined(__x86_64__) || defined(__i386__) |
| 3074 | |
fbarchard@google.com | fe5ff7e | 2011-12-10 07:45:58 +0000 | [diff] [blame] | 3075 | #ifdef __cplusplus |
mikhal@webrtc.org | aed1cc9 | 2011-09-28 00:06:25 +0000 | [diff] [blame] | 3076 | } // extern "C" |
fbarchard@google.com | fe5ff7e | 2011-12-10 07:45:58 +0000 | [diff] [blame] | 3077 | } // namespace libyuv |
| 3078 | #endif |