[vlc-commits] audiobargraph_a: compute maximum value only when using it
Rafaël Carré
git at videolan.org
Wed Jul 27 16:24:49 CEST 2016
vlc | branch: master | Rafaël Carré <funman at videolan.org> | Wed Jul 27 15:56:31 2016 +0200| [6344700eb01cc60914328b3ca1bd8cb60cb706ef] | committer: Rafaël Carré
audiobargraph_a: compute maximum value only when using it
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6344700eb01cc60914328b3ca1bd8cb60cb706ef
---
modules/audio_filter/audiobargraph_a.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/modules/audio_filter/audiobargraph_a.c b/modules/audio_filter/audiobargraph_a.c
index 3020a0c..0b1f624 100644
--- a/modules/audio_filter/audiobargraph_a.c
+++ b/modules/audio_filter/audiobargraph_a.c
@@ -175,22 +175,23 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
i_value[i] = 0.;
/* 1 - Compute the peak values */
- float max = 0.0;
- for (size_t i = 0; i < p_in_buf->i_nb_samples; i++) {
+ for (size_t i = 0; i < p_in_buf->i_nb_samples; i++)
for (int j = 0; j<nbChannels; j++) {
- float ch = (*p_sample++);
+ float ch = *p_sample++;
if (ch > i_value[j])
i_value[j] = ch;
- if (ch > max)
- max = ch;
}
- }
- max *= max;
if (p_sys->silence) {
/* 2 - store the new value */
ValueDate_t *new = xmalloc(sizeof(*new));
- new->value = max;
+ new->value = 0.0;
+ for (int j = 0; j<nbChannels; j++) {
+ float ch = i_value[j];
+ if (ch > new->value)
+ new->value = ch;
+ }
+ new->value *= new->value;
new->date = p_in_buf->i_pts;
new->next = NULL;
if (p_sys->last != NULL)
More information about the vlc-commits
mailing list