| 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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 int src_stride_rgb24, | 825 int src_stride_rgb24, |
| 826 uint8* dst_y, | 826 uint8* dst_y, |
| 827 int dst_stride_y, | 827 int dst_stride_y, |
| 828 uint8* dst_u, | 828 uint8* dst_u, |
| 829 int dst_stride_u, | 829 int dst_stride_u, |
| 830 uint8* dst_v, | 830 uint8* dst_v, |
| 831 int dst_stride_v, | 831 int dst_stride_v, |
| 832 int width, | 832 int width, |
| 833 int height) { | 833 int height) { |
| 834 int y; | 834 int y; |
| 835 #if defined(HAS_RGB24TOYROW_NEON) | 835 #if (defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA)) |
| 836 void (*RGB24ToUVRow)(const uint8* src_rgb24, int src_stride_rgb24, | 836 void (*RGB24ToUVRow)(const uint8* src_rgb24, int src_stride_rgb24, |
| 837 uint8* dst_u, uint8* dst_v, int width) = RGB24ToUVRow_C; | 837 uint8* dst_u, uint8* dst_v, int width) = RGB24ToUVRow_C; |
| 838 void (*RGB24ToYRow)(const uint8* src_rgb24, uint8* dst_y, int width) = | 838 void (*RGB24ToYRow)(const uint8* src_rgb24, uint8* dst_y, int width) = |
| 839 RGB24ToYRow_C; | 839 RGB24ToYRow_C; |
| 840 #else | 840 #else |
| 841 void (*RGB24ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) = | 841 void (*RGB24ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) = |
| 842 RGB24ToARGBRow_C; | 842 RGB24ToARGBRow_C; |
| 843 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u, | 843 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u, |
| 844 uint8* dst_v, int width) = ARGBToUVRow_C; | 844 uint8* dst_v, int width) = ARGBToUVRow_C; |
| 845 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = | 845 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = |
| (...skipping 14 matching lines...) Expand all Loading... |
| 860 if (TestCpuFlag(kCpuHasNEON)) { | 860 if (TestCpuFlag(kCpuHasNEON)) { |
| 861 RGB24ToUVRow = RGB24ToUVRow_Any_NEON; | 861 RGB24ToUVRow = RGB24ToUVRow_Any_NEON; |
| 862 RGB24ToYRow = RGB24ToYRow_Any_NEON; | 862 RGB24ToYRow = RGB24ToYRow_Any_NEON; |
| 863 if (IS_ALIGNED(width, 8)) { | 863 if (IS_ALIGNED(width, 8)) { |
| 864 RGB24ToYRow = RGB24ToYRow_NEON; | 864 RGB24ToYRow = RGB24ToYRow_NEON; |
| 865 if (IS_ALIGNED(width, 16)) { | 865 if (IS_ALIGNED(width, 16)) { |
| 866 RGB24ToUVRow = RGB24ToUVRow_NEON; | 866 RGB24ToUVRow = RGB24ToUVRow_NEON; |
| 867 } | 867 } |
| 868 } | 868 } |
| 869 } | 869 } |
| 870 #elif defined(HAS_RGB24TOYROW_MSA) |
| 871 if (TestCpuFlag(kCpuHasMSA)) { |
| 872 RGB24ToUVRow = RGB24ToUVRow_Any_MSA; |
| 873 RGB24ToYRow = RGB24ToYRow_Any_MSA; |
| 874 if (IS_ALIGNED(width, 16)) { |
| 875 RGB24ToYRow = RGB24ToYRow_MSA; |
| 876 RGB24ToUVRow = RGB24ToUVRow_MSA; |
| 877 } |
| 878 } |
| 870 // Other platforms do intermediate conversion from RGB24 to ARGB. | 879 // Other platforms do intermediate conversion from RGB24 to ARGB. |
| 871 #else | 880 #else |
| 872 #if defined(HAS_RGB24TOARGBROW_SSSE3) | 881 #if defined(HAS_RGB24TOARGBROW_SSSE3) |
| 873 if (TestCpuFlag(kCpuHasSSSE3)) { | 882 if (TestCpuFlag(kCpuHasSSSE3)) { |
| 874 RGB24ToARGBRow = RGB24ToARGBRow_Any_SSSE3; | 883 RGB24ToARGBRow = RGB24ToARGBRow_Any_SSSE3; |
| 875 if (IS_ALIGNED(width, 16)) { | 884 if (IS_ALIGNED(width, 16)) { |
| 876 RGB24ToARGBRow = RGB24ToARGBRow_SSSE3; | 885 RGB24ToARGBRow = RGB24ToARGBRow_SSSE3; |
| 877 } | 886 } |
| 878 } | 887 } |
| 879 #endif | 888 #endif |
| (...skipping 17 matching lines...) Expand all Loading... |
| 897 } | 906 } |
| 898 } | 907 } |
| 899 #endif | 908 #endif |
| 900 { | 909 { |
| 901 // Allocate 2 rows of ARGB. | 910 // Allocate 2 rows of ARGB. |
| 902 const int kRowSize = (width * 4 + 31) & ~31; | 911 const int kRowSize = (width * 4 + 31) & ~31; |
| 903 align_buffer_64(row, kRowSize * 2); | 912 align_buffer_64(row, kRowSize * 2); |
| 904 #endif | 913 #endif |
| 905 | 914 |
| 906 for (y = 0; y < height - 1; y += 2) { | 915 for (y = 0; y < height - 1; y += 2) { |
| 907 #if defined(HAS_RGB24TOYROW_NEON) | 916 #if (defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA)) |
| 908 RGB24ToUVRow(src_rgb24, src_stride_rgb24, dst_u, dst_v, width); | 917 RGB24ToUVRow(src_rgb24, src_stride_rgb24, dst_u, dst_v, width); |
| 909 RGB24ToYRow(src_rgb24, dst_y, width); | 918 RGB24ToYRow(src_rgb24, dst_y, width); |
| 910 RGB24ToYRow(src_rgb24 + src_stride_rgb24, dst_y + dst_stride_y, width); | 919 RGB24ToYRow(src_rgb24 + src_stride_rgb24, dst_y + dst_stride_y, width); |
| 911 #else | 920 #else |
| 912 RGB24ToARGBRow(src_rgb24, row, width); | 921 RGB24ToARGBRow(src_rgb24, row, width); |
| 913 RGB24ToARGBRow(src_rgb24 + src_stride_rgb24, row + kRowSize, width); | 922 RGB24ToARGBRow(src_rgb24 + src_stride_rgb24, row + kRowSize, width); |
| 914 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); | 923 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); |
| 915 ARGBToYRow(row, dst_y, width); | 924 ARGBToYRow(row, dst_y, width); |
| 916 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); | 925 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); |
| 917 #endif | 926 #endif |
| 918 src_rgb24 += src_stride_rgb24 * 2; | 927 src_rgb24 += src_stride_rgb24 * 2; |
| 919 dst_y += dst_stride_y * 2; | 928 dst_y += dst_stride_y * 2; |
| 920 dst_u += dst_stride_u; | 929 dst_u += dst_stride_u; |
| 921 dst_v += dst_stride_v; | 930 dst_v += dst_stride_v; |
| 922 } | 931 } |
| 923 if (height & 1) { | 932 if (height & 1) { |
| 924 #if defined(HAS_RGB24TOYROW_NEON) | 933 #if (defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA)) |
| 925 RGB24ToUVRow(src_rgb24, 0, dst_u, dst_v, width); | 934 RGB24ToUVRow(src_rgb24, 0, dst_u, dst_v, width); |
| 926 RGB24ToYRow(src_rgb24, dst_y, width); | 935 RGB24ToYRow(src_rgb24, dst_y, width); |
| 927 #else | 936 #else |
| 928 RGB24ToARGBRow(src_rgb24, row, width); | 937 RGB24ToARGBRow(src_rgb24, row, width); |
| 929 ARGBToUVRow(row, 0, dst_u, dst_v, width); | 938 ARGBToUVRow(row, 0, dst_u, dst_v, width); |
| 930 ARGBToYRow(row, dst_y, width); | 939 ARGBToYRow(row, dst_y, width); |
| 931 #endif | 940 #endif |
| 932 } | 941 } |
| 933 #if !defined(HAS_RGB24TOYROW_NEON) | 942 #if !(defined(HAS_RGB24TOYROW_NEON) || defined(HAS_RGB24TOYROW_MSA)) |
| 934 free_aligned_buffer_64(row); | 943 free_aligned_buffer_64(row); |
| 935 } | 944 } |
| 936 #endif | 945 #endif |
| 937 return 0; | 946 return 0; |
| 938 } | 947 } |
| 939 | 948 |
| 940 // Convert RAW to I420. | 949 // Convert RAW to I420. |
| 941 LIBYUV_API | 950 LIBYUV_API |
| 942 int RAWToI420(const uint8* src_raw, | 951 int RAWToI420(const uint8* src_raw, |
| 943 int src_stride_raw, | 952 int src_stride_raw, |
| 944 uint8* dst_y, | 953 uint8* dst_y, |
| 945 int dst_stride_y, | 954 int dst_stride_y, |
| 946 uint8* dst_u, | 955 uint8* dst_u, |
| 947 int dst_stride_u, | 956 int dst_stride_u, |
| 948 uint8* dst_v, | 957 uint8* dst_v, |
| 949 int dst_stride_v, | 958 int dst_stride_v, |
| 950 int width, | 959 int width, |
| 951 int height) { | 960 int height) { |
| 952 int y; | 961 int y; |
| 953 #if defined(HAS_RAWTOYROW_NEON) | 962 #if (defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA)) |
| 954 void (*RAWToUVRow)(const uint8* src_raw, int src_stride_raw, uint8* dst_u, | 963 void (*RAWToUVRow)(const uint8* src_raw, int src_stride_raw, uint8* dst_u, |
| 955 uint8* dst_v, int width) = RAWToUVRow_C; | 964 uint8* dst_v, int width) = RAWToUVRow_C; |
| 956 void (*RAWToYRow)(const uint8* src_raw, uint8* dst_y, int width) = | 965 void (*RAWToYRow)(const uint8* src_raw, uint8* dst_y, int width) = |
| 957 RAWToYRow_C; | 966 RAWToYRow_C; |
| 958 #else | 967 #else |
| 959 void (*RAWToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) = | 968 void (*RAWToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) = |
| 960 RAWToARGBRow_C; | 969 RAWToARGBRow_C; |
| 961 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, | 970 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u, |
| 962 uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; | 971 uint8* dst_v, int width) = ARGBToUVRow_C; |
| 963 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = | 972 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = |
| 964 ARGBToYRow_C; | 973 ARGBToYRow_C; |
| 965 #endif | 974 #endif |
| 966 if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { | 975 if (!src_raw || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { |
| 967 return -1; | 976 return -1; |
| 968 } | 977 } |
| 969 // Negative height means invert the image. | 978 // Negative height means invert the image. |
| 970 if (height < 0) { | 979 if (height < 0) { |
| 971 height = -height; | 980 height = -height; |
| 972 src_raw = src_raw + (height - 1) * src_stride_raw; | 981 src_raw = src_raw + (height - 1) * src_stride_raw; |
| 973 src_stride_raw = -src_stride_raw; | 982 src_stride_raw = -src_stride_raw; |
| 974 } | 983 } |
| 975 | 984 |
| 976 // Neon version does direct RAW to YUV. | 985 // Neon version does direct RAW to YUV. |
| 977 #if defined(HAS_RAWTOYROW_NEON) | 986 #if defined(HAS_RAWTOYROW_NEON) |
| 978 if (TestCpuFlag(kCpuHasNEON)) { | 987 if (TestCpuFlag(kCpuHasNEON)) { |
| 979 RAWToUVRow = RAWToUVRow_Any_NEON; | 988 RAWToUVRow = RAWToUVRow_Any_NEON; |
| 980 RAWToYRow = RAWToYRow_Any_NEON; | 989 RAWToYRow = RAWToYRow_Any_NEON; |
| 981 if (IS_ALIGNED(width, 8)) { | 990 if (IS_ALIGNED(width, 8)) { |
| 982 RAWToYRow = RAWToYRow_NEON; | 991 RAWToYRow = RAWToYRow_NEON; |
| 983 if (IS_ALIGNED(width, 16)) { | 992 if (IS_ALIGNED(width, 16)) { |
| 984 RAWToUVRow = RAWToUVRow_NEON; | 993 RAWToUVRow = RAWToUVRow_NEON; |
| 985 } | 994 } |
| 986 } | 995 } |
| 987 } | 996 } |
| 997 #elif defined(HAS_RAWTOYROW_MSA) |
| 998 if (TestCpuFlag(kCpuHasMSA)) { |
| 999 RAWToUVRow = RAWToUVRow_Any_MSA; |
| 1000 RAWToYRow = RAWToYRow_Any_MSA; |
| 1001 if (IS_ALIGNED(width, 16)) { |
| 1002 RAWToYRow = RAWToYRow_MSA; |
| 1003 RAWToUVRow = RAWToUVRow_MSA; |
| 1004 } |
| 1005 } |
| 988 // Other platforms do intermediate conversion from RAW to ARGB. | 1006 // Other platforms do intermediate conversion from RAW to ARGB. |
| 989 #else | 1007 #else |
| 990 #if defined(HAS_RAWTOARGBROW_SSSE3) | 1008 #if defined(HAS_RAWTOARGBROW_SSSE3) |
| 991 if (TestCpuFlag(kCpuHasSSSE3)) { | 1009 if (TestCpuFlag(kCpuHasSSSE3)) { |
| 992 RAWToARGBRow = RAWToARGBRow_Any_SSSE3; | 1010 RAWToARGBRow = RAWToARGBRow_Any_SSSE3; |
| 993 if (IS_ALIGNED(width, 16)) { | 1011 if (IS_ALIGNED(width, 16)) { |
| 994 RAWToARGBRow = RAWToARGBRow_SSSE3; | 1012 RAWToARGBRow = RAWToARGBRow_SSSE3; |
| 995 } | 1013 } |
| 996 } | 1014 } |
| 997 #endif | 1015 #endif |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1015 } | 1033 } |
| 1016 } | 1034 } |
| 1017 #endif | 1035 #endif |
| 1018 { | 1036 { |
| 1019 // Allocate 2 rows of ARGB. | 1037 // Allocate 2 rows of ARGB. |
| 1020 const int kRowSize = (width * 4 + 31) & ~31; | 1038 const int kRowSize = (width * 4 + 31) & ~31; |
| 1021 align_buffer_64(row, kRowSize * 2); | 1039 align_buffer_64(row, kRowSize * 2); |
| 1022 #endif | 1040 #endif |
| 1023 | 1041 |
| 1024 for (y = 0; y < height - 1; y += 2) { | 1042 for (y = 0; y < height - 1; y += 2) { |
| 1025 #if defined(HAS_RAWTOYROW_NEON) | 1043 #if (defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA)) |
| 1026 RAWToUVRow(src_raw, src_stride_raw, dst_u, dst_v, width); | 1044 RAWToUVRow(src_raw, src_stride_raw, dst_u, dst_v, width); |
| 1027 RAWToYRow(src_raw, dst_y, width); | 1045 RAWToYRow(src_raw, dst_y, width); |
| 1028 RAWToYRow(src_raw + src_stride_raw, dst_y + dst_stride_y, width); | 1046 RAWToYRow(src_raw + src_stride_raw, dst_y + dst_stride_y, width); |
| 1029 #else | 1047 #else |
| 1030 RAWToARGBRow(src_raw, row, width); | 1048 RAWToARGBRow(src_raw, row, width); |
| 1031 RAWToARGBRow(src_raw + src_stride_raw, row + kRowSize, width); | 1049 RAWToARGBRow(src_raw + src_stride_raw, row + kRowSize, width); |
| 1032 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); | 1050 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); |
| 1033 ARGBToYRow(row, dst_y, width); | 1051 ARGBToYRow(row, dst_y, width); |
| 1034 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); | 1052 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); |
| 1035 #endif | 1053 #endif |
| 1036 src_raw += src_stride_raw * 2; | 1054 src_raw += src_stride_raw * 2; |
| 1037 dst_y += dst_stride_y * 2; | 1055 dst_y += dst_stride_y * 2; |
| 1038 dst_u += dst_stride_u; | 1056 dst_u += dst_stride_u; |
| 1039 dst_v += dst_stride_v; | 1057 dst_v += dst_stride_v; |
| 1040 } | 1058 } |
| 1041 if (height & 1) { | 1059 if (height & 1) { |
| 1042 #if defined(HAS_RAWTOYROW_NEON) | 1060 #if (defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA)) |
| 1043 RAWToUVRow(src_raw, 0, dst_u, dst_v, width); | 1061 RAWToUVRow(src_raw, 0, dst_u, dst_v, width); |
| 1044 RAWToYRow(src_raw, dst_y, width); | 1062 RAWToYRow(src_raw, dst_y, width); |
| 1045 #else | 1063 #else |
| 1046 RAWToARGBRow(src_raw, row, width); | 1064 RAWToARGBRow(src_raw, row, width); |
| 1047 ARGBToUVRow(row, 0, dst_u, dst_v, width); | 1065 ARGBToUVRow(row, 0, dst_u, dst_v, width); |
| 1048 ARGBToYRow(row, dst_y, width); | 1066 ARGBToYRow(row, dst_y, width); |
| 1049 #endif | 1067 #endif |
| 1050 } | 1068 } |
| 1051 #if !defined(HAS_RAWTOYROW_NEON) | 1069 #if !(defined(HAS_RAWTOYROW_NEON) || defined(HAS_RAWTOYROW_MSA)) |
| 1052 free_aligned_buffer_64(row); | 1070 free_aligned_buffer_64(row); |
| 1053 } | 1071 } |
| 1054 #endif | 1072 #endif |
| 1055 return 0; | 1073 return 0; |
| 1056 } | 1074 } |
| 1057 | 1075 |
| 1058 // Convert RGB565 to I420. | 1076 // Convert RGB565 to I420. |
| 1059 LIBYUV_API | 1077 LIBYUV_API |
| 1060 int RGB565ToI420(const uint8* src_rgb565, | 1078 int RGB565ToI420(const uint8* src_rgb565, |
| 1061 int src_stride_rgb565, | 1079 int src_stride_rgb565, |
| 1062 uint8* dst_y, | 1080 uint8* dst_y, |
| 1063 int dst_stride_y, | 1081 int dst_stride_y, |
| 1064 uint8* dst_u, | 1082 uint8* dst_u, |
| 1065 int dst_stride_u, | 1083 int dst_stride_u, |
| 1066 uint8* dst_v, | 1084 uint8* dst_v, |
| 1067 int dst_stride_v, | 1085 int dst_stride_v, |
| 1068 int width, | 1086 int width, |
| 1069 int height) { | 1087 int height) { |
| 1070 int y; | 1088 int y; |
| 1071 #if defined(HAS_RGB565TOYROW_NEON) | 1089 #if (defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA)) |
| 1072 void (*RGB565ToUVRow)(const uint8* src_rgb565, int src_stride_rgb565, | 1090 void (*RGB565ToUVRow)(const uint8* src_rgb565, int src_stride_rgb565, |
| 1073 uint8* dst_u, uint8* dst_v, int width) = | 1091 uint8* dst_u, uint8* dst_v, int width) = |
| 1074 RGB565ToUVRow_C; | 1092 RGB565ToUVRow_C; |
| 1075 void (*RGB565ToYRow)(const uint8* src_rgb565, uint8* dst_y, int width) = | 1093 void (*RGB565ToYRow)(const uint8* src_rgb565, uint8* dst_y, int width) = |
| 1076 RGB565ToYRow_C; | 1094 RGB565ToYRow_C; |
| 1077 #else | 1095 #else |
| 1078 void (*RGB565ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, | 1096 void (*RGB565ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) = |
| 1079 int width) = RGB565ToARGBRow_C; | 1097 RGB565ToARGBRow_C; |
| 1080 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, | 1098 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u, |
| 1081 uint8* dst_u, uint8* dst_v, int width) = | 1099 uint8* dst_v, int width) = ARGBToUVRow_C; |
| 1082 ARGBToUVRow_C; | 1100 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = |
| 1083 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = | 1101 ARGBToYRow_C; |
| 1084 ARGBToYRow_C; | |
| 1085 #endif | 1102 #endif |
| 1086 if (!src_rgb565 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { | 1103 if (!src_rgb565 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { |
| 1087 return -1; | 1104 return -1; |
| 1088 } | 1105 } |
| 1089 // Negative height means invert the image. | 1106 // Negative height means invert the image. |
| 1090 if (height < 0) { | 1107 if (height < 0) { |
| 1091 height = -height; | 1108 height = -height; |
| 1092 src_rgb565 = src_rgb565 + (height - 1) * src_stride_rgb565; | 1109 src_rgb565 = src_rgb565 + (height - 1) * src_stride_rgb565; |
| 1093 src_stride_rgb565 = -src_stride_rgb565; | 1110 src_stride_rgb565 = -src_stride_rgb565; |
| 1094 } | 1111 } |
| 1095 | 1112 |
| 1096 // Neon version does direct RGB565 to YUV. | 1113 // Neon version does direct RGB565 to YUV. |
| 1097 #if defined(HAS_RGB565TOYROW_NEON) | 1114 #if defined(HAS_RGB565TOYROW_NEON) |
| 1098 if (TestCpuFlag(kCpuHasNEON)) { | 1115 if (TestCpuFlag(kCpuHasNEON)) { |
| 1099 RGB565ToUVRow = RGB565ToUVRow_Any_NEON; | 1116 RGB565ToUVRow = RGB565ToUVRow_Any_NEON; |
| 1100 RGB565ToYRow = RGB565ToYRow_Any_NEON; | 1117 RGB565ToYRow = RGB565ToYRow_Any_NEON; |
| 1101 if (IS_ALIGNED(width, 8)) { | 1118 if (IS_ALIGNED(width, 8)) { |
| 1102 RGB565ToYRow = RGB565ToYRow_NEON; | 1119 RGB565ToYRow = RGB565ToYRow_NEON; |
| 1103 if (IS_ALIGNED(width, 16)) { | 1120 if (IS_ALIGNED(width, 16)) { |
| 1104 RGB565ToUVRow = RGB565ToUVRow_NEON; | 1121 RGB565ToUVRow = RGB565ToUVRow_NEON; |
| 1105 } | 1122 } |
| 1106 } | 1123 } |
| 1107 } | 1124 } |
| 1125 #elif defined(HAS_RGB565TOYROW_MSA) |
| 1126 if (TestCpuFlag(kCpuHasMSA)) { |
| 1127 RGB565ToUVRow = RGB565ToUVRow_Any_MSA; |
| 1128 RGB565ToYRow = RGB565ToYRow_Any_MSA; |
| 1129 if (IS_ALIGNED(width, 16)) { |
| 1130 RGB565ToYRow = RGB565ToYRow_MSA; |
| 1131 RGB565ToUVRow = RGB565ToUVRow_MSA; |
| 1132 } |
| 1133 } |
| 1108 // Other platforms do intermediate conversion from RGB565 to ARGB. | 1134 // Other platforms do intermediate conversion from RGB565 to ARGB. |
| 1109 #else | 1135 #else |
| 1110 #if defined(HAS_RGB565TOARGBROW_SSE2) | 1136 #if defined(HAS_RGB565TOARGBROW_SSE2) |
| 1111 if (TestCpuFlag(kCpuHasSSE2)) { | 1137 if (TestCpuFlag(kCpuHasSSE2)) { |
| 1112 RGB565ToARGBRow = RGB565ToARGBRow_Any_SSE2; | 1138 RGB565ToARGBRow = RGB565ToARGBRow_Any_SSE2; |
| 1113 if (IS_ALIGNED(width, 8)) { | 1139 if (IS_ALIGNED(width, 8)) { |
| 1114 RGB565ToARGBRow = RGB565ToARGBRow_SSE2; | 1140 RGB565ToARGBRow = RGB565ToARGBRow_SSE2; |
| 1115 } | 1141 } |
| 1116 } | 1142 } |
| 1117 #endif | 1143 #endif |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1143 } | 1169 } |
| 1144 } | 1170 } |
| 1145 #endif | 1171 #endif |
| 1146 { | 1172 { |
| 1147 // Allocate 2 rows of ARGB. | 1173 // Allocate 2 rows of ARGB. |
| 1148 const int kRowSize = (width * 4 + 31) & ~31; | 1174 const int kRowSize = (width * 4 + 31) & ~31; |
| 1149 align_buffer_64(row, kRowSize * 2); | 1175 align_buffer_64(row, kRowSize * 2); |
| 1150 #endif | 1176 #endif |
| 1151 | 1177 |
| 1152 for (y = 0; y < height - 1; y += 2) { | 1178 for (y = 0; y < height - 1; y += 2) { |
| 1153 #if defined(HAS_RGB565TOYROW_NEON) | 1179 #if (defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA)) |
| 1154 RGB565ToUVRow(src_rgb565, src_stride_rgb565, dst_u, dst_v, width); | 1180 RGB565ToUVRow(src_rgb565, src_stride_rgb565, dst_u, dst_v, width); |
| 1155 RGB565ToYRow(src_rgb565, dst_y, width); | 1181 RGB565ToYRow(src_rgb565, dst_y, width); |
| 1156 RGB565ToYRow(src_rgb565 + src_stride_rgb565, dst_y + dst_stride_y, width); | 1182 RGB565ToYRow(src_rgb565 + src_stride_rgb565, dst_y + dst_stride_y, width); |
| 1157 #else | 1183 #else |
| 1158 RGB565ToARGBRow(src_rgb565, row, width); | 1184 RGB565ToARGBRow(src_rgb565, row, width); |
| 1159 RGB565ToARGBRow(src_rgb565 + src_stride_rgb565, row + kRowSize, | 1185 RGB565ToARGBRow(src_rgb565 + src_stride_rgb565, row + kRowSize, width); |
| 1160 width); | 1186 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); |
| 1161 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); | 1187 ARGBToYRow(row, dst_y, width); |
| 1162 ARGBToYRow(row, dst_y, width); | 1188 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); |
| 1163 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); | |
| 1164 #endif | 1189 #endif |
| 1165 src_rgb565 += src_stride_rgb565 * 2; | 1190 src_rgb565 += src_stride_rgb565 * 2; |
| 1166 dst_y += dst_stride_y * 2; | 1191 dst_y += dst_stride_y * 2; |
| 1167 dst_u += dst_stride_u; | 1192 dst_u += dst_stride_u; |
| 1168 dst_v += dst_stride_v; | 1193 dst_v += dst_stride_v; |
| 1169 } | 1194 } |
| 1170 if (height & 1) { | 1195 if (height & 1) { |
| 1171 #if defined(HAS_RGB565TOYROW_NEON) | 1196 #if (defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA)) |
| 1172 RGB565ToUVRow(src_rgb565, 0, dst_u, dst_v, width); | 1197 RGB565ToUVRow(src_rgb565, 0, dst_u, dst_v, width); |
| 1173 RGB565ToYRow(src_rgb565, dst_y, width); | 1198 RGB565ToYRow(src_rgb565, dst_y, width); |
| 1174 #else | 1199 #else |
| 1175 RGB565ToARGBRow(src_rgb565, row, width); | 1200 RGB565ToARGBRow(src_rgb565, row, width); |
| 1176 ARGBToUVRow(row, 0, dst_u, dst_v, width); | 1201 ARGBToUVRow(row, 0, dst_u, dst_v, width); |
| 1177 ARGBToYRow(row, dst_y, width); | 1202 ARGBToYRow(row, dst_y, width); |
| 1178 #endif | 1203 #endif |
| 1179 } | 1204 } |
| 1180 #if !defined(HAS_RGB565TOYROW_NEON) | 1205 #if !(defined(HAS_RGB565TOYROW_NEON) || defined(HAS_RGB565TOYROW_MSA)) |
| 1181 free_aligned_buffer_64(row); | 1206 free_aligned_buffer_64(row); |
| 1182 } | 1207 } |
| 1183 #endif | 1208 #endif |
| 1184 return 0; | 1209 return 0; |
| 1185 } | 1210 } |
| 1186 | 1211 |
| 1187 // Convert ARGB1555 to I420. | 1212 // Convert ARGB1555 to I420. |
| 1188 LIBYUV_API | 1213 LIBYUV_API |
| 1189 int ARGB1555ToI420(const uint8* src_argb1555, | 1214 int ARGB1555ToI420(const uint8* src_argb1555, |
| 1190 int src_stride_argb1555, | 1215 int src_stride_argb1555, |
| 1191 uint8* dst_y, | 1216 uint8* dst_y, |
| 1192 int dst_stride_y, | 1217 int dst_stride_y, |
| 1193 uint8* dst_u, | 1218 uint8* dst_u, |
| 1194 int dst_stride_u, | 1219 int dst_stride_u, |
| 1195 uint8* dst_v, | 1220 uint8* dst_v, |
| 1196 int dst_stride_v, | 1221 int dst_stride_v, |
| 1197 int width, | 1222 int width, |
| 1198 int height) { | 1223 int height) { |
| 1199 int y; | 1224 int y; |
| 1200 #if defined(HAS_ARGB1555TOYROW_NEON) | 1225 #if (defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA)) |
| 1201 void (*ARGB1555ToUVRow)(const uint8* src_argb1555, int src_stride_argb1555, | 1226 void (*ARGB1555ToUVRow)(const uint8* src_argb1555, int src_stride_argb1555, |
| 1202 uint8* dst_u, uint8* dst_v, int width) = | 1227 uint8* dst_u, uint8* dst_v, int width) = |
| 1203 ARGB1555ToUVRow_C; | 1228 ARGB1555ToUVRow_C; |
| 1204 void (*ARGB1555ToYRow)(const uint8* src_argb1555, uint8* dst_y, int width) = | 1229 void (*ARGB1555ToYRow)(const uint8* src_argb1555, uint8* dst_y, int width) = |
| 1205 ARGB1555ToYRow_C; | 1230 ARGB1555ToYRow_C; |
| 1206 #else | 1231 #else |
| 1207 void (*ARGB1555ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, | 1232 void (*ARGB1555ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) = |
| 1208 int width) = ARGB1555ToARGBRow_C; | 1233 ARGB1555ToARGBRow_C; |
| 1209 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, | 1234 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u, |
| 1210 uint8* dst_u, uint8* dst_v, int width) = | 1235 uint8* dst_v, int width) = ARGBToUVRow_C; |
| 1211 ARGBToUVRow_C; | 1236 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = |
| 1212 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = | 1237 ARGBToYRow_C; |
| 1213 ARGBToYRow_C; | |
| 1214 #endif | 1238 #endif |
| 1215 if (!src_argb1555 || !dst_y || !dst_u || !dst_v || width <= 0 || | 1239 if (!src_argb1555 || !dst_y || !dst_u || !dst_v || width <= 0 || |
| 1216 height == 0) { | 1240 height == 0) { |
| 1217 return -1; | 1241 return -1; |
| 1218 } | 1242 } |
| 1219 // Negative height means invert the image. | 1243 // Negative height means invert the image. |
| 1220 if (height < 0) { | 1244 if (height < 0) { |
| 1221 height = -height; | 1245 height = -height; |
| 1222 src_argb1555 = src_argb1555 + (height - 1) * src_stride_argb1555; | 1246 src_argb1555 = src_argb1555 + (height - 1) * src_stride_argb1555; |
| 1223 src_stride_argb1555 = -src_stride_argb1555; | 1247 src_stride_argb1555 = -src_stride_argb1555; |
| 1224 } | 1248 } |
| 1225 | 1249 |
| 1226 // Neon version does direct ARGB1555 to YUV. | 1250 // Neon version does direct ARGB1555 to YUV. |
| 1227 #if defined(HAS_ARGB1555TOYROW_NEON) | 1251 #if defined(HAS_ARGB1555TOYROW_NEON) |
| 1228 if (TestCpuFlag(kCpuHasNEON)) { | 1252 if (TestCpuFlag(kCpuHasNEON)) { |
| 1229 ARGB1555ToUVRow = ARGB1555ToUVRow_Any_NEON; | 1253 ARGB1555ToUVRow = ARGB1555ToUVRow_Any_NEON; |
| 1230 ARGB1555ToYRow = ARGB1555ToYRow_Any_NEON; | 1254 ARGB1555ToYRow = ARGB1555ToYRow_Any_NEON; |
| 1231 if (IS_ALIGNED(width, 8)) { | 1255 if (IS_ALIGNED(width, 8)) { |
| 1232 ARGB1555ToYRow = ARGB1555ToYRow_NEON; | 1256 ARGB1555ToYRow = ARGB1555ToYRow_NEON; |
| 1233 if (IS_ALIGNED(width, 16)) { | 1257 if (IS_ALIGNED(width, 16)) { |
| 1234 ARGB1555ToUVRow = ARGB1555ToUVRow_NEON; | 1258 ARGB1555ToUVRow = ARGB1555ToUVRow_NEON; |
| 1235 } | 1259 } |
| 1236 } | 1260 } |
| 1237 } | 1261 } |
| 1262 #elif defined(HAS_ARGB1555TOYROW_MSA) |
| 1263 if (TestCpuFlag(kCpuHasMSA)) { |
| 1264 ARGB1555ToUVRow = ARGB1555ToUVRow_Any_MSA; |
| 1265 ARGB1555ToYRow = ARGB1555ToYRow_Any_MSA; |
| 1266 if (IS_ALIGNED(width, 16)) { |
| 1267 ARGB1555ToYRow = ARGB1555ToYRow_MSA; |
| 1268 ARGB1555ToUVRow = ARGB1555ToUVRow_MSA; |
| 1269 } |
| 1270 } |
| 1238 // Other platforms do intermediate conversion from ARGB1555 to ARGB. | 1271 // Other platforms do intermediate conversion from ARGB1555 to ARGB. |
| 1239 #else | 1272 #else |
| 1240 #if defined(HAS_ARGB1555TOARGBROW_SSE2) | 1273 #if defined(HAS_ARGB1555TOARGBROW_SSE2) |
| 1241 if (TestCpuFlag(kCpuHasSSE2)) { | 1274 if (TestCpuFlag(kCpuHasSSE2)) { |
| 1242 ARGB1555ToARGBRow = ARGB1555ToARGBRow_Any_SSE2; | 1275 ARGB1555ToARGBRow = ARGB1555ToARGBRow_Any_SSE2; |
| 1243 if (IS_ALIGNED(width, 8)) { | 1276 if (IS_ALIGNED(width, 8)) { |
| 1244 ARGB1555ToARGBRow = ARGB1555ToARGBRow_SSE2; | 1277 ARGB1555ToARGBRow = ARGB1555ToARGBRow_SSE2; |
| 1245 } | 1278 } |
| 1246 } | 1279 } |
| 1247 #endif | 1280 #endif |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1273 } | 1306 } |
| 1274 } | 1307 } |
| 1275 #endif | 1308 #endif |
| 1276 { | 1309 { |
| 1277 // Allocate 2 rows of ARGB. | 1310 // Allocate 2 rows of ARGB. |
| 1278 const int kRowSize = (width * 4 + 31) & ~31; | 1311 const int kRowSize = (width * 4 + 31) & ~31; |
| 1279 align_buffer_64(row, kRowSize * 2); | 1312 align_buffer_64(row, kRowSize * 2); |
| 1280 #endif | 1313 #endif |
| 1281 | 1314 |
| 1282 for (y = 0; y < height - 1; y += 2) { | 1315 for (y = 0; y < height - 1; y += 2) { |
| 1283 #if defined(HAS_ARGB1555TOYROW_NEON) | 1316 #if (defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA)) |
| 1284 ARGB1555ToUVRow(src_argb1555, src_stride_argb1555, dst_u, dst_v, width); | 1317 ARGB1555ToUVRow(src_argb1555, src_stride_argb1555, dst_u, dst_v, width); |
| 1285 ARGB1555ToYRow(src_argb1555, dst_y, width); | 1318 ARGB1555ToYRow(src_argb1555, dst_y, width); |
| 1286 ARGB1555ToYRow(src_argb1555 + src_stride_argb1555, dst_y + dst_stride_y, | 1319 ARGB1555ToYRow(src_argb1555 + src_stride_argb1555, dst_y + dst_stride_y, |
| 1287 width); | 1320 width); |
| 1288 #else | 1321 #else |
| 1289 ARGB1555ToARGBRow(src_argb1555, row, width); | 1322 ARGB1555ToARGBRow(src_argb1555, row, width); |
| 1290 ARGB1555ToARGBRow(src_argb1555 + src_stride_argb1555, | 1323 ARGB1555ToARGBRow(src_argb1555 + src_stride_argb1555, row + kRowSize, |
| 1291 row + kRowSize, width); | 1324 width); |
| 1292 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); | 1325 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); |
| 1293 ARGBToYRow(row, dst_y, width); | 1326 ARGBToYRow(row, dst_y, width); |
| 1294 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); | 1327 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); |
| 1295 #endif | 1328 #endif |
| 1296 src_argb1555 += src_stride_argb1555 * 2; | 1329 src_argb1555 += src_stride_argb1555 * 2; |
| 1297 dst_y += dst_stride_y * 2; | 1330 dst_y += dst_stride_y * 2; |
| 1298 dst_u += dst_stride_u; | 1331 dst_u += dst_stride_u; |
| 1299 dst_v += dst_stride_v; | 1332 dst_v += dst_stride_v; |
| 1300 } | 1333 } |
| 1301 if (height & 1) { | 1334 if (height & 1) { |
| 1302 #if defined(HAS_ARGB1555TOYROW_NEON) | 1335 #if (defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA)) |
| 1303 ARGB1555ToUVRow(src_argb1555, 0, dst_u, dst_v, width); | 1336 ARGB1555ToUVRow(src_argb1555, 0, dst_u, dst_v, width); |
| 1304 ARGB1555ToYRow(src_argb1555, dst_y, width); | 1337 ARGB1555ToYRow(src_argb1555, dst_y, width); |
| 1305 #else | 1338 #else |
| 1306 ARGB1555ToARGBRow(src_argb1555, row, width); | 1339 ARGB1555ToARGBRow(src_argb1555, row, width); |
| 1307 ARGBToUVRow(row, 0, dst_u, dst_v, width); | 1340 ARGBToUVRow(row, 0, dst_u, dst_v, width); |
| 1308 ARGBToYRow(row, dst_y, width); | 1341 ARGBToYRow(row, dst_y, width); |
| 1309 #endif | 1342 #endif |
| 1310 } | 1343 } |
| 1311 #if !defined(HAS_ARGB1555TOYROW_NEON) | 1344 #if !(defined(HAS_ARGB1555TOYROW_NEON) || defined(HAS_ARGB1555TOYROW_MSA)) |
| 1312 free_aligned_buffer_64(row); | 1345 free_aligned_buffer_64(row); |
| 1313 } | 1346 } |
| 1314 #endif | 1347 #endif |
| 1315 return 0; | 1348 return 0; |
| 1316 } | 1349 } |
| 1317 | 1350 |
| 1318 // Convert ARGB4444 to I420. | 1351 // Convert ARGB4444 to I420. |
| 1319 LIBYUV_API | 1352 LIBYUV_API |
| 1320 int ARGB4444ToI420(const uint8* src_argb4444, | 1353 int ARGB4444ToI420(const uint8* src_argb4444, |
| 1321 int src_stride_argb4444, | 1354 int src_stride_argb4444, |
| 1322 uint8* dst_y, | 1355 uint8* dst_y, |
| 1323 int dst_stride_y, | 1356 int dst_stride_y, |
| 1324 uint8* dst_u, | 1357 uint8* dst_u, |
| 1325 int dst_stride_u, | 1358 int dst_stride_u, |
| 1326 uint8* dst_v, | 1359 uint8* dst_v, |
| 1327 int dst_stride_v, | 1360 int dst_stride_v, |
| 1328 int width, | 1361 int width, |
| 1329 int height) { | 1362 int height) { |
| 1330 int y; | 1363 int y; |
| 1331 #if defined(HAS_ARGB4444TOYROW_NEON) | 1364 #if defined(HAS_ARGB4444TOYROW_NEON) |
| 1332 void (*ARGB4444ToUVRow)(const uint8* src_argb4444, int src_stride_argb4444, | 1365 void (*ARGB4444ToUVRow)(const uint8* src_argb4444, int src_stride_argb4444, |
| 1333 uint8* dst_u, uint8* dst_v, int width) = | 1366 uint8* dst_u, uint8* dst_v, int width) = |
| 1334 ARGB4444ToUVRow_C; | 1367 ARGB4444ToUVRow_C; |
| 1335 void (*ARGB4444ToYRow)(const uint8* src_argb4444, uint8* dst_y, int width) = | 1368 void (*ARGB4444ToYRow)(const uint8* src_argb4444, uint8* dst_y, int width) = |
| 1336 ARGB4444ToYRow_C; | 1369 ARGB4444ToYRow_C; |
| 1337 #else | 1370 #else |
| 1338 void (*ARGB4444ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, | 1371 void (*ARGB4444ToARGBRow)(const uint8* src_rgb, uint8* dst_argb, int width) = |
| 1339 int width) = ARGB4444ToARGBRow_C; | 1372 ARGB4444ToARGBRow_C; |
| 1340 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, | 1373 void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, uint8* dst_u, |
| 1341 uint8* dst_u, uint8* dst_v, int width) = | 1374 uint8* dst_v, int width) = ARGBToUVRow_C; |
| 1342 ARGBToUVRow_C; | 1375 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = |
| 1343 void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int width) = | 1376 ARGBToYRow_C; |
| 1344 ARGBToYRow_C; | |
| 1345 #endif | 1377 #endif |
| 1346 if (!src_argb4444 || !dst_y || !dst_u || !dst_v || width <= 0 || | 1378 if (!src_argb4444 || !dst_y || !dst_u || !dst_v || width <= 0 || |
| 1347 height == 0) { | 1379 height == 0) { |
| 1348 return -1; | 1380 return -1; |
| 1349 } | 1381 } |
| 1350 // Negative height means invert the image. | 1382 // Negative height means invert the image. |
| 1351 if (height < 0) { | 1383 if (height < 0) { |
| 1352 height = -height; | 1384 height = -height; |
| 1353 src_argb4444 = src_argb4444 + (height - 1) * src_stride_argb4444; | 1385 src_argb4444 = src_argb4444 + (height - 1) * src_stride_argb4444; |
| 1354 src_stride_argb4444 = -src_stride_argb4444; | 1386 src_stride_argb4444 = -src_stride_argb4444; |
| 1355 } | 1387 } |
| 1356 | 1388 |
| 1357 // Neon version does direct ARGB4444 to YUV. | 1389 // Neon version does direct ARGB4444 to YUV. |
| 1358 #if defined(HAS_ARGB4444TOYROW_NEON) | 1390 #if defined(HAS_ARGB4444TOYROW_NEON) |
| 1359 if (TestCpuFlag(kCpuHasNEON)) { | 1391 if (TestCpuFlag(kCpuHasNEON)) { |
| 1360 ARGB4444ToUVRow = ARGB4444ToUVRow_Any_NEON; | 1392 ARGB4444ToUVRow = ARGB4444ToUVRow_Any_NEON; |
| 1361 ARGB4444ToYRow = ARGB4444ToYRow_Any_NEON; | 1393 ARGB4444ToYRow = ARGB4444ToYRow_Any_NEON; |
| 1362 if (IS_ALIGNED(width, 8)) { | 1394 if (IS_ALIGNED(width, 8)) { |
| 1363 ARGB4444ToYRow = ARGB4444ToYRow_NEON; | 1395 ARGB4444ToYRow = ARGB4444ToYRow_NEON; |
| 1364 if (IS_ALIGNED(width, 16)) { | 1396 if (IS_ALIGNED(width, 16)) { |
| 1365 ARGB4444ToUVRow = ARGB4444ToUVRow_NEON; | 1397 ARGB4444ToUVRow = ARGB4444ToUVRow_NEON; |
| 1366 } | 1398 } |
| 1367 } | 1399 } |
| 1368 } | 1400 } |
| 1369 // Other platforms do intermediate conversion from ARGB4444 to ARGB. | 1401 // Other platforms do intermediate conversion from ARGB4444 to ARGB. |
| 1370 #else | 1402 #else |
| 1371 #if defined(HAS_ARGB4444TOARGBROW_SSE2) | 1403 #if defined(HAS_ARGB4444TOARGBROW_SSE2) |
| 1372 if (TestCpuFlag(kCpuHasSSE2)) { | 1404 if (TestCpuFlag(kCpuHasSSE2)) { |
| 1373 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_SSE2; | 1405 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_SSE2; |
| 1374 if (IS_ALIGNED(width, 8)) { | 1406 if (IS_ALIGNED(width, 8)) { |
| 1375 ARGB4444ToARGBRow = ARGB4444ToARGBRow_SSE2; | 1407 ARGB4444ToARGBRow = ARGB4444ToARGBRow_SSE2; |
| 1376 } | 1408 } |
| 1377 } | 1409 } |
| 1378 #endif | 1410 #endif |
| 1379 #if defined(HAS_ARGB4444TOARGBROW_AVX2) | 1411 #if defined(HAS_ARGB4444TOARGBROW_AVX2) |
| 1380 if (TestCpuFlag(kCpuHasAVX2)) { | 1412 if (TestCpuFlag(kCpuHasAVX2)) { |
| 1381 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_AVX2; | 1413 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_AVX2; |
| 1382 if (IS_ALIGNED(width, 16)) { | 1414 if (IS_ALIGNED(width, 16)) { |
| 1383 ARGB4444ToARGBRow = ARGB4444ToARGBRow_AVX2; | 1415 ARGB4444ToARGBRow = ARGB4444ToARGBRow_AVX2; |
| 1384 } | 1416 } |
| 1385 } | 1417 } |
| 1386 #endif | 1418 #endif |
| 1387 #if defined(HAS_ARGB4444TOARGBROW_MSA) | 1419 #if defined(HAS_ARGB4444TOARGBROW_MSA) |
| 1388 if (TestCpuFlag(kCpuHasMSA)) { | 1420 if (TestCpuFlag(kCpuHasMSA)) { |
| 1389 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_MSA; | 1421 ARGB4444ToARGBRow = ARGB4444ToARGBRow_Any_MSA; |
| 1390 if (IS_ALIGNED(width, 16)) { | 1422 if (IS_ALIGNED(width, 16)) { |
| 1391 ARGB4444ToARGBRow = ARGB4444ToARGBRow_MSA; | 1423 ARGB4444ToARGBRow = ARGB4444ToARGBRow_MSA; |
| 1392 } | 1424 } |
| 1393 } | 1425 } |
| 1394 #endif | 1426 #endif |
| 1395 #if defined(HAS_ARGBTOYROW_SSSE3) && defined(HAS_ARGBTOUVROW_SSSE3) | 1427 #if defined(HAS_ARGBTOYROW_SSSE3) && defined(HAS_ARGBTOUVROW_SSSE3) |
| 1396 if (TestCpuFlag(kCpuHasSSSE3)) { | 1428 if (TestCpuFlag(kCpuHasSSSE3)) { |
| 1397 ARGBToUVRow = ARGBToUVRow_Any_SSSE3; | 1429 ARGBToUVRow = ARGBToUVRow_Any_SSSE3; |
| 1398 ARGBToYRow = ARGBToYRow_Any_SSSE3; | 1430 ARGBToYRow = ARGBToYRow_Any_SSSE3; |
| 1399 if (IS_ALIGNED(width, 16)) { | 1431 if (IS_ALIGNED(width, 16)) { |
| 1400 ARGBToUVRow = ARGBToUVRow_SSSE3; | 1432 ARGBToUVRow = ARGBToUVRow_SSSE3; |
| 1401 ARGBToYRow = ARGBToYRow_SSSE3; | 1433 ARGBToYRow = ARGBToYRow_SSSE3; |
| 1402 } | 1434 } |
| 1403 } | 1435 } |
| 1404 #endif | 1436 #endif |
| 1405 #if defined(HAS_ARGBTOYROW_AVX2) && defined(HAS_ARGBTOUVROW_AVX2) | 1437 #if defined(HAS_ARGBTOYROW_AVX2) && defined(HAS_ARGBTOUVROW_AVX2) |
| 1406 if (TestCpuFlag(kCpuHasAVX2)) { | 1438 if (TestCpuFlag(kCpuHasAVX2)) { |
| 1407 ARGBToUVRow = ARGBToUVRow_Any_AVX2; | 1439 ARGBToUVRow = ARGBToUVRow_Any_AVX2; |
| 1408 ARGBToYRow = ARGBToYRow_Any_AVX2; | 1440 ARGBToYRow = ARGBToYRow_Any_AVX2; |
| 1409 if (IS_ALIGNED(width, 32)) { | 1441 if (IS_ALIGNED(width, 32)) { |
| 1410 ARGBToUVRow = ARGBToUVRow_AVX2; | 1442 ARGBToUVRow = ARGBToUVRow_AVX2; |
| 1411 ARGBToYRow = ARGBToYRow_AVX2; | 1443 ARGBToYRow = ARGBToYRow_AVX2; |
| 1412 } | 1444 } |
| 1413 } | 1445 } |
| 1414 #endif | 1446 #endif |
| 1415 #if defined(HAS_ARGBTOYROW_MSA) | 1447 #if defined(HAS_ARGBTOYROW_MSA) |
| 1416 if (TestCpuFlag(kCpuHasMSA)) { | 1448 if (TestCpuFlag(kCpuHasMSA)) { |
| 1417 ARGBToUVRow = ARGBToUVRow_Any_MSA; | 1449 ARGBToUVRow = ARGBToUVRow_Any_MSA; |
| 1418 ARGBToYRow = ARGBToYRow_Any_MSA; | 1450 ARGBToYRow = ARGBToYRow_Any_MSA; |
| 1419 if (IS_ALIGNED(width, 16)) { | 1451 if (IS_ALIGNED(width, 16)) { |
| 1420 ARGBToYRow = ARGBToYRow_MSA; | 1452 ARGBToYRow = ARGBToYRow_MSA; |
| 1421 if (IS_ALIGNED(width, 32)) { | 1453 if (IS_ALIGNED(width, 32)) { |
| 1422 ARGBToUVRow = ARGBToUVRow_MSA; | 1454 ARGBToUVRow = ARGBToUVRow_MSA; |
| 1423 } | 1455 } |
| 1424 } | 1456 } |
| 1425 } | 1457 } |
| 1426 #endif | 1458 #endif |
| 1427 { | 1459 { |
| 1428 // Allocate 2 rows of ARGB. | 1460 // Allocate 2 rows of ARGB. |
| 1429 const int kRowSize = (width * 4 + 31) & ~31; | 1461 const int kRowSize = (width * 4 + 31) & ~31; |
| 1430 align_buffer_64(row, kRowSize * 2); | 1462 align_buffer_64(row, kRowSize * 2); |
| 1431 #endif | 1463 #endif |
| 1432 | 1464 |
| 1433 for (y = 0; y < height - 1; y += 2) { | 1465 for (y = 0; y < height - 1; y += 2) { |
| 1434 #if defined(HAS_ARGB4444TOYROW_NEON) | 1466 #if defined(HAS_ARGB4444TOYROW_NEON) |
| 1435 ARGB4444ToUVRow(src_argb4444, src_stride_argb4444, dst_u, dst_v, width); | 1467 ARGB4444ToUVRow(src_argb4444, src_stride_argb4444, dst_u, dst_v, width); |
| 1436 ARGB4444ToYRow(src_argb4444, dst_y, width); | 1468 ARGB4444ToYRow(src_argb4444, dst_y, width); |
| 1437 ARGB4444ToYRow(src_argb4444 + src_stride_argb4444, dst_y + dst_stride_y, | 1469 ARGB4444ToYRow(src_argb4444 + src_stride_argb4444, dst_y + dst_stride_y, |
| 1438 width); | 1470 width); |
| 1439 #else | 1471 #else |
| 1440 ARGB4444ToARGBRow(src_argb4444, row, width); | 1472 ARGB4444ToARGBRow(src_argb4444, row, width); |
| 1441 ARGB4444ToARGBRow(src_argb4444 + src_stride_argb4444, | 1473 ARGB4444ToARGBRow(src_argb4444 + src_stride_argb4444, row + kRowSize, |
| 1442 row + kRowSize, width); | 1474 width); |
| 1443 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); | 1475 ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); |
| 1444 ARGBToYRow(row, dst_y, width); | 1476 ARGBToYRow(row, dst_y, width); |
| 1445 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); | 1477 ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); |
| 1446 #endif | 1478 #endif |
| 1447 src_argb4444 += src_stride_argb4444 * 2; | 1479 src_argb4444 += src_stride_argb4444 * 2; |
| 1448 dst_y += dst_stride_y * 2; | 1480 dst_y += dst_stride_y * 2; |
| 1449 dst_u += dst_stride_u; | 1481 dst_u += dst_stride_u; |
| 1450 dst_v += dst_stride_v; | 1482 dst_v += dst_stride_v; |
| 1451 } | 1483 } |
| 1452 if (height & 1) { | 1484 if (height & 1) { |
| 1453 #if defined(HAS_ARGB4444TOYROW_NEON) | 1485 #if defined(HAS_ARGB4444TOYROW_NEON) |
| 1454 ARGB4444ToUVRow(src_argb4444, 0, dst_u, dst_v, width); | 1486 ARGB4444ToUVRow(src_argb4444, 0, dst_u, dst_v, width); |
| 1455 ARGB4444ToYRow(src_argb4444, dst_y, width); | 1487 ARGB4444ToYRow(src_argb4444, dst_y, width); |
| 1456 #else | 1488 #else |
| 1457 ARGB4444ToARGBRow(src_argb4444, row, width); | 1489 ARGB4444ToARGBRow(src_argb4444, row, width); |
| 1458 ARGBToUVRow(row, 0, dst_u, dst_v, width); | 1490 ARGBToUVRow(row, 0, dst_u, dst_v, width); |
| 1459 ARGBToYRow(row, dst_y, width); | 1491 ARGBToYRow(row, dst_y, width); |
| 1460 #endif | 1492 #endif |
| 1461 } | 1493 } |
| 1462 #if !defined(HAS_ARGB4444TOYROW_NEON) | 1494 #if !defined(HAS_ARGB4444TOYROW_NEON) |
| 1463 free_aligned_buffer_64(row); | 1495 free_aligned_buffer_64(row); |
| 1464 } | 1496 } |
| 1465 #endif | 1497 #endif |
| 1466 return 0; | 1498 return 0; |
| 1467 } | 1499 } |
| 1468 | 1500 |
| 1469 static void SplitPixels(const uint8* src_u, | 1501 static void SplitPixels(const uint8* src_u, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 dst_u += dst_stride_u; | 1577 dst_u += dst_stride_u; |
| 1546 dst_v += dst_stride_v; | 1578 dst_v += dst_stride_v; |
| 1547 } | 1579 } |
| 1548 return 0; | 1580 return 0; |
| 1549 } | 1581 } |
| 1550 | 1582 |
| 1551 #ifdef __cplusplus | 1583 #ifdef __cplusplus |
| 1552 } // extern "C" | 1584 } // extern "C" |
| 1553 } // namespace libyuv | 1585 } // namespace libyuv |
| 1554 #endif | 1586 #endif |
| OLD | NEW |