1/* 2 * Copyright 2011 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_PLANAR_FUNCTIONS_H_ // NOLINT 12#define INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ 13 14#include "libyuv/basic_types.h" 15 16// TODO(fbarchard): Remove the following headers includes. 17#include "libyuv/convert.h" 18#include "libyuv/convert_argb.h" 19 20#ifdef __cplusplus 21namespace libyuv { 22extern "C" { 23#endif 24 25LIBYUV_API 26void SetPlane(uint8* dst_y, int dst_stride_y, 27 int width, int height, 28 uint32 value); 29 30// Alias. 31#define I400ToI400 CopyPlane 32 33// Copy a plane of data (I420 to I400). 34LIBYUV_API 35void CopyPlane(const uint8* src_y, int src_stride_y, 36 uint8* dst_y, int dst_stride_y, 37 int width, int height); 38 39// Convert YUY2 to I422. 40LIBYUV_API 41int YUY2ToI422(const uint8* src_yuy2, int src_stride_yuy2, 42 uint8* dst_y, int dst_stride_y, 43 uint8* dst_u, int dst_stride_u, 44 uint8* dst_v, int dst_stride_v, 45 int width, int height); 46 47// Convert UYVY to I422. 48int UYVYToI422(const uint8* src_uyvy, int src_stride_uyvy, 49 uint8* dst_y, int dst_stride_y, 50 uint8* dst_u, int dst_stride_u, 51 uint8* dst_v, int dst_stride_v, 52 int width, int height); 53 54// Convert I420 to I400. (calls CopyPlane ignoring u/v). 55LIBYUV_API 56int I420ToI400(const uint8* src_y, int src_stride_y, 57 uint8* dst_y, int dst_stride_y, 58 uint8* dst_u, int dst_stride_u, 59 uint8* dst_v, int dst_stride_v, 60 int width, int height); 61 62// I420 mirror. 63LIBYUV_API 64int I420Mirror(const uint8* src_y, int src_stride_y, 65 const uint8* src_u, int src_stride_u, 66 const uint8* src_v, int src_stride_v, 67 uint8* dst_y, int dst_stride_y, 68 uint8* dst_u, int dst_stride_u, 69 uint8* dst_v, int dst_stride_v, 70 int width, int height); 71 72// ARGB mirror. 73LIBYUV_API 74int ARGBMirror(const uint8* src_argb, int src_stride_argb, 75 uint8* dst_argb, int dst_stride_argb, 76 int width, int height); 77 78// Convert NV12 to RGB565. 79LIBYUV_API 80int NV12ToRGB565(const uint8* src_y, int src_stride_y, 81 const uint8* src_uv, int src_stride_uv, 82 uint8* dst_rgb565, int dst_stride_rgb565, 83 int width, int height); 84 85// Convert NV21 to RGB565. 86LIBYUV_API 87int NV21ToRGB565(const uint8* src_y, int src_stride_y, 88 const uint8* src_uv, int src_stride_uv, 89 uint8* dst_rgb565, int dst_stride_rgb565, 90 int width, int height); 91 92// Aliases. 93#define ARGBToBGRA BGRAToARGB 94#define ARGBToABGR ABGRToARGB 95 96// Convert ARGB To RGBA. 97LIBYUV_API 98int ARGBToRGBA(const uint8* src_frame, int src_stride_frame, 99 uint8* dst_argb, int dst_stride_argb, 100 int width, int height); 101 102// Convert ARGB To RGB24. 103LIBYUV_API 104int ARGBToRGB24(const uint8* src_argb, int src_stride_argb, 105 uint8* dst_rgb24, int dst_stride_rgb24, 106 int width, int height); 107 108// Convert ARGB To RAW. 109LIBYUV_API 110int ARGBToRAW(const uint8* src_argb, int src_stride_argb, 111 uint8* dst_rgb, int dst_stride_rgb, 112 int width, int height); 113 114// Convert ARGB To RGB565. 115LIBYUV_API 116int ARGBToRGB565(const uint8* src_argb, int src_stride_argb, 117 uint8* dst_rgb565, int dst_stride_rgb565, 118 int width, int height); 119 120// Convert ARGB To ARGB1555. 121LIBYUV_API 122int ARGBToARGB1555(const uint8* src_argb, int src_stride_argb, 123 uint8* dst_argb1555, int dst_stride_argb1555, 124 int width, int height); 125 126// Convert ARGB To ARGB4444. 127LIBYUV_API 128int ARGBToARGB4444(const uint8* src_argb, int src_stride_argb, 129 uint8* dst_argb4444, int dst_stride_argb4444, 130 int width, int height); 131 132// Convert ARGB to I400. 133LIBYUV_API 134int ARGBToI400(const uint8* src_argb, int src_stride_argb, 135 uint8* dst_y, int dst_stride_y, 136 int width, int height); 137 138// ARGB little endian (bgra in memory) to I422. 139LIBYUV_API 140int ARGBToI422(const uint8* src_frame, int src_stride_frame, 141 uint8* dst_y, int dst_stride_y, 142 uint8* dst_u, int dst_stride_u, 143 uint8* dst_v, int dst_stride_v, 144 int width, int height); 145 146// I422ToARGB is in convert_argb.h 147// Convert I422 to BGRA. 148LIBYUV_API 149int I422ToBGRA(const uint8* src_y, int src_stride_y, 150 const uint8* src_u, int src_stride_u, 151 const uint8* src_v, int src_stride_v, 152 uint8* dst_bgra, int dst_stride_bgra, 153 int width, int height); 154 155// Convert I422 to ABGR. 156LIBYUV_API 157int I422ToABGR(const uint8* src_y, int src_stride_y, 158 const uint8* src_u, int src_stride_u, 159 const uint8* src_v, int src_stride_v, 160 uint8* dst_abgr, int dst_stride_abgr, 161 int width, int height); 162 163// Convert I422 to RGBA. 164LIBYUV_API 165int I422ToRGBA(const uint8* src_y, int src_stride_y, 166 const uint8* src_u, int src_stride_u, 167 const uint8* src_v, int src_stride_v, 168 uint8* dst_rgba, int dst_stride_rgba, 169 int width, int height); 170 171// Draw a rectangle into I420. 172LIBYUV_API 173int I420Rect(uint8* dst_y, int dst_stride_y, 174 uint8* dst_u, int dst_stride_u, 175 uint8* dst_v, int dst_stride_v, 176 int x, int y, int width, int height, 177 int value_y, int value_u, int value_v); 178 179// Draw a rectangle into ARGB. 180LIBYUV_API 181int ARGBRect(uint8* dst_argb, int dst_stride_argb, 182 int x, int y, int width, int height, uint32 value); 183 184// Convert ARGB to gray scale ARGB. 185LIBYUV_API 186int ARGBGrayTo(const uint8* src_argb, int src_stride_argb, 187 uint8* dst_argb, int dst_stride_argb, 188 int width, int height); 189 190// Make a rectangle of ARGB gray scale. 191LIBYUV_API 192int ARGBGray(uint8* dst_argb, int dst_stride_argb, 193 int x, int y, int width, int height); 194 195// Make a rectangle of ARGB Sepia tone. 196LIBYUV_API 197int ARGBSepia(uint8* dst_argb, int dst_stride_argb, 198 int x, int y, int width, int height); 199 200// Apply a matrix rotation to each ARGB pixel. 201// matrix_argb is 3 signed ARGB values. -128 to 127 representing -1 to 1. 202// The first 4 coefficients apply to B, G, R, A and produce B of the output. 203// The next 4 coefficients apply to B, G, R, A and produce G of the output. 204// The last 4 coefficients apply to B, G, R, A and produce R of the output. 205LIBYUV_API 206int ARGBColorMatrix(uint8* dst_argb, int dst_stride_argb, 207 const int8* matrix_argb, 208 int x, int y, int width, int height); 209 210// Apply a color table each ARGB pixel. 211// Table contains 256 ARGB values. 212LIBYUV_API 213int ARGBColorTable(uint8* dst_argb, int dst_stride_argb, 214 const uint8* table_argb, 215 int x, int y, int width, int height); 216 217// Quantize a rectangle of ARGB. Alpha unaffected. 218// scale is a 16 bit fractional fixed point scaler between 0 and 65535. 219// interval_size should be a value between 1 and 255. 220// interval_offset should be a value between 0 and 255. 221LIBYUV_API 222int ARGBQuantize(uint8* dst_argb, int dst_stride_argb, 223 int scale, int interval_size, int interval_offset, 224 int x, int y, int width, int height); 225 226// Copy ARGB to ARGB. 227LIBYUV_API 228int ARGBCopy(const uint8* src_argb, int src_stride_argb, 229 uint8* dst_argb, int dst_stride_argb, 230 int width, int height); 231 232typedef void (*ARGBBlendRow)(const uint8* src_argb0, const uint8* src_argb1, 233 uint8* dst_argb, int width); 234 235// Get function to Alpha Blend ARGB pixels and store to destination. 236LIBYUV_API 237ARGBBlendRow GetARGBBlend(); 238 239// Alpha Blend ARGB images and store to destination. 240// Alpha of destination is set to 255. 241LIBYUV_API 242int ARGBBlend(const uint8* src_argb0, int src_stride_argb0, 243 const uint8* src_argb1, int src_stride_argb1, 244 uint8* dst_argb, int dst_stride_argb, 245 int width, int height); 246 247// Convert I422 to YUY2. 248LIBYUV_API 249int I422ToYUY2(const uint8* src_y, int src_stride_y, 250 const uint8* src_u, int src_stride_u, 251 const uint8* src_v, int src_stride_v, 252 uint8* dst_frame, int dst_stride_frame, 253 int width, int height); 254 255// Convert I422 to UYVY. 256LIBYUV_API 257int I422ToUYVY(const uint8* src_y, int src_stride_y, 258 const uint8* src_u, int src_stride_u, 259 const uint8* src_v, int src_stride_v, 260 uint8* dst_frame, int dst_stride_frame, 261 int width, int height); 262 263// Convert unattentuated ARGB to preattenuated ARGB. 264LIBYUV_API 265int ARGBAttenuate(const uint8* src_argb, int src_stride_argb, 266 uint8* dst_argb, int dst_stride_argb, 267 int width, int height); 268 269// Convert preattentuated ARGB to unattenuated ARGB. 270LIBYUV_API 271int ARGBUnattenuate(const uint8* src_argb, int src_stride_argb, 272 uint8* dst_argb, int dst_stride_argb, 273 int width, int height); 274 275// Convert MJPG to ARGB. 276LIBYUV_API 277int MJPGToARGB(const uint8* sample, size_t sample_size, 278 uint8* argb, int argb_stride, 279 int w, int h, int dw, int dh); 280 281// Computes table of cumulative sum for image where the value is the sum 282// of all values above and to the left of the entry. Used by ARGBBlur. 283LIBYUV_API 284int ARGBComputeCumulativeSum(const uint8* src_argb, int src_stride_argb, 285 int32* dst_cumsum, int dst_stride32_cumsum, 286 int width, int height); 287 288// Blur ARGB image. 289// Caller should allocate dst_cumsum table of width * height * 16 bytes aligned 290// to 16 byte boundary. 291LIBYUV_API 292int ARGBBlur(const uint8* src_argb, int src_stride_argb, 293 uint8* dst_argb, int dst_stride_argb, 294 int32* dst_cumsum, int dst_stride32_cumsum, 295 int width, int height, int radius); 296 297// Multiply ARGB image by ARGB value. 298LIBYUV_API 299int ARGBShade(const uint8* src_argb, int src_stride_argb, 300 uint8* dst_argb, int dst_stride_argb, 301 int width, int height, uint32 value); 302 303// Interpolate between two ARGB images using specified amount of interpolation 304// (0 to 255) and store to destination. 305// 'interpolation' is specified as 8 bit fraction where 0 means 100% src_argb0 306// and 255 means 1% src_argb0 and 99% src_argb1. 307// Internally uses ARGBScale bilinear filtering. 308// Caveat: This function will write up to 16 bytes beyond the end of dst_argb. 309LIBYUV_API 310int ARGBInterpolate(const uint8* src_argb0, int src_stride_argb0, 311 const uint8* src_argb1, int src_stride_argb1, 312 uint8* dst_argb, int dst_stride_argb, 313 int width, int height, int interpolation); 314 315#if defined(__CLR_VER) || defined(COVERAGE_ENABLED) || \ 316 defined(TARGET_IPHONE_SIMULATOR) 317#define YUV_DISABLE_ASM 318#endif 319// Row functions for copying a pixels from a source with a slope to a row 320// of destination. Useful for scaling, rotation, mirror, texture mapping. 321LIBYUV_API 322void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride, 323 uint8* dst_argb, const float* uv_dudv, int width); 324// The following are available on all x86 platforms: 325#if !defined(YUV_DISABLE_ASM) && \ 326 (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)) 327LIBYUV_API 328void ARGBAffineRow_SSE2(const uint8* src_argb, int src_argb_stride, 329 uint8* dst_argb, const float* uv_dudv, int width); 330#define HAS_ARGBAFFINEROW_SSE2 331#endif 332 333#ifdef __cplusplus 334} // extern "C" 335} // namespace libyuv 336#endif 337 338#endif // INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ NOLINT 339