📄 effects.c
字号:
y = yy; a = ( (i+1) * band_sep_angle + section_sep_angle * (c+1) + k ) * 3.141592 / 180.0; x += (double)( cos(a) * (double)( i_line + j + i_rad ) ); y += (double)( -sin(a) * (double)( i_line + j + i_rad ) ); *(p_picture->p[0].p_pixels + x + y * p_picture->p[0].i_pitch ) = 255;/* Y(R,G,B); */ x /= 2; y /= 2; *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch ) = 0;/* U(R,G,B); */ if( 0x04 * (i_line + k ) - 0x0f > 0 ) { if ( 0x04 * (i_line + k ) -0x0f < 0xff) *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch ) = ( 0x04 * ( i_line + k ) ) -(color1-1);/* -V(R,G,B); */ else *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch ) = 255;/* V(R,G,B); */ } else { *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch ) = color1;/* V(R,G,B); */ } } } } if( (height[i] * i_amp) > p_effect->i_height ) height[i] = floor( p_effect->i_height / i_amp ); /* DO BASE OF BAND (mostly makes a circle) */ if( i_show_base != 0 ) { x = p_picture->p[0].i_pitch / 2; y = p_picture->p[0].i_lines / 2; a = ( (i+1) * band_sep_angle + section_sep_angle * (c+1) ) * 3.141592 / 180.0; x += (double)( cos(a) * (double)i_rad );/* newb-forceful casting */ y += (double)( -sin(a) * (double)i_rad ); *(p_picture->p[0].p_pixels + x + y * p_picture->p[0].i_pitch ) = 255;/* Y(R,G,B); */ x /= 2; y /= 2; *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch ) = 0;/* U(R,G,B); */ if( 0x04 * i_line - 0x0f > 0 ) { if( 0x04 * i_line -0x0f < 0xff) *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch ) = ( 0x04 * i_line) -(color1-1);/* -V(R,G,B); */ else *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch ) = 255;/* V(R,G,B); */ } else { *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch ) = color1;/* V(R,G,B); */ } } /* DO A BAND */ if( i_show_bands != 0 ) for( j = 0 ; j < i_band_width ; j++ ) { x = p_picture->p[0].i_pitch / 2; y = p_picture->p[0].i_lines / 2; xx = x; yy = y; a = ( (i+1) * band_sep_angle + section_sep_angle * (c+1) + j ) * 3.141592/180.0; for( k = (i_rad+1) ; k < max_band_length ; k++ ) { if( (k-i_rad) > height[i] ) break;/* uhh.. */ x = xx; y = yy; x += (double)( cos(a) * (double)k );/* newbed! */ y += (double)( -sin(a) * (double)k ); *(p_picture->p[0].p_pixels + x + y * p_picture->p[0].i_pitch ) = 255; x /= 2; y /= 2; *(p_picture->p[1].p_pixels + x + y * p_picture->p[1].i_pitch ) = 0; if( 0x04 * i_line - 0x0f > 0 ) { if ( 0x04 * i_line -0x0f < 0xff) *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch ) = ( 0x04 * i_line) -(color1-1); else *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch ) = 255; } else { *(p_picture->p[2].p_pixels + x + y * p_picture->p[2].i_pitch ) = color1; } } } } fft_close( p_state ); free( p_s16_buff ); free( height ); return 0;}/***************************************************************************** * scope_Run: scope effect *****************************************************************************/int scope_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, aout_buffer_t * p_buffer , picture_t * p_picture){ VLC_UNUSED(p_aout); int i_index; float *p_sample ; uint8_t *ppp_area[2][3]; for( i_index = 0 ; i_index < 2 ; i_index++ ) { int j; for( j = 0 ; j < 3 ; j++ ) { ppp_area[i_index][j] = p_picture->p[j].p_pixels + i_index * p_picture->p[j].i_lines / 2 * p_picture->p[j].i_pitch; } } for( i_index = 0, p_sample = (float *)p_buffer->p_buffer; i_index < p_effect->i_width; i_index++ ) { uint8_t i_value; /* Left channel */ i_value = (*p_sample++ +1) * 127; *(ppp_area[0][0] + p_picture->p[0].i_pitch * i_index / p_effect->i_width + p_picture->p[0].i_lines * i_value / 512 * p_picture->p[0].i_pitch) = 0xbf; *(ppp_area[0][1] + p_picture->p[1].i_pitch * i_index / p_effect->i_width + p_picture->p[1].i_lines * i_value / 512 * p_picture->p[1].i_pitch) = 0xff; /* Right channel */ i_value = ( *p_sample++ +1 ) * 127; *(ppp_area[1][0] + p_picture->p[0].i_pitch * i_index / p_effect->i_width + p_picture->p[0].i_lines * i_value / 512 * p_picture->p[0].i_pitch) = 0x9f; *(ppp_area[1][2] + p_picture->p[2].i_pitch * i_index / p_effect->i_width + p_picture->p[2].i_lines * i_value / 512 * p_picture->p[2].i_pitch) = 0xdd; } return 0;}/***************************************************************************** * vuMeter_Run: vu meter effect *****************************************************************************/int vuMeter_Run(visual_effect_t * p_effect, aout_instance_t *p_aout, aout_buffer_t * p_buffer , picture_t * p_picture){ VLC_UNUSED(p_aout); int i, j; float *p_sample = (float *)p_buffer->p_buffer; float i_value_l = 0; float i_value_r = 0; float ch; /* Compute the peack values */ for ( i = 0 ; i < 1024; i++ ) { ch = (*p_sample++) * 256; if (ch > i_value_l) i_value_l = ch; ch = (*p_sample++) * 256; if (ch > i_value_r) i_value_r = ch; } i_value_l = abs(i_value_l); i_value_r = abs(i_value_r); /* Stay under maximum value admited */ if ( i_value_l > 200 * M_PI_2 ) i_value_l = 200 * M_PI_2; if ( i_value_r > 200 * M_PI_2 ) i_value_r = 200 * M_PI_2; float *i_value; if( !p_effect->p_data ) { /* Allocate memory to save hand positions */ p_effect->p_data = (void *)malloc( 2 * sizeof(float) ); i_value = p_effect->p_data; i_value[0] = i_value_l; i_value[1] = i_value_r; } else { /* Make the hands go down slowly if the current values are slower than the previous */ i_value = p_effect->p_data; if ( i_value_l > i_value[0] - 6 ) i_value[0] = i_value_l; else i_value[0] = i_value[0] - 6; if ( i_value_r > i_value[1] - 6 ) i_value[1] = i_value_r; else i_value[1] = i_value[1] - 6; } int x, y, k; float teta; float teta_grad; for ( j = 0; j < 2; j++ ) { /* Draw the two scales */ k = 0; teta_grad = GRAD_ANGLE_MIN; for ( teta = -M_PI_4; teta <= M_PI_4; teta = teta + 0.003 ) { for ( i = 140; i <= 150; i++ ) { y = i * cos(teta) + 20; x = i * sin(teta) + 150 + 240 * j; /* Compute the last color for the gradation */ if (teta >= teta_grad + GRAD_INCR && teta_grad <= GRAD_ANGLE_MAX) { teta_grad = teta_grad + GRAD_INCR; k = k + 5; } *(p_picture->p[0].p_pixels + (p_picture->p[0].i_lines - y - 1 ) * p_picture->p[0].i_pitch + x ) = 0x45; *(p_picture->p[1].p_pixels + (p_picture->p[1].i_lines - y / 2 - 1 ) * p_picture->p[1].i_pitch + x / 2 ) = 0x0; *(p_picture->p[2].p_pixels + (p_picture->p[2].i_lines - y / 2 - 1 ) * p_picture->p[2].i_pitch + x / 2 ) = 0x4D + k; } } /* Draw the two hands */ teta = (float)i_value[j] / 200 - M_PI_4; for ( i = 0; i <= 150; i++ ) { y = i * cos(teta) + 20; x = i * sin(teta) + 150 + 240 * j; *(p_picture->p[0].p_pixels + (p_picture->p[0].i_lines - y - 1 ) * p_picture->p[0].i_pitch + x ) = 0xAD; *(p_picture->p[1].p_pixels + (p_picture->p[1].i_lines - y / 2 - 1 ) * p_picture->p[1].i_pitch + x / 2 ) = 0xFC; *(p_picture->p[2].p_pixels + (p_picture->p[2].i_lines - y / 2 - 1 ) * p_picture->p[2].i_pitch + x / 2 ) = 0xAC; } /* Draw the hand bases */ for ( teta = -M_PI_2; teta <= M_PI_2 + 0.01; teta = teta + 0.003 ) { for ( i = 0; i < 10; i++ ) { y = i * cos(teta) + 20; x = i * sin(teta) + 150 + 240 * j; *(p_picture->p[0].p_pixels + (p_picture->p[0].i_lines - y - 1 ) * p_picture->p[0].i_pitch + x ) = 0xFF; *(p_picture->p[1].p_pixels + (p_picture->p[1].i_lines - y / 2 - 1 ) * p_picture->p[1].i_pitch + x / 2 ) = 0x80; *(p_picture->p[2].p_pixels + (p_picture->p[2].i_lines - y / 2 - 1 ) * p_picture->p[2].i_pitch + x / 2 ) = 0x80; } } } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -