None
None
int pow4(int in, int curve) __attribute__((noinline)) {
float x = int2f(in);
// Transform curve param to float in 0 - 1 range
float a = int2f(curve << 21);
// Reverse curve param
a = 1 - a;
// Interpolate between exp-like and log-like curves (without using pow())
// With thanks to Johannes for code
float outf = a * (x * x * x * x) +
(1 - a) * (1 - (1 - x) * (1 - x) * (1 - x) * (1 - x));
return f2int(outf);
}
float int2f(int32_t val) __attribute__((noinline)) {
return val * (float)(1.0f / (1 << 27));
}
int32_t f2int(float val) __attribute__((noinline)) {
return (int)(val * (float)(1 << 27));
}
int scale(int in, int hi, int lo) __attribute__((noinline)) {
return (___SMMUL((((hi << 21) - (lo << 21)) >> 1), in) << 6) + (lo << 21);
}