]> git.sesse.net Git - vlc/commitdiff
updates spectrometer visualization. some optimization tweaks and additional features.
authorScott Caudle <zcot@videolan.org>
Thu, 20 Oct 2005 22:37:14 +0000 (22:37 +0000)
committerScott Caudle <zcot@videolan.org>
Thu, 20 Oct 2005 22:37:14 +0000 (22:37 +0000)
modules/visualization/visual/effects.c
modules/visualization/visual/visual.c

index d86011df5ed963b6d43dfb3b96600fe8f767262a..a8f278156ebeb791842e528da9def352b3690d05 100644 (file)
@@ -396,11 +396,6 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
     }
 
     p_buffs = p_s16_buff;
-    //i_nb_bands = config_GetInt ( p_aout, "visual-nbbands" );
-    //i_separ    = config_GetInt( p_aout, "visual-separ" );
-    //i_amp     = config_GetInt ( p_aout, "visual-amp" );
-    //i_peak     = config_GetInt ( p_aout, "visual-peaks" );
-    /* previous 4 vars changed.. using them as `spect' variables */
     i_original     = config_GetInt ( p_aout, "spect-show-original" );
     i_nb_bands     = config_GetInt ( p_aout, "spect-nbbands" );
     i_separ        = config_GetInt ( p_aout, "spect-separ" );
@@ -420,12 +415,10 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
     }
     else
     {
-        i_nb_bands = 80;
+        if( i_nb_bands > 80 )
+            i_nb_bands = 80;
         xscale = xscale2;
     }
-    i_nb_bands *= i_sections;
-    /* whoops, dont malloc the following memory for all the duplicated bands..
-        -only the original 20 or 80 will be fine */
 
     if( !p_effect->p_data )
     {
@@ -446,13 +439,13 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
         peaks =(int *)p_effect->p_data;
     }
 
-
     height = (int *)malloc( i_nb_bands * sizeof(int) );
     if( !height)
     {
         msg_Err(p_aout,"Out of memory");
         return -1;
     }
+
     /* Convert the buffer to int16_t  */
     /* Pasted from float32tos16.c */
     for (i = p_buffer->i_nb_samples * p_effect->i_nb_chans; i--; )
@@ -482,6 +475,8 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
     for(i= 0; i< FFT_BUFFER_SIZE ; i++ )
         p_dest[i] = ( (int) sqrt( p_output [ i + 1 ] ) ) >> 8;
 
+    i_nb_bands *= i_sections;
+
     for ( i = 0 ; i< i_nb_bands/i_sections ;i++)
     {
         /* We search the maximum on one scale */
@@ -660,24 +655,20 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
                     y /= 2;
 
                     *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
-                    - p_picture->p[1].i_pitch
                     ) = 0;/* U(R,G,B); */
 
                     if( 0x04 * (i_line + k ) - 0x0f > 0 )
                     {
                         if ( 0x04 * (i_line + k ) -0x0f < 0xff)
                             *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
-                            - p_picture->p[2].i_pitch
                             ) = ( 0x04 * ( i_line + k ) ) -(color1-1);/* -V(R,G,B); */
                         else
                             *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
-                            - p_picture->p[2].i_pitch
                             ) = 255;/* V(R,G,B); */
                     }
                     else
                     {
                         *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
-                        - p_picture->p[2].i_pitch
                         ) = color1;/* V(R,G,B); */
                     }
                 }
@@ -705,24 +696,20 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
             y /= 2;
 
             *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
-            - p_picture->p[1].i_pitch
             ) = 0;/* U(R,G,B); */
 
             if( 0x04 * i_line - 0x0f > 0 )
             {
                 if( 0x04 * i_line -0x0f < 0xff)
                     *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
-                    - p_picture->p[2].i_pitch
                     ) = ( 0x04 * i_line) -(color1-1);/* -V(R,G,B); */
                 else
                     *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
-                    - p_picture->p[2].i_pitch
                     ) = 255;/* V(R,G,B); */
             }
             else
             {
                 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
-                - p_picture->p[2].i_pitch
                 ) = color1;/* V(R,G,B); */
             }
         }
