mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-25 16:48:11 +00:00
level: misc cleanups
Fix some oudated comments. Sort out some confusion of interval_frames and num_frames.
This commit is contained in:
parent
82e7826af0
commit
6feaf69bec
1 changed files with 15 additions and 19 deletions
|
@ -354,11 +354,11 @@ gst_level_get_property (GObject * object, guint prop_id,
|
||||||
*
|
*
|
||||||
* caller must assure num is a multiple of channels
|
* caller must assure num is a multiple of channels
|
||||||
* samples for multiple channels are interleaved
|
* samples for multiple channels are interleaved
|
||||||
* input sample data enters in *in_data as 8 or 16 bit data
|
* input sample data enters in *in_data and is not modified
|
||||||
* this filter only accepts signed audio data, so mid level is always 0
|
* this filter only accepts signed audio data, so mid level is always 0
|
||||||
*
|
*
|
||||||
* for 16 bit, this code considers the non-existant 32768 value to be
|
* for integers, this code considers the non-existant positive max value to be
|
||||||
* full-scale; so 32767 will not map to 1.0
|
* full-scale; so max-1 will not map to 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEFINE_INT_LEVEL_CALCULATOR(TYPE, RESOLUTION) \
|
#define DEFINE_INT_LEVEL_CALCULATOR(TYPE, RESOLUTION) \
|
||||||
|
@ -368,13 +368,13 @@ gst_level_calculate_##TYPE (gpointer data, guint num, guint channels, \
|
||||||
{ \
|
{ \
|
||||||
TYPE * in = (TYPE *)data; \
|
TYPE * in = (TYPE *)data; \
|
||||||
register guint j; \
|
register guint j; \
|
||||||
gdouble squaresum = 0.0; /* square sum of the integer samples */ \
|
gdouble squaresum = 0.0; /* square sum of the input samples */ \
|
||||||
register gdouble square = 0.0; /* Square */ \
|
register gdouble square = 0.0; /* Square */ \
|
||||||
register gdouble peaksquare = 0.0; /* Peak Square Sample */ \
|
register gdouble peaksquare = 0.0; /* Peak Square Sample */ \
|
||||||
gdouble normalizer; /* divisor to get a [-1.0, 1.0] range */ \
|
gdouble normalizer; /* divisor to get a [-1.0, 1.0] range */ \
|
||||||
\
|
\
|
||||||
/* *NCS = 0.0; Normalized Cumulative Square */ \
|
/* *NCS = 0.0; Normalized Cumulative Square */ \
|
||||||
/* *NPS = 0.0; Normalized Peask Square */ \
|
/* *NPS = 0.0; Normalized Peak Square */ \
|
||||||
\
|
\
|
||||||
for (j = 0; j < num; j += channels) { \
|
for (j = 0; j < num; j += channels) { \
|
||||||
square = ((gdouble) in[j]) * in[j]; \
|
square = ((gdouble) in[j]) * in[j]; \
|
||||||
|
@ -399,12 +399,12 @@ gst_level_calculate_##TYPE (gpointer data, guint num, guint channels, \
|
||||||
{ \
|
{ \
|
||||||
TYPE * in = (TYPE *)data; \
|
TYPE * in = (TYPE *)data; \
|
||||||
register guint j; \
|
register guint j; \
|
||||||
gdouble squaresum = 0.0; /* square sum of the integer samples */ \
|
gdouble squaresum = 0.0; /* square sum of the input samples */ \
|
||||||
register gdouble square = 0.0; /* Square */ \
|
register gdouble square = 0.0; /* Square */ \
|
||||||
register gdouble peaksquare = 0.0; /* Peak Square Sample */ \
|
register gdouble peaksquare = 0.0; /* Peak Square Sample */ \
|
||||||
\
|
\
|
||||||
/* *NCS = 0.0; Normalized Cumulative Square */ \
|
/* *NCS = 0.0; Normalized Cumulative Square */ \
|
||||||
/* *NPS = 0.0; Normalized Peask Square */ \
|
/* *NPS = 0.0; Normalized Peak Square */ \
|
||||||
\
|
\
|
||||||
/* orc_level_squaresum_f64(&squaresum,in,num); */ \
|
/* orc_level_squaresum_f64(&squaresum,in,num); */ \
|
||||||
for (j = 0; j < num; j += channels) { \
|
for (j = 0; j < num; j += channels) { \
|
||||||
|
@ -621,16 +621,13 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
block_size = MIN (block_size, num_frames);
|
block_size = MIN (block_size, num_frames);
|
||||||
block_int_size = block_size * channels;
|
block_int_size = block_size * channels;
|
||||||
|
|
||||||
GST_LOG_OBJECT (filter, "run inner loop for %u sample frames",
|
|
||||||
block_int_size);
|
|
||||||
|
|
||||||
for (i = 0; i < channels; ++i) {
|
for (i = 0; i < channels; ++i) {
|
||||||
if (!GST_BUFFER_FLAG_IS_SET (in, GST_BUFFER_FLAG_GAP)) {
|
if (!GST_BUFFER_FLAG_IS_SET (in, GST_BUFFER_FLAG_GAP)) {
|
||||||
filter->process (in_data, block_int_size, channels, &CS,
|
filter->process (in_data, block_int_size, channels, &CS,
|
||||||
&filter->peak[i]);
|
&filter->peak[i]);
|
||||||
GST_LOG_OBJECT (filter,
|
GST_LOG_OBJECT (filter,
|
||||||
"channel %d, cumulative sum %f, over %d samples/%d channels", i, CS,
|
"[%d]: cumulative squares %lf, over %d samples/%d channels",
|
||||||
block_int_size, channels);
|
i, CS, block_int_size, channels);
|
||||||
filter->CS[i] += CS;
|
filter->CS[i] += CS;
|
||||||
} else {
|
} else {
|
||||||
filter->peak[i] = 0.0;
|
filter->peak[i] = 0.0;
|
||||||
|
@ -702,12 +699,12 @@ static void
|
||||||
gst_level_post_message (GstLevel * filter)
|
gst_level_post_message (GstLevel * filter)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
gint channels, rate;
|
gint channels, rate, frames = filter->num_frames;
|
||||||
GstClockTime duration;
|
GstClockTime duration;
|
||||||
|
|
||||||
channels = GST_AUDIO_INFO_CHANNELS (&filter->info);
|
channels = GST_AUDIO_INFO_CHANNELS (&filter->info);
|
||||||
rate = GST_AUDIO_INFO_RATE (&filter->info);
|
rate = GST_AUDIO_INFO_RATE (&filter->info);
|
||||||
duration = GST_FRAMES_TO_CLOCK_TIME (filter->interval_frames, rate);
|
duration = GST_FRAMES_TO_CLOCK_TIME (frames, rate);
|
||||||
|
|
||||||
if (filter->post_messages) {
|
if (filter->post_messages) {
|
||||||
GstMessage *m =
|
GstMessage *m =
|
||||||
|
@ -716,16 +713,15 @@ gst_level_post_message (GstLevel * filter)
|
||||||
GST_LOG_OBJECT (filter,
|
GST_LOG_OBJECT (filter,
|
||||||
"message: ts %" GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT
|
"message: ts %" GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT
|
||||||
", num_frames %d", GST_TIME_ARGS (filter->message_ts),
|
", num_frames %d", GST_TIME_ARGS (filter->message_ts),
|
||||||
GST_TIME_ARGS (duration), filter->num_frames);
|
GST_TIME_ARGS (duration), frames);
|
||||||
|
|
||||||
for (i = 0; i < channels; ++i) {
|
for (i = 0; i < channels; ++i) {
|
||||||
gdouble RMS;
|
gdouble RMS;
|
||||||
gdouble RMSdB, peakdB, decaydB;
|
gdouble RMSdB, peakdB, decaydB;
|
||||||
|
|
||||||
RMS = sqrt (filter->CS[i] / filter->num_frames);
|
RMS = sqrt (filter->CS[i] / frames);
|
||||||
GST_LOG_OBJECT (filter,
|
GST_LOG_OBJECT (filter,
|
||||||
"message: channel %d, CS %f, num_frames %d, RMS %f",
|
"message: channel %d, CS %f, RMS %f", i, filter->CS[i], RMS);
|
||||||
i, filter->CS[i], filter->num_frames, RMS);
|
|
||||||
GST_LOG_OBJECT (filter,
|
GST_LOG_OBJECT (filter,
|
||||||
"message: last_peak: %f, decay_peak: %f",
|
"message: last_peak: %f, decay_peak: %f",
|
||||||
filter->last_peak[i], filter->decay_peak[i]);
|
filter->last_peak[i], filter->decay_peak[i]);
|
||||||
|
@ -757,7 +753,7 @@ gst_level_post_message (GstLevel * filter)
|
||||||
gst_element_post_message (GST_ELEMENT (filter), m);
|
gst_element_post_message (GST_ELEMENT (filter), m);
|
||||||
|
|
||||||
}
|
}
|
||||||
filter->num_frames -= filter->interval_frames;
|
filter->num_frames -= frames;
|
||||||
filter->message_ts += duration;
|
filter->message_ts += duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue