remove unused field tmp_buf of struct fft_context.
[paraslash.git] / wmadec_filter.c
index a548d04..15bb392 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <sys/time.h>
 #include <inttypes.h>
 
 #include <sys/time.h>
 #include <inttypes.h>
-#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -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 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
        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
@@ -168,9 +166,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);
 
 
        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;
        i = 2;
        level = 1;
        k = 0;
@@ -446,14 +444,13 @@ static int wma_decode_init(char *initial_buf, int len, struct private_wmadec_dat
        struct private_wmadec_data *s;
        int ret, i;
 
        struct private_wmadec_data *s;
        int ret, i;
 
-       if (len < 18)
-               return 0;
-
        PARA_NOTICE_LOG("initial buf: %d bytes\n", len);
        s = para_calloc(sizeof(*s));
        ret = read_asf_header(initial_buf, len, &s->ahi);
        PARA_NOTICE_LOG("initial buf: %d bytes\n", len);
        s = para_calloc(sizeof(*s));
        ret = read_asf_header(initial_buf, len, &s->ahi);
-       if (ret < 0)
+       if (ret <= 0) {
+               free(s);
                return ret;
                return ret;
+       }
 
        s->use_exp_vlc = s->ahi.flags2 & 0x0001;
        s->use_bit_reservoir = s->ahi.flags2 & 0x0002;
 
        s->use_exp_vlc = s->ahi.flags2 & 0x0001;
        s->use_bit_reservoir = s->ahi.flags2 & 0x0002;
@@ -471,14 +468,14 @@ static int wma_decode_init(char *initial_buf, int len, struct private_wmadec_dat
        if (s->use_noise_coding) {
                PARA_INFO_LOG("using noise coding\n");
                init_vlc(&s->hgain_vlc, HGAINVLCBITS,
        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,
                        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");
                1, 1, ff_wma_scale_huffcodes, 4, 4);
        } else {
                PARA_INFO_LOG("using curve\n");
@@ -656,7 +653,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,
                                         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;
        }
 
        out += s->block_len;
@@ -674,12 +671,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;
 
                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);
 
 
                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));
        }
 }
 
        }
 }
 
@@ -779,7 +776,6 @@ static int wma_decode_block(struct private_wmadec_data *s)
 
        /* complex coding */
        if (s->use_noise_coding) {
 
        /* complex coding */
        if (s->use_noise_coding) {
-
                for (ch = 0; ch < s->ahi.channels; ch++) {
                        if (s->channel_coded[ch]) {
                                int i, m, a;
                for (ch = 0; ch < s->ahi.channels; ch++) {
                        if (s->channel_coded[ch]) {
                                int i, m, a;
@@ -1091,7 +1087,7 @@ next:
                if (s->channel_coded[ch])
                        imdct(s->mdct_ctx[bsize], s->output, s->coefs[ch]);
                else if (!(s->ms_stereo && ch == 1))
                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;
 
                /* multiply by the window and add in the frame */
                index = (s->frame_len / 2) + s->block_pos - n4;
@@ -1099,7 +1095,6 @@ next:
        }
 
        /* update block number */
        }
 
        /* update block number */
-       s->block_num++;
        s->block_pos += s->block_len;
        if (s->block_pos >= s->frame_len)
                return 1;
        s->block_pos += s->block_len;
        if (s->block_pos >= s->frame_len)
                return 1;
@@ -1130,7 +1125,6 @@ static int wma_decode_frame(struct private_wmadec_data *s, int16_t * samples)
        float *iptr;
 
        /* read each block */
        float *iptr;
 
        /* read each block */
-       s->block_num = 0;
        s->block_pos = 0;
        for (;;) {
                ret = wma_decode_block(s);
        s->block_pos = 0;
        for (;;) {
                ret = wma_decode_block(s);
@@ -1153,7 +1147,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],
                }
                /* 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;
 }
        }
        return 0;
 }