blob: 996f4768f60341495d9a8fccc93fd4ac4ee7547c [file] [log] [blame]
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -08001/*
2 * Copyright 2012 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
Hangyu Kuangf047e7c2016-07-06 14:21:45 -07007 * in the file PATENTS. All contributing project authors may
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -08008 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef INCLUDE_LIBYUV_CONVERT_ARGB_H_ // NOLINT
12#define INCLUDE_LIBYUV_CONVERT_ARGB_H_
13
14#include "libyuv/basic_types.h"
Hangyu Kuangf047e7c2016-07-06 14:21:45 -070015
16#include "libyuv/rotate.h" // For enum RotationMode.
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -080017
18// TODO(fbarchard): This set of functions should exactly match convert.h
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -080019// TODO(fbarchard): Add tests. Create random content of right size and convert
20// with C vs Opt and or to I420 and compare.
21// TODO(fbarchard): Some of these functions lack parameter setting.
22
23#ifdef __cplusplus
24namespace libyuv {
25extern "C" {
26#endif
27
28// Alias.
29#define ARGBToARGB ARGBCopy
30
31// Copy ARGB to ARGB.
32LIBYUV_API
33int ARGBCopy(const uint8* src_argb, int src_stride_argb,
34 uint8* dst_argb, int dst_stride_argb,
35 int width, int height);
36
37// Convert I420 to ARGB.
38LIBYUV_API
39int I420ToARGB(const uint8* src_y, int src_stride_y,
40 const uint8* src_u, int src_stride_u,
41 const uint8* src_v, int src_stride_v,
42 uint8* dst_argb, int dst_stride_argb,
43 int width, int height);
44
45// Convert I422 to ARGB.
46LIBYUV_API
47int I422ToARGB(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_argb, int dst_stride_argb,
51 int width, int height);
52
53// Convert I444 to ARGB.
54LIBYUV_API
55int I444ToARGB(const uint8* src_y, int src_stride_y,
56 const uint8* src_u, int src_stride_u,
57 const uint8* src_v, int src_stride_v,
58 uint8* dst_argb, int dst_stride_argb,
59 int width, int height);
60
Hangyu Kuangf047e7c2016-07-06 14:21:45 -070061// Convert J444 to ARGB.
62LIBYUV_API
63int J444ToARGB(const uint8* src_y, int src_stride_y,
64 const uint8* src_u, int src_stride_u,
65 const uint8* src_v, int src_stride_v,
66 uint8* dst_argb, int dst_stride_argb,
67 int width, int height);
68
69// Convert I444 to ABGR.
70LIBYUV_API
71int I444ToABGR(const uint8* src_y, int src_stride_y,
72 const uint8* src_u, int src_stride_u,
73 const uint8* src_v, int src_stride_v,
74 uint8* dst_abgr, int dst_stride_abgr,
75 int width, int height);
76
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -080077// Convert I411 to ARGB.
78LIBYUV_API
79int I411ToARGB(const uint8* src_y, int src_stride_y,
80 const uint8* src_u, int src_stride_u,
81 const uint8* src_v, int src_stride_v,
82 uint8* dst_argb, int dst_stride_argb,
83 int width, int height);
84
Hangyu Kuangf047e7c2016-07-06 14:21:45 -070085// Convert I420 with Alpha to preattenuated ARGB.
86LIBYUV_API
87int I420AlphaToARGB(const uint8* src_y, int src_stride_y,
88 const uint8* src_u, int src_stride_u,
89 const uint8* src_v, int src_stride_v,
90 const uint8* src_a, int src_stride_a,
91 uint8* dst_argb, int dst_stride_argb,
92 int width, int height, int attenuate);
93
94// Convert I420 with Alpha to preattenuated ABGR.
95LIBYUV_API
96int I420AlphaToABGR(const uint8* src_y, int src_stride_y,
97 const uint8* src_u, int src_stride_u,
98 const uint8* src_v, int src_stride_v,
99 const uint8* src_a, int src_stride_a,
100 uint8* dst_abgr, int dst_stride_abgr,
101 int width, int height, int attenuate);
102
103// Convert I400 (grey) to ARGB. Reverse of ARGBToI400.
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -0800104LIBYUV_API
105int I400ToARGB(const uint8* src_y, int src_stride_y,
106 uint8* dst_argb, int dst_stride_argb,
107 int width, int height);
108
Hangyu Kuangf047e7c2016-07-06 14:21:45 -0700109// Convert J400 (jpeg grey) to ARGB.
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -0800110LIBYUV_API
Hangyu Kuangf047e7c2016-07-06 14:21:45 -0700111int J400ToARGB(const uint8* src_y, int src_stride_y,
112 uint8* dst_argb, int dst_stride_argb,
113 int width, int height);
114
115// Alias.
116#define YToARGB I400ToARGB
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -0800117
118// Convert NV12 to ARGB.
119LIBYUV_API
120int NV12ToARGB(const uint8* src_y, int src_stride_y,
121 const uint8* src_uv, int src_stride_uv,
122 uint8* dst_argb, int dst_stride_argb,
123 int width, int height);
124
125// Convert NV21 to ARGB.
126LIBYUV_API
127int NV21ToARGB(const uint8* src_y, int src_stride_y,
128 const uint8* src_vu, int src_stride_vu,
129 uint8* dst_argb, int dst_stride_argb,
130 int width, int height);
131
132// Convert M420 to ARGB.
133LIBYUV_API
134int M420ToARGB(const uint8* src_m420, int src_stride_m420,
135 uint8* dst_argb, int dst_stride_argb,
136 int width, int height);
137
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -0800138// Convert YUY2 to ARGB.
139LIBYUV_API
140int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2,
141 uint8* dst_argb, int dst_stride_argb,
142 int width, int height);
143
144// Convert UYVY to ARGB.
145LIBYUV_API
146int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy,
147 uint8* dst_argb, int dst_stride_argb,
148 int width, int height);
149
Hangyu Kuangf047e7c2016-07-06 14:21:45 -0700150// Convert J420 to ARGB.
151LIBYUV_API
152int J420ToARGB(const uint8* src_y, int src_stride_y,
153 const uint8* src_u, int src_stride_u,
154 const uint8* src_v, int src_stride_v,
155 uint8* dst_argb, int dst_stride_argb,
156 int width, int height);
157
158// Convert J422 to ARGB.
159LIBYUV_API
160int J422ToARGB(const uint8* src_y, int src_stride_y,
161 const uint8* src_u, int src_stride_u,
162 const uint8* src_v, int src_stride_v,
163 uint8* dst_argb, int dst_stride_argb,
164 int width, int height);
165
166// Convert J420 to ABGR.
167LIBYUV_API
168int J420ToABGR(const uint8* src_y, int src_stride_y,
169 const uint8* src_u, int src_stride_u,
170 const uint8* src_v, int src_stride_v,
171 uint8* dst_abgr, int dst_stride_abgr,
172 int width, int height);
173
174// Convert J422 to ABGR.
175LIBYUV_API
176int J422ToABGR(const uint8* src_y, int src_stride_y,
177 const uint8* src_u, int src_stride_u,
178 const uint8* src_v, int src_stride_v,
179 uint8* dst_abgr, int dst_stride_abgr,
180 int width, int height);
181
182// Convert H420 to ARGB.
183LIBYUV_API
184int H420ToARGB(const uint8* src_y, int src_stride_y,
185 const uint8* src_u, int src_stride_u,
186 const uint8* src_v, int src_stride_v,
187 uint8* dst_argb, int dst_stride_argb,
188 int width, int height);
189
190// Convert H422 to ARGB.
191LIBYUV_API
192int H422ToARGB(const uint8* src_y, int src_stride_y,
193 const uint8* src_u, int src_stride_u,
194 const uint8* src_v, int src_stride_v,
195 uint8* dst_argb, int dst_stride_argb,
196 int width, int height);
197
198// Convert H420 to ABGR.
199LIBYUV_API
200int H420ToABGR(const uint8* src_y, int src_stride_y,
201 const uint8* src_u, int src_stride_u,
202 const uint8* src_v, int src_stride_v,
203 uint8* dst_abgr, int dst_stride_abgr,
204 int width, int height);
205
206// Convert H422 to ABGR.
207LIBYUV_API
208int H422ToABGR(const uint8* src_y, int src_stride_y,
209 const uint8* src_u, int src_stride_u,
210 const uint8* src_v, int src_stride_v,
211 uint8* dst_abgr, int dst_stride_abgr,
212 int width, int height);
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -0800213
214// BGRA little endian (argb in memory) to ARGB.
215LIBYUV_API
216int BGRAToARGB(const uint8* src_frame, int src_stride_frame,
217 uint8* dst_argb, int dst_stride_argb,
218 int width, int height);
219
220// ABGR little endian (rgba in memory) to ARGB.
221LIBYUV_API
222int ABGRToARGB(const uint8* src_frame, int src_stride_frame,
223 uint8* dst_argb, int dst_stride_argb,
224 int width, int height);
225
226// RGBA little endian (abgr in memory) to ARGB.
227LIBYUV_API
228int RGBAToARGB(const uint8* src_frame, int src_stride_frame,
229 uint8* dst_argb, int dst_stride_argb,
230 int width, int height);
231
232// Deprecated function name.
233#define BG24ToARGB RGB24ToARGB
234
235// RGB little endian (bgr in memory) to ARGB.
236LIBYUV_API
237int RGB24ToARGB(const uint8* src_frame, int src_stride_frame,
238 uint8* dst_argb, int dst_stride_argb,
239 int width, int height);
240
241// RGB big endian (rgb in memory) to ARGB.
242LIBYUV_API
243int RAWToARGB(const uint8* src_frame, int src_stride_frame,
244 uint8* dst_argb, int dst_stride_argb,
245 int width, int height);
246
247// RGB16 (RGBP fourcc) little endian to ARGB.
248LIBYUV_API
249int RGB565ToARGB(const uint8* src_frame, int src_stride_frame,
250 uint8* dst_argb, int dst_stride_argb,
251 int width, int height);
252
253// RGB15 (RGBO fourcc) little endian to ARGB.
254LIBYUV_API
255int ARGB1555ToARGB(const uint8* src_frame, int src_stride_frame,
256 uint8* dst_argb, int dst_stride_argb,
257 int width, int height);
258
259// RGB12 (R444 fourcc) little endian to ARGB.
260LIBYUV_API
261int ARGB4444ToARGB(const uint8* src_frame, int src_stride_frame,
262 uint8* dst_argb, int dst_stride_argb,
263 int width, int height);
264
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -0800265// src_width/height provided by capture
266// dst_width/height for clipping determine final size.
267LIBYUV_API
268int MJPGToARGB(const uint8* sample, size_t sample_size,
269 uint8* dst_argb, int dst_stride_argb,
270 int src_width, int src_height,
271 int dst_width, int dst_height);
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -0800272
273// Convert camera sample to ARGB with cropping, rotation and vertical flip.
274// "src_size" is needed to parse MJPG.
275// "dst_stride_argb" number of bytes in a row of the dst_argb plane.
276// Normally this would be the same as dst_width, with recommended alignment
277// to 16 bytes for better efficiency.
278// If rotation of 90 or 270 is used, stride is affected. The caller should
279// allocate the I420 buffer according to rotation.
280// "dst_stride_u" number of bytes in a row of the dst_u plane.
281// Normally this would be the same as (dst_width + 1) / 2, with
282// recommended alignment to 16 bytes for better efficiency.
283// If rotation of 90 or 270 is used, stride is affected.
284// "crop_x" and "crop_y" are starting position for cropping.
285// To center, crop_x = (src_width - dst_width) / 2
286// crop_y = (src_height - dst_height) / 2
287// "src_width" / "src_height" is size of src_frame in pixels.
288// "src_height" can be negative indicating a vertically flipped image source.
Hangyu Kuangf047e7c2016-07-06 14:21:45 -0700289// "crop_width" / "crop_height" is the size to crop the src to.
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -0800290// Must be less than or equal to src_width/src_height
291// Cropping parameters are pre-rotation.
292// "rotation" can be 0, 90, 180 or 270.
293// "format" is a fourcc. ie 'I420', 'YUY2'
294// Returns 0 for successful; -1 for invalid parameter. Non-zero for failure.
295LIBYUV_API
296int ConvertToARGB(const uint8* src_frame, size_t src_size,
297 uint8* dst_argb, int dst_stride_argb,
298 int crop_x, int crop_y,
299 int src_width, int src_height,
Hangyu Kuangf047e7c2016-07-06 14:21:45 -0700300 int crop_width, int crop_height,
301 enum RotationMode rotation,
Hendrik Dahlkamp33cfdeb2013-01-23 18:27:37 -0800302 uint32 format);
303
304#ifdef __cplusplus
305} // extern "C"
306} // namespace libyuv
307#endif
308
309#endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_ NOLINT