| 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 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 { 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, | 1045 { 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, |
| 1046 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR }, | 1046 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR }, |
| 1047 { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, | 1047 { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, |
| 1048 { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, | 1048 { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, |
| 1049 { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, | 1049 { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, |
| 1050 { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } | 1050 { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } |
| 1051 }; | 1051 }; |
| 1052 #endif | 1052 #endif |
| 1053 | 1053 |
| 1054 // C reference code that mimics the YUV assembly. | 1054 // C reference code that mimics the YUV assembly. |
| 1055 static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, |
| 1056 uint8* b, uint8* g, uint8* r, |
| 1057 const struct YuvConstants* yuvconstants) { |
| 1058 #if defined(__aarch64__) |
| 1059 int ub = -yuvconstants->kUVToRB[0]; |
| 1060 int ug = yuvconstants->kUVToG[0]; |
| 1061 int vg = yuvconstants->kUVToG[1]; |
| 1062 int vr = -yuvconstants->kUVToRB[1]; |
| 1063 int bb = yuvconstants->kUVBiasBGR[0]; |
| 1064 int bg = yuvconstants->kUVBiasBGR[1]; |
| 1065 int br = yuvconstants->kUVBiasBGR[2]; |
| 1066 int yg = yuvconstants->kYToRgb[0] / 0x0101; |
| 1067 #elif defined(__arm__) |
| 1068 int ub = -yuvconstants->kUVToRB[0]; |
| 1069 int ug = yuvconstants->kUVToG[0]; |
| 1070 int vg = yuvconstants->kUVToG[4]; |
| 1071 int vr = -yuvconstants->kUVToRB[4]; |
| 1072 int bb = yuvconstants->kUVBiasBGR[0]; |
| 1073 int bg = yuvconstants->kUVBiasBGR[1]; |
| 1074 int br = yuvconstants->kUVBiasBGR[2]; |
| 1075 int yg = yuvconstants->kYToRgb[0] / 0x0101; |
| 1076 #else |
| 1077 int ub = yuvconstants->kUVToB[0]; |
| 1078 int ug = yuvconstants->kUVToG[0]; |
| 1079 int vg = yuvconstants->kUVToG[1]; |
| 1080 int vr = yuvconstants->kUVToR[1]; |
| 1081 int bb = yuvconstants->kUVBiasB[0]; |
| 1082 int bg = yuvconstants->kUVBiasG[0]; |
| 1083 int br = yuvconstants->kUVBiasR[0]; |
| 1084 int yg = yuvconstants->kYToRgb[0]; |
| 1085 #endif |
| 1086 |
| 1087 uint32 y1 = (uint32)(y * 0x0101 * yg) >> 16; |
| 1088 *b = Clamp((int32)(-(u * ub ) + y1 + bb) >> 6); |
| 1089 *g = Clamp((int32)(-(u * ug + v * vg) + y1 + bg) >> 6); |
| 1090 *r = Clamp((int32)(-( v * vr) + y1 + br) >> 6); |
| 1091 } |
| 1092 |
| 1093 // C reference code that mimics the YUV assembly. |
| 1055 static __inline void YPixel(uint8 y, uint8* b, uint8* g, uint8* r) { | 1094 static __inline void YPixel(uint8 y, uint8* b, uint8* g, uint8* r) { |
| 1056 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; | 1095 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; |
| 1057 *b = Clamp((int32)(y1 + YGB) >> 6); | 1096 *b = Clamp((int32)(y1 + YGB) >> 6); |
| 1058 *g = Clamp((int32)(y1 + YGB) >> 6); | 1097 *g = Clamp((int32)(y1 + YGB) >> 6); |
| 1059 *r = Clamp((int32)(y1 + YGB) >> 6); | 1098 *r = Clamp((int32)(y1 + YGB) >> 6); |
| 1060 } | 1099 } |
| 1061 | 1100 |
| 1062 #undef BB | 1101 #undef BB |
| 1063 #undef BG | 1102 #undef BG |
| 1064 #undef BR | 1103 #undef BR |
| 1065 #undef YGB | 1104 #undef YGB |
| 1066 #undef UB | 1105 #undef UB |
| 1067 #undef UG | 1106 #undef UG |
| 1068 #undef VG | 1107 #undef VG |
| 1069 #undef VR | 1108 #undef VR |
| 1070 #undef YG | 1109 #undef YG |
| 1071 | 1110 |
| 1072 // C reference code that mimics the YUV assembly. | |
| 1073 static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, | |
| 1074 uint8* b, uint8* g, uint8* r, | |
| 1075 const struct YuvConstants* yuvconstants) { | |
| 1076 #if defined(__aarch64__) | |
| 1077 int UB = -yuvconstants->kUVToRB[0]; | |
| 1078 int UG = yuvconstants->kUVToG[0]; | |
| 1079 int VG = yuvconstants->kUVToG[1]; | |
| 1080 int VR = -yuvconstants->kUVToRB[1]; | |
| 1081 int BB = yuvconstants->kUVBiasBGR[0]; | |
| 1082 int BG = yuvconstants->kUVBiasBGR[1]; | |
| 1083 int BR = yuvconstants->kUVBiasBGR[2]; | |
| 1084 int YG = yuvconstants->kYToRgb[0]; | |
| 1085 #elif defined(__arm__) | |
| 1086 int UB = -yuvconstants->kUVToRB[0]; | |
| 1087 int UG = yuvconstants->kUVToG[0]; | |
| 1088 int VG = yuvconstants->kUVToG[4]; | |
| 1089 int VR = -yuvconstants->kUVToRB[4]; | |
| 1090 int BB = yuvconstants->kUVBiasBGR[0]; | |
| 1091 int BG = yuvconstants->kUVBiasBGR[1]; | |
| 1092 int BR = yuvconstants->kUVBiasBGR[2]; | |
| 1093 int YG = yuvconstants->kYToRgb[0]; | |
| 1094 #else | |
| 1095 int UB = yuvconstants->kUVToB[0]; | |
| 1096 int UG = yuvconstants->kUVToG[0]; | |
| 1097 int VG = yuvconstants->kUVToG[1]; | |
| 1098 int VR = yuvconstants->kUVToR[1]; | |
| 1099 int BB = yuvconstants->kUVBiasB[0]; | |
| 1100 int BG = yuvconstants->kUVBiasG[0]; | |
| 1101 int BR = yuvconstants->kUVBiasR[0]; | |
| 1102 int YG = yuvconstants->kYToRgb[0]; | |
| 1103 #endif | |
| 1104 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; | |
| 1105 *b = Clamp((int32)(-(u * UB ) + y1 + BB) >> 6); | |
| 1106 *g = Clamp((int32)(-(u * UG + v * VG) + y1 + BG) >> 6); | |
| 1107 *r = Clamp((int32)(-( v * VR) + y1 + BR) >> 6); | |
| 1108 } | |
| 1109 | |
| 1110 // JPEG YUV to RGB reference | 1111 // JPEG YUV to RGB reference |
| 1111 // * R = Y - V * -1.40200 | 1112 // * R = Y - V * -1.40200 |
| 1112 // * G = Y - U * 0.34414 - V * 0.71414 | 1113 // * G = Y - U * 0.34414 - V * 0.71414 |
| 1113 // * B = Y - U * -1.77200 | 1114 // * B = Y - U * -1.77200 |
| 1114 | 1115 |
| 1115 // Y contribution to R,G,B. Scale and bias. | 1116 // Y contribution to R,G,B. Scale and bias. |
| 1116 #define YGJ 16320 /* round(1.000 * 64 * 256 * 256 / 257) */ | 1117 #define YGJ 16320 /* round(1.000 * 64 * 256 * 256 / 257) */ |
| 1117 #define YGBJ 32 /* 64 / 2 */ | 1118 #define YGBJ 32 /* 64 / 2 */ |
| 1118 | 1119 |
| 1119 // U and V contributions to R,G,B. | 1120 // U and V contributions to R,G,B. |
| (...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2699 dst_rgb565 += twidth * 2; | 2700 dst_rgb565 += twidth * 2; |
| 2700 width -= twidth; | 2701 width -= twidth; |
| 2701 } | 2702 } |
| 2702 } | 2703 } |
| 2703 #endif | 2704 #endif |
| 2704 | 2705 |
| 2705 #ifdef __cplusplus | 2706 #ifdef __cplusplus |
| 2706 } // extern "C" | 2707 } // extern "C" |
| 2707 } // namespace libyuv | 2708 } // namespace libyuv |
| 2708 #endif | 2709 #endif |
| OLD | NEW |