Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 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 |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 7 | * in the file PATENTS. All contributing project authors may |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 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" |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 15 | |
| 16 | #include "libyuv/rotate.h" // For enum RotationMode. |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 17 | |
| 18 | // TODO(fbarchard): This set of functions should exactly match convert.h |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 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. |
| 32 | LIBYUV_API |
| 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. |
| 38 | LIBYUV_API |
| 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 | // Convert I422 to ARGB. |
| 46 | LIBYUV_API |
| 47 | int 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. |
| 54 | LIBYUV_API |
| 55 | int 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 Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 61 | // Convert J444 to ARGB. |
| 62 | LIBYUV_API |
| 63 | int 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. |
| 70 | LIBYUV_API |
| 71 | int 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 Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 77 | // Convert I411 to ARGB. |
| 78 | LIBYUV_API |
| 79 | int 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 Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 85 | // Convert I420 with Alpha to preattenuated ARGB. |
| 86 | LIBYUV_API |
| 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. |
| 95 | LIBYUV_API |
| 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. |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 104 | LIBYUV_API |
| 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 | |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 109 | // Convert J400 (jpeg grey) to ARGB. |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 110 | LIBYUV_API |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 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 |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 117 | |
| 118 | // Convert NV12 to ARGB. |
| 119 | LIBYUV_API |
| 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. |
| 126 | LIBYUV_API |
| 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. |
| 133 | LIBYUV_API |
| 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 | |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 138 | // Convert YUY2 to ARGB. |
| 139 | LIBYUV_API |
| 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. |
| 145 | LIBYUV_API |
| 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 | |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 150 | // Convert J420 to ARGB. |
| 151 | LIBYUV_API |
| 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. |
| 159 | LIBYUV_API |
| 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. |
| 167 | LIBYUV_API |
| 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. |
| 175 | LIBYUV_API |
| 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. |
| 183 | LIBYUV_API |
| 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. |
| 191 | LIBYUV_API |
| 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. |
| 199 | LIBYUV_API |
| 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. |
| 207 | LIBYUV_API |
| 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); |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 213 | |
| 214 | // BGRA little endian (argb in memory) to ARGB. |
| 215 | LIBYUV_API |
| 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. |
| 221 | LIBYUV_API |
| 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. |
| 227 | LIBYUV_API |
| 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. |
| 236 | LIBYUV_API |
| 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. |
| 242 | LIBYUV_API |
| 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. |
| 248 | LIBYUV_API |
| 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. |
| 254 | LIBYUV_API |
| 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. |
| 260 | LIBYUV_API |
| 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 | |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 265 | // src_width/height provided by capture |
| 266 | // dst_width/height for clipping determine final size. |
| 267 | LIBYUV_API |
| 268 | int 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 Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 272 | |
| 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 Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 289 | // "crop_width" / "crop_height" is the size to crop the src to. |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 290 | // 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. |
| 295 | LIBYUV_API |
| 296 | int 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 Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 300 | int crop_width, int crop_height, |
| 301 | enum RotationMode rotation, |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 302 | uint32 format); |
| 303 | |
| 304 | #ifdef __cplusplus |
| 305 | } // extern "C" |
| 306 | } // namespace libyuv |
| 307 | #endif |
| 308 | |
| 309 | #endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_ NOLINT |