Commit a1280730 authored by fbarchard@google.com's avatar fbarchard@google.com

cleanup yuv for consistency. stride, return int, negative heights, inplace…

cleanup yuv for consistency.  stride, return int, negative heights, inplace conversions, lower case names, filter enum, uint, planarfunction updates, remove common.h, remove common/ folder, cpuid header public, move headers into libyuv/, add libyuv.h, fixed header guards, remove internal timing from scale, tweaks for llvm build, videocommon simplified
BUG=none
TEST=Talk builds on all platforms against libyuv.
Review URL: http://webrtc-codereview.appspot.com/226003

git-svn-id: http://libyuv.googlecode.com/svn/trunk@31 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent ec9d86ca
......@@ -8,34 +8,16 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef LIBYUV_SOURCE_COMMON_H_
#define LIBYUV_SOURCE_COMMON_H_
#if defined(_MSC_VER)
// warning C4355: 'this' : used in base member initializer list
#pragma warning(disable:4355)
#endif
#ifndef LIBYUV_INCLUDE_LIBYUV_H_
#define LIBYUV_INCLUDE_LIBYUV_H_
#ifndef ENABLE_DEBUG
#define ENABLE_DEBUG _DEBUG
#endif // !defined(ENABLE_DEBUG)
#include "libyuv/basic_types.h"
#include "libyuv/convert.h"
#include "libyuv/cpu_id.h"
#include "libyuv/format_conversion.h"
#include "libyuv/general.h"
#include "libyuv/planar_functions.h"
#include "libyuv/scale.h"
#if ENABLE_DEBUG
#if defined(_MSC_VER) && _MSC_VER < 1300
#define __FUNCTION__ ""
#endif
#else // !ENABLE_DEBUG
#endif // !ENABLE_DEBUG
// Forces compiler to inline, even against its better judgement. Use wisely.
#if defined(__GNUC__)
#define FORCE_INLINE __attribute__((always_inline))
#elif defined(WIN32)
#define FORCE_INLINE __forceinline
#else
#define FORCE_INLINE
#endif
#endif // LIBYUV_SOURCE_COMMON_H_
#endif // LIBYUV_INCLUDE_LIBYUV_H_
......@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef LIBYUV_COMMON_BASIC_TYPES_H_
#define LIBYUV_COMMON_BASIC_TYPES_H_
#ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_
#define INCLUDE_LIBYUV_BASIC_TYPES_H_
#include <stddef.h> // for NULL, size_t
......@@ -17,11 +17,6 @@
#include <stdint.h> // for uintptr_t
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef INT_TYPES_DEFINED
#define INT_TYPES_DEFINED
#ifdef COMPILER_MSVC
......@@ -59,48 +54,15 @@ typedef unsigned short uint16;
typedef unsigned char uint8;
#endif // INT_TYPES_DEFINED
#ifdef WIN32
typedef int socklen_t;
#endif
namespace libyuv {
template<class T> inline T _min(T a, T b) { return (a > b) ? b : a; }
template<class T> inline T _max(T a, T b) { return (a < b) ? b : a; }
// For wait functions that take a number of milliseconds, kForever indicates
// unlimited time.
const int kForever = -1;
}
// Detect compiler is for x86 or x64.
#if defined(__x86_64__) || defined(_M_X64) || \
defined(__i386__) || defined(_M_IX86)
#define CPU_X86 1
#endif
#ifdef WIN32
#define alignof(t) __alignof(t)
#else // !WIN32
#define alignof(t) __alignof__(t)
#endif // !WIN32
#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))))
#ifndef UNUSED
#define UNUSED(x) Unused(static_cast<const void *>(&x))
#define UNUSED2(x,y) Unused(static_cast<const void *>(&x)); Unused(static_cast<const void *>(&y))
#define UNUSED3(x,y,z) Unused(static_cast<const void *>(&x)); Unused(static_cast<const void *>(&y)); Unused(static_cast<const void *>(&z))
#define UNUSED4(x,y,z,a) Unused(static_cast<const void *>(&x)); Unused(static_cast<const void *>(&y)); Unused(static_cast<const void *>(&z)); Unused(static_cast<const void *>(&a))
#define UNUSED5(x,y,z,a,b) Unused(static_cast<const void *>(&x)); Unused(static_cast<const void *>(&y)); Unused(static_cast<const void *>(&z)); Unused(static_cast<const void *>(&a)); Unused(static_cast<const void *>(&b))
inline void Unused(const void *) { }
#endif // UNUSED
#if defined(__GNUC__)
#define GCC_ATTR(x) __attribute__ ((x))
#else // !__GNUC__
#define GCC_ATTR(x)
#endif // !__GNUC__
#endif // LIBYUV_COMMON_BASIC_TYPES_H_
#endif // INCLUDE_LIBYUV_BASIC_TYPES_H_
......@@ -9,10 +9,10 @@
*/
#ifndef LIBYUV_INCLUDE_CONVERT_H_
#define LIBYUV_INCLUDE_CONVERT_H_
#ifndef INCLUDE_LIBYUV_CONVERT_H_
#define INCLUDE_LIBYUV_CONVERT_H_
#include "basic_types.h"
#include "libyuv/basic_types.h"
namespace libyuv {
......@@ -106,4 +106,4 @@ NV12ToRGB565(const uint8* src_yplane, int src_ystride,
} // namespace libyuv
#endif // LIBYUV_INCLUDE_CONVERT_H_
#endif // INCLUDE_LIBYUV_CONVERT_H_
......@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef LIBYUV_SOURCE_CPU_ID_H_
#define LIBYUV_SOURCE_CPU_ID_H_
#ifndef INCLUDE_LIBYUV_CPU_ID_H_
#define INCLUDE_LIBYUV_CPU_ID_H_
namespace libyuv {
......@@ -28,4 +28,4 @@ void MaskCpuFlagsForTest(int enable_flags);
} // namespace libyuv
#endif // LIBYUV_SOURCE_CPU_ID_H_
#endif // INCLUDE_LIBYUV_CPU_ID_H_
......@@ -9,33 +9,33 @@
*/
#ifndef LIBYUV_INCLUDE_FORMATCONVERSION_H_
#define LIBYUV_INCLUDE_FORMATCONVERSION_H_
#ifndef INCLUDE_LIBYUV_FORMATCONVERSION_H_
#define INCLUDE_LIBYUV_FORMATCONVERSION_H_
#include "basic_types.h"
#include "libyuv/basic_types.h"
namespace libyuv {
// Converts any Bayer RGB format to I420.
void BayerRGBToI420(const uint8* src_bayer, int src_pitch_bayer,
int BayerRGBToI420(const uint8* src_bayer, int src_stride_bayer,
uint32 src_fourcc_bayer,
uint8* dst_y, int dst_pitch_y,
uint8* dst_u, int dst_pitch_u,
uint8* dst_v, int dst_pitch_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);
// Converts any Bayer RGB format to ARGB.
void BayerRGBToARGB(const uint8* src_bayer, int src_pitch_bayer,
int BayerRGBToARGB(const uint8* src_bayer, int src_stride_bayer,
uint32 src_fourcc_bayer,
uint8* dst_rgb, int dst_pitch_rgb,
uint8* dst_rgb, int dst_stride_rgb,
int width, int height);
// Converts ARGB to any Bayer RGB format.
void ARGBToBayerRGB(const uint8* src_rgb, int src_pitch_rgb,
uint8* dst_bayer, int dst_pitch_bayer,
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 // LIBYUV_INCLUDE_FORMATCONVERSION_H_
#endif // INCLUDE_LIBYUV_FORMATCONVERSION_H_
......@@ -13,16 +13,15 @@
* General operations on YUV images.
*/
#ifndef LIBYUV_INCLUDE_GENERAL_H_
#define LIBYUV_INCLUDE_GENERAL_H_
#ifndef INCLUDE_LIBYUV_GENERAL_H_
#define INCLUDE_LIBYUV_GENERAL_H_
#include "basic_types.h"
#include "libyuv/basic_types.h"
namespace libyuv {
// Supported rotation
enum RotationMode
{
enum RotationMode {
kRotateNone = 0,
kRotateClockwise = 90,
kRotateCounterClockwise = 270,
......@@ -45,7 +44,7 @@ I420CropPad(const uint8* src_frame, int src_width,
int src_height, uint8* dst_frame,
int dst_width, int dst_height);
// I420 Crop - make a center cut
// I420 Crop - crop a rectangle from image
int
I420Crop(uint8* frame,
int src_width, int src_height,
......@@ -62,8 +61,6 @@ I420Rotate(const uint8* src_yplane, int src_ystride,
int width, int height,
RotationMode mode);
} // namespace libyuv
#endif // LIBYUV_INCLUDE_GENERAL_H_
#endif // INCLUDE_LIBYUV_GENERAL_H_
/*
* 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);
// 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 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 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 NV12 to I420. Also used for NV21.
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 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.
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.
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.
int BGRAToARGB(const uint8* src_bgra, int src_stride_bgra,
uint8* dst_argb, int dst_stride_argb,
int width, int height);
} // namespace libyuv
#endif // INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_
/*
* 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_
/*
* 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 LIBYUV_INCLUDE_PLANAR_FUNCTIONS_H_
#define LIBYUV_INCLUDE_PLANAR_FUNCTIONS_H_
#include "basic_types.h"
namespace libyuv {
// Copy I420 to I420.
void I420Copy(const uint8* src_y, int src_pitch_y,
const uint8* src_u, int src_pitch_u,
const uint8* src_v, int src_pitch_v,
uint8* dst_y, int dst_pitch_y,
uint8* dst_u, int dst_pitch_u,
uint8* dst_v, int dst_pitch_v,
int width, int height);
// Convert I422 to I420. Used by MJPG.
void I422ToI420(const uint8* src_y, int src_pitch_y,
const uint8* src_u, int src_pitch_u,
const uint8* src_v, int src_pitch_v,
uint8* dst_y, int dst_pitch_y,
uint8* dst_u, int dst_pitch_u,
uint8* dst_v, int dst_pitch_v,
int width, int height);
// Convert M420 to I420.
void M420ToI420(const uint8* src_m420, int src_pitch_m420,
uint8* dst_y, int dst_pitch_y,
uint8* dst_u, int dst_pitch_u,
uint8* dst_v, int dst_pitch_v,
int width, int height);
// Convert Q420 to I420.
void Q420ToI420(const uint8* src_y, int src_pitch_y,
const uint8* src_yuy2, int src_pitch_yuy2,
uint8* dst_y, int dst_pitch_y,
uint8* dst_u, int dst_pitch_u,
uint8* dst_v, int dst_pitch_v,
int width, int height);
// Convert NV12 to I420. Also used for NV21.
void NV12ToI420(const uint8* src_y,
const uint8* src_uv, int src_pitch,
uint8* dst_y, int dst_pitch_y,
uint8* dst_u, int dst_pitch_u,
uint8* dst_v, int dst_pitch_v,
int width, int height);
// Convert YUY2 to I420.
void YUY2ToI420(const uint8* src_yuy2, int src_pitch_yuy2,
uint8* dst_y, int dst_pitch_y,
uint8* dst_u, int dst_pitch_u,
uint8* dst_v, int dst_pitch_v,
int width, int height);
// Convert UYVY to I420.
void UYVYToI420(const uint8* src_uyvy, int src_pitch_uyvy,
uint8* dst_y, int dst_pitch_y,
uint8* dst_u, int dst_pitch_u,
uint8* dst_v, int dst_pitch_v,
int width, int height);
// Convert I420 to ARGB.
void I420ToARGB(const uint8* src_y, int src_pitch_y,
const uint8* src_u, int src_pitch_u,
const uint8* src_v, int src_pitch_v,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
// Convert I420 to BGRA.
void I420ToBGRA(const uint8* src_y, int src_pitch_y,
const uint8* src_u, int src_pitch_u,
const uint8* src_v, int src_pitch_v,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
// Convert I420 to ABGR.
void I420ToABGR(const uint8* src_y, int src_pitch_y,
const uint8* src_u, int src_pitch_u,
const uint8* src_v, int src_pitch_v,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
// Convert I422 to ARGB.
void I422ToARGB(const uint8* src_y, int src_pitch_y,
const uint8* src_u, int src_pitch_u,
const uint8* src_v, int src_pitch_v,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
// Convert I444 to ARGB.
void I444ToARGB(const uint8* src_y, int src_pitch_y,
const uint8* src_u, int src_pitch_u,
const uint8* src_v, int src_pitch_v,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
// Convert I400 to ARGB.
void I400ToARGB(const uint8* src_y, int src_pitch_y,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
// Convert I400 to ARGB.
void I400ToARGB_Reference(const uint8* src_y, int src_pitch_y,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
// Convert RAW to ARGB.
void RAWToARGB(const uint8* src_raw, int src_pitch_raw,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
// Convert BG24 to ARGB.
void BG24ToARGB(const uint8* src_bg24, int src_pitch_bg24,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
// Convert ABGR to ARGB.
void ABGRToARGB(const uint8* src_abgr, int src_pitch_abgr,
uint8* dst_argb, int dst_pitch_argb,
int width, int height);
} // namespace libyuv
#endif // LIBYUV_INCLUDE_PLANAR_FUNCTIONS_H_
/*
* 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 LIBYUV_INCLUDE_SCALE_H_
#define LIBYUV_INCLUDE_SCALE_H_
#include "basic_types.h"
#if defined(_MSC_VER)
#define ALIGN16(var) __declspec(align(16)) var
#else
#define ALIGN16(var) var __attribute__((aligned(16)))
#endif
namespace libyuv {
// Scales a YUV 4:2:0 image from the input width and height to the
// output width and height. If outh_offset is nonzero, the image is
// offset by that many pixels and stretched to (outh - outh_offset * 2)
// pixels high, instead of outh.
// If interpolate is not set, a simple nearest-neighbor algorithm is
// used. This produces basic (blocky) quality at the fastest speed.
// If interpolate is set, interpolation is used to produce a better
// quality image, at the expense of speed.
// Returns true if successful.
bool Scale(const uint8 *in, int32 inw, int32 inh,
uint8 *out, int32 outw, int32 outh, int32 outh_offset,
bool interpolate);
// Same, but specified in terms of each plane location and stride.
bool Scale(const uint8 *inY, const uint8 *inU, const uint8 *inV,
int32 istrideY, int32 istrideU, int32 istrideV,
int32 iwidth, int32 iheight,
uint8 *outY, uint8 *outU, uint8 *outV,
int32 ostrideY, int32 ostrideU, int32 ostrideV,
int32 owidth, int32 oheight,
bool interpolate);
// For testing, allow disabling of optimizations.
void SetUseReferenceImpl(bool use);
} // namespace libyuv
#endif // LIBYUV_INCLUDE_SCALE_H_
......@@ -15,11 +15,11 @@
*
***************************************************************/
#ifndef WEBRTC_COMMON_VIDEO_VPLIB_CONVERSION_TABLES
#define WEBRTC_COMMON_VIDEO_VPLIB_CONVERSION_TABLES
#ifndef LIBYUV_SOURCE_CONVERSION_TABLES_H_
#define LIBYUV_SOURCE_CONVERSION_TABLES_H_
namespace libyuv {
namespace libyuv
{
/******************************************************************************
* YUV TO RGB approximation
*
......@@ -97,7 +97,6 @@ namespace libyuv
Ucg(244),Ucg(245),Ucg(246),Ucg(247),Ucg(248),Ucg(249),Ucg(250),Ucg(251),
Ucg(252),Ucg(253),Ucg(254),Ucg(255)};
static const int mapUcb[256] = {
Ucb(0),Ucb(1),Ucb(2),Ucb(3),Ucb(4),Ucb(5),Ucb(6),Ucb(7),Ucb(8),Ucb(9),
Ucb(10),Ucb(11),Ucb(12),Ucb(13),Ucb(14),Ucb(15),Ucb(16),Ucb(17),Ucb(18),
......@@ -199,5 +198,6 @@ namespace libyuv
Vcg(252),Vcg(253),Vcg(254),Vcg(255)};
} // namespace libyuv
#endif
......@@ -8,13 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "libyuv/convert.h"
#include "convert.h"
#include "basic_types.h"
#include <string.h> // memcpy(), memset()
#include <assert.h>
#include <stdlib.h> // abs
#include "libyuv/basic_types.h"
#include "conversion_tables.h"
//#define SCALEOPT //Currently for windows only. June 2010
......@@ -22,20 +19,16 @@
#include <emmintrin.h>
#endif
#include "conversion_tables.h"
namespace libyuv
{
// Clip value to [0,255]
inline uint8 Clip(int32 val);
#ifdef SCALEOPT
void *memcpy_16(void * dest, const void * src, size_t n);
void *memcpy_8(void * dest, const void * src, size_t n);
#endif
namespace libyuv {
static inline uint8 Clip(int32 val) {
if (val < 0) {
return (uint8) 0;
} else if (val > 255){
return (uint8) 255;
}
return (uint8) val;
}
int
I420ToRGB24(const uint8* src_yplane, int src_ystride,
......@@ -344,8 +337,8 @@ I420ToYUY2(const uint8* src_yplane, int src_ystride,
const uint8* in1 = src_yplane;
const uint8* in2 = src_yplane + src_ystride ;
const uint8* inU = src_uplane;
const uint8* inV = src_vplane;
const uint8* src_u = src_uplane;
const uint8* src_v = src_vplane;
uint8* out1 = dst_frame;
uint8* out2 = dst_frame + 2 * dst_stride;
......@@ -356,25 +349,25 @@ I420ToYUY2(const uint8* src_yplane, int src_ystride,
for (int i = 0; i < ((src_height + 1) >> 1); i++){
for (int j = 0; j < ((src_width + 1) >> 1); j++){
out1[0] = in1[0];
out1[1] = *inU;
out1[1] = *src_u;
out1[2] = in1[1];
out1[3] = *inV;
out1[3] = *src_v;
out2[0] = in2[0];
out2[1] = *inU;
out2[1] = *src_u;
out2[2] = in2[1];
out2[3] = *inV;
out2[3] = *src_v;
out1 += 4;
out2 += 4;
inU++;
inV++;
src_u++;
src_v++;
in1 += 2;
in2 += 2;
}
in1 += 2 * src_ystride - src_width;
in2 += 2 * src_ystride - src_width;
inU += src_ustride - ((src_width + 1) >> 1);
inV += src_vstride - ((src_width + 1) >> 1);
src_u += src_ustride - ((src_width + 1) >> 1);
src_v += src_vstride - ((src_width + 1) >> 1);
out1 += 2 * dst_stride + 2 * (dst_stride - src_width);
out2 += 2 * dst_stride + 2 * (dst_stride - src_width);
}
......@@ -387,34 +380,34 @@ I420ToYUY2(const uint8* src_yplane, int src_ystride,
;pusha
mov eax, DWORD PTR [in1] ;1939.33
mov ecx, DWORD PTR [in2] ;1939.33
mov ebx, DWORD PTR [inU] ;1939.33
mov edx, DWORD PTR [inV] ;1939.33
mov ebx, DWORD PTR [src_u] ;1939.33
mov edx, DWORD PTR [src_v] ;1939.33
loop0:
movq xmm6, QWORD PTR [ebx] ;inU
movq xmm0, QWORD PTR [edx] ;inV
punpcklbw xmm6, xmm0 ;inU, inV mix
movq xmm6, QWORD PTR [ebx] ;src_u
movq xmm0, QWORD PTR [edx] ;src_v
punpcklbw xmm6, xmm0 ;src_u, src_v mix
;movdqa xmm1, xmm6
;movdqa xmm2, xmm6
;movdqa xmm4, xmm6
movdqu xmm3, XMMWORD PTR [eax] ;in1
movdqa xmm1, xmm3
punpcklbw xmm1, xmm6 ;in1, inU, in1, inV
punpcklbw xmm1, xmm6 ;in1, src_u, in1, src_v
mov esi, DWORD PTR [out1]
movdqu XMMWORD PTR [esi], xmm1 ;write to out1
movdqu xmm5, XMMWORD PTR [ecx] ;in2
movdqa xmm2, xmm5
punpcklbw xmm2, xmm6 ;in2, inU, in2, inV
punpcklbw xmm2, xmm6 ;in2, src_u, in2, src_v
mov edi, DWORD PTR [out2]
movdqu XMMWORD PTR [edi], xmm2 ;write to out2
punpckhbw xmm3, xmm6 ;in1, inU, in1, inV again
punpckhbw xmm3, xmm6 ;in1, src_u, in1, src_v again
movdqu XMMWORD PTR [esi+16], xmm3 ;write to out1 again
add esi, 32
mov DWORD PTR [out1], esi
punpckhbw xmm5, xmm6 ;inU, in2, inV again
punpckhbw xmm5, xmm6 ;src_u, in2, src_v again
movdqu XMMWORD PTR [edi+16], xmm5 ;write to out2 again
add edi, 32
mov DWORD PTR [out2], edi
......@@ -431,8 +424,8 @@ I420ToYUY2(const uint8* src_yplane, int src_ystride,
mov DWORD PTR [in1], eax ;1939.33
mov DWORD PTR [in2], ecx ;1939.33
mov DWORD PTR [inU], ebx ;1939.33
mov DWORD PTR [inV], edx ;1939.33
mov DWORD PTR [src_u], ebx ;1939.33
mov DWORD PTR [src_v], edx ;1939.33
;popa
emms
......@@ -504,32 +497,32 @@ I420ToUYVY(const uint8* src_yplane, int src_ystride,
;pusha
mov eax, DWORD PTR [in1] ;1939.33
mov ecx, DWORD PTR [in2] ;1939.33
mov ebx, DWORD PTR [inU] ;1939.33
mov edx, DWORD PTR [inV] ;1939.33
mov ebx, DWORD PTR [src_u] ;1939.33
mov edx, DWORD PTR [src_v] ;1939.33
loop0:
movq xmm6, QWORD PTR [ebx] ;inU
movq xmm0, QWORD PTR [edx] ;inV
punpcklbw xmm6, xmm0 ;inU, inV mix
movq xmm6, QWORD PTR [ebx] ;src_u
movq xmm0, QWORD PTR [edx] ;src_v
punpcklbw xmm6, xmm0 ;src_u, src_v mix
movdqa xmm1, xmm6
movdqa xmm2, xmm6
movdqa xmm4, xmm6
movdqu xmm3, XMMWORD PTR [eax] ;in1
punpcklbw xmm1, xmm3 ;inU, in1, inV
punpcklbw xmm1, xmm3 ;src_u, in1, src_v
mov esi, DWORD PTR [out1]
movdqu XMMWORD PTR [esi], xmm1 ;write to out1
movdqu xmm5, XMMWORD PTR [ecx] ;in2
punpcklbw xmm2, xmm5 ;inU, in2, inV
punpcklbw xmm2, xmm5 ;src_u, in2, src_v
mov edi, DWORD PTR [out2]
movdqu XMMWORD PTR [edi], xmm2 ;write to out2
punpckhbw xmm4, xmm3 ;inU, in1, inV again
punpckhbw xmm4, xmm3 ;src_u, in1, src_v again
movdqu XMMWORD PTR [esi+16], xmm4 ;write to out1 again
add esi, 32
mov DWORD PTR [out1], esi
punpckhbw xmm6, xmm5 ;inU, in2, inV again
punpckhbw xmm6, xmm5 ;src_u, in2, src_v again
movdqu XMMWORD PTR [edi+16], xmm6 ;write to out2 again
add edi, 32
mov DWORD PTR [out2], edi
......@@ -546,8 +539,8 @@ loop0:
mov DWORD PTR [in1], eax ;1939.33
mov DWORD PTR [in2], ecx ;1939.33
mov DWORD PTR [inU], ebx ;1939.33
mov DWORD PTR [inV], edx ;1939.33
mov DWORD PTR [src_u], ebx ;1939.33
mov DWORD PTR [src_v], edx ;1939.33
;popa
emms
......@@ -848,62 +841,4 @@ RAWToI420(const uint8* src_frame, int src_stride,
src_width, src_height, RAWToI420Row_C);
}
inline
uint8 Clip(int32 val)
{
if (val < 0){
return (uint8)0;
} else if (val > 255){
return (uint8)255;
}
return (uint8)val;
}
#ifdef SCALEOPT
//memcpy_16 assumes that width is an integer multiple of 16!
void
*memcpy_16(void * dest, const void * src, size_t n)
{
_asm
{
mov eax, dword ptr [src]
mov ebx, dword ptr [dest]
mov ecx, dword ptr [n]
loop0:
movdqu xmm0, XMMWORD PTR [eax]
movdqu XMMWORD PTR [ebx], xmm0
add eax, 16
add ebx, 16
sub ecx, 16
jg loop0
}
}
// memcpy_8 assumes that width is an integer multiple of 8!
void
*memcpy_8(void * dest, const void * src, size_t n)
{
_asm
{
mov eax, dword ptr [src]
mov ebx, dword ptr [dest]
mov ecx, dword ptr [n]
loop0:
movq mm0, QWORD PTR [eax]
movq QWORD PTR [ebx], mm0
add eax, 8
add ebx, 8
sub ecx, 8
jg loop0
emms
}
}
#endif
} // namespace libyuv
......@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "cpu_id.h"
#include "basic_types.h" // for CPU_X86
#include "libyuv/cpu_id.h"
#include "libyuv/basic_types.h" // for CPU_X86
#ifdef _MSC_VER
#include <intrin.h>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -19,31 +19,31 @@ typedef void (*rotate_wxhfunc)(const uint8*, int, uint8*, int, int, int);
#ifdef __ARM_NEON__
extern "C" {
void ReverseLine_NEON(const uint8* src, uint8* dst, int width);
void Transpose_wx8_NEON(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch, int width);
void Transpose_wx8_NEON(const uint8* src, int src_stride,
uint8* dst, int dst_stride, int width);
} // extern "C"
#endif
static void Transpose_wx8_C(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
static void Transpose_wx8_C(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int w) {
int i, j;
for (i = 0; i < w; ++i)
for (j = 0; j < 8; ++j)
dst[i * dst_pitch + j] = src[j * src_pitch + i];
dst[i * dst_stride + j] = src[j * src_stride + i];
}
static void Transpose_wxh_C(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
static void Transpose_wxh_C(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int width, int height) {
int i, j;
for (i = 0; i < width; ++i)
for (j = 0; j < height; ++j)
dst[i * dst_pitch + j] = src[j * src_pitch + i];
dst[i * dst_stride + j] = src[j * src_stride + i];
}
void Transpose(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
void Transpose(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int width, int height) {
int i = height;
rotate_wx8func Transpose_wx8;
......@@ -60,33 +60,33 @@ void Transpose(const uint8* src, int src_pitch,
// work across the source in 8x8 tiles
do {
Transpose_wx8(src, src_pitch, dst, dst_pitch, width);
Transpose_wx8(src, src_stride, dst, dst_stride, width);
src += 8 * src_pitch;
src += 8 * src_stride;
dst += 8;
i -= 8;
} while (i >= 8);
// TODO(frkoenig): Have wx4 and maybe wx2
Transpose_wxh(src, src_pitch, dst, dst_pitch, width, i);
Transpose_wxh(src, src_stride, dst, dst_stride, width, i);
}
void Rotate90(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
void Rotate90(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int width, int height) {
src += src_pitch*(height-1);
src_pitch = -src_pitch;
src += src_stride*(height-1);
src_stride = -src_stride;
Transpose(src, src_pitch, dst, dst_pitch, width, height);
Transpose(src, src_stride, dst, dst_stride, width, height);
}
void Rotate270(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
void Rotate270(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int width, int height) {
dst += dst_pitch*(width-1);
dst_pitch = -dst_pitch;
dst += dst_stride*(width-1);
dst_stride = -dst_stride;
Transpose(src, src_pitch, dst, dst_pitch, width, height);
Transpose(src, src_stride, dst, dst_stride, width, height);
}
void ReverseLine_C(const uint8* src, uint8* dst, int width) {
......@@ -95,8 +95,8 @@ void ReverseLine_C(const uint8* src, uint8* dst, int width) {
dst[width-1 - i] = src[i];
}
void Rotate180(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
void Rotate180(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int width, int height) {
int i;
reverse_func ReverseLine;
......@@ -108,13 +108,13 @@ void Rotate180(const uint8* src, int src_pitch,
ReverseLine = ReverseLine_C;
#endif
dst += dst_pitch*(height-1);
dst += dst_stride*(height-1);
for (i = 0; i < height; ++i) {
ReverseLine(src, dst, width);
src += src_pitch;
dst -= dst_pitch;
src += src_stride;
dst -= dst_stride;
}
}
......
......@@ -11,34 +11,35 @@
#ifndef LIBYUV_SOURCE_ROTATE_H_
#define LIBYUV_SOURCE_ROTATE_H_
#include "basic_types.h"
#include "libyuv/basic_types.h"
namespace libyuv {
void Rotate90(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
void Rotate90(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int width, int height);
void Rotate180(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
void Rotate180(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int width, int height);
void Rotate270(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
void Rotate270(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int width, int height);
void Rotate90_deinterleave(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
void Rotate90_deinterleave(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int width, int height);
void Rotate180_deinterleave(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
void Rotate180_deinterleave(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int width, int height);
void Rotate270_deinterleave(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
void Rotate270_deinterleave(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int width, int height);
void Transpose(const uint8* src, int src_pitch,
uint8* dst, int dst_pitch,
void Transpose(const uint8* src, int src_stride,
uint8* dst, int dst_stride,
int width, int height);
} // namespace libyuv
......
......@@ -27,40 +27,40 @@ void ReverseLine_di_NEON(const uint8* src,
uint8* dst_a, uint8* dst_b,
int width);
void SaveRegisters_NEON(unsigned long long *store);
void Transpose_di_wx8_NEON(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
void Transpose_di_wx8_NEON(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int width);
} // extern "C"
#endif
static void Transpose_di_wx8_C(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
static void Transpose_di_wx8_C(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int w) {
int i, j;
for (i = 0; i < w*2; i += 2)
for (j = 0; j < 8; ++j) {
dst_a[j + (i>>1)*dst_pitch_a] = src[i + j*src_pitch];
dst_b[j + (i>>1)*dst_pitch_b] = src[i + j*src_pitch + 1];
dst_a[j + (i>>1)*dst_stride_a] = src[i + j*src_stride];
dst_b[j + (i>>1)*dst_stride_b] = src[i + j*src_stride + 1];
}
}
static void Transpose_di_wxh_C(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
static void Transpose_di_wxh_C(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int w, int h) {
int i, j;
for (i = 0; i < w*2; i += 2)
for (j = 0; j < h; ++j) {
dst_a[j + (i>>1)*dst_pitch_a] = src[i + j*src_pitch];
dst_b[j + (i>>1)*dst_pitch_b] = src[i + j*src_pitch + 1];
dst_a[j + (i>>1)*dst_stride_a] = src[i + j*src_stride];
dst_b[j + (i>>1)*dst_stride_b] = src[i + j*src_stride + 1];
}
}
void Transpose_deinterleave(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
void Transpose_deinterleave(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int width, int height) {
int i = height;
rotate_wx8func Transpose_wx8;
......@@ -81,20 +81,20 @@ void Transpose_deinterleave(const uint8* src, int src_pitch,
// work across the source in 8x8 tiles
do {
Transpose_wx8(src, src_pitch,
dst_a, dst_pitch_a,
dst_b, dst_pitch_b,
Transpose_wx8(src, src_stride,
dst_a, dst_stride_a,
dst_b, dst_stride_b,
width);
src += 8 * src_pitch;
src += 8 * src_stride;
dst_a += 8;
dst_b += 8;
i -= 8;
} while (i >= 8);
Transpose_wxh(src, src_pitch,
dst_a, dst_pitch_a,
dst_b, dst_pitch_b,
Transpose_wxh(src, src_stride,
dst_a, dst_stride_a,
dst_b, dst_stride_b,
width, i);
#ifdef __ARM_NEON__
......@@ -102,31 +102,31 @@ void Transpose_deinterleave(const uint8* src, int src_pitch,
#endif
}
void Rotate90_deinterleave(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
void Rotate90_deinterleave(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int width, int height) {
src += src_pitch*(height-1);
src_pitch = -src_pitch;
src += src_stride*(height-1);
src_stride = -src_stride;
Transpose_deinterleave(src, src_pitch,
dst_a, dst_pitch_a,
dst_b, dst_pitch_b,
Transpose_deinterleave(src, src_stride,
dst_a, dst_stride_a,
dst_b, dst_stride_b,
width, height);
}
void Rotate270_deinterleave(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
void Rotate270_deinterleave(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int width, int height) {
dst_a += dst_pitch_a*((width>>1)-1);
dst_b += dst_pitch_b*((width>>1)-1);
dst_pitch_a = -dst_pitch_a;
dst_pitch_b = -dst_pitch_b;
Transpose_deinterleave(src, src_pitch,
dst_a, dst_pitch_a,
dst_b, dst_pitch_b,
dst_a += dst_stride_a*((width>>1)-1);
dst_b += dst_stride_b*((width>>1)-1);
dst_stride_a = -dst_stride_a;
dst_stride_b = -dst_stride_b;
Transpose_deinterleave(src, src_stride,
dst_a, dst_stride_a,
dst_b, dst_stride_b,
width, height);
}
......@@ -140,9 +140,9 @@ static void ReverseLine_di_C(const uint8* src,
}
}
void Rotate180_deinterleave(const uint8* src, int src_pitch,
uint8* dst_a, int dst_pitch_a,
uint8* dst_b, int dst_pitch_b,
void Rotate180_deinterleave(const uint8* src, int src_stride,
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b,
int width, int height) {
int i;
reverse_func ReverseLine;
......@@ -154,17 +154,17 @@ void Rotate180_deinterleave(const uint8* src, int src_pitch,
ReverseLine = ReverseLine_di_C;
#endif
dst_a += dst_pitch_a*(height-1);
dst_b += dst_pitch_b*(height-1);
dst_a += dst_stride_a*(height-1);
dst_b += dst_stride_b*(height-1);
width >>= 1;
for (i = 0; i < height; ++i) {
ReverseLine(src, dst_a, dst_b, width);
src += src_pitch;
dst_a -= dst_pitch_a;
dst_b -= dst_pitch_b;
src += src_stride;
dst_a -= dst_stride_a;
dst_b -= dst_stride_b;
}
}
......
......@@ -11,7 +11,7 @@
#ifndef LIBYUV_SOURCE_ROW_H_
#define LIBYUV_SOURCE_ROW_H_
#include "basic_types.h"
#include "libyuv/basic_types.h"
extern "C" {
void FastConvertYUVToRGB32Row(const uint8* y_buf,
......
This diff is collapsed.
......@@ -13,8 +13,6 @@
#include <sstream>
#include "common.h"
namespace libyuv {
#define ARRAY_SIZE(x) (static_cast<int>((sizeof(x)/sizeof(x[0]))))
......@@ -47,20 +45,4 @@ uint32 CanonicalFourCC(uint32 fourcc) {
return fourcc;
}
std::string VideoFormat::ToString() const {
std::string fourcc_name = GetFourccName(fourcc) + " ";
for (std::string::const_iterator i = fourcc_name.begin();
i < fourcc_name.end(); ++i) {
// Test character is printable; Avoid isprint() which asserts on negatives
if (*i < 32 || *i >= 127) {
fourcc_name = "";
break;
}
}
std::ostringstream ss;
ss << fourcc_name << width << "x" << height << "x" << IntervalToFps(interval);
return ss.str();
}
} // namespace libyuv
......@@ -18,7 +18,7 @@
#include <string>
#include "basic_types.h"
#include "libyuv/basic_types.h"
namespace libyuv {
......@@ -32,16 +32,6 @@ namespace libyuv {
(static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \
(static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24))
// Get the name, that is, string with four characters, of a fourcc code.
inline std::string GetFourccName(uint32 fourcc) {
std::string name;
name.push_back(static_cast<char>(fourcc & 0xFF));
name.push_back(static_cast<char>((fourcc >> 8) & 0xFF));
name.push_back(static_cast<char>((fourcc >> 16) & 0xFF));
name.push_back(static_cast<char>((fourcc >> 24) & 0xFF));
return name;
}
// Some good pages discussing FourCC codes:
// http://developer.apple.com/quicktime/icefloe/dispatch020.html
// http://www.fourcc.org/yuv.php
......@@ -87,88 +77,6 @@ enum FourCC {
// Converts fourcc aliases into canonical ones.
uint32 CanonicalFourCC(uint32 fourcc);
//////////////////////////////////////////////////////////////////////////////
// Definition of VideoFormat.
//////////////////////////////////////////////////////////////////////////////
static const int64 kNumNanosecsPerSec = 1000000000;
struct VideoFormat {
static const int64 kMinimumInterval = kNumNanosecsPerSec / 10000; // 10k fps
VideoFormat() : width(0), height(0), interval(0), fourcc(0) {}
VideoFormat(int w, int h, int64 interval_ns, uint32 cc)
: width(w),
height(h),
interval(interval_ns),
fourcc(cc) {
}
VideoFormat(const VideoFormat& format)
: width(format.width),
height(format.height),
interval(format.interval),
fourcc(format.fourcc) {
}
static int64 FpsToInterval(int fps) {
return fps ? kNumNanosecsPerSec / fps : kMinimumInterval;
}
static int IntervalToFps(int64 interval) {
// Normalize the interval first.
interval = libyuv::_max(interval, kMinimumInterval);
return static_cast<int>(kNumNanosecsPerSec / interval);
}
bool operator==(const VideoFormat& format) const {
return width == format.width && height == format.height &&
interval == format.interval && fourcc == format.fourcc;
}
bool operator!=(const VideoFormat& format) const {
return !(*this == format);
}
bool operator<(const VideoFormat& format) const {
return (fourcc < format.fourcc) ||
(fourcc == format.fourcc && width < format.width) ||
(fourcc == format.fourcc && width == format.width &&
height < format.height) ||
(fourcc == format.fourcc && width == format.width &&
height == format.height && interval > format.interval);
}
int framerate() const { return IntervalToFps(interval); }
// Check if both width and height are 0.
bool IsSize0x0() const { return 0 == width && 0 == height; }
// Check if this format is less than another one by comparing the resolution
// and frame rate.
bool IsPixelRateLess(const VideoFormat& format) const {
return width * height * framerate() <
format.width * format.height * format.framerate();
}
// Get a string presentation in the form of "fourcc width x height x fps"
std::string ToString() const;
int width; // in number of pixels
int height; // in number of pixels
int64 interval; // in nanoseconds
uint32 fourcc; // color space. FOURCC_ANY means that any color space is OK.
};
// Result of video capturer start.
enum CaptureResult {
CR_SUCCESS, // The capturer starts successfully.
CR_PENDING, // The capturer is pending to start the capture device.
CR_FAILURE, // The capturer fails to start.
CR_NO_DEVICE, // The capturer has no device and fails to start.
};
} // namespace libyuv
#endif // LIBYUV_SOURCE_VIDEO_COMMON_H_
......@@ -22,8 +22,7 @@ class libyuvEnvironment : public ::testing::Environment {
libyuvTest::libyuvTest() :
_rotate_max_w(128),
_rotate_max_h(128)
{
_rotate_max_h(128) {
}
void libyuvTest::SetUp() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment