00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <stdlib.h>
00028 #include <vlc/vlc.h>
00029 #include <vlc/vout.h>
00030 #include "audio_output.h"
00031 #include "aout_internal.h"
00032
00033 #include "visual.h"
00034 #include <math.h>
00035
00036 #include "fft.h"
00037
00038 #define PEAK_SPEED 1
00039
00040
00041
00042
00043 int dummy_Run( visual_effect_t * p_effect, aout_instance_t *p_aout,
00044 aout_buffer_t * p_buffer , picture_t * p_picture)
00045 {
00046 return 0;
00047 }
00048
00049
00050
00051
00052 int spectrum_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
00053 aout_buffer_t * p_buffer , picture_t * p_picture)
00054 {
00055 float p_output[FFT_BUFFER_SIZE];
00056 int *height;
00057 int *peaks;
00058 int i_nb_bands;
00059 int i_band_width;
00060 int i_separ;
00061 int i_amp;
00062 int i_peak;
00063 char *psz_parse = NULL;
00064
00065
00066 const int xscale1[]={0,1,2,3,4,5,6,7,8,11,15,20,27,
00067 36,47,62,82,107,141,184,255};
00068
00069
00070 const int xscale2[] =
00071 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
00072 19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,
00073 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
00074 52,53,54,55,56,57,58,59,61,63,67,72,77,82,87,93,99,105,
00075 110,115,121,130,141,152,163,174,185,200,255};
00076 const int *xscale;
00077 const double y_scale = 3.60673760222;
00078
00079 fft_state *p_state;
00080
00081 int i , j , y , k;
00082 int i_line;
00083 int16_t p_dest[FFT_BUFFER_SIZE];
00084 int16_t p_buffer1[FFT_BUFFER_SIZE];
00085
00086
00087 float *p_buffl =
00088 (float*)p_buffer->p_buffer;
00089
00090 int16_t *p_buffs;
00091 int16_t *p_s16_buff = NULL;
00092
00093 p_s16_buff = (int16_t*)malloc(
00094 p_buffer->i_nb_samples * p_effect->i_nb_chans * sizeof(int16_t));
00095
00096 if( !p_s16_buff )
00097 {
00098 msg_Err(p_aout,"Out of memory");
00099 return -1;
00100 }
00101
00102 p_buffs = p_s16_buff;
00103 i_nb_bands = config_GetInt ( p_aout, "visual-nbbands" );
00104 i_separ = config_GetInt( p_aout, "visual-separ" );
00105 i_amp = config_GetInt ( p_aout, "visual-amp" );
00106 i_peak = config_GetInt ( p_aout, "visual-peaks" );
00107
00108 if( i_nb_bands == 20)
00109 {
00110 xscale = xscale1;
00111 }
00112 else
00113 {
00114 i_nb_bands = 80;
00115 xscale = xscale2;
00116 }
00117
00118 if( !p_effect->p_data )
00119 {
00120 p_effect->p_data=(void *)malloc(i_nb_bands * sizeof(int) );
00121 if( !p_effect->p_data)
00122 {
00123 msg_Err(p_aout,"Out of memory");
00124 return -1;
00125 }
00126 peaks = (int *)p_effect->p_data;
00127 for( i = 0 ; i < i_nb_bands ; i++)
00128 {
00129 peaks[i] = 0;
00130 }
00131
00132 }
00133 else
00134 {
00135 peaks =(int *)p_effect->p_data;
00136 }
00137
00138
00139 height = (int *)malloc( i_nb_bands * sizeof(int) );
00140 if( !height)
00141 {
00142 msg_Err(p_aout,"Out of memory");
00143 return -1;
00144 }
00145
00146
00147 for (i = p_buffer->i_nb_samples * p_effect->i_nb_chans; i--; )
00148 {
00149 union { float f; int32_t i; } u;
00150 u.f = *p_buffl + 384.0;
00151 if(u.i > 0x43c07fff ) * p_buffs = 32767;
00152 else if ( u.i < 0x43bf8000 ) *p_buffs = -32768;
00153 else *p_buffs = u.i - 0x43c00000;
00154
00155 p_buffl++ ; p_buffs++ ;
00156 }
00157 p_state = visual_fft_init();
00158 if( !p_state)
00159 {
00160 msg_Err(p_aout,"Unable to initialize FFT transform");
00161 return -1;
00162 }
00163 p_buffs = p_s16_buff;
00164 for ( i = 0 ; i < FFT_BUFFER_SIZE ; i++)
00165 {
00166 p_output[i] = 0;
00167 p_buffer1[i] = *p_buffs;
00168 p_buffs = p_buffs + p_effect->i_nb_chans;
00169 }
00170 fft_perform( p_buffer1, p_output, p_state);
00171 for(i= 0; i< FFT_BUFFER_SIZE ; i++ )
00172 p_dest[i] = ( (int) sqrt( p_output [ i + 1 ] ) ) >> 8;
00173
00174 for ( i = 0 ; i< i_nb_bands ;i++)
00175 {
00176
00177 for( j = xscale[i] , y=0 ; j< xscale[ i + 1 ] ; j++ )
00178 {
00179 if ( p_dest[j] > y )
00180 y = p_dest[j];
00181 }
00182
00183 y >>=7;
00184 if( y != 0)
00185 {
00186 height[i] = (int)log(y)* y_scale;
00187 if(height[i] > 150)
00188 height[i] = 150;
00189 }
00190 else
00191 {
00192 height[i] = 0 ;
00193 }
00194
00195
00196 i_band_width = floor( p_effect->i_width / i_nb_bands) ;
00197
00198 if( i_amp * height[i] > peaks[i])
00199 {
00200 peaks[i] = i_amp * height[i];
00201 }
00202 else if (peaks[i] > 0 )
00203 {
00204 peaks[i] -= PEAK_SPEED;
00205 if( peaks[i] < i_amp * height[i] )
00206 {
00207 peaks[i] = i_amp * height[i];
00208 }
00209 if( peaks[i] < 0 )
00210 {
00211 peaks[i] = 0;
00212 }
00213 }
00214
00215 if( peaks[i] > 0 && i_peak )
00216 {
00217 if( peaks[i] >= p_effect->i_height )
00218 peaks[i] = p_effect->i_height - 2;
00219 i_line = peaks[i];
00220
00221 for( j = 0 ; j< i_band_width - i_separ; j++)
00222 {
00223 for( k = 0 ; k< 3 ; k ++)
00224 {
00225
00226 *(p_picture->p[0].p_pixels +
00227 (p_picture->p[0].i_lines - i_line -1 -k ) *
00228 p_picture->p[0].i_pitch + (i_band_width*i +j) )
00229 = 0xff;
00230
00231 *(p_picture->p[1].p_pixels +
00232 (p_picture->p[1].i_lines - i_line /2 -1 -k/2 ) *
00233 p_picture->p[1].i_pitch +
00234 ( ( i_band_width * i + j ) /2 ) )
00235 = 0x00;
00236
00237 if( 0x04 * (i_line + k ) - 0x0f > 0 )
00238 {
00239 if ( 0x04 * (i_line + k ) -0x0f < 0xff)
00240 *(p_picture->p[2].p_pixels +
00241 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
00242 p_picture->p[2].i_pitch +
00243 ( ( i_band_width * i + j ) /2 ) )
00244 = ( 0x04 * ( i_line + k ) ) -0x0f ;
00245 else
00246 *(p_picture->p[2].p_pixels +
00247 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
00248 p_picture->p[2].i_pitch +
00249 ( ( i_band_width * i + j ) /2 ) )
00250 = 0xff;
00251 }
00252 else
00253 {
00254 *(p_picture->p[2].p_pixels +
00255 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
00256 p_picture->p[2].i_pitch +
00257 ( ( i_band_width * i + j ) /2 ) )
00258 = 0x10 ;
00259 }
00260 }
00261 }
00262 }
00263
00264 if(height[i] * i_amp > p_effect->i_height)
00265 height[i] = floor(p_effect->i_height / i_amp );
00266
00267 for(i_line = 0 ; i_line < i_amp * height[i]; i_line ++ )
00268 {
00269 for( j = 0 ; j< i_band_width - i_separ ; j++)
00270 {
00271 *(p_picture->p[0].p_pixels +
00272 (p_picture->p[0].i_lines - i_line -1) *
00273 p_picture->p[0].i_pitch + (i_band_width*i +j) ) = 0xff;
00274
00275 *(p_picture->p[1].p_pixels +
00276 (p_picture->p[1].i_lines - i_line /2 -1) *
00277 p_picture->p[1].i_pitch +
00278 ( ( i_band_width * i + j ) /2 ) ) = 0x00;
00279
00280 if( 0x04 * i_line - 0x0f > 0 )
00281 {
00282 if( 0x04 * i_line - 0x0f < 0xff )
00283 *(p_picture->p[2].p_pixels +
00284 (p_picture->p[2].i_lines - i_line /2 - 1) *
00285 p_picture->p[2].i_pitch +
00286 ( ( i_band_width * i + j ) /2 ) ) =
00287 ( 0x04 * i_line) -0x0f ;
00288 else
00289 *(p_picture->p[2].p_pixels +
00290 (p_picture->p[2].i_lines - i_line /2 - 1) *
00291 p_picture->p[2].i_pitch +
00292 ( ( i_band_width * i + j ) /2 ) ) =
00293 0xff;
00294 }
00295 else
00296 {
00297 *(p_picture->p[2].p_pixels +
00298 (p_picture->p[2].i_lines - i_line /2 - 1) *
00299 p_picture->p[2].i_pitch +
00300 ( ( i_band_width * i + j ) /2 ) ) =
00301 0x10 ;
00302 }
00303 }
00304 }
00305 }
00306
00307 fft_close( p_state );
00308
00309 if( p_s16_buff != NULL )
00310 {
00311 free( p_s16_buff );
00312 p_s16_buff = NULL;
00313 }
00314
00315 if(height) free(height);
00316
00317 if(psz_parse) free(psz_parse);
00318
00319 return 0;
00320 }
00321
00322
00323
00324
00325
00326 int spectrometer_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
00327 aout_buffer_t * p_buffer , picture_t * p_picture)
00328 {
00329 #define Y(R,G,B) ((uint8_t)( (R * .299) + (G * .587) + (B * .114) ))
00330 #define U(R,G,B) ((uint8_t)( (R * -.169) + (G * -.332) + (B * .500) + 128 ))
00331 #define V(R,G,B) ((uint8_t)( (R * .500) + (G * -.419) + (B * -.0813) + 128 ))
00332 float p_output[FFT_BUFFER_SIZE];
00333 int *height;
00334 int *peaks;
00335 int i_nb_bands;
00336 int i_band_width;
00337 int i_separ;
00338 int i_amp;
00339 int i_peak;
00340
00341 int i_original;
00342 int i_rad;
00343 int i_sections;
00344 int i_extra_width;
00345 int i_peak_height;
00346 int c;
00347 double band_sep_angle;
00348 double section_sep_angle;
00349 int max_band_length;
00350 int i_show_base;
00351 int i_show_bands;
00352
00353 double a;
00354 int x,y,xx,yy;
00355 char color1;
00356
00357
00358 char *psz_parse = NULL;
00359
00360
00361 const int xscale1[]={0,1,2,3,4,5,6,7,8,11,15,20,27,
00362 36,47,62,82,107,141,184,255};
00363
00364
00365 const int xscale2[] =
00366 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
00367 19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,
00368 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
00369 52,53,54,55,56,57,58,59,61,63,67,72,77,82,87,93,99,105,
00370 110,115,121,130,141,152,163,174,185,200,255};
00371 const int *xscale;
00372 const double y_scale = 3.60673760222;
00373
00374 fft_state *p_state;
00375
00376 int i , j , k;
00377 int i_line;
00378 int16_t p_dest[FFT_BUFFER_SIZE];
00379 int16_t p_buffer1[FFT_BUFFER_SIZE];
00380
00381 float *p_buffl =
00382 (float*)p_buffer->p_buffer;
00383
00384 int16_t *p_buffs;
00385 int16_t *p_s16_buff = NULL;
00386
00387 i_line = 0;
00388
00389 p_s16_buff = (int16_t*)malloc(
00390 p_buffer->i_nb_samples * p_effect->i_nb_chans * sizeof(int16_t));
00391
00392 if( !p_s16_buff )
00393 {
00394 msg_Err(p_aout,"Out of memory");
00395 return -1;
00396 }
00397
00398 p_buffs = p_s16_buff;
00399 i_original = config_GetInt ( p_aout, "spect-show-original" );
00400 i_nb_bands = config_GetInt ( p_aout, "spect-nbbands" );
00401 i_separ = config_GetInt ( p_aout, "spect-separ" );
00402 i_amp = config_GetInt ( p_aout, "spect-amp" );
00403 i_peak = config_GetInt ( p_aout, "spect-show-peaks" );
00404 i_show_base = config_GetInt ( p_aout, "spect-show-base" );
00405 i_show_bands = config_GetInt ( p_aout, "spect-show-bands" );
00406 i_rad = config_GetInt ( p_aout, "spect-radius" );
00407 i_sections = config_GetInt ( p_aout, "spect-sections" );
00408 i_extra_width = config_GetInt ( p_aout, "spect-peak-width" );
00409 i_peak_height = config_GetInt ( p_aout, "spect-peak-height" );
00410 color1 = config_GetInt ( p_aout, "spect-color" );
00411
00412 if( i_nb_bands == 20)
00413 {
00414 xscale = xscale1;
00415 }
00416 else
00417 {
00418 if( i_nb_bands > 80 )
00419 i_nb_bands = 80;
00420 xscale = xscale2;
00421 }
00422
00423 if( !p_effect->p_data )
00424 {
00425 p_effect->p_data=(void *)malloc(i_nb_bands * sizeof(int) );
00426 if( !p_effect->p_data)
00427 {
00428 msg_Err(p_aout,"Out of memory");
00429 return -1;
00430 }
00431 peaks = (int *)p_effect->p_data;
00432 for( i = 0 ; i < i_nb_bands ; i++)
00433 {
00434 peaks[i] = 0;
00435 }
00436 }
00437 else
00438 {
00439 peaks =(int *)p_effect->p_data;
00440 }
00441
00442 height = (int *)malloc( i_nb_bands * sizeof(int) );
00443 if( !height)
00444 {
00445 msg_Err(p_aout,"Out of memory");
00446 return -1;
00447 }
00448
00449
00450
00451 for (i = p_buffer->i_nb_samples * p_effect->i_nb_chans; i--; )
00452 {
00453 union { float f; int32_t i; } u;
00454 u.f = *p_buffl + 384.0;
00455 if(u.i > 0x43c07fff ) * p_buffs = 32767;
00456 else if ( u.i < 0x43bf8000 ) *p_buffs = -32768;
00457 else *p_buffs = u.i - 0x43c00000;
00458
00459 p_buffl++ ; p_buffs++ ;
00460 }
00461 p_state = visual_fft_init();
00462 if( !p_state)
00463 {
00464 msg_Err(p_aout,"Unable to initialize FFT transform");
00465 return -1;
00466 }
00467 p_buffs = p_s16_buff;
00468 for ( i = 0 ; i < FFT_BUFFER_SIZE ; i++)
00469 {
00470 p_output[i] = 0;
00471 p_buffer1[i] = *p_buffs;
00472 p_buffs = p_buffs + p_effect->i_nb_chans;
00473 }
00474 fft_perform( p_buffer1, p_output, p_state);
00475 for(i= 0; i< FFT_BUFFER_SIZE ; i++ )
00476 p_dest[i] = ( (int) sqrt( p_output [ i + 1 ] ) ) >> 8;
00477
00478 i_nb_bands *= i_sections;
00479
00480 for ( i = 0 ; i< i_nb_bands/i_sections ;i++)
00481 {
00482
00483 for( j = xscale[i] , y=0 ; j< xscale[ i + 1 ] ; j++ )
00484 {
00485 if ( p_dest[j] > y )
00486 y = p_dest[j];
00487 }
00488
00489 y >>=7;
00490 if( y != 0)
00491 {
00492 height[i] = (int)log(y)* y_scale;
00493 if(height[i] > 150)
00494 height[i] = 150;
00495 }
00496 else
00497 {
00498 height[i] = 0 ;
00499 }
00500
00501
00502 i_band_width = floor( p_effect->i_width / (i_nb_bands/i_sections)) ;
00503
00504 if( i_amp * height[i] > peaks[i])
00505 {
00506 peaks[i] = i_amp * height[i];
00507 }
00508 else if (peaks[i] > 0 )
00509 {
00510 peaks[i] -= PEAK_SPEED;
00511 if( peaks[i] < i_amp * height[i] )
00512 {
00513 peaks[i] = i_amp * height[i];
00514 }
00515 if( peaks[i] < 0 )
00516 {
00517 peaks[i] = 0;
00518 }
00519 }
00520
00521 if( i_original != 0 )
00522 {
00523 if( peaks[i] > 0 && i_peak )
00524 {
00525 if( peaks[i] >= p_effect->i_height )
00526 peaks[i] = p_effect->i_height - 2;
00527 i_line = peaks[i];
00528
00529 for( j = 0 ; j< i_band_width - i_separ; j++)
00530 {
00531 for( k = 0 ; k< 3 ; k ++)
00532 {
00533
00534 *(p_picture->p[0].p_pixels +
00535 (p_picture->p[0].i_lines - i_line -1 -k ) *
00536 p_picture->p[0].i_pitch + (i_band_width*i +j) )
00537 = 0xff;
00538
00539 *(p_picture->p[1].p_pixels +
00540 (p_picture->p[1].i_lines - i_line /2 -1 -k/2 ) *
00541 p_picture->p[1].i_pitch +
00542 ( ( i_band_width * i + j ) /2 ) )
00543 = 0x00;
00544
00545 if( 0x04 * (i_line + k ) - 0x0f > 0 )
00546 {
00547 if ( 0x04 * (i_line + k ) -0x0f < 0xff)
00548 *(p_picture->p[2].p_pixels +
00549 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
00550 p_picture->p[2].i_pitch +
00551 ( ( i_band_width * i + j ) /2 ) )
00552 = ( 0x04 * ( i_line + k ) ) -0x0f ;
00553 else
00554 *(p_picture->p[2].p_pixels +
00555 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
00556 p_picture->p[2].i_pitch +
00557 ( ( i_band_width * i + j ) /2 ) )
00558 = 0xff;
00559 }
00560 else
00561 {
00562 *(p_picture->p[2].p_pixels +
00563 (p_picture->p[2].i_lines - i_line /2 - 1 -k/2 ) *
00564 p_picture->p[2].i_pitch +
00565 ( ( i_band_width * i + j ) /2 ) )
00566 = 0x10 ;
00567 }
00568 }
00569 }
00570 }
00571 if(height[i] * i_amp > p_effect->i_height)
00572 height[i] = floor(p_effect->i_height / i_amp );
00573
00574 for(i_line = 0 ; i_line < i_amp * height[i]; i_line ++ )
00575 {
00576 for( j = 0 ; j< i_band_width - i_separ ; j++)
00577 {
00578 *(p_picture->p[0].p_pixels +
00579 (p_picture->p[0].i_lines - i_line -1) *
00580 p_picture->p[0].i_pitch + (i_band_width*i +j) ) = 0xff;
00581
00582 *(p_picture->p[1].p_pixels +
00583 (p_picture->p[1].i_lines - i_line /2 -1) *
00584 p_picture->p[1].i_pitch +
00585 ( ( i_band_width * i + j ) /2 ) ) = 0x00;
00586
00587 if( 0x04 * i_line - 0x0f > 0 )
00588 {
00589 if( 0x04 * i_line - 0x0f < 0xff )
00590 *(p_picture->p[2].p_pixels +
00591 (p_picture->p[2].i_lines - i_line /2 - 1) *
00592 p_picture->p[2].i_pitch +
00593 ( ( i_band_width * i + j ) /2 ) ) =
00594 ( 0x04 * i_line) -0x0f ;
00595 else
00596 *(p_picture->p[2].p_pixels +
00597 (p_picture->p[2].i_lines - i_line /2 - 1) *
00598 p_picture->p[2].i_pitch +
00599 ( ( i_band_width * i + j ) /2 ) ) =
00600 0xff;
00601 }
00602 else
00603 {
00604 *(p_picture->p[2].p_pixels +
00605 (p_picture->p[2].i_lines - i_line /2 - 1) *
00606 p_picture->p[2].i_pitch +
00607 ( ( i_band_width * i + j ) /2 ) ) =
00608 0x10 ;
00609 }
00610 }
00611 }
00612 }
00613 }
00614
00615 band_sep_angle = 360.0 / i_nb_bands;
00616 section_sep_angle = 360.0 / i_sections;
00617 if( i_peak_height < 1 )
00618 i_peak_height = 1;
00619 max_band_length = p_picture->p[0].i_lines / 2 - ( i_rad + i_peak_height + 1 );
00620
00621 i_band_width = floor( 360 / i_nb_bands - i_separ );
00622 if( i_band_width < 1 )
00623 i_band_width = 1;
00624
00625 for( c = 0 ; c < i_sections ; c++ )
00626 for( i = 0 ; i < (i_nb_bands / i_sections) ; i++ )
00627 {
00628
00629 if( peaks[i] > 0 && i_peak )
00630 {
00631 if( peaks[i] >= p_effect->i_height )
00632 peaks[i] = p_effect->i_height - 2;
00633 i_line = peaks[i];
00634
00635
00636 for( j = 0 ; j < i_peak_height ; j++ )
00637 {
00638 x = p_picture->p[0].i_pitch / 2;
00639 y = p_picture->p[0].i_lines / 2;
00640 xx = x;
00641 yy = y;
00642 for( k = 0 ; k < (i_band_width + i_extra_width) ; k++ )
00643 {
00644 x = xx;
00645 y = yy;
00646 a = ( (i+1) * band_sep_angle + section_sep_angle * (c+1) + k )
00647 * 3.141592 / 180.0;
00648 x += (double)( cos(a) * (double)( i_line + j + i_rad ) );
00649 y += (double)( -sin(a) * (double)( i_line + j + i_rad ) );
00650
00651 *(p_picture->p[0].p_pixels + x + y * p_picture->p[0].i_pitch
00652 ) = 255;
00653
00654 x /= 2;
00655 y /= 2;
00656
00657 *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
00658 ) = 0;
00659
00660 if( 0x04 * (i_line + k ) - 0x0f > 0 )
00661 {
00662 if ( 0x04 * (i_line + k ) -0x0f < 0xff)
00663 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
00664 ) = ( 0x04 * ( i_line + k ) ) -(color1-1);
00665 else
00666 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
00667 ) = 255;
00668 }
00669 else
00670 {
00671 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
00672 ) = color1;
00673 }
00674 }
00675 }
00676 }
00677
00678 if( (height[i] * i_amp) > p_effect->i_height )
00679 height[i] = floor( p_effect->i_height / i_amp );
00680
00681
00682 if( i_show_base != 0 )
00683 {
00684 x = p_picture->p[0].i_pitch / 2;
00685 y = p_picture->p[0].i_lines / 2;
00686
00687 a = ( (i+1) * band_sep_angle + section_sep_angle * (c+1) )
00688 * 3.141592 / 180.0;
00689 x += (double)( cos(a) * (double)i_rad );
00690 y += (double)( -sin(a) * (double)i_rad );
00691
00692 *(p_picture->p[0].p_pixels + x + y * p_picture->p[0].i_pitch
00693 ) = 255;
00694
00695 x /= 2;
00696 y /= 2;
00697
00698 *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
00699 ) = 0;
00700
00701 if( 0x04 * i_line - 0x0f > 0 )
00702 {
00703 if( 0x04 * i_line -0x0f < 0xff)
00704 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
00705 ) = ( 0x04 * i_line) -(color1-1);
00706 else
00707 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
00708 ) = 255;
00709 }
00710 else
00711 {
00712 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
00713 ) = color1;
00714 }
00715 }
00716
00717
00718 if( i_show_bands != 0 )
00719 for( j = 0 ; j < i_band_width ; j++ )
00720 {
00721 x = p_picture->p[0].i_pitch / 2;
00722 y = p_picture->p[0].i_lines / 2;
00723 xx = x;
00724 yy = y;
00725 a = ( (i+1) * band_sep_angle + section_sep_angle * (c+1) + j )
00726 * 3.141592/180.0;
00727
00728 for( k = (i_rad+1) ; k < max_band_length ; k++ )
00729 {
00730 if( (k-i_rad) > height[i] )
00731 break;
00732
00733 x = xx;
00734 y = yy;
00735 x += (double)( cos(a) * (double)k );
00736 y += (double)( -sin(a) * (double)k );
00737
00738 *(p_picture->p[0].p_pixels + x + y * p_picture->p[0].i_pitch
00739 ) = 255;
00740
00741 x /= 2;
00742 y /= 2;
00743
00744 *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch
00745 ) = 0;
00746
00747 if( 0x04 * i_line - 0x0f > 0 )
00748 {
00749 if ( 0x04 * i_line -0x0f < 0xff)
00750 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
00751 ) = ( 0x04 * i_line) -(color1-1);
00752 else
00753 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
00754 ) = 255;
00755 }
00756 else
00757 {
00758 *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch
00759 ) = color1;
00760 }
00761 }
00762 }
00763 }
00764
00765 fft_close( p_state );
00766
00767 if( p_s16_buff != NULL )
00768 {
00769 free( p_s16_buff );
00770 p_s16_buff = NULL;
00771 }
00772
00773 if(height) free(height);
00774
00775 if(psz_parse) free(psz_parse);
00776
00777 return 0;
00778 }
00779
00780
00781
00782
00783
00784 int scope_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
00785 aout_buffer_t * p_buffer , picture_t * p_picture)
00786 {
00787 int i_index;
00788 float *p_sample ;
00789 uint8_t *ppp_area[2][3];
00790
00791
00792 for( i_index = 0 ; i_index < 2 ; i_index++ )
00793 {
00794 int j;
00795 for( j = 0 ; j < 3 ; j++ )
00796 {
00797 ppp_area[i_index][j] =
00798 p_picture->p[j].p_pixels + i_index * p_picture->p[j].i_lines
00799 / 2 * p_picture->p[j].i_pitch;
00800 }
00801 }
00802
00803 for( i_index = 0, p_sample = (float *)p_buffer->p_buffer;
00804 i_index < p_effect->i_width;
00805 i_index++ )
00806 {
00807 uint8_t i_value;
00808
00809
00810 i_value = (*p_sample++ +1) * 127;
00811 *(ppp_area[0][0]
00812 + p_picture->p[0].i_pitch * i_index / p_effect->i_width
00813 + p_picture->p[0].i_lines * i_value / 512
00814 * p_picture->p[0].i_pitch) = 0xbf;
00815 *(ppp_area[0][1]
00816 + p_picture->p[1].i_pitch * i_index / p_effect->i_width
00817 + p_picture->p[1].i_lines * i_value / 512
00818 * p_picture->p[1].i_pitch) = 0xff;
00819
00820
00821
00822 i_value = ( *p_sample++ +1 ) * 127;
00823 *(ppp_area[1][0]
00824 + p_picture->p[0].i_pitch * i_index / p_effect->i_width
00825 + p_picture->p[0].i_lines * i_value / 512
00826 * p_picture->p[0].i_pitch) = 0x9f;
00827 *(ppp_area[1][2]
00828 + p_picture->p[2].i_pitch * i_index / p_effect->i_width
00829 + p_picture->p[2].i_lines * i_value / 512
00830 * p_picture->p[2].i_pitch) = 0xdd;
00831 }
00832 return 0;
00833 }
00834
00835
00836
00837
00838 #if 0
00839
00840 int blur_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
00841 aout_buffer_t * p_buffer , picture_t * p_picture)
00842 {
00843 uint8_t * p_pictures;
00844 int i,j;
00845 int i_size;
00846
00847 i_size = (p_picture->p[0].i_pitch * p_picture->p[0].i_lines +
00848 p_picture->p[1].i_pitch * p_picture->p[1].i_lines +
00849 p_picture->p[2].i_pitch * p_picture->p[2].i_lines );
00850
00851 if( !p_effect->p_data )
00852 {
00853 p_effect->p_data=(void *)malloc( 5 * i_size *sizeof(uint8_t));
00854
00855 if( !p_effect->p_data)
00856 {
00857 msg_Err(p_aout,"Out of memory");
00858 return -1;
00859 }
00860 p_pictures = (uint8_t *)p_effect->p_data;
00861 }
00862 else
00863 {
00864 p_pictures =(uint8_t *)p_effect->p_data;
00865 }
00866
00867 for( i = 0 ; i < 5 ; i++)
00868 {
00869 for ( j = 0 ; j< p_picture->p[0].i_pitch * p_picture->p[0].i_lines; i++)
00870 p_picture->p[0].p_pixels[j] =
00871 p_pictures[i * i_size + j] * (100 - 20 * i) /100 ;
00872 for ( j = 0 ; j< p_picture->p[1].i_pitch * p_picture->p[1].i_lines; i++)
00873 p_picture->p[1].p_pixels[j] =
00874 p_pictures[i * i_size +
00875 p_picture->p[0].i_pitch * p_picture->p[0].i_lines + j ];
00876 for ( j = 0 ; j< p_picture->p[2].i_pitch * p_picture->p[2].i_lines; i++)
00877 p_picture->p[2].p_pixels[j] =
00878 p_pictures[i * i_size +
00879 p_picture->p[0].i_pitch * p_picture->p[0].i_lines +
00880 p_picture->p[1].i_pitch * p_picture->p[1].i_lines
00881 + j ];
00882 }
00883
00884 memcpy ( &p_pictures[ i_size ] , &p_pictures[0] , 4 * i_size * sizeof(uint8_t) );
00885 }
00886 #endif