gstreamer/gst/level/filter.func
Ronald S. Bultje da88f91368 gcc-2.95 fixage
Original commit message from CVS:
gcc-2.95 fixage
2003-10-14 10:07:59 +00:00

35 lines
1.1 KiB
Text

/* process one (interleaved) channel of incoming samples
* calculate square sum of samples
* normalize and return normalized Cumulative Square
* caller must assure num is a multiple of channels
* this filter only accepts signed audio data, so mid level is always 0
*/
{
register int j;
double squaresum = 0.0; /* square sum of the integer samples */
register double square = 0.0; /* Square */
register double PSS = 0.0; /* Peak Square Sample */
gdouble normalizer;
*CS = 0.0; /* Cumulative Square for this block */
normalizer = (double) (1 << resolution);
/*
* process data here
* input sample data enters in *in_data as 8 or 16 bit data
* samples for left and right channel are interleaved
* returns the Mean Square of the samples as a double between 0 and 1
*/
for (j = 0; j < num; j += channels)
{
square = (double) (in[j] * in[j]);
if (square > PSS) PSS = square;
squaresum += square;
}
*peak = PSS / ((double) normalizer * (double) normalizer);
/* return normalized cumulative square */
*CS = squaresum / ((double) normalizer * (double) normalizer);
}