OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2012 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return I420ToI4xx(src_y, src_stride_y, | 97 return I420ToI4xx(src_y, src_stride_y, |
98 src_u, src_stride_u, | 98 src_u, src_stride_u, |
99 src_v, src_stride_v, | 99 src_v, src_stride_v, |
100 dst_y, dst_stride_y, | 100 dst_y, dst_stride_y, |
101 dst_u, dst_stride_u, | 101 dst_u, dst_stride_u, |
102 dst_v, dst_stride_v, | 102 dst_v, dst_stride_v, |
103 width, height, | 103 width, height, |
104 dst_uv_width, dst_uv_height); | 104 dst_uv_width, dst_uv_height); |
105 } | 105 } |
106 | 106 |
107 // 420 chroma is 1/2 width, 1/2 height | |
108 // 411 chroma is 1/4 width, 1x height | |
109 LIBYUV_API | |
110 int I420ToI411(const uint8* src_y, int src_stride_y, | |
111 const uint8* src_u, int src_stride_u, | |
112 const uint8* src_v, int src_stride_v, | |
113 uint8* dst_y, int dst_stride_y, | |
114 uint8* dst_u, int dst_stride_u, | |
115 uint8* dst_v, int dst_stride_v, | |
116 int width, int height) { | |
117 const int dst_uv_width = (Abs(width) + 3) >> 2; | |
118 const int dst_uv_height = Abs(height); | |
119 return I420ToI4xx(src_y, src_stride_y, | |
120 src_u, src_stride_u, | |
121 src_v, src_stride_v, | |
122 dst_y, dst_stride_y, | |
123 dst_u, dst_stride_u, | |
124 dst_v, dst_stride_v, | |
125 width, height, | |
126 dst_uv_width, dst_uv_height); | |
127 } | |
128 | |
129 // Copy to I400. Source can be I420,422,444,400,NV12,NV21 | 107 // Copy to I400. Source can be I420,422,444,400,NV12,NV21 |
130 LIBYUV_API | 108 LIBYUV_API |
131 int I400Copy(const uint8* src_y, int src_stride_y, | 109 int I400Copy(const uint8* src_y, int src_stride_y, |
132 uint8* dst_y, int dst_stride_y, | 110 uint8* dst_y, int dst_stride_y, |
133 int width, int height) { | 111 int width, int height) { |
134 if (!src_y || !dst_y || | 112 if (!src_y || !dst_y || |
135 width <= 0 || height == 0) { | 113 width <= 0 || height == 0) { |
136 return -1; | 114 return -1; |
137 } | 115 } |
138 // Negative height means invert the image. | 116 // Negative height means invert the image. |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_NEON; | 871 ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_NEON; |
894 } | 872 } |
895 } | 873 } |
896 #endif | 874 #endif |
897 { | 875 { |
898 // Allocate a row of argb. | 876 // Allocate a row of argb. |
899 align_buffer_64(row_argb, width * 4); | 877 align_buffer_64(row_argb, width * 4); |
900 for (y = 0; y < height; ++y) { | 878 for (y = 0; y < height; ++y) { |
901 I422ToARGBRow(src_y, src_u, src_v, row_argb, &kYuvI601Constants, width); | 879 I422ToARGBRow(src_y, src_u, src_v, row_argb, &kYuvI601Constants, width); |
902 ARGBToRGB565DitherRow(row_argb, dst_rgb565, | 880 ARGBToRGB565DitherRow(row_argb, dst_rgb565, |
903 *(uint32*)(dither4x4 + ((y & 3) << 2)), width); | 881 *(uint32*)(dither4x4 + ((y & 3) << 2)), width); // NOLINT |
904 dst_rgb565 += dst_stride_rgb565; | 882 dst_rgb565 += dst_stride_rgb565; |
905 src_y += src_stride_y; | 883 src_y += src_stride_y; |
906 if (y & 1) { | 884 if (y & 1) { |
907 src_u += src_stride_u; | 885 src_u += src_stride_u; |
908 src_v += src_stride_v; | 886 src_v += src_stride_v; |
909 } | 887 } |
910 } | 888 } |
911 free_aligned_buffer_64(row_argb); | 889 free_aligned_buffer_64(row_argb); |
912 } | 890 } |
913 return 0; | 891 return 0; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 } | 1084 } |
1107 r = I420ToI444(y, y_stride, | 1085 r = I420ToI444(y, y_stride, |
1108 u, u_stride, | 1086 u, u_stride, |
1109 v, v_stride, | 1087 v, v_stride, |
1110 dst_sample, width, | 1088 dst_sample, width, |
1111 dst_u, width, | 1089 dst_u, width, |
1112 dst_v, width, | 1090 dst_v, width, |
1113 width, height); | 1091 width, height); |
1114 break; | 1092 break; |
1115 } | 1093 } |
1116 case FOURCC_I411: { | |
1117 int quarterwidth = (width + 3) / 4; | |
1118 uint8* dst_u = dst_sample + width * height; | |
1119 uint8* dst_v = dst_u + quarterwidth * height; | |
1120 r = I420ToI411(y, y_stride, | |
1121 u, u_stride, | |
1122 v, v_stride, | |
1123 dst_sample, width, | |
1124 dst_u, quarterwidth, | |
1125 dst_v, quarterwidth, | |
1126 width, height); | |
1127 break; | |
1128 } | |
1129 | |
1130 // Formats not supported - MJPG, biplanar, some rgb formats. | 1094 // Formats not supported - MJPG, biplanar, some rgb formats. |
1131 default: | 1095 default: |
1132 return -1; // unknown fourcc - return failure code. | 1096 return -1; // unknown fourcc - return failure code. |
1133 } | 1097 } |
1134 return r; | 1098 return r; |
1135 } | 1099 } |
1136 | 1100 |
1137 #ifdef __cplusplus | 1101 #ifdef __cplusplus |
1138 } // extern "C" | 1102 } // extern "C" |
1139 } // namespace libyuv | 1103 } // namespace libyuv |
1140 #endif | 1104 #endif |
OLD | NEW |