[go: nahoru, domu]

blob: 360c6d359396c0b7d8c21eea7fad597d56aac85c [file] [log] [blame]
Vignesh Venkatasubramanian5a9753f2016-01-19 11:05:09 -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
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_ // NOLINT
12#define INCLUDE_LIBYUV_CONVERT_ARGB_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// 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.
24
25#ifdef __cplusplus
26namespace libyuv {
27extern "C" {
28#endif
29
30// Alias.
31#define ARGBToARGB ARGBCopy
32
33// Copy ARGB to ARGB.
34LIBYUV_API
35int ARGBCopy(const uint8* src_argb, int src_stride_argb,
36 uint8* dst_argb, int dst_stride_argb,
37 int width, int height);
38
39// Convert I420 to ARGB.
40LIBYUV_API
41int 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);
46
47// Convert I422 to ARGB.
48LIBYUV_API
49int 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);
54
55// Convert I444 to ARGB.
56LIBYUV_API
57int 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);
62
63// Convert I411 to ARGB.
64LIBYUV_API
65int 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);
70
71// Convert I400 (grey) to ARGB. Reverse of ARGBToI400.
72LIBYUV_API
73int I400ToARGB(const uint8* src_y, int src_stride_y,
74 uint8* dst_argb, int dst_stride_argb,
75 int width, int height);
76
77// Convert J400 (jpeg grey) to ARGB.
78LIBYUV_API
79int J400ToARGB(const uint8* src_y, int src_stride_y,
80 uint8* dst_argb, int dst_stride_argb,
81 int width, int height);
82
83// Alias.
84#define YToARGB I400ToARGB
85
86// Convert NV12 to ARGB.
87LIBYUV_API
88int 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);
92
93// Convert NV21 to ARGB.
94LIBYUV_API
95int 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);
99
100// Convert M420 to ARGB.
101LIBYUV_API
102int M420ToARGB(const uint8* src_m420, int src_stride_m420,
103 uint8* dst_argb, int dst_stride_argb,
104 int width, int height);
105
106// Convert YUY2 to ARGB.
107LIBYUV_API
108int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2,
109 uint8* dst_argb, int dst_stride_argb,
110 int width, int height);
111
112// Convert UYVY to ARGB.
113LIBYUV_API
114int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy,
115 uint8* dst_argb, int dst_stride_argb,
116 int width, int height);
117
118// Convert J420 to ARGB.
119LIBYUV_API
120int 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);
125
126// Convert J422 to ARGB.
127LIBYUV_API
128int 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);
133
134// BGRA little endian (argb in memory) to ARGB.
135LIBYUV_API
136int BGRAToARGB(const uint8* src_frame, int src_stride_frame,
137 uint8* dst_argb, int dst_stride_argb,
138 int width, int height);
139
140// ABGR little endian (rgba in memory) to ARGB.
141LIBYUV_API
142int ABGRToARGB(const uint8* src_frame, int src_stride_frame,
143 uint8* dst_argb, int dst_stride_argb,
144 int width, int height);
145
146// RGBA little endian (abgr in memory) to ARGB.
147LIBYUV_API
148int RGBAToARGB(const uint8* src_frame, int src_stride_frame,
149 uint8* dst_argb, int dst_stride_argb,
150 int width, int height);
151
152// Deprecated function name.
153#define BG24ToARGB RGB24ToARGB
154
155// RGB little endian (bgr in memory) to ARGB.
156LIBYUV_API
157int RGB24ToARGB(const uint8* src_frame, int src_stride_frame,
158 uint8* dst_argb, int dst_stride_argb,
159 int width, int height);
160
161// RGB big endian (rgb in memory) to ARGB.
162LIBYUV_API
163int RAWToARGB(const uint8* src_frame, int src_stride_frame,
164 uint8* dst_argb, int dst_stride_argb,
165 int width, int height);
166
167// RGB16 (RGBP fourcc) little endian to ARGB.
168LIBYUV_API
169int RGB565ToARGB(const uint8* src_frame, int src_stride_frame,
170 uint8* dst_argb, int dst_stride_argb,
171 int width, int height);
172
173// RGB15 (RGBO fourcc) little endian to ARGB.
174LIBYUV_API
175int ARGB1555ToARGB(const uint8* src_frame, int src_stride_frame,
176 uint8* dst_argb, int dst_stride_argb,
177 int width, int height);
178
179// RGB12 (R444 fourcc) little endian to ARGB.
180LIBYUV_API
181int ARGB4444ToARGB(const uint8* src_frame, int src_stride_frame,
182 uint8* dst_argb, int dst_stride_argb,
183 int width, int height);
184
185#ifdef HAVE_JPEG
186// src_width/height provided by capture
187// dst_width/height for clipping determine final size.
188LIBYUV_API
189int 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);
193#endif
194
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.
217LIBYUV_API
218int 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,
224 uint32 format);
225
226#ifdef __cplusplus
227} // extern "C"
228} // namespace libyuv
229#endif
230
231#endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_ NOLINT