diff --git a/gst/moodbar/CMakeLists.txt b/gst/moodbar/CMakeLists.txt index 222c81f9c..dc3934b7b 100644 --- a/gst/moodbar/CMakeLists.txt +++ b/gst/moodbar/CMakeLists.txt @@ -25,5 +25,5 @@ target_link_libraries(gstmoodbar ${GLIB_LIBRARIES} ${GSTREAMER_LIBRARIES} ${GSTREAMER_BASE_LIBRARIES} - ${FFTW3_FFTWF_LIBRARY} + ${FFTW3_FFTW_LIBRARY} ) diff --git a/gst/moodbar/gstfftwspectrum.c b/gst/moodbar/gstfftwspectrum.c index f6e2427a5..8b32e93b8 100644 --- a/gst/moodbar/gstfftwspectrum.c +++ b/gst/moodbar/gstfftwspectrum.c @@ -107,7 +107,7 @@ static GstStateChangeReturn gst_fftwspectrum_change_state (GstElement *element, GstStateChange transition); -#define OUTPUT_SIZE(conv) (((conv)->size/2+1)*sizeof(fftwf_complex)) +#define OUTPUT_SIZE(conv) (((conv)->size/2+1)*sizeof(fftw_complex)) /***************************************************************/ @@ -275,11 +275,11 @@ static void free_fftw_data (GstFFTWSpectrum *conv) { if(conv->fftw_plan != NULL) - fftwf_destroy_plan (conv->fftw_plan); + fftw_destroy_plan (conv->fftw_plan); if(conv->fftw_in != NULL) - fftwf_free (conv->fftw_in); + fftw_free (conv->fftw_in); if(conv->fftw_out != NULL) - fftwf_free (conv->fftw_out); + fftw_free (conv->fftw_out); conv->fftw_in = NULL; conv->fftw_out = NULL; @@ -294,8 +294,8 @@ alloc_fftw_data (GstFFTWSpectrum *conv) GST_DEBUG ("Allocating data for size = %d and step = %d", conv->size, conv->step); - conv->fftw_in = (float *) fftwf_malloc (sizeof(float) * conv->size); - conv->fftw_out = (float *) fftwf_malloc (OUTPUT_SIZE (conv)); + conv->fftw_in = (double *) fftw_malloc (sizeof(double) * conv->size); + conv->fftw_out = (double *) fftw_malloc (OUTPUT_SIZE (conv)); /* We use the simplest real-to-complex algorithm, which takes n real * inputs and returns floor(n/2) + 1 complex outputs (the other n/2 @@ -306,8 +306,8 @@ alloc_fftw_data (GstFFTWSpectrum *conv) static GStaticMutex mutex = G_STATIC_MUTEX_INIT; g_static_mutex_lock(&mutex); conv->fftw_plan - = fftwf_plan_dft_r2c_1d(conv->size, conv->fftw_in, - (fftwf_complex *) conv->fftw_out, + = fftw_plan_dft_r2c_1d(conv->size, conv->fftw_in, + (fftw_complex *) conv->fftw_out, conv->hi_q ? FFTW_MEASURE : FFTW_ESTIMATE); g_static_mutex_unlock(&mutex); } @@ -504,7 +504,7 @@ gst_fftwspectrum_change_state (GstElement * element, alloc_fftw_data (conv); break; case GST_STATE_CHANGE_READY_TO_PAUSED: - conv->samples = (gfloat *) g_malloc (sizeof(gfloat)); + conv->samples = (gdouble *) g_malloc (sizeof(gdouble)); conv->numsamples = 0; conv->timestamp = 0; conv->offset = 0; @@ -545,13 +545,13 @@ gst_fftwspectrum_change_state (GstElement * element, static void push_samples (GstFFTWSpectrum *conv, GstBuffer *buf) { - gint newsamples = GST_BUFFER_SIZE (buf) / sizeof (gfloat); + gint newsamples = GST_BUFFER_SIZE (buf) / sizeof (gdouble); gint oldsamples = conv->numsamples; conv->numsamples += newsamples; - conv->samples = g_realloc (conv->samples, conv->numsamples * sizeof (gfloat)); + conv->samples = g_realloc (conv->samples, conv->numsamples * sizeof (gdouble)); memcpy (&conv->samples[oldsamples], GST_BUFFER_DATA (buf), - newsamples * sizeof (gfloat)); + newsamples * sizeof (gdouble)); /* GST_LOG ("Added %d samples", newsamples); */ } @@ -562,12 +562,12 @@ push_samples (GstFFTWSpectrum *conv, GstBuffer *buf) static void shift_samples (GstFFTWSpectrum *conv, gint toshift) { - gfloat *oldsamples = conv->samples; + gdouble *oldsamples = conv->samples; conv->numsamples -= toshift; - conv->samples = g_malloc (MAX (conv->numsamples, 1) * sizeof (float)); + conv->samples = g_malloc (MAX (conv->numsamples, 1) * sizeof (double)); memcpy (conv->samples, &oldsamples[toshift], - conv->numsamples * sizeof (gfloat)); + conv->numsamples * sizeof (gdouble)); g_free (oldsamples); /* Fix the timestamp and offset */ @@ -613,8 +613,8 @@ gst_fftwspectrum_chain (GstPad * pad, GstBuffer * buf) = gst_util_uint64_scale_int (GST_SECOND, conv->step, conv->rate); /* Do the Fourier transform */ - memcpy (conv->fftw_in, conv->samples, conv->size * sizeof (float)); - fftwf_execute (conv->fftw_plan); + memcpy (conv->fftw_in, conv->samples, conv->size * sizeof (double)); + fftw_execute (conv->fftw_plan); { /* Normalize */ gint i; gfloat root = sqrtf (conv->size); diff --git a/gst/moodbar/gstfftwspectrum.h b/gst/moodbar/gstfftwspectrum.h index 8e72ae553..fc7647e7c 100644 --- a/gst/moodbar/gstfftwspectrum.h +++ b/gst/moodbar/gstfftwspectrum.h @@ -41,15 +41,15 @@ struct _GstFFTWSpectrum gint rate, size, step; /* Actual queued (incoming) stream */ - gfloat *samples; + gdouble *samples; gint numsamples; GstClockTime timestamp; /* Timestamp of the first sample */ guint64 offset; /* Offset of the first sample */ /* State data for fftw */ - float *fftw_in; - float *fftw_out; - fftwf_plan fftw_plan; + double *fftw_in; + double *fftw_out; + fftw_plan fftw_plan; /* Properties */ gint32 def_size, def_step; diff --git a/gst/moodbar/gstmoodbar.c b/gst/moodbar/gstmoodbar.c index 7954328ab..da2f2e7b0 100644 --- a/gst/moodbar/gstmoodbar.c +++ b/gst/moodbar/gstmoodbar.c @@ -386,9 +386,9 @@ gst_moodbar_change_state (GstElement *element, GstStateChange transition) calc_barkband_table (mood); break; case GST_STATE_CHANGE_READY_TO_PAUSED: - mood->r = (gfloat *) g_malloc (FRAME_CHUNK * sizeof(gfloat)); - mood->g = (gfloat *) g_malloc (FRAME_CHUNK * sizeof(gfloat)); - mood->b = (gfloat *) g_malloc (FRAME_CHUNK * sizeof(gfloat)); + mood->r = (gdouble *) g_malloc (FRAME_CHUNK * sizeof(gdouble)); + mood->g = (gdouble *) g_malloc (FRAME_CHUNK * sizeof(gdouble)); + mood->b = (gdouble *) g_malloc (FRAME_CHUNK * sizeof(gdouble)); mood->numframes = 0; break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: @@ -438,11 +438,11 @@ allocate_another_frame (GstMoodbar *mood) if(mood->numframes % FRAME_CHUNK == 0) { - guint size = (mood->numframes + FRAME_CHUNK) * sizeof (gfloat); + guint size = (mood->numframes + FRAME_CHUNK) * sizeof (gdouble); - mood->r = (gfloat *) g_realloc (mood->r, size); - mood->g = (gfloat *) g_realloc (mood->g, size); - mood->b = (gfloat *) g_realloc (mood->b, size); + mood->r = (gdouble *) g_realloc (mood->r, size); + mood->g = (gdouble *) g_realloc (mood->g, size); + mood->b = (gdouble *) g_realloc (mood->b, size); if (mood->r == NULL || mood->g == NULL || mood->b == NULL) return FALSE; @@ -461,17 +461,17 @@ gst_moodbar_chain (GstPad *pad, GstBuffer *buf) { GstMoodbar *mood = GST_MOODBAR (gst_pad_get_parent (pad)); guint i; - gfloat amplitudes[24], rgb[3] = {0.f, 0.f, 0.f}; - gfloat *out, real, imag; + gdouble amplitudes[24], rgb[3] = {0.f, 0.f, 0.f}; + gdouble *out, real, imag; guint numfreqs = NUMFREQS (mood); - if (GST_BUFFER_SIZE (buf) != numfreqs * sizeof (gfloat) * 2) + if (GST_BUFFER_SIZE (buf) != numfreqs * sizeof (gdouble) * 2) { gst_object_unref (mood); return GST_FLOW_ERROR; } - out = (gfloat *) GST_BUFFER_DATA (buf); + out = (gdouble *) GST_BUFFER_DATA (buf); if (!allocate_another_frame (mood)) return GST_FLOW_ERROR; @@ -512,11 +512,11 @@ gst_moodbar_chain (GstPad *pad, GstBuffer *buf) * library, normalise.cpp */ static void -normalize (gfloat *vals, guint numvals) +normalize (gdouble *vals, guint numvals) { - gfloat mini, maxi, tu = 0.f, tb = 0.f; - gfloat avgu = 0.f, avgb = 0.f, delta, avg = 0.f; - gfloat avguu = 0.f, avgbb = 0.f; + gdouble mini, maxi, tu = 0.f, tb = 0.f; + gdouble avgu = 0.f, avgb = 0.f, delta, avg = 0.f; + gdouble avguu = 0.f, avgbb = 0.f; guint i; gint t = 0; @@ -537,7 +537,7 @@ normalize (gfloat *vals, guint numvals) { if(vals[i] != mini && vals[i] != maxi) { - avg += vals[i] / ((gfloat) numvals); + avg += vals[i] / ((gdouble) numvals); t++; } } @@ -559,8 +559,8 @@ normalize (gfloat *vals, guint numvals) } } - avgu /= (gfloat) tu; - avgb /= (gfloat) tb; + avgu /= (gdouble) tu; + avgb /= (gdouble) tb; tu = 0.f; tb = 0.f; @@ -582,8 +582,8 @@ normalize (gfloat *vals, guint numvals) } } - avguu /= (gfloat) tu; - avgbb /= (gfloat) tb; + avguu /= (gdouble) tu; + avgbb /= (gdouble) tb; mini = MAX (avg + (avgb - avg) * 2.f, avgbb); maxi = MIN (avg + (avgu - avg) * 2.f, avguu); @@ -628,7 +628,7 @@ gst_moodbar_finish (GstMoodbar *mood) GST_BUFFER_OFFSET (buf) = 0; data = (guchar *) GST_BUFFER_DATA (buf); - gfloat r, g, b; + gdouble r, g, b; guint i, j, n; guint start, end; for (line = 0; line < mood->height; ++line) @@ -650,9 +650,9 @@ gst_moodbar_finish (GstMoodbar *mood) n = end - start; - *(data++) = (guchar) (r / ((gfloat) n)); - *(data++) = (guchar) (g / ((gfloat) n)); - *(data++) = (guchar) (b / ((gfloat) n)); + *(data++) = (guchar) (r / ((gdouble) n)); + *(data++) = (guchar) (g / ((gdouble) n)); + *(data++) = (guchar) (b / ((gdouble) n)); } } diff --git a/gst/moodbar/gstmoodbar.h b/gst/moodbar/gstmoodbar.h index 1f2a472ff..6ce2f799c 100644 --- a/gst/moodbar/gstmoodbar.h +++ b/gst/moodbar/gstmoodbar.h @@ -43,7 +43,7 @@ struct _GstMoodbar guint *barkband_table; /* Queued moodbar data */ - gfloat *r, *g, *b; + gdouble *r, *g, *b; guint numframes; /* Property */ diff --git a/gst/moodbar/spectrum.h b/gst/moodbar/spectrum.h index 14ca2f118..65f271338 100644 --- a/gst/moodbar/spectrum.h +++ b/gst/moodbar/spectrum.h @@ -22,7 +22,7 @@ "rate = (int) [ 1, MAX ], " \ "channels = (int) 1, " \ "endianness = (int) BYTE_ORDER, " \ - "width = (int) 32, " \ + "width = (int) 64, " \ "signed = (boolean) true" /* audio/x-spectrum-complex-float is an array of complex floats. A @@ -44,7 +44,7 @@ #define SPECTRUM_FREQ_CAPS "audio/x-spectrum-complex-float, " \ "rate = (int) [ 1, MAX ], " \ "endianness = (int) BYTE_ORDER, " \ - "width = (int) 32, " \ + "width = (int) 64, " \ "size = (int) [ 1, MAX ], " \ "step = (int) [ 1, MAX ]"