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 27namespace libyuv { 28extern "C" { 29#endif 30 31// Alias. 32#define ARGBToARGB ARGBCopy 33 34// Copy ARGB to ARGB. 35LIBYUV_API 36int 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. 41LIBYUV_API 42int 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. 49LIBYUV_API 50int 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. 57LIBYUV_API 58int 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. 65LIBYUV_API 66int 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. 73LIBYUV_API 74int 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. 79LIBYUV_API 80int 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. 85LIBYUV_API 86int 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. 92LIBYUV_API 93int 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. 99LIBYUV_API 100int 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. 112LIBYUV_API 113int 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. 118LIBYUV_API 119int 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. 130LIBYUV_API 131int 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. 136LIBYUV_API 137int 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. 142LIBYUV_API 143int 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. 151LIBYUV_API 152int 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. 157LIBYUV_API 158int 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. 163LIBYUV_API 164int 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. 169LIBYUV_API 170int 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. 175LIBYUV_API 176int 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. 183LIBYUV_API 184int 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. 214LIBYUV_API 215int 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