diff --git a/libavcodec/eval.c b/libavcodec/eval.c
index 832af28e62df0f4354bf0d0a31834c65222c445e..bcaf4f59b27bb802a9172b6805268a208baa2eb2 100644
--- a/libavcodec/eval.c
+++ b/libavcodec/eval.c
@@ -32,6 +32,10 @@
   #define NAN 0
 #endif
 
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 #define STACK_SIZE 100
 
 typedef struct Parser{
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index fd55367a50ba08fd14dab315d058acd0359b9767..77af3c93c429f348af0705219e4f716d8165d127 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -26,6 +26,14 @@
 #undef NDEBUG // allways check asserts, the speed effect is far too small to disable them
 #include <assert.h>
 
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#ifndef M_E
+#define M_E 2.718281828
+#endif
+
 static int init_pass2(MpegEncContext *s);
 static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num);