• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
3  *
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.
9  */
10 
11 #ifndef INCLUDE_LIBYUV_CONVERT_H_  // NOLINT
12 #define INCLUDE_LIBYUV_CONVERT_H_
13 
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"
19 
20 #ifdef __cplusplus
21 namespace libyuv {
22 extern "C" {
23 #endif
24 
25 // Alias.
26 #define I420ToI420 I420Copy
27 
28 // Copy I420 to I420.
29 LIBYUV_API
30 int I420Copy(const uint8* src_y, int src_stride_y,
31              const uint8* src_u, int src_stride_u,
32              const uint8* src_v, int src_stride_v,
33              uint8* dst_y, int dst_stride_y,
34              uint8* dst_u, int dst_stride_u,
35              uint8* dst_v, int dst_stride_v,
36              int width, int height);
37 
38 // Convert I422 to I420.
39 LIBYUV_API
40 int I422ToI420(const uint8* src_y, int src_stride_y,
41                const uint8* src_u, int src_stride_u,
42                const uint8* src_v, int src_stride_v,
43                uint8* dst_y, int dst_stride_y,
44                uint8* dst_u, int dst_stride_u,
45                uint8* dst_v, int dst_stride_v,
46                int width, int height);
47 
48 // Convert I444 to I420.
49 LIBYUV_API
50 int I444ToI420(const uint8* src_y, int src_stride_y,
51                const uint8* src_u, int src_stride_u,
52                const uint8* src_v, int src_stride_v,
53                uint8* dst_y, int dst_stride_y,
54                uint8* dst_u, int dst_stride_u,
55                uint8* dst_v, int dst_stride_v,
56                int width, int height);
57 
58 // Convert I411 to I420.
59 LIBYUV_API
60 int I411ToI420(const uint8* src_y, int src_stride_y,
61                const uint8* src_u, int src_stride_u,
62                const uint8* src_v, int src_stride_v,
63                uint8* dst_y, int dst_stride_y,
64                uint8* dst_u, int dst_stride_u,
65                uint8* dst_v, int dst_stride_v,
66                int width, int height);
67 
68 // Convert I400 (grey) to I420.
69 LIBYUV_API
70 int I400ToI420(const uint8* src_y, int src_stride_y,
71                uint8* dst_y, int dst_stride_y,
72                uint8* dst_u, int dst_stride_u,
73                uint8* dst_v, int dst_stride_v,
74                int width, int height);
75 
76 // Convert NV12 to I420. Also used for NV21.
77 LIBYUV_API
78 int NV12ToI420(const uint8* src_y, int src_stride_y,
79                const uint8* src_uv, int src_stride_uv,
80                uint8* dst_y, int dst_stride_y,
81                uint8* dst_u, int dst_stride_u,
82                uint8* dst_v, int dst_stride_v,
83                int width, int height);
84 
85 // Convert M420 to I420.
86 LIBYUV_API
87 int M420ToI420(const uint8* src_m420, int src_stride_m420,
88                uint8* dst_y, int dst_stride_y,
89                uint8* dst_u, int dst_stride_u,
90                uint8* dst_v, int dst_stride_v,
91                int width, int height);
92 
93 // Convert Q420 to I420.
94 LIBYUV_API
95 int Q420ToI420(const uint8* src_y, int src_stride_y,
96                const uint8* src_yuy2, int src_stride_yuy2,
97                uint8* dst_y, int dst_stride_y,
98                uint8* dst_u, int dst_stride_u,
99                uint8* dst_v, int dst_stride_v,
100                int width, int height);
101 
102 // Convert YUY2 to I420.
103 LIBYUV_API
104 int YUY2ToI420(const uint8* src_yuy2, int src_stride_yuy2,
105                uint8* dst_y, int dst_stride_y,
106                uint8* dst_u, int dst_stride_u,
107                uint8* dst_v, int dst_stride_v,
108                int width, int height);
109 
110 // Convert UYVY to I420.
111 LIBYUV_API
112 int UYVYToI420(const uint8* src_uyvy, int src_stride_uyvy,
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 
118 // Convert V210 to I420.
119 LIBYUV_API
120 int V210ToI420(const uint8* src_uyvy, int src_stride_uyvy,
121                uint8* dst_y, int dst_stride_y,
122                uint8* dst_u, int dst_stride_u,
123                uint8* dst_v, int dst_stride_v,
124                int width, int height);
125 
126 // ARGB little endian (bgra in memory) to I420.
127 LIBYUV_API
128 int ARGBToI420(const uint8* src_frame, int src_stride_frame,
129                uint8* dst_y, int dst_stride_y,
130                uint8* dst_u, int dst_stride_u,
131                uint8* dst_v, int dst_stride_v,
132                int width, int height);
133 
134 // BGRA little endian (argb in memory) to I420.
135 LIBYUV_API
136 int BGRAToI420(const uint8* src_frame, int src_stride_frame,
137                uint8* dst_y, int dst_stride_y,
138                uint8* dst_u, int dst_stride_u,
139                uint8* dst_v, int dst_stride_v,
140                int width, int height);
141 
142 // ABGR little endian (rgba in memory) to I420.
143 LIBYUV_API
144 int ABGRToI420(const uint8* src_frame, int src_stride_frame,
145                uint8* dst_y, int dst_stride_y,
146                uint8* dst_u, int dst_stride_u,
147                uint8* dst_v, int dst_stride_v,
148                int width, int height);
149 
150 // RGBA little endian (abgr in memory) to I420.
151 LIBYUV_API
152 int RGBAToI420(const uint8* src_frame, int src_stride_frame,
153                uint8* dst_y, int dst_stride_y,
154                uint8* dst_u, int dst_stride_u,
155                uint8* dst_v, int dst_stride_v,
156                int width, int height);
157 
158 // RGB little endian (bgr in memory) to I420.
159 LIBYUV_API
160 int RGB24ToI420(const uint8* src_frame, int src_stride_frame,
161                 uint8* dst_y, int dst_stride_y,
162                 uint8* dst_u, int dst_stride_u,
163                 uint8* dst_v, int dst_stride_v,
164                 int width, int height);
165 
166 // RGB big endian (rgb in memory) to I420.
167 LIBYUV_API
168 int RAWToI420(const uint8* src_frame, int src_stride_frame,
169               uint8* dst_y, int dst_stride_y,
170               uint8* dst_u, int dst_stride_u,
171               uint8* dst_v, int dst_stride_v,
172               int width, int height);
173 
174 // RGB16 (RGBP fourcc) little endian to I420.
175 LIBYUV_API
176 int RGB565ToI420(const uint8* src_frame, int src_stride_frame,
177                  uint8* dst_y, int dst_stride_y,
178                  uint8* dst_u, int dst_stride_u,
179                  uint8* dst_v, int dst_stride_v,
180                  int width, int height);
181 
182 // RGB15 (RGBO fourcc) little endian to I420.
183 LIBYUV_API
184 int ARGB1555ToI420(const uint8* src_frame, int src_stride_frame,
185                    uint8* dst_y, int dst_stride_y,
186                    uint8* dst_u, int dst_stride_u,
187                    uint8* dst_v, int dst_stride_v,
188                    int width, int height);
189 
190 // RGB12 (R444 fourcc) little endian to I420.
191 LIBYUV_API
192 int ARGB4444ToI420(const uint8* src_frame, int src_stride_frame,
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 width, int height);
197 
198 #ifdef HAVE_JPEG
199 // src_width/height provided by capture.
200 // dst_width/height for clipping determine final size.
201 LIBYUV_API
202 int MJPGToI420(const uint8* sample, size_t sample_size,
203                uint8* dst_y, int dst_stride_y,
204                uint8* dst_u, int dst_stride_u,
205                uint8* dst_v, int dst_stride_v,
206                int src_width, int src_height,
207                int dst_width, int dst_height);
208 #endif
209 
210 // Note Bayer formats (BGGR) To I420 are in format_conversion.h
211 
212 // Convert camera sample to I420 with cropping, rotation and vertical flip.
213 // "src_size" is needed to parse MJPG.
214 // "dst_stride_y" number of bytes in a row of the dst_y plane.
215 //   Normally this would be the same as dst_width, with recommended alignment
216 //   to 16 bytes for better efficiency.
217 //   If rotation of 90 or 270 is used, stride is affected. The caller should
218 //   allocate the I420 buffer according to rotation.
219 // "dst_stride_u" number of bytes in a row of the dst_u plane.
220 //   Normally this would be the same as (dst_width + 1) / 2, with
221 //   recommended alignment to 16 bytes for better efficiency.
222 //   If rotation of 90 or 270 is used, stride is affected.
223 // "crop_x" and "crop_y" are starting position for cropping.
224 //   To center, crop_x = (src_width - dst_width) / 2
225 //              crop_y = (src_height - dst_height) / 2
226 // "src_width" / "src_height" is size of src_frame in pixels.
227 //   "src_height" can be negative indicating a vertically flipped image source.
228 // "dst_width" / "dst_height" is size of destination to crop to.
229 //    Must be less than or equal to src_width/src_height
230 //    Cropping parameters are pre-rotation.
231 // "rotation" can be 0, 90, 180 or 270.
232 // "format" is a fourcc. ie 'I420', 'YUY2'
233 // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure.
234 LIBYUV_API
235 int ConvertToI420(const uint8* src_frame, size_t src_size,
236                   uint8* dst_y, int dst_stride_y,
237                   uint8* dst_u, int dst_stride_u,
238                   uint8* dst_v, int dst_stride_v,
239                   int crop_x, int crop_y,
240                   int src_width, int src_height,
241                   int dst_width, int dst_height,
242                   RotationMode rotation,
243                   uint32 format);
244 
245 #ifdef __cplusplus
246 }  // extern "C"
247 }  // namespace libyuv
248 #endif
249 
250 #endif  // INCLUDE_LIBYUV_CONVERT_H_  NOLINT
251