1 /*****************************************************************************
2 * effects.c : Effects for the visualization system
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: effects.c,v 1.1 2003/08/19 21:20:00 zorglub Exp $
7 * Authors: Clément Stenac <zorglub@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 /*****************************************************************************
32 * Argument list parsers *
33 *****************************************************************************/
34 int args_getint(char *psz_parse, char * name,const int defaut)
38 if( psz_parse != NULL )
40 if(!strncmp( psz_parse, name, strlen(name) ) )
42 psz_parse += strlen( name );
43 psz_eof = strchr( psz_parse , ',' );
45 psz_eof = psz_parse + strlen(psz_parse);
50 i_value = atoi(++psz_parse);
60 char * args_getpsz(char *psz_parse, char * name,const char * defaut)
64 if( psz_parse != NULL )
66 if(!strncmp( psz_parse, name, strlen(name) ) )
68 psz_parse += strlen( name );
69 psz_eof = strchr( psz_parse , ',' );
71 psz_eof = psz_parse + strlen(psz_parse);
76 psz_value = strdup(++psz_parse);
82 return strdup(defaut);
86 /*****************************************************************************
88 *****************************************************************************/
89 int dummy_Run( visual_effect_t * p_effect, aout_instance_t *p_aout,
90 aout_buffer_t * p_buffer , picture_t * p_picture)
95 /*****************************************************************************
96 * spectrum_Run: spectrum analyser
97 *****************************************************************************/
98 int spectrum_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
99 aout_buffer_t * p_buffer , picture_t * p_picture)
105 /*****************************************************************************
106 * scope_Run: scope effect
107 *****************************************************************************/
108 int scope_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
109 aout_buffer_t * p_buffer , picture_t * p_picture)
116 for( i_index = 0 ; i_index < 2 ; i_index++ )
119 for( j = 0 ; j < 3 ; j++ )
121 ppp_area[i_index][j] =
122 p_picture->p[j].p_pixels + i_index * p_picture->p[j].i_lines
123 / 2 * p_picture->p[j].i_pitch;
127 for( i_index = 0, p_sample = (float *)p_buffer->p_buffer;
128 i_index < p_effect->i_width;
134 i_value = (*p_sample++ +1) * 127;
136 + p_picture->p[0].i_pitch * i_index / p_effect->i_width
137 + p_picture->p[0].i_lines * i_value / 512
138 * p_picture->p[0].i_pitch) = 0xbf;
140 + p_picture->p[1].i_pitch * i_index / p_effect->i_width
141 + p_picture->p[1].i_lines * i_value / 512
142 * p_picture->p[1].i_pitch) = 0xff;
146 i_value = ( *p_sample++ +1 ) * 127;
148 + p_picture->p[0].i_pitch * i_index / p_effect->i_width
149 + p_picture->p[0].i_lines * i_value / 512
150 * p_picture->p[0].i_pitch) = 0x9f;
152 + p_picture->p[2].i_pitch * i_index / p_effect->i_width
153 + p_picture->p[2].i_lines * i_value / 512
154 * p_picture->p[2].i_pitch) = 0xdd;
160 /*****************************************************************************
161 * random_Run: random plots display effect
162 *****************************************************************************/
163 int random_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
164 aout_buffer_t * p_buffer , picture_t * p_picture)
167 char *psz_parse= NULL;
168 int i , i_y , i_u , i_v;
170 srand((unsigned int)mdate());
172 if( p_effect->psz_args )
174 psz_parse = strdup( p_effect->psz_args );
177 i_nb_plots = args_getint ( psz_parse , "nb" , 200 );
178 if(i_nb_plots) break;
190 for( i = 0 ; i < i_nb_plots ; i++ )
192 i_position = rand() % (p_effect->i_width * p_effect->i_height );
196 *(p_picture->p[0].p_pixels + i_position )= i_u;