21 void log(int16_t golden, int16_t candidate) {
22 int diff = candidate - golden;
37 return (1.0f - t) *
a + t *
b;
40template <
int logPixelScale>
42 const int16_t half = 1 << (logPixelScale - 1);
44 Q15 qa(
a << logPixelScale);
45 Q15 qb(
b << logPixelScale);
48 return (answer[0] + half) >> logPixelScale;
51template <
int logPixelScale>
53 const int16_t half = 1 << (logPixelScale - 1);
55 Q15 qa(
a << logPixelScale);
56 Q15 qb(
b << logPixelScale);
59 return (answer[0] + half) >> logPixelScale;
63 int32_t ft(
floor(t * 65536.0f + 0.5f));
65 int32_t temp = ft * (
b -
a) +
a * 65536;
66 int32_t rounded = temp + 32768;
71template <
int logPixelScale>
73 const int16_t half = 1 << logPixelScale;
75 Q15 qt (
floor(t * 65536.0f - 32768.0f + 0.5f));
77 Q15 qw ((
b -
a) << logPixelScale);
78 Q15 qm ((
a +
b) << logPixelScale);
81 return (answer[0] + half) >> (logPixelScale + 1);
84template <
typename Lerp>
87 for (
float t = 0; t < 1.0f - 1.0f / 65536.0f ; t += 1.0f/65536.0f)
88 for (
int a = 255;
a >= 0;
a--)
89 for (
int b = 255;
b >= 0;
b--) {
91 int16_t golden =
floor(l + 0.5f);
92 int16_t candidate =
lerp(t,
a,
b);
93 stats.log(golden, candidate);
101 printf(
"\nUsing full_res_lerp...\n");
105 printf(
"\nUsing vqrdmulhq_s16...\n");
109 printf(
"\nUsing mm_mulhrs_epi16...\n");
113 printf(
"\nInterval [-1, 1) mm_mulhrs_epi16...\n");
SkPoint lerp(const SkPoint &a, const SkPoint &b, float t)
static I16 simulate_ssse3_mm_mulhrs_epi16(I16 a, I16 b)
static Q15 simulate_neon_vqrdmulhq_s16(Q15 a, Q15 b)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
static int16_t ssse3_lerp(float t, int16_t a, int16_t b)
static int16_t full_res_lerp(float t, int16_t a, int16_t b)
static int16_t saturating_lerp(float t, int16_t a, int16_t b)
static int16_t balanced_lerp(float t, int16_t a, int16_t b)
static Stats check_lerp(Lerp lerp)
static float golden_lerp(float t, int16_t a, int16_t b)
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
SK_API sk_sp< PrecompileColorFilter > Lerp(SkSpan< const sk_sp< PrecompileColorFilter > > dstOptions, SkSpan< const sk_sp< PrecompileColorFilter > > srcOptions)
SIN Vec< N, float > floor(const Vec< N, float > &x)
void log(int16_t golden, int16_t candidate)