| 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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 int I422ToBGRA(const uint8* src_y, int src_stride_y, | 770 int I422ToBGRA(const uint8* src_y, int src_stride_y, |
| 771 const uint8* src_u, int src_stride_u, | 771 const uint8* src_u, int src_stride_u, |
| 772 const uint8* src_v, int src_stride_v, | 772 const uint8* src_v, int src_stride_v, |
| 773 uint8* dst_bgra, int dst_stride_bgra, | 773 uint8* dst_bgra, int dst_stride_bgra, |
| 774 int width, int height) { | 774 int width, int height) { |
| 775 int y; | 775 int y; |
| 776 void (*I422ToBGRARow)(const uint8* y_buf, | 776 void (*I422ToBGRARow)(const uint8* y_buf, |
| 777 const uint8* u_buf, | 777 const uint8* u_buf, |
| 778 const uint8* v_buf, | 778 const uint8* v_buf, |
| 779 uint8* rgb_buf, | 779 uint8* rgb_buf, |
| 780 struct YuvConstants* yuvconstants, | 780 const struct YuvConstants* yuvconstants, |
| 781 int width) = I422ToBGRARow_C; | 781 int width) = I422ToBGRARow_C; |
| 782 if (!src_y || !src_u || !src_v || | 782 if (!src_y || !src_u || !src_v || |
| 783 !dst_bgra || | 783 !dst_bgra || |
| 784 width <= 0 || height == 0) { | 784 width <= 0 || height == 0) { |
| 785 return -1; | 785 return -1; |
| 786 } | 786 } |
| 787 // Negative height means invert the image. | 787 // Negative height means invert the image. |
| 788 if (height < 0) { | 788 if (height < 0) { |
| 789 height = -height; | 789 height = -height; |
| 790 dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra; | 790 dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | 827 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && |
| 828 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | 828 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && |
| 829 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | 829 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && |
| 830 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | 830 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && |
| 831 IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) { | 831 IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) { |
| 832 I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2; | 832 I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2; |
| 833 } | 833 } |
| 834 #endif | 834 #endif |
| 835 | 835 |
| 836 for (y = 0; y < height; ++y) { | 836 for (y = 0; y < height; ++y) { |
| 837 I422ToBGRARow(src_y, src_u, src_v, dst_bgra, &kYuvConstants, width); | 837 I422ToBGRARow(src_y, src_u, src_v, dst_bgra, &kYuvIConstants, width); |
| 838 dst_bgra += dst_stride_bgra; | 838 dst_bgra += dst_stride_bgra; |
| 839 src_y += src_stride_y; | 839 src_y += src_stride_y; |
| 840 src_u += src_stride_u; | 840 src_u += src_stride_u; |
| 841 src_v += src_stride_v; | 841 src_v += src_stride_v; |
| 842 } | 842 } |
| 843 return 0; | 843 return 0; |
| 844 } | 844 } |
| 845 | 845 |
| 846 // Convert I422 to ABGR. | 846 // Convert I422 to ABGR. |
| 847 LIBYUV_API | 847 LIBYUV_API |
| 848 int I422ToABGR(const uint8* src_y, int src_stride_y, | 848 int I422ToABGR(const uint8* src_y, int src_stride_y, |
| 849 const uint8* src_u, int src_stride_u, | 849 const uint8* src_u, int src_stride_u, |
| 850 const uint8* src_v, int src_stride_v, | 850 const uint8* src_v, int src_stride_v, |
| 851 uint8* dst_abgr, int dst_stride_abgr, | 851 uint8* dst_abgr, int dst_stride_abgr, |
| 852 int width, int height) { | 852 int width, int height) { |
| 853 int y; | 853 int y; |
| 854 void (*I422ToABGRRow)(const uint8* y_buf, | 854 void (*I422ToABGRRow)(const uint8* y_buf, |
| 855 const uint8* u_buf, | 855 const uint8* u_buf, |
| 856 const uint8* v_buf, | 856 const uint8* v_buf, |
| 857 uint8* rgb_buf, | 857 uint8* rgb_buf, |
| 858 struct YuvConstants* yuvconstants, | 858 const struct YuvConstants* yuvconstants, |
| 859 int width) = I422ToABGRRow_C; | 859 int width) = I422ToABGRRow_C; |
| 860 if (!src_y || !src_u || !src_v || | 860 if (!src_y || !src_u || !src_v || |
| 861 !dst_abgr || | 861 !dst_abgr || |
| 862 width <= 0 || height == 0) { | 862 width <= 0 || height == 0) { |
| 863 return -1; | 863 return -1; |
| 864 } | 864 } |
| 865 // Negative height means invert the image. | 865 // Negative height means invert the image. |
| 866 if (height < 0) { | 866 if (height < 0) { |
| 867 height = -height; | 867 height = -height; |
| 868 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; | 868 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 896 #if defined(HAS_I422TOABGRROW_AVX2) | 896 #if defined(HAS_I422TOABGRROW_AVX2) |
| 897 if (TestCpuFlag(kCpuHasAVX2)) { | 897 if (TestCpuFlag(kCpuHasAVX2)) { |
| 898 I422ToABGRRow = I422ToABGRRow_Any_AVX2; | 898 I422ToABGRRow = I422ToABGRRow_Any_AVX2; |
| 899 if (IS_ALIGNED(width, 16)) { | 899 if (IS_ALIGNED(width, 16)) { |
| 900 I422ToABGRRow = I422ToABGRRow_AVX2; | 900 I422ToABGRRow = I422ToABGRRow_AVX2; |
| 901 } | 901 } |
| 902 } | 902 } |
| 903 #endif | 903 #endif |
| 904 | 904 |
| 905 for (y = 0; y < height; ++y) { | 905 for (y = 0; y < height; ++y) { |
| 906 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvConstants, width); | 906 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvIConstants, width); |
| 907 dst_abgr += dst_stride_abgr; | 907 dst_abgr += dst_stride_abgr; |
| 908 src_y += src_stride_y; | 908 src_y += src_stride_y; |
| 909 src_u += src_stride_u; | 909 src_u += src_stride_u; |
| 910 src_v += src_stride_v; | 910 src_v += src_stride_v; |
| 911 } | 911 } |
| 912 return 0; | 912 return 0; |
| 913 } | 913 } |
| 914 | 914 |
| 915 // Convert I422 to RGBA. | 915 // Convert I422 to RGBA. |
| 916 LIBYUV_API | 916 LIBYUV_API |
| 917 int I422ToRGBA(const uint8* src_y, int src_stride_y, | 917 int I422ToRGBA(const uint8* src_y, int src_stride_y, |
| 918 const uint8* src_u, int src_stride_u, | 918 const uint8* src_u, int src_stride_u, |
| 919 const uint8* src_v, int src_stride_v, | 919 const uint8* src_v, int src_stride_v, |
| 920 uint8* dst_rgba, int dst_stride_rgba, | 920 uint8* dst_rgba, int dst_stride_rgba, |
| 921 int width, int height) { | 921 int width, int height) { |
| 922 int y; | 922 int y; |
| 923 void (*I422ToRGBARow)(const uint8* y_buf, | 923 void (*I422ToRGBARow)(const uint8* y_buf, |
| 924 const uint8* u_buf, | 924 const uint8* u_buf, |
| 925 const uint8* v_buf, | 925 const uint8* v_buf, |
| 926 uint8* rgb_buf, | 926 uint8* rgb_buf, |
| 927 struct YuvConstants* yuvconstants, | 927 const struct YuvConstants* yuvconstants, |
| 928 int width) = I422ToRGBARow_C; | 928 int width) = I422ToRGBARow_C; |
| 929 if (!src_y || !src_u || !src_v || | 929 if (!src_y || !src_u || !src_v || |
| 930 !dst_rgba || | 930 !dst_rgba || |
| 931 width <= 0 || height == 0) { | 931 width <= 0 || height == 0) { |
| 932 return -1; | 932 return -1; |
| 933 } | 933 } |
| 934 // Negative height means invert the image. | 934 // Negative height means invert the image. |
| 935 if (height < 0) { | 935 if (height < 0) { |
| 936 height = -height; | 936 height = -height; |
| 937 dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba; | 937 dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 965 #if defined(HAS_I422TORGBAROW_AVX2) | 965 #if defined(HAS_I422TORGBAROW_AVX2) |
| 966 if (TestCpuFlag(kCpuHasAVX2)) { | 966 if (TestCpuFlag(kCpuHasAVX2)) { |
| 967 I422ToRGBARow = I422ToRGBARow_Any_AVX2; | 967 I422ToRGBARow = I422ToRGBARow_Any_AVX2; |
| 968 if (IS_ALIGNED(width, 16)) { | 968 if (IS_ALIGNED(width, 16)) { |
| 969 I422ToRGBARow = I422ToRGBARow_AVX2; | 969 I422ToRGBARow = I422ToRGBARow_AVX2; |
| 970 } | 970 } |
| 971 } | 971 } |
| 972 #endif | 972 #endif |
| 973 | 973 |
| 974 for (y = 0; y < height; ++y) { | 974 for (y = 0; y < height; ++y) { |
| 975 I422ToRGBARow(src_y, src_u, src_v, dst_rgba, &kYuvConstants, width); | 975 I422ToRGBARow(src_y, src_u, src_v, dst_rgba, &kYuvIConstants, width); |
| 976 dst_rgba += dst_stride_rgba; | 976 dst_rgba += dst_stride_rgba; |
| 977 src_y += src_stride_y; | 977 src_y += src_stride_y; |
| 978 src_u += src_stride_u; | 978 src_u += src_stride_u; |
| 979 src_v += src_stride_v; | 979 src_v += src_stride_v; |
| 980 } | 980 } |
| 981 return 0; | 981 return 0; |
| 982 } | 982 } |
| 983 | 983 |
| 984 // Convert NV12 to RGB565. | 984 // Convert NV12 to RGB565. |
| 985 LIBYUV_API | 985 LIBYUV_API |
| 986 int NV12ToRGB565(const uint8* src_y, int src_stride_y, | 986 int NV12ToRGB565(const uint8* src_y, int src_stride_y, |
| 987 const uint8* src_uv, int src_stride_uv, | 987 const uint8* src_uv, int src_stride_uv, |
| 988 uint8* dst_rgb565, int dst_stride_rgb565, | 988 uint8* dst_rgb565, int dst_stride_rgb565, |
| 989 int width, int height) { | 989 int width, int height) { |
| 990 int y; | 990 int y; |
| 991 void (*NV12ToRGB565Row)(const uint8* y_buf, | 991 void (*NV12ToRGB565Row)(const uint8* y_buf, |
| 992 const uint8* uv_buf, | 992 const uint8* uv_buf, |
| 993 uint8* rgb_buf, | 993 uint8* rgb_buf, |
| 994 struct YuvConstants* yuvconstants, | 994 const struct YuvConstants* yuvconstants, |
| 995 int width) = NV12ToRGB565Row_C; | 995 int width) = NV12ToRGB565Row_C; |
| 996 if (!src_y || !src_uv || !dst_rgb565 || | 996 if (!src_y || !src_uv || !dst_rgb565 || |
| 997 width <= 0 || height == 0) { | 997 width <= 0 || height == 0) { |
| 998 return -1; | 998 return -1; |
| 999 } | 999 } |
| 1000 // Negative height means invert the image. | 1000 // Negative height means invert the image. |
| 1001 if (height < 0) { | 1001 if (height < 0) { |
| 1002 height = -height; | 1002 height = -height; |
| 1003 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; | 1003 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; |
| 1004 dst_stride_rgb565 = -dst_stride_rgb565; | 1004 dst_stride_rgb565 = -dst_stride_rgb565; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1022 #if defined(HAS_NV12TORGB565ROW_NEON) | 1022 #if defined(HAS_NV12TORGB565ROW_NEON) |
| 1023 if (TestCpuFlag(kCpuHasNEON)) { | 1023 if (TestCpuFlag(kCpuHasNEON)) { |
| 1024 NV12ToRGB565Row = NV12ToRGB565Row_Any_NEON; | 1024 NV12ToRGB565Row = NV12ToRGB565Row_Any_NEON; |
| 1025 if (IS_ALIGNED(width, 8)) { | 1025 if (IS_ALIGNED(width, 8)) { |
| 1026 NV12ToRGB565Row = NV12ToRGB565Row_NEON; | 1026 NV12ToRGB565Row = NV12ToRGB565Row_NEON; |
| 1027 } | 1027 } |
| 1028 } | 1028 } |
| 1029 #endif | 1029 #endif |
| 1030 | 1030 |
| 1031 for (y = 0; y < height; ++y) { | 1031 for (y = 0; y < height; ++y) { |
| 1032 NV12ToRGB565Row(src_y, src_uv, dst_rgb565, &kYuvConstants, width); | 1032 NV12ToRGB565Row(src_y, src_uv, dst_rgb565, &kYuvIConstants, width); |
| 1033 dst_rgb565 += dst_stride_rgb565; | 1033 dst_rgb565 += dst_stride_rgb565; |
| 1034 src_y += src_stride_y; | 1034 src_y += src_stride_y; |
| 1035 if (y & 1) { | 1035 if (y & 1) { |
| 1036 src_uv += src_stride_uv; | 1036 src_uv += src_stride_uv; |
| 1037 } | 1037 } |
| 1038 } | 1038 } |
| 1039 return 0; | 1039 return 0; |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 LIBYUV_API | 1042 LIBYUV_API |
| (...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2484 } | 2484 } |
| 2485 free_aligned_buffer_64(rows); | 2485 free_aligned_buffer_64(rows); |
| 2486 } | 2486 } |
| 2487 return 0; | 2487 return 0; |
| 2488 } | 2488 } |
| 2489 | 2489 |
| 2490 #ifdef __cplusplus | 2490 #ifdef __cplusplus |
| 2491 } // extern "C" | 2491 } // extern "C" |
| 2492 } // namespace libyuv | 2492 } // namespace libyuv |
| 2493 #endif | 2493 #endif |
| OLD | NEW |