diff options
Diffstat (limited to 'files/include/libyuv')
-rw-r--r-- | files/include/libyuv/basic_types.h | 68 | ||||
-rw-r--r-- | files/include/libyuv/convert.h | 97 | ||||
-rw-r--r-- | files/include/libyuv/cpu_id.h | 35 | ||||
-rw-r--r-- | files/include/libyuv/format_conversion.h | 41 | ||||
-rw-r--r-- | files/include/libyuv/general.h | 47 | ||||
-rw-r--r-- | files/include/libyuv/planar_functions.h | 162 | ||||
-rw-r--r-- | files/include/libyuv/rotate.h | 52 | ||||
-rw-r--r-- | files/include/libyuv/scale.h | 67 |
8 files changed, 569 insertions, 0 deletions
diff --git a/files/include/libyuv/basic_types.h b/files/include/libyuv/basic_types.h new file mode 100644 index 00000000..5adc2bfd --- /dev/null +++ b/files/include/libyuv/basic_types.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ +#define INCLUDE_LIBYUV_BASIC_TYPES_H_ + +#include <stddef.h> // for NULL, size_t + +#ifndef WIN32 +#include <stdint.h> // for uintptr_t +#endif + +#ifndef INT_TYPES_DEFINED +#define INT_TYPES_DEFINED +#ifdef COMPILER_MSVC +typedef __int64 int64; +#else +typedef long long int64; +#endif /* COMPILER_MSVC */ +typedef int int32; +typedef short int16; +typedef char int8; + +#ifdef COMPILER_MSVC +typedef unsigned __int64 uint64; +typedef __int64 int64; +#ifndef INT64_C +#define INT64_C(x) x ## I64 +#endif +#ifndef UINT64_C +#define UINT64_C(x) x ## UI64 +#endif +#define INT64_F "I64" +#else +typedef unsigned long long uint64; +typedef long long int64; +#ifndef INT64_C +#define INT64_C(x) x ## LL +#endif +#ifndef UINT64_C +#define UINT64_C(x) x ## ULL +#endif +#define INT64_F "ll" +#endif /* COMPILER_MSVC */ +typedef unsigned int uint32; +typedef unsigned short uint16; +typedef unsigned char uint8; +#endif // INT_TYPES_DEFINED + +// Detect compiler is for x86 or x64. +#if defined(__x86_64__) || defined(_M_X64) || \ + defined(__i386__) || defined(_M_IX86) +#define CPU_X86 1 +#endif + +#define IS_ALIGNED(p, a) (0==(reinterpret_cast<uintptr_t>(p) & ((a)-1))) +#define ALIGNP(p, t) \ + (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \ + ((t)-1)) & ~((t)-1)))) + +#endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ diff --git a/files/include/libyuv/convert.h b/files/include/libyuv/convert.h new file mode 100644 index 00000000..fa3b6446 --- /dev/null +++ b/files/include/libyuv/convert.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + + +#ifndef INCLUDE_LIBYUV_CONVERT_H_ +#define INCLUDE_LIBYUV_CONVERT_H_ + +#include "libyuv/basic_types.h" + +namespace libyuv { + +int I420ToRGB24(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_frame, int dst_stride_frame, + int width, int height); + +int I420ToARGB4444(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_frame, int dst_stride_frame, + int width, int height); + +int I420ToRGB565(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_frame, int dst_stride_frame, + int width, int height); + +int I420ToARGB1555(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_frame, int dst_stride_frame, + int width, int height); + +int I420ToYUY2(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_frame, int dst_stride_frame, + int width, int height); + +int I420ToUYVY(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_frame, int dst_stride_frame, + int width, int height); + +// TODO(fbarchard): Deprecated - this is same as BG24ToARGB with -height +int RGB24ToARGB(const uint8* src_frame, int src_stride_frame, + uint8* dst_frame, int dst_stride_frame, + int width, int height); + +int RGB24ToI420(const uint8* src_frame, int src_stride_frame, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +int RAWToI420(const uint8* src_frame, int src_stride_frame, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +int ABGRToI420(const uint8* src_frame, int src_stride_frame, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +int BGRAToI420(const uint8* src_frame, int src_stride_frame, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +int ARGBToI420(const uint8* src_frame, int src_stride_frame, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +int NV12ToRGB565(const uint8* src_y, int src_stride_y, + const uint8* src_uv, int src_stride_uv, + uint8* dst_frame, int dst_stride_frame, + int width, int height); + +} // namespace libyuv + +#endif // INCLUDE_LIBYUV_CONVERT_H_ diff --git a/files/include/libyuv/cpu_id.h b/files/include/libyuv/cpu_id.h new file mode 100644 index 00000000..c1000e86 --- /dev/null +++ b/files/include/libyuv/cpu_id.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef INCLUDE_LIBYUV_CPU_ID_H_ +#define INCLUDE_LIBYUV_CPU_ID_H_ + +namespace libyuv { + +// These flags are only valid on x86 processors +static const int kCpuHasSSE2 = 1; +static const int kCpuHasSSSE3 = 2; + +// These flags are only valid on ARM processors +static const int kCpuHasNEON = 4; + +// Internal flag to indicate cpuid is initialized. +static const int kCpuInitialized = 8; + +// Detect CPU has SSE2 etc. +bool TestCpuFlag(int flag); + +// For testing, allow CPU flags to be disabled. +// ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. -1 to enable all. +void MaskCpuFlags(int enable_flags); + +} // namespace libyuv + +#endif // INCLUDE_LIBYUV_CPU_ID_H_ diff --git a/files/include/libyuv/format_conversion.h b/files/include/libyuv/format_conversion.h new file mode 100644 index 00000000..d3d36f38 --- /dev/null +++ b/files/include/libyuv/format_conversion.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + + +#ifndef INCLUDE_LIBYUV_FORMATCONVERSION_H_ +#define INCLUDE_LIBYUV_FORMATCONVERSION_H_ + +#include "libyuv/basic_types.h" + +namespace libyuv { + +// Converts any Bayer RGB format to I420. +int BayerRGBToI420(const uint8* src_bayer, int src_stride_bayer, + uint32 src_fourcc_bayer, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +// Converts any Bayer RGB format to ARGB. +int BayerRGBToARGB(const uint8* src_bayer, int src_stride_bayer, + uint32 src_fourcc_bayer, + uint8* dst_rgb, int dst_stride_rgb, + int width, int height); + +// Converts ARGB to any Bayer RGB format. +int ARGBToBayerRGB(const uint8* src_rgb, int src_stride_rgb, + uint8* dst_bayer, int dst_stride_bayer, + uint32 dst_fourcc_bayer, + int width, int height); + +} // namespace libyuv + +#endif // INCLUDE_LIBYUV_FORMATCONVERSION_H_ diff --git a/files/include/libyuv/general.h b/files/include/libyuv/general.h new file mode 100644 index 00000000..58943c86 --- /dev/null +++ b/files/include/libyuv/general.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + + +/* + * General operations on YUV images. + */ + +#ifndef INCLUDE_LIBYUV_GENERAL_H_ +#define INCLUDE_LIBYUV_GENERAL_H_ + +#include "libyuv/basic_types.h" + +namespace libyuv { + +// I420 mirror +int +I420Mirror(const uint8* src_yplane, int src_ystride, + const uint8* src_uplane, int src_ustride, + const uint8* src_vplane, int src_vstride, + uint8* dst_yplane, int dst_ystride, + uint8* dst_uplane, int dst_ustride, + uint8* dst_vplane, int dst_vstride, + int width, int height); + +// Crop/Pad I420 frame to match required dimensions. +int +I420CropPad(const uint8* src_frame, int src_width, + int src_height, uint8* dst_frame, + int dst_width, int dst_height); + +// I420 Crop - crop a rectangle from image +int +I420Crop(uint8* frame, + int src_width, int src_height, + int dst_width, int dst_height); + +} // namespace libyuv + +#endif // INCLUDE_LIBYUV_GENERAL_H_ diff --git a/files/include/libyuv/planar_functions.h b/files/include/libyuv/planar_functions.h new file mode 100644 index 00000000..9c0a10a3 --- /dev/null +++ b/files/include/libyuv/planar_functions.h @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + + +#ifndef INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ +#define INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ + +#include "libyuv/basic_types.h" + +namespace libyuv { + +// Copy I420 to I420. +int I420Copy(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +// Draw a rectangle into I420 +int I420Rect(uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int x, int y, + int width, int height, + int value_y, int value_u, int value_v); + +// Convert I422 to I420. Used by MJPG. +int I422ToI420(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +// Convert NV12 to I420. Also used for NV21. +int NV12ToI420(const uint8* src_y, int src_stride_y, + const uint8* src_uv, int src_stride_uv, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +// Convert NV12 to I420. Deprecated. +int NV12ToI420(const uint8* src_y, + const uint8* src_uv, int src_stride, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +// Convert Q420 to I420. +int Q420ToI420(const uint8* src_y, int src_stride_y, + const uint8* src_yuy2, int src_stride_yuy2, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +// Convert M420 to I420. +int M420ToI420(const uint8* src_m420, int src_stride_m420, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +// Convert YUY2 to I420. +int YUY2ToI420(const uint8* src_yuy2, int src_stride_yuy2, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +// Convert UYVY to I420. +int UYVYToI420(const uint8* src_uyvy, int src_stride_uyvy, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height); + +// Convert I420 to ARGB. +int I420ToARGB(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert I420 to BGRA. +int I420ToBGRA(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert I420 to ABGR. +int I420ToABGR(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert I422 to ARGB. +int I422ToARGB(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert I444 to ARGB. +int I444ToARGB(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert I400 to ARGB. +int I400ToARGB(const uint8* src_y, int src_stride_y, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert I400 to ARGB. Reverse of ARGBToI400 +int I400ToARGB_Reference(const uint8* src_y, int src_stride_y, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert RAW to ARGB. +int RAWToARGB(const uint8* src_raw, int src_stride_raw, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert BG24 to ARGB. +int BG24ToARGB(const uint8* src_bg24, int src_stride_bg24, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert ABGR to ARGB. Also used for ARGB to ABGR. +int ABGRToARGB(const uint8* src_abgr, int src_stride_abgr, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert BGRA to ARGB. Also used for ARGB to BGRA. +int BGRAToARGB(const uint8* src_bgra, int src_stride_bgra, + uint8* dst_argb, int dst_stride_argb, + int width, int height); + +// Convert ARGB to I400. +int ARGBToI400(const uint8* src_argb, int src_stride_argb, + uint8* dst_y, int dst_stride_y, + int width, int height); + +} // namespace libyuv + +#endif // INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ diff --git a/files/include/libyuv/rotate.h b/files/include/libyuv/rotate.h new file mode 100644 index 00000000..65c38de3 --- /dev/null +++ b/files/include/libyuv/rotate.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef INCLUDE_LIBYUV_ROTATE_H_ +#define INCLUDE_LIBYUV_ROTATE_H_ + +#include "libyuv/basic_types.h" + +namespace libyuv { + +// Supported rotation +enum RotationMode { + kRotate0 = 0, // No rotation + kRotate90 = 90, // Rotate 90 degrees clockwise + kRotate180 = 180, // Rotate 180 degrees + kRotate270 = 270, // Rotate 270 degrees clockwise + + // Deprecated + kRotateNone = 0, + kRotateClockwise = 90, + kRotateCounterClockwise = 270, +}; + +// Rotate I420 frame +int I420Rotate(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height, + RotationMode mode); + +// Rotate NV12 input and store in I420 +int NV12ToI420Rotate(const uint8* src_y, int src_stride_y, + const uint8* src_uv, int src_stride_uv, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height, + RotationMode mode); + +} // namespace libyuv + +#endif // INCLUDE_LIBYUV_ROTATE_H_ diff --git a/files/include/libyuv/scale.h b/files/include/libyuv/scale.h new file mode 100644 index 00000000..8433908b --- /dev/null +++ b/files/include/libyuv/scale.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef INCLUDE_LIBYUV_SCALE_H_ +#define INCLUDE_LIBYUV_SCALE_H_ + +#include "libyuv/basic_types.h" + +namespace libyuv { + +// Supported filtering +enum FilterMode { + kFilterNone = 0, // Point sample; Fastest + kFilterBilinear = 1, // Faster than box, but lower quality scaling down. + kFilterBox = 2 // Highest quality +}; + +// Scales a YUV 4:2:0 image from the src width and height to the +// dst width and height. +// If filtering is kFilterNone, a simple nearest-neighbor algorithm is +// used. This produces basic (blocky) quality at the fastest speed. +// If filtering is kFilterBilinear, interpolation is used to produce a better +// quality image, at the expense of speed. +// If filtering is kFilterBox, averaging is used to produce ever better +// quality image, at further expense of speed. +// Returns 0 if successful. + +int I420Scale(const uint8* src_y, int src_stride_y, + const uint8* src_u, int src_stride_u, + const uint8* src_v, int src_stride_v, + int src_width, int src_height, + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int dst_width, int dst_height, + FilterMode filtering); + +// Legacy API +// If dst_height_offset is non-zero, the image is offset by that many pixels +// and stretched to (dst_height - dst_height_offset * 2) pixels high, +// instead of dst_height. +int Scale(const uint8* src, int src_width, int src_height, + uint8* dst, int dst_width, int dst_height, int dst_height_offset, + bool interpolate); + +// Same, but specified src terms of each plane location and stride. +int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, + int src_stride_y, int src_stride_u, int src_stride_v, + int src_width, int src_height, + uint8* dst_y, uint8* dst_u, uint8* dst_v, + int dst_stride_y, int dst_stride_u, int dst_stride_v, + int dst_width, int dst_height, + bool interpolate); + +// For testing, allow disabling of optimizations. +void SetUseReferenceImpl(bool use); + +} // namespace libyuv + +#endif // INCLUDE_LIBYUV_SCALE_H_ |