]> git.sesse.net Git - ffmpeg/commitdiff
af_hdcd: hdcd_analyze_gen() using int instead of float
authorBurt P <pburt0@gmail.com>
Sat, 3 Sep 2016 09:39:07 +0000 (04:39 -0500)
committerBurt P <pburt0@gmail.com>
Wed, 7 Sep 2016 15:59:18 +0000 (10:59 -0500)
Signed-off-by: Burt P <pburt0@gmail.com>
libavfilter/af_hdcd.c

index a8a3d59448debd3e7708771eb01a9189a749f6c7..96d5a0faf1451f01a45686eb4f23e40300084b5e 100644 (file)
@@ -1318,11 +1318,10 @@ static void hdcd_analyze_prepare(hdcd_state *state, int32_t *samples, int count,
 /** 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