diff --git a/dnn/common.h b/dnn/common.h
index b2e9a20799b2497150e6f9d9b48197436ed7f1ac..9510072b82d27c93c8e980d6b973b6e046385fc0 100644
--- a/dnn/common.h
+++ b/dnn/common.h
@@ -12,6 +12,26 @@
 
 float lpc_from_cepstrum(float *lpc, const float *cepstrum);
 
+#define LOG256 5.5451774445f
+static RNN_INLINE float log2_approx(float x)
+{
+   int integer;
+   float frac;
+   union {
+      float f;
+      int i;
+   } in;
+   in.f = x;
+   integer = (in.i>>23)-127;
+   in.i -= integer<<23;
+   frac = in.f - 1.5f;
+   frac = -0.41445418f + frac*(0.95909232f
+          + frac*(-0.33951290f + frac*0.16541097f));
+   return 1+integer+frac;
+}
+
+#define log_approx(x) (0.69315f*log2_approx(x))
+
 static RNN_INLINE float ulaw2lin(float u)
 {
     float s;
@@ -19,7 +39,7 @@ static RNN_INLINE float ulaw2lin(float u)
     u = u - 128;
     s = u >= 0 ? 1 : -1;
     u = fabs(u);
-    return s*scale_1*(exp(u/128.*log(256))-1);
+    return s*scale_1*(exp(u/128.*LOG256)-1);
 }
 
 static RNN_INLINE int lin2ulaw(float x)
@@ -28,7 +48,7 @@ static RNN_INLINE int lin2ulaw(float x)
     float scale = 255.f/32768.f;
     int s = x >= 0 ? 1 : -1;
     x = fabs(x);
-    u = (s*(128*log(1+scale*x)/log(256)));
+    u = (s*(128*log_approx(1+scale*x)/LOG256));
     u = 128 + u;
     if (u < 0) u = 0;
     if (u > 255) u = 255;
diff --git a/dnn/dump_data.c b/dnn/dump_data.c
index 769da9b7ee80f2e816e3fc5807d2f63dbbe447e4..d61de234a639dff9fed51cc08adf8de4389ed282 100644
--- a/dnn/dump_data.c
+++ b/dnn/dump_data.c
@@ -219,7 +219,7 @@ void write_audio(DenoiseState *st, const short *pcm, float noise_std, FILE *file
     /* Excitation out. */
     data[4*i+3] = e;
     /* Simulate error on excitation. */
-    noise = (int)floor(.5 + noise_std*.707*(log((float)rand()/RAND_MAX)-log((float)rand()/RAND_MAX)));
+    noise = (int)floor(.5 + noise_std*.707*(log_approx((float)rand()/RAND_MAX)-log_approx((float)rand()/RAND_MAX)));
     e += noise;
     e = IMIN(255, IMAX(0, e));