2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef INCLUDE_LIBYUV_CONVERT_H_ // NOLINT
12 #define INCLUDE_LIBYUV_CONVERT_H_
14 #include "libyuv/basic_types.h"
15 // TODO(fbarchard): Remove the following headers includes.
16 #include "libyuv/convert_from.h"
17 #include "libyuv/planar_functions.h"
18 #include "libyuv/rotate.h"
25 // Convert I444 to I420.
27 int I444ToI420(const uint8* src_y, int src_stride_y,
28 const uint8* src_u, int src_stride_u,
29 const uint8* src_v, int src_stride_v,
30 uint8* dst_y, int dst_stride_y,
31 uint8* dst_u, int dst_stride_u,
32 uint8* dst_v, int dst_stride_v,
33 int width, int height);
35 // Convert I422 to I420.
37 int I422ToI420(const uint8* src_y, int src_stride_y,
38 const uint8* src_u, int src_stride_u,
39 const uint8* src_v, int src_stride_v,
40 uint8* dst_y, int dst_stride_y,
41 uint8* dst_u, int dst_stride_u,
42 uint8* dst_v, int dst_stride_v,
43 int width, int height);
45 // Convert I411 to I420.
47 int I411ToI420(const uint8* src_y, int src_stride_y,
48 const uint8* src_u, int src_stride_u,
49 const uint8* src_v, int src_stride_v,
50 uint8* dst_y, int dst_stride_y,
51 uint8* dst_u, int dst_stride_u,
52 uint8* dst_v, int dst_stride_v,
53 int width, int height);
56 #define I420ToI420 I420Copy
58 int I420Copy(const uint8* src_y, int src_stride_y,
59 const uint8* src_u, int src_stride_u,
60 const uint8* src_v, int src_stride_v,
61 uint8* dst_y, int dst_stride_y,
62 uint8* dst_u, int dst_stride_u,
63 uint8* dst_v, int dst_stride_v,
64 int width, int height);
66 // Convert I400 (grey) to I420.
68 int I400ToI420(const uint8* src_y, int src_stride_y,
69 uint8* dst_y, int dst_stride_y,
70 uint8* dst_u, int dst_stride_u,
71 uint8* dst_v, int dst_stride_v,
72 int width, int height);
74 // Convert NV12 to I420.
76 int NV12ToI420(const uint8* src_y, int src_stride_y,
77 const uint8* src_uv, int src_stride_uv,
78 uint8* dst_y, int dst_stride_y,
79 uint8* dst_u, int dst_stride_u,
80 uint8* dst_v, int dst_stride_v,
81 int width, int height);
83 // Convert NV21 to I420.
85 int NV21ToI420(const uint8* src_y, int src_stride_y,
86 const uint8* src_vu, int src_stride_vu,
87 uint8* dst_y, int dst_stride_y,
88 uint8* dst_u, int dst_stride_u,
89 uint8* dst_v, int dst_stride_v,
90 int width, int height);
92 // Convert YUY2 to I420.
94 int YUY2ToI420(const uint8* src_yuy2, int src_stride_yuy2,
95 uint8* dst_y, int dst_stride_y,
96 uint8* dst_u, int dst_stride_u,
97 uint8* dst_v, int dst_stride_v,
98 int width, int height);
100 // Convert UYVY to I420.
102 int UYVYToI420(const uint8* src_uyvy, int src_stride_uyvy,
103 uint8* dst_y, int dst_stride_y,
104 uint8* dst_u, int dst_stride_u,
105 uint8* dst_v, int dst_stride_v,
106 int width, int height);
108 // Convert M420 to I420.
110 int M420ToI420(const uint8* src_m420, int src_stride_m420,
111 uint8* dst_y, int dst_stride_y,
112 uint8* dst_u, int dst_stride_u,
113 uint8* dst_v, int dst_stride_v,
114 int width, int height);
116 // ARGB little endian (bgra in memory) to I420.
118 int ARGBToI420(const uint8* src_frame, int src_stride_frame,
119 uint8* dst_y, int dst_stride_y,
120 uint8* dst_u, int dst_stride_u,
121 uint8* dst_v, int dst_stride_v,
122 int width, int height);
124 // BGRA little endian (argb in memory) to I420.
126 int BGRAToI420(const uint8* src_frame, int src_stride_frame,
127 uint8* dst_y, int dst_stride_y,
128 uint8* dst_u, int dst_stride_u,
129 uint8* dst_v, int dst_stride_v,
130 int width, int height);
132 // ABGR little endian (rgba in memory) to I420.
134 int ABGRToI420(const uint8* src_frame, int src_stride_frame,
135 uint8* dst_y, int dst_stride_y,
136 uint8* dst_u, int dst_stride_u,
137 uint8* dst_v, int dst_stride_v,
138 int width, int height);
140 // RGBA little endian (abgr in memory) to I420.
142 int RGBAToI420(const uint8* src_frame, int src_stride_frame,
143 uint8* dst_y, int dst_stride_y,
144 uint8* dst_u, int dst_stride_u,
145 uint8* dst_v, int dst_stride_v,
146 int width, int height);
148 // RGB little endian (bgr in memory) to I420.
150 int RGB24ToI420(const uint8* src_frame, int src_stride_frame,
151 uint8* dst_y, int dst_stride_y,
152 uint8* dst_u, int dst_stride_u,
153 uint8* dst_v, int dst_stride_v,
154 int width, int height);
156 // RGB big endian (rgb in memory) to I420.
158 int RAWToI420(const uint8* src_frame, int src_stride_frame,
159 uint8* dst_y, int dst_stride_y,
160 uint8* dst_u, int dst_stride_u,
161 uint8* dst_v, int dst_stride_v,
162 int width, int height);
164 // RGB16 (RGBP fourcc) little endian to I420.
166 int RGB565ToI420(const uint8* src_frame, int src_stride_frame,
167 uint8* dst_y, int dst_stride_y,
168 uint8* dst_u, int dst_stride_u,
169 uint8* dst_v, int dst_stride_v,
170 int width, int height);
172 // RGB15 (RGBO fourcc) little endian to I420.
174 int ARGB1555ToI420(const uint8* src_frame, int src_stride_frame,
175 uint8* dst_y, int dst_stride_y,
176 uint8* dst_u, int dst_stride_u,
177 uint8* dst_v, int dst_stride_v,
178 int width, int height);
180 // RGB12 (R444 fourcc) little endian to I420.
182 int ARGB4444ToI420(const uint8* src_frame, int src_stride_frame,
183 uint8* dst_y, int dst_stride_y,
184 uint8* dst_u, int dst_stride_u,
185 uint8* dst_v, int dst_stride_v,
186 int width, int height);
189 // src_width/height provided by capture.
190 // dst_width/height for clipping determine final size.
192 int MJPGToI420(const uint8* sample, size_t sample_size,
193 uint8* dst_y, int dst_stride_y,
194 uint8* dst_u, int dst_stride_u,
195 uint8* dst_v, int dst_stride_v,
196 int src_width, int src_height,
197 int dst_width, int dst_height);
199 // Query size of MJPG in pixels.
201 int MJPGSize(const uint8* sample, size_t sample_size,
202 int* width, int* height);
205 // Convert camera sample to I420 with cropping, rotation and vertical flip.
206 // "src_size" is needed to parse MJPG.
207 // "dst_stride_y" number of bytes in a row of the dst_y plane.
208 // Normally this would be the same as dst_width, with recommended alignment
209 // to 16 bytes for better efficiency.
210 // If rotation of 90 or 270 is used, stride is affected. The caller should
211 // allocate the I420 buffer according to rotation.
212 // "dst_stride_u" number of bytes in a row of the dst_u plane.
213 // Normally this would be the same as (dst_width + 1) / 2, with
214 // recommended alignment to 16 bytes for better efficiency.
215 // If rotation of 90 or 270 is used, stride is affected.
216 // "crop_x" and "crop_y" are starting position for cropping.
217 // To center, crop_x = (src_width - dst_width) / 2
218 // crop_y = (src_height - dst_height) / 2
219 // "src_width" / "src_height" is size of src_frame in pixels.
220 // "src_height" can be negative indicating a vertically flipped image source.
221 // "crop_width" / "crop_height" is the size to crop the src to.
222 // Must be less than or equal to src_width/src_height
223 // Cropping parameters are pre-rotation.
224 // "rotation" can be 0, 90, 180 or 270.
225 // "format" is a fourcc. ie 'I420', 'YUY2'
226 // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure.
228 int ConvertToI420(const uint8* src_frame, size_t src_size,
229 uint8* dst_y, int dst_stride_y,
230 uint8* dst_u, int dst_stride_u,
231 uint8* dst_v, int dst_stride_v,
232 int crop_x, int crop_y,
233 int src_width, int src_height,
234 int crop_width, int crop_height,
235 enum RotationMode rotation,
240 } // namespace libyuv
243 #endif // INCLUDE_LIBYUV_CONVERT_H_ NOLINT