Changeset eba02c65a872331ab2fd64d30d3ee04b4aaf6338

Show
Ignore:
Timestamp:
29/08/03 18:56:43 (5 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1062176203 +0000
git-parent:

[e5fe2b341fad70233788ceb83533c8d1a5a91d87]

git-author:
Clément Stenac <zorglub@videolan.org> 1062176203 +0000
Message:

* effects.c :

  • added a spectrum analyser
    options are:

-nb : number of bands , 20 or 80 (80 is default)
-separ : how many blank pixels between bands (1 default)
-amp : vertical amplification ( 3 default)
-peaks: draw peaks ? (default 1)

  • improved options parsing

* fft.c, fft.h :

FFT code mainly taken from XMMS (adapted coding style)

* visual.c:

Sanity checks (users aren't stupid, are they ? )

* LIST: updated the list

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/LIST

    re73a028 reba02c6  
    11List of vlc plugins (221) 
    2 $Id: LIST,v 1.10 2003/08/10 12:45:52 zorglub Exp $ 
     2$Id: LIST,v 1.11 2003/08/29 16:56:43 zorglub Exp $ 
    33 
    44 * a52: A/52 basic parser 
     
    9292 * downmixsse: SSE accelerated version of downmix. 
    9393 
     94 * dshow: DirectShow access plugin for encoding cards under Windows 
     95 
    9496 * dts: DTS basic parser 
    9597 
     
    157159  
    158160 * gnome_main: Gtk+ wrapper for gtk_main 
     161 
     162 * goom: visualisation plugin based on goom 
    159163 
    160164 * gtk2: interface using the Gtk2 widget set. 
     
    291295 * ncurses: interface module using the ncurses library. 
    292296 
     297 * ntservice: run VLC as a NT service 
     298 
    293299 * ogg: input module for OGG decapsulation. 
    294300 
     
    414420 * vcd: input module for accessing Video CDs. 
    415421 
     422 * visual: visualisation system 
     423 
    416424 * vorbis: a vorbis audio decoder using the libvorbis library. 
    417425 
     
    434442 * x11: video output module using the X11 API. 
    435443 
    436  * xmga: X11 MGA video_output plugin 
    437   
    438444 * xosd: X On Screen Display interface 
    439445 
  • modules/visualization/visual/Modules.am

    r6db0571 reba02c6  
    11SOURCES_visual = visual.c \ 
    2          effects.c 
     2         effects.c \ 
     3         fft.c 
  • modules/visualization/visual/effects.c

    r6db0571 reba02c6  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: effects.c,v 1.1 2003/08/19 21:20:00 zorglub Exp $ 
     5 * $Id: effects.c,v 1.2 2003/08/29 16:56:43 zorglub Exp $ 
    66 * 
    77 * Authors: Cl�nt Stenac <zorglub@via.ecp.fr> 
     
    2828#include <math.h> 
    2929 
    30  
     30#include "fft.h" 
     31 
     32#define PEAK_SPEED 1 
    3133/***************************************************************************** 
    3234 * Argument list parsers                                                     * 
     
    3840    if( psz_parse != NULL ) 
    3941    { 
    40         if(!strncmp( psz_parse, name, strlen(name) ) ) 
    41         { 
    42             psz_parse += strlen( name ); 
    43             psz_eof = strchr( psz_parse , ',' ); 
    44             if( !psz_eof) 
    45                 psz_eof = psz_parse + strlen(psz_parse); 
    46             if( psz_eof ) 
    47             { 
    48                 *psz_eof = '\0' ; 
     42        while(1) 
     43        { 
     44            if(!strncmp( psz_parse, name, strlen(name) ) ) 
     45            { 
     46                psz_parse += strlen( name ); 
     47                psz_eof = strchr( psz_parse , ',' ); 
     48                if( !psz_eof) 
     49                    psz_eof = psz_parse + strlen(psz_parse); 
     50                if( psz_eof ) 
     51                { 
     52                    *psz_eof = '\0' ; 
     53                } 
     54                i_value = atoi(++psz_parse); 
     55                psz_parse= psz_eof; 
     56                psz_parse++; 
     57                return i_value; 
    4958            } 
    50             i_value = atoi(++psz_parse); 
    51             psz_parse= psz_eof
    52             psz_parse++; 
    53             return i_value
    54         } 
     59            if( *psz_parse ) 
     60                psz_parse ++
     61            else 
     62                break
     63        }  
    5564    } 
    5665    return defaut; 
     
    6473    if( psz_parse != NULL ) 
    6574    { 
    66         if(!strncmp( psz_parse, name, strlen(name) ) )                             
    67         { 
    68             psz_parse += strlen( name ); 
    69             psz_eof = strchr( psz_parse , ',' ); 
    70             if( !psz_eof) 
    71                 psz_eof = psz_parse + strlen(psz_parse); 
    72             if( psz_eof ) 
    73             { 
    74                 *psz_eof = '\0' ; 
     75        while(1) 
     76        { 
     77            if(!strncmp( psz_parse, name, strlen(name) ) )                             
     78            { 
     79                psz_parse += strlen( name ); 
     80                psz_eof = strchr( psz_parse , ',' ); 
     81                if( !psz_eof) 
     82                    psz_eof = psz_parse + strlen(psz_parse); 
     83                if( psz_eof ) 
     84                { 
     85                    *psz_eof = '\0' ; 
     86                } 
     87                psz_value = strdup(++psz_parse); 
     88                psz_parse= psz_eof; 
     89                psz_parse++; 
     90                return psz_value; 
    7591            } 
    76             psz_value = strdup(++psz_parse); 
    77             psz_parse= psz_eof
    78             psz_parse++; 
    79             return psz_value
    80         } 
    81     } 
    82         return strdup(defaut); 
     92            if( *psz_parse ) 
     93                psz_parse ++
     94            else 
     95                break
     96        } 
     97    } 
     98    return strdup(defaut); 
    8399} 
    84100 
     
    99115                 aout_buffer_t * p_buffer , picture_t * p_picture) 
    100116{ 
    101         return 0; 
     117    float p_output[FFT_BUFFER_SIZE];  /* Raw FFT Result  */ 
     118    int *height;                      /* Bar heights */ 
     119    int *peaks;                       /* Peaks */ 
     120    int i_nb_bands;                   /* number of bands */ 
     121    int i_band_width;                 /* width of bands */ 
     122    int i_separ;                      /* Should we let blanks ? */ 
     123    int i_amp;                        /* Vertical amplification */ 
     124    int i_peak;                       /* Should we draw peaks ? */ 
     125    char *psz_parse = NULL;           /* Args line */ 
     126     
     127    /* Horizontal scale for 20-band equalizer */ 
     128    const int xscale1[]={0,1,2,3,4,5,6,7,8,11,15,20,27, 
     129                        36,47,62,82,107,141,184,255}; 
     130                         
     131    /* Horizontal scale for 80-band equalizer */ 
     132    const int xscale2[] =  
     133    {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18, 
     134     19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34, 
     135     35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51, 
     136     52,53,54,55,56,57,58,59,61,63,67,72,77,82,87,93,99,105, 
     137     110,115,121,130,141,152,163,174,185,255}; 
     138    const int *xscale; 
     139    const double y_scale =  3.60673760222;  /* (log 256) */ 
     140     
     141    fft_state *p_state;                 /* internal FFT data */ 
     142     
     143    int i , j , y , k; 
     144    int i_line; 
     145    s16 p_dest[FFT_BUFFER_SIZE];          /* Adapted FFT result */ 
     146    s16 p_buffer1[FFT_BUFFER_SIZE];       /* Buffer on which we perform 
     147                                             the FFT (first channel) */ 
     148 
     149    float *p_buffl =                     /* Original buffer */ 
     150            (float*)p_buffer->p_buffer; 
     151 
     152    s16  *p_buffs;                        /* s16 converted buffer */ 
     153    s16  *p_s16_buff = NULL;                    /* s16 converted buffer */ 
     154     
     155    p_s16_buff = (s16*)malloc(  
     156              p_buffer->i_nb_samples * p_effect->i_nb_chans * sizeof(s16)); 
     157 
     158    if( !p_s16_buff ) 
     159    { 
     160        msg_Err(p_aout,"Out of memory"); 
     161        return -1; 
     162    } 
     163     
     164    p_buffs = p_s16_buff; 
     165    if( p_effect->psz_args ) 
     166    { 
     167        psz_parse  = strdup( p_effect->psz_args ); 
     168        i_nb_bands = args_getint ( psz_parse , "nb" , 80 ); 
     169        psz_parse  = strdup( p_effect->psz_args ); 
     170        i_separ    = args_getint ( psz_parse , "separ", 1 ); 
     171        psz_parse  = strdup( p_effect->psz_args ); 
     172        i_amp     = args_getint ( psz_parse , "amp", 3 ); 
     173        psz_parse  = strdup( p_effect->psz_args ); 
     174        i_peak     = args_getint ( psz_parse , "peaks", 1 ); 
     175    } 
     176    else 
     177    { 
     178       i_nb_bands = 80; 
     179       i_separ = 1; 
     180       i_amp = 3; 
     181       i_peak = 1; 
     182    } 
     183 
     184    if( i_nb_bands == 20) 
     185    { 
     186        xscale = xscale1; 
     187    } 
     188    else 
     189    { 
     190        i_nb_bands = 80; 
     191        xscale = xscale2; 
     192    } 
     193     
     194    if( !p_effect->p_data ) 
     195    { 
     196        p_effect->p_data=(void *)malloc(i_nb_bands * sizeof(int) ); 
     197        if( !p_effect->p_data) 
     198        { 
     199            msg_Err(p_aout,"Out of memory"); 
     200            return -1; 
     201        } 
     202        peaks = (int *)p_effect->p_data; 
     203        for( i = 0 ; i < i_nb_bands ; i++) 
     204        { 
     205           peaks[i] = 0; 
     206        } 
     207                       
     208    } 
     209    else 
     210    { 
     211        peaks =(int *)p_effect->p_data; 
     212    } 
     213    
     214     
     215    height = (int *)malloc( i_nb_bands * sizeof(int) ); 
     216    if( !height) 
     217    { 
     218        msg_Err(p_aout,"Out of memory"); 
     219        return -1; 
     220    } 
     221    /* Convert the buffer to s16  */ 
     222    /* Pasted from float32tos16.c */ 
     223    for (i = p_buffer->i_nb_samples * p_effect->i_nb_chans; i--; ) 
     224    { 
     225        float f_in = *p_buffl + 384.0; 
     226        s32 i_in; 
     227        i_in = *(s32 *)&f_in; 
     228        if(i_in >  0x43c07fff ) * p_buffs = 32767; 
     229        else if ( i_in < 0x43bf8000 ) *p_buffs = -32768; 
     230        else *p_buffs = i_in - 0x43c00000; 
     231       
     232        p_buffl++ ; p_buffs++ ; 
     233    } 
     234    p_state  = fft_init(); 
     235    if( !p_state) 
     236    { 
     237        msg_Err(p_aout,"Unable to initialize FFT transform"); 
     238        return -1; 
     239    } 
     240    p_buffs = p_s16_buff; 
     241    for ( i = 0 ; i < FFT_BUFFER_SIZE ; i++) 
     242    { 
     243        p_output[i]    = 0; 
     244        p_buffer1[i] = *p_buffs; 
     245        p_buffs      = p_buffs + p_effect->i_nb_chans; 
     246    }  
     247    fft_perform( p_buffer1, p_output, p_state); 
     248    for(i= 0; i< FFT_BUFFER_SIZE ; i++ ) 
     249        p_dest[i] = ( (int) sqrt( p_output [ i + 1 ] ) ) >> 8; 
     250                 
     251    for ( i = 0 ; i< i_nb_bands ;i++) 
     252    { 
     253        /* We search the maximum on one scale */ 
     254        for( j = xscale[i] , y=0 ; j< xscale[ i + 1 ] ; j++ ) 
     255        { 
     256            if ( p_dest[j] > y ) 
     257                 y = p_dest[j]; 
     258        } 
     259        /* Calculate the height of the bar */ 
     260        y >>=5; /* remove some noise */ 
     261        if( y != 0) 
     262        { 
     263            height[i] = (int)log(y)* y_scale; 
     264               if(height[i] > 150) 
     265                  height[i] = 150; 
     266        } 
     267        else 
     268        { 
     269            height[i] = 0 ; 
     270        } 
     271              
     272        /* Draw the bar now */ 
     273        i_band_width = floor( p_effect->i_width / i_nb_bands) ; 
     274 
     275        if( i_amp * height[i] > peaks[i]) 
     276        { 
     277            peaks[i] = i_amp * height[i]; 
     278        } 
     279        else if (peaks[i] > 0 ) 
     280        { 
     281            peaks[i] -= PEAK_SPEED; 
     282            if( peaks[i] < i_amp * height[i] ) 
     283            { 
     284                peaks[i] = i_amp * height[i]; 
     285            } 
     286            if( peaks[i] < 0 ) 
     287            { 
     288                peaks[i] = 0; 
     289            } 
     290        } 
     291 
     292        if( peaks[i] > 0 && i_peak ) 
     293        { 
     294            if( peaks[i] >= p_effect->i_height )  
     295                peaks[i] = p_effect->i_height - 2; 
     296            i_line = peaks[i]; 
     297             
     298            for( j = 0 ; j< i_band_width - i_separ; j++) 
     299            { 
     300               for( k = 0 ; k< 3 ; k ++) 
     301               { 
     302                   /* Draw the peak */ 
     303                     *(p_picture->p[0].p_pixels +  
     304                    (p_picture->p[0].i_lines - i_line -1 -k ) *  
     305                     p_picture->p[0].i_pitch + (i_band_width*i +j) )  
     306                                    = 0xff; 
     307 
     308                    *(p_picture->p[1].p_pixels + 
     309                     (p_picture->p[1].i_lines - i_line /2 -1 -k/2 ) * 
     310                     p_picture->p[1].i_pitch +  
     311                    ( ( i_band_width * i + j ) /2  ) ) 
     312                                    = 0x00; 
     313   
     314                   if( 0x04 * (i_line + k ) - 0x0f > 0 ) 
     315                   { 
     316                       if ( 0x04 * (i_line + k ) -0x0f < 0xff) 
     317                           *(p_picture->p[2].p_pixels  + 
     318                            (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) * 
     319                             p_picture->p[2].i_pitch +  
     320                             ( ( i_band_width * i + j ) /2  ) )  
     321                                    = ( 0x04 * ( i_line + k ) ) -0x0f ; 
     322                       else 
     323                           *(p_picture->p[2].p_pixels  + 
     324                            (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) * 
     325                             p_picture->p[2].i_pitch +  
     326                             ( ( i_band_width * i + j ) /2  ) )  
     327                                    = 0xff;  
     328                   } 
     329                   else 
     330                   { 
     331                        *(p_picture->p[2].p_pixels  + 
     332                         (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) * 
     333                         p_picture->p[2].i_pitch +  
     334                         ( ( i_band_width * i + j ) /2  ) )  
     335                               = 0x10 ; 
     336                   } 
     337               } 
     338            }  
     339        } 
     340     
     341        if(height[i] * i_amp > p_effect->i_height) 
     342            height[i] = floor(p_effect->i_height / i_amp ); 
     343 
     344        for(i_line = 0 ; i_line < i_amp * height[i]; i_line ++ ) 
     345        { 
     346            for( j = 0 ; j< i_band_width - i_separ ; j++) 
     347            { 
     348               *(p_picture->p[0].p_pixels +  
     349                 (p_picture->p[0].i_lines - i_line -1) *  
     350                  p_picture->p[0].i_pitch + (i_band_width*i +j) ) = 0xff; 
     351 
     352                *(p_picture->p[1].p_pixels + 
     353                 (p_picture->p[1].i_lines - i_line /2 -1) * 
     354                 p_picture->p[1].i_pitch +  
     355                 ( ( i_band_width * i + j ) /2  ) ) = 0x00; 
     356 
     357                
     358               if( 0x04 * i_line - 0x0f > 0 ) 
     359               { 
     360                    if( 0x04 * i_line - 0x0f < 0xff ) 
     361                         *(p_picture->p[2].p_pixels  + 
     362                          (p_picture->p[2].i_lines - i_line /2 - 1) * 
     363                           p_picture->p[2].i_pitch +  
     364                           ( ( i_band_width * i + j ) /2  ) ) =  
     365                               ( 0x04 * i_line) -0x0f ; 
     366                    else 
     367                         *(p_picture->p[2].p_pixels  + 
     368                          (p_picture->p[2].i_lines - i_line /2 - 1) * 
     369                           p_picture->p[2].i_pitch +  
     370                           ( ( i_band_width * i + j ) /2  ) ) =  
     371                                       0xff; 
     372               } 
     373               else 
     374               { 
     375                    *(p_picture->p[2].p_pixels  + 
     376                     (p_picture->p[2].i_lines - i_line /2 - 1) * 
     377                     p_picture->p[2].i_pitch +  
     378                     ( ( i_band_width * i + j ) /2  ) ) =  
     379                            0x10 ; 
     380               } 
     381            } 
     382        } 
     383    } 
     384        
     385    fft_close( p_state ); 
     386    
     387    if( p_s16_buff != NULL )  
     388    { 
     389        free( p_s16_buff ); 
     390        p_s16_buff = NULL; 
     391    } 
     392    
     393    if(height) free(height); 
     394    
     395    if(psz_parse) free(psz_parse); 
     396     
     397    return 0; 
    102398} 
    103399 
     
    173469    { 
    174470        psz_parse = strdup( p_effect->psz_args ); 
    175         while(1) 
    176         { 
    177             i_nb_plots = args_getint ( psz_parse , "nb" , 200 ); 
    178             if(i_nb_plots) break; 
    179             if( *psz_parse ) 
    180                  psz_parse ++; 
    181             else 
    182                 break; 
    183         } 
     471        i_nb_plots = args_getint ( psz_parse , "nb" , 200 ); 
    184472    } 
    185473    else 
     
    195483        i_v = rand() % 256; 
    196484        *(p_picture->p[0].p_pixels + i_position )= i_u; 
     485        *(p_picture->p[1].p_pixels + i_position/4) = i_v; 
     486        *(p_picture->p[2].p_pixels + i_position/4) = i_y; 
    197487    } 
    198488    return 0; 
    199489} 
     490 
     491/***************************************************************************** 
     492 * blur_Run:  blur effect 
     493 *****************************************************************************/ 
     494#if 0  
     495  /* This code is totally crappy */ 
     496int blur_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, 
     497              aout_buffer_t * p_buffer , picture_t * p_picture) 
     498{ 
     499    uint8_t * p_pictures; 
     500    int i,j;  
     501    int i_size;   /* Total size of one image */ 
     502     
     503    i_size = (p_picture->p[0].i_pitch * p_picture->p[0].i_lines + 
     504              p_picture->p[1].i_pitch * p_picture->p[1].i_lines + 
     505              p_picture->p[2].i_pitch * p_picture->p[2].i_lines ); 
     506     
     507    if( !p_effect->p_data ) 
     508    { 
     509        p_effect->p_data=(void *)malloc( 5 * i_size *sizeof(uint8_t)); 
     510         
     511        if( !p_effect->p_data) 
     512        { 
     513            msg_Err(p_aout,"Out of memory"); 
     514            return -1; 
     515        } 
     516        p_pictures = (uint8_t *)p_effect->p_data; 
     517    } 
     518    else 
     519    { 
     520        p_pictures =(uint8_t *)p_effect->p_data; 
     521    } 
     522 
     523    for( i = 0 ; i < 5 ; i++) 
     524    { 
     525        for ( j = 0 ; j< p_picture->p[0].i_pitch * p_picture->p[0].i_lines; i++) 
     526            p_picture->p[0].p_pixels[j] =  
     527                    p_pictures[i * i_size + j] * (100 - 20 * i) /100 ; 
     528        for ( j = 0 ; j< p_picture->p[1].i_pitch * p_picture->p[1].i_lines; i++) 
     529            p_picture->p[1].p_pixels[j] =  
     530                    p_pictures[i * i_size + 
     531                    p_picture->p[0].i_pitch * p_picture->p[0].i_lines + j ]; 
     532        for ( j = 0 ; j< p_picture->p[2].i_pitch * p_picture->p[2].i_lines; i++) 
     533            p_picture->p[2].p_pixels[j] =  
     534                    p_pictures[i * i_size + 
     535                    p_picture->p[0].i_pitch * p_picture->p[0].i_lines + 
     536                    p_picture->p[1].i_pitch * p_picture->p[1].i_lines  
     537                    + j ]; 
     538    } 
     539 
     540    memcpy ( &p_pictures[ i_size ] , &p_pictures[0] , 4 * i_size * sizeof(uint8_t) ); 
     541} 
     542#endif 
  • modules/visualization/visual/visual.c

    r6db0571 reba02c6  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: visual.c,v 1.1 2003/08/19 21:20:00 zorglub Exp $ 
     5 * $Id: visual.c,v 1.2 2003/08/29 16:56:43 zorglub Exp $ 
    66 * 
    77 * Authors: Cl�nt Stenac <zorglub@via.ecp.fr> 
     
    9898 
    9999    p_filter->p_sys->i_height = config_GetInt( p_filter , "effect-height"); 
    100     p_filter->p_sys->i_width = config_GetInt( p_filter , "effect-width"); 
     100    p_filter->p_sys->i_width  = config_GetInt( p_filter , "effect-width"); 
     101 
     102    if ( p_filter->p_sys->i_height < 20 )  
     103        p_filter->p_sys->i_height =  20; 
     104    if ( p_filter->p_sys->i_width < 20 )  
     105        p_filter->p_sys->i_width =  20; 
     106     
     107    if( (p_filter->p_sys->i_height % 2 ) != 0 ) 
     108        p_filter->p_sys->i_height --; 
     109    
     110    if( (p_filter->p_sys->i_width % 2 ) != 0 ) 
     111        p_filter->p_sys->i_width --; 
    101112     
    102113    /* Parse the effect list */ 
     
    114125    p_current_effect = p_filter->p_sys->p_first_effect; 
    115126    p_current_effect->p_next = NULL; 
    116      
    117 #define SEARCH(name , function )                                              \ 
    118     if(!strncmp( psz_effects , name, strlen(name) ) )                         \ 
    119     {                                                                         \ 
    120         p_current_effect->p_next =                                            \ 
    121                 (visual_effect_t *)malloc( sizeof( visual_effect_t ) );       \ 
    122         if( !p_current_effect )                                               \ 
    123         {                                                                     \ 
    124             msg_Err( p_filter, "Out of memory" );                             \ 
    125         }                                                                     \ 
    126         p_current_effect = p_current_effect -> p_next;                        \ 
    127         p_current_effect->pf_run = NULL;                                      \ 
    128         p_current_effect->p_next = NULL;                                      \ 
    129         p_current_effect->i_width = p_filter->p_sys->i_width;                 \ 
    130         p_current_effect->i_height = p_filter->p_sys->i_height;               \ 
    131         p_current_effect->pf_run = function ;                                 \ 
    132         p_current_effect->psz_args  = NULL;                                   \ 
    133         psz_boa = strchr( psz_effects, '{' );                                 \ 
    134         if( psz_boa )                                                         \ 
    135         {                                                                     \ 
    136             psz_eoa = strchr( psz_effects, '}');                              \ 
    137             if( ! psz_eoa )                                                   \ 
    138             {                                                                 \ 
    139                msg_Err( p_filter, "Unable to parse effect list. Aborting");   \ 
    140                return -1;                                                     \ 
    141             }                                                                 \ 
    142             *psz_eoa = '\0';                                                  \ 
    143             p_current_effect->psz_args = strdup(++psz_boa);                   \ 
    144             psz_effects = psz_eoa;                                            \ 
    145         }                                                                     \ 
    146         msg_Dbg(p_filter, "Adding filter: %s ( %s )",name,                    \ 
    147                         p_current_effect->psz_args);                          \ 
    148     } 
    149      
    150127    while(1) 
    151128    { 
     
    160137            *psz_eof = '\0'; 
    161138        } 
    162      
    163  
    164         SEARCH("dummy",dummy_Run); 
    165         SEARCH("scope",scope_Run); 
    166         SEARCH("random",random_Run); 
    167         SEARCH("spectrum",spectrum_Run); 
    168          
     139 
     140        p_current_effect->p_next = 
     141                (visual_effect_t *)malloc( sizeof( visual_effect_t ) ); 
     142        if( !p_current_effect ) 
     143        { 
     144            msg_Err( p_filter, "Out of memory" ); 
     145        } 
     146        p_current_effect = p_current_effect -> p_next; 
     147        p_current_effect->pf_run = NULL; 
     148        p_current_effect->p_next = NULL; 
     149        p_current_effect->i_width = p_filter->p_sys->i_width; 
     150        p_current_effect->i_height = p_filter->p_sys->i_height; 
     151        p_current_effect->p_data = NULL; 
     152 
     153        if(! strncasecmp(psz_effects,"dummy",5)) 
     154            p_current_effect->pf_run = dummy_Run; 
     155        else if(! strncasecmp(psz_effects,"scope",5) ) 
     156            p_current_effect->pf_run = scope_Run; 
     157        else if(! strncasecmp(psz_effects,"spectrum",8) ) 
     158            p_current_effect->pf_run = spectrum_Run; 
     159        else if(! strncasecmp(psz_effects,"random",6) ) 
     160            p_current_effect->pf_run = random_Run; 
     161#if 0 
     162        else if(! strncasecmp(psz_effects,"blur",4) ) 
     163            p_current_effect->pf_run = blur_Run; 
     164#endif 
     165        p_current_effect->psz_args  = NULL; 
     166        p_current_effect->i_nb_chans = 
     167                aout_FormatNbChannels( &p_filter->input); 
     168        psz_boa = strchr( psz_effects, '{' ); 
     169        if( psz_boa ) 
     170        { 
     171            psz_eoa = strchr( psz_effects, '}'); 
     172            if( ! psz_eoa ) 
     173            { 
     174               msg_Err( p_filter, "Unable to parse effect list. Aborting"); 
     175               return -1; 
     176            } 
     177            *psz_eoa = '\0'; 
     178            p_current_effect->psz_args = strdup(++psz_boa); 
     179            psz_effects = psz_eoa; 
     180        } 
    169181        psz_effects =  psz_eof; 
    170182        psz_effects ++; 
    171183 
    172         if( !* psz_effects || b_end == VLC_TRUE ) 
     184        if( b_end == VLC_TRUE ) 
    173185            break; 
    174186    } 
    175187                 
    176188    p_filter->pf_do_work = DoWork; 
    177     p_filter->b_in_place= 0
     189    p_filter->b_in_place= 1
    178190 
    179191    /* Open the video output */ 
    180192    p_filter->p_sys->p_vout = 
    181          vout_Create( p_filter, p_filter->p_sys->i_width,  
     193         vout_Request( p_filter, NULL, 
     194                         p_filter->p_sys->i_width,  
    182195                         p_filter->p_sys->i_height, 
    183196                  VLC_FOURCC('I','4','2','0'),  
     
    316329    while( p_current_effect )   
    317330    { 
     331 
     332#if 1 
    318333        /* FIXME: Find why it segfaults when we directly call 
    319334         * p_current_effect->pf_run(....) 
     
    335350            spectrum_Run(p_current_effect, p_aout, p_out_buf , p_outpic ); 
    336351        } 
    337              
     352#if 0 
     353        else if (p_current_effect->pf_run == blur_Run ) 
     354        { 
     355            blur_Run(p_current_effect, p_aout, p_out_buf , p_outpic ); 
     356        } 
     357#endif 
     358#else 
     359        p_current_effect->pf_run(p_current_effect, p_aout, p_out_buf , p_outpic ); 
     360#endif 
    338361        p_current_effect = p_current_effect->p_next; 
    339362    } 
     
    344367    vout_DisplayPicture ( p_filter->p_sys->p_vout, p_outpic ); 
    345368 
    346      
    347369} 
    348370 
     
    354376    aout_filter_t * p_filter = (aout_filter_t *)p_this; 
    355377 
     378    visual_effect_t *p_old; 
     379    visual_effect_t *p_cur = p_filter->p_sys->p_first_effect; 
     380     
    356381    if( p_filter->p_sys->p_vout )  
    357382    { 
     
    359384        vout_Destroy( p_filter->p_sys->p_vout ); 
    360385    } 
    361      
     386    
     387    /* Free the list */  
     388    while( p_cur ) 
     389    { 
     390        p_old = p_cur; 
     391        p_cur = p_cur->p_next; 
     392        if( p_old ) free( p_old ); 
     393    } 
     394                     
    362395    if( p_filter->p_sys != NULL ) 
    363396        free( p_filter->p_sys); 
  • modules/visualization/visual/visual.h

    r6db0571 reba02c6  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: visual.h,v 1.1 2003/08/19 21:20:00 zorglub Exp $ 
     5 * $Id: visual.h,v 1.2 2003/08/29 16:56:43 zorglub Exp $ 
    66 * 
    77 * Authors: Cl�nt Stenac <zorglub@via.ecp.fr> 
     
    5252    int        i_height; 
    5353    char *     psz_args;  
     54    int        i_nb_chans; 
    5455} visual_effect_t ; 
    5556 
     
    7273int spectrum_Run 
    7374        (visual_effect_t * , aout_instance_t *, aout_buffer_t *, picture_t *); 
    74  
     75#if 0 
     76int blur_Run 
     77        (visual_effect_t * , aout_instance_t *, aout_buffer_t *, picture_t *); 
     78#endif 
    7579 
    7680/* Default vout size */