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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 #define VR -102 /* round(-1.596 * 64) */ | 1010 #define VR -102 /* round(-1.596 * 64) */ |
1011 | 1011 |
1012 // Bias values to subtract 16 from Y and 128 from U and V. | 1012 // Bias values to subtract 16 from Y and 128 from U and V. |
1013 #define BB (UB * 128 + YGB) | 1013 #define BB (UB * 128 + YGB) |
1014 #define BG (UG * 128 + VG * 128 + YGB) | 1014 #define BG (UG * 128 + VG * 128 + YGB) |
1015 #define BR (VR * 128 + YGB) | 1015 #define BR (VR * 128 + YGB) |
1016 | 1016 |
1017 // BT.601 constants for YUV to RGB. | 1017 // BT.601 constants for YUV to RGB. |
1018 // TODO(fbarchard): Unify these structures to be platform independent. | 1018 // TODO(fbarchard): Unify these structures to be platform independent. |
1019 // TODO(fbarchard): Generate SIMD structures from float matrix. | 1019 // TODO(fbarchard): Generate SIMD structures from float matrix. |
| 1020 |
| 1021 // BT601 constants for YUV to RGB. |
1020 #if defined(__aarch64__) | 1022 #if defined(__aarch64__) |
1021 const YuvConstants SIMD_ALIGNED(kYuvIConstants) = { | 1023 const YuvConstants SIMD_ALIGNED(kYuvIConstants) = { |
1022 { -UB, 0, -UB, 0, -UB, 0, -UB, 0, -VR, 0, -VR, 0, -VR, 0, -VR, 0 }, | 1024 { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, |
1023 { UG, 0, UG, 0, UG, 0, UG, 0, VG, 0, VG, 0, VG, 0, VG, 0 }, | 1025 { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, |
| 1026 { UG, VG, UG, VG, UG, VG, UG, VG }, |
| 1027 { UG, VG, UG, VG, UG, VG, UG, VG }, |
1024 { BB, BG, BR, 0, 0, 0, 0, 0 }, | 1028 { BB, BG, BR, 0, 0, 0, 0, 0 }, |
1025 { 0x0101 * YG, 0, 0, 0 } | 1029 { 0x0101 * YG, 0, 0, 0 } |
1026 }; | 1030 }; |
1027 | 1031 |
1028 #elif defined(__arm__) | 1032 #elif defined(__arm__) |
1029 const YuvConstants SIMD_ALIGNED(kYuvIConstants) = { | 1033 const YuvConstants SIMD_ALIGNED(kYuvIConstants) = { |
1030 { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, | 1034 { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, |
1031 { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, | 1035 { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, |
1032 { BB, BG, BR, 0, 0, 0, 0, 0 }, | 1036 { BB, BG, BR, 0, 0, 0, 0, 0 }, |
1033 { 0x0101 * YG, 0, 0, 0 } | 1037 { 0x0101 * YG, 0, 0, 0 } |
1034 }; | 1038 }; |
1035 #else | 1039 #else |
1036 const YuvConstants SIMD_ALIGNED(kYuvIConstants) = { | 1040 const YuvConstants SIMD_ALIGNED(kYuvIConstants) = { |
(...skipping 28 matching lines...) Expand all Loading... |
1065 #undef VR | 1069 #undef VR |
1066 #undef YG | 1070 #undef YG |
1067 | 1071 |
1068 // C reference code that mimics the YUV assembly. | 1072 // C reference code that mimics the YUV assembly. |
1069 static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, | 1073 static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, |
1070 uint8* b, uint8* g, uint8* r, | 1074 uint8* b, uint8* g, uint8* r, |
1071 const struct YuvConstants* yuvconstants) { | 1075 const struct YuvConstants* yuvconstants) { |
1072 #if defined(__aarch64__) | 1076 #if defined(__aarch64__) |
1073 int UB = -yuvconstants->kUVToRB[0]; | 1077 int UB = -yuvconstants->kUVToRB[0]; |
1074 int UG = yuvconstants->kUVToG[0]; | 1078 int UG = yuvconstants->kUVToG[0]; |
1075 int VG = yuvconstants->kUVToG[8]; | 1079 int VG = yuvconstants->kUVToG[1]; |
1076 int VR = -yuvconstants->kUVToRB[8]; | 1080 int VR = -yuvconstants->kUVToRB[1]; |
1077 int BB = yuvconstants->kUVBiasBGR[0]; | 1081 int BB = yuvconstants->kUVBiasBGR[0]; |
1078 int BG = yuvconstants->kUVBiasBGR[1]; | 1082 int BG = yuvconstants->kUVBiasBGR[1]; |
1079 int BR = yuvconstants->kUVBiasBGR[2]; | 1083 int BR = yuvconstants->kUVBiasBGR[2]; |
1080 int YG = yuvconstants->kYToRgb[0]; | 1084 int YG = yuvconstants->kYToRgb[0]; |
1081 #elif defined(__arm__) | 1085 #elif defined(__arm__) |
1082 int UB = -yuvconstants->kUVToRB[0]; | 1086 int UB = -yuvconstants->kUVToRB[0]; |
1083 int UG = yuvconstants->kUVToG[0]; | 1087 int UG = yuvconstants->kUVToG[0]; |
1084 int VG = yuvconstants->kUVToG[4]; | 1088 int VG = yuvconstants->kUVToG[4]; |
1085 int VR = -yuvconstants->kUVToRB[4]; | 1089 int VR = -yuvconstants->kUVToRB[4]; |
1086 int BB = yuvconstants->kUVBiasBGR[0]; | 1090 int BB = yuvconstants->kUVBiasBGR[0]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 #define VRJ -90 /* round(-1.40200 * 64) */ | 1123 #define VRJ -90 /* round(-1.40200 * 64) */ |
1120 | 1124 |
1121 // Bias values to round, and subtract 128 from U and V. | 1125 // Bias values to round, and subtract 128 from U and V. |
1122 #define BBJ (UBJ * 128 + YGBJ) | 1126 #define BBJ (UBJ * 128 + YGBJ) |
1123 #define BGJ (UGJ * 128 + VGJ * 128 + YGBJ) | 1127 #define BGJ (UGJ * 128 + VGJ * 128 + YGBJ) |
1124 #define BRJ (VRJ * 128 + YGBJ) | 1128 #define BRJ (VRJ * 128 + YGBJ) |
1125 | 1129 |
1126 // JPEG constants for YUV to RGB. | 1130 // JPEG constants for YUV to RGB. |
1127 #if defined(__aarch64__) | 1131 #if defined(__aarch64__) |
1128 const YuvConstants SIMD_ALIGNED(kYuvJConstants) = { | 1132 const YuvConstants SIMD_ALIGNED(kYuvJConstants) = { |
1129 { -UBJ, 0, -UBJ, 0, -UBJ, 0, -UBJ, 0, -VRJ, 0, -VRJ, 0, -VRJ, 0, -VRJ, 0 }, | 1133 { -UBJ, -VRJ, -UBJ, -VRJ, -UBJ, -VRJ, -UBJ, -VRJ }, |
1130 { UGJ, 0, UGJ, 0, UGJ, 0, UGJ, 0, VGJ, 0, VGJ, 0, VGJ, 0, VGJ, 0 }, | 1134 { -UBJ, -VRJ, -UBJ, -VRJ, -UBJ, -VRJ, -UBJ, -VRJ }, |
| 1135 { UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ }, |
| 1136 { UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ }, |
1131 { BBJ, BGJ, BRJ, 0, 0, 0, 0, 0 }, | 1137 { BBJ, BGJ, BRJ, 0, 0, 0, 0, 0 }, |
1132 { 0x0101 * YGJ, 0, 0, 0 } | 1138 { 0x0101 * YGJ, 0, 0, 0 } |
1133 }; | 1139 }; |
1134 | 1140 |
1135 #elif defined(__arm__) | 1141 #elif defined(__arm__) |
1136 const YuvConstants SIMD_ALIGNED(kYuvJConstants) = { | 1142 const YuvConstants SIMD_ALIGNED(kYuvJConstants) = { |
1137 { -UBJ, -UBJ, -UBJ, -UBJ, -VRJ, -VRJ, -VRJ, -VRJ, 0, 0, 0, 0, 0, 0, 0, 0 }, | 1143 { -UBJ, -UBJ, -UBJ, -UBJ, -VRJ, -VRJ, -VRJ, -VRJ, 0, 0, 0, 0, 0, 0, 0, 0 }, |
1138 { UGJ, UGJ, UGJ, UGJ, VGJ, VGJ, VGJ, VGJ, 0, 0, 0, 0, 0, 0, 0, 0 }, | 1144 { UGJ, UGJ, UGJ, UGJ, VGJ, VGJ, VGJ, VGJ, 0, 0, 0, 0, 0, 0, 0, 0 }, |
1139 { BBJ, BGJ, BRJ, 0, 0, 0, 0, 0 }, | 1145 { BBJ, BGJ, BRJ, 0, 0, 0, 0, 0 }, |
1140 { 0x0101 * YGJ, 0, 0, 0 } | 1146 { 0x0101 * YGJ, 0, 0, 0 } |
1141 }; | 1147 }; |
1142 #else | 1148 #else |
1143 const YuvConstants SIMD_ALIGNED(kYuvJConstants) = { | 1149 const YuvConstants SIMD_ALIGNED(kYuvJConstants) = { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 #define VRH -82 /* round(-1.28033 * 64) */ | 1193 #define VRH -82 /* round(-1.28033 * 64) */ |
1188 | 1194 |
1189 // Bias values to round, and subtract 128 from U and V. | 1195 // Bias values to round, and subtract 128 from U and V. |
1190 #define BBH (UBH * 128 + YGBH) | 1196 #define BBH (UBH * 128 + YGBH) |
1191 #define BGH (UGH * 128 + VGH * 128 + YGBH) | 1197 #define BGH (UGH * 128 + VGH * 128 + YGBH) |
1192 #define BRH (VRH * 128 + YGBH) | 1198 #define BRH (VRH * 128 + YGBH) |
1193 | 1199 |
1194 // BT.709 constants for YUV to RGB. | 1200 // BT.709 constants for YUV to RGB. |
1195 #if defined(__aarch64__) | 1201 #if defined(__aarch64__) |
1196 const YuvConstants SIMD_ALIGNED(kYuvHConstants) = { | 1202 const YuvConstants SIMD_ALIGNED(kYuvHConstants) = { |
1197 { -UBH, 0, -UBH, 0, -UBH, 0, -UBH, 0, -VRH, 0, -VRH, 0, -VRH, 0, -VRH, 0 }, | 1203 { -UBH, -VRH, -UBH, -VRH, -UBH, -VRH, -UBH, -VRH }, |
1198 { UGH, 0, UGH, 0, UGH, 0, UGH, 0, VGH, 0, VGH, 0, VGH, 0, VGH, 0 }, | 1204 { -UBH, -VRH, -UBH, -VRH, -UBH, -VRH, -UBH, -VRH }, |
| 1205 { UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH }, |
| 1206 { UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH }, |
1199 { BBH, BGH, BRH, 0, 0, 0, 0, 0 }, | 1207 { BBH, BGH, BRH, 0, 0, 0, 0, 0 }, |
1200 { 0x0101 * YGH, 0, 0, 0 } | 1208 { 0x0101 * YGH, 0, 0, 0 } |
1201 }; | 1209 }; |
1202 | 1210 |
1203 #elif defined(__arm__) | 1211 #elif defined(__arm__) |
1204 const YuvConstants SIMD_ALIGNED(kYuvHConstants) = { | 1212 const YuvConstants SIMD_ALIGNED(kYuvHConstants) = { |
1205 { -UBH, -UBH, -UBH, -UBH, -VRH, -VRH, -VRH, -VRH, 0, 0, 0, 0, 0, 0, 0, 0 }, | 1213 { -UBH, -UBH, -UBH, -UBH, -VRH, -VRH, -VRH, -VRH, 0, 0, 0, 0, 0, 0, 0, 0 }, |
1206 { UGH, UGH, UGH, UGH, VGH, VGH, VGH, VGH, 0, 0, 0, 0, 0, 0, 0, 0 }, | 1214 { UGH, UGH, UGH, UGH, VGH, VGH, VGH, VGH, 0, 0, 0, 0, 0, 0, 0, 0 }, |
1207 { BBH, BGH, BRH, 0, 0, 0, 0, 0 }, | 1215 { BBH, BGH, BRH, 0, 0, 0, 0, 0 }, |
1208 { 0x0101 * YGH, 0, 0, 0 } | 1216 { 0x0101 * YGH, 0, 0, 0 } |
1209 }; | 1217 }; |
1210 #else | 1218 #else |
1211 const YuvConstants SIMD_ALIGNED(kYuvHConstants) = { | 1219 const YuvConstants SIMD_ALIGNED(kYuvHConstants) = { |
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2691 dst_rgb565 += twidth * 2; | 2699 dst_rgb565 += twidth * 2; |
2692 width -= twidth; | 2700 width -= twidth; |
2693 } | 2701 } |
2694 } | 2702 } |
2695 #endif | 2703 #endif |
2696 | 2704 |
2697 #ifdef __cplusplus | 2705 #ifdef __cplusplus |
2698 } // extern "C" | 2706 } // extern "C" |
2699 } // namespace libyuv | 2707 } // namespace libyuv |
2700 #endif | 2708 #endif |
OLD | NEW |