Issue #2101 - Part 3: Update libyuv

Updated to version 1861, git revision 88b050f337cc0ca2a51800fe7bf4737222c87344 from
https://chromium.googlesource.com/libyuv/libyuv/
This commit is contained in:
u3shit 2023-02-24 21:56:43 +01:00 • committed by roytam1
commit a4d1f57b9e
222 changed files with 111006 additions and 37106 deletions

View file

@ -11,11 +11,11 @@
#ifndef UNIT_TEST_UNIT_TEST_H_ // NOLINT
#define UNIT_TEST_UNIT_TEST_H_
#ifdef WIN32
#include <stddef.h> // For NULL
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include <gtest/gtest.h>
@ -36,6 +36,9 @@ static __inline int Abs(int v) {
return v >= 0 ? v : -v;
}
static __inline float FAbs(float v) {
return v >= 0 ? v : -v;
}
#define OFFBY 0
// Scaling uses 16.16 fixed point to step thru the source image, so a
@ -54,8 +57,10 @@ static __inline int Abs(int v) {
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) {
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");
@ -64,16 +69,26 @@ static inline bool SizeValid(int src_width, int src_height,
return true;
}
#define align_buffer_page_end(var, size) \
uint8* var; \
uint8* var##_mem; \
var##_mem = reinterpret_cast<uint8*>(malloc(((size) + 4095 + 63) & ~4095)); \
var = (uint8*)((intptr_t)(var##_mem + (((size) + 4095 + 63) & ~4095) - \
(size)) & ~63);
#define align_buffer_page_end(var, size) \
uint8_t* var##_mem = \
reinterpret_cast<uint8_t*>(malloc(((size) + 4095 + 63) & ~4095)); \
uint8_t* var = reinterpret_cast<uint8_t*>( \
(intptr_t)(var##_mem + (((size) + 4095 + 63) & ~4095) - (size)) & ~63)
#define free_aligned_buffer_page_end(var) \
free(var##_mem); \
var = 0;
free(var##_mem); \
var = NULL
#define align_buffer_page_end_16(var, size) \
uint8_t* var##_mem = \
reinterpret_cast<uint8_t*>(malloc(((size)*2 + 4095 + 63) & ~4095)); \
uint16_t* var = reinterpret_cast<uint16_t*>( \
(intptr_t)(var##_mem + (((size)*2 + 4095 + 63) & ~4095) - (size)*2) & \
~63)
#define free_aligned_buffer_page_end_16(var) \
free(var##_mem); \
var = NULL
#ifdef WIN32
static inline double get_time() {
@ -107,10 +122,13 @@ inline int fastrand() {
return static_cast<int>((fastrand_seed >> 16) & 0xffff);
}
static inline void MemRandomize(uint8* dst, int64 len) {
int64 i;
// ubsan fails if dst is unaligned unless we use uint8
static inline void MemRandomize(uint8_t* dst, int64_t len) {
int64_t i;
for (i = 0; i < len - 1; i += 2) {
*reinterpret_cast<uint16*>(dst) = fastrand();
int r = fastrand();
dst[0] = static_cast<uint8_t>(r);
dst[1] = static_cast<uint8_t>(r >> 8);
dst += 2;
}
for (; i < len; ++i) {
@ -123,12 +141,11 @@ class LibYUVColorTest : public ::testing::Test {
LibYUVColorTest();
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVConvertTest : public ::testing::Test {
@ -136,12 +153,11 @@ class LibYUVConvertTest : public ::testing::Test {
LibYUVConvertTest();
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVScaleTest : public ::testing::Test {
@ -149,12 +165,11 @@ class LibYUVScaleTest : public ::testing::Test {
LibYUVScaleTest();
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVRotateTest : public ::testing::Test {
@ -162,12 +177,11 @@ class LibYUVRotateTest : public ::testing::Test {
LibYUVRotateTest();
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVPlanarTest : public ::testing::Test {
@ -175,12 +189,11 @@ class LibYUVPlanarTest : public ::testing::Test {
LibYUVPlanarTest();
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVBaseTest : public ::testing::Test {
@ -188,12 +201,23 @@ class LibYUVBaseTest : public ::testing::Test {
LibYUVBaseTest();
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
class LibYUVCompareTest : public ::testing::Test {
protected:
LibYUVCompareTest();
int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
};
#endif // UNIT_TEST_UNIT_TEST_H_ NOLINT