Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: source/convert.cc

Issue 2600713002: Add MSA optimized RAW/RGB/ARGB to ARGB/Y/UV row functions (Closed)
Patch Set: Resolved merge conflicts Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/libyuv/row.h ('k') | source/convert_argb.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 int src_stride_rgb24, 889 int src_stride_rgb24,
890 uint8* dst_y, 890 uint8* dst_y,
891 int dst_stride_y, 891 int dst_stride_y,
892 uint8* dst_u, 892 uint8* dst_u,
893 int dst_stride_u, 893 int dst_stride_u,
894 uint8* dst_v, 894 uint8* dst_v,
895 int dst_stride_v, 895 int dst_stride_v,
896 int width, 896 int width,
897 int height) { 897 int height) {
898 int y; 898 int y;
899 #if defined(HAS_RGB24TOYROW_NEON) 899 #if (defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA))
900 void (*RGB24ToUVRow)(const uint8* src_rgb24, int src_stride_rgb24, 900 void (*RGB24ToUVRow)(const uint8* src_rgb24, int src_stride_rgb24,
901 uint8* dst_u, uint8* dst_v, int width) = RGB24ToUVRow_C; 901 uint8* dst_u, uint8* dst_v, int width) = RGB24ToUVRow_C;
902 void (*RGB24ToYRow)(const uint8* src_rgb24, uint8* dst_y, int width) = 902 void (*RGB24ToYRow)(const uint8* src_rgb24, uint8* dst_y, int width) =
903 RGB24ToYRow_C; 903 RGB24ToYRow_C;
904 #else 904 #else
905 void (*RGB24ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) = 905 void (*RGB24ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
906 RGB24ToARGBRow_C; 906 RGB24ToARGBRow_C;
907 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u, 907 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u,
908 uint8* dst_v, int width) = ARGBToUVRow_C; 908 uint8* dst_v, int width) = ARGBToUVRow_C;
909 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = 909 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
(...skipping 14 matching lines...) Expand all
924 if (TestCpuFlag(kCpuHasNEON)) { 924 if (TestCpuFlag(kCpuHasNEON)) {
925 RGB24ToUVRow = RGB24ToUVRow_Any_NEON; 925 RGB24ToUVRow = RGB24ToUVRow_Any_NEON;
926 RGB24ToYRow = RGB24ToYRow_Any_NEON; 926 RGB24ToYRow = RGB24ToYRow_Any_NEON;
927 if (IS_ALIGNED(width, 8)) { 927 if (IS_ALIGNED(width, 8)) {
928 RGB24ToYRow = RGB24ToYRow_NEON; 928 RGB24ToYRow = RGB24ToYRow_NEON;
929 if (IS_ALIGNED(width, 16)) { 929 if (IS_ALIGNED(width, 16)) {
930 RGB24ToUVRow = RGB24ToUVRow_NEON; 930 RGB24ToUVRow = RGB24ToUVRow_NEON;
931 } 931 }
932 } 932 }
933 } 933 }
934 #elif defined(HAS_RGB24TOYROW_MSA)
935 if (TestCpuFlag(kCpuHasMSA)) {
936 RGB24ToUVRow = RGB24ToUVRow_Any_MSA;
937 RGB24ToYRow = RGB24ToYRow_Any_MSA;
938 if (IS_ALIGNED(width, 16)) {
939 RGB24ToYRow = RGB24ToYRow_MSA;
940 RGB24ToUVRow = RGB24ToUVRow_MSA;
941 }
942 }
934 // Other platforms do intermediate conversion from RGB24 to ARGB. 943 // Other platforms do intermediate conversion from RGB24 to ARGB.
935 #else 944 #else
936 #if defined(HAS_RGB24TOARGBROW_SSSE3) 945 #if defined(HAS_RGB24TOARGBROW_SSSE3)
937 if (TestCpuFlag(kCpuHasSSSE3)) { 946 if (TestCpuFlag(kCpuHasSSSE3)) {
938 RGB24ToARGBRow = RGB24ToARGBRow_Any_SSSE3; 947 RGB24ToARGBRow = RGB24ToARGBRow_Any_SSSE3;
939 if (IS_ALIGNED(width, 16)) { 948 if (IS_ALIGNED(width, 16)) {
940 RGB24ToARGBRow = RGB24ToARGBRow_SSSE3; 949 RGB24ToARGBRow = RGB24ToARGBRow_SSSE3;
941 } 950 }
942 } 951 }
943 #endif 952 #endif
(...skipping 17 matching lines...) Expand all
961 } 970 }
962 } 971 }
963 #endif 972 #endif
964 { 973 {
965 // Allocate 2 rows of ARGB. 974 // Allocate 2 rows of ARGB.
966 const int kRowSize = (width * 4 + 31) & ~31; 975 const int kRowSize = (width * 4 + 31) & ~31;
967 align_buffer_64(row, kRowSize * 2); 976 align_buffer_64(row, kRowSize * 2);
968 #endif 977 #endif
969 978
970 for (y = 0; y < height - 1; y += 2) { 979 for (y = 0; y < height - 1; y += 2) {
971 #if defined(HAS_RGB24TOYROW_NEON) 980 #if (defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA))
972 RGB24ToUVRow(src_rgb24, src_stride_rgb24, dst_u, dst_v, width); 981 RGB24ToUVRow(src_rgb24, src_stride_rgb24, dst_u, dst_v, width);
973 RGB24ToYRow(src_rgb24, dst_y, width); 982 RGB24ToYRow(src_rgb24, dst_y, width);
974 RGB24ToYRow(src_rgb24 + src_stride_rgb24, dst_y + dst_stride_y, width); 983 RGB24ToYRow(src_rgb24 + src_stride_rgb24, dst_y + dst_stride_y, width);
975 #else 984 #else
976 RGB24ToARGBRow(src_rgb24, row, width); 985 RGB24ToARGBRow(src_rgb24, row, width);
977 RGB24ToARGBRow(src_rgb24 + src_stride_rgb24, row + kRowSize, width); 986 RGB24ToARGBRow(src_rgb24 + src_stride_rgb24, row + kRowSize, width);
978 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); 987 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
979 ARGBToYRow(row, dst_y, width); 988 ARGBToYRow(row, dst_y, width);
980 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); 989 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
981 #endif 990 #endif
982 src_rgb24 += src_stride_rgb24 * 2; 991 src_rgb24 += src_stride_rgb24 * 2;
983 dst_y += dst_stride_y * 2; 992 dst_y += dst_stride_y * 2;
984 dst_u += dst_stride_u; 993 dst_u += dst_stride_u;
985 dst_v += dst_stride_v; 994 dst_v += dst_stride_v;
986 } 995 }
987 if (height & 1) { 996 if (height & 1) {
988 #if defined(HAS_RGB24TOYROW_NEON) 997 #if (defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA))
989 RGB24ToUVRow(src_rgb24, 0, dst_u, dst_v, width); 998 RGB24ToUVRow(src_rgb24, 0, dst_u, dst_v, width);
990 RGB24ToYRow(src_rgb24, dst_y, width); 999 RGB24ToYRow(src_rgb24, dst_y, width);
991 #else 1000 #else
992 RGB24ToARGBRow(src_rgb24, row, width); 1001 RGB24ToARGBRow(src_rgb24, row, width);
993 ARGBToUVRow(row, 0, dst_u, dst_v, width); 1002 ARGBToUVRow(row, 0, dst_u, dst_v, width);
994 ARGBToYRow(row, dst_y, width); 1003 ARGBToYRow(row, dst_y, width);
995 #endif 1004 #endif
996 } 1005 }
997 #if !defined(HAS_RGB24TOYROW_NEON) 1006 #if !(defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA))
998 free_aligned_buffer_64(row); 1007 free_aligned_buffer_64(row);
999 } 1008 }
1000 #endif 1009 #endif
1001 return 0; 1010 return 0;
1002 } 1011 }
1003 1012
1004 // Convert RAW to I420. 1013 // Convert RAW to I420.
1005 LIBYUV_API 1014 LIBYUV_API
1006 int RAWToI420(const uint8* src_raw, 1015 int RAWToI420(const uint8* src_raw,
1007 int src_stride_raw, 1016 int src_stride_raw,
1008 uint8* dst_y, 1017 uint8* dst_y,
1009 int dst_stride_y, 1018 int dst_stride_y,
1010 uint8* dst_u, 1019 uint8* dst_u,
1011 int dst_stride_u, 1020 int dst_stride_u,
1012 uint8* dst_v, 1021 uint8* dst_v,
1013 int dst_stride_v, 1022 int dst_stride_v,
1014 int width, 1023 int width,
1015 int height) { 1024 int height) {
1016 int y; 1025 int y;
1017 #if defined(HAS_RAWTOYROW_NEON) 1026 #if (defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA))
1018 void (*RAWToUVRow)(const uint8* src_raw, int src_stride_raw, uint8* dst_u, 1027 void (*RAWToUVRow)(const uint8* src_raw, int src_stride_raw, uint8* dst_u,
1019 uint8* dst_v, int width) = RAWToUVRow_C; 1028 uint8* dst_v, int width) = RAWToUVRow_C;
1020 void (*RAWToYRow)(const uint8* src_raw, uint8* dst_y, int width) = 1029 void (*RAWToYRow)(const uint8* src_raw, uint8* dst_y, int width) =
1021 RAWToYRow_C; 1030 RAWToYRow_C;
1022 #else 1031 #else
1023 void (*RAWToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) = 1032 void (*RAWToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
1024 RAWToARGBRow_C; 1033 RAWToARGBRow_C;
1025 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, 1034 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u,
1026 uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; 1035 uint8* dst_v, int width) = ARGBToUVRow_C;
1027 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = 1036 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
1028 ARGBToYRow_C; 1037 ARGBToYRow_C;
1029 #endif 1038 #endif
1030 if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { 1039 if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
1031 return -1; 1040 return -1;
1032 } 1041 }
1033 // Negative height means invert the image. 1042 // Negative height means invert the image.
1034 if (height < 0) { 1043 if (height < 0) {
1035 height = -height; 1044 height = -height;
1036 src_raw = src_raw + (height - 1) * src_stride_raw; 1045 src_raw = src_raw + (height - 1) * src_stride_raw;
1037 src_stride_raw = -src_stride_raw; 1046 src_stride_raw = -src_stride_raw;
1038 } 1047 }
1039 1048
1040 // Neon version does direct RAW to YUV. 1049 // Neon version does direct RAW to YUV.
1041 #if defined(HAS_RAWTOYROW_NEON) 1050 #if defined(HAS_RAWTOYROW_NEON)
1042 if (TestCpuFlag(kCpuHasNEON)) { 1051 if (TestCpuFlag(kCpuHasNEON)) {
1043 RAWToUVRow = RAWToUVRow_Any_NEON; 1052 RAWToUVRow = RAWToUVRow_Any_NEON;
1044 RAWToYRow = RAWToYRow_Any_NEON; 1053 RAWToYRow = RAWToYRow_Any_NEON;
1045 if (IS_ALIGNED(width, 8)) { 1054 if (IS_ALIGNED(width, 8)) {
1046 RAWToYRow = RAWToYRow_NEON; 1055 RAWToYRow = RAWToYRow_NEON;
1047 if (IS_ALIGNED(width, 16)) { 1056 if (IS_ALIGNED(width, 16)) {
1048 RAWToUVRow = RAWToUVRow_NEON; 1057 RAWToUVRow = RAWToUVRow_NEON;
1049 } 1058 }
1050 } 1059 }
1051 } 1060 }
1061 #elif defined(HAS_RAWTOYROW_MSA)
1062 if (TestCpuFlag(kCpuHasMSA)) {
1063 RAWToUVRow = RAWToUVRow_Any_MSA;
1064 RAWToYRow = RAWToYRow_Any_MSA;
1065 if (IS_ALIGNED(width, 16)) {
1066 RAWToYRow = RAWToYRow_MSA;
1067 RAWToUVRow = RAWToUVRow_MSA;
1068 }
1069 }
1052 // Other platforms do intermediate conversion from RAW to ARGB. 1070 // Other platforms do intermediate conversion from RAW to ARGB.
1053 #else 1071 #else
1054 #if defined(HAS_RAWTOARGBROW_SSSE3) 1072 #if defined(HAS_RAWTOARGBROW_SSSE3)
1055 if (TestCpuFlag(kCpuHasSSSE3)) { 1073 if (TestCpuFlag(kCpuHasSSSE3)) {
1056 RAWToARGBRow = RAWToARGBRow_Any_SSSE3; 1074 RAWToARGBRow = RAWToARGBRow_Any_SSSE3;
1057 if (IS_ALIGNED(width, 16)) { 1075 if (IS_ALIGNED(width, 16)) {
1058 RAWToARGBRow = RAWToARGBRow_SSSE3; 1076 RAWToARGBRow = RAWToARGBRow_SSSE3;
1059 } 1077 }
1060 } 1078 }
1061 #endif 1079 #endif
(...skipping 25 matching lines...) Expand all
1087 } 1105 }
1088 } 1106 }
1089 #endif 1107 #endif
1090 { 1108 {
1091 // Allocate 2 rows of ARGB. 1109 // Allocate 2 rows of ARGB.
1092 const int kRowSize = (width * 4 + 31) & ~31; 1110 const int kRowSize = (width * 4 + 31) & ~31;
1093 align_buffer_64(row, kRowSize * 2); 1111 align_buffer_64(row, kRowSize * 2);
1094 #endif 1112 #endif
1095 1113
1096 for (y = 0; y < height - 1; y += 2) { 1114 for (y = 0; y < height - 1; y += 2) {
1097 #if defined(HAS_RAWTOYROW_NEON) 1115 #if (defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA))
1098 RAWToUVRow(src_raw, src_stride_raw, dst_u, dst_v, width); 1116 RAWToUVRow(src_raw, src_stride_raw, dst_u, dst_v, width);
1099 RAWToYRow(src_raw, dst_y, width); 1117 RAWToYRow(src_raw, dst_y, width);
1100 RAWToYRow(src_raw + src_stride_raw, dst_y + dst_stride_y, width); 1118 RAWToYRow(src_raw + src_stride_raw, dst_y + dst_stride_y, width);
1101 #else 1119 #else
1102 RAWToARGBRow(src_raw, row, width); 1120 RAWToARGBRow(src_raw, row, width);
1103 RAWToARGBRow(src_raw + src_stride_raw, row + kRowSize, width); 1121 RAWToARGBRow(src_raw + src_stride_raw, row + kRowSize, width);
1104 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); 1122 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
1105 ARGBToYRow(row, dst_y, width); 1123 ARGBToYRow(row, dst_y, width);
1106 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); 1124 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
1107 #endif 1125 #endif
1108 src_raw += src_stride_raw * 2; 1126 src_raw += src_stride_raw * 2;
1109 dst_y += dst_stride_y * 2; 1127 dst_y += dst_stride_y * 2;
1110 dst_u += dst_stride_u; 1128 dst_u += dst_stride_u;
1111 dst_v += dst_stride_v; 1129 dst_v += dst_stride_v;
1112 } 1130 }
1113 if (height & 1) { 1131 if (height & 1) {
1114 #if defined(HAS_RAWTOYROW_NEON) 1132 #if (defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA))
1115 RAWToUVRow(src_raw, 0, dst_u, dst_v, width); 1133 RAWToUVRow(src_raw, 0, dst_u, dst_v, width);
1116 RAWToYRow(src_raw, dst_y, width); 1134 RAWToYRow(src_raw, dst_y, width);
1117 #else 1135 #else
1118 RAWToARGBRow(src_raw, row, width); 1136 RAWToARGBRow(src_raw, row, width);
1119 ARGBToUVRow(row, 0, dst_u, dst_v, width); 1137 ARGBToUVRow(row, 0, dst_u, dst_v, width);
1120 ARGBToYRow(row, dst_y, width); 1138 ARGBToYRow(row, dst_y, width);
1121 #endif 1139 #endif
1122 } 1140 }
1123 #if !defined(HAS_RAWTOYROW_NEON) 1141 #if !(defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA))
1124 free_aligned_buffer_64(row); 1142 free_aligned_buffer_64(row);
1125 } 1143 }
1126 #endif 1144 #endif
1127 return 0; 1145 return 0;
1128 } 1146 }
1129 1147
1130 // Convert RGB565 to I420. 1148 // Convert RGB565 to I420.
1131 LIBYUV_API 1149 LIBYUV_API
1132 int RGB565ToI420(const uint8* src_rgb565, 1150 int RGB565ToI420(const uint8* src_rgb565,
1133 int src_stride_rgb565, 1151 int src_stride_rgb565,
1134 uint8* dst_y, 1152 uint8* dst_y,
1135 int dst_stride_y, 1153 int dst_stride_y,
1136 uint8* dst_u, 1154 uint8* dst_u,
1137 int dst_stride_u, 1155 int dst_stride_u,
1138 uint8* dst_v, 1156 uint8* dst_v,
1139 int dst_stride_v, 1157 int dst_stride_v,
1140 int width, 1158 int width,
1141 int height) { 1159 int height) {
1142 int y; 1160 int y;
1143 #if defined(HAS_RGB565TOYROW_NEON) 1161 #if (defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA))
1144 void (*RGB565ToUVRow)(const uint8* src_rgb565, int src_stride_rgb565, 1162 void (*RGB565ToUVRow)(const uint8* src_rgb565, int src_stride_rgb565,
1145 uint8* dst_u, uint8* dst_v, int width) = 1163 uint8* dst_u, uint8* dst_v, int width) =
1146 RGB565ToUVRow_C; 1164 RGB565ToUVRow_C;
1147 void (*RGB565ToYRow)(const uint8* src_rgb565, uint8* dst_y, int width) = 1165 void (*RGB565ToYRow)(const uint8* src_rgb565, uint8* dst_y, int width) =
1148 RGB565ToYRow_C; 1166 RGB565ToYRow_C;
1149 #else 1167 #else
1150 void (*RGB565ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, 1168 void (*RGB565ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
1151 int width) = RGB565ToARGBRow_C; 1169 RGB565ToARGBRow_C;
1152 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, 1170 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u,
1153 uint8* dst_u, uint8* dst_v, int width) = 1171 uint8* dst_v, int width) = ARGBToUVRow_C;
1154 ARGBToUVRow_C; 1172 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
1155 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = 1173 ARGBToYRow_C;
1156 ARGBToYRow_C;
1157 #endif 1174 #endif
1158 if (!src_rgb565 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { 1175 if (!src_rgb565 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
1159 return -1; 1176 return -1;
1160 } 1177 }
1161 // Negative height means invert the image. 1178 // Negative height means invert the image.
1162 if (height < 0) { 1179 if (height < 0) {
1163 height = -height; 1180 height = -height;
1164 src_rgb565 = src_rgb565 + (height - 1) * src_stride_rgb565; 1181 src_rgb565 = src_rgb565 + (height - 1) * src_stride_rgb565;
1165 src_stride_rgb565 = -src_stride_rgb565; 1182 src_stride_rgb565 = -src_stride_rgb565;
1166 } 1183 }
1167 1184
1168 // Neon version does direct RGB565 to YUV. 1185 // Neon version does direct RGB565 to YUV.
1169 #if defined(HAS_RGB565TOYROW_NEON) 1186 #if defined(HAS_RGB565TOYROW_NEON)
1170 if (TestCpuFlag(kCpuHasNEON)) { 1187 if (TestCpuFlag(kCpuHasNEON)) {
1171 RGB565ToUVRow = RGB565ToUVRow_Any_NEON; 1188 RGB565ToUVRow = RGB565ToUVRow_Any_NEON;
1172 RGB565ToYRow = RGB565ToYRow_Any_NEON; 1189 RGB565ToYRow = RGB565ToYRow_Any_NEON;
1173 if (IS_ALIGNED(width, 8)) { 1190 if (IS_ALIGNED(width, 8)) {
1174 RGB565ToYRow = RGB565ToYRow_NEON; 1191 RGB565ToYRow = RGB565ToYRow_NEON;
1175 if (IS_ALIGNED(width, 16)) { 1192 if (IS_ALIGNED(width, 16)) {
1176 RGB565ToUVRow = RGB565ToUVRow_NEON; 1193 RGB565ToUVRow = RGB565ToUVRow_NEON;
1177 } 1194 }
1178 } 1195 }
1179 } 1196 }
1197 #elif defined(HAS_RGB565TOYROW_MSA)
1198 if (TestCpuFlag(kCpuHasMSA)) {
1199 RGB565ToUVRow = RGB565ToUVRow_Any_MSA;
1200 RGB565ToYRow = RGB565ToYRow_Any_MSA;
1201 if (IS_ALIGNED(width, 16)) {
1202 RGB565ToYRow = RGB565ToYRow_MSA;
1203 RGB565ToUVRow = RGB565ToUVRow_MSA;
1204 }
1205 }
1180 // Other platforms do intermediate conversion from RGB565 to ARGB. 1206 // Other platforms do intermediate conversion from RGB565 to ARGB.
1181 #else 1207 #else
1182 #if defined(HAS_RGB565TOARGBROW_SSE2) 1208 #if defined(HAS_RGB565TOARGBROW_SSE2)
1183 if (TestCpuFlag(kCpuHasSSE2)) { 1209 if (TestCpuFlag(kCpuHasSSE2)) {
1184 RGB565ToARGBRow = RGB565ToARGBRow_Any_SSE2; 1210 RGB565ToARGBRow = RGB565ToARGBRow_Any_SSE2;
1185 if (IS_ALIGNED(width, 8)) { 1211 if (IS_ALIGNED(width, 8)) {
1186 RGB565ToARGBRow = RGB565ToARGBRow_SSE2; 1212 RGB565ToARGBRow = RGB565ToARGBRow_SSE2;
1187 } 1213 }
1188 } 1214 }
1189 #endif 1215 #endif
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 } 1249 }
1224 } 1250 }
1225 #endif 1251 #endif
1226 { 1252 {
1227 // Allocate 2 rows of ARGB. 1253 // Allocate 2 rows of ARGB.
1228 const int kRowSize = (width * 4 + 31) & ~31; 1254 const int kRowSize = (width * 4 + 31) & ~31;
1229 align_buffer_64(row, kRowSize * 2); 1255 align_buffer_64(row, kRowSize * 2);
1230 #endif 1256 #endif
1231 1257
1232 for (y = 0; y < height - 1; y += 2) { 1258 for (y = 0; y < height - 1; y += 2) {
1233 #if defined(HAS_RGB565TOYROW_NEON) 1259 #if (defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA))
1234 RGB565ToUVRow(src_rgb565, src_stride_rgb565, dst_u, dst_v, width); 1260 RGB565ToUVRow(src_rgb565, src_stride_rgb565, dst_u, dst_v, width);
1235 RGB565ToYRow(src_rgb565, dst_y, width); 1261 RGB565ToYRow(src_rgb565, dst_y, width);
1236 RGB565ToYRow(src_rgb565 + src_stride_rgb565, dst_y + dst_stride_y, width); 1262 RGB565ToYRow(src_rgb565 + src_stride_rgb565, dst_y + dst_stride_y, width);
1237 #else 1263 #else
1238 RGB565ToARGBRow(src_rgb565, row, width); 1264 RGB565ToARGBRow(src_rgb565, row, width);
1239 RGB565ToARGBRow(src_rgb565 + src_stride_rgb565, row + kRowSize, 1265 RGB565ToARGBRow(src_rgb565 + src_stride_rgb565, row + kRowSize, width);
1240 width); 1266 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
1241 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); 1267 ARGBToYRow(row, dst_y, width);
1242 ARGBToYRow(row, dst_y, width); 1268 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
1243 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
1244 #endif 1269 #endif
1245 src_rgb565 += src_stride_rgb565 * 2; 1270 src_rgb565 += src_stride_rgb565 * 2;
1246 dst_y += dst_stride_y * 2; 1271 dst_y += dst_stride_y * 2;
1247 dst_u += dst_stride_u; 1272 dst_u += dst_stride_u;
1248 dst_v += dst_stride_v; 1273 dst_v += dst_stride_v;
1249 } 1274 }
1250 if (height & 1) { 1275 if (height & 1) {
1251 #if defined(HAS_RGB565TOYROW_NEON) 1276 #if (defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA))
1252 RGB565ToUVRow(src_rgb565, 0, dst_u, dst_v, width); 1277 RGB565ToUVRow(src_rgb565, 0, dst_u, dst_v, width);
1253 RGB565ToYRow(src_rgb565, dst_y, width); 1278 RGB565ToYRow(src_rgb565, dst_y, width);
1254 #else 1279 #else
1255 RGB565ToARGBRow(src_rgb565, row, width); 1280 RGB565ToARGBRow(src_rgb565, row, width);
1256 ARGBToUVRow(row, 0, dst_u, dst_v, width); 1281 ARGBToUVRow(row, 0, dst_u, dst_v, width);
1257 ARGBToYRow(row, dst_y, width); 1282 ARGBToYRow(row, dst_y, width);
1258 #endif 1283 #endif
1259 } 1284 }
1260 #if !defined(HAS_RGB565TOYROW_NEON) 1285 #if !(defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA))
1261 free_aligned_buffer_64(row); 1286 free_aligned_buffer_64(row);
1262 } 1287 }
1263 #endif 1288 #endif
1264 return 0; 1289 return 0;
1265 } 1290 }
1266 1291
1267 // Convert ARGB1555 to I420. 1292 // Convert ARGB1555 to I420.
1268 LIBYUV_API 1293 LIBYUV_API
1269 int ARGB1555ToI420(const uint8* src_argb1555, 1294 int ARGB1555ToI420(const uint8* src_argb1555,
1270 int src_stride_argb1555, 1295 int src_stride_argb1555,
1271 uint8* dst_y, 1296 uint8* dst_y,
1272 int dst_stride_y, 1297 int dst_stride_y,
1273 uint8* dst_u, 1298 uint8* dst_u,
1274 int dst_stride_u, 1299 int dst_stride_u,
1275 uint8* dst_v, 1300 uint8* dst_v,
1276 int dst_stride_v, 1301 int dst_stride_v,
1277 int width, 1302 int width,
1278 int height) { 1303 int height) {
1279 int y; 1304 int y;
1280 #if defined(HAS_ARGB1555TOYROW_NEON) 1305 #if (defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA))
1281 void (*ARGB1555ToUVRow)(const uint8* src_argb1555, int src_stride_argb1555, 1306 void (*ARGB1555ToUVRow)(const uint8* src_argb1555, int src_stride_argb1555,
1282 uint8* dst_u, uint8* dst_v, int width) = 1307 uint8* dst_u, uint8* dst_v, int width) =
1283 ARGB1555ToUVRow_C; 1308 ARGB1555ToUVRow_C;
1284 void (*ARGB1555ToYRow)(const uint8* src_argb1555, uint8* dst_y, int width) = 1309 void (*ARGB1555ToYRow)(const uint8* src_argb1555, uint8* dst_y, int width) =
1285 ARGB1555ToYRow_C; 1310 ARGB1555ToYRow_C;
1286 #else 1311 #else
1287 void (*ARGB1555ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, 1312 void (*ARGB1555ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
1288 int width) = ARGB1555ToARGBRow_C; 1313 ARGB1555ToARGBRow_C;
1289 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, 1314 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u,
1290 uint8* dst_u, uint8* dst_v, int width) = 1315 uint8* dst_v, int width) = ARGBToUVRow_C;
1291 ARGBToUVRow_C; 1316 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
1292 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = 1317 ARGBToYRow_C;
1293 ARGBToYRow_C;
1294 #endif 1318 #endif
1295 if (!src_argb1555 || !dst_y || !dst_u || !dst_v || width <= 0 || 1319 if (!src_argb1555 || !dst_y || !dst_u || !dst_v || width <= 0 ||
1296 height == 0) { 1320 height == 0) {
1297 return -1; 1321 return -1;
1298 } 1322 }
1299 // Negative height means invert the image. 1323 // Negative height means invert the image.
1300 if (height < 0) { 1324 if (height < 0) {
1301 height = -height; 1325 height = -height;
1302 src_argb1555 = src_argb1555 + (height - 1) * src_stride_argb1555; 1326 src_argb1555 = src_argb1555 + (height - 1) * src_stride_argb1555;
1303 src_stride_argb1555 = -src_stride_argb1555; 1327 src_stride_argb1555 = -src_stride_argb1555;
1304 } 1328 }
1305 1329
1306 // Neon version does direct ARGB1555 to YUV. 1330 // Neon version does direct ARGB1555 to YUV.
1307 #if defined(HAS_ARGB1555TOYROW_NEON) 1331 #if defined(HAS_ARGB1555TOYROW_NEON)
1308 if (TestCpuFlag(kCpuHasNEON)) { 1332 if (TestCpuFlag(kCpuHasNEON)) {
1309 ARGB1555ToUVRow = ARGB1555ToUVRow_Any_NEON; 1333 ARGB1555ToUVRow = ARGB1555ToUVRow_Any_NEON;
1310 ARGB1555ToYRow = ARGB1555ToYRow_Any_NEON; 1334 ARGB1555ToYRow = ARGB1555ToYRow_Any_NEON;
1311 if (IS_ALIGNED(width, 8)) { 1335 if (IS_ALIGNED(width, 8)) {
1312 ARGB1555ToYRow = ARGB1555ToYRow_NEON; 1336 ARGB1555ToYRow = ARGB1555ToYRow_NEON;
1313 if (IS_ALIGNED(width, 16)) { 1337 if (IS_ALIGNED(width, 16)) {
1314 ARGB1555ToUVRow = ARGB1555ToUVRow_NEON; 1338 ARGB1555ToUVRow = ARGB1555ToUVRow_NEON;
1315 } 1339 }
1316 } 1340 }
1317 } 1341 }
1342 #elif defined(HAS_ARGB1555TOYROW_MSA)
1343 if (TestCpuFlag(kCpuHasMSA)) {
1344 ARGB1555ToUVRow = ARGB1555ToUVRow_Any_MSA;
1345 ARGB1555ToYRow = ARGB1555ToYRow_Any_MSA;
1346 if (IS_ALIGNED(width, 16)) {
1347 ARGB1555ToYRow = ARGB1555ToYRow_MSA;
1348 ARGB1555ToUVRow = ARGB1555ToUVRow_MSA;
1349 }
1350 }
1318 // Other platforms do intermediate conversion from ARGB1555 to ARGB. 1351 // Other platforms do intermediate conversion from ARGB1555 to ARGB.
1319 #else 1352 #else
1320 #if defined(HAS_ARGB1555TOARGBROW_SSE2) 1353 #if defined(HAS_ARGB1555TOARGBROW_SSE2)
1321 if (TestCpuFlag(kCpuHasSSE2)) { 1354 if (TestCpuFlag(kCpuHasSSE2)) {
1322 ARGB1555ToARGBRow = ARGB1555ToARGBRow_Any_SSE2; 1355 ARGB1555ToARGBRow = ARGB1555ToARGBRow_Any_SSE2;
1323 if (IS_ALIGNED(width, 8)) { 1356 if (IS_ALIGNED(width, 8)) {
1324 ARGB1555ToARGBRow = ARGB1555ToARGBRow_SSE2; 1357 ARGB1555ToARGBRow = ARGB1555ToARGBRow_SSE2;
1325 } 1358 }
1326 } 1359 }
1327 #endif 1360 #endif
(...skipping 25 matching lines...) Expand all
1353 } 1386 }
1354 } 1387 }
1355 #endif 1388 #endif
1356 { 1389 {
1357 // Allocate 2 rows of ARGB. 1390 // Allocate 2 rows of ARGB.
1358 const int kRowSize = (width * 4 + 31) & ~31; 1391 const int kRowSize = (width * 4 + 31) & ~31;
1359 align_buffer_64(row, kRowSize * 2); 1392 align_buffer_64(row, kRowSize * 2);
1360 #endif 1393 #endif
1361 1394
1362 for (y = 0; y < height - 1; y += 2) { 1395 for (y = 0; y < height - 1; y += 2) {
1363 #if defined(HAS_ARGB1555TOYROW_NEON) 1396 #if (defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA))
1364 ARGB1555ToUVRow(src_argb1555, src_stride_argb1555, dst_u, dst_v, width); 1397 ARGB1555ToUVRow(src_argb1555, src_stride_argb1555, dst_u, dst_v, width);
1365 ARGB1555ToYRow(src_argb1555, dst_y, width); 1398 ARGB1555ToYRow(src_argb1555, dst_y, width);
1366 ARGB1555ToYRow(src_argb1555 + src_stride_argb1555, dst_y + dst_stride_y, 1399 ARGB1555ToYRow(src_argb1555 + src_stride_argb1555, dst_y + dst_stride_y,
1367 width); 1400 width);
1368 #else 1401 #else
1369 ARGB1555ToARGBRow(src_argb1555, row, width); 1402 ARGB1555ToARGBRow(src_argb1555, row, width);
1370 ARGB1555ToARGBRow(src_argb1555 + src_stride_argb1555, 1403 ARGB1555ToARGBRow(src_argb1555 + src_stride_argb1555, row + kRowSize,
1371 row + kRowSize, width); 1404 width);
1372 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); 1405 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
1373 ARGBToYRow(row, dst_y, width); 1406 ARGBToYRow(row, dst_y, width);
1374 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); 1407 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
1375 #endif 1408 #endif
1376 src_argb1555 += src_stride_argb1555 * 2; 1409 src_argb1555 += src_stride_argb1555 * 2;
1377 dst_y += dst_stride_y * 2; 1410 dst_y += dst_stride_y * 2;
1378 dst_u += dst_stride_u; 1411 dst_u += dst_stride_u;
1379 dst_v += dst_stride_v; 1412 dst_v += dst_stride_v;
1380 } 1413 }
1381 if (height & 1) { 1414 if (height & 1) {
1382 #if defined(HAS_ARGB1555TOYROW_NEON) 1415 #if (defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA))
1383 ARGB1555ToUVRow(src_argb1555, 0, dst_u, dst_v, width); 1416 ARGB1555ToUVRow(src_argb1555, 0, dst_u, dst_v, width);
1384 ARGB1555ToYRow(src_argb1555, dst_y, width); 1417 ARGB1555ToYRow(src_argb1555, dst_y, width);
1385 #else 1418 #else
1386 ARGB1555ToARGBRow(src_argb1555, row, width); 1419 ARGB1555ToARGBRow(src_argb1555, row, width);
1387 ARGBToUVRow(row, 0, dst_u, dst_v, width); 1420 ARGBToUVRow(row, 0, dst_u, dst_v, width);
1388 ARGBToYRow(row, dst_y, width); 1421 ARGBToYRow(row, dst_y, width);
1389 #endif 1422 #endif
1390 } 1423 }
1391 #if !defined(HAS_ARGB1555TOYROW_NEON) 1424 #if !(defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA))
1392 free_aligned_buffer_64(row); 1425 free_aligned_buffer_64(row);
1393 } 1426 }
1394 #endif 1427 #endif
1395 return 0; 1428 return 0;
1396 } 1429 }
1397 1430
1398 // Convert ARGB4444 to I420. 1431 // Convert ARGB4444 to I420.
1399 LIBYUV_API 1432 LIBYUV_API
1400 int ARGB4444ToI420(const uint8* src_argb4444, 1433 int ARGB4444ToI420(const uint8* src_argb4444,
1401 int src_stride_argb4444, 1434 int src_stride_argb4444,
1402 uint8* dst_y, 1435 uint8* dst_y,
1403 int dst_stride_y, 1436 int dst_stride_y,
1404 uint8* dst_u, 1437 uint8* dst_u,
1405 int dst_stride_u, 1438 int dst_stride_u,
1406 uint8* dst_v, 1439 uint8* dst_v,
1407 int dst_stride_v, 1440 int dst_stride_v,
1408 int width, 1441 int width,
1409 int height) { 1442 int height) {
1410 int y; 1443 int y;
1411 #if defined(HAS_ARGB4444TOYROW_NEON) 1444 #if defined(HAS_ARGB4444TOYROW_NEON)
1412 void (*ARGB4444ToUVRow)(const uint8* src_argb4444, int src_stride_argb4444, 1445 void (*ARGB4444ToUVRow)(const uint8* src_argb4444, int src_stride_argb4444,
1413 uint8* dst_u, uint8* dst_v, int width) = 1446 uint8* dst_u, uint8* dst_v, int width) =
1414 ARGB4444ToUVRow_C; 1447 ARGB4444ToUVRow_C;
1415 void (*ARGB4444ToYRow)(const uint8* src_argb4444, uint8* dst_y, int width) = 1448 void (*ARGB4444ToYRow)(const uint8* src_argb4444, uint8* dst_y, int width) =
1416 ARGB4444ToYRow_C; 1449 ARGB4444ToYRow_C;
1417 #else 1450 #else
1418 void (*ARGB4444ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, 1451 void (*ARGB4444ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) =
1419 int width) = ARGB4444ToARGBRow_C; 1452 ARGB4444ToARGBRow_C;
1420 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, 1453 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u,
1421 uint8* dst_u, uint8* dst_v, int width) = 1454 uint8* dst_v, int width) = ARGBToUVRow_C;
1422 ARGBToUVRow_C; 1455 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) =
1423 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = 1456 ARGBToYRow_C;
1424 ARGBToYRow_C;
1425 #endif 1457 #endif
1426 if (!src_argb4444 || !dst_y || !dst_u || !dst_v || width <= 0 || 1458 if (!src_argb4444 || !dst_y || !dst_u || !dst_v || width <= 0 ||
1427 height == 0) { 1459 height == 0) {
1428 return -1; 1460 return -1;
1429 } 1461 }
1430 // Negative height means invert the image. 1462 // Negative height means invert the image.
1431 if (height < 0) { 1463 if (height < 0) {
1432 height = -height; 1464 height = -height;
1433 src_argb4444 = src_argb4444 + (height - 1) * src_stride_argb4444; 1465 src_argb4444 = src_argb4444 + (height - 1) * src_stride_argb4444;
1434 src_stride_argb4444 = -src_stride_argb4444; 1466 src_stride_argb4444 = -src_stride_argb4444;
1435 } 1467 }
1436 1468
1437 // Neon version does direct ARGB4444 to YUV. 1469 // Neon version does direct ARGB4444 to YUV.
1438 #if defined(HAS_ARGB4444TOYROW_NEON) 1470 #if defined(HAS_ARGB4444TOYROW_NEON)
1439 if (TestCpuFlag(kCpuHasNEON)) { 1471 if (TestCpuFlag(kCpuHasNEON)) {
1440 ARGB4444ToUVRow = ARGB4444ToUVRow_Any_NEON; 1472 ARGB4444ToUVRow = ARGB4444ToUVRow_Any_NEON;
1441 ARGB4444ToYRow = ARGB4444ToYRow_Any_NEON; 1473 ARGB4444ToYRow = ARGB4444ToYRow_Any_NEON;
1442 if (IS_ALIGNED(width, 8)) { 1474 if (IS_ALIGNED(width, 8)) {
1443 ARGB4444ToYRow = ARGB4444ToYRow_NEON; 1475 ARGB4444ToYRow = ARGB4444ToYRow_NEON;
1444 if (IS_ALIGNED(width, 16)) { 1476 if (IS_ALIGNED(width, 16)) {
1445 ARGB4444ToUVRow = ARGB4444ToUVRow_NEON; 1477 ARGB4444ToUVRow = ARGB4444ToUVRow_NEON;
1446 } 1478 }
1447 } 1479 }
1448 } 1480 }
1449 // Other platforms do intermediate conversion from ARGB4444 to ARGB. 1481 // Other platforms do intermediate conversion from ARGB4444 to ARGB.
1450 #else 1482 #else
1451 #if defined(HAS_ARGB4444TOARGBROW_SSE2) 1483 #if defined(HAS_ARGB4444TOARGBROW_SSE2)
1452 if (TestCpuFlag(kCpuHasSSE2)) { 1484 if (TestCpuFlag(kCpuHasSSE2)) {
1453 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_SSE2; 1485 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_SSE2;
1454 if (IS_ALIGNED(width, 8)) { 1486 if (IS_ALIGNED(width, 8)) {
1455 ARGB4444ToARGBRow = ARGB4444ToARGBRow_SSE2; 1487 ARGB4444ToARGBRow = ARGB4444ToARGBRow_SSE2;
1456 } 1488 }
1457 } 1489 }
1458 #endif 1490 #endif
1459 #if defined(HAS_ARGB4444TOARGBROW_AVX2) 1491 #if defined(HAS_ARGB4444TOARGBROW_AVX2)
1460 if (TestCpuFlag(kCpuHasAVX2)) { 1492 if (TestCpuFlag(kCpuHasAVX2)) {
1461 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_AVX2; 1493 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_AVX2;
1462 if (IS_ALIGNED(width, 16)) { 1494 if (IS_ALIGNED(width, 16)) {
1463 ARGB4444ToARGBRow = ARGB4444ToARGBRow_AVX2; 1495 ARGB4444ToARGBRow = ARGB4444ToARGBRow_AVX2;
1464 } 1496 }
1465 } 1497 }
1466 #endif 1498 #endif
1467 #if defined(HAS_ARGB4444TOARGBROW_MSA) 1499 #if defined(HAS_ARGB4444TOARGBROW_MSA)
1468 if (TestCpuFlag(kCpuHasMSA)) { 1500 if (TestCpuFlag(kCpuHasMSA)) {
1469 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_MSA; 1501 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_MSA;
1470 if (IS_ALIGNED(width, 16)) { 1502 if (IS_ALIGNED(width, 16)) {
1471 ARGB4444ToARGBRow = ARGB4444ToARGBRow_MSA; 1503 ARGB4444ToARGBRow = ARGB4444ToARGBRow_MSA;
1472 } 1504 }
1473 } 1505 }
1474 #endif 1506 #endif
1475 #if defined(HAS_ARGBTOYROW_SSSE3) && defined(HAS_ARGBTOUVROW_SSSE3) 1507 #if defined(HAS_ARGBTOYROW_SSSE3) && defined(HAS_ARGBTOUVROW_SSSE3)
1476 if (TestCpuFlag(kCpuHasSSSE3)) { 1508 if (TestCpuFlag(kCpuHasSSSE3)) {
1477 ARGBToUVRow = ARGBToUVRow_Any_SSSE3; 1509 ARGBToUVRow = ARGBToUVRow_Any_SSSE3;
1478 ARGBToYRow = ARGBToYRow_Any_SSSE3; 1510 ARGBToYRow = ARGBToYRow_Any_SSSE3;
1479 if (IS_ALIGNED(width, 16)) { 1511 if (IS_ALIGNED(width, 16)) {
1480 ARGBToUVRow = ARGBToUVRow_SSSE3; 1512 ARGBToUVRow = ARGBToUVRow_SSSE3;
1481 ARGBToYRow = ARGBToYRow_SSSE3; 1513 ARGBToYRow = ARGBToYRow_SSSE3;
1482 } 1514 }
1483 } 1515 }
1484 #endif 1516 #endif
1485 #if defined(HAS_ARGBTOYROW_AVX2) && defined(HAS_ARGBTOUVROW_AVX2) 1517 #if defined(HAS_ARGBTOYROW_AVX2) && defined(HAS_ARGBTOUVROW_AVX2)
1486 if (TestCpuFlag(kCpuHasAVX2)) { 1518 if (TestCpuFlag(kCpuHasAVX2)) {
1487 ARGBToUVRow = ARGBToUVRow_Any_AVX2; 1519 ARGBToUVRow = ARGBToUVRow_Any_AVX2;
1488 ARGBToYRow = ARGBToYRow_Any_AVX2; 1520 ARGBToYRow = ARGBToYRow_Any_AVX2;
1489 if (IS_ALIGNED(width, 32)) { 1521 if (IS_ALIGNED(width, 32)) {
1490 ARGBToUVRow = ARGBToUVRow_AVX2; 1522 ARGBToUVRow = ARGBToUVRow_AVX2;
1491 ARGBToYRow = ARGBToYRow_AVX2; 1523 ARGBToYRow = ARGBToYRow_AVX2;
1492 } 1524 }
1493 } 1525 }
1494 #endif 1526 #endif
1495 #if defined(HAS_ARGBTOYROW_MSA) 1527 #if defined(HAS_ARGBTOYROW_MSA)
1496 if (TestCpuFlag(kCpuHasMSA)) { 1528 if (TestCpuFlag(kCpuHasMSA)) {
1497 ARGBToUVRow = ARGBToUVRow_Any_MSA; 1529 ARGBToUVRow = ARGBToUVRow_Any_MSA;
1498 ARGBToYRow = ARGBToYRow_Any_MSA; 1530 ARGBToYRow = ARGBToYRow_Any_MSA;
1499 if (IS_ALIGNED(width, 16)) { 1531 if (IS_ALIGNED(width, 16)) {
1500 ARGBToYRow = ARGBToYRow_MSA; 1532 ARGBToYRow = ARGBToYRow_MSA;
1501 if (IS_ALIGNED(width, 32)) { 1533 if (IS_ALIGNED(width, 32)) {
1502 ARGBToUVRow = ARGBToUVRow_MSA; 1534 ARGBToUVRow = ARGBToUVRow_MSA;
1503 } 1535 }
1504 } 1536 }
1505 } 1537 }
1506 #endif 1538 #endif
1507 { 1539 {
1508 // Allocate 2 rows of ARGB. 1540 // Allocate 2 rows of ARGB.
1509 const int kRowSize = (width * 4 + 31) & ~31; 1541 const int kRowSize = (width * 4 + 31) & ~31;
1510 align_buffer_64(row, kRowSize * 2); 1542 align_buffer_64(row, kRowSize * 2);
1511 #endif 1543 #endif
1512 1544
1513 for (y = 0; y < height - 1; y += 2) { 1545 for (y = 0; y < height - 1; y += 2) {
1514 #if defined(HAS_ARGB4444TOYROW_NEON) 1546 #if defined(HAS_ARGB4444TOYROW_NEON)
1515 ARGB4444ToUVRow(src_argb4444, src_stride_argb4444, dst_u, dst_v, width); 1547 ARGB4444ToUVRow(src_argb4444, src_stride_argb4444, dst_u, dst_v, width);
1516 ARGB4444ToYRow(src_argb4444, dst_y, width); 1548 ARGB4444ToYRow(src_argb4444, dst_y, width);
1517 ARGB4444ToYRow(src_argb4444 + src_stride_argb4444, dst_y + dst_stride_y, 1549 ARGB4444ToYRow(src_argb4444 + src_stride_argb4444, dst_y + dst_stride_y,
1518 width); 1550 width);
1519 #else 1551 #else
1520 ARGB4444ToARGBRow(src_argb4444, row, width); 1552 ARGB4444ToARGBRow(src_argb4444, row, width);
1521 ARGB4444ToARGBRow(src_argb4444 + src_stride_argb4444, 1553 ARGB4444ToARGBRow(src_argb4444 + src_stride_argb4444, row + kRowSize,
1522 row + kRowSize, width); 1554 width);
1523 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); 1555 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
1524 ARGBToYRow(row, dst_y, width); 1556 ARGBToYRow(row, dst_y, width);
1525 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); 1557 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
1526 #endif 1558 #endif
1527 src_argb4444 += src_stride_argb4444 * 2; 1559 src_argb4444 += src_stride_argb4444 * 2;
1528 dst_y += dst_stride_y * 2; 1560 dst_y += dst_stride_y * 2;
1529 dst_u += dst_stride_u; 1561 dst_u += dst_stride_u;
1530 dst_v += dst_stride_v; 1562 dst_v += dst_stride_v;
1531 } 1563 }
1532 if (height & 1) { 1564 if (height & 1) {
1533 #if defined(HAS_ARGB4444TOYROW_NEON) 1565 #if defined(HAS_ARGB4444TOYROW_NEON)
1534 ARGB4444ToUVRow(src_argb4444, 0, dst_u, dst_v, width); 1566 ARGB4444ToUVRow(src_argb4444, 0, dst_u, dst_v, width);
1535 ARGB4444ToYRow(src_argb4444, dst_y, width); 1567 ARGB4444ToYRow(src_argb4444, dst_y, width);
1536 #else 1568 #else
1537 ARGB4444ToARGBRow(src_argb4444, row, width); 1569 ARGB4444ToARGBRow(src_argb4444, row, width);
1538 ARGBToUVRow(row, 0, dst_u, dst_v, width); 1570 ARGBToUVRow(row, 0, dst_u, dst_v, width);
1539 ARGBToYRow(row, dst_y, width); 1571 ARGBToYRow(row, dst_y, width);
1540 #endif 1572 #endif
1541 } 1573 }
1542 #if !defined(HAS_ARGB4444TOYROW_NEON) 1574 #if !defined(HAS_ARGB4444TOYROW_NEON)
1543 free_aligned_buffer_64(row); 1575 free_aligned_buffer_64(row);
1544 } 1576 }
1545 #endif 1577 #endif
1546 return 0; 1578 return 0;
1547 } 1579 }
1548 1580
1549 static void SplitPixels(const uint8* src_u, 1581 static void SplitPixels(const uint8* src_u,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 dst_u += dst_stride_u; 1657 dst_u += dst_stride_u;
1626 dst_v += dst_stride_v; 1658 dst_v += dst_stride_v;
1627 } 1659 }
1628 return 0; 1660 return 0;
1629 } 1661 }
1630 1662
1631 #ifdef __cplusplus 1663 #ifdef __cplusplus
1632 } // extern "C" 1664 } // extern "C"
1633 } // namespace libyuv 1665 } // namespace libyuv
1634 #endif 1666 #endif
OLDNEW
« no previous file with comments | « include/libyuv/row.h ('k') | source/convert_argb.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698