Vignesh Venkatasubramanian | 5a9753f | 2016-01-19 11:05:09 -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 |
| 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 |
| 26 | namespace libyuv { |
| 27 | extern "C" { |
| 28 | #endif |
| 29 | |
| 30 | // Alias. |
| 31 | #define ARGBToARGB ARGBCopy |
| 32 | |
| 33 | // Copy ARGB to ARGB. |
| 34 | LIBYUV_API |
| 35 | int 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. |
| 40 | LIBYUV_API |
| 41 | int 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. |
| 48 | LIBYUV_API |
| 49 | int 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. |
| 56 | LIBYUV_API |
| 57 | int 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. |
| 64 | LIBYUV_API |
| 65 | int 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. |
| 72 | LIBYUV_API |
| 73 | int 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. |
| 78 | LIBYUV_API |
| 79 | int 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. |
| 87 | LIBYUV_API |
| 88 | int 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. |
| 94 | LIBYUV_API |
| 95 | int 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. |
| 101 | LIBYUV_API |
| 102 | int 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. |
| 107 | LIBYUV_API |
| 108 | int 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. |
| 113 | LIBYUV_API |
| 114 | int 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. |
| 119 | LIBYUV_API |
| 120 | int 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. |
| 127 | LIBYUV_API |
| 128 | int 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. |
| 135 | LIBYUV_API |
| 136 | int 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. |
| 141 | LIBYUV_API |
| 142 | int 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. |
| 147 | LIBYUV_API |
| 148 | int 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. |
| 156 | LIBYUV_API |
| 157 | int 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. |
| 162 | LIBYUV_API |
| 163 | int 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. |
| 168 | LIBYUV_API |
| 169 | int 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. |
| 174 | LIBYUV_API |
| 175 | int 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. |
| 180 | LIBYUV_API |
| 181 | int 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. |
| 188 | LIBYUV_API |
| 189 | int 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. |
| 217 | LIBYUV_API |
| 218 | int 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 |