| 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__) |
| 1018 YuvConstants SIMD_ALIGNED(kYuvConstants) = { |
| 1019 { -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 }, |
| 1021 { BB, BG, BR, 0, 0, 0, 0, 0 }, |
| 1022 { 0x0101 * YG, 0, 0, 0 } |
| 1023 }; |
| 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 |
| 1017 // BT601 constants for YUV to RGB. | 1033 // BT601 constants for YUV to RGB. |
| 1018 YuvConstants SIMD_ALIGNED(kYuvConstants) = { | 1034 YuvConstants SIMD_ALIGNED(kYuvConstants) = { |
| 1019 { 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, |
| 1020 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 }, |
| 1021 { 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, |
| 1022 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 }, |
| 1023 { 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, |
| 1024 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 }, |
| 1025 { 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 }, |
| 1026 { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, | 1042 { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, |
| 1027 { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, | 1043 { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, |
| 1028 { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } | 1044 { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } |
| 1029 }; | 1045 }; |
| 1030 | 1046 |
| 1031 // BT601 constants for NV21 where chroma plane is VU instead of UV. | 1047 // BT601 constants for NV21 where chroma plane is VU instead of UV. |
| 1032 YuvConstants SIMD_ALIGNED(kYvuConstants) = { | 1048 YuvConstants SIMD_ALIGNED(kYvuConstants) = { |
| 1033 { 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, | 1049 { 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, |
| 1034 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB }, | 1050 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB }, |
| 1035 { VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, | 1051 { VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, |
| 1036 VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG }, | 1052 VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG }, |
| 1037 { VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, | 1053 { VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, |
| 1038 VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0 }, | 1054 VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0 }, |
| 1039 { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, | 1055 { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, |
| 1040 { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, | 1056 { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, |
| 1041 { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, | 1057 { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, |
| 1042 { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } | 1058 { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } |
| 1043 }; | 1059 }; |
| 1044 | 1060 #endif |
| 1045 YuvConstantsNEON SIMD_ALIGNED(kYuvConstantsNEON) = { | |
| 1046 { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, | |
| 1047 { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, | |
| 1048 { BB, BG, BR, 0, 0, 0, 0, 0 }, | |
| 1049 { 0x0101 * YG, 0, 0, 0 } | |
| 1050 }; | |
| 1051 | |
| 1052 // C reference code that mimics the YUV assembly. | |
| 1053 static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, | |
| 1054 uint8* b, uint8* g, uint8* r) { | |
| 1055 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; | |
| 1056 *b = Clamp((int32)(-(u * UB) + y1 + BB) >> 6); | |
| 1057 *g = Clamp((int32)(-(v * VG + u * UG) + y1 + BG) >> 6); | |
| 1058 *r = Clamp((int32)(-(v * VR)+ y1 + BR) >> 6); | |
| 1059 } | |
| 1060 | 1061 |
| 1061 // C reference code that mimics the YUV assembly. | 1062 // C reference code that mimics the YUV assembly. |
| 1062 static __inline void YPixel(uint8 y, uint8* b, uint8* g, uint8* r) { | 1063 static __inline void YPixel(uint8 y, uint8* b, uint8* g, uint8* r) { |
| 1063 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; | 1064 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; |
| 1064 *b = Clamp((int32)(y1 + YGB) >> 6); | 1065 *b = Clamp((int32)(y1 + YGB) >> 6); |
| 1065 *g = Clamp((int32)(y1 + YGB) >> 6); | 1066 *g = Clamp((int32)(y1 + YGB) >> 6); |
| 1066 *r = Clamp((int32)(y1 + YGB) >> 6); | 1067 *r = Clamp((int32)(y1 + YGB) >> 6); |
| 1067 } | 1068 } |
| 1068 #undef YG | 1069 |
| 1070 #undef BB |
| 1071 #undef BG |
| 1072 #undef BR |
| 1069 #undef YGB | 1073 #undef YGB |
| 1070 #undef UB | 1074 #undef UB |
| 1071 #undef UG | 1075 #undef UG |
| 1072 #undef VG | 1076 #undef VG |
| 1073 #undef VR | 1077 #undef VR |
| 1074 #undef BB | 1078 #undef YG |
| 1075 #undef BG | 1079 |
| 1076 #undef BR | 1080 // C reference code that mimics the YUV assembly. |
| 1081 static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, |
| 1082 uint8* b, uint8* g, uint8* r, |
| 1083 struct YuvConstants* yuvconstants) { |
| 1084 #if defined(__arm__) || defined(__aarch64__) |
| 1085 |
| 1086 int UB = -yuvconstants->kUVToRB[0]; |
| 1087 int VB = 0; |
| 1088 int UG = yuvconstants->kUVToG[0]; |
| 1089 int VG = yuvconstants->kUVToG[4]; |
| 1090 int UR = 0; |
| 1091 int VR = -yuvconstants->kUVToRB[4]; |
| 1092 int BB = yuvconstants->kUVBiasBGR[0]; |
| 1093 int BG = yuvconstants->kUVBiasBGR[1]; |
| 1094 int BR = yuvconstants->kUVBiasBGR[2]; |
| 1095 int YG = yuvconstants->kYToRgb[0]; |
| 1096 #else |
| 1097 int UB = yuvconstants->kUVToB[0]; |
| 1098 int VB = yuvconstants->kUVToB[1]; // usually 0 |
| 1099 int UG = yuvconstants->kUVToG[0]; |
| 1100 int VG = yuvconstants->kUVToG[1]; |
| 1101 int UR = yuvconstants->kUVToR[0]; // usually 0 |
| 1102 int VR = yuvconstants->kUVToR[1]; |
| 1103 int BB = yuvconstants->kUVBiasB[0]; |
| 1104 int BG = yuvconstants->kUVBiasG[0]; |
| 1105 int BR = yuvconstants->kUVBiasR[0]; |
| 1106 int YG = yuvconstants->kYToRgb[0]; |
| 1107 #endif |
| 1108 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; |
| 1109 *b = Clamp((int32)(-(u * UB + v * VB) + y1 + BB) >> 6); |
| 1110 *g = Clamp((int32)(-(u * UG + v * VG) + y1 + BG) >> 6); |
| 1111 *r = Clamp((int32)(-(u * UR + v * VR) + y1 + BR) >> 6); |
| 1112 } |
| 1077 | 1113 |
| 1078 // JPEG YUV to RGB reference | 1114 // JPEG YUV to RGB reference |
| 1079 // * R = Y - V * -1.40200 | 1115 // * R = Y - V * -1.40200 |
| 1080 // * G = Y - U * 0.34414 - V * 0.71414 | 1116 // * G = Y - U * 0.34414 - V * 0.71414 |
| 1081 // * B = Y - U * -1.77200 | 1117 // * B = Y - U * -1.77200 |
| 1082 | 1118 |
| 1083 // Y contribution to R,G,B. Scale and bias. | 1119 // Y contribution to R,G,B. Scale and bias. |
| 1084 #define YGJ 16320 /* round(1.000 * 64 * 256 * 256 / 257) */ | 1120 #define YGJ 16320 /* round(1.000 * 64 * 256 * 256 / 257) */ |
| 1085 #define YGBJ 32 /* 64 / 2 */ | 1121 #define YGBJ 32 /* 64 / 2 */ |
| 1086 | 1122 |
| 1087 // U and V contributions to R,G,B. | 1123 // U and V contributions to R,G,B. |
| 1088 #define UBJ -113 /* round(-1.77200 * 64) */ | 1124 #define UBJ -113 /* round(-1.77200 * 64) */ |
| 1089 #define UGJ 22 /* round(0.34414 * 64) */ | 1125 #define UGJ 22 /* round(0.34414 * 64) */ |
| 1090 #define VGJ 46 /* round(0.71414 * 64) */ | 1126 #define VGJ 46 /* round(0.71414 * 64) */ |
| 1091 #define VRJ -90 /* round(-1.40200 * 64) */ | 1127 #define VRJ -90 /* round(-1.40200 * 64) */ |
| 1092 | 1128 |
| 1093 // Bias values to round, and subtract 128 from U and V. | 1129 // Bias values to round, and subtract 128 from U and V. |
| 1094 #define BBJ (UBJ * 128 + YGBJ) | 1130 #define BBJ (UBJ * 128 + YGBJ) |
| 1095 #define BGJ (UGJ * 128 + VGJ * 128 + YGBJ) | 1131 #define BGJ (UGJ * 128 + VGJ * 128 + YGBJ) |
| 1096 #define BRJ (VRJ * 128 + YGBJ) | 1132 #define BRJ (VRJ * 128 + YGBJ) |
| 1097 | 1133 |
| 1134 #if defined(__arm__) || defined(__aarch64__) |
| 1135 // JPEG constants for YUV to RGB. |
| 1136 YuvConstants SIMD_ALIGNED(kYuvJConstants) = { |
| 1137 { -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 }, |
| 1139 { BBJ, BGJ, BRJ, 0, 0, 0, 0, 0 }, |
| 1140 { 0x0101 * YGJ, 0, 0, 0 } |
| 1141 }; |
| 1142 #else |
| 1098 // JPEG constants for YUV to RGB. | 1143 // JPEG constants for YUV to RGB. |
| 1099 YuvConstants SIMD_ALIGNED(kYuvJConstants) = { | 1144 YuvConstants SIMD_ALIGNED(kYuvJConstants) = { |
| 1100 { UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, | 1145 { UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, |
| 1101 UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0 }, | 1146 UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0, UBJ, 0 }, |
| 1102 { UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, | 1147 { UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, |
| 1103 UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, | 1148 UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, |
| 1104 UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, | 1149 UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, |
| 1105 UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ }, | 1150 UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ }, |
| 1106 { 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, | 1151 { 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, |
| 1107 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ }, | 1152 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ, 0, VRJ }, |
| 1108 { BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, | 1153 { BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, |
| 1109 BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ }, | 1154 BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ, BBJ }, |
| 1110 { BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, | 1155 { BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, |
| 1111 BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ }, | 1156 BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ, BGJ }, |
| 1112 { BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, | 1157 { BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, |
| 1113 BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ }, | 1158 BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ, BRJ }, |
| 1114 { YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, | 1159 { YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, |
| 1115 YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ } | 1160 YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ, YGJ } |
| 1116 }; | 1161 }; |
| 1117 | 1162 #endif |
| 1118 // JPEG constants for YUV to RGB. | |
| 1119 YuvConstantsNEON SIMD_ALIGNED(kYuvJConstantsNEON) = { | |
| 1120 { -UBJ, -UBJ, -UBJ, -UBJ, -VRJ, -VRJ, -VRJ, -VRJ, 0, 0, 0, 0, 0, 0, 0, 0 }, | |
| 1121 { UGJ, UGJ, UGJ, UGJ, VGJ, VGJ, VGJ, VGJ, 0, 0, 0, 0, 0, 0, 0, 0 }, | |
| 1122 { BBJ, BGJ, BRJ, 0, 0, 0, 0, 0 }, | |
| 1123 { 0x0101 * YGJ, 0, 0, 0 } | |
| 1124 }; | |
| 1125 | |
| 1126 // C reference code that mimics the YUV assembly. | |
| 1127 static __inline void YuvJPixel(uint8 y, uint8 u, uint8 v, | |
| 1128 uint8* b, uint8* g, uint8* r) { | |
| 1129 uint32 y1 = (uint32)(y * 0x0101 * YGJ) >> 16; | |
| 1130 *b = Clamp((int32)(-(u * UBJ) + y1 + BBJ) >> 6); | |
| 1131 *g = Clamp((int32)(-(v * VGJ + u * UGJ) + y1 + BGJ) >> 6); | |
| 1132 *r = Clamp((int32)(-(v * VRJ) + y1 + BRJ) >> 6); | |
| 1133 } | |
| 1134 | 1163 |
| 1135 #undef YGJ | 1164 #undef YGJ |
| 1136 #undef YGBJ | 1165 #undef YGBJ |
| 1137 #undef UBJ | 1166 #undef UBJ |
| 1138 #undef UGJ | 1167 #undef UGJ |
| 1139 #undef VGJ | 1168 #undef VGJ |
| 1140 #undef VRJ | 1169 #undef VRJ |
| 1141 #undef BBJ | 1170 #undef BBJ |
| 1142 #undef BGJ | 1171 #undef BGJ |
| 1143 #undef BRJ | 1172 #undef BRJ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1155 #define UBH -128 /* max(-128, round(-2.12798 * 64)) */ | 1184 #define UBH -128 /* max(-128, round(-2.12798 * 64)) */ |
| 1156 #define UGH 14 /* round(0.21482 * 64) */ | 1185 #define UGH 14 /* round(0.21482 * 64) */ |
| 1157 #define VGH 24 /* round(0.38059 * 64) */ | 1186 #define VGH 24 /* round(0.38059 * 64) */ |
| 1158 #define VRH -82 /* round(-1.28033 * 64) */ | 1187 #define VRH -82 /* round(-1.28033 * 64) */ |
| 1159 | 1188 |
| 1160 // Bias values to round, and subtract 128 from U and V. | 1189 // Bias values to round, and subtract 128 from U and V. |
| 1161 #define BBH (UBH * 128 + YGBH) | 1190 #define BBH (UBH * 128 + YGBH) |
| 1162 #define BGH (UGH * 128 + VGH * 128 + YGBH) | 1191 #define BGH (UGH * 128 + VGH * 128 + YGBH) |
| 1163 #define BRH (VRH * 128 + YGBH) | 1192 #define BRH (VRH * 128 + YGBH) |
| 1164 | 1193 |
| 1194 #if defined(__arm__) || defined(__aarch64__) |
| 1195 // BT.709 constants for YUV to RGB. |
| 1196 YuvConstants SIMD_ALIGNED(kYuvHConstants) = { |
| 1197 { -UBH, -UBH, -UBH, -UBH, -VRH, -VRH, -VRH, -VRH, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 1198 { UGH, UGH, UGH, UGH, VGH, VGH, VGH, VGH, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 1199 { BBH, BGH, BRH, 0, 0, 0, 0, 0 }, |
| 1200 { 0x0101 * YGH, 0, 0, 0 } |
| 1201 }; |
| 1202 #else |
| 1165 // BT.709 constants for YUV to RGB. | 1203 // BT.709 constants for YUV to RGB. |
| 1166 YuvConstants SIMD_ALIGNED(kYuvHConstants) = { | 1204 YuvConstants SIMD_ALIGNED(kYuvHConstants) = { |
| 1167 { UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, | 1205 { UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, |
| 1168 UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0 }, | 1206 UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0, UBH, 0 }, |
| 1169 { UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH, | 1207 { UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH, |
| 1170 UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH, | 1208 UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH, |
| 1171 UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH, | 1209 UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH, |
| 1172 UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH }, | 1210 UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH }, |
| 1173 { 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, | 1211 { 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, |
| 1174 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH }, | 1212 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH, 0, VRH }, |
| 1175 { BBH, BBH, BBH, BBH, BBH, BBH, BBH, BBH, | 1213 { BBH, BBH, BBH, BBH, BBH, BBH, BBH, BBH, |
| 1176 BBH, BBH, BBH, BBH, BBH, BBH, BBH, BBH }, | 1214 BBH, BBH, BBH, BBH, BBH, BBH, BBH, BBH }, |
| 1177 { BGH, BGH, BGH, BGH, BGH, BGH, BGH, BGH, | 1215 { BGH, BGH, BGH, BGH, BGH, BGH, BGH, BGH, |
| 1178 BGH, BGH, BGH, BGH, BGH, BGH, BGH, BGH }, | 1216 BGH, BGH, BGH, BGH, BGH, BGH, BGH, BGH }, |
| 1179 { BRH, BRH, BRH, BRH, BRH, BRH, BRH, BRH, | 1217 { BRH, BRH, BRH, BRH, BRH, BRH, BRH, BRH, |
| 1180 BRH, BRH, BRH, BRH, BRH, BRH, BRH, BRH }, | 1218 BRH, BRH, BRH, BRH, BRH, BRH, BRH, BRH }, |
| 1181 { YGH, YGH, YGH, YGH, YGH, YGH, YGH, YGH, | 1219 { YGH, YGH, YGH, YGH, YGH, YGH, YGH, YGH, |
| 1182 YGH, YGH, YGH, YGH, YGH, YGH, YGH, YGH } | 1220 YGH, YGH, YGH, YGH, YGH, YGH, YGH, YGH } |
| 1183 }; | 1221 }; |
| 1184 | 1222 #endif |
| 1185 // BT.709 constants for YUV to RGB. | |
| 1186 YuvConstantsNEON SIMD_ALIGNED(kYuvHConstantsNEON) = { | |
| 1187 { -UBH, -UBH, -UBH, -UBH, -VRH, -VRH, -VRH, -VRH, 0, 0, 0, 0, 0, 0, 0, 0 }, | |
| 1188 { UGH, UGH, UGH, UGH, VGH, VGH, VGH, VGH, 0, 0, 0, 0, 0, 0, 0, 0 }, | |
| 1189 { BBH, BGH, BRH, 0, 0, 0, 0, 0 }, | |
| 1190 { 0x0101 * YGH, 0, 0, 0 } | |
| 1191 }; | |
| 1192 | |
| 1193 // C reference code that mimics the YUV assembly. | |
| 1194 static __inline void YuvHPixel(uint8 y, uint8 u, uint8 v, | |
| 1195 uint8* b, uint8* g, uint8* r) { | |
| 1196 uint32 y1 = (uint32)(y * 0x0101 * YGH) >> 16; | |
| 1197 *b = Clamp((int32)(-(u * UBH) + y1 + BBH) >> 6); | |
| 1198 *g = Clamp((int32)(-(v * VGH + u * UGH) + y1 + BGH) >> 6); | |
| 1199 *r = Clamp((int32)(-(v * VRH) + y1 + BRH) >> 6); | |
| 1200 } | |
| 1201 | 1223 |
| 1202 #undef YGH | 1224 #undef YGH |
| 1203 #undef YGBH | 1225 #undef YGBH |
| 1204 #undef UBH | 1226 #undef UBH |
| 1205 #undef UGH | 1227 #undef UGH |
| 1206 #undef VGH | 1228 #undef VGH |
| 1207 #undef VRH | 1229 #undef VRH |
| 1208 #undef BBH | 1230 #undef BBH |
| 1209 #undef BGH | 1231 #undef BGH |
| 1210 #undef BRH | 1232 #undef BRH |
| 1211 | 1233 |
| 1212 #if !defined(LIBYUV_DISABLE_NEON) && \ | 1234 #if !defined(LIBYUV_DISABLE_NEON) && \ |
| 1213 (defined(__ARM_NEON__) || defined(__aarch64__) || defined(LIBYUV_NEON)) | 1235 (defined(__ARM_NEON__) || defined(__aarch64__) || defined(LIBYUV_NEON)) |
| 1214 // C mimic assembly. | 1236 // C mimic assembly. |
| 1215 // TODO(fbarchard): Remove subsampling from Neon. | 1237 // TODO(fbarchard): Remove subsampling from Neon. |
| 1216 void I444ToARGBRow_C(const uint8* src_y, | 1238 void I444ToARGBRow_C(const uint8* src_y, |
| 1217 const uint8* src_u, | 1239 const uint8* src_u, |
| 1218 const uint8* src_v, | 1240 const uint8* src_v, |
| 1219 uint8* rgb_buf, | 1241 uint8* rgb_buf, |
| 1242 struct YuvConstants* yuvconstants, |
| 1220 int width) { | 1243 int width) { |
| 1221 int x; | 1244 int x; |
| 1222 for (x = 0; x < width - 1; x += 2) { | 1245 for (x = 0; x < width - 1; x += 2) { |
| 1223 uint8 u = (src_u[0] + src_u[1] + 1) >> 1; | 1246 uint8 u = (src_u[0] + src_u[1] + 1) >> 1; |
| 1224 uint8 v = (src_v[0] + src_v[1] + 1) >> 1; | 1247 uint8 v = (src_v[0] + src_v[1] + 1) >> 1; |
| 1225 YuvPixel(src_y[0], u, v, rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1248 YuvPixel(src_y[0], u, v, rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, |
| 1249 yuvconstants); |
| 1226 rgb_buf[3] = 255; | 1250 rgb_buf[3] = 255; |
| 1227 YuvPixel(src_y[1], u, v, rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | 1251 YuvPixel(src_y[1], u, v, rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, |
| 1252 yuvconstants); |
| 1228 rgb_buf[7] = 255; | 1253 rgb_buf[7] = 255; |
| 1229 src_y += 2; | 1254 src_y += 2; |
| 1230 src_u += 2; | 1255 src_u += 2; |
| 1231 src_v += 2; | 1256 src_v += 2; |
| 1232 rgb_buf += 8; // Advance 2 pixels. | 1257 rgb_buf += 8; // Advance 2 pixels. |
| 1233 } | 1258 } |
| 1234 if (width & 1) { | 1259 if (width & 1) { |
| 1235 YuvPixel(src_y[0], src_u[0], src_v[0], | 1260 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1236 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1261 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1237 } | 1262 } |
| 1238 } | 1263 } |
| 1239 | 1264 |
| 1240 void I444ToABGRRow_C(const uint8* src_y, | 1265 void I444ToABGRRow_C(const uint8* src_y, |
| 1241 const uint8* src_u, | 1266 const uint8* src_u, |
| 1242 const uint8* src_v, | 1267 const uint8* src_v, |
| 1243 uint8* rgb_buf, | 1268 uint8* rgb_buf, |
| 1269 struct YuvConstants* yuvconstants, |
| 1244 int width) { | 1270 int width) { |
| 1245 int x; | 1271 int x; |
| 1246 for (x = 0; x < width - 1; x += 2) { | 1272 for (x = 0; x < width - 1; x += 2) { |
| 1247 uint8 u = (src_u[0] + src_u[1] + 1) >> 1; | 1273 uint8 u = (src_u[0] + src_u[1] + 1) >> 1; |
| 1248 uint8 v = (src_v[0] + src_v[1] + 1) >> 1; | 1274 uint8 v = (src_v[0] + src_v[1] + 1) >> 1; |
| 1249 YuvPixel(src_y[0], u, v, rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | 1275 YuvPixel(src_y[0], u, v, rgb_buf + 2, rgb_buf + 1, rgb_buf + 0, |
| 1276 yuvconstants); |
| 1250 rgb_buf[3] = 255; | 1277 rgb_buf[3] = 255; |
| 1251 YuvPixel(src_y[1], u, v, rgb_buf + 6, rgb_buf + 5, rgb_buf + 4); | 1278 YuvPixel(src_y[1], u, v, rgb_buf + 6, rgb_buf + 5, rgb_buf + 4, |
| 1279 yuvconstants); |
| 1252 rgb_buf[7] = 255; | 1280 rgb_buf[7] = 255; |
| 1253 src_y += 2; | 1281 src_y += 2; |
| 1254 src_u += 2; | 1282 src_u += 2; |
| 1255 src_v += 2; | 1283 src_v += 2; |
| 1256 rgb_buf += 8; // Advance 2 pixels. | 1284 rgb_buf += 8; // Advance 2 pixels. |
| 1257 } | 1285 } |
| 1258 if (width & 1) { | 1286 if (width & 1) { |
| 1259 YuvPixel(src_y[0], src_u[0], src_v[0], | 1287 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1260 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | 1288 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0, yuvconstants); |
| 1261 } | 1289 } |
| 1262 } | 1290 } |
| 1263 #else | 1291 #else |
| 1264 void I444ToARGBRow_C(const uint8* src_y, | 1292 void I444ToARGBRow_C(const uint8* src_y, |
| 1265 const uint8* src_u, | 1293 const uint8* src_u, |
| 1266 const uint8* src_v, | 1294 const uint8* src_v, |
| 1267 uint8* rgb_buf, | 1295 uint8* rgb_buf, |
| 1296 struct YuvConstants* yuvconstants, |
| 1268 int width) { | 1297 int width) { |
| 1269 int x; | 1298 int x; |
| 1270 for (x = 0; x < width; ++x) { | 1299 for (x = 0; x < width; ++x) { |
| 1271 YuvPixel(src_y[0], src_u[0], src_v[0], | 1300 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1272 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1301 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1273 rgb_buf[3] = 255; | 1302 rgb_buf[3] = 255; |
| 1274 src_y += 1; | 1303 src_y += 1; |
| 1275 src_u += 1; | 1304 src_u += 1; |
| 1276 src_v += 1; | 1305 src_v += 1; |
| 1277 rgb_buf += 4; // Advance 1 pixel. | 1306 rgb_buf += 4; // Advance 1 pixel. |
| 1278 } | 1307 } |
| 1279 } | 1308 } |
| 1280 | 1309 |
| 1281 void I444ToABGRRow_C(const uint8* src_y, | 1310 void I444ToABGRRow_C(const uint8* src_y, |
| 1282 const uint8* src_u, | 1311 const uint8* src_u, |
| 1283 const uint8* src_v, | 1312 const uint8* src_v, |
| 1284 uint8* rgb_buf, | 1313 uint8* rgb_buf, |
| 1314 struct YuvConstants* yuvconstants, |
| 1285 int width) { | 1315 int width) { |
| 1286 int x; | 1316 int x; |
| 1287 for (x = 0; x < width; ++x) { | 1317 for (x = 0; x < width; ++x) { |
| 1288 YuvPixel(src_y[0], src_u[0], src_v[0], | 1318 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1289 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | 1319 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0, yuvconstants); |
| 1290 rgb_buf[3] = 255; | 1320 rgb_buf[3] = 255; |
| 1291 src_y += 1; | 1321 src_y += 1; |
| 1292 src_u += 1; | 1322 src_u += 1; |
| 1293 src_v += 1; | 1323 src_v += 1; |
| 1294 rgb_buf += 4; // Advance 1 pixel. | 1324 rgb_buf += 4; // Advance 1 pixel. |
| 1295 } | 1325 } |
| 1296 } | 1326 } |
| 1297 #endif | 1327 #endif |
| 1298 | 1328 |
| 1299 // Also used for 420 | 1329 // Also used for 420 |
| 1300 void I422ToARGBRow_C(const uint8* src_y, | 1330 void I422ToARGBRow_C(const uint8* src_y, |
| 1301 const uint8* src_u, | 1331 const uint8* src_u, |
| 1302 const uint8* src_v, | 1332 const uint8* src_v, |
| 1303 uint8* rgb_buf, | 1333 uint8* rgb_buf, |
| 1334 struct YuvConstants* yuvconstants, |
| 1304 int width) { | 1335 int width) { |
| 1305 int x; | 1336 int x; |
| 1306 for (x = 0; x < width - 1; x += 2) { | 1337 for (x = 0; x < width - 1; x += 2) { |
| 1307 YuvPixel(src_y[0], src_u[0], src_v[0], | 1338 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1308 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1339 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1309 rgb_buf[3] = 255; | 1340 rgb_buf[3] = 255; |
| 1310 YuvPixel(src_y[1], src_u[0], src_v[0], | 1341 YuvPixel(src_y[1], src_u[0], src_v[0], |
| 1311 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | 1342 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); |
| 1312 rgb_buf[7] = 255; | 1343 rgb_buf[7] = 255; |
| 1313 src_y += 2; | 1344 src_y += 2; |
| 1314 src_u += 1; | 1345 src_u += 1; |
| 1315 src_v += 1; | 1346 src_v += 1; |
| 1316 rgb_buf += 8; // Advance 2 pixels. | 1347 rgb_buf += 8; // Advance 2 pixels. |
| 1317 } | 1348 } |
| 1318 if (width & 1) { | 1349 if (width & 1) { |
| 1319 YuvPixel(src_y[0], src_u[0], src_v[0], | 1350 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1320 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1351 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1321 rgb_buf[3] = 255; | 1352 rgb_buf[3] = 255; |
| 1322 } | 1353 } |
| 1323 } | 1354 } |
| 1324 | 1355 |
| 1325 void J422ToARGBRow_C(const uint8* src_y, | |
| 1326 const uint8* src_u, | |
| 1327 const uint8* src_v, | |
| 1328 uint8* rgb_buf, | |
| 1329 int width) { | |
| 1330 int x; | |
| 1331 for (x = 0; x < width - 1; x += 2) { | |
| 1332 YuvJPixel(src_y[0], src_u[0], src_v[0], | |
| 1333 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | |
| 1334 rgb_buf[3] = 255; | |
| 1335 YuvJPixel(src_y[1], src_u[0], src_v[0], | |
| 1336 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | |
| 1337 rgb_buf[7] = 255; | |
| 1338 src_y += 2; | |
| 1339 src_u += 1; | |
| 1340 src_v += 1; | |
| 1341 rgb_buf += 8; // Advance 2 pixels. | |
| 1342 } | |
| 1343 if (width & 1) { | |
| 1344 YuvJPixel(src_y[0], src_u[0], src_v[0], | |
| 1345 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | |
| 1346 rgb_buf[3] = 255; | |
| 1347 } | |
| 1348 } | |
| 1349 | |
| 1350 void J422ToABGRRow_C(const uint8* src_y, | |
| 1351 const uint8* src_u, | |
| 1352 const uint8* src_v, | |
| 1353 uint8* rgb_buf, | |
| 1354 int width) { | |
| 1355 int x; | |
| 1356 for (x = 0; x < width - 1; x += 2) { | |
| 1357 YuvJPixel(src_y[0], src_u[0], src_v[0], | |
| 1358 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | |
| 1359 rgb_buf[3] = 255; | |
| 1360 YuvJPixel(src_y[1], src_u[0], src_v[0], | |
| 1361 rgb_buf + 6, rgb_buf + 5, rgb_buf + 4); | |
| 1362 rgb_buf[7] = 255; | |
| 1363 src_y += 2; | |
| 1364 src_u += 1; | |
| 1365 src_v += 1; | |
| 1366 rgb_buf += 8; // Advance 2 pixels. | |
| 1367 } | |
| 1368 if (width & 1) { | |
| 1369 YuvJPixel(src_y[0], src_u[0], src_v[0], | |
| 1370 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | |
| 1371 rgb_buf[3] = 255; | |
| 1372 } | |
| 1373 } | |
| 1374 | |
| 1375 // TODO(fbarchard): replace with common matrix function. | |
| 1376 void H422ToARGBRow_C(const uint8* src_y, | |
| 1377 const uint8* src_u, | |
| 1378 const uint8* src_v, | |
| 1379 uint8* rgb_buf, | |
| 1380 int width) { | |
| 1381 int x; | |
| 1382 for (x = 0; x < width - 1; x += 2) { | |
| 1383 YuvHPixel(src_y[0], src_u[0], src_v[0], | |
| 1384 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | |
| 1385 rgb_buf[3] = 255; | |
| 1386 YuvHPixel(src_y[1], src_u[0], src_v[0], | |
| 1387 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | |
| 1388 rgb_buf[7] = 255; | |
| 1389 src_y += 2; | |
| 1390 src_u += 1; | |
| 1391 src_v += 1; | |
| 1392 rgb_buf += 8; // Advance 2 pixels. | |
| 1393 } | |
| 1394 if (width & 1) { | |
| 1395 YuvHPixel(src_y[0], src_u[0], src_v[0], | |
| 1396 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | |
| 1397 rgb_buf[3] = 255; | |
| 1398 } | |
| 1399 } | |
| 1400 | |
| 1401 void H422ToABGRRow_C(const uint8* src_y, | |
| 1402 const uint8* src_u, | |
| 1403 const uint8* src_v, | |
| 1404 uint8* rgb_buf, | |
| 1405 int width) { | |
| 1406 int x; | |
| 1407 for (x = 0; x < width - 1; x += 2) { | |
| 1408 YuvHPixel(src_y[0], src_u[0], src_v[0], | |
| 1409 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | |
| 1410 rgb_buf[3] = 255; | |
| 1411 YuvHPixel(src_y[1], src_u[0], src_v[0], | |
| 1412 rgb_buf + 6, rgb_buf + 5, rgb_buf + 4); | |
| 1413 rgb_buf[7] = 255; | |
| 1414 src_y += 2; | |
| 1415 src_u += 1; | |
| 1416 src_v += 1; | |
| 1417 rgb_buf += 8; // Advance 2 pixels. | |
| 1418 } | |
| 1419 if (width & 1) { | |
| 1420 YuvHPixel(src_y[0], src_u[0], src_v[0], | |
| 1421 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | |
| 1422 rgb_buf[3] = 255; | |
| 1423 } | |
| 1424 } | |
| 1425 | |
| 1426 | |
| 1427 void I422ToRGB24Row_C(const uint8* src_y, | 1356 void I422ToRGB24Row_C(const uint8* src_y, |
| 1428 const uint8* src_u, | 1357 const uint8* src_u, |
| 1429 const uint8* src_v, | 1358 const uint8* src_v, |
| 1430 uint8* rgb_buf, | 1359 uint8* rgb_buf, |
| 1360 struct YuvConstants* yuvconstants, |
| 1431 int width) { | 1361 int width) { |
| 1432 int x; | 1362 int x; |
| 1433 for (x = 0; x < width - 1; x += 2) { | 1363 for (x = 0; x < width - 1; x += 2) { |
| 1434 YuvPixel(src_y[0], src_u[0], src_v[0], | 1364 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1435 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1365 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1436 YuvPixel(src_y[1], src_u[0], src_v[0], | 1366 YuvPixel(src_y[1], src_u[0], src_v[0], |
| 1437 rgb_buf + 3, rgb_buf + 4, rgb_buf + 5); | 1367 rgb_buf + 3, rgb_buf + 4, rgb_buf + 5, yuvconstants); |
| 1438 src_y += 2; | 1368 src_y += 2; |
| 1439 src_u += 1; | 1369 src_u += 1; |
| 1440 src_v += 1; | 1370 src_v += 1; |
| 1441 rgb_buf += 6; // Advance 2 pixels. | 1371 rgb_buf += 6; // Advance 2 pixels. |
| 1442 } | 1372 } |
| 1443 if (width & 1) { | 1373 if (width & 1) { |
| 1444 YuvPixel(src_y[0], src_u[0], src_v[0], | 1374 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1445 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1375 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1446 } | 1376 } |
| 1447 } | 1377 } |
| 1448 | 1378 |
| 1449 void I422ToRAWRow_C(const uint8* src_y, | 1379 void I422ToRAWRow_C(const uint8* src_y, |
| 1450 const uint8* src_u, | 1380 const uint8* src_u, |
| 1451 const uint8* src_v, | 1381 const uint8* src_v, |
| 1452 uint8* rgb_buf, | 1382 uint8* rgb_buf, |
| 1383 struct YuvConstants* yuvconstants, |
| 1453 int width) { | 1384 int width) { |
| 1454 int x; | 1385 int x; |
| 1455 for (x = 0; x < width - 1; x += 2) { | 1386 for (x = 0; x < width - 1; x += 2) { |
| 1456 YuvPixel(src_y[0], src_u[0], src_v[0], | 1387 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1457 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | 1388 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0, yuvconstants); |
| 1458 YuvPixel(src_y[1], src_u[0], src_v[0], | 1389 YuvPixel(src_y[1], src_u[0], src_v[0], |
| 1459 rgb_buf + 5, rgb_buf + 4, rgb_buf + 3); | 1390 rgb_buf + 5, rgb_buf + 4, rgb_buf + 3, yuvconstants); |
| 1460 src_y += 2; | 1391 src_y += 2; |
| 1461 src_u += 1; | 1392 src_u += 1; |
| 1462 src_v += 1; | 1393 src_v += 1; |
| 1463 rgb_buf += 6; // Advance 2 pixels. | 1394 rgb_buf += 6; // Advance 2 pixels. |
| 1464 } | 1395 } |
| 1465 if (width & 1) { | 1396 if (width & 1) { |
| 1466 YuvPixel(src_y[0], src_u[0], src_v[0], | 1397 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1467 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | 1398 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0, yuvconstants); |
| 1468 } | 1399 } |
| 1469 } | 1400 } |
| 1470 | 1401 |
| 1471 void I422ToARGB4444Row_C(const uint8* src_y, | 1402 void I422ToARGB4444Row_C(const uint8* src_y, |
| 1472 const uint8* src_u, | 1403 const uint8* src_u, |
| 1473 const uint8* src_v, | 1404 const uint8* src_v, |
| 1474 uint8* dst_argb4444, | 1405 uint8* dst_argb4444, |
| 1406 struct YuvConstants* yuvconstants, |
| 1475 int width) { | 1407 int width) { |
| 1476 uint8 b0; | 1408 uint8 b0; |
| 1477 uint8 g0; | 1409 uint8 g0; |
| 1478 uint8 r0; | 1410 uint8 r0; |
| 1479 uint8 b1; | 1411 uint8 b1; |
| 1480 uint8 g1; | 1412 uint8 g1; |
| 1481 uint8 r1; | 1413 uint8 r1; |
| 1482 int x; | 1414 int x; |
| 1483 for (x = 0; x < width - 1; x += 2) { | 1415 for (x = 0; x < width - 1; x += 2) { |
| 1484 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0); | 1416 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0, yuvconstants); |
| 1485 YuvPixel(src_y[1], src_u[0], src_v[0], &b1, &g1, &r1); | 1417 YuvPixel(src_y[1], src_u[0], src_v[0], &b1, &g1, &r1, yuvconstants); |
| 1486 b0 = b0 >> 4; | 1418 b0 = b0 >> 4; |
| 1487 g0 = g0 >> 4; | 1419 g0 = g0 >> 4; |
| 1488 r0 = r0 >> 4; | 1420 r0 = r0 >> 4; |
| 1489 b1 = b1 >> 4; | 1421 b1 = b1 >> 4; |
| 1490 g1 = g1 >> 4; | 1422 g1 = g1 >> 4; |
| 1491 r1 = r1 >> 4; | 1423 r1 = r1 >> 4; |
| 1492 *(uint32*)(dst_argb4444) = b0 | (g0 << 4) | (r0 << 8) | | 1424 *(uint32*)(dst_argb4444) = b0 | (g0 << 4) | (r0 << 8) | |
| 1493 (b1 << 16) | (g1 << 20) | (r1 << 24) | 0xf000f000; | 1425 (b1 << 16) | (g1 << 20) | (r1 << 24) | 0xf000f000; |
| 1494 src_y += 2; | 1426 src_y += 2; |
| 1495 src_u += 1; | 1427 src_u += 1; |
| 1496 src_v += 1; | 1428 src_v += 1; |
| 1497 dst_argb4444 += 4; // Advance 2 pixels. | 1429 dst_argb4444 += 4; // Advance 2 pixels. |
| 1498 } | 1430 } |
| 1499 if (width & 1) { | 1431 if (width & 1) { |
| 1500 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0); | 1432 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0, yuvconstants); |
| 1501 b0 = b0 >> 4; | 1433 b0 = b0 >> 4; |
| 1502 g0 = g0 >> 4; | 1434 g0 = g0 >> 4; |
| 1503 r0 = r0 >> 4; | 1435 r0 = r0 >> 4; |
| 1504 *(uint16*)(dst_argb4444) = b0 | (g0 << 4) | (r0 << 8) | | 1436 *(uint16*)(dst_argb4444) = b0 | (g0 << 4) | (r0 << 8) | |
| 1505 0xf000; | 1437 0xf000; |
| 1506 } | 1438 } |
| 1507 } | 1439 } |
| 1508 | 1440 |
| 1509 void I422ToARGB1555Row_C(const uint8* src_y, | 1441 void I422ToARGB1555Row_C(const uint8* src_y, |
| 1510 const uint8* src_u, | 1442 const uint8* src_u, |
| 1511 const uint8* src_v, | 1443 const uint8* src_v, |
| 1512 uint8* dst_argb1555, | 1444 uint8* dst_argb1555, |
| 1445 struct YuvConstants* yuvconstants, |
| 1513 int width) { | 1446 int width) { |
| 1514 uint8 b0; | 1447 uint8 b0; |
| 1515 uint8 g0; | 1448 uint8 g0; |
| 1516 uint8 r0; | 1449 uint8 r0; |
| 1517 uint8 b1; | 1450 uint8 b1; |
| 1518 uint8 g1; | 1451 uint8 g1; |
| 1519 uint8 r1; | 1452 uint8 r1; |
| 1520 int x; | 1453 int x; |
| 1521 for (x = 0; x < width - 1; x += 2) { | 1454 for (x = 0; x < width - 1; x += 2) { |
| 1522 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0); | 1455 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0, yuvconstants); |
| 1523 YuvPixel(src_y[1], src_u[0], src_v[0], &b1, &g1, &r1); | 1456 YuvPixel(src_y[1], src_u[0], src_v[0], &b1, &g1, &r1, yuvconstants); |
| 1524 b0 = b0 >> 3; | 1457 b0 = b0 >> 3; |
| 1525 g0 = g0 >> 3; | 1458 g0 = g0 >> 3; |
| 1526 r0 = r0 >> 3; | 1459 r0 = r0 >> 3; |
| 1527 b1 = b1 >> 3; | 1460 b1 = b1 >> 3; |
| 1528 g1 = g1 >> 3; | 1461 g1 = g1 >> 3; |
| 1529 r1 = r1 >> 3; | 1462 r1 = r1 >> 3; |
| 1530 *(uint32*)(dst_argb1555) = b0 | (g0 << 5) | (r0 << 10) | | 1463 *(uint32*)(dst_argb1555) = b0 | (g0 << 5) | (r0 << 10) | |
| 1531 (b1 << 16) | (g1 << 21) | (r1 << 26) | 0x80008000; | 1464 (b1 << 16) | (g1 << 21) | (r1 << 26) | 0x80008000; |
| 1532 src_y += 2; | 1465 src_y += 2; |
| 1533 src_u += 1; | 1466 src_u += 1; |
| 1534 src_v += 1; | 1467 src_v += 1; |
| 1535 dst_argb1555 += 4; // Advance 2 pixels. | 1468 dst_argb1555 += 4; // Advance 2 pixels. |
| 1536 } | 1469 } |
| 1537 if (width & 1) { | 1470 if (width & 1) { |
| 1538 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0); | 1471 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0, yuvconstants); |
| 1539 b0 = b0 >> 3; | 1472 b0 = b0 >> 3; |
| 1540 g0 = g0 >> 3; | 1473 g0 = g0 >> 3; |
| 1541 r0 = r0 >> 3; | 1474 r0 = r0 >> 3; |
| 1542 *(uint16*)(dst_argb1555) = b0 | (g0 << 5) | (r0 << 10) | | 1475 *(uint16*)(dst_argb1555) = b0 | (g0 << 5) | (r0 << 10) | |
| 1543 0x8000; | 1476 0x8000; |
| 1544 } | 1477 } |
| 1545 } | 1478 } |
| 1546 | 1479 |
| 1547 void I422ToRGB565Row_C(const uint8* src_y, | 1480 void I422ToRGB565Row_C(const uint8* src_y, |
| 1548 const uint8* src_u, | 1481 const uint8* src_u, |
| 1549 const uint8* src_v, | 1482 const uint8* src_v, |
| 1550 uint8* dst_rgb565, | 1483 uint8* dst_rgb565, |
| 1484 struct YuvConstants* yuvconstants, |
| 1551 int width) { | 1485 int width) { |
| 1552 uint8 b0; | 1486 uint8 b0; |
| 1553 uint8 g0; | 1487 uint8 g0; |
| 1554 uint8 r0; | 1488 uint8 r0; |
| 1555 uint8 b1; | 1489 uint8 b1; |
| 1556 uint8 g1; | 1490 uint8 g1; |
| 1557 uint8 r1; | 1491 uint8 r1; |
| 1558 int x; | 1492 int x; |
| 1559 for (x = 0; x < width - 1; x += 2) { | 1493 for (x = 0; x < width - 1; x += 2) { |
| 1560 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0); | 1494 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0, yuvconstants); |
| 1561 YuvPixel(src_y[1], src_u[0], src_v[0], &b1, &g1, &r1); | 1495 YuvPixel(src_y[1], src_u[0], src_v[0], &b1, &g1, &r1, yuvconstants); |
| 1562 b0 = b0 >> 3; | 1496 b0 = b0 >> 3; |
| 1563 g0 = g0 >> 2; | 1497 g0 = g0 >> 2; |
| 1564 r0 = r0 >> 3; | 1498 r0 = r0 >> 3; |
| 1565 b1 = b1 >> 3; | 1499 b1 = b1 >> 3; |
| 1566 g1 = g1 >> 2; | 1500 g1 = g1 >> 2; |
| 1567 r1 = r1 >> 3; | 1501 r1 = r1 >> 3; |
| 1568 *(uint32*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11) | | 1502 *(uint32*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11) | |
| 1569 (b1 << 16) | (g1 << 21) | (r1 << 27); | 1503 (b1 << 16) | (g1 << 21) | (r1 << 27); |
| 1570 src_y += 2; | 1504 src_y += 2; |
| 1571 src_u += 1; | 1505 src_u += 1; |
| 1572 src_v += 1; | 1506 src_v += 1; |
| 1573 dst_rgb565 += 4; // Advance 2 pixels. | 1507 dst_rgb565 += 4; // Advance 2 pixels. |
| 1574 } | 1508 } |
| 1575 if (width & 1) { | 1509 if (width & 1) { |
| 1576 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0); | 1510 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0, yuvconstants); |
| 1577 b0 = b0 >> 3; | 1511 b0 = b0 >> 3; |
| 1578 g0 = g0 >> 2; | 1512 g0 = g0 >> 2; |
| 1579 r0 = r0 >> 3; | 1513 r0 = r0 >> 3; |
| 1580 *(uint16*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11); | 1514 *(uint16*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11); |
| 1581 } | 1515 } |
| 1582 } | 1516 } |
| 1583 | 1517 |
| 1584 void I411ToARGBRow_C(const uint8* src_y, | 1518 void I411ToARGBRow_C(const uint8* src_y, |
| 1585 const uint8* src_u, | 1519 const uint8* src_u, |
| 1586 const uint8* src_v, | 1520 const uint8* src_v, |
| 1587 uint8* rgb_buf, | 1521 uint8* rgb_buf, |
| 1522 struct YuvConstants* yuvconstants, |
| 1588 int width) { | 1523 int width) { |
| 1589 int x; | 1524 int x; |
| 1590 for (x = 0; x < width - 3; x += 4) { | 1525 for (x = 0; x < width - 3; x += 4) { |
| 1591 YuvPixel(src_y[0], src_u[0], src_v[0], | 1526 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1592 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1527 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1593 rgb_buf[3] = 255; | 1528 rgb_buf[3] = 255; |
| 1594 YuvPixel(src_y[1], src_u[0], src_v[0], | 1529 YuvPixel(src_y[1], src_u[0], src_v[0], |
| 1595 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | 1530 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); |
| 1596 rgb_buf[7] = 255; | 1531 rgb_buf[7] = 255; |
| 1597 YuvPixel(src_y[2], src_u[0], src_v[0], | 1532 YuvPixel(src_y[2], src_u[0], src_v[0], |
| 1598 rgb_buf + 8, rgb_buf + 9, rgb_buf + 10); | 1533 rgb_buf + 8, rgb_buf + 9, rgb_buf + 10, yuvconstants); |
| 1599 rgb_buf[11] = 255; | 1534 rgb_buf[11] = 255; |
| 1600 YuvPixel(src_y[3], src_u[0], src_v[0], | 1535 YuvPixel(src_y[3], src_u[0], src_v[0], |
| 1601 rgb_buf + 12, rgb_buf + 13, rgb_buf + 14); | 1536 rgb_buf + 12, rgb_buf + 13, rgb_buf + 14, yuvconstants); |
| 1602 rgb_buf[15] = 255; | 1537 rgb_buf[15] = 255; |
| 1603 src_y += 4; | 1538 src_y += 4; |
| 1604 src_u += 1; | 1539 src_u += 1; |
| 1605 src_v += 1; | 1540 src_v += 1; |
| 1606 rgb_buf += 16; // Advance 4 pixels. | 1541 rgb_buf += 16; // Advance 4 pixels. |
| 1607 } | 1542 } |
| 1608 if (width & 2) { | 1543 if (width & 2) { |
| 1609 YuvPixel(src_y[0], src_u[0], src_v[0], | 1544 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1610 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1545 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1611 rgb_buf[3] = 255; | 1546 rgb_buf[3] = 255; |
| 1612 YuvPixel(src_y[1], src_u[0], src_v[0], | 1547 YuvPixel(src_y[1], src_u[0], src_v[0], |
| 1613 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | 1548 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); |
| 1614 rgb_buf[7] = 255; | 1549 rgb_buf[7] = 255; |
| 1615 src_y += 2; | 1550 src_y += 2; |
| 1616 rgb_buf += 8; // Advance 2 pixels. | 1551 rgb_buf += 8; // Advance 2 pixels. |
| 1617 } | 1552 } |
| 1618 if (width & 1) { | 1553 if (width & 1) { |
| 1619 YuvPixel(src_y[0], src_u[0], src_v[0], | 1554 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1620 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1555 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1621 rgb_buf[3] = 255; | 1556 rgb_buf[3] = 255; |
| 1622 } | 1557 } |
| 1623 } | 1558 } |
| 1624 | 1559 |
| 1625 void NV12ToARGBRow_C(const uint8* src_y, | 1560 void NV12ToARGBRow_C(const uint8* src_y, |
| 1626 const uint8* src_uv, | 1561 const uint8* src_uv, |
| 1627 uint8* rgb_buf, | 1562 uint8* rgb_buf, |
| 1563 struct YuvConstants* yuvconstants, |
| 1628 int width) { | 1564 int width) { |
| 1629 int x; | 1565 int x; |
| 1630 for (x = 0; x < width - 1; x += 2) { | 1566 for (x = 0; x < width - 1; x += 2) { |
| 1631 YuvPixel(src_y[0], src_uv[0], src_uv[1], | 1567 YuvPixel(src_y[0], src_uv[0], src_uv[1], |
| 1632 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1568 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1633 rgb_buf[3] = 255; | 1569 rgb_buf[3] = 255; |
| 1634 YuvPixel(src_y[1], src_uv[0], src_uv[1], | 1570 YuvPixel(src_y[1], src_uv[0], src_uv[1], |
| 1635 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | 1571 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); |
| 1636 rgb_buf[7] = 255; | 1572 rgb_buf[7] = 255; |
| 1637 src_y += 2; | 1573 src_y += 2; |
| 1638 src_uv += 2; | 1574 src_uv += 2; |
| 1639 rgb_buf += 8; // Advance 2 pixels. | 1575 rgb_buf += 8; // Advance 2 pixels. |
| 1640 } | 1576 } |
| 1641 if (width & 1) { | 1577 if (width & 1) { |
| 1642 YuvPixel(src_y[0], src_uv[0], src_uv[1], | 1578 YuvPixel(src_y[0], src_uv[0], src_uv[1], |
| 1643 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1579 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1644 rgb_buf[3] = 255; | 1580 rgb_buf[3] = 255; |
| 1645 } | 1581 } |
| 1646 } | 1582 } |
| 1647 | |
| 1648 void NV21ToARGBRow_C(const uint8* src_y, | |
| 1649 const uint8* src_vu, | |
| 1650 uint8* rgb_buf, | |
| 1651 int width) { | |
| 1652 int x; | |
| 1653 for (x = 0; x < width - 1; x += 2) { | |
| 1654 YuvPixel(src_y[0], src_vu[1], src_vu[0], | |
| 1655 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | |
| 1656 rgb_buf[3] = 255; | |
| 1657 | |
| 1658 YuvPixel(src_y[1], src_vu[1], src_vu[0], | |
| 1659 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | |
| 1660 rgb_buf[7] = 255; | |
| 1661 | |
| 1662 src_y += 2; | |
| 1663 src_vu += 2; | |
| 1664 rgb_buf += 8; // Advance 2 pixels. | |
| 1665 } | |
| 1666 if (width & 1) { | |
| 1667 YuvPixel(src_y[0], src_vu[1], src_vu[0], | |
| 1668 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | |
| 1669 rgb_buf[3] = 255; | |
| 1670 } | |
| 1671 } | |
| 1672 | 1583 |
| 1673 void NV12ToRGB565Row_C(const uint8* src_y, | 1584 void NV12ToRGB565Row_C(const uint8* src_y, |
| 1674 const uint8* src_uv, | 1585 const uint8* src_uv, |
| 1675 uint8* dst_rgb565, | 1586 uint8* dst_rgb565, |
| 1587 struct YuvConstants* yuvconstants, |
| 1676 int width) { | 1588 int width) { |
| 1677 uint8 b0; | 1589 uint8 b0; |
| 1678 uint8 g0; | 1590 uint8 g0; |
| 1679 uint8 r0; | 1591 uint8 r0; |
| 1680 uint8 b1; | 1592 uint8 b1; |
| 1681 uint8 g1; | 1593 uint8 g1; |
| 1682 uint8 r1; | 1594 uint8 r1; |
| 1683 int x; | 1595 int x; |
| 1684 for (x = 0; x < width - 1; x += 2) { | 1596 for (x = 0; x < width - 1; x += 2) { |
| 1685 YuvPixel(src_y[0], src_uv[0], src_uv[1], &b0, &g0, &r0); | 1597 YuvPixel(src_y[0], src_uv[0], src_uv[1], &b0, &g0, &r0, yuvconstants); |
| 1686 YuvPixel(src_y[1], src_uv[0], src_uv[1], &b1, &g1, &r1); | 1598 YuvPixel(src_y[1], src_uv[0], src_uv[1], &b1, &g1, &r1, yuvconstants); |
| 1687 b0 = b0 >> 3; | 1599 b0 = b0 >> 3; |
| 1688 g0 = g0 >> 2; | 1600 g0 = g0 >> 2; |
| 1689 r0 = r0 >> 3; | 1601 r0 = r0 >> 3; |
| 1690 b1 = b1 >> 3; | 1602 b1 = b1 >> 3; |
| 1691 g1 = g1 >> 2; | 1603 g1 = g1 >> 2; |
| 1692 r1 = r1 >> 3; | 1604 r1 = r1 >> 3; |
| 1693 *(uint32*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11) | | 1605 *(uint32*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11) | |
| 1694 (b1 << 16) | (g1 << 21) | (r1 << 27); | 1606 (b1 << 16) | (g1 << 21) | (r1 << 27); |
| 1695 src_y += 2; | 1607 src_y += 2; |
| 1696 src_uv += 2; | 1608 src_uv += 2; |
| 1697 dst_rgb565 += 4; // Advance 2 pixels. | 1609 dst_rgb565 += 4; // Advance 2 pixels. |
| 1698 } | 1610 } |
| 1699 if (width & 1) { | 1611 if (width & 1) { |
| 1700 YuvPixel(src_y[0], src_uv[0], src_uv[1], &b0, &g0, &r0); | 1612 YuvPixel(src_y[0], src_uv[0], src_uv[1], &b0, &g0, &r0, yuvconstants); |
| 1701 b0 = b0 >> 3; | 1613 b0 = b0 >> 3; |
| 1702 g0 = g0 >> 2; | 1614 g0 = g0 >> 2; |
| 1703 r0 = r0 >> 3; | 1615 r0 = r0 >> 3; |
| 1704 *(uint16*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11); | |
| 1705 } | |
| 1706 } | |
| 1707 | |
| 1708 void NV21ToRGB565Row_C(const uint8* src_y, | |
| 1709 const uint8* vsrc_u, | |
| 1710 uint8* dst_rgb565, | |
| 1711 int width) { | |
| 1712 uint8 b0; | |
| 1713 uint8 g0; | |
| 1714 uint8 r0; | |
| 1715 uint8 b1; | |
| 1716 uint8 g1; | |
| 1717 uint8 r1; | |
| 1718 int x; | |
| 1719 for (x = 0; x < width - 1; x += 2) { | |
| 1720 YuvPixel(src_y[0], vsrc_u[1], vsrc_u[0], &b0, &g0, &r0); | |
| 1721 YuvPixel(src_y[1], vsrc_u[1], vsrc_u[0], &b1, &g1, &r1); | |
| 1722 b0 = b0 >> 3; | |
| 1723 g0 = g0 >> 2; | |
| 1724 r0 = r0 >> 3; | |
| 1725 b1 = b1 >> 3; | |
| 1726 g1 = g1 >> 2; | |
| 1727 r1 = r1 >> 3; | |
| 1728 *(uint32*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11) | | |
| 1729 (b1 << 16) | (g1 << 21) | (r1 << 27); | |
| 1730 src_y += 2; | |
| 1731 vsrc_u += 2; | |
| 1732 dst_rgb565 += 4; // Advance 2 pixels. | |
| 1733 } | |
| 1734 if (width & 1) { | |
| 1735 YuvPixel(src_y[0], vsrc_u[1], vsrc_u[0], &b0, &g0, &r0); | |
| 1736 b0 = b0 >> 3; | |
| 1737 g0 = g0 >> 2; | |
| 1738 r0 = r0 >> 3; | |
| 1739 *(uint16*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11); | 1616 *(uint16*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11); |
| 1740 } | 1617 } |
| 1741 } | 1618 } |
| 1742 | 1619 |
| 1743 void YUY2ToARGBRow_C(const uint8* src_yuy2, | 1620 void YUY2ToARGBRow_C(const uint8* src_yuy2, |
| 1744 uint8* rgb_buf, | 1621 uint8* rgb_buf, |
| 1622 struct YuvConstants* yuvconstants, |
| 1745 int width) { | 1623 int width) { |
| 1746 int x; | 1624 int x; |
| 1747 for (x = 0; x < width - 1; x += 2) { | 1625 for (x = 0; x < width - 1; x += 2) { |
| 1748 YuvPixel(src_yuy2[0], src_yuy2[1], src_yuy2[3], | 1626 YuvPixel(src_yuy2[0], src_yuy2[1], src_yuy2[3], |
| 1749 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1627 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1750 rgb_buf[3] = 255; | 1628 rgb_buf[3] = 255; |
| 1751 YuvPixel(src_yuy2[2], src_yuy2[1], src_yuy2[3], | 1629 YuvPixel(src_yuy2[2], src_yuy2[1], src_yuy2[3], |
| 1752 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | 1630 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); |
| 1753 rgb_buf[7] = 255; | 1631 rgb_buf[7] = 255; |
| 1754 src_yuy2 += 4; | 1632 src_yuy2 += 4; |
| 1755 rgb_buf += 8; // Advance 2 pixels. | 1633 rgb_buf += 8; // Advance 2 pixels. |
| 1756 } | 1634 } |
| 1757 if (width & 1) { | 1635 if (width & 1) { |
| 1758 YuvPixel(src_yuy2[0], src_yuy2[1], src_yuy2[3], | 1636 YuvPixel(src_yuy2[0], src_yuy2[1], src_yuy2[3], |
| 1759 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1637 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1760 rgb_buf[3] = 255; | 1638 rgb_buf[3] = 255; |
| 1761 } | 1639 } |
| 1762 } | 1640 } |
| 1763 | 1641 |
| 1764 void UYVYToARGBRow_C(const uint8* src_uyvy, | 1642 void UYVYToARGBRow_C(const uint8* src_uyvy, |
| 1765 uint8* rgb_buf, | 1643 uint8* rgb_buf, |
| 1644 struct YuvConstants* yuvconstants, |
| 1766 int width) { | 1645 int width) { |
| 1767 int x; | 1646 int x; |
| 1768 for (x = 0; x < width - 1; x += 2) { | 1647 for (x = 0; x < width - 1; x += 2) { |
| 1769 YuvPixel(src_uyvy[1], src_uyvy[0], src_uyvy[2], | 1648 YuvPixel(src_uyvy[1], src_uyvy[0], src_uyvy[2], |
| 1770 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1649 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1771 rgb_buf[3] = 255; | 1650 rgb_buf[3] = 255; |
| 1772 YuvPixel(src_uyvy[3], src_uyvy[0], src_uyvy[2], | 1651 YuvPixel(src_uyvy[3], src_uyvy[0], src_uyvy[2], |
| 1773 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | 1652 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); |
| 1774 rgb_buf[7] = 255; | 1653 rgb_buf[7] = 255; |
| 1775 src_uyvy += 4; | 1654 src_uyvy += 4; |
| 1776 rgb_buf += 8; // Advance 2 pixels. | 1655 rgb_buf += 8; // Advance 2 pixels. |
| 1777 } | 1656 } |
| 1778 if (width & 1) { | 1657 if (width & 1) { |
| 1779 YuvPixel(src_uyvy[1], src_uyvy[0], src_uyvy[2], | 1658 YuvPixel(src_uyvy[1], src_uyvy[0], src_uyvy[2], |
| 1780 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1659 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
| 1781 rgb_buf[3] = 255; | 1660 rgb_buf[3] = 255; |
| 1782 } | 1661 } |
| 1783 } | 1662 } |
| 1784 | 1663 |
| 1785 void I422ToBGRARow_C(const uint8* src_y, | 1664 void I422ToBGRARow_C(const uint8* src_y, |
| 1786 const uint8* src_u, | 1665 const uint8* src_u, |
| 1787 const uint8* src_v, | 1666 const uint8* src_v, |
| 1788 uint8* rgb_buf, | 1667 uint8* rgb_buf, |
| 1668 struct YuvConstants* yuvconstants, |
| 1789 int width) { | 1669 int width) { |
| 1790 int x; | 1670 int x; |
| 1791 for (x = 0; x < width - 1; x += 2) { | 1671 for (x = 0; x < width - 1; x += 2) { |
| 1792 YuvPixel(src_y[0], src_u[0], src_v[0], | 1672 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1793 rgb_buf + 3, rgb_buf + 2, rgb_buf + 1); | 1673 rgb_buf + 3, rgb_buf + 2, rgb_buf + 1, yuvconstants); |
| 1794 rgb_buf[0] = 255; | 1674 rgb_buf[0] = 255; |
| 1795 YuvPixel(src_y[1], src_u[0], src_v[0], | 1675 YuvPixel(src_y[1], src_u[0], src_v[0], |
| 1796 rgb_buf + 7, rgb_buf + 6, rgb_buf + 5); | 1676 rgb_buf + 7, rgb_buf + 6, rgb_buf + 5, yuvconstants); |
| 1797 rgb_buf[4] = 255; | 1677 rgb_buf[4] = 255; |
| 1798 src_y += 2; | 1678 src_y += 2; |
| 1799 src_u += 1; | 1679 src_u += 1; |
| 1800 src_v += 1; | 1680 src_v += 1; |
| 1801 rgb_buf += 8; // Advance 2 pixels. | 1681 rgb_buf += 8; // Advance 2 pixels. |
| 1802 } | 1682 } |
| 1803 if (width & 1) { | 1683 if (width & 1) { |
| 1804 YuvPixel(src_y[0], src_u[0], src_v[0], | 1684 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1805 rgb_buf + 3, rgb_buf + 2, rgb_buf + 1); | 1685 rgb_buf + 3, rgb_buf + 2, rgb_buf + 1, yuvconstants); |
| 1806 rgb_buf[0] = 255; | 1686 rgb_buf[0] = 255; |
| 1807 } | 1687 } |
| 1808 } | 1688 } |
| 1809 | 1689 |
| 1810 void I422ToABGRRow_C(const uint8* src_y, | 1690 void I422ToABGRRow_C(const uint8* src_y, |
| 1811 const uint8* src_u, | 1691 const uint8* src_u, |
| 1812 const uint8* src_v, | 1692 const uint8* src_v, |
| 1813 uint8* rgb_buf, | 1693 uint8* rgb_buf, |
| 1694 struct YuvConstants* yuvconstants, |
| 1814 int width) { | 1695 int width) { |
| 1815 int x; | 1696 int x; |
| 1816 for (x = 0; x < width - 1; x += 2) { | 1697 for (x = 0; x < width - 1; x += 2) { |
| 1817 YuvPixel(src_y[0], src_u[0], src_v[0], | 1698 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1818 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | 1699 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0, yuvconstants); |
| 1819 rgb_buf[3] = 255; | 1700 rgb_buf[3] = 255; |
| 1820 YuvPixel(src_y[1], src_u[0], src_v[0], | 1701 YuvPixel(src_y[1], src_u[0], src_v[0], |
| 1821 rgb_buf + 6, rgb_buf + 5, rgb_buf + 4); | 1702 rgb_buf + 6, rgb_buf + 5, rgb_buf + 4, yuvconstants); |
| 1822 rgb_buf[7] = 255; | 1703 rgb_buf[7] = 255; |
| 1823 src_y += 2; | 1704 src_y += 2; |
| 1824 src_u += 1; | 1705 src_u += 1; |
| 1825 src_v += 1; | 1706 src_v += 1; |
| 1826 rgb_buf += 8; // Advance 2 pixels. | 1707 rgb_buf += 8; // Advance 2 pixels. |
| 1827 } | 1708 } |
| 1828 if (width & 1) { | 1709 if (width & 1) { |
| 1829 YuvPixel(src_y[0], src_u[0], src_v[0], | 1710 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1830 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); | 1711 rgb_buf + 2, rgb_buf + 1, rgb_buf + 0, yuvconstants); |
| 1831 rgb_buf[3] = 255; | 1712 rgb_buf[3] = 255; |
| 1832 } | 1713 } |
| 1833 } | 1714 } |
| 1834 | 1715 |
| 1835 void I422ToRGBARow_C(const uint8* src_y, | 1716 void I422ToRGBARow_C(const uint8* src_y, |
| 1836 const uint8* src_u, | 1717 const uint8* src_u, |
| 1837 const uint8* src_v, | 1718 const uint8* src_v, |
| 1838 uint8* rgb_buf, | 1719 uint8* rgb_buf, |
| 1720 struct YuvConstants* yuvconstants, |
| 1839 int width) { | 1721 int width) { |
| 1840 int x; | 1722 int x; |
| 1841 for (x = 0; x < width - 1; x += 2) { | 1723 for (x = 0; x < width - 1; x += 2) { |
| 1842 YuvPixel(src_y[0], src_u[0], src_v[0], | 1724 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1843 rgb_buf + 1, rgb_buf + 2, rgb_buf + 3); | 1725 rgb_buf + 1, rgb_buf + 2, rgb_buf + 3, yuvconstants); |
| 1844 rgb_buf[0] = 255; | 1726 rgb_buf[0] = 255; |
| 1845 YuvPixel(src_y[1], src_u[0], src_v[0], | 1727 YuvPixel(src_y[1], src_u[0], src_v[0], |
| 1846 rgb_buf + 5, rgb_buf + 6, rgb_buf + 7); | 1728 rgb_buf + 5, rgb_buf + 6, rgb_buf + 7, yuvconstants); |
| 1847 rgb_buf[4] = 255; | 1729 rgb_buf[4] = 255; |
| 1848 src_y += 2; | 1730 src_y += 2; |
| 1849 src_u += 1; | 1731 src_u += 1; |
| 1850 src_v += 1; | 1732 src_v += 1; |
| 1851 rgb_buf += 8; // Advance 2 pixels. | 1733 rgb_buf += 8; // Advance 2 pixels. |
| 1852 } | 1734 } |
| 1853 if (width & 1) { | 1735 if (width & 1) { |
| 1854 YuvPixel(src_y[0], src_u[0], src_v[0], | 1736 YuvPixel(src_y[0], src_u[0], src_v[0], |
| 1855 rgb_buf + 1, rgb_buf + 2, rgb_buf + 3); | 1737 rgb_buf + 1, rgb_buf + 2, rgb_buf + 3, yuvconstants); |
| 1856 rgb_buf[0] = 255; | 1738 rgb_buf[0] = 255; |
| 1857 } | 1739 } |
| 1858 } | 1740 } |
| 1859 | 1741 |
| 1860 void I400ToARGBRow_C(const uint8* src_y, uint8* rgb_buf, int width) { | 1742 void I400ToARGBRow_C(const uint8* src_y, uint8* rgb_buf, int width) { |
| 1861 int x; | 1743 int x; |
| 1862 for (x = 0; x < width - 1; x += 2) { | 1744 for (x = 0; x < width - 1; x += 2) { |
| 1863 YPixel(src_y[0], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); | 1745 YPixel(src_y[0], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); |
| 1864 rgb_buf[3] = 255; | 1746 rgb_buf[3] = 255; |
| 1865 YPixel(src_y[1], rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); | 1747 YPixel(src_y[1], rgb_buf + 4, rgb_buf + 5, rgb_buf + 6); |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2394 src_v += 1; | 2276 src_v += 1; |
| 2395 } | 2277 } |
| 2396 if (width & 1) { | 2278 if (width & 1) { |
| 2397 dst_frame[0] = src_u[0]; | 2279 dst_frame[0] = src_u[0]; |
| 2398 dst_frame[1] = src_y[0]; | 2280 dst_frame[1] = src_y[0]; |
| 2399 dst_frame[2] = src_v[0]; | 2281 dst_frame[2] = src_v[0]; |
| 2400 dst_frame[3] = 0; | 2282 dst_frame[3] = 0; |
| 2401 } | 2283 } |
| 2402 } | 2284 } |
| 2403 | 2285 |
| 2404 #define ANYYUV(NAMEANY, ANY_SIMD, YUVCONSTANTS) \ | |
| 2405 void NAMEANY(const uint8* y_buf, \ | |
| 2406 const uint8* u_buf, \ | |
| 2407 const uint8* v_buf, \ | |
| 2408 uint8* dst_argb, \ | |
| 2409 int width) { \ | |
| 2410 ANY_SIMD(y_buf, u_buf, v_buf, dst_argb, &YUVCONSTANTS, width); \ | |
| 2411 } | |
| 2412 | 2286 |
| 2413 #ifdef HAS_I422TOARGBMATRIXROW_NEON | 2287 void ARGBPolynomialRow_C(const uint8* src_argb, |
| 2414 ANYYUV(I422ToARGBRow_NEON, I422ToARGBMatrixRow_NEON, kYuvConstantsNEON) | 2288 uint8* dst_argb, |
| 2415 ANYYUV(J422ToARGBRow_NEON, I422ToARGBMatrixRow_NEON, kYuvJConstantsNEON) | 2289 const float* poly, |
| 2416 ANYYUV(H422ToARGBRow_NEON, I422ToARGBMatrixRow_NEON, kYuvHConstantsNEON) | 2290 int width) { |
| 2417 #endif | 2291 int i; |
| 2418 #ifdef HAS_I422TOABGRMATRIXROW_NEON | 2292 for (i = 0; i < width; ++i) { |
| 2419 ANYYUV(I422ToABGRRow_NEON, I422ToABGRMatrixRow_NEON, kYuvConstantsNEON) | 2293 float b = (float)(src_argb[0]); |
| 2420 ANYYUV(J422ToABGRRow_NEON, I422ToABGRMatrixRow_NEON, kYuvJConstantsNEON) | 2294 float g = (float)(src_argb[1]); |
| 2421 ANYYUV(H422ToABGRRow_NEON, I422ToABGRMatrixRow_NEON, kYuvHConstantsNEON) | 2295 float r = (float)(src_argb[2]); |
| 2422 #endif | 2296 float a = (float)(src_argb[3]); |
| 2423 #ifdef HAS_I422TOARGBMATRIXROW_SSSE3 | 2297 float b2 = b * b; |
| 2424 ANYYUV(I422ToARGBRow_SSSE3, I422ToARGBMatrixRow_SSSE3, kYuvConstants) | 2298 float g2 = g * g; |
| 2425 ANYYUV(J422ToARGBRow_SSSE3, I422ToARGBMatrixRow_SSSE3, kYuvJConstants) | 2299 float r2 = r * r; |
| 2426 ANYYUV(H422ToARGBRow_SSSE3, I422ToARGBMatrixRow_SSSE3, kYuvHConstants) | 2300 float a2 = a * a; |
| 2427 #endif | 2301 float db = poly[0] + poly[4] * b; |
| 2428 #ifdef HAS_I422TOARGBMATRIXROW_AVX2 | 2302 float dg = poly[1] + poly[5] * g; |
| 2429 ANYYUV(I422ToARGBRow_AVX2, I422ToARGBMatrixRow_AVX2, kYuvConstants) | 2303 float dr = poly[2] + poly[6] * r; |
| 2430 ANYYUV(J422ToARGBRow_AVX2, I422ToARGBMatrixRow_AVX2, kYuvJConstants) | 2304 float da = poly[3] + poly[7] * a; |
| 2431 ANYYUV(H422ToARGBRow_AVX2, I422ToARGBMatrixRow_AVX2, kYuvHConstants) | 2305 float b3 = b2 * b; |
| 2432 #endif | 2306 float g3 = g2 * g; |
| 2433 #ifdef HAS_I422TOABGRMATRIXROW_SSSE3 | 2307 float r3 = r2 * r; |
| 2434 ANYYUV(I422ToABGRRow_SSSE3, I422ToABGRMatrixRow_SSSE3, kYuvConstants) | 2308 float a3 = a2 * a; |
| 2435 ANYYUV(J422ToABGRRow_SSSE3, I422ToABGRMatrixRow_SSSE3, kYuvJConstants) | 2309 db += poly[8] * b2; |
| 2436 ANYYUV(H422ToABGRRow_SSSE3, I422ToABGRMatrixRow_SSSE3, kYuvHConstants) | 2310 dg += poly[9] * g2; |
| 2437 #endif | 2311 dr += poly[10] * r2; |
| 2438 #ifdef HAS_I422TOABGRMATRIXROW_AVX2 | 2312 da += poly[11] * a2; |
| 2439 ANYYUV(I422ToABGRRow_AVX2, I422ToABGRMatrixRow_AVX2, kYuvConstants) | 2313 db += poly[12] * b3; |
| 2440 ANYYUV(J422ToABGRRow_AVX2, I422ToABGRMatrixRow_AVX2, kYuvJConstants) | 2314 dg += poly[13] * g3; |
| 2441 ANYYUV(H422ToABGRRow_AVX2, I422ToABGRMatrixRow_AVX2, kYuvHConstants) | 2315 dr += poly[14] * r3; |
| 2442 #endif | 2316 da += poly[15] * a3; |
| 2443 // TODO(fbarchard): Neon, J444, H444 versions. | 2317 |
| 2444 #ifdef HAS_I444TOARGBMATRIXROW_SSSE3 | 2318 dst_argb[0] = Clamp((int32)(db)); |
| 2445 ANYYUV(I444ToARGBRow_SSSE3, I444ToARGBMatrixRow_SSSE3, kYuvConstants) | 2319 dst_argb[1] = Clamp((int32)(dg)); |
| 2446 #endif | 2320 dst_argb[2] = Clamp((int32)(dr)); |
| 2447 #ifdef HAS_I444TOARGBMATRIXROW_AVX2 | 2321 dst_argb[3] = Clamp((int32)(da)); |
| 2448 ANYYUV(I444ToARGBRow_AVX2, I444ToARGBMatrixRow_AVX2, kYuvConstants) | 2322 src_argb += 4; |
| 2449 #endif | 2323 dst_argb += 4; |
| 2450 #ifdef HAS_I444TOABGRMATRIXROW_SSSE3 | 2324 } |
| 2451 ANYYUV(I444ToABGRRow_SSSE3, I444ToABGRMatrixRow_SSSE3, kYuvConstants) | 2325 } |
| 2452 #endif | 2326 |
| 2453 #ifdef HAS_I444TOABGRMATRIXROW_AVX2 | 2327 void ARGBLumaColorTableRow_C(const uint8* src_argb, uint8* dst_argb, int width, |
| 2454 ANYYUV(I444ToABGRRow_AVX2, I444ToABGRMatrixRow_AVX2, kYuvConstants) | 2328 const uint8* luma, uint32 lumacoeff) { |
| 2455 #endif | 2329 uint32 bc = lumacoeff & 0xff; |
| 2330 uint32 gc = (lumacoeff >> 8) & 0xff; |
| 2331 uint32 rc = (lumacoeff >> 16) & 0xff; |
| 2332 |
| 2333 int i; |
| 2334 for (i = 0; i < width - 1; i += 2) { |
| 2335 // Luminance in rows, color values in columns. |
| 2336 const uint8* luma0 = ((src_argb[0] * bc + src_argb[1] * gc + |
| 2337 src_argb[2] * rc) & 0x7F00u) + luma; |
| 2338 const uint8* luma1; |
| 2339 dst_argb[0] = luma0[src_argb[0]]; |
| 2340 dst_argb[1] = luma0[src_argb[1]]; |
| 2341 dst_argb[2] = luma0[src_argb[2]]; |
| 2342 dst_argb[3] = src_argb[3]; |
| 2343 luma1 = ((src_argb[4] * bc + src_argb[5] * gc + |
| 2344 src_argb[6] * rc) & 0x7F00u) + luma; |
| 2345 dst_argb[4] = luma1[src_argb[4]]; |
| 2346 dst_argb[5] = luma1[src_argb[5]]; |
| 2347 dst_argb[6] = luma1[src_argb[6]]; |
| 2348 dst_argb[7] = src_argb[7]; |
| 2349 src_argb += 8; |
| 2350 dst_argb += 8; |
| 2351 } |
| 2352 if (width & 1) { |
| 2353 // Luminance in rows, color values in columns. |
| 2354 const uint8* luma0 = ((src_argb[0] * bc + src_argb[1] * gc + |
| 2355 src_argb[2] * rc) & 0x7F00u) + luma; |
| 2356 dst_argb[0] = luma0[src_argb[0]]; |
| 2357 dst_argb[1] = luma0[src_argb[1]]; |
| 2358 dst_argb[2] = luma0[src_argb[2]]; |
| 2359 dst_argb[3] = src_argb[3]; |
| 2360 } |
| 2361 } |
| 2362 |
| 2363 void ARGBCopyAlphaRow_C(const uint8* src, uint8* dst, int width) { |
| 2364 int i; |
| 2365 for (i = 0; i < width - 1; i += 2) { |
| 2366 dst[3] = src[3]; |
| 2367 dst[7] = src[7]; |
| 2368 dst += 8; |
| 2369 src += 8; |
| 2370 } |
| 2371 if (width & 1) { |
| 2372 dst[3] = src[3]; |
| 2373 } |
| 2374 } |
| 2375 |
| 2376 void ARGBCopyYToAlphaRow_C(const uint8* src, uint8* dst, int width) { |
| 2377 int i; |
| 2378 for (i = 0; i < width - 1; i += 2) { |
| 2379 dst[3] = src[0]; |
| 2380 dst[7] = src[1]; |
| 2381 dst += 8; |
| 2382 src += 2; |
| 2383 } |
| 2384 if (width & 1) { |
| 2385 dst[3] = src[0]; |
| 2386 } |
| 2387 } |
| 2456 | 2388 |
| 2457 // Maximum temporary width for wrappers to process at a time, in pixels. | 2389 // Maximum temporary width for wrappers to process at a time, in pixels. |
| 2458 #define MAXTWIDTH 2048 | 2390 #define MAXTWIDTH 2048 |
| 2459 | 2391 |
| 2460 #if !(defined(_MSC_VER) && defined(_M_IX86)) && \ | 2392 #if !(defined(_MSC_VER) && defined(_M_IX86)) && \ |
| 2461 defined(HAS_I422TORGB565ROW_SSSE3) | 2393 defined(HAS_I422TORGB565ROW_SSSE3) |
| 2462 // row_win.cc has asm version, but GCC uses 2 step wrapper. | 2394 // row_win.cc has asm version, but GCC uses 2 step wrapper. |
| 2463 void I422ToRGB565Row_SSSE3(const uint8* src_y, | 2395 void I422ToRGB565Row_SSSE3(const uint8* src_y, |
| 2464 const uint8* src_u, | 2396 const uint8* src_u, |
| 2465 const uint8* src_v, | 2397 const uint8* src_v, |
| 2466 uint8* dst_rgb565, | 2398 uint8* dst_rgb565, |
| 2399 struct YuvConstants* yuvconstants, |
| 2467 int width) { | 2400 int width) { |
| 2468 SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); | 2401 SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); |
| 2469 while (width > 0) { | 2402 while (width > 0) { |
| 2470 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2403 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2471 I422ToARGBRow_SSSE3(src_y, src_u, src_v, row, twidth); | 2404 I422ToARGBRow_SSSE3(src_y, src_u, src_v, row, yuvconstants, twidth); |
| 2472 ARGBToRGB565Row_SSE2(row, dst_rgb565, twidth); | 2405 ARGBToRGB565Row_SSE2(row, dst_rgb565, twidth); |
| 2473 src_y += twidth; | 2406 src_y += twidth; |
| 2474 src_u += twidth / 2; | 2407 src_u += twidth / 2; |
| 2475 src_v += twidth / 2; | 2408 src_v += twidth / 2; |
| 2476 dst_rgb565 += twidth * 2; | 2409 dst_rgb565 += twidth * 2; |
| 2477 width -= twidth; | 2410 width -= twidth; |
| 2478 } | 2411 } |
| 2479 } | 2412 } |
| 2480 #endif | 2413 #endif |
| 2481 | 2414 |
| 2482 #if defined(HAS_I422TOARGB1555ROW_SSSE3) | 2415 #if defined(HAS_I422TOARGB1555ROW_SSSE3) |
| 2483 void I422ToARGB1555Row_SSSE3(const uint8* src_y, | 2416 void I422ToARGB1555Row_SSSE3(const uint8* src_y, |
| 2484 const uint8* src_u, | 2417 const uint8* src_u, |
| 2485 const uint8* src_v, | 2418 const uint8* src_v, |
| 2486 uint8* dst_argb1555, | 2419 uint8* dst_argb1555, |
| 2420 struct YuvConstants* yuvconstants, |
| 2487 int width) { | 2421 int width) { |
| 2488 // Row buffer for intermediate ARGB pixels. | 2422 // Row buffer for intermediate ARGB pixels. |
| 2489 SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); | 2423 SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); |
| 2490 while (width > 0) { | 2424 while (width > 0) { |
| 2491 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2425 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2492 I422ToARGBRow_SSSE3(src_y, src_u, src_v, row, twidth); | 2426 I422ToARGBRow_SSSE3(src_y, src_u, src_v, row, yuvconstants, twidth); |
| 2493 ARGBToARGB1555Row_SSE2(row, dst_argb1555, twidth); | 2427 ARGBToARGB1555Row_SSE2(row, dst_argb1555, twidth); |
| 2494 src_y += twidth; | 2428 src_y += twidth; |
| 2495 src_u += twidth / 2; | 2429 src_u += twidth / 2; |
| 2496 src_v += twidth / 2; | 2430 src_v += twidth / 2; |
| 2497 dst_argb1555 += twidth * 2; | 2431 dst_argb1555 += twidth * 2; |
| 2498 width -= twidth; | 2432 width -= twidth; |
| 2499 } | 2433 } |
| 2500 } | 2434 } |
| 2501 #endif | 2435 #endif |
| 2502 | 2436 |
| 2503 #if defined(HAS_I422TOARGB4444ROW_SSSE3) | 2437 #if defined(HAS_I422TOARGB4444ROW_SSSE3) |
| 2504 void I422ToARGB4444Row_SSSE3(const uint8* src_y, | 2438 void I422ToARGB4444Row_SSSE3(const uint8* src_y, |
| 2505 const uint8* src_u, | 2439 const uint8* src_u, |
| 2506 const uint8* src_v, | 2440 const uint8* src_v, |
| 2507 uint8* dst_argb4444, | 2441 uint8* dst_argb4444, |
| 2442 struct YuvConstants* yuvconstants, |
| 2508 int width) { | 2443 int width) { |
| 2509 // Row buffer for intermediate ARGB pixels. | 2444 // Row buffer for intermediate ARGB pixels. |
| 2510 SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); | 2445 SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); |
| 2511 while (width > 0) { | 2446 while (width > 0) { |
| 2512 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2447 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2513 I422ToARGBRow_SSSE3(src_y, src_u, src_v, row, twidth); | 2448 I422ToARGBRow_SSSE3(src_y, src_u, src_v, row, yuvconstants, twidth); |
| 2514 ARGBToARGB4444Row_SSE2(row, dst_argb4444, twidth); | 2449 ARGBToARGB4444Row_SSE2(row, dst_argb4444, twidth); |
| 2515 src_y += twidth; | 2450 src_y += twidth; |
| 2516 src_u += twidth / 2; | 2451 src_u += twidth / 2; |
| 2517 src_v += twidth / 2; | 2452 src_v += twidth / 2; |
| 2518 dst_argb4444 += twidth * 2; | 2453 dst_argb4444 += twidth * 2; |
| 2519 width -= twidth; | 2454 width -= twidth; |
| 2520 } | 2455 } |
| 2521 } | 2456 } |
| 2522 #endif | 2457 #endif |
| 2523 | 2458 |
| 2524 #if defined(HAS_NV12TORGB565ROW_SSSE3) | 2459 #if defined(HAS_NV12TORGB565ROW_SSSE3) |
| 2525 void NV12ToRGB565Row_SSSE3(const uint8* src_y, const uint8* src_uv, | 2460 void NV12ToRGB565Row_SSSE3(const uint8* src_y, |
| 2526 uint8* dst_rgb565, int width) { | 2461 const uint8* src_uv, |
| 2462 uint8* dst_rgb565, |
| 2463 struct YuvConstants* yuvconstants, |
| 2464 int width) { |
| 2527 // Row buffer for intermediate ARGB pixels. | 2465 // Row buffer for intermediate ARGB pixels. |
| 2528 SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); | 2466 SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); |
| 2529 while (width > 0) { | 2467 while (width > 0) { |
| 2530 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2468 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2531 NV12ToARGBRow_SSSE3(src_y, src_uv, row, twidth); | 2469 NV12ToARGBRow_SSSE3(src_y, src_uv, row, yuvconstants, twidth); |
| 2532 ARGBToRGB565Row_SSE2(row, dst_rgb565, twidth); | 2470 ARGBToRGB565Row_SSE2(row, dst_rgb565, twidth); |
| 2533 src_y += twidth; | 2471 src_y += twidth; |
| 2534 src_uv += twidth; | 2472 src_uv += twidth; |
| 2535 dst_rgb565 += twidth * 2; | 2473 dst_rgb565 += twidth * 2; |
| 2536 width -= twidth; | 2474 width -= twidth; |
| 2537 } | 2475 } |
| 2538 } | 2476 } |
| 2539 #endif | 2477 #endif |
| 2540 | 2478 |
| 2541 #if defined(HAS_NV21TORGB565ROW_SSSE3) | |
| 2542 void NV21ToRGB565Row_SSSE3(const uint8* src_y, const uint8* src_vu, | |
| 2543 uint8* dst_rgb565, int width) { | |
| 2544 // Row buffer for intermediate ARGB pixels. | |
| 2545 SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); | |
| 2546 while (width > 0) { | |
| 2547 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | |
| 2548 NV21ToARGBRow_SSSE3(src_y, src_vu, row, twidth); | |
| 2549 ARGBToRGB565Row_SSE2(row, dst_rgb565, twidth); | |
| 2550 src_y += twidth; | |
| 2551 src_vu += twidth; | |
| 2552 dst_rgb565 += twidth * 2; | |
| 2553 width -= twidth; | |
| 2554 } | |
| 2555 } | |
| 2556 #endif | |
| 2557 | |
| 2558 #if defined(HAS_YUY2TOARGBROW_SSSE3) | 2479 #if defined(HAS_YUY2TOARGBROW_SSSE3) |
| 2559 void YUY2ToARGBRow_SSSE3(const uint8* src_yuy2, uint8* dst_argb, int width) { | 2480 void YUY2ToARGBRow_SSSE3(const uint8* src_yuy2, |
| 2481 uint8* dst_argb, |
| 2482 struct YuvConstants* yuvconstants, |
| 2483 int width) { |
| 2560 // Row buffers for intermediate YUV pixels. | 2484 // Row buffers for intermediate YUV pixels. |
| 2561 SIMD_ALIGNED(uint8 row_y[MAXTWIDTH]); | 2485 SIMD_ALIGNED(uint8 row_y[MAXTWIDTH]); |
| 2562 SIMD_ALIGNED(uint8 row_u[MAXTWIDTH / 2]); | 2486 SIMD_ALIGNED(uint8 row_u[MAXTWIDTH / 2]); |
| 2563 SIMD_ALIGNED(uint8 row_v[MAXTWIDTH / 2]); | 2487 SIMD_ALIGNED(uint8 row_v[MAXTWIDTH / 2]); |
| 2564 while (width > 0) { | 2488 while (width > 0) { |
| 2565 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2489 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2566 YUY2ToUV422Row_SSE2(src_yuy2, row_u, row_v, twidth); | 2490 YUY2ToUV422Row_SSE2(src_yuy2, row_u, row_v, twidth); |
| 2567 YUY2ToYRow_SSE2(src_yuy2, row_y, twidth); | 2491 YUY2ToYRow_SSE2(src_yuy2, row_y, twidth); |
| 2568 I422ToARGBRow_SSSE3(row_y, row_u, row_v, dst_argb, twidth); | 2492 I422ToARGBRow_SSSE3(row_y, row_u, row_v, dst_argb, yuvconstants, twidth); |
| 2569 src_yuy2 += twidth * 2; | 2493 src_yuy2 += twidth * 2; |
| 2570 dst_argb += twidth * 4; | 2494 dst_argb += twidth * 4; |
| 2571 width -= twidth; | 2495 width -= twidth; |
| 2572 } | 2496 } |
| 2573 } | 2497 } |
| 2574 #endif | 2498 #endif |
| 2575 | 2499 |
| 2576 #if defined(HAS_UYVYTOARGBROW_SSSE3) | 2500 #if defined(HAS_UYVYTOARGBROW_SSSE3) |
| 2577 void UYVYToARGBRow_SSSE3(const uint8* src_uyvy, uint8* dst_argb, int width) { | 2501 void UYVYToARGBRow_SSSE3(const uint8* src_uyvy, |
| 2502 uint8* dst_argb, |
| 2503 struct YuvConstants* yuvconstants, |
| 2504 int width) { |
| 2578 // Row buffers for intermediate YUV pixels. | 2505 // Row buffers for intermediate YUV pixels. |
| 2579 SIMD_ALIGNED(uint8 row_y[MAXTWIDTH]); | 2506 SIMD_ALIGNED(uint8 row_y[MAXTWIDTH]); |
| 2580 SIMD_ALIGNED(uint8 row_u[MAXTWIDTH / 2]); | 2507 SIMD_ALIGNED(uint8 row_u[MAXTWIDTH / 2]); |
| 2581 SIMD_ALIGNED(uint8 row_v[MAXTWIDTH / 2]); | 2508 SIMD_ALIGNED(uint8 row_v[MAXTWIDTH / 2]); |
| 2582 while (width > 0) { | 2509 while (width > 0) { |
| 2583 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2510 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2584 UYVYToUV422Row_SSE2(src_uyvy, row_u, row_v, twidth); | 2511 UYVYToUV422Row_SSE2(src_uyvy, row_u, row_v, twidth); |
| 2585 UYVYToYRow_SSE2(src_uyvy, row_y, twidth); | 2512 UYVYToYRow_SSE2(src_uyvy, row_y, twidth); |
| 2586 I422ToARGBRow_SSSE3(row_y, row_u, row_v, dst_argb, twidth); | 2513 I422ToARGBRow_SSSE3(row_y, row_u, row_v, dst_argb, yuvconstants, twidth); |
| 2587 src_uyvy += twidth * 2; | 2514 src_uyvy += twidth * 2; |
| 2588 dst_argb += twidth * 4; | 2515 dst_argb += twidth * 4; |
| 2589 width -= twidth; | 2516 width -= twidth; |
| 2590 } | 2517 } |
| 2591 } | 2518 } |
| 2592 #endif // !defined(LIBYUV_DISABLE_X86) | 2519 #endif // !defined(LIBYUV_DISABLE_X86) |
| 2593 | 2520 |
| 2594 #if defined(HAS_I422TORGB565ROW_AVX2) | 2521 #if defined(HAS_I422TORGB565ROW_AVX2) |
| 2595 void I422ToRGB565Row_AVX2(const uint8* src_y, | 2522 void I422ToRGB565Row_AVX2(const uint8* src_y, |
| 2596 const uint8* src_u, | 2523 const uint8* src_u, |
| 2597 const uint8* src_v, | 2524 const uint8* src_v, |
| 2598 uint8* dst_rgb565, | 2525 uint8* dst_rgb565, |
| 2526 struct YuvConstants* yuvconstants, |
| 2599 int width) { | 2527 int width) { |
| 2600 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); | 2528 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); |
| 2601 while (width > 0) { | 2529 while (width > 0) { |
| 2602 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2530 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2603 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, twidth); | 2531 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, yuvconstants, twidth); |
| 2604 ARGBToRGB565Row_AVX2(row, dst_rgb565, twidth); | 2532 ARGBToRGB565Row_AVX2(row, dst_rgb565, twidth); |
| 2605 src_y += twidth; | 2533 src_y += twidth; |
| 2606 src_u += twidth / 2; | 2534 src_u += twidth / 2; |
| 2607 src_v += twidth / 2; | 2535 src_v += twidth / 2; |
| 2608 dst_rgb565 += twidth * 2; | 2536 dst_rgb565 += twidth * 2; |
| 2609 width -= twidth; | 2537 width -= twidth; |
| 2610 } | 2538 } |
| 2611 } | 2539 } |
| 2612 #endif | 2540 #endif |
| 2613 | 2541 |
| 2614 #if defined(HAS_I422TOARGB1555ROW_AVX2) | 2542 #if defined(HAS_I422TOARGB1555ROW_AVX2) |
| 2615 void I422ToARGB1555Row_AVX2(const uint8* src_y, | 2543 void I422ToARGB1555Row_AVX2(const uint8* src_y, |
| 2616 const uint8* src_u, | 2544 const uint8* src_u, |
| 2617 const uint8* src_v, | 2545 const uint8* src_v, |
| 2618 uint8* dst_argb1555, | 2546 uint8* dst_argb1555, |
| 2547 struct YuvConstants* yuvconstants, |
| 2619 int width) { | 2548 int width) { |
| 2620 // Row buffer for intermediate ARGB pixels. | 2549 // Row buffer for intermediate ARGB pixels. |
| 2621 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); | 2550 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); |
| 2622 while (width > 0) { | 2551 while (width > 0) { |
| 2623 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2552 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2624 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, twidth); | 2553 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, yuvconstants, twidth); |
| 2625 ARGBToARGB1555Row_AVX2(row, dst_argb1555, twidth); | 2554 ARGBToARGB1555Row_AVX2(row, dst_argb1555, twidth); |
| 2626 src_y += twidth; | 2555 src_y += twidth; |
| 2627 src_u += twidth / 2; | 2556 src_u += twidth / 2; |
| 2628 src_v += twidth / 2; | 2557 src_v += twidth / 2; |
| 2629 dst_argb1555 += twidth * 2; | 2558 dst_argb1555 += twidth * 2; |
| 2630 width -= twidth; | 2559 width -= twidth; |
| 2631 } | 2560 } |
| 2632 } | 2561 } |
| 2633 #endif | 2562 #endif |
| 2634 | 2563 |
| 2635 #if defined(HAS_I422TOARGB4444ROW_AVX2) | 2564 #if defined(HAS_I422TOARGB4444ROW_AVX2) |
| 2636 void I422ToARGB4444Row_AVX2(const uint8* src_y, | 2565 void I422ToARGB4444Row_AVX2(const uint8* src_y, |
| 2637 const uint8* src_u, | 2566 const uint8* src_u, |
| 2638 const uint8* src_v, | 2567 const uint8* src_v, |
| 2639 uint8* dst_argb4444, | 2568 uint8* dst_argb4444, |
| 2569 struct YuvConstants* yuvconstants, |
| 2640 int width) { | 2570 int width) { |
| 2641 // Row buffer for intermediate ARGB pixels. | 2571 // Row buffer for intermediate ARGB pixels. |
| 2642 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); | 2572 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); |
| 2643 while (width > 0) { | 2573 while (width > 0) { |
| 2644 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2574 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2645 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, twidth); | 2575 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, yuvconstants, twidth); |
| 2646 ARGBToARGB4444Row_AVX2(row, dst_argb4444, twidth); | 2576 ARGBToARGB4444Row_AVX2(row, dst_argb4444, twidth); |
| 2647 src_y += twidth; | 2577 src_y += twidth; |
| 2648 src_u += twidth / 2; | 2578 src_u += twidth / 2; |
| 2649 src_v += twidth / 2; | 2579 src_v += twidth / 2; |
| 2650 dst_argb4444 += twidth * 2; | 2580 dst_argb4444 += twidth * 2; |
| 2651 width -= twidth; | 2581 width -= twidth; |
| 2652 } | 2582 } |
| 2653 } | 2583 } |
| 2654 #endif | 2584 #endif |
| 2655 | 2585 |
| 2656 #if defined(HAS_I422TORGB24ROW_AVX2) | 2586 #if defined(HAS_I422TORGB24ROW_AVX2) |
| 2657 void I422ToRGB24Row_AVX2(const uint8* src_y, | 2587 void I422ToRGB24Row_AVX2(const uint8* src_y, |
| 2658 const uint8* src_u, | 2588 const uint8* src_u, |
| 2659 const uint8* src_v, | 2589 const uint8* src_v, |
| 2660 uint8* dst_rgb24, | 2590 uint8* dst_rgb24, |
| 2591 struct YuvConstants* yuvconstants, |
| 2661 int width) { | 2592 int width) { |
| 2662 // Row buffer for intermediate ARGB pixels. | 2593 // Row buffer for intermediate ARGB pixels. |
| 2663 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); | 2594 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); |
| 2664 while (width > 0) { | 2595 while (width > 0) { |
| 2665 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2596 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2666 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, twidth); | 2597 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, yuvconstants, twidth); |
| 2667 // TODO(fbarchard): ARGBToRGB24Row_AVX2 | 2598 // TODO(fbarchard): ARGBToRGB24Row_AVX2 |
| 2668 ARGBToRGB24Row_SSSE3(row, dst_rgb24, twidth); | 2599 ARGBToRGB24Row_SSSE3(row, dst_rgb24, twidth); |
| 2669 src_y += twidth; | 2600 src_y += twidth; |
| 2670 src_u += twidth / 2; | 2601 src_u += twidth / 2; |
| 2671 src_v += twidth / 2; | 2602 src_v += twidth / 2; |
| 2672 dst_rgb24 += twidth * 3; | 2603 dst_rgb24 += twidth * 3; |
| 2673 width -= twidth; | 2604 width -= twidth; |
| 2674 } | 2605 } |
| 2675 } | 2606 } |
| 2676 #endif | 2607 #endif |
| 2677 | 2608 |
| 2678 #if defined(HAS_I422TORAWROW_AVX2) | 2609 #if defined(HAS_I422TORAWROW_AVX2) |
| 2679 void I422ToRAWRow_AVX2(const uint8* src_y, | 2610 void I422ToRAWRow_AVX2(const uint8* src_y, |
| 2680 const uint8* src_u, | 2611 const uint8* src_u, |
| 2681 const uint8* src_v, | 2612 const uint8* src_v, |
| 2682 uint8* dst_raw, | 2613 uint8* dst_raw, |
| 2614 struct YuvConstants* yuvconstants, |
| 2683 int width) { | 2615 int width) { |
| 2684 // Row buffer for intermediate ARGB pixels. | 2616 // Row buffer for intermediate ARGB pixels. |
| 2685 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); | 2617 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); |
| 2686 while (width > 0) { | 2618 while (width > 0) { |
| 2687 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2619 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2688 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, twidth); | 2620 I422ToARGBRow_AVX2(src_y, src_u, src_v, row, yuvconstants, twidth); |
| 2689 // TODO(fbarchard): ARGBToRAWRow_AVX2 | 2621 // TODO(fbarchard): ARGBToRAWRow_AVX2 |
| 2690 ARGBToRAWRow_SSSE3(row, dst_raw, twidth); | 2622 ARGBToRAWRow_SSSE3(row, dst_raw, twidth); |
| 2691 src_y += twidth; | 2623 src_y += twidth; |
| 2692 src_u += twidth / 2; | 2624 src_u += twidth / 2; |
| 2693 src_v += twidth / 2; | 2625 src_v += twidth / 2; |
| 2694 dst_raw += twidth * 3; | 2626 dst_raw += twidth * 3; |
| 2695 width -= twidth; | 2627 width -= twidth; |
| 2696 } | 2628 } |
| 2697 } | 2629 } |
| 2698 #endif | 2630 #endif |
| 2699 | 2631 |
| 2700 #if defined(HAS_NV12TORGB565ROW_AVX2) | 2632 #if defined(HAS_NV12TORGB565ROW_AVX2) |
| 2701 void NV12ToRGB565Row_AVX2(const uint8* src_y, const uint8* src_uv, | 2633 void NV12ToRGB565Row_AVX2(const uint8* src_y, |
| 2702 uint8* dst_rgb565, int width) { | 2634 const uint8* src_uv, |
| 2635 uint8* dst_rgb565, |
| 2636 struct YuvConstants* yuvconstants, |
| 2637 int width) { |
| 2703 // Row buffer for intermediate ARGB pixels. | 2638 // Row buffer for intermediate ARGB pixels. |
| 2704 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); | 2639 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); |
| 2705 while (width > 0) { | 2640 while (width > 0) { |
| 2706 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2641 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2707 NV12ToARGBRow_AVX2(src_y, src_uv, row, twidth); | 2642 NV12ToARGBRow_AVX2(src_y, src_uv, row, yuvconstants, twidth); |
| 2708 ARGBToRGB565Row_AVX2(row, dst_rgb565, twidth); | 2643 ARGBToRGB565Row_AVX2(row, dst_rgb565, twidth); |
| 2709 src_y += twidth; | 2644 src_y += twidth; |
| 2710 src_uv += twidth; | 2645 src_uv += twidth; |
| 2711 dst_rgb565 += twidth * 2; | 2646 dst_rgb565 += twidth * 2; |
| 2712 width -= twidth; | 2647 width -= twidth; |
| 2713 } | 2648 } |
| 2714 } | 2649 } |
| 2715 #endif | 2650 #endif |
| 2716 | 2651 |
| 2717 #if defined(HAS_NV21TORGB565ROW_AVX2) | |
| 2718 void NV21ToRGB565Row_AVX2(const uint8* src_y, const uint8* src_vu, | |
| 2719 uint8* dst_rgb565, int width) { | |
| 2720 // Row buffer for intermediate ARGB pixels. | |
| 2721 SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); | |
| 2722 while (width > 0) { | |
| 2723 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | |
| 2724 NV21ToARGBRow_AVX2(src_y, src_vu, row, twidth); | |
| 2725 ARGBToRGB565Row_AVX2(row, dst_rgb565, twidth); | |
| 2726 src_y += twidth; | |
| 2727 src_vu += twidth; | |
| 2728 dst_rgb565 += twidth * 2; | |
| 2729 width -= twidth; | |
| 2730 } | |
| 2731 } | |
| 2732 #endif | |
| 2733 | |
| 2734 #if defined(HAS_YUY2TOARGBROW_AVX2) | 2652 #if defined(HAS_YUY2TOARGBROW_AVX2) |
| 2735 void YUY2ToARGBRow_AVX2(const uint8* src_yuy2, uint8* dst_argb, int width) { | 2653 void YUY2ToARGBRow_AVX2(const uint8* src_yuy2, |
| 2654 uint8* dst_argb, |
| 2655 struct YuvConstants* yuvconstants, |
| 2656 int width) { |
| 2736 // Row buffers for intermediate YUV pixels. | 2657 // Row buffers for intermediate YUV pixels. |
| 2737 SIMD_ALIGNED32(uint8 row_y[MAXTWIDTH]); | 2658 SIMD_ALIGNED32(uint8 row_y[MAXTWIDTH]); |
| 2738 SIMD_ALIGNED32(uint8 row_u[MAXTWIDTH / 2]); | 2659 SIMD_ALIGNED32(uint8 row_u[MAXTWIDTH / 2]); |
| 2739 SIMD_ALIGNED32(uint8 row_v[MAXTWIDTH / 2]); | 2660 SIMD_ALIGNED32(uint8 row_v[MAXTWIDTH / 2]); |
| 2740 while (width > 0) { | 2661 while (width > 0) { |
| 2741 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2662 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2742 YUY2ToUV422Row_AVX2(src_yuy2, row_u, row_v, twidth); | 2663 YUY2ToUV422Row_AVX2(src_yuy2, row_u, row_v, twidth); |
| 2743 YUY2ToYRow_AVX2(src_yuy2, row_y, twidth); | 2664 YUY2ToYRow_AVX2(src_yuy2, row_y, twidth); |
| 2744 I422ToARGBRow_AVX2(row_y, row_u, row_v, dst_argb, twidth); | 2665 I422ToARGBRow_AVX2(row_y, row_u, row_v, dst_argb, yuvconstants, twidth); |
| 2745 src_yuy2 += twidth * 2; | 2666 src_yuy2 += twidth * 2; |
| 2746 dst_argb += twidth * 4; | 2667 dst_argb += twidth * 4; |
| 2747 width -= twidth; | 2668 width -= twidth; |
| 2748 } | 2669 } |
| 2749 } | 2670 } |
| 2750 #endif | 2671 #endif |
| 2751 | 2672 |
| 2752 #if defined(HAS_UYVYTOARGBROW_AVX2) | 2673 #if defined(HAS_UYVYTOARGBROW_AVX2) |
| 2753 void UYVYToARGBRow_AVX2(const uint8* src_uyvy, uint8* dst_argb, int width) { | 2674 void UYVYToARGBRow_AVX2(const uint8* src_uyvy, |
| 2675 uint8* dst_argb, |
| 2676 struct YuvConstants* yuvconstants, |
| 2677 int width) { |
| 2754 // Row buffers for intermediate YUV pixels. | 2678 // Row buffers for intermediate YUV pixels. |
| 2755 SIMD_ALIGNED32(uint8 row_y[MAXTWIDTH]); | 2679 SIMD_ALIGNED32(uint8 row_y[MAXTWIDTH]); |
| 2756 SIMD_ALIGNED32(uint8 row_u[MAXTWIDTH / 2]); | 2680 SIMD_ALIGNED32(uint8 row_u[MAXTWIDTH / 2]); |
| 2757 SIMD_ALIGNED32(uint8 row_v[MAXTWIDTH / 2]); | 2681 SIMD_ALIGNED32(uint8 row_v[MAXTWIDTH / 2]); |
| 2758 while (width > 0) { | 2682 while (width > 0) { |
| 2759 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; | 2683 int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; |
| 2760 UYVYToUV422Row_AVX2(src_uyvy, row_u, row_v, twidth); | 2684 UYVYToUV422Row_AVX2(src_uyvy, row_u, row_v, twidth); |
| 2761 UYVYToYRow_AVX2(src_uyvy, row_y, twidth); | 2685 UYVYToYRow_AVX2(src_uyvy, row_y, twidth); |
| 2762 I422ToARGBRow_AVX2(row_y, row_u, row_v, dst_argb, twidth); | 2686 I422ToARGBRow_AVX2(row_y, row_u, row_v, dst_argb, yuvconstants, twidth); |
| 2763 src_uyvy += twidth * 2; | 2687 src_uyvy += twidth * 2; |
| 2764 dst_argb += twidth * 4; | 2688 dst_argb += twidth * 4; |
| 2765 width -= twidth; | 2689 width -= twidth; |
| 2766 } | 2690 } |
| 2767 } | 2691 } |
| 2768 #endif // !defined(LIBYUV_DISABLE_X86) | 2692 #endif // !defined(LIBYUV_DISABLE_X86) |
| 2769 | 2693 |
| 2770 void ARGBPolynomialRow_C(const uint8* src_argb, | |
| 2771 uint8* dst_argb, const float* poly, | |
| 2772 int width) { | |
| 2773 int i; | |
| 2774 for (i = 0; i < width; ++i) { | |
| 2775 float b = (float)(src_argb[0]); | |
| 2776 float g = (float)(src_argb[1]); | |
| 2777 float r = (float)(src_argb[2]); | |
| 2778 float a = (float)(src_argb[3]); | |
| 2779 float b2 = b * b; | |
| 2780 float g2 = g * g; | |
| 2781 float r2 = r * r; | |
| 2782 float a2 = a * a; | |
| 2783 float db = poly[0] + poly[4] * b; | |
| 2784 float dg = poly[1] + poly[5] * g; | |
| 2785 float dr = poly[2] + poly[6] * r; | |
| 2786 float da = poly[3] + poly[7] * a; | |
| 2787 float b3 = b2 * b; | |
| 2788 float g3 = g2 * g; | |
| 2789 float r3 = r2 * r; | |
| 2790 float a3 = a2 * a; | |
| 2791 db += poly[8] * b2; | |
| 2792 dg += poly[9] * g2; | |
| 2793 dr += poly[10] * r2; | |
| 2794 da += poly[11] * a2; | |
| 2795 db += poly[12] * b3; | |
| 2796 dg += poly[13] * g3; | |
| 2797 dr += poly[14] * r3; | |
| 2798 da += poly[15] * a3; | |
| 2799 | |
| 2800 dst_argb[0] = Clamp((int32)(db)); | |
| 2801 dst_argb[1] = Clamp((int32)(dg)); | |
| 2802 dst_argb[2] = Clamp((int32)(dr)); | |
| 2803 dst_argb[3] = Clamp((int32)(da)); | |
| 2804 src_argb += 4; | |
| 2805 dst_argb += 4; | |
| 2806 } | |
| 2807 } | |
| 2808 | |
| 2809 void ARGBLumaColorTableRow_C(const uint8* src_argb, uint8* dst_argb, int width, | |
| 2810 const uint8* luma, uint32 lumacoeff) { | |
| 2811 uint32 bc = lumacoeff & 0xff; | |
| 2812 uint32 gc = (lumacoeff >> 8) & 0xff; | |
| 2813 uint32 rc = (lumacoeff >> 16) & 0xff; | |
| 2814 | |
| 2815 int i; | |
| 2816 for (i = 0; i < width - 1; i += 2) { | |
| 2817 // Luminance in rows, color values in columns. | |
| 2818 const uint8* luma0 = ((src_argb[0] * bc + src_argb[1] * gc + | |
| 2819 src_argb[2] * rc) & 0x7F00u) + luma; | |
| 2820 const uint8* luma1; | |
| 2821 dst_argb[0] = luma0[src_argb[0]]; | |
| 2822 dst_argb[1] = luma0[src_argb[1]]; | |
| 2823 dst_argb[2] = luma0[src_argb[2]]; | |
| 2824 dst_argb[3] = src_argb[3]; | |
| 2825 luma1 = ((src_argb[4] * bc + src_argb[5] * gc + | |
| 2826 src_argb[6] * rc) & 0x7F00u) + luma; | |
| 2827 dst_argb[4] = luma1[src_argb[4]]; | |
| 2828 dst_argb[5] = luma1[src_argb[5]]; | |
| 2829 dst_argb[6] = luma1[src_argb[6]]; | |
| 2830 dst_argb[7] = src_argb[7]; | |
| 2831 src_argb += 8; | |
| 2832 dst_argb += 8; | |
| 2833 } | |
| 2834 if (width & 1) { | |
| 2835 // Luminance in rows, color values in columns. | |
| 2836 const uint8* luma0 = ((src_argb[0] * bc + src_argb[1] * gc + | |
| 2837 src_argb[2] * rc) & 0x7F00u) + luma; | |
| 2838 dst_argb[0] = luma0[src_argb[0]]; | |
| 2839 dst_argb[1] = luma0[src_argb[1]]; | |
| 2840 dst_argb[2] = luma0[src_argb[2]]; | |
| 2841 dst_argb[3] = src_argb[3]; | |
| 2842 } | |
| 2843 } | |
| 2844 | |
| 2845 void ARGBCopyAlphaRow_C(const uint8* src, uint8* dst, int width) { | |
| 2846 int i; | |
| 2847 for (i = 0; i < width - 1; i += 2) { | |
| 2848 dst[3] = src[3]; | |
| 2849 dst[7] = src[7]; | |
| 2850 dst += 8; | |
| 2851 src += 8; | |
| 2852 } | |
| 2853 if (width & 1) { | |
| 2854 dst[3] = src[3]; | |
| 2855 } | |
| 2856 } | |
| 2857 | |
| 2858 void ARGBCopyYToAlphaRow_C(const uint8* src, uint8* dst, int width) { | |
| 2859 int i; | |
| 2860 for (i = 0; i < width - 1; i += 2) { | |
| 2861 dst[3] = src[0]; | |
| 2862 dst[7] = src[1]; | |
| 2863 dst += 8; | |
| 2864 src += 2; | |
| 2865 } | |
| 2866 if (width & 1) { | |
| 2867 dst[3] = src[0]; | |
| 2868 } | |
| 2869 } | |
| 2870 | |
| 2871 #ifdef __cplusplus | 2694 #ifdef __cplusplus |
| 2872 } // extern "C" | 2695 } // extern "C" |
| 2873 } // namespace libyuv | 2696 } // namespace libyuv |
| 2874 #endif | 2697 #endif |
| OLD | NEW |