This commit is contained in:
Mike Jerris
2016-09-27 13:08:00 -04:00
parent d6bf6705de
commit 93591e2f47
93 changed files with 3194 additions and 2023 deletions

View File

@@ -22,18 +22,54 @@
#include "libyuv/basic_types.h"
#ifndef SIMD_ALIGNED
#if defined(_MSC_VER) && !defined(__CLR_VER)
#define SIMD_ALIGNED(var) __declspec(align(16)) var
#elif defined(__GNUC__) && !defined(__pnacl__)
#define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
#else
#define SIMD_ALIGNED(var) var
#endif
#endif
static __inline int Abs(int v) {
return v >= 0 ? v : -v;
}
#define OFFBY 0
// Scaling uses 16.16 fixed point to step thru the source image, so a
// maximum size of 32767.999 can be expressed. 32768 is valid because
// the step is 1 beyond the image but not used.
// Destination size is mainly constrained by valid scale step not the
// absolute size, so it may be possible to relax the destination size
// constraint.
// Source size is unconstrained for most specialized scalers. e.g.
// An image of 65536 scaled to half size would be valid. The test
// could be relaxed for special scale factors.
// If this test is removed, the scaling function should gracefully
// fail with a return code. The test could be changed to know that
// libyuv failed in a controlled way.
static const int kMaxWidth = 32768;
static const int kMaxHeight = 32768;
static inline bool SizeValid(int src_width, int src_height,
int dst_width, int dst_height) {
if (src_width > kMaxWidth || src_height > kMaxHeight ||
dst_width > kMaxWidth || dst_height > kMaxHeight) {
printf("Warning - size too large to test. Skipping\n");
return false;
}
return true;
}
#define align_buffer_page_end(var, size) \
uint8* var; \
uint8* var##_mem; \
var##_mem = reinterpret_cast<uint8*>(malloc((((size) + 4095) & ~4095) + \
OFFBY)); \
var = var##_mem + (-(size) & 4095) + OFFBY;
var##_mem = reinterpret_cast<uint8*>(malloc(((size) + 4095 + 63) & ~4095)); \
var = (uint8*)((intptr_t)(var##_mem + (((size) + 4095 + 63) & ~4095) - \
(size)) & ~63);
#define free_aligned_buffer_page_end(var) \
free(var##_mem); \
@@ -55,6 +91,16 @@ static inline double get_time() {
}
#endif
#ifndef SIMD_ALIGNED
#if defined(_MSC_VER) && !defined(__CLR_VER)
#define SIMD_ALIGNED(var) __declspec(align(16)) var
#elif defined(__GNUC__) && !defined(__pnacl__)
#define SIMD_ALIGNED(var) var __attribute__((aligned(16)))
#else
#define SIMD_ALIGNED(var) var
#endif
#endif
extern unsigned int fastrand_seed;
inline int fastrand() {
fastrand_seed = fastrand_seed * 214013u + 2531011u;