| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // Shuffle table for converting RGB24 to ARGB. | 219 // Shuffle table for converting RGB24 to ARGB. |
| 220 static const uvec8 kShuffleMaskRGB24ToARGB = { | 220 static const uvec8 kShuffleMaskRGB24ToARGB = { |
| 221 0u, 1u, 2u, 12u, 3u, 4u, 5u, 13u, 6u, 7u, 8u, 14u, 9u, 10u, 11u, 15u | 221 0u, 1u, 2u, 12u, 3u, 4u, 5u, 13u, 6u, 7u, 8u, 14u, 9u, 10u, 11u, 15u |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 // Shuffle table for converting RAW to ARGB. | 224 // Shuffle table for converting RAW to ARGB. |
| 225 static const uvec8 kShuffleMaskRAWToARGB = { | 225 static const uvec8 kShuffleMaskRAWToARGB = { |
| 226 2u, 1u, 0u, 12u, 5u, 4u, 3u, 13u, 8u, 7u, 6u, 14u, 11u, 10u, 9u, 15u | 226 2u, 1u, 0u, 12u, 5u, 4u, 3u, 13u, 8u, 7u, 6u, 14u, 11u, 10u, 9u, 15u |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 // Shuffle table for converting RAW to RGB24. First 8. |
| 230 static const uvec8 kShuffleMaskRAWToRGB24_0 = { |
| 231 2u, 1u, 0u, 5u, 4u, 3u, 8u, 7u, |
| 232 128u, 128u, 128u, 128u, 128u, 128u, 128u, 128u |
| 233 }; |
| 234 |
| 235 // Shuffle table for converting RAW to RGB24. Middle 8. |
| 236 static const uvec8 kShuffleMaskRAWToRGB24_1 = { |
| 237 2u, 7u, 6u, 5u, 10u, 9u, 8u, 13u, |
| 238 128u, 128u, 128u, 128u, 128u, 128u, 128u, 128u |
| 239 }; |
| 240 |
| 241 // Shuffle table for converting RAW to RGB24. Last 8. |
| 242 static const uvec8 kShuffleMaskRAWToRGB24_2 = { |
| 243 8u, 7u, 12u, 11u, 10u, 15u, 14u, 13u, |
| 244 128u, 128u, 128u, 128u, 128u, 128u, 128u, 128u |
| 245 }; |
| 246 |
| 229 // Shuffle table for converting ARGB to RGB24. | 247 // Shuffle table for converting ARGB to RGB24. |
| 230 static const uvec8 kShuffleMaskARGBToRGB24 = { | 248 static const uvec8 kShuffleMaskARGBToRGB24 = { |
| 231 0u, 1u, 2u, 4u, 5u, 6u, 8u, 9u, 10u, 12u, 13u, 14u, 128u, 128u, 128u, 128u | 249 0u, 1u, 2u, 4u, 5u, 6u, 8u, 9u, 10u, 12u, 13u, 14u, 128u, 128u, 128u, 128u |
| 232 }; | 250 }; |
| 233 | 251 |
| 234 // Shuffle table for converting ARGB to RAW. | 252 // Shuffle table for converting ARGB to RAW. |
| 235 static const uvec8 kShuffleMaskARGBToRAW = { | 253 static const uvec8 kShuffleMaskARGBToRAW = { |
| 236 2u, 1u, 0u, 6u, 5u, 4u, 10u, 9u, 8u, 14u, 13u, 12u, 128u, 128u, 128u, 128u | 254 2u, 1u, 0u, 6u, 5u, 4u, 10u, 9u, 8u, 14u, 13u, 12u, 128u, 128u, 128u, 128u |
| 237 }; | 255 }; |
| 238 | 256 |
| 239 // Shuffle table for converting ARGBToRGB24 for I422ToRGB24. First 8 + next 4 | 257 // Shuffle table for converting ARGBToRGB24 for I422ToRGB24. First 8 + next 4 |
| 240 static const uvec8 kShuffleMaskARGBToRGB24_0 = { | 258 static const uvec8 kShuffleMaskARGBToRGB24_0 = { |
| 241 0u, 1u, 2u, 4u, 5u, 6u, 8u, 9u, 128u, 128u, 128u, 128u, 10u, 12u, 13u, 14u | 259 0u, 1u, 2u, 4u, 5u, 6u, 8u, 9u, 128u, 128u, 128u, 128u, 10u, 12u, 13u, 14u |
| 242 }; | 260 }; |
| 243 | 261 |
| 244 // Shuffle table for converting ARGB to RAW. | |
| 245 static const uvec8 kShuffleMaskARGBToRAW_0 = { | |
| 246 2u, 1u, 0u, 6u, 5u, 4u, 10u, 9u, 128u, 128u, 128u, 128u, 8u, 14u, 13u, 12u | |
| 247 }; | |
| 248 | |
| 249 // YUY2 shuf 16 Y to 32 Y. | 262 // YUY2 shuf 16 Y to 32 Y. |
| 250 static const lvec8 kShuffleYUY2Y = { | 263 static const lvec8 kShuffleYUY2Y = { |
| 251 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, | 264 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, |
| 252 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14 | 265 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14 |
| 253 }; | 266 }; |
| 254 | 267 |
| 255 // YUY2 shuf 8 UV to 16 UV. | 268 // YUY2 shuf 8 UV to 16 UV. |
| 256 static const lvec8 kShuffleYUY2UV = { | 269 static const lvec8 kShuffleYUY2UV = { |
| 257 1, 3, 1, 3, 5, 7, 5, 7, 9, 11, 9, 11, 13, 15, 13, 15, | 270 1, 3, 1, 3, 5, 7, 5, 7, 9, 11, 9, 11, 13, 15, 13, 15, |
| 258 1, 3, 1, 3, 5, 7, 5, 7, 9, 11, 9, 11, 13, 15, 13, 15 | 271 1, 3, 1, 3, 5, 7, 5, 7, 9, 11, 9, 11, 13, 15, 13, 15 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 movdqu [edx + 16], xmm1 | 419 movdqu [edx + 16], xmm1 |
| 407 por xmm3, xmm5 | 420 por xmm3, xmm5 |
| 408 movdqu [edx + 48], xmm3 | 421 movdqu [edx + 48], xmm3 |
| 409 lea edx, [edx + 64] | 422 lea edx, [edx + 64] |
| 410 sub ecx, 16 | 423 sub ecx, 16 |
| 411 jg convertloop | 424 jg convertloop |
| 412 ret | 425 ret |
| 413 } | 426 } |
| 414 } | 427 } |
| 415 | 428 |
| 429 __declspec(naked) |
| 430 void RAWToRGB24Row_SSSE3(const uint8* src_raw, uint8* dst_rgb24, int width) { |
| 431 __asm { |
| 432 mov eax, [esp + 4] // src_raw |
| 433 mov edx, [esp + 8] // dst_rgb24 |
| 434 mov ecx, [esp + 12] // width |
| 435 movdqa xmm3, xmmword ptr kShuffleMaskRAWToRGB24_0 |
| 436 movdqa xmm4, xmmword ptr kShuffleMaskRAWToRGB24_1 |
| 437 movdqa xmm5, xmmword ptr kShuffleMaskRAWToRGB24_2 |
| 438 |
| 439 convertloop: |
| 440 movdqu xmm0, [eax] |
| 441 movdqu xmm1, [eax + 4] |
| 442 movdqu xmm2, [eax + 8] |
| 443 lea eax, [eax + 24] |
| 444 pshufb xmm0, xmm3 |
| 445 pshufb xmm1, xmm4 |
| 446 pshufb xmm2, xmm5 |
| 447 movq qword ptr [edx], xmm0 |
| 448 movq qword ptr [edx + 8], xmm1 |
| 449 movq qword ptr [edx + 16], xmm2 |
| 450 lea edx, [edx + 24] |
| 451 sub ecx, 8 |
| 452 jg convertloop |
| 453 ret |
| 454 } |
| 455 } |
| 456 |
| 416 // pmul method to replicate bits. | 457 // pmul method to replicate bits. |
| 417 // Math to replicate bits: | 458 // Math to replicate bits: |
| 418 // (v << 8) | (v << 3) | 459 // (v << 8) | (v << 3) |
| 419 // v * 256 + v * 8 | 460 // v * 256 + v * 8 |
| 420 // v * (256 + 8) | 461 // v * (256 + 8) |
| 421 // G shift of 5 is incorporated, so shift is 5 + 8 and 5 + 3 | 462 // G shift of 5 is incorporated, so shift is 5 + 8 and 5 + 3 |
| 422 // 20 instructions. | 463 // 20 instructions. |
| 423 __declspec(naked) | 464 __declspec(naked) |
| 424 void RGB565ToARGBRow_SSE2(const uint8* src_rgb565, uint8* dst_argb, | 465 void RGB565ToARGBRow_SSE2(const uint8* src_rgb565, uint8* dst_argb, |
| 425 int width) { | 466 int width) { |
| (...skipping 5761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6187 } | 6228 } |
| 6188 #endif // HAS_ARGBLUMACOLORTABLEROW_SSSE3 | 6229 #endif // HAS_ARGBLUMACOLORTABLEROW_SSSE3 |
| 6189 | 6230 |
| 6190 #endif // defined(_M_X64) | 6231 #endif // defined(_M_X64) |
| 6191 #endif // !defined(LIBYUV_DISABLE_X86) && (defined(_M_IX86) || defined(_M_X64)) | 6232 #endif // !defined(LIBYUV_DISABLE_X86) && (defined(_M_IX86) || defined(_M_X64)) |
| 6192 | 6233 |
| 6193 #ifdef __cplusplus | 6234 #ifdef __cplusplus |
| 6194 } // extern "C" | 6235 } // extern "C" |
| 6195 } // namespace libyuv | 6236 } // namespace libyuv |
| 6196 #endif | 6237 #endif |
| OLD | NEW |