From: Maxime Even <maximeeven@proton.me>
Date: Mon, 8 Jul 2024 17:51:14 +0200
Subject: spectrogram: allows better visualization of low frequencies

In some cases, Y which represents the height of a column was equal to 1
and therefore when passed through the log, the output displayed was
zero, by adding this 0.1, this allows you to see a column when y = 1
without really changing the height of each column

(cherry picked from commit c347fed91e76bd31387171e1ff67224c21194362)
---
 modules/visualization/glspectrum.c     | 7 +++++--
 modules/visualization/visual/effects.c | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules/visualization/glspectrum.c b/modules/visualization/glspectrum.c
index 96ee3fe..832a52d 100644
--- a/modules/visualization/glspectrum.c
+++ b/modules/visualization/glspectrum.c
@@ -58,6 +58,8 @@ static void Close(vlc_object_t *);
 #define HEIGHT_TEXT N_("Video height")
 #define HEIGHT_LONGTEXT N_("The height of the visualization window, in pixels.")
 
+#define LOG_OFFSET 0.1
+
 vlc_module_begin()
     set_shortname(N_("glSpectrum"))
     set_description(N_("3D OpenGL spectrum visualization"))
@@ -466,8 +468,9 @@ static void *Thread( void *p_data )
                 if (p_dest[j] > y)
                      y = p_dest[j];
             }
-            /* Calculate the height of the bar */
-            float new_height = y != 0 ? logf(y) * 0.4f : 0;
+            /* Calculate the height of the bar
+               This log_offset makes it possible to display low values */
+            float new_height = y != 0 ? logf( y + LOG_OFFSET ) * 0.4f : 0;
             height[i] = new_height > height[i]
                         ? new_height : height[i];
         }
diff --git a/modules/visualization/visual/effects.c b/modules/visualization/visual/effects.c
index d5a7209..6961c54 100644
--- a/modules/visualization/visual/effects.c
+++ b/modules/visualization/visual/effects.c
@@ -46,6 +46,8 @@
 #define GRAD_ANGLE_MAX 0.5
 #define GRAD_INCR 0.01
 
+#define LOG_OFFSET 0.1
+
 /*****************************************************************************
  * dummy_Run
  *****************************************************************************/
@@ -231,10 +233,11 @@ static int spectrum_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
             if ( p_dest[j] > y )
                  y = p_dest[j];
         }
-        /* Calculate the height of the bar */
+        /* Calculate the height of the bar
+           This log_offset makes it possible to display low values */
         if( y != 0 )
         {
-            height[i] = log( y ) * 30;
+            height[i] = log( y + LOG_OFFSET ) * 30;
             if( height[i] > 380 )
                 height[i] = 380;
         }
