X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=wmadec_filter.c;h=fdf312b981abe0fee30e92856a58dd87fee90250;hb=509972da450f90a330fe290b62cd3e3d02de6e67;hp=4d384e1ddf9c82c2768712f9a50aaf44af5284f9;hpb=03900fe178fa1dc6b371424c8a96f91be52877e2;p=paraslash.git diff --git a/wmadec_filter.c b/wmadec_filter.c index 4d384e1d..fdf312b9 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -96,7 +95,6 @@ struct private_wmadec_data { int next_block_len_bits; ///< log2 of next block length int prev_block_len_bits; ///< log2 of prev block length int block_len; ///< block length in samples - int block_num; ///< block number in current frame int block_pos; ///< current position in frame uint8_t ms_stereo; ///< true if mid/side stereo mode uint8_t channel_coded[MAX_CHANNELS]; ///< true if channel is coded @@ -133,6 +131,27 @@ struct private_wmadec_data { #define VLCBITS 9 #define VLCMAX ((22+VLCBITS-1)/VLCBITS) +DECLARE_ALIGNED(16, float, ff_sine_128[128]); +DECLARE_ALIGNED(16, float, ff_sine_256[256]); +DECLARE_ALIGNED(16, float, ff_sine_512[512]); +DECLARE_ALIGNED(16, float, ff_sine_1024[1024]); +DECLARE_ALIGNED(16, float, ff_sine_2048[2048]); +DECLARE_ALIGNED(16, float, ff_sine_4096[4096]); + +static float *ff_sine_windows[6] = { + ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, + ff_sine_2048, ff_sine_4096 +}; + +/* Generate a sine window. */ +static void sine_window_init(float *window, int n) +{ + int i; + + for (i = 0; i < n; i++) + window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); +} + static int wmadec_cleanup(struct private_wmadec_data *s) { int i; @@ -168,9 +187,9 @@ static void init_coef_vlc(struct vlc *vlc, uint16_t **prun_table, init_vlc(vlc, VLCBITS, n, table_bits, 1, 1, table_codes, 4, 4); - run_table = para_malloc(n * sizeof (uint16_t)); - level_table = para_malloc(n * sizeof (uint16_t)); - int_table = para_malloc(n * sizeof (uint16_t)); + run_table = para_malloc(n * sizeof(uint16_t)); + level_table = para_malloc(n * sizeof(uint16_t)); + int_table = para_malloc(n * sizeof(uint16_t)); i = 2; level = 1; k = 0; @@ -463,21 +482,21 @@ static int wma_decode_init(char *initial_buf, int len, struct private_wmadec_dat return ret; /* init MDCT */ for (i = 0; i < s->nb_block_sizes; i++) { - ret = imdct_init(s->frame_len_bits - i + 1, 1, &s->mdct_ctx[i]); + ret = imdct_init(s->frame_len_bits - i + 1, &s->mdct_ctx[i]); if (ret < 0) return ret; } if (s->use_noise_coding) { PARA_INFO_LOG("using noise coding\n"); init_vlc(&s->hgain_vlc, HGAINVLCBITS, - sizeof (ff_wma_hgain_huffbits), ff_wma_hgain_huffbits, + sizeof(ff_wma_hgain_huffbits), ff_wma_hgain_huffbits, 1, 1, ff_wma_hgain_huffcodes, 2, 2); } if (s->use_exp_vlc) { PARA_INFO_LOG("using exp_vlc\n"); init_vlc(&s->exp_vlc, EXPVLCBITS, - sizeof (ff_wma_scale_huffbits), ff_wma_scale_huffbits, + sizeof(ff_wma_scale_huffbits), ff_wma_scale_huffbits, 1, 1, ff_wma_scale_huffcodes, 4, 4); } else { PARA_INFO_LOG("using curve\n"); @@ -655,7 +674,7 @@ static void wma_window(struct private_wmadec_data *s, float *out) out + n, 0, block_len, 1); memcpy(out + n + block_len, in + n + block_len, - n * sizeof (float)); + n * sizeof(float)); } out += s->block_len; @@ -673,12 +692,12 @@ static void wma_window(struct private_wmadec_data *s, float *out) n = (s->block_len - block_len) / 2; bsize = s->frame_len_bits - s->next_block_len_bits; - memcpy(out, in, n * sizeof (float)); + memcpy(out, in, n * sizeof(float)); vector_fmul_reverse_c(out + n, in + n, s->windows[bsize], block_len); - memset(out + n + block_len, 0, n * sizeof (float)); + memset(out + n + block_len, 0, n * sizeof(float)); } } @@ -778,7 +797,6 @@ static int wma_decode_block(struct private_wmadec_data *s) /* complex coding */ if (s->use_noise_coding) { - for (ch = 0; ch < s->ahi.channels; ch++) { if (s->channel_coded[ch]) { int i, m, a; @@ -1090,7 +1108,7 @@ next: if (s->channel_coded[ch]) imdct(s->mdct_ctx[bsize], s->output, s->coefs[ch]); else if (!(s->ms_stereo && ch == 1)) - memset(s->output, 0, sizeof (s->output)); + memset(s->output, 0, sizeof(s->output)); /* multiply by the window and add in the frame */ index = (s->frame_len / 2) + s->block_pos - n4; @@ -1098,7 +1116,6 @@ next: } /* update block number */ - s->block_num++; s->block_pos += s->block_len; if (s->block_pos >= s->frame_len) return 1; @@ -1129,7 +1146,6 @@ static int wma_decode_frame(struct private_wmadec_data *s, int16_t * samples) float *iptr; /* read each block */ - s->block_num = 0; s->block_pos = 0; for (;;) { ret = wma_decode_block(s); @@ -1152,7 +1168,7 @@ static int wma_decode_frame(struct private_wmadec_data *s, int16_t * samples) } /* prepare for next block */ memmove(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len], - s->frame_len * sizeof (float)); + s->frame_len * sizeof(float)); } return 0; }