• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_  // 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 // Add missing V210 and Q420.
22 // TODO(fbarchard): Add tests. Create random content of right size and convert
23 // with C vs Opt and or to I420 and compare.
24 // TODO(fbarchard): Some of these functions lack parameter setting.
25 
26 #ifdef __cplusplus
27 namespace libyuv {
28 extern "C" {
29 #endif
30 
31 // Alias.
32 #define ARGBToARGB ARGBCopy
33 
34 // Copy ARGB to ARGB.
35 LIBYUV_API
36 int ARGBCopy(const uint8* src_argb, int src_stride_argb,
37              uint8* dst_argb, int dst_stride_argb,
38              int width, int height);
39 
40 // Convert I420 to ARGB.
41 LIBYUV_API
42 int I420ToARGB(const uint8* src_y, int src_stride_y,
43                const uint8* src_u, int src_stride_u,
44                const uint8* src_v, int src_stride_v,
45                uint8* dst_argb, int dst_stride_argb,
46                int width, int height);
47 
48 // Convert I422 to ARGB.
49 LIBYUV_API
50 int I422ToARGB(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_argb, int dst_stride_argb,
54                int width, int height);
55 
56 // Convert I444 to ARGB.
57 LIBYUV_API
58 int I444ToARGB(const uint8* src_y, int src_stride_y,
59                const uint8* src_u, int src_stride_u,
60                const uint8* src_v, int src_stride_v,
61                uint8* dst_argb, int dst_stride_argb,
62                int width, int height);
63 
64 // Convert I411 to ARGB.
65 LIBYUV_API
66 int I411ToARGB(const uint8* src_y, int src_stride_y,
67                const uint8* src_u, int src_stride_u,
68                const uint8* src_v, int src_stride_v,
69                uint8* dst_argb, int dst_stride_argb,
70                int width, int height);
71 
72 // Convert I400 (grey) to ARGB.
73 LIBYUV_API
74 int I400ToARGB(const uint8* src_y, int src_stride_y,
75                uint8* dst_argb, int dst_stride_argb,
76                int width, int height);
77 
78 // Convert I400 to ARGB. Reverse of ARGBToI400.
79 LIBYUV_API
80 int I400ToARGB_Reference(const uint8* src_y, int src_stride_y,
81                          uint8* dst_argb, int dst_stride_argb,
82                          int width, int height);
83 
84 // Convert NV12 to ARGB.
85 LIBYUV_API
86 int NV12ToARGB(const uint8* src_y, int src_stride_y,
87                const uint8* src_uv, int src_stride_uv,
88                uint8* dst_argb, int dst_stride_argb,
89                int width, int height);
90 
91 // Convert NV21 to ARGB.
92 LIBYUV_API
93 int NV21ToARGB(const uint8* src_y, int src_stride_y,
94                const uint8* src_vu, int src_stride_vu,
95                uint8* dst_argb, int dst_stride_argb,
96                int width, int height);
97 
98 // Convert M420 to ARGB.
99 LIBYUV_API
100 int M420ToARGB(const uint8* src_m420, int src_stride_m420,
101                uint8* dst_argb, int dst_stride_argb,
102                int width, int height);
103 
104 // TODO(fbarchard): Convert Q420 to ARGB.
105 // LIBYUV_API
106 // int Q420ToARGB(const uint8* src_y, int src_stride_y,
107 //                const uint8* src_yuy2, int src_stride_yuy2,
108 //                uint8* dst_argb, int dst_stride_argb,
109 //                int width, int height);
110 
111 // Convert YUY2 to ARGB.
112 LIBYUV_API
113 int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2,
114                uint8* dst_argb, int dst_stride_argb,
115                int width, int height);
116 
117 // Convert UYVY to ARGB.
118 LIBYUV_API
119 int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy,
120                uint8* dst_argb, int dst_stride_argb,
121                int width, int height);
122 
123 // TODO(fbarchard): Convert V210 to ARGB.
124 // LIBYUV_API
125 // int V210ToARGB(const uint8* src_uyvy, int src_stride_uyvy,
126 //                uint8* dst_argb, int dst_stride_argb,
127 //                int width, int height);
128 
129 // BGRA little endian (argb in memory) to ARGB.
130 LIBYUV_API
131 int BGRAToARGB(const uint8* src_frame, int src_stride_frame,
132                uint8* dst_argb, int dst_stride_argb,
133                int width, int height);
134 
135 // ABGR little endian (rgba in memory) to ARGB.
136 LIBYUV_API
137 int ABGRToARGB(const uint8* src_frame, int src_stride_frame,
138                uint8* dst_argb, int dst_stride_argb,
139                int width, int height);
140 
141 // RGBA little endian (abgr in memory) to ARGB.
142 LIBYUV_API
143 int RGBAToARGB(const uint8* src_frame, int src_stride_frame,
144                uint8* dst_argb, int dst_stride_argb,
145                int width, int height);
146 
147 // Deprecated function name.
148 #define BG24ToARGB RGB24ToARGB
149 
150 // RGB little endian (bgr in memory) to ARGB.
151 LIBYUV_API
152 int RGB24ToARGB(const uint8* src_frame, int src_stride_frame,
153                 uint8* dst_argb, int dst_stride_argb,
154                 int width, int height);
155 
156 // RGB big endian (rgb in memory) to ARGB.
157 LIBYUV_API
158 int RAWToARGB(const uint8* src_frame, int src_stride_frame,
159               uint8* dst_argb, int dst_stride_argb,
160               int width, int height);
161 
162 // RGB16 (RGBP fourcc) little endian to ARGB.
163 LIBYUV_API
164 int RGB565ToARGB(const uint8* src_frame, int src_stride_frame,
165                  uint8* dst_argb, int dst_stride_argb,
166                  int width, int height);
167 
168 // RGB15 (RGBO fourcc) little endian to ARGB.
169 LIBYUV_API
170 int ARGB1555ToARGB(const uint8* src_frame, int src_stride_frame,
171                    uint8* dst_argb, int dst_stride_argb,
172                    int width, int height);
173 
174 // RGB12 (R444 fourcc) little endian to ARGB.
175 LIBYUV_API
176 int ARGB4444ToARGB(const uint8* src_frame, int src_stride_frame,
177                    uint8* dst_argb, int dst_stride_argb,
178                    int width, int height);
179 
180 #ifdef HAVE_JPEG
181 // src_width/height provided by capture
182 // dst_width/height for clipping determine final size.
183 LIBYUV_API
184 int MJPGToARGB(const uint8* sample, size_t sample_size,
185                uint8* dst_argb, int dst_stride_argb,
186                int src_width, int src_height,
187                int dst_width, int dst_height);
188 #endif
189 
190 // Note Bayer formats (BGGR) to ARGB are in format_conversion.h.
191 
192 // Convert camera sample to ARGB with cropping, rotation and vertical flip.
193 // "src_size" is needed to parse MJPG.
194 // "dst_stride_argb" number of bytes in a row of the dst_argb plane.
195 //   Normally this would be the same as dst_width, with recommended alignment
196 //   to 16 bytes for better efficiency.
197 //   If rotation of 90 or 270 is used, stride is affected. The caller should
198 //   allocate the I420 buffer according to rotation.
199 // "dst_stride_u" number of bytes in a row of the dst_u plane.
200 //   Normally this would be the same as (dst_width + 1) / 2, with
201 //   recommended alignment to 16 bytes for better efficiency.
202 //   If rotation of 90 or 270 is used, stride is affected.
203 // "crop_x" and "crop_y" are starting position for cropping.
204 //   To center, crop_x = (src_width - dst_width) / 2
205 //              crop_y = (src_height - dst_height) / 2
206 // "src_width" / "src_height" is size of src_frame in pixels.
207 //   "src_height" can be negative indicating a vertically flipped image source.
208 // "dst_width" / "dst_height" is size of destination to crop to.
209 //    Must be less than or equal to src_width/src_height
210 //    Cropping parameters are pre-rotation.
211 // "rotation" can be 0, 90, 180 or 270.
212 // "format" is a fourcc. ie 'I420', 'YUY2'
213 // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure.
214 LIBYUV_API
215 int ConvertToARGB(const uint8* src_frame, size_t src_size,
216                   uint8* dst_argb, int dst_stride_argb,
217                   int crop_x, int crop_y,
218                   int src_width, int src_height,
219                   int dst_width, int dst_height,
220                   RotationMode rotation,
221                   uint32 format);
222 
223 #ifdef __cplusplus
224 }  // extern "C"
225 }  // namespace libyuv
226 #endif
227 
228 #endif  // INCLUDE_LIBYUV_CONVERT_ARGB_H_  NOLINT
229