/** encode a value in the given sample by adjusting the amplitude */
static int32_t hdcd_analyze_gen(int32_t sample, unsigned int v, unsigned int maxv)
{
- float sflt = sample, vv = v;
- vv /= maxv;
- if (vv > 1.0) vv = 1.0;
- sflt *= 1.0 + (vv * 18);
- return (int32_t)sflt;
+ static const int r = 18, m = 1024;
+ int64_t s64 = sample;
+ v = m + (v * r * m / maxv);
+ return (int32_t)(s64 * v / m);
}
/** behaves like hdcd_envelope(), but encodes processing information in