@@ -755,24 +742,20 @@ int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
                 y /= 2;
 
                 *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
-                - p_picture->p[1].i_pitch
                 ) = 0;
 
                 if( 0x04 * i_line - 0x0f > 0 )
                 {
                     if ( 0x04 * i_line -0x0f < 0xff)
                         *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
-                        - p_picture->p[2].i_pitch
                         ) = ( 0x04 * i_line) -(color1-1);
                     else
                         *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
-                        - p_picture->p[2].i_pitch
                         ) = 255;
                 }
                 else
                 {
                     *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
-                    - p_picture->p[2].i_pitch
                     ) = color1;
                 }
             }
index 77818f20d30396907d15444ae3e3ca8e094e7405..2e8898259d27c2df5754336510e5ece01e39e9a1 100644 (file)
@@ -51,6 +51,8 @@
 #define NBBANDS_TEXT N_( "Number of bands" )
 #define NBBANDS_LONGTEXT N_( \
       "Number of bands used by spectrum analyzer, should be 20 or 80." )
+#define SPNBBANDS_LONGTEXT N_( \
+      "Number of bands used by the spectrOmeter, from 20 to 80." )
 
 #define SEPAR_TEXT N_( "Band separator" )
 #define SEPAR_LONGTEXT N_( \
@@ -125,27 +127,27 @@ vlc_module_begin();
     add_bool("visual-peaks", VLC_TRUE, NULL,
              PEAKS_TEXT, PEAKS_LONGTEXT, VLC_TRUE );
     set_section( N_("Spectrometer") , NULL );
-    add_bool("spect-show-original", VLC_TRUE, NULL,
+    add_bool("spect-show-original", VLC_FALSE, NULL,
              ORIG_TEXT, ORIG_LONGTEXT, VLC_TRUE );
     add_bool("spect-show-base", VLC_TRUE, NULL,
              BASE_TEXT, BASE_LONGTEXT, VLC_TRUE );
-    add_integer("spect-radius", 22, NULL,
+    add_integer("spect-radius", 42, NULL,
              RADIUS_TEXT, RADIUS_LONGTEXT, VLC_TRUE );
-    add_integer("spect-sections", 2, NULL,
+    add_integer("spect-sections", 3, NULL,
              SECT_TEXT, SECT_LONGTEXT, VLC_TRUE );
-    add_integer("spect-color", 16, NULL,
+    add_integer("spect-color", 80, NULL,
              COLOR1_TEXT, COLOR1_LONGTEXT, VLC_TRUE );
     add_bool("spect-show-bands", VLC_TRUE, NULL,
              BANDS_TEXT, BANDS_LONGTEXT, VLC_TRUE );
-    add_integer("spect-nbbands", 80, NULL,
-             NBBANDS_TEXT, NBBANDS_LONGTEXT, VLC_TRUE );
+    add_integer("spect-nbbands", 32, NULL,
+             NBBANDS_TEXT, SPNBBANDS_LONGTEXT, VLC_TRUE );
     add_integer("spect-separ", 1, NULL,
              SEPAR_TEXT, SEPAR_LONGTEXT, VLC_TRUE );
-    add_integer("spect-amp", 3, NULL,
+    add_integer("spect-amp", 8, NULL,
              AMP_TEXT, AMP_LONGTEXT, VLC_TRUE );
     add_bool("spect-show-peaks", VLC_TRUE, NULL,
              PEAKS_TEXT, PEAKS_LONGTEXT, VLC_TRUE );
-    add_integer("spect-peak-width", 1, NULL,
+    add_integer("spect-peak-width", 61, NULL,
              PEAK_WIDTH_TEXT, PEAK_WIDTH_LONGTEXT, VLC_TRUE );
     add_integer("spect-peak-height", 1, NULL,
              PEAK_HEIGHT_TEXT, PEAK_HEIGHT_LONGTEXT, VLC_TRUE );