397
396
int16_t *p_buffs; /* int16_t converted buffer */
398
397
int16_t *p_s16_buff; /* int16_t converted buffer */
402
p_s16_buff = malloc( p_buffer->i_nb_samples * p_effect->i_nb_chans * sizeof(int16_t) );
406
p_buffs = p_s16_buff;
407
i_original = config_GetInt ( p_aout, "spect-show-original" );
408
i_80_bands = config_GetInt ( p_aout, "spect-80-bands" );
409
i_separ = config_GetInt ( p_aout, "spect-separ" );
410
i_amp = config_GetInt ( p_aout, "spect-amp" );
411
i_peak = config_GetInt ( p_aout, "spect-show-peaks" );
412
i_show_base = config_GetInt ( p_aout, "spect-show-base" );
413
i_show_bands = config_GetInt ( p_aout, "spect-show-bands" );
414
i_rad = config_GetInt ( p_aout, "spect-radius" );
415
i_sections = config_GetInt ( p_aout, "spect-sections" );
416
i_extra_width = config_GetInt ( p_aout, "spect-peak-width" );
417
i_peak_height = config_GetInt ( p_aout, "spect-peak-height" );
418
color1 = config_GetInt ( p_aout, "spect-color" );
399
/* Create the data struct if needed */
400
spectrometer_data *p_data = p_effect->p_data;
403
p_data = malloc( sizeof(spectrometer_data) );
406
p_data->peaks = calloc( 80, sizeof(int) );
412
p_data->i_prev_nb_samples = 0;
413
p_data->p_prev_s16_buff = NULL;
414
p_effect->p_data = (void*)p_data;
416
peaks = p_data->peaks;
418
/* Allocate the buffer only if the number of samples change */
419
if( p_buffer->i_nb_samples != p_data->i_prev_nb_samples )
421
free( p_data->p_prev_s16_buff );
422
p_data->p_prev_s16_buff = malloc( p_buffer->i_nb_samples *
423
p_effect->i_nb_chans *
425
p_data->i_prev_nb_samples = p_buffer->i_nb_samples;
426
if( !p_data->p_prev_s16_buff )
429
p_buffs = p_s16_buff = p_data->p_prev_s16_buff;
431
i_original = var_InheritInteger( p_aout, "spect-show-original" );
432
i_80_bands = var_InheritInteger( p_aout, "spect-80-bands" );
433
i_separ = var_InheritInteger( p_aout, "spect-separ" );
434
i_amp = var_InheritInteger( p_aout, "spect-amp" );
435
i_peak = var_InheritInteger( p_aout, "spect-show-peaks" );
436
i_show_base = var_InheritInteger( p_aout, "spect-show-base" );
437
i_show_bands = var_InheritInteger( p_aout, "spect-show-bands" );
438
i_rad = var_InheritInteger( p_aout, "spect-radius" );
439
i_sections = var_InheritInteger( p_aout, "spect-sections" );
440
i_extra_width = var_InheritInteger( p_aout, "spect-peak-width" );
441
i_peak_height = var_InheritInteger( p_aout, "spect-peak-height" );
442
color1 = var_InheritInteger( p_aout, "spect-color" );
420
444
if( i_80_bands != 0)
791
793
/*****************************************************************************
792
794
* scope_Run: scope effect
793
795
*****************************************************************************/
794
int scope_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
795
aout_buffer_t * p_buffer , picture_t * p_picture)
796
int scope_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
797
const block_t * p_buffer , picture_t * p_picture)
797
799
VLC_UNUSED(p_aout);
799
802
float *p_sample ;
800
803
uint8_t *ppp_area[2][3];
803
for( i_index = 0 ; i_index < 2 ; i_index++ )
805
for( i_index = 0 ; i_index < 2 ; i_index++ )
807
for( int j = 0 ; j < 3 ; j++ )
806
for( j = 0 ; j < 3 ; j++ )
808
ppp_area[i_index][j] =
809
p_picture->p[j].p_pixels + i_index * p_picture->p[j].i_lines
810
/ 2 * p_picture->p[j].i_pitch;
809
ppp_area[i_index][j] =
810
p_picture->p[j].p_pixels + i_index * p_picture->p[j].i_lines
811
/ 2 * p_picture->p[j].i_pitch;
814
for( i_index = 0, p_sample = (float *)p_buffer->p_buffer;
815
i_index < __MIN( p_effect->i_width, p_buffer->i_nb_samples );
821
i_value = p_sample[p_effect->i_idx_left] * 127;
823
+ p_picture->p[0].i_pitch * i_index / p_effect->i_width
824
+ p_picture->p[0].i_lines * i_value / 512
825
* p_picture->p[0].i_pitch) = 0xbf;
815
for( i_index = 0, p_sample = (float *)p_buffer->p_buffer;
816
i_index < __MIN( p_effect->i_width, (int)p_buffer->i_nb_samples );
822
i_value = p_sample[p_effect->i_idx_left] * 127;
824
+ p_picture->p[0].i_pitch * i_index / p_effect->i_width
825
+ p_picture->p[0].i_lines * i_value / 512
826
* p_picture->p[0].i_pitch) = 0xbf;
827
828
+ p_picture->p[1].i_pitch * i_index / p_effect->i_width
828
829
+ p_picture->p[1].i_lines * i_value / 512
829
* p_picture->p[1].i_pitch) = 0xff;
833
i_value = p_sample[p_effect->i_idx_right] * 127;
835
+ p_picture->p[0].i_pitch * i_index / p_effect->i_width
836
+ p_picture->p[0].i_lines * i_value / 512
837
* p_picture->p[0].i_pitch) = 0x9f;
839
+ p_picture->p[2].i_pitch * i_index / p_effect->i_width
840
+ p_picture->p[2].i_lines * i_value / 512
830
* p_picture->p[1].i_pitch) = 0xff;
834
i_value = p_sample[p_effect->i_idx_right] * 127;
836
+ p_picture->p[0].i_pitch * i_index / p_effect->i_width
837
+ p_picture->p[0].i_lines * i_value / 512
838
* p_picture->p[0].i_pitch) = 0x9f;
840
+ p_picture->p[2].i_pitch * i_index / p_effect->i_width
841
+ p_picture->p[2].i_lines * i_value / 512
841
842
* p_picture->p[2].i_pitch) = 0xdd;
843
p_sample += p_effect->i_nb_chans;
844
p_sample += p_effect->i_nb_chans;
849
850
/*****************************************************************************
850
851
* vuMeter_Run: vu meter effect
851
852
*****************************************************************************/
852
int vuMeter_Run(visual_effect_t * p_effect, aout_instance_t *p_aout,
853
aout_buffer_t * p_buffer , picture_t * p_picture)
853
int vuMeter_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
854
const block_t * p_buffer , picture_t * p_picture)
860
/* Compute the peack values */
861
for ( i = 0 ; i < p_buffer->i_nb_samples; i++ )
863
const float *p_sample = (float *)p_buffer->p_buffer;
866
ch = p_sample[p_effect->i_idx_left] * 256;
870
ch = p_sample[p_effect->i_idx_right] * 256;
874
p_sample += p_effect->i_nb_chans;
877
i_value_l = abs(i_value_l);
878
i_value_r = abs(i_value_r);
880
/* Stay under maximum value admited */
881
if ( i_value_l > 200 * M_PI_2 )
882
i_value_l = 200 * M_PI_2;
883
if ( i_value_r > 200 * M_PI_2 )
884
i_value_r = 200 * M_PI_2;
888
if( !p_effect->p_data )
890
/* Allocate memory to save hand positions */
891
p_effect->p_data = (void *)malloc( 2 * sizeof(float) );
892
i_value = p_effect->p_data;
893
i_value[0] = i_value_l;
894
i_value[1] = i_value_r;
898
/* Make the hands go down slowly if the current values are slower
900
i_value = p_effect->p_data;
902
if ( i_value_l > i_value[0] - 6 )
903
i_value[0] = i_value_l;
905
i_value[0] = i_value[0] - 6;
907
if ( i_value_r > i_value[1] - 6 )
908
i_value[1] = i_value_r;
910
i_value[1] = i_value[1] - 6;
917
for ( j = 0; j < 2; j++ )
919
/* Draw the two scales */
921
teta_grad = GRAD_ANGLE_MIN;
922
for ( teta = -M_PI_4; teta <= M_PI_4; teta = teta + 0.003 )
924
for ( i = 140; i <= 150; i++ )
926
y = i * cos(teta) + 20;
927
x = i * sin(teta) + 150 + 240 * j;
928
/* Compute the last color for the gradation */
929
if (teta >= teta_grad + GRAD_INCR && teta_grad <= GRAD_ANGLE_MAX)
931
teta_grad = teta_grad + GRAD_INCR;
934
*(p_picture->p[0].p_pixels +
935
(p_picture->p[0].i_lines - y - 1 ) * p_picture->p[0].i_pitch
937
*(p_picture->p[1].p_pixels +
938
(p_picture->p[1].i_lines - y / 2 - 1 ) * p_picture->p[1].i_pitch
940
*(p_picture->p[2].p_pixels +
941
(p_picture->p[2].i_lines - y / 2 - 1 ) * p_picture->p[2].i_pitch
942
+ x / 2 ) = 0x4D + k;
946
/* Draw the two hands */
947
teta = (float)i_value[j] / 200 - M_PI_4;
948
for ( i = 0; i <= 150; i++ )
950
y = i * cos(teta) + 20;
951
x = i * sin(teta) + 150 + 240 * j;
952
*(p_picture->p[0].p_pixels +
953
(p_picture->p[0].i_lines - y - 1 ) * p_picture->p[0].i_pitch
955
*(p_picture->p[1].p_pixels +
956
(p_picture->p[1].i_lines - y / 2 - 1 ) * p_picture->p[1].i_pitch
958
*(p_picture->p[2].p_pixels +
959
(p_picture->p[2].i_lines - y / 2 - 1 ) * p_picture->p[2].i_pitch
963
/* Draw the hand bases */
964
for ( teta = -M_PI_2; teta <= M_PI_2 + 0.01; teta = teta + 0.003 )
966
for ( i = 0; i < 10; i++ )
968
y = i * cos(teta) + 20;
969
x = i * sin(teta) + 150 + 240 * j;
970
*(p_picture->p[0].p_pixels +
971
(p_picture->p[0].i_lines - y - 1 ) * p_picture->p[0].i_pitch
973
*(p_picture->p[1].p_pixels +
974
(p_picture->p[1].i_lines - y / 2 - 1 ) * p_picture->p[1].i_pitch
976
*(p_picture->p[2].p_pixels +
977
(p_picture->p[2].i_lines - y / 2 - 1 ) * p_picture->p[2].i_pitch
860
/* Compute the peack values */
861
for ( unsigned i = 0 ; i < p_buffer->i_nb_samples; i++ )
863
const float *p_sample = (float *)p_buffer->p_buffer;
866
ch = p_sample[p_effect->i_idx_left] * 256;
870
ch = p_sample[p_effect->i_idx_right] * 256;
874
p_sample += p_effect->i_nb_chans;
877
i_value_l = abs(i_value_l);
878
i_value_r = abs(i_value_r);
880
/* Stay under maximum value admited */
881
if ( i_value_l > 200 * M_PI_2 )
882
i_value_l = 200 * M_PI_2;
883
if ( i_value_r > 200 * M_PI_2 )
884
i_value_r = 200 * M_PI_2;
888
if( !p_effect->p_data )
890
/* Allocate memory to save hand positions */
891
p_effect->p_data = malloc( 2 * sizeof(float) );
892
i_value = p_effect->p_data;
893
i_value[0] = i_value_l;
894
i_value[1] = i_value_r;
898
/* Make the hands go down slowly if the current values are slower
900
i_value = p_effect->p_data;
902
if ( i_value_l > i_value[0] - 6 )
903
i_value[0] = i_value_l;
905
i_value[0] = i_value[0] - 6;
907
if ( i_value_r > i_value[1] - 6 )
908
i_value[1] = i_value_r;
910
i_value[1] = i_value[1] - 6;
917
int start_x = p_effect->i_width / 2 - 120; /* i_width.min = 532 (visual.c) */
919
for ( int j = 0; j < 2; j++ )
921
/* Draw the two scales */
923
teta_grad = GRAD_ANGLE_MIN;
924
for ( teta = -M_PI_4; teta <= M_PI_4; teta = teta + 0.003 )
926
for ( unsigned i = 140; i <= 150; i++ )
928
y = i * cos(teta) + 20;
929
x = i * sin(teta) + start_x + 240 * j;
930
/* Compute the last color for the gradation */
931
if (teta >= teta_grad + GRAD_INCR && teta_grad <= GRAD_ANGLE_MAX)
933
teta_grad = teta_grad + GRAD_INCR;
936
*(p_picture->p[0].p_pixels +
937
(p_picture->p[0].i_lines - y - 1 ) * p_picture->p[0].i_pitch
939
*(p_picture->p[1].p_pixels +
940
(p_picture->p[1].i_lines - y / 2 - 1 ) * p_picture->p[1].i_pitch
942
*(p_picture->p[2].p_pixels +
943
(p_picture->p[2].i_lines - y / 2 - 1 ) * p_picture->p[2].i_pitch
944
+ x / 2 ) = 0x4D + k;
948
/* Draw the two hands */
949
teta = (float)i_value[j] / 200 - M_PI_4;
950
for ( int i = 0; i <= 150; i++ )
952
y = i * cos(teta) + 20;
953
x = i * sin(teta) + start_x + 240 * j;
954
*(p_picture->p[0].p_pixels +
955
(p_picture->p[0].i_lines - y - 1 ) * p_picture->p[0].i_pitch
957
*(p_picture->p[1].p_pixels +
958
(p_picture->p[1].i_lines - y / 2 - 1 ) * p_picture->p[1].i_pitch
960
*(p_picture->p[2].p_pixels +
961
(p_picture->p[2].i_lines - y / 2 - 1 ) * p_picture->p[2].i_pitch
965
/* Draw the hand bases */
966
for ( teta = -M_PI_2; teta <= M_PI_2 + 0.01; teta = teta + 0.003 )
968
for ( int i = 0; i < 10; i++ )
970
y = i * cos(teta) + 20;
971
x = i * sin(teta) + start_x + 240 * j;
972
*(p_picture->p[0].p_pixels +
973
(p_picture->p[0].i_lines - y - 1 ) * p_picture->p[0].i_pitch
975
*(p_picture->p[1].p_pixels +
976
(p_picture->p[1].i_lines - y / 2 - 1 ) * p_picture->p[1].i_pitch
978
*(p_picture->p[2].p_pixels +
979
(p_picture->p[2].i_lines - y / 2 - 1 ) * p_picture->p[2].i_pitch