| 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 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 #define UB -128 /* max(-128, round(-2.018 * 64)) */ | 1007 #define UB -128 /* max(-128, round(-2.018 * 64)) */ |
| 1008 #define UG 25 /* round(0.391 * 64) */ | 1008 #define UG 25 /* round(0.391 * 64) */ |
| 1009 #define VG 52 /* round(0.813 * 64) */ | 1009 #define VG 52 /* round(0.813 * 64) */ |
| 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 #if defined(__arm__) || defined(__aarch64__) | 1017 #if defined(__aarch64__) |
| 1018 YuvConstants SIMD_ALIGNED(kYuvConstants) = { |
| 1019 { -UB, 0, -UB, 0, -UB, 0, -UB, 0, -VR, 0, -VR, 0, -VR, 0, -VR, 0 }, |
| 1020 { UG, 0, UG, 0, UG, 0, UG, 0, VG, 0, VG, 0, VG, 0, VG, 0 }, |
| 1021 { BB, BG, BR, 0, 0, 0, 0, 0 }, |
| 1022 { 0x0101 * YG, 0, 0, 0 } |
| 1023 }; |
| 1024 |
| 1025 #elif defined(__arm__) |
| 1018 YuvConstants SIMD_ALIGNED(kYuvConstants) = { | 1026 YuvConstants SIMD_ALIGNED(kYuvConstants) = { |
| 1019 { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, | 1027 { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 1020 { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, | 1028 { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 1021 { BB, BG, BR, 0, 0, 0, 0, 0 }, | 1029 { BB, BG, BR, 0, 0, 0, 0, 0 }, |
| 1022 { 0x0101 * YG, 0, 0, 0 } | 1030 { 0x0101 * YG, 0, 0, 0 } |
| 1023 }; | 1031 }; |
| 1024 | |
| 1025 YuvConstants SIMD_ALIGNED(kYvuConstants) = { | |
| 1026 { -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 }, | |
| 1027 { VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 }, | |
| 1028 { BB, BG, BR, 0, 0, 0, 0, 0 }, | |
| 1029 { 0x0101 * YG, 0, 0, 0 } | |
| 1030 }; | |
| 1031 | |
| 1032 #else | 1032 #else |
| 1033 // BT601 constants for YUV to RGB. | 1033 // BT601 constants for YUV to RGB. |
| 1034 YuvConstants SIMD_ALIGNED(kYuvConstants) = { | 1034 YuvConstants SIMD_ALIGNED(kYuvConstants) = { |
| 1035 { UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, | 1035 { UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, |
| 1036 UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0 }, | 1036 UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0 }, |
| 1037 { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, | 1037 { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, |
| 1038 UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG }, | 1038 UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG }, |
| 1039 { 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, | 1039 { 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, |
| 1040 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR }, | 1040 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR }, |
| 1041 { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, | 1041 { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 #undef UB | 1074 #undef UB |
| 1075 #undef UG | 1075 #undef UG |
| 1076 #undef VG | 1076 #undef VG |
| 1077 #undef VR | 1077 #undef VR |
| 1078 #undef YG | 1078 #undef YG |
| 1079 | 1079 |
| 1080 // C reference code that mimics the YUV assembly. | 1080 // C reference code that mimics the YUV assembly. |
| 1081 static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, | 1081 static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, |
| 1082 uint8* b, uint8* g, uint8* r, | 1082 uint8* b, uint8* g, uint8* r, |
| 1083 struct YuvConstants* yuvconstants) { | 1083 struct YuvConstants* yuvconstants) { |
| 1084 #if defined(__arm__) || defined(__aarch64__) | 1084 #if defined(__aarch64__) |
| 1085 | |
| 1086 int UB = -yuvconstants->kUVToRB[0]; | 1085 int UB = -yuvconstants->kUVToRB[0]; |
| 1087 int VB = 0; | 1086 int UG = yuvconstants->kUVToG[0]; |
| 1087 int VG = yuvconstants->kUVToG[8]; |
| 1088 int VR = -yuvconstants->kUVToRB[8]; |
| 1089 int BB = yuvconstants->kUVBiasBGR[0]; |
| 1090 int BG = yuvconstants->kUVBiasBGR[1]; |
| 1091 int BR = yuvconstants->kUVBiasBGR[2]; |
| 1092 int YG = yuvconstants->kYToRgb[0]; |
| 1093 #elif defined(__arm__) |
| 1094 int UB = -yuvconstants->kUVToRB[0]; |
| 1088 int UG = yuvconstants->kUVToG[0]; | 1095 int UG = yuvconstants->kUVToG[0]; |
| 1089 int VG = yuvconstants->kUVToG[4]; | 1096 int VG = yuvconstants->kUVToG[4]; |
| 1090 int UR = 0; | |
| 1091 int VR = -yuvconstants->kUVToRB[4]; | 1097 int VR = -yuvconstants->kUVToRB[4]; |
| 1092 int BB = yuvconstants->kUVBiasBGR[0]; | 1098 int BB = yuvconstants->kUVBiasBGR[0]; |
| 1093 int BG = yuvconstants->kUVBiasBGR[1]; | 1099 int BG = yuvconstants->kUVBiasBGR[1]; |
| 1094 int BR = yuvconstants->kUVBiasBGR[2]; | 1100 int BR = yuvconstants->kUVBiasBGR[2]; |
| 1095 int YG = yuvconstants->kYToRgb[0]; | 1101 int YG = yuvconstants->kYToRgb[0]; |
| 1096 #else | 1102 #else |
| 1097 int UB = yuvconstants->kUVToB[0]; | 1103 int UB = yuvconstants->kUVToB[0]; |
| 1098 int VB = yuvconstants->kUVToB[1]; // usually 0 | |
| 1099 int UG = yuvconstants->kUVToG[0]; | 1104 int UG = yuvconstants->kUVToG[0]; |
| 1100 int VG = yuvconstants->kUVToG[1]; | 1105 int VG = yuvconstants->kUVToG[1]; |
| 1101 int UR = yuvconstants->kUVToR[0]; // usually 0 | |
| 1102 int VR = yuvconstants->kUVToR[1]; | 1106 int VR = yuvconstants->kUVToR[1]; |
| 1103 int BB = yuvconstants->kUVBiasB[0]; | 1107 int BB = yuvconstants->kUVBiasB[0]; |
| 1104 int BG = yuvconstants->kUVBiasG[0]; | 1108 int BG = yuvconstants->kUVBiasG[0]; |
| 1105 int BR = yuvconstants->kUVBiasR[0]; | 1109 int BR = yuvconstants->kUVBiasR[0]; |
| 1106 int YG = yuvconstants->kYToRgb[0]; | 1110 int YG = yuvconstants->kYToRgb[0]; |
| 1107 #endif | 1111 #endif |
| 1108 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; | 1112 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; |
| 1109 *b = Clamp((int32)(-(u * UB + v * VB) + y1 + BB) >> 6); | 1113 *b = Clamp((int32)(-(u * UB ) + y1 + BB) >> 6); |
| 1110 *g = Clamp((int32)(-(u * UG + v * VG) + y1 + BG) >> 6); | 1114 *g = Clamp((int32)(-(u * UG + v * VG) + y1 + BG) >> 6); |
| 1111 *r = Clamp((int32)(-(u * UR + v * VR) + y1 + BR) >> 6); | 1115 *r = Clamp((int32)(-( v * VR) + y1 + BR) >> 6); |
| 1112 } | 1116 } |
| 1113 | 1117 |
| 1114 // JPEG YUV to RGB reference | 1118 // JPEG YUV to RGB reference |
| 1115 // * R = Y - V * -1.40200 | 1119 // * R = Y - V * -1.40200 |
| 1116 // * G = Y - U * 0.34414 - V * 0.71414 | 1120 // * G = Y - U * 0.34414 - V * 0.71414 |
| 1117 // * B = Y - U * -1.77200 | 1121 // * B = Y - U * -1.77200 |
| 1118 | 1122 |
| 1119 // Y contribution to R,G,B. Scale and bias. | 1123 // Y contribution to R,G,B. Scale and bias. |
| 1120 #define YGJ 16320 /* round(1.000 * 64 * 256 * 256 / 257) */ | 1124 #define YGJ 16320 /* round(1.000 * 64 * 256 * 256 / 257) */ |
| 1121 #define YGBJ 32 /* 64 / 2 */ | 1125 #define YGBJ 32 /* 64 / 2 */ |
| (...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2684 dst_rgb565 += twidth * 2; | 2688 dst_rgb565 += twidth * 2; |
| 2685 width -= twidth; | 2689 width -= twidth; |
| 2686 } | 2690 } |
| 2687 } | 2691 } |
| 2688 #endif | 2692 #endif |
| 2689 | 2693 |
| 2690 #ifdef __cplusplus | 2694 #ifdef __cplusplus |
| 2691 } // extern "C" | 2695 } // extern "C" |
| 2692 } // namespace libyuv | 2696 } // namespace libyuv |
| 2693 #endif | 2697 #endif |
| OLD | NEW |