update window

dev
xufuji456 3 years ago
parent d51bdd6b6a
commit b885fa4b96
  1. 3
      app/src/main/cpp/visualizer/execute_fft.c
  2. 26
      app/src/main/cpp/visualizer/window.c
  3. 2
      app/src/main/cpp/visualizer/window.h

@ -55,7 +55,7 @@ static inline block_t *block_Duplicate(const block_t *p_block)
p_sys->wind_param = *w_param;//TODO p_sys->wind_param = *w_param;//TODO
/* Fetch the FFT window parameters */ /* Fetch the FFT window parameters */
window_get_param(/*VLC_OBJECT( p_filter )*/NULL, &p_sys->wind_param);//TODO window_get_param(&p_sys->wind_param);
/* Create the FIFO for the audio data. */ /* Create the FIFO for the audio data. */
vlc_queue_Init(&p_sys->queue, offsetof (block_t, p_next)); vlc_queue_Init(&p_sys->queue, offsetof (block_t, p_next));
@ -219,6 +219,7 @@ static void *Thread(void *p_data)
// vlc_tick_wait(block->i_pts + (block->i_length / 2)); // vlc_tick_wait(block->i_pts + (block->i_length / 2));
// vlc_gl_Swap(gl); // vlc_gl_Swap(gl);
usleep(block->i_pts + (block->i_length / 2)); usleep(block->i_pts + (block->i_length / 2));
LOGE("height[0]=%f, height[1]=%f, height=[2]=%f", height[0], height[1], height[2]);
release: release:
window_close(&wind_ctx); window_close(&wind_ctx);

@ -44,10 +44,6 @@
static const char * const window_list[NB_WINDOWS] = { static const char * const window_list[NB_WINDOWS] = {
"none", "hann", "flattop", "blackmanharris", "kaiser", "none", "hann", "flattop", "blackmanharris", "kaiser",
}; };
static const char * const window_list_text[NB_WINDOWS] = {
// N_("None"), N_("Hann"), N_("Flat Top"), N_("Blackman-Harris"), N_("Kaiser"),
"None", "Hann", "Flat Top", "Blackman-Harris", "Kaiser",
};
/* /*
* The modified Bessel function I0(x). See Chapter 6 of the "Numerical Recipes * The modified Bessel function I0(x). See Chapter 6 of the "Numerical Recipes
@ -62,17 +58,17 @@ static float bessi0(float x)
{ {
y = x / 3.75; y = x / 3.75;
y *= y; y *= y;
ans = 1.0 + y * ( 3.5156229 + y * ( 3.0899424 + y * ( 1.2067492 ans = (float) (1.0 + y * ( 3.5156229 + y * ( 3.0899424 + y * ( 1.2067492
+ y * ( 0.2659732 + y * ( 0.360768e-1 + y * ( 0.2659732 + y * ( 0.360768e-1
+ y * 0.45813e-2 ) ) ) ) ); + y * 0.45813e-2 ) ) ) ) ) );
} }
else else
{ {
y = 3.75 / ax; y = 3.75 / ax;
ans = ( exp( ax ) / sqrt( ax ) ) * ( 0.39894228 + y * ( 0.1328592e-1 ans = (float) ( ( exp( ax ) / sqrt( ax ) ) * ( 0.39894228 + y * ( 0.1328592e-1
+ y * ( 0.225319e-2 + y * ( -0.157565e-2 + y * ( 0.916281e-2 + y * ( 0.225319e-2 + y * ( -0.157565e-2 + y * ( 0.916281e-2
+ y * ( -0.2057706e-1 + y * ( 0.2635537e-1 + y * ( -0.1647633e-1 + y * ( -0.2057706e-1 + y * ( 0.2635537e-1 + y * ( -0.1647633e-1
+ y * 0.392377e-2 ) ) ) ) ) ) ) ); + y * 0.392377e-2 ) ) ) ) ) ) ) ) );
} }
return ans; return ans;
} }
@ -80,13 +76,13 @@ static float bessi0(float x)
/* /*
* Obtain the window type from the window type variable. * Obtain the window type from the window type variable.
*/ */
void window_get_param(void * p_aout, window_param * p_param) void window_get_param(window_param * p_param)
{ {
/* Fetch Kaiser parameter */ /* Fetch Kaiser parameter */
p_param->f_kaiser_alpha = 1; //TODO var_InheritFloat( p_aout, "effect-kaiser-param" ); p_param->f_kaiser_alpha = 1.0f;
/* Fetch window type */ /* Fetch window type */
char * psz_preset = "hann"; //TODO var_InheritString( p_aout, "effect-fft-window" ); char * psz_preset = "hann";
if( !psz_preset ) if( !psz_preset )
{ {
goto no_preset; goto no_preset;
@ -96,16 +92,12 @@ void window_get_param(void * p_aout, window_param * p_param)
{ {
if( !strcasecmp( psz_preset, window_list[i] ) ) if( !strcasecmp( psz_preset, window_list[i] ) )
{ {
// free( psz_preset );//TODO p_param->wind_type = (window_type) i;
p_param->wind_type = i;
return; return;
} }
} }
// free( psz_preset );//TODO
no_preset: no_preset:
// msg_Warn( p_aout, "No matching window preset found; using rectangular "
// "window (i.e. no window)" );
p_param->wind_type = NONE; p_param->wind_type = NONE;
} }
@ -132,7 +124,6 @@ bool window_init(int i_buffer_size, window_param * p_param, window_context * p_c
goto exit; goto exit;
} }
// pf_table = vlc_alloc( i_buffer_size, sizeof( *pf_table ) );
pf_table = (float * )malloc( i_buffer_size * sizeof(*pf_table)); pf_table = (float * )malloc( i_buffer_size * sizeof(*pf_table));
if( !pf_table ) if( !pf_table )
{ {
@ -191,7 +182,6 @@ bool window_init(int i_buffer_size, window_param * p_param, window_context * p_c
} }
default: default:
/* We should not reach here */ /* We should not reach here */
// vlc_assert_unreachable();
break; break;
} }

@ -58,7 +58,7 @@ struct _struct_window_param {
/* Prototypes for the window function */ /* Prototypes for the window function */
typedef struct _struct_window_context window_context; typedef struct _struct_window_context window_context;
typedef struct _struct_window_param window_param; typedef struct _struct_window_param window_param;
void window_get_param(void * p_aout, window_param * p_param); void window_get_param(window_param * p_param);
bool window_init(int i_buffer_size, window_param * p_param, window_context * p_ctx); bool window_init(int i_buffer_size, window_param * p_param, window_context * p_ctx);
void window_scale_in_place(int16_t * p_buffer, window_context * p_ctx); void window_scale_in_place(int16_t * p_buffer, window_context * p_ctx);
void window_close(window_context * p_ctx); void window_close(window_context * p_ctx);

Loading…
Cancel
Save