| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 280 |
| 281 // Convert YUY2 to I422. | 281 // Convert YUY2 to I422. |
| 282 LIBYUV_API | 282 LIBYUV_API |
| 283 int YUY2ToI422(const uint8* src_yuy2, int src_stride_yuy2, | 283 int YUY2ToI422(const uint8* src_yuy2, int src_stride_yuy2, |
| 284 uint8* dst_y, int dst_stride_y, | 284 uint8* dst_y, int dst_stride_y, |
| 285 uint8* dst_u, int dst_stride_u, | 285 uint8* dst_u, int dst_stride_u, |
| 286 uint8* dst_v, int dst_stride_v, | 286 uint8* dst_v, int dst_stride_v, |
| 287 int width, int height) { | 287 int width, int height) { |
| 288 int y; | 288 int y; |
| 289 void (*YUY2ToUV422Row)(const uint8* src_yuy2, | 289 void (*YUY2ToUV422Row)(const uint8* src_yuy2, |
| 290 uint8* dst_u, uint8* dst_v, int pix) = | 290 uint8* dst_u, uint8* dst_v, int width) = |
| 291 YUY2ToUV422Row_C; | 291 YUY2ToUV422Row_C; |
| 292 void (*YUY2ToYRow)(const uint8* src_yuy2, uint8* dst_y, int pix) = | 292 void (*YUY2ToYRow)(const uint8* src_yuy2, uint8* dst_y, int width) = |
| 293 YUY2ToYRow_C; | 293 YUY2ToYRow_C; |
| 294 // Negative height means invert the image. | 294 // Negative height means invert the image. |
| 295 if (height < 0) { | 295 if (height < 0) { |
| 296 height = -height; | 296 height = -height; |
| 297 src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2; | 297 src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2; |
| 298 src_stride_yuy2 = -src_stride_yuy2; | 298 src_stride_yuy2 = -src_stride_yuy2; |
| 299 } | 299 } |
| 300 // Coalesce rows. | 300 // Coalesce rows. |
| 301 if (src_stride_yuy2 == width * 2 && | 301 if (src_stride_yuy2 == width * 2 && |
| 302 dst_stride_y == width && | 302 dst_stride_y == width && |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 352 |
| 353 // Convert UYVY to I422. | 353 // Convert UYVY to I422. |
| 354 LIBYUV_API | 354 LIBYUV_API |
| 355 int UYVYToI422(const uint8* src_uyvy, int src_stride_uyvy, | 355 int UYVYToI422(const uint8* src_uyvy, int src_stride_uyvy, |
| 356 uint8* dst_y, int dst_stride_y, | 356 uint8* dst_y, int dst_stride_y, |
| 357 uint8* dst_u, int dst_stride_u, | 357 uint8* dst_u, int dst_stride_u, |
| 358 uint8* dst_v, int dst_stride_v, | 358 uint8* dst_v, int dst_stride_v, |
| 359 int width, int height) { | 359 int width, int height) { |
| 360 int y; | 360 int y; |
| 361 void (*UYVYToUV422Row)(const uint8* src_uyvy, | 361 void (*UYVYToUV422Row)(const uint8* src_uyvy, |
| 362 uint8* dst_u, uint8* dst_v, int pix) = | 362 uint8* dst_u, uint8* dst_v, int width) = |
| 363 UYVYToUV422Row_C; | 363 UYVYToUV422Row_C; |
| 364 void (*UYVYToYRow)(const uint8* src_uyvy, | 364 void (*UYVYToYRow)(const uint8* src_uyvy, |
| 365 uint8* dst_y, int pix) = UYVYToYRow_C; | 365 uint8* dst_y, int width) = UYVYToYRow_C; |
| 366 // Negative height means invert the image. | 366 // Negative height means invert the image. |
| 367 if (height < 0) { | 367 if (height < 0) { |
| 368 height = -height; | 368 height = -height; |
| 369 src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy; | 369 src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy; |
| 370 src_stride_uyvy = -src_stride_uyvy; | 370 src_stride_uyvy = -src_stride_uyvy; |
| 371 } | 371 } |
| 372 // Coalesce rows. | 372 // Coalesce rows. |
| 373 if (src_stride_uyvy == width * 2 && | 373 if (src_stride_uyvy == width * 2 && |
| 374 dst_stride_y == width && | 374 dst_stride_y == width && |
| 375 dst_stride_u * 2 == width && | 375 dst_stride_u * 2 == width && |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 int I422ToBGRA(const uint8* src_y, int src_stride_y, | 783 int I422ToBGRA(const uint8* src_y, int src_stride_y, |
| 784 const uint8* src_u, int src_stride_u, | 784 const uint8* src_u, int src_stride_u, |
| 785 const uint8* src_v, int src_stride_v, | 785 const uint8* src_v, int src_stride_v, |
| 786 uint8* dst_bgra, int dst_stride_bgra, | 786 uint8* dst_bgra, int dst_stride_bgra, |
| 787 int width, int height) { | 787 int width, int height) { |
| 788 int y; | 788 int y; |
| 789 void (*I422ToBGRARow)(const uint8* y_buf, | 789 void (*I422ToBGRARow)(const uint8* y_buf, |
| 790 const uint8* u_buf, | 790 const uint8* u_buf, |
| 791 const uint8* v_buf, | 791 const uint8* v_buf, |
| 792 uint8* rgb_buf, | 792 uint8* rgb_buf, |
| 793 struct YuvConstants* yuvconstants, |
| 793 int width) = I422ToBGRARow_C; | 794 int width) = I422ToBGRARow_C; |
| 794 if (!src_y || !src_u || !src_v || | 795 if (!src_y || !src_u || !src_v || |
| 795 !dst_bgra || | 796 !dst_bgra || |
| 796 width <= 0 || height == 0) { | 797 width <= 0 || height == 0) { |
| 797 return -1; | 798 return -1; |
| 798 } | 799 } |
| 799 // Negative height means invert the image. | 800 // Negative height means invert the image. |
| 800 if (height < 0) { | 801 if (height < 0) { |
| 801 height = -height; | 802 height = -height; |
| 802 dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra; | 803 dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | 840 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && |
| 840 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | 841 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && |
| 841 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | 842 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && |
| 842 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | 843 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && |
| 843 IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) { | 844 IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) { |
| 844 I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2; | 845 I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2; |
| 845 } | 846 } |
| 846 #endif | 847 #endif |
| 847 | 848 |
| 848 for (y = 0; y < height; ++y) { | 849 for (y = 0; y < height; ++y) { |
| 849 I422ToBGRARow(src_y, src_u, src_v, dst_bgra, width); | 850 I422ToBGRARow(src_y, src_u, src_v, dst_bgra, &kYuvConstants, width); |
| 850 dst_bgra += dst_stride_bgra; | 851 dst_bgra += dst_stride_bgra; |
| 851 src_y += src_stride_y; | 852 src_y += src_stride_y; |
| 852 src_u += src_stride_u; | 853 src_u += src_stride_u; |
| 853 src_v += src_stride_v; | 854 src_v += src_stride_v; |
| 854 } | 855 } |
| 855 return 0; | 856 return 0; |
| 856 } | 857 } |
| 857 | 858 |
| 858 // Convert I422 to ABGR. | 859 // Convert I422 to ABGR. |
| 859 LIBYUV_API | 860 LIBYUV_API |
| 860 int I422ToABGR(const uint8* src_y, int src_stride_y, | 861 int I422ToABGR(const uint8* src_y, int src_stride_y, |
| 861 const uint8* src_u, int src_stride_u, | 862 const uint8* src_u, int src_stride_u, |
| 862 const uint8* src_v, int src_stride_v, | 863 const uint8* src_v, int src_stride_v, |
| 863 uint8* dst_abgr, int dst_stride_abgr, | 864 uint8* dst_abgr, int dst_stride_abgr, |
| 864 int width, int height) { | 865 int width, int height) { |
| 865 int y; | 866 int y; |
| 866 void (*I422ToABGRRow)(const uint8* y_buf, | 867 void (*I422ToABGRRow)(const uint8* y_buf, |
| 867 const uint8* u_buf, | 868 const uint8* u_buf, |
| 868 const uint8* v_buf, | 869 const uint8* v_buf, |
| 869 uint8* rgb_buf, | 870 uint8* rgb_buf, |
| 871 struct YuvConstants* yuvconstants, |
| 870 int width) = I422ToABGRRow_C; | 872 int width) = I422ToABGRRow_C; |
| 871 if (!src_y || !src_u || !src_v || | 873 if (!src_y || !src_u || !src_v || |
| 872 !dst_abgr || | 874 !dst_abgr || |
| 873 width <= 0 || height == 0) { | 875 width <= 0 || height == 0) { |
| 874 return -1; | 876 return -1; |
| 875 } | 877 } |
| 876 // Negative height means invert the image. | 878 // Negative height means invert the image. |
| 877 if (height < 0) { | 879 if (height < 0) { |
| 878 height = -height; | 880 height = -height; |
| 879 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; | 881 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 907 #if defined(HAS_I422TOABGRROW_AVX2) | 909 #if defined(HAS_I422TOABGRROW_AVX2) |
| 908 if (TestCpuFlag(kCpuHasAVX2)) { | 910 if (TestCpuFlag(kCpuHasAVX2)) { |
| 909 I422ToABGRRow = I422ToABGRRow_Any_AVX2; | 911 I422ToABGRRow = I422ToABGRRow_Any_AVX2; |
| 910 if (IS_ALIGNED(width, 16)) { | 912 if (IS_ALIGNED(width, 16)) { |
| 911 I422ToABGRRow = I422ToABGRRow_AVX2; | 913 I422ToABGRRow = I422ToABGRRow_AVX2; |
| 912 } | 914 } |
| 913 } | 915 } |
| 914 #endif | 916 #endif |
| 915 | 917 |
| 916 for (y = 0; y < height; ++y) { | 918 for (y = 0; y < height; ++y) { |
| 917 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, width); | 919 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvConstants, width); |
| 918 dst_abgr += dst_stride_abgr; | 920 dst_abgr += dst_stride_abgr; |
| 919 src_y += src_stride_y; | 921 src_y += src_stride_y; |
| 920 src_u += src_stride_u; | 922 src_u += src_stride_u; |
| 921 src_v += src_stride_v; | 923 src_v += src_stride_v; |
| 922 } | 924 } |
| 923 return 0; | 925 return 0; |
| 924 } | 926 } |
| 925 | 927 |
| 926 // Convert I422 to RGBA. | 928 // Convert I422 to RGBA. |
| 927 LIBYUV_API | 929 LIBYUV_API |
| 928 int I422ToRGBA(const uint8* src_y, int src_stride_y, | 930 int I422ToRGBA(const uint8* src_y, int src_stride_y, |
| 929 const uint8* src_u, int src_stride_u, | 931 const uint8* src_u, int src_stride_u, |
| 930 const uint8* src_v, int src_stride_v, | 932 const uint8* src_v, int src_stride_v, |
| 931 uint8* dst_rgba, int dst_stride_rgba, | 933 uint8* dst_rgba, int dst_stride_rgba, |
| 932 int width, int height) { | 934 int width, int height) { |
| 933 int y; | 935 int y; |
| 934 void (*I422ToRGBARow)(const uint8* y_buf, | 936 void (*I422ToRGBARow)(const uint8* y_buf, |
| 935 const uint8* u_buf, | 937 const uint8* u_buf, |
| 936 const uint8* v_buf, | 938 const uint8* v_buf, |
| 937 uint8* rgb_buf, | 939 uint8* rgb_buf, |
| 940 struct YuvConstants* yuvconstants, |
| 938 int width) = I422ToRGBARow_C; | 941 int width) = I422ToRGBARow_C; |
| 939 if (!src_y || !src_u || !src_v || | 942 if (!src_y || !src_u || !src_v || |
| 940 !dst_rgba || | 943 !dst_rgba || |
| 941 width <= 0 || height == 0) { | 944 width <= 0 || height == 0) { |
| 942 return -1; | 945 return -1; |
| 943 } | 946 } |
| 944 // Negative height means invert the image. | 947 // Negative height means invert the image. |
| 945 if (height < 0) { | 948 if (height < 0) { |
| 946 height = -height; | 949 height = -height; |
| 947 dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba; | 950 dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 975 #if defined(HAS_I422TORGBAROW_AVX2) | 978 #if defined(HAS_I422TORGBAROW_AVX2) |
| 976 if (TestCpuFlag(kCpuHasAVX2)) { | 979 if (TestCpuFlag(kCpuHasAVX2)) { |
| 977 I422ToRGBARow = I422ToRGBARow_Any_AVX2; | 980 I422ToRGBARow = I422ToRGBARow_Any_AVX2; |
| 978 if (IS_ALIGNED(width, 16)) { | 981 if (IS_ALIGNED(width, 16)) { |
| 979 I422ToRGBARow = I422ToRGBARow_AVX2; | 982 I422ToRGBARow = I422ToRGBARow_AVX2; |
| 980 } | 983 } |
| 981 } | 984 } |
| 982 #endif | 985 #endif |
| 983 | 986 |
| 984 for (y = 0; y < height; ++y) { | 987 for (y = 0; y < height; ++y) { |
| 985 I422ToRGBARow(src_y, src_u, src_v, dst_rgba, width); | 988 I422ToRGBARow(src_y, src_u, src_v, dst_rgba, &kYuvConstants, width); |
| 986 dst_rgba += dst_stride_rgba; | 989 dst_rgba += dst_stride_rgba; |
| 987 src_y += src_stride_y; | 990 src_y += src_stride_y; |
| 988 src_u += src_stride_u; | 991 src_u += src_stride_u; |
| 989 src_v += src_stride_v; | 992 src_v += src_stride_v; |
| 990 } | 993 } |
| 991 return 0; | 994 return 0; |
| 992 } | 995 } |
| 993 | 996 |
| 994 // Convert NV12 to RGB565. | 997 // Convert NV12 to RGB565. |
| 995 LIBYUV_API | 998 LIBYUV_API |
| 996 int NV12ToRGB565(const uint8* src_y, int src_stride_y, | 999 int NV12ToRGB565(const uint8* src_y, int src_stride_y, |
| 997 const uint8* src_uv, int src_stride_uv, | 1000 const uint8* src_uv, int src_stride_uv, |
| 998 uint8* dst_rgb565, int dst_stride_rgb565, | 1001 uint8* dst_rgb565, int dst_stride_rgb565, |
| 999 int width, int height) { | 1002 int width, int height) { |
| 1000 int y; | 1003 int y; |
| 1001 void (*NV12ToRGB565Row)(const uint8* y_buf, | 1004 void (*NV12ToRGB565Row)(const uint8* y_buf, |
| 1002 const uint8* uv_buf, | 1005 const uint8* uv_buf, |
| 1003 uint8* rgb_buf, | 1006 uint8* rgb_buf, |
| 1007 struct YuvConstants* yuvconstants, |
| 1004 int width) = NV12ToRGB565Row_C; | 1008 int width) = NV12ToRGB565Row_C; |
| 1005 if (!src_y || !src_uv || !dst_rgb565 || | 1009 if (!src_y || !src_uv || !dst_rgb565 || |
| 1006 width <= 0 || height == 0) { | 1010 width <= 0 || height == 0) { |
| 1007 return -1; | 1011 return -1; |
| 1008 } | 1012 } |
| 1009 // Negative height means invert the image. | 1013 // Negative height means invert the image. |
| 1010 if (height < 0) { | 1014 if (height < 0) { |
| 1011 height = -height; | 1015 height = -height; |
| 1012 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; | 1016 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; |
| 1013 dst_stride_rgb565 = -dst_stride_rgb565; | 1017 dst_stride_rgb565 = -dst_stride_rgb565; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1031 #if defined(HAS_NV12TORGB565ROW_NEON) | 1035 #if defined(HAS_NV12TORGB565ROW_NEON) |
| 1032 if (TestCpuFlag(kCpuHasNEON)) { | 1036 if (TestCpuFlag(kCpuHasNEON)) { |
| 1033 NV12ToRGB565Row = NV12ToRGB565Row_Any_NEON; | 1037 NV12ToRGB565Row = NV12ToRGB565Row_Any_NEON; |
| 1034 if (IS_ALIGNED(width, 8)) { | 1038 if (IS_ALIGNED(width, 8)) { |
| 1035 NV12ToRGB565Row = NV12ToRGB565Row_NEON; | 1039 NV12ToRGB565Row = NV12ToRGB565Row_NEON; |
| 1036 } | 1040 } |
| 1037 } | 1041 } |
| 1038 #endif | 1042 #endif |
| 1039 | 1043 |
| 1040 for (y = 0; y < height; ++y) { | 1044 for (y = 0; y < height; ++y) { |
| 1041 NV12ToRGB565Row(src_y, src_uv, dst_rgb565, width); | 1045 NV12ToRGB565Row(src_y, src_uv, dst_rgb565, &kYuvConstants, width); |
| 1042 dst_rgb565 += dst_stride_rgb565; | 1046 dst_rgb565 += dst_stride_rgb565; |
| 1043 src_y += src_stride_y; | 1047 src_y += src_stride_y; |
| 1044 if (y & 1) { | 1048 if (y & 1) { |
| 1045 src_uv += src_stride_uv; | 1049 src_uv += src_stride_uv; |
| 1046 } | 1050 } |
| 1047 } | 1051 } |
| 1048 return 0; | 1052 return 0; |
| 1049 } | 1053 } |
| 1050 | 1054 |
| 1051 // Convert NV21 to RGB565. | 1055 // Convert NV21 to RGB565. |
| 1052 LIBYUV_API | 1056 LIBYUV_API |
| 1053 int NV21ToRGB565(const uint8* src_y, int src_stride_y, | 1057 int NV21ToRGB565(const uint8* src_y, int src_stride_y, |
| 1054 const uint8* src_vu, int src_stride_vu, | 1058 const uint8* src_vu, int src_stride_vu, |
| 1055 uint8* dst_rgb565, int dst_stride_rgb565, | 1059 uint8* dst_rgb565, int dst_stride_rgb565, |
| 1056 int width, int height) { | 1060 int width, int height) { |
| 1057 int y; | 1061 int y; |
| 1058 void (*NV21ToRGB565Row)(const uint8* y_buf, | 1062 void (*NV12ToRGB565Row)(const uint8* y_buf, |
| 1059 const uint8* src_vu, | 1063 const uint8* src_vu, |
| 1060 uint8* rgb_buf, | 1064 uint8* rgb_buf, |
| 1061 int width) = NV21ToRGB565Row_C; | 1065 struct YuvConstants* yuvconstants, |
| 1066 int width) = NV12ToRGB565Row_C; |
| 1062 if (!src_y || !src_vu || !dst_rgb565 || | 1067 if (!src_y || !src_vu || !dst_rgb565 || |
| 1063 width <= 0 || height == 0) { | 1068 width <= 0 || height == 0) { |
| 1064 return -1; | 1069 return -1; |
| 1065 } | 1070 } |
| 1066 // Negative height means invert the image. | 1071 // Negative height means invert the image. |
| 1067 if (height < 0) { | 1072 if (height < 0) { |
| 1068 height = -height; | 1073 height = -height; |
| 1069 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; | 1074 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; |
| 1070 dst_stride_rgb565 = -dst_stride_rgb565; | 1075 dst_stride_rgb565 = -dst_stride_rgb565; |
| 1071 } | 1076 } |
| 1072 #if defined(HAS_NV21TORGB565ROW_SSSE3) | 1077 #if defined(HAS_NV12TORGB565ROW_SSSE3) |
| 1073 if (TestCpuFlag(kCpuHasSSSE3)) { | 1078 if (TestCpuFlag(kCpuHasSSSE3)) { |
| 1074 NV21ToRGB565Row = NV21ToRGB565Row_Any_SSSE3; | 1079 NV12ToRGB565Row = NV12ToRGB565Row_Any_SSSE3; |
| 1075 if (IS_ALIGNED(width, 8)) { | 1080 if (IS_ALIGNED(width, 8)) { |
| 1076 NV21ToRGB565Row = NV21ToRGB565Row_SSSE3; | 1081 NV12ToRGB565Row = NV12ToRGB565Row_SSSE3; |
| 1077 } | 1082 } |
| 1078 } | 1083 } |
| 1079 #endif | 1084 #endif |
| 1080 #if defined(HAS_NV21TORGB565ROW_AVX2) | 1085 #if defined(HAS_NV12TORGB565ROW_AVX2) |
| 1081 if (TestCpuFlag(kCpuHasAVX2)) { | 1086 if (TestCpuFlag(kCpuHasAVX2)) { |
| 1082 NV21ToRGB565Row = NV21ToRGB565Row_Any_AVX2; | 1087 NV12ToRGB565Row = NV12ToRGB565Row_Any_AVX2; |
| 1083 if (IS_ALIGNED(width, 16)) { | 1088 if (IS_ALIGNED(width, 16)) { |
| 1084 NV21ToRGB565Row = NV21ToRGB565Row_AVX2; | 1089 NV12ToRGB565Row = NV12ToRGB565Row_AVX2; |
| 1085 } | 1090 } |
| 1086 } | 1091 } |
| 1087 #endif | 1092 #endif |
| 1088 #if defined(HAS_NV21TORGB565ROW_NEON) | 1093 #if defined(HAS_NV12TORGB565ROW_NEON) |
| 1089 if (TestCpuFlag(kCpuHasNEON)) { | 1094 if (TestCpuFlag(kCpuHasNEON)) { |
| 1090 NV21ToRGB565Row = NV21ToRGB565Row_Any_NEON; | 1095 NV12ToRGB565Row = NV12ToRGB565Row_Any_NEON; |
| 1091 if (IS_ALIGNED(width, 8)) { | 1096 if (IS_ALIGNED(width, 8)) { |
| 1092 NV21ToRGB565Row = NV21ToRGB565Row_NEON; | 1097 NV12ToRGB565Row = NV12ToRGB565Row_NEON; |
| 1093 } | 1098 } |
| 1094 } | 1099 } |
| 1095 #endif | 1100 #endif |
| 1096 | 1101 |
| 1097 for (y = 0; y < height; ++y) { | 1102 for (y = 0; y < height; ++y) { |
| 1098 NV21ToRGB565Row(src_y, src_vu, dst_rgb565, width); | 1103 NV12ToRGB565Row(src_y, src_vu, dst_rgb565, &kYvuConstants, width); |
| 1099 dst_rgb565 += dst_stride_rgb565; | 1104 dst_rgb565 += dst_stride_rgb565; |
| 1100 src_y += src_stride_y; | 1105 src_y += src_stride_y; |
| 1101 if (y & 1) { | 1106 if (y & 1) { |
| 1102 src_vu += src_stride_vu; | 1107 src_vu += src_stride_vu; |
| 1103 } | 1108 } |
| 1104 } | 1109 } |
| 1105 return 0; | 1110 return 0; |
| 1106 } | 1111 } |
| 1107 | 1112 |
| 1108 LIBYUV_API | 1113 LIBYUV_API |
| 1109 void SetPlane(uint8* dst_y, int dst_stride_y, | 1114 void SetPlane(uint8* dst_y, int dst_stride_y, |
| 1110 int width, int height, | 1115 int width, int height, |
| 1111 uint32 value) { | 1116 uint32 value) { |
| 1112 int y; | 1117 int y; |
| 1113 void (*SetRow)(uint8* dst, uint8 value, int pix) = SetRow_C; | 1118 void (*SetRow)(uint8* dst, uint8 value, int width) = SetRow_C; |
| 1114 if (height < 0) { | 1119 if (height < 0) { |
| 1115 height = -height; | 1120 height = -height; |
| 1116 dst_y = dst_y + (height - 1) * dst_stride_y; | 1121 dst_y = dst_y + (height - 1) * dst_stride_y; |
| 1117 dst_stride_y = -dst_stride_y; | 1122 dst_stride_y = -dst_stride_y; |
| 1118 } | 1123 } |
| 1119 // Coalesce rows. | 1124 // Coalesce rows. |
| 1120 if (dst_stride_y == width) { | 1125 if (dst_stride_y == width) { |
| 1121 width *= height; | 1126 width *= height; |
| 1122 height = 1; | 1127 height = 1; |
| 1123 dst_stride_y = 0; | 1128 dst_stride_y = 0; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 return 0; | 1184 return 0; |
| 1180 } | 1185 } |
| 1181 | 1186 |
| 1182 // Draw a rectangle into ARGB | 1187 // Draw a rectangle into ARGB |
| 1183 LIBYUV_API | 1188 LIBYUV_API |
| 1184 int ARGBRect(uint8* dst_argb, int dst_stride_argb, | 1189 int ARGBRect(uint8* dst_argb, int dst_stride_argb, |
| 1185 int dst_x, int dst_y, | 1190 int dst_x, int dst_y, |
| 1186 int width, int height, | 1191 int width, int height, |
| 1187 uint32 value) { | 1192 uint32 value) { |
| 1188 int y; | 1193 int y; |
| 1189 void (*ARGBSetRow)(uint8* dst_argb, uint32 value, int pix) = ARGBSetRow_C; | 1194 void (*ARGBSetRow)(uint8* dst_argb, uint32 value, int width) = ARGBSetRow_C; |
| 1190 if (!dst_argb || | 1195 if (!dst_argb || |
| 1191 width <= 0 || height == 0 || | 1196 width <= 0 || height == 0 || |
| 1192 dst_x < 0 || dst_y < 0) { | 1197 dst_x < 0 || dst_y < 0) { |
| 1193 return -1; | 1198 return -1; |
| 1194 } | 1199 } |
| 1195 if (height < 0) { | 1200 if (height < 0) { |
| 1196 height = -height; | 1201 height = -height; |
| 1197 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | 1202 dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| 1198 dst_stride_argb = -dst_stride_argb; | 1203 dst_stride_argb = -dst_stride_argb; |
| 1199 } | 1204 } |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 return 0; | 1907 return 0; |
| 1903 } | 1908 } |
| 1904 | 1909 |
| 1905 // Shuffle ARGB channel order. e.g. BGRA to ARGB. | 1910 // Shuffle ARGB channel order. e.g. BGRA to ARGB. |
| 1906 LIBYUV_API | 1911 LIBYUV_API |
| 1907 int ARGBShuffle(const uint8* src_bgra, int src_stride_bgra, | 1912 int ARGBShuffle(const uint8* src_bgra, int src_stride_bgra, |
| 1908 uint8* dst_argb, int dst_stride_argb, | 1913 uint8* dst_argb, int dst_stride_argb, |
| 1909 const uint8* shuffler, int width, int height) { | 1914 const uint8* shuffler, int width, int height) { |
| 1910 int y; | 1915 int y; |
| 1911 void (*ARGBShuffleRow)(const uint8* src_bgra, uint8* dst_argb, | 1916 void (*ARGBShuffleRow)(const uint8* src_bgra, uint8* dst_argb, |
| 1912 const uint8* shuffler, int pix) = ARGBShuffleRow_C; | 1917 const uint8* shuffler, int width) = ARGBShuffleRow_C; |
| 1913 if (!src_bgra || !dst_argb || | 1918 if (!src_bgra || !dst_argb || |
| 1914 width <= 0 || height == 0) { | 1919 width <= 0 || height == 0) { |
| 1915 return -1; | 1920 return -1; |
| 1916 } | 1921 } |
| 1917 // Negative height means invert the image. | 1922 // Negative height means invert the image. |
| 1918 if (height < 0) { | 1923 if (height < 0) { |
| 1919 height = -height; | 1924 height = -height; |
| 1920 src_bgra = src_bgra + (height - 1) * src_stride_bgra; | 1925 src_bgra = src_bgra + (height - 1) * src_stride_bgra; |
| 1921 src_stride_bgra = -src_stride_bgra; | 1926 src_stride_bgra = -src_stride_bgra; |
| 1922 } | 1927 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1969 } | 1974 } |
| 1970 | 1975 |
| 1971 // Sobel ARGB effect. | 1976 // Sobel ARGB effect. |
| 1972 static int ARGBSobelize(const uint8* src_argb, int src_stride_argb, | 1977 static int ARGBSobelize(const uint8* src_argb, int src_stride_argb, |
| 1973 uint8* dst_argb, int dst_stride_argb, | 1978 uint8* dst_argb, int dst_stride_argb, |
| 1974 int width, int height, | 1979 int width, int height, |
| 1975 void (*SobelRow)(const uint8* src_sobelx, | 1980 void (*SobelRow)(const uint8* src_sobelx, |
| 1976 const uint8* src_sobely, | 1981 const uint8* src_sobely, |
| 1977 uint8* dst, int width)) { | 1982 uint8* dst, int width)) { |
| 1978 int y; | 1983 int y; |
| 1979 void (*ARGBToYJRow)(const uint8* src_argb, uint8* dst_g, int pix) = | 1984 void (*ARGBToYJRow)(const uint8* src_argb, uint8* dst_g, int width) = |
| 1980 ARGBToYJRow_C; | 1985 ARGBToYJRow_C; |
| 1981 void (*SobelYRow)(const uint8* src_y0, const uint8* src_y1, | 1986 void (*SobelYRow)(const uint8* src_y0, const uint8* src_y1, |
| 1982 uint8* dst_sobely, int width) = SobelYRow_C; | 1987 uint8* dst_sobely, int width) = SobelYRow_C; |
| 1983 void (*SobelXRow)(const uint8* src_y0, const uint8* src_y1, | 1988 void (*SobelXRow)(const uint8* src_y0, const uint8* src_y1, |
| 1984 const uint8* src_y2, uint8* dst_sobely, int width) = | 1989 const uint8* src_y2, uint8* dst_sobely, int width) = |
| 1985 SobelXRow_C; | 1990 SobelXRow_C; |
| 1986 const int kEdge = 16; // Extra pixels at start of row for extrude/align. | 1991 const int kEdge = 16; // Extra pixels at start of row for extrude/align. |
| 1987 if (!src_argb || !dst_argb || width <= 0 || height == 0) { | 1992 if (!src_argb || !dst_argb || width <= 0 || height == 0) { |
| 1988 return -1; | 1993 return -1; |
| 1989 } | 1994 } |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2353 return 0; | 2358 return 0; |
| 2354 } | 2359 } |
| 2355 | 2360 |
| 2356 LIBYUV_API | 2361 LIBYUV_API |
| 2357 int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2, | 2362 int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2, |
| 2358 uint8* dst_y, int dst_stride_y, | 2363 uint8* dst_y, int dst_stride_y, |
| 2359 uint8* dst_uv, int dst_stride_uv, | 2364 uint8* dst_uv, int dst_stride_uv, |
| 2360 int width, int height) { | 2365 int width, int height) { |
| 2361 int y; | 2366 int y; |
| 2362 int halfwidth = (width + 1) >> 1; | 2367 int halfwidth = (width + 1) >> 1; |
| 2363 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix) = | 2368 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, |
| 2364 SplitUVRow_C; | 2369 int width) = SplitUVRow_C; |
| 2365 void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr, | 2370 void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr, |
| 2366 ptrdiff_t src_stride, int dst_width, | 2371 ptrdiff_t src_stride, int dst_width, |
| 2367 int source_y_fraction) = InterpolateRow_C; | 2372 int source_y_fraction) = InterpolateRow_C; |
| 2368 if (!src_yuy2 || | 2373 if (!src_yuy2 || |
| 2369 !dst_y || !dst_uv || | 2374 !dst_y || !dst_uv || |
| 2370 width <= 0 || height == 0) { | 2375 width <= 0 || height == 0) { |
| 2371 return -1; | 2376 return -1; |
| 2372 } | 2377 } |
| 2373 // Negative height means invert the image. | 2378 // Negative height means invert the image. |
| 2374 if (height < 0) { | 2379 if (height < 0) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2457 return 0; | 2462 return 0; |
| 2458 } | 2463 } |
| 2459 | 2464 |
| 2460 LIBYUV_API | 2465 LIBYUV_API |
| 2461 int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy, | 2466 int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy, |
| 2462 uint8* dst_y, int dst_stride_y, | 2467 uint8* dst_y, int dst_stride_y, |
| 2463 uint8* dst_uv, int dst_stride_uv, | 2468 uint8* dst_uv, int dst_stride_uv, |
| 2464 int width, int height) { | 2469 int width, int height) { |
| 2465 int y; | 2470 int y; |
| 2466 int halfwidth = (width + 1) >> 1; | 2471 int halfwidth = (width + 1) >> 1; |
| 2467 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix) = | 2472 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, |
| 2468 SplitUVRow_C; | 2473 int width) = SplitUVRow_C; |
| 2469 void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr, | 2474 void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr, |
| 2470 ptrdiff_t src_stride, int dst_width, | 2475 ptrdiff_t src_stride, int dst_width, |
| 2471 int source_y_fraction) = InterpolateRow_C; | 2476 int source_y_fraction) = InterpolateRow_C; |
| 2472 if (!src_uyvy || | 2477 if (!src_uyvy || |
| 2473 !dst_y || !dst_uv || | 2478 !dst_y || !dst_uv || |
| 2474 width <= 0 || height == 0) { | 2479 width <= 0 || height == 0) { |
| 2475 return -1; | 2480 return -1; |
| 2476 } | 2481 } |
| 2477 // Negative height means invert the image. | 2482 // Negative height means invert the image. |
| 2478 if (height < 0) { | 2483 if (height < 0) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2558 } | 2563 } |
| 2559 free_aligned_buffer_64(rows); | 2564 free_aligned_buffer_64(rows); |
| 2560 } | 2565 } |
| 2561 return 0; | 2566 return 0; |
| 2562 } | 2567 } |
| 2563 | 2568 |
| 2564 #ifdef __cplusplus | 2569 #ifdef __cplusplus |
| 2565 } // extern "C" | 2570 } // extern "C" |
| 2566 } // namespace libyuv | 2571 } // namespace libyuv |
| 2567 #endif | 2572 #endif |
| OLD | NEW |