From 4db89c82bb756e963e4a9c1d64f59f0c0e41d841 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Tue, 31 May 2011 22:14:09 -0700 Subject: [PATCH] convert M_PI to G_PI, for msvc --- gst/audioresample/resample.c | 8 ++------ gst/audiotestsrc/gstaudiotestsrc.c | 24 ++++++++---------------- gst/videoscale/vs_4tap.c | 4 ++-- gst/videotestsrc/generate_sine_table.c | 4 ++-- gst/videotestsrc/videotestsrc.c | 4 ++-- tests/icles/test-xoverlay.c | 6 +++--- 6 files changed, 19 insertions(+), 31 deletions(-) diff --git a/gst/audioresample/resample.c b/gst/audioresample/resample.c index 7d42f0e..a10c9f6 100644 --- a/gst/audioresample/resample.c +++ b/gst/audioresample/resample.c @@ -97,10 +97,6 @@ speex_free (void *ptr) #include -#ifndef M_PI -#define M_PI 3.14159263 -#endif - #ifdef FIXED_POINT #define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x))) #else @@ -323,7 +319,7 @@ sinc (float cutoff, float x, int N, struct FuncDef *window_func) else if (fabs (x) > .5f * N) return 0; /*FIXME: Can it really be any slower than this? */ - return WORD2INT (32768. * cutoff * sin (M_PI * xx) / (M_PI * xx) * + return WORD2INT (32768. * cutoff * sin (G_PI * xx) / (G_PI * xx) * compute_func (fabs (2. * x / N), window_func)); } #else @@ -346,7 +342,7 @@ sinc (float cutoff, float x, int N, struct FuncDef *window_func) else if (fabs (x) > .5 * N) return 0; /*FIXME: Can it really be any slower than this? */ - return cutoff * sin (M_PI * xx) / (M_PI * xx) * compute_func (fabs (2. * x / + return cutoff * sin (G_PI * xx) / (G_PI * xx) * compute_func (fabs (2. * x / N), window_func); } #endif diff --git a/gst/audiotestsrc/gstaudiotestsrc.c b/gst/audiotestsrc/gstaudiotestsrc.c index 030322e..91ace92 100644 --- a/gst/audiotestsrc/gstaudiotestsrc.c +++ b/gst/audiotestsrc/gstaudiotestsrc.c @@ -48,15 +48,7 @@ #include "gstaudiotestsrc.h" -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#ifndef M_PI_2 -#define M_PI_2 1.57079632679489661923 -#endif - -#define M_PI_M2 ( M_PI + M_PI ) +#define M_PI_M2 ( G_PI + G_PI ) GST_DEBUG_CATEGORY_STATIC (audio_test_src_debug); #define GST_CAT_DEFAULT audio_test_src_debug @@ -479,7 +471,7 @@ gst_audio_test_src_create_square_##type (GstAudioTestSrc * src, g##type * sample src->accumulator -= M_PI_M2; \ \ for (c = 0; c < src->channels; ++c) { \ - samples[i++] = (g##type) ((src->accumulator < M_PI) ? amp : -amp); \ + samples[i++] = (g##type) ((src->accumulator < G_PI) ? amp : -amp); \ } \ } \ } @@ -504,7 +496,7 @@ gst_audio_test_src_create_saw_##type (GstAudioTestSrc * src, g##type * samples) gdouble step, amp; \ \ step = M_PI_M2 * src->freq / src->samplerate; \ - amp = (src->volume * scale) / M_PI; \ + amp = (src->volume * scale) / G_PI; \ \ i = 0; \ while (i < (src->generate_samples_per_buffer * src->channels)) { \ @@ -512,7 +504,7 @@ gst_audio_test_src_create_saw_##type (GstAudioTestSrc * src, g##type * samples) if (src->accumulator >= M_PI_M2) \ src->accumulator -= M_PI_M2; \ \ - if (src->accumulator < M_PI) { \ + if (src->accumulator < G_PI) { \ for (c = 0; c < src->channels; ++c) \ samples[i++] = (g##type) (src->accumulator * amp); \ } else { \ @@ -542,7 +534,7 @@ gst_audio_test_src_create_triangle_##type (GstAudioTestSrc * src, g##type * samp gdouble step, amp; \ \ step = M_PI_M2 * src->freq / src->samplerate; \ - amp = (src->volume * scale) / M_PI_2; \ + amp = (src->volume * scale) / G_PI_2; \ \ i = 0; \ while (i < (src->generate_samples_per_buffer * src->channels)) { \ @@ -550,12 +542,12 @@ gst_audio_test_src_create_triangle_##type (GstAudioTestSrc * src, g##type * samp if (src->accumulator >= M_PI_M2) \ src->accumulator -= M_PI_M2; \ \ - if (src->accumulator < (M_PI * 0.5)) { \ + if (src->accumulator < (G_PI_2)) { \ for (c = 0; c < src->channels; ++c) \ samples[i++] = (g##type) (src->accumulator * amp); \ - } else if (src->accumulator < (M_PI * 1.5)) { \ + } else if (src->accumulator < (G_PI * 1.5)) { \ for (c = 0; c < src->channels; ++c) \ - samples[i++] = (g##type) ((src->accumulator - M_PI) * -amp); \ + samples[i++] = (g##type) ((src->accumulator - G_PI) * -amp); \ } else { \ for (c = 0; c < src->channels; ++c) \ samples[i++] = (g##type) ((M_PI_M2 - src->accumulator) * -amp); \ diff --git a/gst/videoscale/vs_4tap.c b/gst/videoscale/vs_4tap.c index f983df2..93024bc 100644 --- a/gst/videoscale/vs_4tap.c +++ b/gst/videoscale/vs_4tap.c @@ -52,12 +52,12 @@ vs_4tap_func (double x) #if 0 if (x == 0) return 1; - return sin (M_PI * x) / (M_PI * x) * (1 - 0.25 * x * x); + return sin (G_PI * x) / (G_PI * x) * (1 - 0.25 * x * x); #endif #if 1 if (x == 0) return 1; - return sin (M_PI * x) / (M_PI * x); + return sin (G_PI * x) / (G_PI * x); #endif } diff --git a/gst/videotestsrc/generate_sine_table.c b/gst/videotestsrc/generate_sine_table.c index 432e1a5..11d17af 100644 --- a/gst/videotestsrc/generate_sine_table.c +++ b/gst/videotestsrc/generate_sine_table.c @@ -1,14 +1,14 @@ #include #include - +#include static int get_value (int i) { int x; - x = floor (256 * (0.5 + 0.5 * sin (i * 2 * M_PI / 256))); + x = floor (256 * (0.5 + 0.5 * sin (i * 2 * G_PI / 256))); if (x > 255) x = 255; return x; diff --git a/gst/videotestsrc/videotestsrc.c b/gst/videotestsrc/videotestsrc.c index 9973507..ecc83f8 100644 --- a/gst/videotestsrc/videotestsrc.c +++ b/gst/videotestsrc/videotestsrc.c @@ -1561,8 +1561,8 @@ gst_video_test_src_ball (GstVideoTestSrc * v, unsigned char *dest, int w, int h) fourcc->paint_setup (p, dest); - x = radius + (0.5 + 0.5 * sin (2 * M_PI * t / 200)) * (w - 2 * radius); - y = radius + (0.5 + 0.5 * sin (2 * M_PI * sqrt (2) * t / 200)) * (h - + x = radius + (0.5 + 0.5 * sin (2 * G_PI * t / 200)) * (w - 2 * radius); + y = radius + (0.5 + 0.5 * sin (2 * G_PI * sqrt (2) * t / 200)) * (h - 2 * radius); for (i = 0; i < h; i++) { diff --git a/tests/icles/test-xoverlay.c b/tests/icles/test-xoverlay.c index c129b41..b1b9d92 100644 --- a/tests/icles/test-xoverlay.c +++ b/tests/icles/test-xoverlay.c @@ -64,8 +64,8 @@ animate_render_rect (gpointer user_data) gdouble c = cos (2.0 * anim_state.a); anim_state.a += anim_state.p; - if (anim_state.a > (M_PI + M_PI)) - anim_state.a -= (M_PI + M_PI); + if (anim_state.a > (G_PI + G_PI)) + anim_state.a -= (G_PI + G_PI); r->w = anim_state.w / 2; r->x = (r->w - (r->w / 2)) + c * (r->w / 2); @@ -223,7 +223,7 @@ main (gint argc, gchar ** argv) anim_state.w = 320; anim_state.h = 240; anim_state.a = 0.0; - anim_state.p = (M_PI + M_PI) / 200.0; + anim_state.p = (G_PI + G_PI) / 200.0; handle_resize_cb (video_window, NULL, sink); g_signal_connect (video_window, "configure-event", -- 2.7.4