| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2012 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 |
| 11 #include "libyuv/row.h" | 11 #include "libyuv/row.h" |
| 12 | 12 |
| 13 #include <string.h> // For memset. | 13 #include <string.h> // For memset. |
| 14 | 14 |
| 15 #include "libyuv/basic_types.h" | 15 #include "libyuv/basic_types.h" |
| 16 | 16 |
| 17 #ifdef __cplusplus | 17 #ifdef __cplusplus |
| 18 namespace libyuv { | 18 namespace libyuv { |
| 19 extern "C" { | 19 extern "C" { |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 // Subsampled source needs to be increase by 1 of not even. | 22 // Subsampled source needs to be increase by 1 of not even. |
| 23 #define SS(width, shift) (((width) + (1 << (shift)) - 1) >> (shift)) | 23 #define SS(width, shift) (((width) + (1 << (shift)) - 1) >> (shift)) |
| 24 | 24 |
| 25 // Any 4 planes to 1 with yuvconstants |
| 26 #define ANY41C(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \ |
| 27 void NAMEANY(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, \ |
| 28 const uint8* a_buf, uint8* dst_ptr, \ |
| 29 struct YuvConstants* yuvconstants, int width) { \ |
| 30 SIMD_ALIGNED(uint8 temp[64 * 5]); \ |
| 31 memset(temp, 0, 64 * 4); /* for msan */ \ |
| 32 int r = width & MASK; \ |
| 33 int n = width & ~MASK; \ |
| 34 if (n > 0) { \ |
| 35 ANY_SIMD(y_buf, u_buf, v_buf, a_buf, dst_ptr, yuvconstants, n); \ |
| 36 } \ |
| 37 memcpy(temp, y_buf + n, r); \ |
| 38 memcpy(temp + 64, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \ |
| 39 memcpy(temp + 128, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \ |
| 40 memcpy(temp + 192, a_buf + n, r); \ |
| 41 ANY_SIMD(temp, temp + 64, temp + 128, temp + 192, temp + 256, \ |
| 42 yuvconstants, MASK + 1); \ |
| 43 memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, temp + 256, \ |
| 44 SS(r, DUVSHIFT) * BPP); \ |
| 45 } |
| 46 |
| 47 #ifdef HAS_I422ALPHATOARGBROW_SSSE3 |
| 48 ANY41C(I422AlphaToARGBRow_Any_SSSE3, I422AlphaToARGBRow_SSSE3, 1, 0, 4, 7) |
| 49 ANY41C(I422AlphaToABGRRow_Any_SSSE3, I422AlphaToABGRRow_SSSE3, 1, 0, 4, 7) |
| 50 #endif |
| 51 #undef ANY41C |
| 52 |
| 25 // Any 3 planes to 1. | 53 // Any 3 planes to 1. |
| 26 #define ANY31(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \ | 54 #define ANY31(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \ |
| 27 void NAMEANY(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, \ | 55 void NAMEANY(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, \ |
| 28 uint8* dst_ptr, int width) { \ | 56 uint8* dst_ptr, int width) { \ |
| 29 SIMD_ALIGNED(uint8 temp[64 * 4]); \ | 57 SIMD_ALIGNED(uint8 temp[64 * 4]); \ |
| 30 memset(temp, 0, 64 * 3); /* for YUY2 and msan */ \ | 58 memset(temp, 0, 64 * 3); /* for YUY2 and msan */ \ |
| 31 int r = width & MASK; \ | 59 int r = width & MASK; \ |
| 32 int n = width & ~MASK; \ | 60 int n = width & ~MASK; \ |
| 33 if (n > 0) { \ | 61 if (n > 0) { \ |
| 34 ANY_SIMD(y_buf, u_buf, v_buf, dst_ptr, n); \ | 62 ANY_SIMD(y_buf, u_buf, v_buf, dst_ptr, n); \ |
| 35 } \ | 63 } \ |
| 36 memcpy(temp, y_buf + n, r); \ | 64 memcpy(temp, y_buf + n, r); \ |
| 37 memcpy(temp + 64, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \ | 65 memcpy(temp + 64, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \ |
| 38 memcpy(temp + 128, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \ | 66 memcpy(temp + 128, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \ |
| 39 ANY_SIMD(temp, temp + 64, temp + 128, temp + 192, MASK + 1); \ | 67 ANY_SIMD(temp, temp + 64, temp + 128, temp + 192, MASK + 1); \ |
| 40 memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, temp + 192, \ | 68 memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, temp + 192, \ |
| 41 SS(r, DUVSHIFT) * BPP); \ | 69 SS(r, DUVSHIFT) * BPP); \ |
| 42 } | 70 } |
| 43 #ifdef HAS_I422TOYUY2ROW_SSE2 | 71 #ifdef HAS_I422TOYUY2ROW_SSE2 |
| 44 ANY31(I422ToYUY2Row_Any_SSE2, I422ToYUY2Row_SSE2, 1, 1, 4, 15) | 72 ANY31(I422ToYUY2Row_Any_SSE2, I422ToYUY2Row_SSE2, 1, 1, 4, 15) |
| 45 ANY31(I422ToUYVYRow_Any_SSE2, I422ToUYVYRow_SSE2, 1, 1, 4, 15) | 73 ANY31(I422ToUYVYRow_Any_SSE2, I422ToUYVYRow_SSE2, 1, 1, 4, 15) |
| 46 #endif | 74 #endif |
| 47 #ifdef HAS_I422TOYUY2ROW_NEON | 75 #ifdef HAS_I422TOYUY2ROW_NEON |
| 48 ANY31(I422ToYUY2Row_Any_NEON, I422ToYUY2Row_NEON, 1, 1, 4, 15) | 76 ANY31(I422ToYUY2Row_Any_NEON, I422ToYUY2Row_NEON, 1, 1, 4, 15) |
| 49 #endif | 77 #endif |
| 50 #ifdef HAS_I422TOUYVYROW_NEON | 78 #ifdef HAS_I422TOUYVYROW_NEON |
| 51 ANY31(I422ToUYVYRow_Any_NEON, I422ToUYVYRow_NEON, 1, 1, 4, 15) | 79 ANY31(I422ToUYVYRow_Any_NEON, I422ToUYVYRow_NEON, 1, 1, 4, 15) |
| 52 #endif | 80 #endif |
| 53 #undef ANY31C | 81 #undef ANY31 |
| 54 | 82 |
| 55 // Any 3 planes to 1 with yuvconstants | 83 // Any 3 planes to 1 with yuvconstants |
| 56 #define ANY31C(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \ | 84 #define ANY31C(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \ |
| 57 void NAMEANY(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, \ | 85 void NAMEANY(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, \ |
| 58 uint8* dst_ptr, struct YuvConstants* yuvconstants, \ | 86 uint8* dst_ptr, struct YuvConstants* yuvconstants, \ |
| 59 int width) { \ | 87 int width) { \ |
| 60 SIMD_ALIGNED(uint8 temp[64 * 4]); \ | 88 SIMD_ALIGNED(uint8 temp[64 * 4]); \ |
| 61 memset(temp, 0, 64 * 3); /* for YUY2 and msan */ \ | 89 memset(temp, 0, 64 * 3); /* for YUY2 and msan */ \ |
| 62 int r = width & MASK; \ | 90 int r = width & MASK; \ |
| 63 int n = width & ~MASK; \ | 91 int n = width & ~MASK; \ |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 #endif | 788 #endif |
| 761 #ifdef HAS_UYVYTOUVROW_NEON | 789 #ifdef HAS_UYVYTOUVROW_NEON |
| 762 ANY12S(UYVYToUVRow_Any_NEON, UYVYToUVRow_NEON, 1, 4, 15) | 790 ANY12S(UYVYToUVRow_Any_NEON, UYVYToUVRow_NEON, 1, 4, 15) |
| 763 #endif | 791 #endif |
| 764 #undef ANY12S | 792 #undef ANY12S |
| 765 | 793 |
| 766 #ifdef __cplusplus | 794 #ifdef __cplusplus |
| 767 } // extern "C" | 795 } // extern "C" |
| 768 } // namespace libyuv | 796 } // namespace libyuv |
| 769 #endif | 797 #endif |
| OLD | NEW |