#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include "experimental/lowp-basic/QMath.h"
Go to the source code of this file.
|
static float | golden_lerp (float t, int16_t a, int16_t b) |
|
template<int logPixelScale> |
static int16_t | saturating_lerp (float t, int16_t a, int16_t b) |
|
template<int logPixelScale> |
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) |
|
template<int logPixelScale> |
static int16_t | balanced_lerp (float t, int16_t a, int16_t b) |
|
template<typename Lerp > |
static Stats | check_lerp (Lerp lerp) |
|
int | main () |
|
◆ balanced_lerp()
template<
int logPixelScale>
static int16_t balanced_lerp |
( |
float |
t, |
|
|
int16_t |
a, |
|
|
int16_t |
b |
|
) |
| |
|
static |
Definition at line 72 of file lerp-study.cpp.
72 {
73 const int16_t half = 1 << logPixelScale;
74
75 Q15 qt (
floor(t * 65536.0f - 32768.0f + 0.5f));
76
77 Q15 qw ((
b -
a) << logPixelScale);
78 Q15 qm ((
a +
b) << logPixelScale);
80
81 return (answer[0] + half) >> (logPixelScale + 1);
82}
static I16 simulate_ssse3_mm_mulhrs_epi16(I16 a, I16 b)
SIN Vec< N, float > floor(const Vec< N, float > &x)
◆ check_lerp()
template<typename Lerp >
static Stats check_lerp |
( |
Lerp |
lerp | ) |
|
|
static |
Definition at line 85 of file lerp-study.cpp.
85 {
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);
94 }
96}
SkPoint lerp(const SkPoint &a, const SkPoint &b, float t)
static float golden_lerp(float t, int16_t a, int16_t b)
◆ full_res_lerp()
static int16_t full_res_lerp |
( |
float |
t, |
|
|
int16_t |
a, |
|
|
int16_t |
b |
|
) |
| |
|
static |
Definition at line 62 of file lerp-study.cpp.
62 {
63 int32_t ft(
floor(t * 65536.0f + 0.5f));
64
65 int32_t temp = ft * (
b -
a) +
a * 65536;
66 int32_t rounded = temp + 32768;
67 return rounded >> 16;
68}
◆ golden_lerp()
static float golden_lerp |
( |
float |
t, |
|
|
int16_t |
a, |
|
|
int16_t |
b |
|
) |
| |
|
static |
◆ main()
Definition at line 98 of file lerp-study.cpp.
98 {
100
101 printf(
"\nUsing full_res_lerp...\n");
104
105 printf(
"\nUsing vqrdmulhq_s16...\n");
108
109 printf(
"\nUsing mm_mulhrs_epi16...\n");
112
113 printf(
"\nInterval [-1, 1) mm_mulhrs_epi16...\n");
116
118 return 0;
119}
static int16_t full_res_lerp(float t, int16_t a, int16_t b)
static Stats check_lerp(Lerp lerp)
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
◆ saturating_lerp()
template<
int logPixelScale>
static int16_t saturating_lerp |
( |
float |
t, |
|
|
int16_t |
a, |
|
|
int16_t |
b |
|
) |
| |
|
static |
Definition at line 41 of file lerp-study.cpp.
41 {
42 const int16_t half = 1 << (logPixelScale - 1);
44 Q15 qa(
a << logPixelScale);
45 Q15 qb(
b << logPixelScale);
46
48 return (answer[0] + half) >> logPixelScale;
49}
static Q15 simulate_neon_vqrdmulhq_s16(Q15 a, Q15 b)
◆ ssse3_lerp()
template<
int logPixelScale>
static int16_t ssse3_lerp |
( |
float |
t, |
|
|
int16_t |
a, |
|
|
int16_t |
b |
|
) |
| |
|
static |
Definition at line 52 of file lerp-study.cpp.
52 {
53 const int16_t half = 1 << (logPixelScale - 1);
55 Q15 qa(
a << logPixelScale);
56 Q15 qb(
b << logPixelScale);
57
59 return (answer[0] + half) >> logPixelScale;
60}