2 * Copyright 2012 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_ARGB_H_ // NOLINT
12 #define INCLUDE_LIBYUV_CONVERT_ARGB_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"
20 // TODO(fbarchard): This set of functions should exactly match convert.h
21 // TODO(fbarchard): Add tests. Create random content of right size and convert
22 // with C vs Opt and or to I420 and compare.
23 // TODO(fbarchard): Some of these functions lack parameter setting.
31 #define ARGBToARGB ARGBCopy
35 int ARGBCopy(const uint8* src_argb, int src_stride_argb,
36 uint8* dst_argb, int dst_stride_argb,
37 int width, int height);
39 // Convert I420 to ARGB.
41 int I420ToARGB(const uint8* src_y, int src_stride_y,
42 const uint8* src_u, int src_stride_u,
43 const uint8* src_v, int src_stride_v,
44 uint8* dst_argb, int dst_stride_argb,
45 int width, int height);
47 // Convert I422 to ARGB.
49 int I422ToARGB(const uint8* src_y, int src_stride_y,
50 const uint8* src_u, int src_stride_u,
51 const uint8* src_v, int src_stride_v,
52 uint8* dst_argb, int dst_stride_argb,
53 int width, int height);
55 // Convert I444 to ARGB.
57 int I444ToARGB(const uint8* src_y, int src_stride_y,
58 const uint8* src_u, int src_stride_u,
59 const uint8* src_v, int src_stride_v,
60 uint8* dst_argb, int dst_stride_argb,
61 int width, int height);
63 // Convert I411 to ARGB.
65 int I411ToARGB(const uint8* src_y, int src_stride_y,
66 const uint8* src_u, int src_stride_u,
67 const uint8* src_v, int src_stride_v,
68 uint8* dst_argb, int dst_stride_argb,
69 int width, int height);
71 // Convert I400 (grey) to ARGB.
73 int I400ToARGB(const uint8* src_y, int src_stride_y,
74 uint8* dst_argb, int dst_stride_argb,
75 int width, int height);
78 #define YToARGB I400ToARGB_Reference
80 // Convert I400 to ARGB. Reverse of ARGBToI400.
82 int I400ToARGB_Reference(const uint8* src_y, int src_stride_y,
83 uint8* dst_argb, int dst_stride_argb,
84 int width, int height);
86 // Convert NV12 to ARGB.
88 int NV12ToARGB(const uint8* src_y, int src_stride_y,
89 const uint8* src_uv, int src_stride_uv,
90 uint8* dst_argb, int dst_stride_argb,
91 int width, int height);
93 // Convert NV21 to ARGB.
95 int NV21ToARGB(const uint8* src_y, int src_stride_y,
96 const uint8* src_vu, int src_stride_vu,
97 uint8* dst_argb, int dst_stride_argb,
98 int width, int height);
100 // Convert M420 to ARGB.
102 int M420ToARGB(const uint8* src_m420, int src_stride_m420,
103 uint8* dst_argb, int dst_stride_argb,
104 int width, int height);
106 // Convert YUY2 to ARGB.
108 int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2,
109 uint8* dst_argb, int dst_stride_argb,
110 int width, int height);
112 // Convert UYVY to ARGB.
114 int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy,
115 uint8* dst_argb, int dst_stride_argb,
116 int width, int height);
118 // Convert J420 to ARGB.
120 int J420ToARGB(const uint8* src_y, int src_stride_y,
121 const uint8* src_u, int src_stride_u,
122 const uint8* src_v, int src_stride_v,
123 uint8* dst_argb, int dst_stride_argb,
124 int width, int height);
126 // Convert J422 to ARGB.
128 int J422ToARGB(const uint8* src_y, int src_stride_y,
129 const uint8* src_u, int src_stride_u,
130 const uint8* src_v, int src_stride_v,
131 uint8* dst_argb, int dst_stride_argb,
132 int width, int height);
134 // BGRA little endian (argb in memory) to ARGB.
136 int BGRAToARGB(const uint8* src_frame, int src_stride_frame,
137 uint8* dst_argb, int dst_stride_argb,
138 int width, int height);
140 // ABGR little endian (rgba in memory) to ARGB.
142 int ABGRToARGB(const uint8* src_frame, int src_stride_frame,
143 uint8* dst_argb, int dst_stride_argb,
144 int width, int height);
146 // RGBA little endian (abgr in memory) to ARGB.
148 int RGBAToARGB(const uint8* src_frame, int src_stride_frame,
149 uint8* dst_argb, int dst_stride_argb,
150 int width, int height);
152 // Deprecated function name.
153 #define BG24ToARGB RGB24ToARGB
155 // RGB little endian (bgr in memory) to ARGB.
157 int RGB24ToARGB(const uint8* src_frame, int src_stride_frame,
158 uint8* dst_argb, int dst_stride_argb,
159 int width, int height);
161 // RGB big endian (rgb in memory) to ARGB.
163 int RAWToARGB(const uint8* src_frame, int src_stride_frame,
164 uint8* dst_argb, int dst_stride_argb,
165 int width, int height);
167 // RGB16 (RGBP fourcc) little endian to ARGB.
169 int RGB565ToARGB(const uint8* src_frame, int src_stride_frame,
170 uint8* dst_argb, int dst_stride_argb,
171 int width, int height);
173 // RGB15 (RGBO fourcc) little endian to ARGB.
175 int ARGB1555ToARGB(const uint8* src_frame, int src_stride_frame,
176 uint8* dst_argb, int dst_stride_argb,
177 int width, int height);
179 // RGB12 (R444 fourcc) little endian to ARGB.
181 int ARGB4444ToARGB(const uint8* src_frame, int src_stride_frame,
182 uint8* dst_argb, int dst_stride_argb,
183 int width, int height);
186 // src_width/height provided by capture
187 // dst_width/height for clipping determine final size.
189 int MJPGToARGB(const uint8* sample, size_t sample_size,
190 uint8* dst_argb, int dst_stride_argb,
191 int src_width, int src_height,
192 int dst_width, int dst_height);
195 // Convert camera sample to ARGB with cropping, rotation and vertical flip.
196 // "src_size" is needed to parse MJPG.
197 // "dst_stride_argb" number of bytes in a row of the dst_argb plane.
198 // Normally this would be the same as dst_width, with recommended alignment
199 // to 16 bytes for better efficiency.
200 // If rotation of 90 or 270 is used, stride is affected. The caller should
201 // allocate the I420 buffer according to rotation.
202 // "dst_stride_u" number of bytes in a row of the dst_u plane.
203 // Normally this would be the same as (dst_width + 1) / 2, with
204 // recommended alignment to 16 bytes for better efficiency.
205 // If rotation of 90 or 270 is used, stride is affected.
206 // "crop_x" and "crop_y" are starting position for cropping.
207 // To center, crop_x = (src_width - dst_width) / 2
208 // crop_y = (src_height - dst_height) / 2
209 // "src_width" / "src_height" is size of src_frame in pixels.
210 // "src_height" can be negative indicating a vertically flipped image source.
211 // "crop_width" / "crop_height" is the size to crop the src to.
212 // Must be less than or equal to src_width/src_height
213 // Cropping parameters are pre-rotation.
214 // "rotation" can be 0, 90, 180 or 270.
215 // "format" is a fourcc. ie 'I420', 'YUY2'
216 // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure.
218 int ConvertToARGB(const uint8* src_frame, size_t src_size,
219 uint8* dst_argb, int dst_stride_argb,
220 int crop_x, int crop_y,
221 int src_width, int src_height,
222 int crop_width, int crop_height,
223 enum RotationMode rotation,
228 } // namespace libyuv
231 #endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_ NOLINT