mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 08:46:47 +08:00
clang on linux prefers no args for rep movsl/stosl. ifdef for C that removes namespace. extern c allows c++ to be used to compile, including with namespace, but C program can link libyuv
BUG=none TEST=none Review URL: http://webrtc-codereview.appspot.com/320004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@101 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
abe1613f51
commit
fe5ff7ed54
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 99
|
||||
Version: 101
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#include <stddef.h> // for NULL, size_t
|
||||
|
||||
#ifndef WIN32
|
||||
#if !(defined(_MSC_VER) && (_MSC_VER < 1600))
|
||||
#include <stdint.h> // for uintptr_t
|
||||
#endif
|
||||
|
||||
|
||||
@ -13,10 +13,15 @@
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static const int kMaxPsnr = 128;
|
||||
|
||||
double SumSquareErrorToPsnr(uint64 sse, uint64 count);
|
||||
|
||||
uint64 ComputeSumSquareError(const uint8 *src_a,
|
||||
const uint8 *src_b, int count);
|
||||
|
||||
@ -48,6 +53,9 @@ double I420Ssim(const uint8 *src_y_a, int stride_y_a,
|
||||
const uint8 *src_v_b, int stride_v_b,
|
||||
int width, int height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_COMPARE_H_
|
||||
|
||||
@ -14,7 +14,10 @@
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "libyuv/rotate.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int I420ToRGB24(const uint8* src_y, int src_stride_y,
|
||||
const uint8* src_u, int src_stride_u,
|
||||
@ -130,6 +133,9 @@ int ConvertToI420(const uint8* src_frame, size_t src_size,
|
||||
RotationMode rotation,
|
||||
uint32 format);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_CONVERT_H_
|
||||
|
||||
@ -11,7 +11,10 @@
|
||||
#ifndef INCLUDE_LIBYUV_CPU_ID_H_
|
||||
#define INCLUDE_LIBYUV_CPU_ID_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// These flags are only valid on x86 processors
|
||||
static const int kCpuHasSSE2 = 1;
|
||||
@ -38,6 +41,9 @@ static inline int TestCpuFlag(int test_flag) {
|
||||
// 0 to disable all cpu specific optimizations.
|
||||
void MaskCpuFlags(int enable_flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_CPU_ID_H_
|
||||
|
||||
@ -13,7 +13,10 @@
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Converts any Bayer RGB format to I420.
|
||||
int BayerRGBToI420(const uint8* src_bayer, int src_stride_bayer,
|
||||
@ -35,6 +38,9 @@ int ARGBToBayerRGB(const uint8* src_rgb, int src_stride_rgb,
|
||||
uint32 dst_fourcc_bayer,
|
||||
int width, int height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_FORMATCONVERSION_H_
|
||||
|
||||
@ -13,7 +13,10 @@
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Copy I420 to I420.
|
||||
int I420Copy(const uint8* src_y, int src_stride_y,
|
||||
@ -68,14 +71,6 @@ int NV12ToI420(const uint8* src_y, int src_stride_y,
|
||||
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,
|
||||
@ -194,6 +189,9 @@ int ARGBCopy(const uint8* src_argb, int src_stride_argb,
|
||||
uint8* dst_argb, int dst_stride_argb,
|
||||
int width, int height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_
|
||||
|
||||
@ -13,7 +13,10 @@
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Supported rotation
|
||||
enum RotationMode {
|
||||
@ -47,6 +50,9 @@ int NV12ToI420Rotate(const uint8* src_y, int src_stride_y,
|
||||
int width, int height,
|
||||
RotationMode mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_ROTATE_H_
|
||||
|
||||
@ -13,7 +13,10 @@
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Supported filtering
|
||||
enum FilterMode {
|
||||
@ -42,15 +45,7 @@ int I420Scale(const uint8* src_y, int src_stride_y,
|
||||
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.
|
||||
// Legacy API. Deprecated
|
||||
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,
|
||||
@ -59,9 +54,17 @@ int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v,
|
||||
int dst_width, int dst_height,
|
||||
bool interpolate);
|
||||
|
||||
// Legacy API. Deprecated
|
||||
int ScaleOffset(const uint8* src, int src_width, int src_height,
|
||||
uint8* dst, int dst_width, int dst_height, int dst_yoffset,
|
||||
bool interpolate);
|
||||
|
||||
// For testing, allow disabling of optimizations.
|
||||
void SetUseReferenceImpl(bool use);
|
||||
|
||||
} // namespace libyuv
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_SCALE_H_
|
||||
|
||||
@ -17,7 +17,10 @@
|
||||
#include "libyuv/cpu_id.h"
|
||||
#include "row.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_NEON__) && !defined(YUV_DISABLE_ASM)
|
||||
#define HAS_SUMSQUAREERROR_NEON
|
||||
@ -222,23 +225,10 @@ uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a,
|
||||
return sse;
|
||||
}
|
||||
|
||||
double Sse2Psnr(double samples, double sse) {
|
||||
double psnr;
|
||||
if (sse > 0.0)
|
||||
psnr = 10.0 * log10(255.0 * 255.0 * samples / sse);
|
||||
else
|
||||
psnr = kMaxPsnr; // Limit to prevent divide by 0
|
||||
|
||||
if (psnr > kMaxPsnr)
|
||||
psnr = kMaxPsnr;
|
||||
|
||||
return psnr;
|
||||
}
|
||||
|
||||
double Sse2Psnr(uint64 samples, uint64 sse) {
|
||||
double SumSquareErrorToPsnr(uint64 sse, uint64 count) {
|
||||
double psnr;
|
||||
if (sse > 0) {
|
||||
double mse = static_cast<double>(samples) / static_cast<double>(sse);
|
||||
double mse = static_cast<double>(count) / static_cast<double>(sse);
|
||||
psnr = 10.0 * log10(255.0 * 255.0 * mse);
|
||||
} else {
|
||||
psnr = kMaxPsnr; // Limit to prevent divide by 0
|
||||
@ -254,12 +244,10 @@ double CalcFramePsnr(const uint8* src_a, int stride_a,
|
||||
const uint8* src_b, int stride_b,
|
||||
int width, int height) {
|
||||
const uint64 samples = width * height;
|
||||
|
||||
const uint64 sse = ComputeSumSquareErrorPlane(src_a, stride_a,
|
||||
src_b, stride_b,
|
||||
width, height);
|
||||
|
||||
return Sse2Psnr(samples, sse);
|
||||
return SumSquareErrorToPsnr(sse, samples);
|
||||
}
|
||||
|
||||
double I420Psnr(const uint8* src_y_a, int stride_y_a,
|
||||
@ -272,22 +260,17 @@ double I420Psnr(const uint8* src_y_a, int stride_y_a,
|
||||
const uint64 sse_y = ComputeSumSquareErrorPlane(src_y_a, stride_y_a,
|
||||
src_y_b, stride_y_b,
|
||||
width, height);
|
||||
|
||||
const int width_uv = (width + 1) >> 1;
|
||||
const int height_uv = (height + 1) >> 1;
|
||||
|
||||
const uint64 sse_u = ComputeSumSquareErrorPlane(src_u_a, stride_u_a,
|
||||
src_u_b, stride_u_b,
|
||||
width_uv, height_uv);
|
||||
const uint64 sse_v = ComputeSumSquareErrorPlane(src_v_a, stride_v_a,
|
||||
src_v_b, stride_v_b,
|
||||
width_uv, height_uv);
|
||||
|
||||
const uint64 samples = width * height + 2 * (width_uv * height_uv);
|
||||
|
||||
const uint64 sse = sse_y + sse_u + sse_v;
|
||||
|
||||
return Sse2Psnr(samples, sse);
|
||||
return SumSquareErrorToPsnr(sse, samples);
|
||||
}
|
||||
|
||||
static const int64 cc1 = 26634; // (64^2*(.01*255)^2
|
||||
@ -374,18 +357,18 @@ double I420Ssim(const uint8* src_y_a, int stride_y_a,
|
||||
int width, int height) {
|
||||
const double ssim_y = CalcFrameSsim(src_y_a, stride_y_a,
|
||||
src_y_b, stride_y_b, width, height);
|
||||
|
||||
const int width_uv = (width + 1) >> 1;
|
||||
const int height_uv = (height + 1) >> 1;
|
||||
|
||||
const double ssim_u = CalcFrameSsim(src_u_a, stride_u_a,
|
||||
src_u_b, stride_u_b,
|
||||
width_uv, height_uv);
|
||||
const double ssim_v = CalcFrameSsim(src_v_a, stride_v_a,
|
||||
src_v_b, stride_v_b,
|
||||
width_uv, height_uv);
|
||||
|
||||
return ssim_y * 0.8 + 0.1 * (ssim_u + ssim_v);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -18,7 +18,10 @@
|
||||
#ifndef LIBYUV_SOURCE_CONVERSION_TABLES_H_
|
||||
#define LIBYUV_SOURCE_CONVERSION_TABLES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* YUV TO RGB approximation
|
||||
@ -197,7 +200,10 @@ namespace libyuv {
|
||||
Vcg(244),Vcg(245),Vcg(246),Vcg(247),Vcg(248),Vcg(249),Vcg(250),Vcg(251),
|
||||
Vcg(252),Vcg(253),Vcg(254),Vcg(255)};
|
||||
|
||||
} // namespace libyuv
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -25,7 +25,10 @@
|
||||
#include "row.h"
|
||||
#include "video_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline uint8 Clip(int32 val) {
|
||||
if (val < 0) {
|
||||
@ -1187,4 +1190,7 @@ int ConvertToI420(const uint8* sample, size_t sample_size,
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace libyuv
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -40,7 +40,10 @@ static inline void __cpuid(int cpu_info[4], int info_type) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// CPU detect function for SIMD instruction sets.
|
||||
int cpu_info_ = 0;
|
||||
@ -72,4 +75,7 @@ void MaskCpuFlags(int enable_flags) {
|
||||
cpu_info_ = (cpu_info_ & enable_flags) | kCpuInitialized;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -15,7 +15,10 @@
|
||||
#include "row.h"
|
||||
#include "video_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Note: to do this with Neon vld4.8 would load ARGB values into 4 registers
|
||||
// and vst would select which 2 components to write. The low level would need
|
||||
@ -430,4 +433,7 @@ int BayerRGBToI420(const uint8* src_bayer, int src_stride_bayer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -15,7 +15,10 @@
|
||||
#include "libyuv/cpu_id.h"
|
||||
#include "row.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_NEON__) && !defined(YUV_DISABLE_ASM)
|
||||
#define HAS_SPLITUV_NEON
|
||||
@ -194,7 +197,7 @@ void CopyRow_X86(const uint8* src, uint8* dst, int width) {
|
||||
size_t width_tmp = static_cast<size_t>(width);
|
||||
asm volatile (
|
||||
"shr $0x2,%2 \n"
|
||||
"rep movsl (%0),(%1) \n"
|
||||
"rep movsl \n"
|
||||
: "+S"(src), // %0
|
||||
"+D"(dst), // %1
|
||||
"+c"(width_tmp) // %2
|
||||
@ -715,22 +718,6 @@ int NV12ToI420(const uint8* src_y, int src_stride_y,
|
||||
width, height);
|
||||
}
|
||||
|
||||
// Convert NV12 to I420. Deprecated.
|
||||
int NV12ToI420(const uint8* src_y,
|
||||
const uint8* src_uv,
|
||||
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) {
|
||||
return X420ToI420(src_y, src_stride_frame, src_stride_frame,
|
||||
src_uv, src_stride_frame,
|
||||
dst_y, dst_stride_y,
|
||||
dst_u, dst_stride_u,
|
||||
dst_v, dst_stride_v,
|
||||
width, height);
|
||||
}
|
||||
|
||||
#if defined(_M_IX86) && !defined(YUV_DISABLE_ASM)
|
||||
#define HAS_SPLITYUY2_SSE2
|
||||
__declspec(naked)
|
||||
@ -1791,7 +1778,7 @@ static void SetRow8_X86(uint8* dst, uint32 v32, int width) {
|
||||
size_t width_tmp = static_cast<size_t>(width);
|
||||
asm volatile (
|
||||
"shr $0x2,%1 \n"
|
||||
"rep stos %2,(%0) \n"
|
||||
"rep stosl \n"
|
||||
: "+D"(dst), // %0
|
||||
"+c"(width_tmp) // %1
|
||||
: "a"(v32) // %2
|
||||
@ -1805,7 +1792,7 @@ static void SetRows32_X86(uint8* dst, uint32 v32, int width,
|
||||
size_t width_tmp = static_cast<size_t>(width);
|
||||
uint32* d = reinterpret_cast<uint32*>(dst);
|
||||
asm volatile (
|
||||
"rep stos %2,(%0) \n"
|
||||
"rep stosl \n"
|
||||
: "+D"(d), // %0
|
||||
"+c"(width_tmp) // %1
|
||||
: "a"(v32) // %2
|
||||
@ -1930,5 +1917,7 @@ int ARGBRect(uint8* dst_argb, int dst_stride_argb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
|
||||
#endif
|
||||
|
||||
@ -15,7 +15,10 @@
|
||||
#include "rotate_priv.h"
|
||||
#include "row.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)) && \
|
||||
!defined(YUV_DISABLE_ASM)
|
||||
@ -29,13 +32,13 @@ uvec8 kShuffleReverseUV = {
|
||||
defined(__i386__)
|
||||
#define DECLARE_FUNCTION(name) \
|
||||
".text \n" \
|
||||
".globl _" name " \n" \
|
||||
"_" name ": \n"
|
||||
".globl _" #name " \n" \
|
||||
"_" #name ": \n"
|
||||
#else
|
||||
#define DECLARE_FUNCTION(name) \
|
||||
".text \n" \
|
||||
".global _" name " \n" \
|
||||
name ": \n"
|
||||
".global _" #name " \n" \
|
||||
#name ": \n"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1203,7 +1206,8 @@ int NV12ToI420Rotate(const uint8* src_y, int src_stride_y,
|
||||
switch (mode) {
|
||||
case kRotate0:
|
||||
// copy frame
|
||||
return NV12ToI420(src_y, src_uv, src_stride_y,
|
||||
return NV12ToI420(src_y, src_stride_y,
|
||||
src_uv, src_stride_uv,
|
||||
dst_y, dst_stride_y,
|
||||
dst_u, dst_stride_u,
|
||||
dst_v, dst_stride_v,
|
||||
@ -1241,4 +1245,7 @@ int NV12ToI420Rotate(const uint8* src_y, int src_stride_y,
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -11,7 +11,10 @@
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "row.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_NEON__) && !defined(YUV_DISABLE_ASM)
|
||||
|
||||
@ -555,4 +558,8 @@ void TransposeUVWx8_NEON(const uint8* src, int src_stride,
|
||||
);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -13,7 +13,10 @@
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Rotate planes by 90, 180, 270
|
||||
void RotatePlane90(const uint8* src, int src_stride,
|
||||
@ -59,6 +62,9 @@ void TransposeUV(const uint8* src, int src_stride,
|
||||
uint8* dst_b, int dst_stride_b,
|
||||
int width, int height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // SOURCE_ROTATE_PRIV_H_
|
||||
|
||||
@ -72,7 +72,10 @@ void FastConvertYUVToABGRRow_NEON(const uint8* y_buf,
|
||||
#define HAS_REVERSE_ROW_NEON
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAS_ARGBTOYROW_SSSE3
|
||||
void ARGBToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix);
|
||||
@ -250,6 +253,9 @@ void FastConvertYToARGBRow_SSE2(const uint8* y_buf,
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // LIBYUV_SOURCE_ROW_H_
|
||||
|
||||
@ -12,7 +12,10 @@
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void ABGRToARGBRow_C(const uint8* src_abgr, uint8* dst_argb, int pix) {
|
||||
for (int x = 0; x < pix; ++x) {
|
||||
@ -343,4 +346,7 @@ void ReverseRow_C(const uint8* src, uint8* dst, int width) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
|
||||
#include "row.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define YUVTORGB \
|
||||
"vld1.u8 {d0}, [%0]! \n" \
|
||||
"vld1.u32 {d2[0]}, [%1]! \n" \
|
||||
@ -154,3 +159,8 @@ YUVTORGB
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -12,7 +12,10 @@
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAS_ARGBTOUVROW_SSSE3
|
||||
vec8 kARGBToU = {
|
||||
@ -318,7 +321,6 @@ void ARGBToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_FASTCONVERTYUVTOARGBROW_SSSE3
|
||||
#define UB 127 /* min(63,static_cast<int8>(2.018 * 64)) */
|
||||
#define UG -25 /* static_cast<int8>(-0.391 * 64 - 0.5) */
|
||||
@ -637,7 +639,7 @@ void BGRAToUVRow_SSSE3(const uint8* src_argb, int src_stride_argb,
|
||||
#ifdef HAS_REVERSE_ROW_SSSE3
|
||||
|
||||
// Shuffle table for reversing the bytes.
|
||||
static const uvec8 kShuffleReverse = {
|
||||
uvec8 kShuffleReverse = {
|
||||
15u, 14u, 13u, 12u, 11u, 10u, 9u, 8u, 7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u
|
||||
};
|
||||
|
||||
@ -666,4 +668,7 @@ void ReverseRow_SSSE3(const uint8* src, uint8* dst, int width) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -10,7 +10,10 @@
|
||||
|
||||
#include "row.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAS_ARGBTOYROW_SSSE3
|
||||
|
||||
@ -844,7 +847,7 @@ __asm {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
|
||||
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
100
source/scale.cc
100
source/scale.cc
@ -16,20 +16,22 @@
|
||||
#include "libyuv/cpu_id.h"
|
||||
#include "row.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define ALIGN16(var) __declspec(align(16)) var
|
||||
#else
|
||||
#define ALIGN16(var) var __attribute__((aligned(16)))
|
||||
#endif
|
||||
|
||||
|
||||
// Note: A Neon reference manual
|
||||
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/CJAJIIGG.html
|
||||
// Note: Some SSE2 reference manuals
|
||||
// cpuvol1.pdf agner_instruction_tables.pdf 253666.pdf 253667.pdf
|
||||
|
||||
namespace libyuv {
|
||||
|
||||
// Set the following flag to true to revert to only
|
||||
// using the reference implementation ScalePlaneBox(), and
|
||||
// NOT the optimized versions. Useful for debugging and
|
||||
@ -516,19 +518,21 @@ static void ScaleRowDown38_2_Int_NEON(const uint8* src_ptr, int src_stride,
|
||||
#else
|
||||
#define TALIGN16(t, var) t _ ## var __attribute__((aligned(16)))
|
||||
#endif
|
||||
|
||||
#if (defined(__APPLE__) || defined(__MINGW32__) || defined(__CYGWIN__)) && \
|
||||
defined(__i386__)
|
||||
#define DECLARE_FUNCTION(name) \
|
||||
".text \n" \
|
||||
".globl _" name " \n" \
|
||||
"_" name ": \n"
|
||||
".globl _" #name " \n" \
|
||||
"_" #name ": \n"
|
||||
#else
|
||||
#define DECLARE_FUNCTION(name) \
|
||||
".text \n" \
|
||||
".global _" name " \n" \
|
||||
name ": \n"
|
||||
".global _" #name " \n" \
|
||||
#name ": \n"
|
||||
#endif
|
||||
|
||||
|
||||
// Offsets for source bytes 0 to 9
|
||||
extern "C" TALIGN16(const uint8, shuf0[16]) =
|
||||
{ 0, 1, 3, 4, 5, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 128 };
|
||||
@ -3677,23 +3681,24 @@ int I420Scale(const uint8* src_y, int src_stride_y,
|
||||
src_stride_u = -src_stride_u;
|
||||
src_stride_v = -src_stride_v;
|
||||
}
|
||||
int halfsrc_width = (src_width + 1) >> 1;
|
||||
int halfsrc_height = (src_height + 1) >> 1;
|
||||
int halfdst_width = (dst_width + 1) >> 1;
|
||||
int halfoheight = (dst_height + 1) >> 1;
|
||||
int src_halfwidth = (src_width + 1) >> 1;
|
||||
int src_halfheight = (src_height + 1) >> 1;
|
||||
int dst_halfwidth = (dst_width + 1) >> 1;
|
||||
int dst_halfheight = (dst_height + 1) >> 1;
|
||||
|
||||
ScalePlane(src_y, src_stride_y, src_width, src_height,
|
||||
dst_y, dst_stride_y, dst_width, dst_height,
|
||||
filtering, use_reference_impl_);
|
||||
ScalePlane(src_u, src_stride_u, halfsrc_width, halfsrc_height,
|
||||
dst_u, dst_stride_u, halfdst_width, halfoheight,
|
||||
ScalePlane(src_u, src_stride_u, src_halfwidth, src_halfheight,
|
||||
dst_u, dst_stride_u, dst_halfwidth, dst_halfheight,
|
||||
filtering, use_reference_impl_);
|
||||
ScalePlane(src_v, src_stride_v, halfsrc_width, halfsrc_height,
|
||||
dst_v, dst_stride_v, halfdst_width, halfoheight,
|
||||
ScalePlane(src_v, src_stride_v, src_halfwidth, src_halfheight,
|
||||
dst_v, dst_stride_v, dst_halfwidth, dst_halfheight,
|
||||
filtering, use_reference_impl_);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Deprecated api
|
||||
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,
|
||||
@ -3716,49 +3721,54 @@ int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v,
|
||||
src_stride_u = -src_stride_u;
|
||||
src_stride_v = -src_stride_v;
|
||||
}
|
||||
int halfsrc_width = (src_width + 1) >> 1;
|
||||
int halfsrc_height = (src_height + 1) >> 1;
|
||||
int halfdst_width = (dst_width + 1) >> 1;
|
||||
int halfoheight = (dst_height + 1) >> 1;
|
||||
int src_halfwidth = (src_width + 1) >> 1;
|
||||
int src_halfheight = (src_height + 1) >> 1;
|
||||
int dst_halfwidth = (dst_width + 1) >> 1;
|
||||
int dst_halfheight = (dst_height + 1) >> 1;
|
||||
FilterMode filtering = interpolate ? kFilterBox : kFilterNone;
|
||||
|
||||
ScalePlane(src_y, src_stride_y, src_width, src_height,
|
||||
dst_y, dst_stride_y, dst_width, dst_height,
|
||||
filtering, use_reference_impl_);
|
||||
ScalePlane(src_u, src_stride_u, halfsrc_width, halfsrc_height,
|
||||
dst_u, dst_stride_u, halfdst_width, halfoheight,
|
||||
ScalePlane(src_u, src_stride_u, src_halfwidth, src_halfheight,
|
||||
dst_u, dst_stride_u, dst_halfwidth, dst_halfheight,
|
||||
filtering, use_reference_impl_);
|
||||
ScalePlane(src_v, src_stride_v, halfsrc_width, halfsrc_height,
|
||||
dst_v, dst_stride_v, halfdst_width, halfoheight,
|
||||
ScalePlane(src_v, src_stride_v, src_halfwidth, src_halfheight,
|
||||
dst_v, dst_stride_v, dst_halfwidth, dst_halfheight,
|
||||
filtering, use_reference_impl_);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Scale(const uint8* src, int src_width, int src_height,
|
||||
uint8* dst, int dst_width, int dst_height, int ooffset,
|
||||
bool interpolate) {
|
||||
// Deprecated api
|
||||
int ScaleOffset(const uint8* src, int src_width, int src_height,
|
||||
uint8* dst, int dst_width, int dst_height, int dst_yoffset,
|
||||
bool interpolate) {
|
||||
if (!src || src_width <= 0 || src_height <= 0 ||
|
||||
!dst || dst_width <= 0 || dst_height <= 0 || ooffset < 0 ||
|
||||
ooffset >= dst_height) {
|
||||
!dst || dst_width <= 0 || dst_height <= 0 || dst_yoffset < 0 ||
|
||||
dst_yoffset >= dst_height) {
|
||||
return -1;
|
||||
}
|
||||
ooffset = ooffset & ~1; // chroma requires offset to multiple of 2.
|
||||
int halfsrc_width = (src_width + 1) >> 1;
|
||||
int halfsrc_height = (src_height + 1) >> 1;
|
||||
int halfdst_width = (dst_width + 1) >> 1;
|
||||
int halfoheight = (dst_height + 1) >> 1;
|
||||
int aheight = dst_height - ooffset * 2; // actual output height
|
||||
const uint8* const iyptr = src;
|
||||
uint8* oyptr = dst + ooffset * dst_width;
|
||||
const uint8* const iuptr = src + src_width * src_height;
|
||||
uint8* ouptr = dst + dst_width * dst_height + (ooffset >> 1) * halfdst_width;
|
||||
const uint8* const ivptr = src + src_width * src_height +
|
||||
halfsrc_width * halfsrc_height;
|
||||
uint8* ovptr = dst + dst_width * dst_height + halfdst_width * halfoheight +
|
||||
(ooffset >> 1) * halfdst_width;
|
||||
return Scale(iyptr, iuptr, ivptr, src_width, halfsrc_width, halfsrc_width,
|
||||
src_width, src_height, oyptr, ouptr, ovptr, dst_width,
|
||||
halfdst_width, halfdst_width, dst_width, aheight, interpolate);
|
||||
dst_yoffset = dst_yoffset & ~1; // chroma requires offset to multiple of 2.
|
||||
int src_halfwidth = (src_width + 1) >> 1;
|
||||
int src_halfheight = (src_height + 1) >> 1;
|
||||
int dst_halfwidth = (dst_width + 1) >> 1;
|
||||
int dst_halfheight = (dst_height + 1) >> 1;
|
||||
int aheight = dst_height - dst_yoffset * 2; // actual output height
|
||||
const uint8* const src_y = src;
|
||||
const uint8* const src_u = src + src_width * src_height;
|
||||
const uint8* const src_v = src + src_width * src_height +
|
||||
src_halfwidth * src_halfheight;
|
||||
uint8* dst_y = dst + dst_yoffset * dst_width;
|
||||
uint8* dst_u = dst + dst_width * dst_height +
|
||||
(dst_yoffset >> 1) * dst_halfwidth;
|
||||
uint8* dst_v = dst + dst_width * dst_height + dst_halfwidth * dst_halfheight +
|
||||
(dst_yoffset >> 1) * dst_halfwidth;
|
||||
return Scale(src_y, src_u, src_v, src_width, src_halfwidth, src_halfwidth,
|
||||
src_width, src_height, dst_y, dst_u, dst_v, dst_width,
|
||||
dst_halfwidth, dst_halfwidth, dst_width, aheight, interpolate);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
@ -13,7 +13,10 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZE(x) (static_cast<int>((sizeof(x)/sizeof(x[0]))))
|
||||
|
||||
@ -47,4 +50,8 @@ uint32 CanonicalFourCC(uint32 fourcc) {
|
||||
return fourcc;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
|
||||
@ -20,7 +20,10 @@
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Definition of fourcc.
|
||||
@ -84,6 +87,9 @@ enum FourCC {
|
||||
// Converts fourcc aliases into canonical ones.
|
||||
uint32 CanonicalFourCC(uint32 fourcc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // LIBYUV_SOURCE_VIDEO_COMMON_H_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user