1 /*****************************************************************************
2 * effects.c : Effects for the visualization system
3 *****************************************************************************
4 * Copyright (C) 2002 the VideoLAN team
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 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
30 #include "audio_output.h"
31 #include "aout_internal.h"
40 /*****************************************************************************
42 *****************************************************************************/
43 int dummy_Run( visual_effect_t * p_effect, aout_instance_t *p_aout,
44 aout_buffer_t * p_buffer , picture_t * p_picture)
49 /*****************************************************************************
50 * spectrum_Run: spectrum analyser
51 *****************************************************************************/
52 int spectrum_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
53 aout_buffer_t * p_buffer , picture_t * p_picture)
55 float p_output[FFT_BUFFER_SIZE]; /* Raw FFT Result */
56 int *height; /* Bar heights */
57 int *peaks; /* Peaks */
58 int i_nb_bands; /* number of bands */
59 int i_band_width; /* width of bands */
60 int i_separ; /* Should we let blanks ? */
61 int i_amp; /* Vertical amplification */
62 int i_peak; /* Should we draw peaks ? */
63 char *psz_parse = NULL; /* Args line */
65 /* Horizontal scale for 20-band equalizer */
66 const int xscale1[]={0,1,2,3,4,5,6,7,8,11,15,20,27,
67 36,47,62,82,107,141,184,255};
69 /* Horizontal scale for 80-band equalizer */
71 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
72 19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,
73 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
74 52,53,54,55,56,57,58,59,61,63,67,72,77,82,87,93,99,105,
75 110,115,121,130,141,152,163,174,185,200,255};
77 const double y_scale = 3.60673760222; /* (log 256) */
79 fft_state *p_state; /* internal FFT data */
83 int16_t p_dest[FFT_BUFFER_SIZE]; /* Adapted FFT result */
84 int16_t p_buffer1[FFT_BUFFER_SIZE]; /* Buffer on which we perform
85 the FFT (first channel) */
87 float *p_buffl = /* Original buffer */
88 (float*)p_buffer->p_buffer;
90 int16_t *p_buffs; /* int16_t converted buffer */
91 int16_t *p_s16_buff = NULL; /* int16_t converted buffer */
93 p_s16_buff = (int16_t*)malloc(
94 p_buffer->i_nb_samples * p_effect->i_nb_chans * sizeof(int16_t));
98 msg_Err(p_aout,"Out of memory");
102 p_buffs = p_s16_buff;
103 i_nb_bands = config_GetInt ( p_aout, "visual-nbbands" );
104 i_separ = config_GetInt( p_aout, "visual-separ" );
105 i_amp = config_GetInt ( p_aout, "visual-amp" );
106 i_peak = config_GetInt ( p_aout, "visual-peaks" );
108 if( i_nb_bands == 20)
118 if( !p_effect->p_data )
120 p_effect->p_data=(void *)malloc(i_nb_bands * sizeof(int) );
121 if( !p_effect->p_data)
123 msg_Err(p_aout,"Out of memory");
126 peaks = (int *)p_effect->p_data;
127 for( i = 0 ; i < i_nb_bands ; i++)
135 peaks =(int *)p_effect->p_data;
139 height = (int *)malloc( i_nb_bands * sizeof(int) );
142 msg_Err(p_aout,"Out of memory");
145 /* Convert the buffer to int16_t */
146 /* Pasted from float32tos16.c */
147 for (i = p_buffer->i_nb_samples * p_effect->i_nb_chans; i--; )
149 union { float f; int32_t i; } u;
150 u.f = *p_buffl + 384.0;
151 if(u.i > 0x43c07fff ) * p_buffs = 32767;
152 else if ( u.i < 0x43bf8000 ) *p_buffs = -32768;
153 else *p_buffs = u.i - 0x43c00000;
155 p_buffl++ ; p_buffs++ ;
157 p_state = visual_fft_init();
160 msg_Err(p_aout,"Unable to initialize FFT transform");
163 p_buffs = p_s16_buff;
164 for ( i = 0 ; i < FFT_BUFFER_SIZE ; i++)
167 p_buffer1[i] = *p_buffs;
168 p_buffs = p_buffs + p_effect->i_nb_chans;
170 fft_perform( p_buffer1, p_output, p_state);
171 for(i= 0; i< FFT_BUFFER_SIZE ; i++ )
172 p_dest[i] = ( (int) sqrt( p_output [ i + 1 ] ) ) >> 8;
174 for ( i = 0 ; i< i_nb_bands ;i++)
176 /* We search the maximum on one scale */
177 for( j = xscale[i] , y=0 ; j< xscale[ i + 1 ] ; j++ )
182 /* Calculate the height of the bar */
183 y >>=7;/* remove some noise */
186 height[i] = (int)log(y)* y_scale;
195 /* Draw the bar now */
196 i_band_width = floor( p_effect->i_width / i_nb_bands) ;
198 if( i_amp * height[i] > peaks[i])
200 peaks[i] = i_amp * height[i];
202 else if (peaks[i] > 0 )
204 peaks[i] -= PEAK_SPEED;
205 if( peaks[i] < i_amp * height[i] )
207 peaks[i] = i_amp * height[i];
215 if( peaks[i] > 0 && i_peak )
217 if( peaks[i] >= p_effect->i_height )
218 peaks[i] = p_effect->i_height - 2;
221 for( j = 0 ; j< i_band_width - i_separ; j++)
223 for( k = 0 ; k< 3 ; k ++)
226 *(p_picture->p[0].p_pixels +
227 (p_picture->p[0].i_lines - i_line -1 -k ) *
228 p_picture->p[0].i_pitch + (i_band_width*i +j) )
231 *(p_picture->p[1].p_pixels +
232 (p_picture->p[1].i_lines - i_line /2 -1 -k/2 ) *
233 p_picture->p[1].i_pitch +
234 ( ( i_band_width * i + j ) /2 ) )
237 if( 0x04 * (i_line + k ) - 0x0f > 0 )
239 if ( 0x04 * (i_line + k ) -0x0f < 0xff)
240 *(p_picture->p[2].p_pixels +
241 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
242 p_picture->p[2].i_pitch +
243 ( ( i_band_width * i + j ) /2 ) )
244 = ( 0x04 * ( i_line + k ) ) -0x0f ;
246 *(p_picture->p[2].p_pixels +
247 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
248 p_picture->p[2].i_pitch +
249 ( ( i_band_width * i + j ) /2 ) )
254 *(p_picture->p[2].p_pixels +
255 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
256 p_picture->p[2].i_pitch +
257 ( ( i_band_width * i + j ) /2 ) )
264 if(height[i] * i_amp > p_effect->i_height)
265 height[i] = floor(p_effect->i_height / i_amp );
267 for(i_line = 0 ; i_line < i_amp * height[i]; i_line ++ )
269 for( j = 0 ; j< i_band_width - i_separ ; j++)
271 *(p_picture->p[0].p_pixels +
272 (p_picture->p[0].i_lines - i_line -1) *
273 p_picture->p[0].i_pitch + (i_band_width*i +j) ) = 0xff;
275 *(p_picture->p[1].p_pixels +
276 (p_picture->p[1].i_lines - i_line /2 -1) *
277 p_picture->p[1].i_pitch +
278 ( ( i_band_width * i + j ) /2 ) ) = 0x00;
280 if( 0x04 * i_line - 0x0f > 0 )
282 if( 0x04 * i_line - 0x0f < 0xff )
283 *(p_picture->p[2].p_pixels +
284 (p_picture->p[2].i_lines - i_line /2 - 1) *
285 p_picture->p[2].i_pitch +
286 ( ( i_band_width * i + j ) /2 ) ) =
287 ( 0x04 * i_line) -0x0f ;
289 *(p_picture->p[2].p_pixels +
290 (p_picture->p[2].i_lines - i_line /2 - 1) *
291 p_picture->p[2].i_pitch +
292 ( ( i_band_width * i + j ) /2 ) ) =
297 *(p_picture->p[2].p_pixels +
298 (p_picture->p[2].i_lines - i_line /2 - 1) *
299 p_picture->p[2].i_pitch +
300 ( ( i_band_width * i + j ) /2 ) ) =
307 fft_close( p_state );
309 if( p_s16_buff != NULL )
315 if(height) free(height);
317 if(psz_parse) free(psz_parse);
323 /*****************************************************************************
324 * spectrometer_Run: derivative spectrum analysis
325 *****************************************************************************/
326 int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
327 aout_buffer_t * p_buffer , picture_t * p_picture)
329 #define Y(R,G,B) ((uint8_t)( (R * .299) + (G * .587) + (B * .114) ))
330 #define U(R,G,B) ((uint8_t)( (R * -.169) + (G * -.332) + (B * .500) + 128 ))
331 #define V(R,G,B) ((uint8_t)( (R * .500) + (G * -.419) + (B * -.0813) + 128 ))
332 float p_output[FFT_BUFFER_SIZE]; /* Raw FFT Result */
333 int *height; /* Bar heights */
334 int *peaks; /* Peaks */
335 int i_nb_bands; /* number of bands */
336 int i_band_width; /* width of bands */
337 int i_separ; /* Should we let blanks ? */
338 int i_amp; /* Vertical amplification */
339 int i_peak; /* Should we draw peaks ? */
341 int i_original; /* original spectrum graphic routine */
342 int i_rad; /* radius of circle of base of bands */
343 int i_sections; /* sections of spectranalysis */
344 int i_extra_width; /* extra width on peak */
345 int i_peak_height; /* height of peak */
346 int c; /* sentinel container of total spectral sections */
347 double band_sep_angle; /* angled separation between beginning of each band */
348 double section_sep_angle;/* " " ' " ' " " spectrum section */
349 int max_band_length; /* try not to go out of screen */
350 int i_show_base; /* Should we draw base of circle ? */
351 int i_show_bands; /* Should we draw bands ? */
352 //int i_invert_bands; /* do the bands point inward ? */
353 double a; /* for various misc angle situations in radians */
354 int x,y,xx,yy; /* various misc x/y */
355 char color1; /* V slide on a YUV color cube */
356 //char color2; /* U slide.. ? color2 fade color ? */
358 char *psz_parse = NULL; /* Args line */
360 /* Horizontal scale for 20-band equalizer */
361 const int xscale1[]={0,1,2,3,4,5,6,7,8,11,15,20,27,
362 36,47,62,82,107,141,184,255};
364 /* Horizontal scale for 80-band equalizer */
365 const int xscale2[] =
366 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
367 19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,
368 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
369 52,53,54,55,56,57,58,59,61,63,67,72,77,82,87,93,99,105,
370 110,115,121,130,141,152,163,174,185,200,255};
372 const double y_scale = 3.60673760222; /* (log 256) */
374 fft_state *p_state; /* internal FFT data */
378 int16_t p_dest[FFT_BUFFER_SIZE]; /* Adapted FFT result */
379 int16_t p_buffer1[FFT_BUFFER_SIZE]; /* Buffer on which we perform
380 the FFT (first channel) */
381 float *p_buffl = /* Original buffer */
382 (float*)p_buffer->p_buffer;
384 int16_t *p_buffs; /* int16_t converted buffer */
385 int16_t *p_s16_buff = NULL; /* int16_t converted buffer */
389 p_s16_buff = (int16_t*)malloc(
390 p_buffer->i_nb_samples * p_effect->i_nb_chans * sizeof(int16_t));
394 msg_Err(p_aout,"Out of memory");
398 p_buffs = p_s16_buff;
399 //i_nb_bands = config_GetInt ( p_aout, "visual-nbbands" );
400 //i_separ = config_GetInt( p_aout, "visual-separ" );
401 //i_amp = config_GetInt ( p_aout, "visual-amp" );
402 //i_peak = config_GetInt ( p_aout, "visual-peaks" );
403 /* previous 4 vars changed.. using them as `spect' variables */
404 i_original = config_GetInt ( p_aout, "spect-show-original" );
405 i_nb_bands = config_GetInt ( p_aout, "spect-nbbands" );
406 i_separ = config_GetInt ( p_aout, "spect-separ" );
407 i_amp = config_GetInt ( p_aout, "spect-amp" );
408 i_peak = config_GetInt ( p_aout, "spect-show-peaks" );
409 i_show_base = config_GetInt ( p_aout, "spect-show-base" );
410 i_show_bands = config_GetInt ( p_aout, "spect-show-bands" );
411 i_rad = config_GetInt ( p_aout, "spect-radius" );
412 i_sections = config_GetInt ( p_aout, "spect-sections" );
413 i_extra_width = config_GetInt ( p_aout, "spect-peak-width" );
414 i_peak_height = config_GetInt ( p_aout, "spect-peak-height" );
415 color1 = config_GetInt ( p_aout, "spect-color" );
417 if( i_nb_bands == 20)
426 i_nb_bands *= i_sections;
427 /* whoops, dont malloc the following memory for all the duplicated bands..
428 -only the original 20 or 80 will be fine */
430 if( !p_effect->p_data )
432 p_effect->p_data=(void *)malloc(i_nb_bands * sizeof(int) );
433 if( !p_effect->p_data)
435 msg_Err(p_aout,"Out of memory");
438 peaks = (int *)p_effect->p_data;
439 for( i = 0 ; i < i_nb_bands ; i++)
446 peaks =(int *)p_effect->p_data;
450 height = (int *)malloc( i_nb_bands * sizeof(int) );
453 msg_Err(p_aout,"Out of memory");
456 /* Convert the buffer to int16_t */
457 /* Pasted from float32tos16.c */
458 for (i = p_buffer->i_nb_samples * p_effect->i_nb_chans; i--; )
460 union { float f; int32_t i; } u;
461 u.f = *p_buffl + 384.0;
462 if(u.i > 0x43c07fff ) * p_buffs = 32767;
463 else if ( u.i < 0x43bf8000 ) *p_buffs = -32768;
464 else *p_buffs = u.i - 0x43c00000;
466 p_buffl++ ; p_buffs++ ;
468 p_state = visual_fft_init();
471 msg_Err(p_aout,"Unable to initialize FFT transform");
474 p_buffs = p_s16_buff;
475 for ( i = 0 ; i < FFT_BUFFER_SIZE ; i++)
478 p_buffer1[i] = *p_buffs;
479 p_buffs = p_buffs + p_effect->i_nb_chans;
481 fft_perform( p_buffer1, p_output, p_state);
482 for(i= 0; i< FFT_BUFFER_SIZE ; i++ )
483 p_dest[i] = ( (int) sqrt( p_output [ i + 1 ] ) ) >> 8;
485 for ( i = 0 ; i< i_nb_bands/i_sections ;i++)
487 /* We search the maximum on one scale */
488 for( j = xscale[i] , y=0 ; j< xscale[ i + 1 ] ; j++ )
493 /* Calculate the height of the bar */
494 y >>=7;/* remove some noise */
497 height[i] = (int)log(y)* y_scale;
506 /* Draw the bar now */
507 i_band_width = floor( p_effect->i_width / (i_nb_bands/i_sections)) ;
509 if( i_amp * height[i] > peaks[i])
511 peaks[i] = i_amp * height[i];
513 else if (peaks[i] > 0 )
515 peaks[i] -= PEAK_SPEED;
516 if( peaks[i] < i_amp * height[i] )
518 peaks[i] = i_amp * height[i];
526 if( i_original != 0 )
528 if( peaks[i] > 0 && i_peak )
530 if( peaks[i] >= p_effect->i_height )
531 peaks[i] = p_effect->i_height - 2;
534 for( j = 0 ; j< i_band_width - i_separ; j++)
536 for( k = 0 ; k< 3 ; k ++)
539 *(p_picture->p[0].p_pixels +
540 (p_picture->p[0].i_lines - i_line -1 -k ) *
541 p_picture->p[0].i_pitch + (i_band_width*i +j) )
544 *(p_picture->p[1].p_pixels +
545 (p_picture->p[1].i_lines - i_line /2 -1 -k/2 ) *
546 p_picture->p[1].i_pitch +
547 ( ( i_band_width * i + j ) /2 ) )
550 if( 0x04 * (i_line + k ) - 0x0f > 0 )
552 if ( 0x04 * (i_line + k ) -0x0f < 0xff)
553 *(p_picture->p[2].p_pixels +
554 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
555 p_picture->p[2].i_pitch +
556 ( ( i_band_width * i + j ) /2 ) )
557 = ( 0x04 * ( i_line + k ) ) -0x0f ;
559 *(p_picture->p[2].p_pixels +
560 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
561 p_picture->p[2].i_pitch +
562 ( ( i_band_width * i + j ) /2 ) )
567 *(p_picture->p[2].p_pixels +
568 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
569 p_picture->p[2].i_pitch +
570 ( ( i_band_width * i + j ) /2 ) )
576 if(height[i] * i_amp > p_effect->i_height)
577 height[i] = floor(p_effect->i_height / i_amp );
579 for(i_line = 0 ; i_line < i_amp * height[i]; i_line ++ )
581 for( j = 0 ; j< i_band_width - i_separ ; j++)
583 *(p_picture->p[0].p_pixels +
584 (p_picture->p[0].i_lines - i_line -1) *
585 p_picture->p[0].i_pitch + (i_band_width*i +j) ) = 0xff;
587 *(p_picture->p[1].p_pixels +
588 (p_picture->p[1].i_lines - i_line /2 -1) *
589 p_picture->p[1].i_pitch +
590 ( ( i_band_width * i + j ) /2 ) ) = 0x00;
592 if( 0x04 * i_line - 0x0f > 0 )
594 if( 0x04 * i_line - 0x0f < 0xff )
595 *(p_picture->p[2].p_pixels +
596 (p_picture->p[2].i_lines - i_line /2 - 1) *
597 p_picture->p[2].i_pitch +
598 ( ( i_band_width * i + j ) /2 ) ) =
599 ( 0x04 * i_line) -0x0f ;
601 *(p_picture->p[2].p_pixels +
602 (p_picture->p[2].i_lines - i_line /2 - 1) *
603 p_picture->p[2].i_pitch +
604 ( ( i_band_width * i + j ) /2 ) ) =
609 *(p_picture->p[2].p_pixels +
610 (p_picture->p[2].i_lines - i_line /2 - 1) *
611 p_picture->p[2].i_pitch +
612 ( ( i_band_width * i + j ) /2 ) ) =
620 band_sep_angle = 360.0 / i_nb_bands;
621 section_sep_angle = 360.0 / i_sections;
622 if( i_peak_height < 1 )
624 max_band_length = p_picture->p[0].i_lines / 2 - ( i_rad + i_peak_height + 1 );
626 i_band_width = floor( 360 / i_nb_bands - i_separ );
627 if( i_band_width < 1 )
630 for( c = 0 ; c < i_sections ; c++ )
631 for( i = 0 ; i < (i_nb_bands / i_sections) ; i++ )
634 if( peaks[i] > 0 && i_peak )
636 if( peaks[i] >= p_effect->i_height )
637 peaks[i] = p_effect->i_height - 2;
640 /* circular line pattern(so color blend is more visible) */
641 for( j = 0 ; j < i_peak_height ; j++ )
643 x = p_picture->p[0].i_pitch / 2;
644 y = p_picture->p[0].i_lines / 2;
647 for( k = 0 ; k < (i_band_width + i_extra_width) ; k++ )
651 a = ( (i+1) * band_sep_angle + section_sep_angle * (c+1) + k )
653 x += (double)( cos(a) * (double)( i_line + j + i_rad ) );
654 y += (double)( -sin(a) * (double)( i_line + j + i_rad ) );
656 *(p_picture->p[0].p_pixels + x + y * p_picture->p[0].i_pitch
657 ) = 255;/* Y(R,G,B); */
662 *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
663 - p_picture->p[1].i_pitch
664 ) = 0;/* U(R,G,B); */
666 if( 0x04 * (i_line + k ) - 0x0f > 0 )
668 if ( 0x04 * (i_line + k ) -0x0f < 0xff)
669 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
670 - p_picture->p[2].i_pitch
671 ) = ( 0x04 * ( i_line + k ) ) -(color1-1);/* -V(R,G,B); */
673 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
674 - p_picture->p[2].i_pitch
675 ) = 255;/* V(R,G,B); */
679 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
680 - p_picture->p[2].i_pitch
681 ) = color1;/* V(R,G,B); */
687 if( (height[i] * i_amp) > p_effect->i_height )
688 height[i] = floor( p_effect->i_height / i_amp );
690 /* DO BASE OF BAND (mostly makes a circle) */
691 if( i_show_base != 0 )
693 x = p_picture->p[0].i_pitch / 2;
694 y = p_picture->p[0].i_lines / 2;
696 a = ( (i+1) * band_sep_angle + section_sep_angle * (c+1) )
698 x += (double)( cos(a) * (double)i_rad );/* newb-forceful casting */
699 y += (double)( -sin(a) * (double)i_rad );
701 *(p_picture->p[0].p_pixels + x + y * p_picture->p[0].i_pitch
702 ) = 255;/* Y(R,G,B); */
707 *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
708 - p_picture->p[1].i_pitch
709 ) = 0;/* U(R,G,B); */
711 if( 0x04 * i_line - 0x0f > 0 )
713 if( 0x04 * i_line -0x0f < 0xff)
714 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
715 - p_picture->p[2].i_pitch
716 ) = ( 0x04 * i_line) -(color1-1);/* -V(R,G,B); */
718 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
719 - p_picture->p[2].i_pitch
720 ) = 255;/* V(R,G,B); */
724 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
725 - p_picture->p[2].i_pitch
726 ) = color1;/* V(R,G,B); */
731 if( i_show_bands != 0 )
732 for( j = 0 ; j < i_band_width ; j++ )
734 x = p_picture->p[0].i_pitch / 2;
735 y = p_picture->p[0].i_lines / 2;
738 a = ( (i+1) * band_sep_angle + section_sep_angle * (c+1) + j )
741 for( k = (i_rad+1) ; k < max_band_length ; k++ )
743 if( (k-i_rad) > height[i] )
748 x += (double)( cos(a) * (double)k );/* newbed! */
749 y += (double)( -sin(a) * (double)k );
751 *(p_picture->p[0].p_pixels + x + y * p_picture->p[0].i_pitch
757 *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
758 - p_picture->p[1].i_pitch
761 if( 0x04 * i_line - 0x0f > 0 )
763 if ( 0x04 * i_line -0x0f < 0xff)
764 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
765 - p_picture->p[2].i_pitch
766 ) = ( 0x04 * i_line) -(color1-1);
768 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
769 - p_picture->p[2].i_pitch
774 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
775 - p_picture->p[2].i_pitch
782 fft_close( p_state );
784 if( p_s16_buff != NULL )
790 if(height) free(height);
792 if(psz_parse) free(psz_parse);
798 /*****************************************************************************
799 * scope_Run: scope effect
800 *****************************************************************************/
801 int scope_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
802 aout_buffer_t * p_buffer , picture_t * p_picture)
806 uint8_t *ppp_area[2][3];
809 for( i_index = 0 ; i_index < 2 ; i_index++ )
812 for( j = 0 ; j < 3 ; j++ )
814 ppp_area[i_index][j] =
815 p_picture->p[j].p_pixels + i_index * p_picture->p[j].i_lines
816 / 2 * p_picture->p[j].i_pitch;
820 for( i_index = 0, p_sample = (float *)p_buffer->p_buffer;
821 i_index < p_effect->i_width;
827 i_value = (*p_sample++ +1) * 127;
829 + p_picture->p[0].i_pitch * i_index / p_effect->i_width
830 + p_picture->p[0].i_lines * i_value / 512
831 * p_picture->p[0].i_pitch) = 0xbf;
833 + p_picture->p[1].i_pitch * i_index / p_effect->i_width
834 + p_picture->p[1].i_lines * i_value / 512
835 * p_picture->p[1].i_pitch) = 0xff;
839 i_value = ( *p_sample++ +1 ) * 127;
841 + p_picture->p[0].i_pitch * i_index / p_effect->i_width
842 + p_picture->p[0].i_lines * i_value / 512
843 * p_picture->p[0].i_pitch) = 0x9f;
845 + p_picture->p[2].i_pitch * i_index / p_effect->i_width
846 + p_picture->p[2].i_lines * i_value / 512
847 * p_picture->p[2].i_pitch) = 0xdd;
852 /*****************************************************************************
853 * blur_Run: blur effect
854 *****************************************************************************/
856 /* This code is totally crappy */
857 int blur_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
858 aout_buffer_t * p_buffer , picture_t * p_picture)
860 uint8_t * p_pictures;
862 int i_size; /* Total size of one image */
864 i_size = (p_picture->p[0].i_pitch * p_picture->p[0].i_lines +
865 p_picture->p[1].i_pitch * p_picture->p[1].i_lines +
866 p_picture->p[2].i_pitch * p_picture->p[2].i_lines );
868 if( !p_effect->p_data )
870 p_effect->p_data=(void *)malloc( 5 * i_size *sizeof(uint8_t));
872 if( !p_effect->p_data)
874 msg_Err(p_aout,"Out of memory");
877 p_pictures = (uint8_t *)p_effect->p_data;
881 p_pictures =(uint8_t *)p_effect->p_data;
884 for( i = 0 ; i < 5 ; i++)
886 for ( j = 0 ; j< p_picture->p[0].i_pitch * p_picture->p[0].i_lines; i++)
887 p_picture->p[0].p_pixels[j] =
888 p_pictures[i * i_size + j] * (100 - 20 * i) /100 ;
889 for ( j = 0 ; j< p_picture->p[1].i_pitch * p_picture->p[1].i_lines; i++)
890 p_picture->p[1].p_pixels[j] =
891 p_pictures[i * i_size +
892 p_picture->p[0].i_pitch * p_picture->p[0].i_lines + j ];
893 for ( j = 0 ; j< p_picture->p[2].i_pitch * p_picture->p[2].i_lines; i++)
894 p_picture->p[2].p_pixels[j] =
895 p_pictures[i * i_size +
896 p_picture->p[0].i_pitch * p_picture->p[0].i_lines +
897 p_picture->p[1].i_pitch * p_picture->p[1].i_lines
901 memcpy ( &p_pictures[ i_size ] , &p_pictures[0] , 4 * i_size * sizeof(uint8_t) );