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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 NV12ToRGB565Row(src_y, src_uv, dst_rgb565, &kYuvConstants, width); | 1032 NV12ToRGB565Row(src_y, src_uv, dst_rgb565, &kYuvConstants, 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 // Convert NV21 to RGB565. | |
1043 LIBYUV_API | |
1044 int NV21ToRGB565(const uint8* src_y, int src_stride_y, | |
1045 const uint8* src_vu, int src_stride_vu, | |
1046 uint8* dst_rgb565, int dst_stride_rgb565, | |
1047 int width, int height) { | |
1048 int y; | |
1049 void (*NV12ToRGB565Row)(const uint8* y_buf, | |
1050 const uint8* src_vu, | |
1051 uint8* rgb_buf, | |
1052 struct YuvConstants* yuvconstants, | |
1053 int width) = NV12ToRGB565Row_C; | |
1054 if (!src_y || !src_vu || !dst_rgb565 || | |
1055 width <= 0 || height == 0) { | |
1056 return -1; | |
1057 } | |
1058 // Negative height means invert the image. | |
1059 if (height < 0) { | |
1060 height = -height; | |
1061 dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; | |
1062 dst_stride_rgb565 = -dst_stride_rgb565; | |
1063 } | |
1064 #if defined(HAS_NV12TORGB565ROW_SSSE3) | |
1065 if (TestCpuFlag(kCpuHasSSSE3)) { | |
1066 NV12ToRGB565Row = NV12ToRGB565Row_Any_SSSE3; | |
1067 if (IS_ALIGNED(width, 8)) { | |
1068 NV12ToRGB565Row = NV12ToRGB565Row_SSSE3; | |
1069 } | |
1070 } | |
1071 #endif | |
1072 #if defined(HAS_NV12TORGB565ROW_AVX2) | |
1073 if (TestCpuFlag(kCpuHasAVX2)) { | |
1074 NV12ToRGB565Row = NV12ToRGB565Row_Any_AVX2; | |
1075 if (IS_ALIGNED(width, 16)) { | |
1076 NV12ToRGB565Row = NV12ToRGB565Row_AVX2; | |
1077 } | |
1078 } | |
1079 #endif | |
1080 #if defined(HAS_NV12TORGB565ROW_NEON) | |
1081 if (TestCpuFlag(kCpuHasNEON)) { | |
1082 NV12ToRGB565Row = NV12ToRGB565Row_Any_NEON; | |
1083 if (IS_ALIGNED(width, 8)) { | |
1084 NV12ToRGB565Row = NV12ToRGB565Row_NEON; | |
1085 } | |
1086 } | |
1087 #endif | |
1088 | |
1089 for (y = 0; y < height; ++y) { | |
1090 NV12ToRGB565Row(src_y, src_vu, dst_rgb565, &kYvuConstants, width); | |
1091 dst_rgb565 += dst_stride_rgb565; | |
1092 src_y += src_stride_y; | |
1093 if (y & 1) { | |
1094 src_vu += src_stride_vu; | |
1095 } | |
1096 } | |
1097 return 0; | |
1098 } | |
1099 | |
1100 LIBYUV_API | 1042 LIBYUV_API |
1101 void SetPlane(uint8* dst_y, int dst_stride_y, | 1043 void SetPlane(uint8* dst_y, int dst_stride_y, |
1102 int width, int height, | 1044 int width, int height, |
1103 uint32 value) { | 1045 uint32 value) { |
1104 int y; | 1046 int y; |
1105 void (*SetRow)(uint8* dst, uint8 value, int width) = SetRow_C; | 1047 void (*SetRow)(uint8* dst, uint8 value, int width) = SetRow_C; |
1106 if (height < 0) { | 1048 if (height < 0) { |
1107 height = -height; | 1049 height = -height; |
1108 dst_y = dst_y + (height - 1) * dst_stride_y; | 1050 dst_y = dst_y + (height - 1) * dst_stride_y; |
1109 dst_stride_y = -dst_stride_y; | 1051 dst_stride_y = -dst_stride_y; |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 } | 2484 } |
2543 free_aligned_buffer_64(rows); | 2485 free_aligned_buffer_64(rows); |
2544 } | 2486 } |
2545 return 0; | 2487 return 0; |
2546 } | 2488 } |
2547 | 2489 |
2548 #ifdef __cplusplus | 2490 #ifdef __cplusplus |
2549 } // extern "C" | 2491 } // extern "C" |
2550 } // namespace libyuv | 2492 } // namespace libyuv |
2551 #endif | 2493 #endif |
OLD | NEW |