mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
level: code cleanup
Use gdouble instead of double. Calculate falloff_time once instead of twice.
This commit is contained in:
parent
024f1bae0c
commit
217b54a8f6
1 changed files with 12 additions and 12 deletions
|
@ -562,11 +562,12 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
{
|
{
|
||||||
GstLevel *filter;
|
GstLevel *filter;
|
||||||
guint8 *in_data;
|
guint8 *in_data;
|
||||||
double CS;
|
gdouble CS;
|
||||||
guint i;
|
guint i;
|
||||||
guint num_frames = 0;
|
guint num_frames = 0;
|
||||||
guint num_int_samples = 0; /* number of interleaved samples
|
guint num_int_samples = 0; /* number of interleaved samples
|
||||||
* ie. total count for all channels combined */
|
* ie. total count for all channels combined */
|
||||||
|
GstClockTimeDiff falloff_time;
|
||||||
|
|
||||||
filter = GST_LEVEL (trans);
|
filter = GST_LEVEL (trans);
|
||||||
|
|
||||||
|
@ -605,16 +606,15 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
filter->last_peak[i] = filter->peak[i];
|
filter->last_peak[i] = filter->peak[i];
|
||||||
|
|
||||||
/* make decay peak fall off if too old */
|
/* make decay peak fall off if too old */
|
||||||
if (gst_guint64_to_gdouble (filter->decay_peak_age[i]) >
|
falloff_time =
|
||||||
filter->decay_peak_ttl) {
|
GST_CLOCK_DIFF (gst_gdouble_to_guint64 (filter->decay_peak_ttl),
|
||||||
double falloff_dB;
|
filter->decay_peak_age[i]);
|
||||||
double falloff;
|
if (falloff_time > 0) {
|
||||||
GstClockTimeDiff falloff_time;
|
gdouble falloff_dB;
|
||||||
double length; /* length of falloff time in seconds */
|
gdouble falloff;
|
||||||
|
gdouble length; /* length of falloff time in seconds */
|
||||||
|
|
||||||
falloff_time = GST_CLOCK_DIFF (filter->decay_peak_ttl,
|
length = (gdouble) (falloff_time / GST_SECOND);
|
||||||
gst_guint64_to_gdouble (filter->decay_peak_age[i]));
|
|
||||||
length = (gdouble) falloff_time / GST_SECOND;
|
|
||||||
falloff_dB = filter->decay_peak_falloff * length;
|
falloff_dB = filter->decay_peak_falloff * length;
|
||||||
falloff = pow (10, falloff_dB / -20.0);
|
falloff = pow (10, falloff_dB / -20.0);
|
||||||
|
|
||||||
|
@ -662,8 +662,8 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
GST_TIME_ARGS (filter->message_ts), filter->num_frames);
|
GST_TIME_ARGS (filter->message_ts), filter->num_frames);
|
||||||
|
|
||||||
for (i = 0; i < filter->channels; ++i) {
|
for (i = 0; i < filter->channels; ++i) {
|
||||||
double RMS;
|
gdouble RMS;
|
||||||
double RMSdB, lastdB, decaydB;
|
gdouble RMSdB, lastdB, decaydB;
|
||||||
|
|
||||||
RMS = sqrt (filter->CS[i] / filter->num_frames);
|
RMS = sqrt (filter->CS[i] / filter->num_frames);
|
||||||
GST_LOG_OBJECT (filter,
|
GST_LOG_OBJECT (filter,
|
||||||
|
|
Loading…
Reference in a new issue