Commit e62309f2 authored by Frank Barchard's avatar Frank Barchard

clang-format libyuv

BUG=libyuv:654
R=kjellander@chromium.org

Review URL: https://codereview.chromium.org/2469353005 .
parent f2c27daf
# Defines the Chromium style for automatic reformatting.
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium
---
Language: Java
BasedOnStyle: Google
...@@ -26,31 +26,31 @@ ...@@ -26,31 +26,31 @@
typedef unsigned __int64 uint64; typedef unsigned __int64 uint64;
typedef __int64 int64; typedef __int64 int64;
#ifndef INT64_C #ifndef INT64_C
#define INT64_C(x) x ## I64 #define INT64_C(x) x##I64
#endif #endif
#ifndef UINT64_C #ifndef UINT64_C
#define UINT64_C(x) x ## UI64 #define UINT64_C(x) x##UI64
#endif #endif
#define INT64_F "I64" #define INT64_F "I64"
#else // COMPILER_MSVC #else // COMPILER_MSVC
#if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__)
typedef unsigned long uint64; // NOLINT typedef unsigned long uint64; // NOLINT
typedef long int64; // NOLINT typedef long int64; // NOLINT
#ifndef INT64_C #ifndef INT64_C
#define INT64_C(x) x ## L #define INT64_C(x) x##L
#endif #endif
#ifndef UINT64_C #ifndef UINT64_C
#define UINT64_C(x) x ## UL #define UINT64_C(x) x##UL
#endif #endif
#define INT64_F "l" #define INT64_F "l"
#else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__)
typedef unsigned long long uint64; // NOLINT typedef unsigned long long uint64; // NOLINT
typedef long long int64; // NOLINT typedef long long int64; // NOLINT
#ifndef INT64_C #ifndef INT64_C
#define INT64_C(x) x ## LL #define INT64_C(x) x##LL
#endif #endif
#ifndef UINT64_C #ifndef UINT64_C
#define UINT64_C(x) x ## ULL #define UINT64_C(x) x##ULL
#endif #endif
#define INT64_F "ll" #define INT64_F "ll"
#endif // __LP64__ #endif // __LP64__
...@@ -58,15 +58,15 @@ typedef long long int64; // NOLINT ...@@ -58,15 +58,15 @@ typedef long long int64; // NOLINT
typedef unsigned int uint32; typedef unsigned int uint32;
typedef int int32; typedef int int32;
typedef unsigned short uint16; // NOLINT typedef unsigned short uint16; // NOLINT
typedef short int16; // NOLINT typedef short int16; // NOLINT
typedef unsigned char uint8; typedef unsigned char uint8;
typedef signed char int8; typedef signed char int8;
#endif // INT_TYPES_DEFINED #endif // INT_TYPES_DEFINED
#endif // GG_LONGLONG #endif // GG_LONGLONG
// Detect compiler is for x86 or x64. // Detect compiler is for x86 or x64.
#if defined(__x86_64__) || defined(_M_X64) || \ #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
defined(__i386__) || defined(_M_IX86) defined(_M_IX86)
#define CPU_X86 1 #define CPU_X86 1
#endif #endif
// Detect compiler is for ARM. // Detect compiler is for ARM.
...@@ -76,12 +76,12 @@ typedef signed char int8; ...@@ -76,12 +76,12 @@ typedef signed char int8;
#ifndef ALIGNP #ifndef ALIGNP
#ifdef __cplusplus #ifdef __cplusplus
#define ALIGNP(p, t) \ #define ALIGNP(p, t) \
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \ reinterpret_cast<uint8*>( \
((t) - 1)) & ~((t) - 1)))) ((reinterpret_cast<uintptr_t>(p) + ((t)-1)) & ~((t)-1)))
#else #else
#define ALIGNP(p, t) \ #define ALIGNP(p, t) \
((uint8*)((((uintptr_t)(p) + ((t) - 1)) & ~((t) - 1)))) /* NOLINT */ (uint8*)((((uintptr_t)(p) + ((t)-1)) & ~((t)-1))) /* NOLINT */
#endif #endif
#endif #endif
...@@ -95,9 +95,9 @@ typedef signed char int8; ...@@ -95,9 +95,9 @@ typedef signed char int8;
#define LIBYUV_API #define LIBYUV_API
#endif // LIBYUV_BUILDING_SHARED_LIBRARY #endif // LIBYUV_BUILDING_SHARED_LIBRARY
#elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \
(defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \
defined(LIBYUV_USING_SHARED_LIBRARY)) defined(LIBYUV_USING_SHARED_LIBRARY))
#define LIBYUV_API __attribute__ ((visibility ("default"))) #define LIBYUV_API __attribute__((visibility("default")))
#else #else
#define LIBYUV_API #define LIBYUV_API
#endif // __GNUC__ #endif // __GNUC__
...@@ -108,10 +108,9 @@ typedef signed char int8; ...@@ -108,10 +108,9 @@ typedef signed char int8;
#define LIBYUV_TRUE 1 #define LIBYUV_TRUE 1
// Visual C x86 or GCC little endian. // Visual C x86 or GCC little endian.
#if defined(__x86_64__) || defined(_M_X64) || \ #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
defined(__i386__) || defined(_M_IX86) || \ defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) || \
defined(__arm__) || defined(_M_ARM) || \ (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#define LIBYUV_LITTLE_ENDIAN #define LIBYUV_LITTLE_ENDIAN
#endif #endif
......
...@@ -29,13 +29,15 @@ uint32 ARGBDetect(const uint8* argb, int stride_argb, int width, int height); ...@@ -29,13 +29,15 @@ uint32 ARGBDetect(const uint8* argb, int stride_argb, int width, int height);
// Sum Square Error - used to compute Mean Square Error or PSNR. // Sum Square Error - used to compute Mean Square Error or PSNR.
LIBYUV_API LIBYUV_API
uint64 ComputeSumSquareError(const uint8* src_a, uint64 ComputeSumSquareError(const uint8* src_a, const uint8* src_b, int count);
const uint8* src_b, int count);
LIBYUV_API LIBYUV_API
uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a, uint64 ComputeSumSquareErrorPlane(const uint8* src_a,
const uint8* src_b, int stride_b, int stride_a,
int width, int height); const uint8* src_b,
int stride_b,
int width,
int height);
static const int kMaxPsnr = 128; static const int kMaxPsnr = 128;
...@@ -43,32 +45,52 @@ LIBYUV_API ...@@ -43,32 +45,52 @@ LIBYUV_API
double SumSquareErrorToPsnr(uint64 sse, uint64 count); double SumSquareErrorToPsnr(uint64 sse, uint64 count);
LIBYUV_API LIBYUV_API
double CalcFramePsnr(const uint8* src_a, int stride_a, double CalcFramePsnr(const uint8* src_a,
const uint8* src_b, int stride_b, int stride_a,
int width, int height); const uint8* src_b,
int stride_b,
int width,
int height);
LIBYUV_API LIBYUV_API
double I420Psnr(const uint8* src_y_a, int stride_y_a, double I420Psnr(const uint8* src_y_a,
const uint8* src_u_a, int stride_u_a, int stride_y_a,
const uint8* src_v_a, int stride_v_a, const uint8* src_u_a,
const uint8* src_y_b, int stride_y_b, int stride_u_a,
const uint8* src_u_b, int stride_u_b, const uint8* src_v_a,
const uint8* src_v_b, int stride_v_b, int stride_v_a,
int width, int height); const uint8* src_y_b,
int stride_y_b,
const uint8* src_u_b,
int stride_u_b,
const uint8* src_v_b,
int stride_v_b,
int width,
int height);
LIBYUV_API LIBYUV_API
double CalcFrameSsim(const uint8* src_a, int stride_a, double CalcFrameSsim(const uint8* src_a,
const uint8* src_b, int stride_b, int stride_a,
int width, int height); const uint8* src_b,
int stride_b,
int width,
int height);
LIBYUV_API LIBYUV_API
double I420Ssim(const uint8* src_y_a, int stride_y_a, double I420Ssim(const uint8* src_y_a,
const uint8* src_u_a, int stride_u_a, int stride_y_a,
const uint8* src_v_a, int stride_v_a, const uint8* src_u_a,
const uint8* src_y_b, int stride_y_b, int stride_u_a,
const uint8* src_u_b, int stride_u_b, const uint8* src_v_a,
const uint8* src_v_b, int stride_v_b, int stride_v_a,
int width, int height); const uint8* src_y_b,
int stride_y_b,
const uint8* src_u_b,
int stride_u_b,
const uint8* src_v_b,
int stride_v_b,
int width,
int height);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
......
...@@ -30,8 +30,8 @@ extern "C" { ...@@ -30,8 +30,8 @@ extern "C" {
#endif #endif
// Visual C 2012 required for AVX2. // Visual C 2012 required for AVX2.
#if defined(_M_IX86) && !defined(__clang__) && \ #if defined(_M_IX86) && !defined(__clang__) && defined(_MSC_VER) && \
defined(_MSC_VER) && _MSC_VER >= 1700 _MSC_VER >= 1700
#define VISUALC_HAS_AVX2 1 #define VISUALC_HAS_AVX2 1
#endif // VisualStudio >= 2012 #endif // VisualStudio >= 2012
...@@ -42,8 +42,8 @@ extern "C" { ...@@ -42,8 +42,8 @@ extern "C" {
#endif // clang >= 3.4 #endif // clang >= 3.4
#endif // __clang__ #endif // __clang__
#if !defined(LIBYUV_DISABLE_X86) && \ #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \
defined(_M_IX86) && (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2)) (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
#define HAS_HASHDJB2_AVX2 #define HAS_HASHDJB2_AVX2
#endif #endif
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -144,12 +144,16 @@ class LIBYUV_API MJpegDecoder { ...@@ -144,12 +144,16 @@ class LIBYUV_API MJpegDecoder {
// callback function. Each call will get the data for a whole number of // callback function. Each call will get the data for a whole number of
// image scanlines. // image scanlines.
// TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded. // TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded.
LIBYUV_BOOL DecodeToCallback(CallbackFunction fn, void* opaque, LIBYUV_BOOL DecodeToCallback(CallbackFunction fn,
int dst_width, int dst_height); void* opaque,
int dst_width,
int dst_height);
// The helper function which recognizes the jpeg sub-sampling type. // The helper function which recognizes the jpeg sub-sampling type.
static JpegSubsamplingType JpegSubsamplingTypeHelper( static JpegSubsamplingType JpegSubsamplingTypeHelper(
int* subsample_x, int* subsample_y, int number_of_components); int* subsample_x,
int* subsample_y,
int number_of_components);
private: private:
void AllocOutputBuffers(int num_outbufs); void AllocOutputBuffers(int num_outbufs);
......
This diff is collapsed.
...@@ -20,8 +20,8 @@ extern "C" { ...@@ -20,8 +20,8 @@ extern "C" {
// Supported rotation. // Supported rotation.
typedef enum RotationMode { typedef enum RotationMode {
kRotate0 = 0, // No rotation. kRotate0 = 0, // No rotation.
kRotate90 = 90, // Rotate 90 degrees clockwise. kRotate90 = 90, // Rotate 90 degrees clockwise.
kRotate180 = 180, // Rotate 180 degrees. kRotate180 = 180, // Rotate 180 degrees.
kRotate270 = 270, // Rotate 270 degrees clockwise. kRotate270 = 270, // Rotate 270 degrees clockwise.
...@@ -33,81 +33,128 @@ typedef enum RotationMode { ...@@ -33,81 +33,128 @@ typedef enum RotationMode {
// Rotate I420 frame. // Rotate I420 frame.
LIBYUV_API LIBYUV_API
int I420Rotate(const uint8* src_y, int src_stride_y, int I420Rotate(const uint8* src_y,
const uint8* src_u, int src_stride_u, int src_stride_y,
const uint8* src_v, int src_stride_v, const uint8* src_u,
uint8* dst_y, int dst_stride_y, int src_stride_u,
uint8* dst_u, int dst_stride_u, const uint8* src_v,
uint8* dst_v, int dst_stride_v, int src_stride_v,
int src_width, int src_height, enum RotationMode mode); uint8* dst_y,
int dst_stride_y,
uint8* dst_u,
int dst_stride_u,
uint8* dst_v,
int dst_stride_v,
int src_width,
int src_height,
enum RotationMode mode);
// Rotate NV12 input and store in I420. // Rotate NV12 input and store in I420.
LIBYUV_API LIBYUV_API
int NV12ToI420Rotate(const uint8* src_y, int src_stride_y, int NV12ToI420Rotate(const uint8* src_y,
const uint8* src_uv, int src_stride_uv, int src_stride_y,
uint8* dst_y, int dst_stride_y, const uint8* src_uv,
uint8* dst_u, int dst_stride_u, int src_stride_uv,
uint8* dst_v, int dst_stride_v, uint8* dst_y,
int src_width, int src_height, enum RotationMode mode); int dst_stride_y,
uint8* dst_u,
int dst_stride_u,
uint8* dst_v,
int dst_stride_v,
int src_width,
int src_height,
enum RotationMode mode);
// Rotate a plane by 0, 90, 180, or 270. // Rotate a plane by 0, 90, 180, or 270.
LIBYUV_API LIBYUV_API
int RotatePlane(const uint8* src, int src_stride, int RotatePlane(const uint8* src,
uint8* dst, int dst_stride, int src_stride,
int src_width, int src_height, enum RotationMode mode); uint8* dst,
int dst_stride,
int src_width,
int src_height,
enum RotationMode mode);
// Rotate planes by 90, 180, 270. Deprecated. // Rotate planes by 90, 180, 270. Deprecated.
LIBYUV_API LIBYUV_API
void RotatePlane90(const uint8* src, int src_stride, void RotatePlane90(const uint8* src,
uint8* dst, int dst_stride, int src_stride,
int width, int height); uint8* dst,
int dst_stride,
int width,
int height);
LIBYUV_API LIBYUV_API
void RotatePlane180(const uint8* src, int src_stride, void RotatePlane180(const uint8* src,
uint8* dst, int dst_stride, int src_stride,
int width, int height); uint8* dst,
int dst_stride,
int width,
int height);
LIBYUV_API LIBYUV_API
void RotatePlane270(const uint8* src, int src_stride, void RotatePlane270(const uint8* src,
uint8* dst, int dst_stride, int src_stride,
int width, int height); uint8* dst,
int dst_stride,
int width,
int height);
LIBYUV_API LIBYUV_API
void RotateUV90(const uint8* src, int src_stride, void RotateUV90(const uint8* src,
uint8* dst_a, int dst_stride_a, int src_stride,
uint8* dst_b, int dst_stride_b, uint8* dst_a,
int width, int height); int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width,
int height);
// Rotations for when U and V are interleaved. // Rotations for when U and V are interleaved.
// These functions take one input pointer and // These functions take one input pointer and
// split the data into two buffers while // split the data into two buffers while
// rotating them. Deprecated. // rotating them. Deprecated.
LIBYUV_API LIBYUV_API
void RotateUV180(const uint8* src, int src_stride, void RotateUV180(const uint8* src,
uint8* dst_a, int dst_stride_a, int src_stride,
uint8* dst_b, int dst_stride_b, uint8* dst_a,
int width, int height); int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width,
int height);
LIBYUV_API LIBYUV_API
void RotateUV270(const uint8* src, int src_stride, void RotateUV270(const uint8* src,
uint8* dst_a, int dst_stride_a, int src_stride,
uint8* dst_b, int dst_stride_b, uint8* dst_a,
int width, int height); int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width,
int height);
// The 90 and 270 functions are based on transposes. // The 90 and 270 functions are based on transposes.
// Doing a transpose with reversing the read/write // Doing a transpose with reversing the read/write
// order will result in a rotation by +- 90 degrees. // order will result in a rotation by +- 90 degrees.
// Deprecated. // Deprecated.
LIBYUV_API LIBYUV_API
void TransposePlane(const uint8* src, int src_stride, void TransposePlane(const uint8* src,
uint8* dst, int dst_stride, int src_stride,
int width, int height); uint8* dst,
int dst_stride,
int width,
int height);
LIBYUV_API LIBYUV_API
void TransposeUV(const uint8* src, int src_stride, void TransposeUV(const uint8* src,
uint8* dst_a, int dst_stride_a, int src_stride,
uint8* dst_b, int dst_stride_b, uint8* dst_a,
int width, int height); int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width,
int height);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
......
...@@ -21,9 +21,13 @@ extern "C" { ...@@ -21,9 +21,13 @@ extern "C" {
// Rotate ARGB frame // Rotate ARGB frame
LIBYUV_API LIBYUV_API
int ARGBRotate(const uint8* src_argb, int src_stride_argb, int ARGBRotate(const uint8* src_argb,
uint8* dst_argb, int dst_stride_argb, int src_stride_argb,
int src_width, int src_height, enum RotationMode mode); uint8* dst_argb,
int dst_stride_argb,
int src_width,
int src_height,
enum RotationMode mode);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
......
...@@ -36,7 +36,8 @@ extern "C" { ...@@ -36,7 +36,8 @@ extern "C" {
// The following are available for GCC 32 or 64 bit but not NaCL for 64 bit: // The following are available for GCC 32 or 64 bit but not NaCL for 64 bit:
#if !defined(LIBYUV_DISABLE_X86) && \ #if !defined(LIBYUV_DISABLE_X86) && \
(defined(__i386__) || (defined(__x86_64__) && !defined(__native_client__))) (defined(__i386__) || \
(defined(__x86_64__) && !defined(__native_client__)))
#define HAS_TRANSPOSEWX8_SSSE3 #define HAS_TRANSPOSEWX8_SSSE3
#endif #endif
...@@ -54,64 +55,129 @@ extern "C" { ...@@ -54,64 +55,129 @@ extern "C" {
#endif #endif
#if !defined(LIBYUV_DISABLE_MIPS) && !defined(__native_client__) && \ #if !defined(LIBYUV_DISABLE_MIPS) && !defined(__native_client__) && \
defined(__mips__) && \ defined(__mips__) && defined(__mips_dsp) && (__mips_dsp_rev >= 2)
defined(__mips_dsp) && (__mips_dsp_rev >= 2)
#define HAS_TRANSPOSEWX8_DSPR2 #define HAS_TRANSPOSEWX8_DSPR2
#define HAS_TRANSPOSEUVWX8_DSPR2 #define HAS_TRANSPOSEUVWX8_DSPR2
#endif // defined(__mips__) #endif // defined(__mips__)
void TransposeWxH_C(const uint8* src, int src_stride, void TransposeWxH_C(const uint8* src,
uint8* dst, int dst_stride, int width, int height); int src_stride,
uint8* dst,
void TransposeWx8_C(const uint8* src, int src_stride, int dst_stride,
uint8* dst, int dst_stride, int width); int width,
void TransposeWx8_NEON(const uint8* src, int src_stride, int height);
uint8* dst, int dst_stride, int width);
void TransposeWx8_SSSE3(const uint8* src, int src_stride, void TransposeWx8_C(const uint8* src,
uint8* dst, int dst_stride, int width); int src_stride,
void TransposeWx8_Fast_SSSE3(const uint8* src, int src_stride, uint8* dst,
uint8* dst, int dst_stride, int width); int dst_stride,
void TransposeWx8_DSPR2(const uint8* src, int src_stride, int width);
uint8* dst, int dst_stride, int width); void TransposeWx8_NEON(const uint8* src,
void TransposeWx8_Fast_DSPR2(const uint8* src, int src_stride, int src_stride,
uint8* dst, int dst_stride, int width); uint8* dst,
int dst_stride,
void TransposeWx8_Any_NEON(const uint8* src, int src_stride, int width);
uint8* dst, int dst_stride, int width); void TransposeWx8_SSSE3(const uint8* src,
void TransposeWx8_Any_SSSE3(const uint8* src, int src_stride, int src_stride,
uint8* dst, int dst_stride, int width); uint8* dst,
void TransposeWx8_Fast_Any_SSSE3(const uint8* src, int src_stride, int dst_stride,
uint8* dst, int dst_stride, int width); int width);
void TransposeWx8_Any_DSPR2(const uint8* src, int src_stride, void TransposeWx8_Fast_SSSE3(const uint8* src,
uint8* dst, int dst_stride, int width); int src_stride,
uint8* dst,
void TransposeUVWxH_C(const uint8* src, int src_stride, int dst_stride,
uint8* dst_a, int dst_stride_a, int width);
uint8* dst_b, int dst_stride_b, void TransposeWx8_DSPR2(const uint8* src,
int width, int height); int src_stride,
uint8* dst,
void TransposeUVWx8_C(const uint8* src, int src_stride, int dst_stride,
uint8* dst_a, int dst_stride_a, int width);
uint8* dst_b, int dst_stride_b, int width); void TransposeWx8_Fast_DSPR2(const uint8* src,
void TransposeUVWx8_SSE2(const uint8* src, int src_stride, int src_stride,
uint8* dst_a, int dst_stride_a, uint8* dst,
uint8* dst_b, int dst_stride_b, int width); int dst_stride,
void TransposeUVWx8_NEON(const uint8* src, int src_stride, int width);
uint8* dst_a, int dst_stride_a,
uint8* dst_b, int dst_stride_b, int width); void TransposeWx8_Any_NEON(const uint8* src,
void TransposeUVWx8_DSPR2(const uint8* src, int src_stride, int src_stride,
uint8* dst_a, int dst_stride_a, uint8* dst,
uint8* dst_b, int dst_stride_b, int width); int dst_stride,
int width);
void TransposeUVWx8_Any_SSE2(const uint8* src, int src_stride, void TransposeWx8_Any_SSSE3(const uint8* src,
uint8* dst_a, int dst_stride_a, int src_stride,
uint8* dst_b, int dst_stride_b, int width); uint8* dst,
void TransposeUVWx8_Any_NEON(const uint8* src, int src_stride, int dst_stride,
uint8* dst_a, int dst_stride_a, int width);
uint8* dst_b, int dst_stride_b, int width); void TransposeWx8_Fast_Any_SSSE3(const uint8* src,
void TransposeUVWx8_Any_DSPR2(const uint8* src, int src_stride, int src_stride,
uint8* dst_a, int dst_stride_a, uint8* dst,
uint8* dst_b, int dst_stride_b, int width); int dst_stride,
int width);
void TransposeWx8_Any_DSPR2(const uint8* src,
int src_stride,
uint8* dst,
int dst_stride,
int width);
void TransposeUVWxH_C(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 TransposeUVWx8_C(const uint8* src,
int src_stride,
uint8* dst_a,
int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width);
void TransposeUVWx8_SSE2(const uint8* src,
int src_stride,
uint8* dst_a,
int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width);
void TransposeUVWx8_NEON(const uint8* src,
int src_stride,
uint8* dst_a,
int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width);
void TransposeUVWx8_DSPR2(const uint8* src,
int src_stride,
uint8* dst_a,
int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width);
void TransposeUVWx8_Any_SSE2(const uint8* src,
int src_stride,
uint8* dst_a,
int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width);
void TransposeUVWx8_Any_NEON(const uint8* src,
int src_stride,
uint8* dst_a,
int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width);
void TransposeUVWx8_Any_DSPR2(const uint8* src,
int src_stride,
uint8* dst_a,
int dst_stride_a,
uint8* dst_b,
int dst_stride_b,
int width);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
......
This diff is collapsed.
...@@ -20,25 +20,33 @@ extern "C" { ...@@ -20,25 +20,33 @@ extern "C" {
// Supported filtering. // Supported filtering.
typedef enum FilterMode { typedef enum FilterMode {
kFilterNone = 0, // Point sample; Fastest. kFilterNone = 0, // Point sample; Fastest.
kFilterLinear = 1, // Filter horizontally only. kFilterLinear = 1, // Filter horizontally only.
kFilterBilinear = 2, // Faster than box, but lower quality scaling down. kFilterBilinear = 2, // Faster than box, but lower quality scaling down.
kFilterBox = 3 // Highest quality. kFilterBox = 3 // Highest quality.
} FilterModeEnum; } FilterModeEnum;
// Scale a YUV plane. // Scale a YUV plane.
LIBYUV_API LIBYUV_API
void ScalePlane(const uint8* src, int src_stride, void ScalePlane(const uint8* src,
int src_width, int src_height, int src_stride,
uint8* dst, int dst_stride, int src_width,
int dst_width, int dst_height, int src_height,
uint8* dst,
int dst_stride,
int dst_width,
int dst_height,
enum FilterMode filtering); enum FilterMode filtering);
LIBYUV_API LIBYUV_API
void ScalePlane_16(const uint16* src, int src_stride, void ScalePlane_16(const uint16* src,
int src_width, int src_height, int src_stride,
uint16* dst, int dst_stride, int src_width,
int dst_width, int dst_height, int src_height,
uint16* dst,
int dst_stride,
int dst_width,
int dst_height,
enum FilterMode filtering); enum FilterMode filtering);
// Scales a YUV 4:2:0 image from the src width and height to the // Scales a YUV 4:2:0 image from the src width and height to the
...@@ -52,42 +60,73 @@ void ScalePlane_16(const uint16* src, int src_stride, ...@@ -52,42 +60,73 @@ void ScalePlane_16(const uint16* src, int src_stride,
// Returns 0 if successful. // Returns 0 if successful.
LIBYUV_API LIBYUV_API
int I420Scale(const uint8* src_y, int src_stride_y, int I420Scale(const uint8* src_y,
const uint8* src_u, int src_stride_u, int src_stride_y,
const uint8* src_v, int src_stride_v, const uint8* src_u,
int src_width, int src_height, int src_stride_u,
uint8* dst_y, int dst_stride_y, const uint8* src_v,
uint8* dst_u, int dst_stride_u, int src_stride_v,
uint8* dst_v, int dst_stride_v, int src_width,
int dst_width, int dst_height, 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,
enum FilterMode filtering); enum FilterMode filtering);
LIBYUV_API LIBYUV_API
int I420Scale_16(const uint16* src_y, int src_stride_y, int I420Scale_16(const uint16* src_y,
const uint16* src_u, int src_stride_u, int src_stride_y,
const uint16* src_v, int src_stride_v, const uint16* src_u,
int src_width, int src_height, int src_stride_u,
uint16* dst_y, int dst_stride_y, const uint16* src_v,
uint16* dst_u, int dst_stride_u, int src_stride_v,
uint16* dst_v, int dst_stride_v, int src_width,
int dst_width, int dst_height, int src_height,
uint16* dst_y,
int dst_stride_y,
uint16* dst_u,
int dst_stride_u,
uint16* dst_v,
int dst_stride_v,
int dst_width,
int dst_height,
enum FilterMode filtering); enum FilterMode filtering);
#ifdef __cplusplus #ifdef __cplusplus
// Legacy API. Deprecated. // Legacy API. Deprecated.
LIBYUV_API LIBYUV_API
int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, int Scale(const uint8* src_y,
int src_stride_y, int src_stride_u, int src_stride_v, const uint8* src_u,
int src_width, int src_height, const uint8* src_v,
uint8* dst_y, uint8* dst_u, uint8* dst_v, int src_stride_y,
int dst_stride_y, int dst_stride_u, int dst_stride_v, int src_stride_u,
int dst_width, int dst_height, 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,
LIBYUV_BOOL interpolate); LIBYUV_BOOL interpolate);
// Legacy API. Deprecated. // Legacy API. Deprecated.
LIBYUV_API LIBYUV_API
int ScaleOffset(const uint8* src_i420, int src_width, int src_height, int ScaleOffset(const uint8* src_i420,
uint8* dst_i420, int dst_width, int dst_height, int dst_yoffset, int src_width,
int src_height,
uint8* dst_i420,
int dst_width,
int dst_height,
int dst_yoffset,
LIBYUV_BOOL interpolate); LIBYUV_BOOL interpolate);
// For testing, allow disabling of specialized scalers. // For testing, allow disabling of specialized scalers.
......
...@@ -20,32 +20,52 @@ extern "C" { ...@@ -20,32 +20,52 @@ extern "C" {
#endif #endif
LIBYUV_API LIBYUV_API
int ARGBScale(const uint8* src_argb, int src_stride_argb, int ARGBScale(const uint8* src_argb,
int src_width, int src_height, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb, int src_width,
int dst_width, int dst_height, int src_height,
uint8* dst_argb,
int dst_stride_argb,
int dst_width,
int dst_height,
enum FilterMode filtering); enum FilterMode filtering);
// Clipped scale takes destination rectangle coordinates for clip values. // Clipped scale takes destination rectangle coordinates for clip values.
LIBYUV_API LIBYUV_API
int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, int ARGBScaleClip(const uint8* src_argb,
int src_width, int src_height, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb, int src_width,
int dst_width, int dst_height, int src_height,
int clip_x, int clip_y, int clip_width, int clip_height, uint8* dst_argb,
int dst_stride_argb,
int dst_width,
int dst_height,
int clip_x,
int clip_y,
int clip_width,
int clip_height,
enum FilterMode filtering); enum FilterMode filtering);
// Scale with YUV conversion to ARGB and clipping. // Scale with YUV conversion to ARGB and clipping.
LIBYUV_API LIBYUV_API
int YUVToARGBScaleClip(const uint8* src_y, int src_stride_y, int YUVToARGBScaleClip(const uint8* src_y,
const uint8* src_u, int src_stride_u, int src_stride_y,
const uint8* src_v, int src_stride_v, const uint8* src_u,
int src_stride_u,
const uint8* src_v,
int src_stride_v,
uint32 src_fourcc, uint32 src_fourcc,
int src_width, int src_height, int src_width,
uint8* dst_argb, int dst_stride_argb, int src_height,
uint8* dst_argb,
int dst_stride_argb,
uint32 dst_fourcc, uint32 dst_fourcc,
int dst_width, int dst_height, int dst_width,
int clip_x, int clip_y, int clip_width, int clip_height, int dst_height,
int clip_x,
int clip_y,
int clip_width,
int clip_height,
enum FilterMode filtering); enum FilterMode filtering);
#ifdef __cplusplus #ifdef __cplusplus
......
This diff is collapsed.
...@@ -28,13 +28,13 @@ extern "C" { ...@@ -28,13 +28,13 @@ extern "C" {
// Needs to be a macro otherwise the OS X compiler complains when the kFormat* // Needs to be a macro otherwise the OS X compiler complains when the kFormat*
// constants are used in a switch. // constants are used in a switch.
#ifdef __cplusplus #ifdef __cplusplus
#define FOURCC(a, b, c, d) ( \ #define FOURCC(a, b, c, d) \
(static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \ ((static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \
(static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24)) (static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24))
#else #else
#define FOURCC(a, b, c, d) ( \ #define FOURCC(a, b, c, d) \
((uint32)(a)) | ((uint32)(b) << 8) | /* NOLINT */ \ (((uint32)(a)) | ((uint32)(b) << 8) | /* NOLINT */ \
((uint32)(c) << 16) | ((uint32)(d) << 24)) /* NOLINT */ ((uint32)(c) << 16) | ((uint32)(d) << 24)) /* NOLINT */
#endif #endif
// Some pages discussing FourCC codes: // Some pages discussing FourCC codes:
...@@ -69,7 +69,7 @@ enum FourCC { ...@@ -69,7 +69,7 @@ enum FourCC {
FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'), FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'),
FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'), FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'),
FOURCC_24BG = FOURCC('2', '4', 'B', 'G'), FOURCC_24BG = FOURCC('2', '4', 'B', 'G'),
FOURCC_RAW = FOURCC('r', 'a', 'w', ' '), FOURCC_RAW = FOURCC('r', 'a', 'w', ' '),
FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'), FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'),
FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE. FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE.
FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE. FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE.
...@@ -137,7 +137,7 @@ enum FourCCBpp { ...@@ -137,7 +137,7 @@ enum FourCCBpp {
FOURCC_BPP_ABGR = 32, FOURCC_BPP_ABGR = 32,
FOURCC_BPP_RGBA = 32, FOURCC_BPP_RGBA = 32,
FOURCC_BPP_24BG = 24, FOURCC_BPP_24BG = 24,
FOURCC_BPP_RAW = 24, FOURCC_BPP_RAW = 24,
FOURCC_BPP_RGBP = 16, FOURCC_BPP_RGBP = 16,
FOURCC_BPP_RGBO = 16, FOURCC_BPP_RGBO = 16,
FOURCC_BPP_R444 = 16, FOURCC_BPP_R444 = 16,
...@@ -170,7 +170,7 @@ enum FourCCBpp { ...@@ -170,7 +170,7 @@ enum FourCCBpp {
FOURCC_BPP_CM24 = 24, FOURCC_BPP_CM24 = 24,
// Match any fourcc. // Match any fourcc.
FOURCC_BPP_ANY = 0, // 0 means unknown. FOURCC_BPP_ANY = 0, // 0 means unknown.
}; };
// Converts fourcc aliases into canonical ones. // Converts fourcc aliases into canonical ones.
......
...@@ -32,8 +32,7 @@ LIBYUV_API ...@@ -32,8 +32,7 @@ LIBYUV_API
uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed) { uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed) {
const int kBlockSize = 1 << 15; // 32768; const int kBlockSize = 1 << 15; // 32768;
int remainder; int remainder;
uint32 (*HashDjb2_SSE)(const uint8* src, int count, uint32 seed) = uint32 (*HashDjb2_SSE)(const uint8* src, int count, uint32 seed) = HashDjb2_C;
HashDjb2_C;
#if defined(HAS_HASHDJB2_SSE41) #if defined(HAS_HASHDJB2_SSE41)
if (TestCpuFlag(kCpuHasSSE41)) { if (TestCpuFlag(kCpuHasSSE41)) {
HashDjb2_SSE = HashDjb2_SSE41; HashDjb2_SSE = HashDjb2_SSE41;
...@@ -50,13 +49,13 @@ uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed) { ...@@ -50,13 +49,13 @@ uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed) {
src += kBlockSize; src += kBlockSize;
count -= kBlockSize; count -= kBlockSize;
} }
remainder = (int)(count) & ~15; remainder = (int)count & ~15;
if (remainder) { if (remainder) {
seed = HashDjb2_SSE(src, remainder, seed); seed = HashDjb2_SSE(src, remainder, seed);
src += remainder; src += remainder;
count -= remainder; count -= remainder;
} }
remainder = (int)(count) & 15; remainder = (int)count & 15;
if (remainder) { if (remainder) {
seed = HashDjb2_C(src, remainder, seed); seed = HashDjb2_C(src, remainder, seed);
} }
...@@ -113,7 +112,8 @@ uint32 ARGBDetect(const uint8* argb, int stride_argb, int width, int height) { ...@@ -113,7 +112,8 @@ uint32 ARGBDetect(const uint8* argb, int stride_argb, int width, int height) {
// TODO(fbarchard): Refactor into row function. // TODO(fbarchard): Refactor into row function.
LIBYUV_API LIBYUV_API
uint64 ComputeSumSquareError(const uint8* src_a, const uint8* src_b, uint64 ComputeSumSquareError(const uint8* src_a,
const uint8* src_b,
int count) { int count) {
// SumSquareError returns values 0 to 65535 for each squared difference. // SumSquareError returns values 0 to 65535 for each squared difference.
// Up to 65536 of those can be summed and remain within a uint32. // Up to 65536 of those can be summed and remain within a uint32.
...@@ -142,7 +142,7 @@ uint64 ComputeSumSquareError(const uint8* src_a, const uint8* src_b, ...@@ -142,7 +142,7 @@ uint64 ComputeSumSquareError(const uint8* src_a, const uint8* src_b,
} }
#endif #endif
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for reduction(+: sse) #pragma omp parallel for reduction(+ : sse)
#endif #endif
for (i = 0; i < (count - (kBlockSize - 1)); i += kBlockSize) { for (i = 0; i < (count - (kBlockSize - 1)); i += kBlockSize) {
sse += SumSquareError(src_a + i, src_b + i, kBlockSize); sse += SumSquareError(src_a + i, src_b + i, kBlockSize);
...@@ -162,14 +162,16 @@ uint64 ComputeSumSquareError(const uint8* src_a, const uint8* src_b, ...@@ -162,14 +162,16 @@ uint64 ComputeSumSquareError(const uint8* src_a, const uint8* src_b,
} }
LIBYUV_API LIBYUV_API
uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a, uint64 ComputeSumSquareErrorPlane(const uint8* src_a,
const uint8* src_b, int stride_b, int stride_a,
int width, int height) { const uint8* src_b,
int stride_b,
int width,
int height) {
uint64 sse = 0; uint64 sse = 0;
int h; int h;
// Coalesce rows. // Coalesce rows.
if (stride_a == width && if (stride_a == width && stride_b == width) {
stride_b == width) {
width *= height; width *= height;
height = 1; height = 1;
stride_a = stride_b = 0; stride_a = stride_b = 0;
...@@ -186,10 +188,10 @@ LIBYUV_API ...@@ -186,10 +188,10 @@ LIBYUV_API
double SumSquareErrorToPsnr(uint64 sse, uint64 count) { double SumSquareErrorToPsnr(uint64 sse, uint64 count) {
double psnr; double psnr;
if (sse > 0) { if (sse > 0) {
double mse = (double)(count) / (double)(sse); double mse = (double)count / (double)sse;
psnr = 10.0 * log10(255.0 * 255.0 * mse); psnr = 10.0 * log10(255.0 * 255.0 * mse);
} else { } else {
psnr = kMaxPsnr; // Limit to prevent divide by 0 psnr = kMaxPsnr; // Limit to prevent divide by 0
} }
if (psnr > kMaxPsnr) if (psnr > kMaxPsnr)
...@@ -199,45 +201,53 @@ double SumSquareErrorToPsnr(uint64 sse, uint64 count) { ...@@ -199,45 +201,53 @@ double SumSquareErrorToPsnr(uint64 sse, uint64 count) {
} }
LIBYUV_API LIBYUV_API
double CalcFramePsnr(const uint8* src_a, int stride_a, double CalcFramePsnr(const uint8* src_a,
const uint8* src_b, int stride_b, int stride_a,
int width, int height) { const uint8* src_b,
int stride_b,
int width,
int height) {
const uint64 samples = width * height; const uint64 samples = width * height;
const uint64 sse = ComputeSumSquareErrorPlane(src_a, stride_a, const uint64 sse = ComputeSumSquareErrorPlane(src_a, stride_a, src_b,
src_b, stride_b, stride_b, width, height);
width, height);
return SumSquareErrorToPsnr(sse, samples); return SumSquareErrorToPsnr(sse, samples);
} }
LIBYUV_API LIBYUV_API
double I420Psnr(const uint8* src_y_a, int stride_y_a, double I420Psnr(const uint8* src_y_a,
const uint8* src_u_a, int stride_u_a, int stride_y_a,
const uint8* src_v_a, int stride_v_a, const uint8* src_u_a,
const uint8* src_y_b, int stride_y_b, int stride_u_a,
const uint8* src_u_b, int stride_u_b, const uint8* src_v_a,
const uint8* src_v_b, int stride_v_b, int stride_v_a,
int width, int height) { const uint8* src_y_b,
const uint64 sse_y = ComputeSumSquareErrorPlane(src_y_a, stride_y_a, int stride_y_b,
src_y_b, stride_y_b, const uint8* src_u_b,
width, height); int stride_u_b,
const uint8* src_v_b,
int stride_v_b,
int width,
int height) {
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 width_uv = (width + 1) >> 1;
const int height_uv = (height + 1) >> 1; const int height_uv = (height + 1) >> 1;
const uint64 sse_u = ComputeSumSquareErrorPlane(src_u_a, stride_u_a, const uint64 sse_u = ComputeSumSquareErrorPlane(
src_u_b, stride_u_b, src_u_a, stride_u_a, src_u_b, stride_u_b, width_uv, height_uv);
width_uv, height_uv); const uint64 sse_v = ComputeSumSquareErrorPlane(
const uint64 sse_v = ComputeSumSquareErrorPlane(src_v_a, stride_v_a, src_v_a, stride_v_a, src_v_b, stride_v_b, width_uv, height_uv);
src_v_b, stride_v_b,
width_uv, height_uv);
const uint64 samples = width * height + 2 * (width_uv * height_uv); const uint64 samples = width * height + 2 * (width_uv * height_uv);
const uint64 sse = sse_y + sse_u + sse_v; const uint64 sse = sse_y + sse_u + sse_v;
return SumSquareErrorToPsnr(sse, samples); return SumSquareErrorToPsnr(sse, samples);
} }
static const int64 cc1 = 26634; // (64^2*(.01*255)^2 static const int64 cc1 = 26634; // (64^2*(.01*255)^2
static const int64 cc2 = 239708; // (64^2*(.03*255)^2 static const int64 cc2 = 239708; // (64^2*(.03*255)^2
static double Ssim8x8_C(const uint8* src_a, int stride_a, static double Ssim8x8_C(const uint8* src_a,
const uint8* src_b, int stride_b) { int stride_a,
const uint8* src_b,
int stride_b) {
int64 sum_a = 0; int64 sum_a = 0;
int64 sum_b = 0; int64 sum_b = 0;
int64 sum_sq_a = 0; int64 sum_sq_a = 0;
...@@ -270,12 +280,12 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a, ...@@ -270,12 +280,12 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a,
const int64 ssim_n = (2 * sum_a_x_sum_b + c1) * const int64 ssim_n = (2 * sum_a_x_sum_b + c1) *
(2 * count * sum_axb - 2 * sum_a_x_sum_b + c2); (2 * count * sum_axb - 2 * sum_a_x_sum_b + c2);
const int64 sum_a_sq = sum_a*sum_a; const int64 sum_a_sq = sum_a * sum_a;
const int64 sum_b_sq = sum_b*sum_b; const int64 sum_b_sq = sum_b * sum_b;
const int64 ssim_d = (sum_a_sq + sum_b_sq + c1) * const int64 ssim_d =
(count * sum_sq_a - sum_a_sq + (sum_a_sq + sum_b_sq + c1) *
count * sum_sq_b - sum_b_sq + c2); (count * sum_sq_a - sum_a_sq + count * sum_sq_b - sum_b_sq + c2);
if (ssim_d == 0.0) { if (ssim_d == 0.0) {
return DBL_MAX; return DBL_MAX;
...@@ -288,13 +298,16 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a, ...@@ -288,13 +298,16 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a,
// on the 4x4 pixel grid. Such arrangement allows the windows to overlap // on the 4x4 pixel grid. Such arrangement allows the windows to overlap
// block boundaries to penalize blocking artifacts. // block boundaries to penalize blocking artifacts.
LIBYUV_API LIBYUV_API
double CalcFrameSsim(const uint8* src_a, int stride_a, double CalcFrameSsim(const uint8* src_a,
const uint8* src_b, int stride_b, int stride_a,
int width, int height) { const uint8* src_b,
int stride_b,
int width,
int height) {
int samples = 0; int samples = 0;
double ssim_total = 0; double ssim_total = 0;
double (*Ssim8x8)(const uint8* src_a, int stride_a, double (*Ssim8x8)(const uint8* src_a, int stride_a, const uint8* src_b,
const uint8* src_b, int stride_b) = Ssim8x8_C; int stride_b) = Ssim8x8_C;
// sample point start with each 4x4 location // sample point start with each 4x4 location
int i; int i;
...@@ -314,22 +327,27 @@ double CalcFrameSsim(const uint8* src_a, int stride_a, ...@@ -314,22 +327,27 @@ double CalcFrameSsim(const uint8* src_a, int stride_a,
} }
LIBYUV_API LIBYUV_API
double I420Ssim(const uint8* src_y_a, int stride_y_a, double I420Ssim(const uint8* src_y_a,
const uint8* src_u_a, int stride_u_a, int stride_y_a,
const uint8* src_v_a, int stride_v_a, const uint8* src_u_a,
const uint8* src_y_b, int stride_y_b, int stride_u_a,
const uint8* src_u_b, int stride_u_b, const uint8* src_v_a,
const uint8* src_v_b, int stride_v_b, int stride_v_a,
int width, int height) { const uint8* src_y_b,
const double ssim_y = CalcFrameSsim(src_y_a, stride_y_a, int stride_y_b,
src_y_b, stride_y_b, width, height); const uint8* src_u_b,
int stride_u_b,
const uint8* src_v_b,
int stride_v_b,
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 width_uv = (width + 1) >> 1;
const int height_uv = (height + 1) >> 1; const int height_uv = (height + 1) >> 1;
const double ssim_u = CalcFrameSsim(src_u_a, stride_u_a, const double ssim_u = CalcFrameSsim(src_u_a, stride_u_a, src_u_b, stride_u_b,
src_u_b, stride_u_b,
width_uv, height_uv); width_uv, height_uv);
const double ssim_v = CalcFrameSsim(src_v_a, stride_v_a, const double ssim_v = CalcFrameSsim(src_v_a, stride_v_a, src_v_b, stride_v_b,
src_v_b, stride_v_b,
width_uv, height_uv); width_uv, height_uv);
return ssim_y * 0.8 + 0.1 * (ssim_u + ssim_v); return ssim_y * 0.8 + 0.1 * (ssim_u + ssim_v);
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -24,7 +24,7 @@ static LIBYUV_BOOL ScanEOI(const uint8* sample, size_t sample_size) { ...@@ -24,7 +24,7 @@ static LIBYUV_BOOL ScanEOI(const uint8* sample, size_t sample_size) {
const uint8* it = sample; const uint8* it = sample;
while (it < end) { while (it < end) {
// TODO(fbarchard): scan for 0xd9 instead. // TODO(fbarchard): scan for 0xd9 instead.
it = static_cast<const uint8 *>(memchr(it, 0xff, end - it)); it = static_cast<const uint8*>(memchr(it, 0xff, end - it));
if (it == NULL) { if (it == NULL) {
break; break;
} }
...@@ -68,4 +68,3 @@ LIBYUV_BOOL ValidateJpeg(const uint8* sample, size_t sample_size) { ...@@ -68,4 +68,3 @@ LIBYUV_BOOL ValidateJpeg(const uint8* sample, size_t sample_size) {
} // extern "C" } // extern "C"
} // namespace libyuv } // namespace libyuv
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "../unit_test/unit_test.h"
#include "libyuv/basic_types.h" #include "libyuv/basic_types.h"
#include "libyuv/cpu_id.h" #include "libyuv/cpu_id.h"
#include "libyuv/scale.h" #include "libyuv/scale.h"
#include "libyuv/scale_row.h" #include "libyuv/scale_row.h"
#include "../unit_test/unit_test.h"
namespace libyuv { namespace libyuv {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -24,8 +24,10 @@ typedef unsigned char uint8; ...@@ -24,8 +24,10 @@ typedef unsigned char uint8;
#define UINT8_TYPE_DEFINED #define UINT8_TYPE_DEFINED
#endif #endif
double CalcSSIM(const uint8* org, const uint8* rec, double CalcSSIM(const uint8* org,
const int image_width, const int image_height); const uint8* rec,
const int image_width,
const int image_height);
double CalcLSSIM(double ssim); double CalcLSSIM(double ssim);
......
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