webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
convert_argb.h
Go to the documentation of this file.
1 /*
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
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_ARGB_H_
12 #define INCLUDE_LIBYUV_CONVERT_ARGB_H_
13 
14 #include "libyuv/basic_types.h"
15 
16 #include "libyuv/rotate.h" // For enum RotationMode.
17 
18 // TODO(fbarchard): This set of functions should exactly match convert.h
19 // 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
24 namespace libyuv {
25 extern "C" {
26 #endif
27 
28 // Alias.
29 #define ARGBToARGB ARGBCopy
30 
31 // Copy ARGB to ARGB.
33 int 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.
39 int 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 // Duplicate prototype for function in convert_from.h for remoting.
47 int I420ToABGR(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 I422 to ARGB.
55 int I422ToARGB(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 
61 // Convert I444 to ARGB.
63 int I444ToARGB(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 J444 to ARGB.
71 int J444ToARGB(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_argb, int dst_stride_argb,
75  int width, int height);
76 
77 // Convert I444 to ABGR.
79 int I444ToABGR(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_abgr, int dst_stride_abgr,
83  int width, int height);
84 
85 // Convert I420 with Alpha to preattenuated ARGB.
87 int 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.
96 int 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.
105 int I400ToARGB(const uint8* src_y, int src_stride_y,
106  uint8* dst_argb, int dst_stride_argb,
107  int width, int height);
108 
109 // Convert J400 (jpeg grey) to ARGB.
111 int 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
117 
118 // Convert NV12 to ARGB.
120 int 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.
127 int 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.
134 int M420ToARGB(const uint8* src_m420, int src_stride_m420,
135  uint8* dst_argb, int dst_stride_argb,
136  int width, int height);
137 
138 // Convert YUY2 to ARGB.
140 int 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.
146 int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy,
147  uint8* dst_argb, int dst_stride_argb,
148  int width, int height);
149 
150 // Convert J420 to ARGB.
152 int 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.
160 int 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.
168 int 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.
176 int 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.
184 int 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.
192 int 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.
200 int 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.
208 int 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);
213 
214 // BGRA little endian (argb in memory) to ARGB.
216 int 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.
222 int 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.
228 int 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.
237 int 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.
243 int 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.
249 int 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.
255 int 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.
261 int ARGB4444ToARGB(const uint8* src_frame, int src_stride_frame,
262  uint8* dst_argb, int dst_stride_argb,
263  int width, int height);
264 
265 #ifdef HAVE_JPEG
266 // src_width/height provided by capture
267 // dst_width/height for clipping determine final size.
269 int MJPGToARGB(const uint8* sample, size_t sample_size,
270  uint8* dst_argb, int dst_stride_argb,
271  int src_width, int src_height,
272  int dst_width, int dst_height);
273 #endif
274 
275 // Convert camera sample to ARGB with cropping, rotation and vertical flip.
276 // "src_size" is needed to parse MJPG.
277 // "dst_stride_argb" number of bytes in a row of the dst_argb plane.
278 // Normally this would be the same as dst_width, with recommended alignment
279 // to 16 bytes for better efficiency.
280 // If rotation of 90 or 270 is used, stride is affected. The caller should
281 // allocate the I420 buffer according to rotation.
282 // "dst_stride_u" number of bytes in a row of the dst_u plane.
283 // Normally this would be the same as (dst_width + 1) / 2, with
284 // recommended alignment to 16 bytes for better efficiency.
285 // If rotation of 90 or 270 is used, stride is affected.
286 // "crop_x" and "crop_y" are starting position for cropping.
287 // To center, crop_x = (src_width - dst_width) / 2
288 // crop_y = (src_height - dst_height) / 2
289 // "src_width" / "src_height" is size of src_frame in pixels.
290 // "src_height" can be negative indicating a vertically flipped image source.
291 // "crop_width" / "crop_height" is the size to crop the src to.
292 // Must be less than or equal to src_width/src_height
293 // Cropping parameters are pre-rotation.
294 // "rotation" can be 0, 90, 180 or 270.
295 // "format" is a fourcc. ie 'I420', 'YUY2'
296 // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure.
298 int ConvertToARGB(const uint8* src_frame, size_t src_size,
299  uint8* dst_argb, int dst_stride_argb,
300  int crop_x, int crop_y,
301  int src_width, int src_height,
302  int crop_width, int crop_height,
303  enum RotationMode rotation,
304  uint32 format);
305 
306 #ifdef __cplusplus
307 } // extern "C"
308 } // namespace libyuv
309 #endif
310 
311 #endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_
LIBYUV_API int RGBAToARGB(const uint8 *src_frame, int src_stride_frame, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:804
EGLSurface EGLint EGLint EGLint EGLint height
Definition: eglext.h:950
LIBYUV_API int I420ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:120
GLint GLint GLint GLsizei GLsizei GLenum format
Definition: gl2.h:403
LIBYUV_API int J422ToABGR(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_abgr, int dst_stride_abgr, int width, int height)
Definition: convert_argb.cc:333
LIBYUV_API int I420AlphaToABGR(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, const uint8 *src_a, int src_stride_a, uint8 *dst_abgr, int dst_stride_abgr, int width, int height, int attenuate)
Definition: convert_argb.cc:612
EGLSurface EGLint EGLint EGLint width
Definition: eglext.h:950
LIBYUV_API int J422ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:318
LIBYUV_API int H420ToABGR(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_abgr, int dst_stride_abgr, int width, int height)
Definition: convert_argb.cc:195
LIBYUV_API int RAWToARGB(const uint8 *src_frame, int src_stride_frame, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:865
LIBYUV_API int RGB24ToARGB(const uint8 *src_frame, int src_stride_frame, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:815
unsigned char uint8
Definition: basic_types.h:62
int dst_height
Definition: convert.cc:32
LIBYUV_API int H422ToABGR(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_abgr, int dst_stride_abgr, int width, int height)
Definition: convert_argb.cc:363
LIBYUV_API int I420AlphaToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, const uint8 *src_a, int src_stride_a, uint8 *dst_argb, int dst_stride_argb, int width, int height, int attenuate)
Definition: convert_argb.cc:595
LIBYUV_API int I444ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:447
LIBYUV_API int BGRAToARGB(const uint8 *src_frame, int src_stride_frame, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:760
LIBYUV_API int I420ToABGR(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:135
LIBYUV_API int J444ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:477
LIBYUV_API int J420ToABGR(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_abgr, int dst_stride_abgr, int width, int height)
Definition: convert_argb.cc:165
uint8_t * src_u
Definition: peerconnection_jni.cc:2263
LIBYUV_API int J420ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:150
LIBYUV_API int ABGRToARGB(const uint8 *src_frame, int src_stride_frame, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:782
LIBYUV_API int RGB565ToARGB(const uint8 *src_frame, int src_stride_frame, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:915
uint8_t * src_y
Definition: peerconnection_jni.cc:2261
bool attenuate
Definition: convert.cc:29
LIBYUV_API int YUY2ToARGB(const uint8 *src_yuy2, int src_stride_yuy2, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:1274
LIBYUV_API int H420ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:180
LIBYUV_API int I400ToARGB(const uint8 *src_y, int src_stride_y, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:629
LIBYUV_API int H422ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:348
JNIEnv jlong jbyteArray jint jint jint jint rotation
Definition: androidvideotracksource_jni.cc:30
LIBYUV_API int I422ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:288
LIBYUV_API int M420ToARGB(const uint8 *src_m420, int src_stride_m420, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:1213
LIBYUV_API int J400ToARGB(const uint8 *src_y, int src_stride_y, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:688
Definition: basictypes_test.cc:14
int dst_width
Definition: convert.cc:32
LIBYUV_API int ConvertToARGB(const uint8 *src_frame, size_t src_size, uint8 *dst_argb, int dst_stride_argb, int crop_x, int crop_y, int src_width, int src_height, int crop_width, int crop_height, enum RotationMode rotation, uint32 format)
Definition: convert_to_argb.cc:32
#define LIBYUV_API
Definition: basic_types.h:102
LIBYUV_API int UYVYToARGB(const uint8 *src_uyvy, int src_stride_uyvy, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:1334
uint32_t uint32
Definition: angle_config.h:28
LIBYUV_API int NV21ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_vu, int src_stride_vu, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:1155
LIBYUV_API int ARGBCopy(const uint8 *src_argb, int src_stride_argb, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:29
uint8_t * src_v
Definition: peerconnection_jni.cc:2265
LIBYUV_API int I444ToABGR(const uint8 *src_y, int src_stride_y, const uint8 *src_u, int src_stride_u, const uint8 *src_v, int src_stride_v, uint8 *dst_abgr, int dst_stride_abgr, int width, int height)
Definition: convert_argb.cc:462
LIBYUV_API int ARGB4444ToARGB(const uint8 *src_frame, int src_stride_frame, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:1031
LIBYUV_API int ARGB1555ToARGB(const uint8 *src_frame, int src_stride_frame, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:973
LIBYUV_API int NV12ToARGB(const uint8 *src_y, int src_stride_y, const uint8 *src_uv, int src_stride_uv, uint8 *dst_argb, int dst_stride_argb, int width, int height)
Definition: convert_argb.cc:1097
RotationMode
Definition: rotate.h:22