diff --git a/README.chromium b/README.chromium index a9a228fc9..2f314d7dd 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 99 +Version: 101 License: BSD License File: LICENSE diff --git a/include/libyuv/basic_types.h b/include/libyuv/basic_types.h index a492df29f..bf20c5715 100644 --- a/include/libyuv/basic_types.h +++ b/include/libyuv/basic_types.h @@ -13,7 +13,7 @@ #include // for NULL, size_t -#ifndef WIN32 +#if !(defined(_MSC_VER) && (_MSC_VER < 1600)) #include // for uintptr_t #endif diff --git a/include/libyuv/compare.h b/include/libyuv/compare.h index def29e37e..70719f9c1 100644 --- a/include/libyuv/compare.h +++ b/include/libyuv/compare.h @@ -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_ diff --git a/include/libyuv/convert.h b/include/libyuv/convert.h index bc7c26dd1..42b00cf09 100644 --- a/include/libyuv/convert.h +++ b/include/libyuv/convert.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_ diff --git a/include/libyuv/cpu_id.h b/include/libyuv/cpu_id.h index 2c3a9b38e..f7f580f59 100644 --- a/include/libyuv/cpu_id.h +++ b/include/libyuv/cpu_id.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_ diff --git a/include/libyuv/format_conversion.h b/include/libyuv/format_conversion.h index 0139f4c5e..632201c7b 100644 --- a/include/libyuv/format_conversion.h +++ b/include/libyuv/format_conversion.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_ diff --git a/include/libyuv/planar_functions.h b/include/libyuv/planar_functions.h index bbcc191d6..2ef10c4fd 100644 --- a/include/libyuv/planar_functions.h +++ b/include/libyuv/planar_functions.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_ diff --git a/include/libyuv/rotate.h b/include/libyuv/rotate.h index 65c38de34..f8d2f57db 100644 --- a/include/libyuv/rotate.h +++ b/include/libyuv/rotate.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_ diff --git a/include/libyuv/scale.h b/include/libyuv/scale.h index 8433908b9..d1660460a 100644 --- a/include/libyuv/scale.h +++ b/include/libyuv/scale.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_ diff --git a/source/compare.cc b/source/compare.cc index 42a8842d9..21a21a7f0 100644 --- a/source/compare.cc +++ b/source/compare.cc @@ -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(samples) / static_cast(sse); + double mse = static_cast(count) / static_cast(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 diff --git a/source/conversion_tables.h b/source/conversion_tables.h index 9a328649c..ef3ebf363 100644 --- a/source/conversion_tables.h +++ b/source/conversion_tables.h @@ -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 diff --git a/source/convert.cc b/source/convert.cc index 6e5ffc688..69f78b54c 100644 --- a/source/convert.cc +++ b/source/convert.cc @@ -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 diff --git a/source/cpu_id.cc b/source/cpu_id.cc index e784c2789..cae34b0b8 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -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 diff --git a/source/format_conversion.cc b/source/format_conversion.cc index 5f9f87e71..ebc20ac43 100644 --- a/source/format_conversion.cc +++ b/source/format_conversion.cc @@ -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 diff --git a/source/planar_functions.cc b/source/planar_functions.cc index 7b6f0de85..4e6dbb6cc 100644 --- a/source/planar_functions.cc +++ b/source/planar_functions.cc @@ -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(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(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(width); uint32* d = reinterpret_cast(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 diff --git a/source/rotate.cc b/source/rotate.cc index 548e7ac4d..93907607d 100644 --- a/source/rotate.cc +++ b/source/rotate.cc @@ -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 diff --git a/source/rotate_neon.cc b/source/rotate_neon.cc index 6d8cb4748..6ba7d51b8 100644 --- a/source/rotate_neon.cc +++ b/source/rotate_neon.cc @@ -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 diff --git a/source/rotate_priv.h b/source/rotate_priv.h index 658d9db01..6c48bbf7b 100644 --- a/source/rotate_priv.h +++ b/source/rotate_priv.h @@ -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_ diff --git a/source/row.h b/source/row.h index 06a446334..d39d0b9ba 100644 --- a/source/row.h +++ b/source/row.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_ diff --git a/source/row_common.cc b/source/row_common.cc index f763a05ed..87164a740 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -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 diff --git a/source/row_neon.cc b/source/row_neon.cc index d61d4440c..8e4e9b081 100644 --- a/source/row_neon.cc +++ b/source/row_neon.cc @@ -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 diff --git a/source/row_posix.cc b/source/row_posix.cc index 005efbb46..e531ab1d5 100644 --- a/source/row_posix.cc +++ b/source/row_posix.cc @@ -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(2.018 * 64)) */ #define UG -25 /* static_cast(-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 diff --git a/source/row_win.cc b/source/row_win.cc index f150d0e4a..d4d51501f 100644 --- a/source/row_win.cc +++ b/source/row_win.cc @@ -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 diff --git a/source/scale.cc b/source/scale.cc index ac6f22993..f56acf412 100644 --- a/source/scale.cc +++ b/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 diff --git a/source/video_common.cc b/source/video_common.cc index 0f5f3b646..63e2e0abb 100644 --- a/source/video_common.cc +++ b/source/video_common.cc @@ -13,7 +13,10 @@ #include +#ifdef __cplusplus namespace libyuv { +extern "C" { +#endif #define ARRAY_SIZE(x) (static_cast((sizeof(x)/sizeof(x[0])))) @@ -47,4 +50,8 @@ uint32 CanonicalFourCC(uint32 fourcc) { return fourcc; } +#ifdef __cplusplus +} // extern "C" } // namespace libyuv +#endif + diff --git a/source/video_common.h b/source/video_common.h index 0f4c6ee5c..ce67bb2c3 100644 --- a/source/video_common.h +++ b/source/video_common.h @@ -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_