X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=wmadec_filter.c;h=9cb964fca0648af10f142732892262aa45db3f80;hp=7479e84c6e9aab2d296ad9b314bf5abff8465e8c;hb=749779fab22f802e41472a31db5a84b9b6314996;hpb=88a7f1ff68c48cca7a4872075a2ad4e16dfca95b diff --git a/wmadec_filter.c b/wmadec_filter.c index 7479e84c..9cb964fc 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -75,7 +75,6 @@ struct private_wmadec_data { uint16_t exponent_bands[BLOCK_NB_SIZES][25]; /** The index of the first coef in high band. */ int high_band_start[BLOCK_NB_SIZES]; - int coefs_start;///< first coded coef int coefs_end[BLOCK_NB_SIZES]; ///< max number of coded coefficients int exponent_high_sizes[BLOCK_NB_SIZES]; int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE]; @@ -213,7 +212,6 @@ static void compute_scale_factor_band_sizes(struct private_wmadec_data *pwd, int a, b, pos, lpos, k, block_len, i, j, n; const uint8_t *table; - pwd->coefs_start = 0; for (k = 0; k < pwd->nb_block_sizes; k++) { block_len = pwd->frame_len >> k; @@ -750,8 +748,6 @@ static void compute_mdct_coefficients(struct private_wmadec_data *pwd, coefs = pwd->coefs[ch]; if (!pwd->use_noise_coding) { /* XXX: optimize more */ - for (i = 0; i < pwd->coefs_start; i++) - *coefs++ = 0.0; n = nb_coefs[ch]; for (i = 0; i < n; i++) *coefs++ = coefs1[i] * @@ -762,13 +758,6 @@ static void compute_mdct_coefficients(struct private_wmadec_data *pwd, continue; } mult1 = mult; - /* very low freqs: noise */ - for (i = 0; i < pwd->coefs_start; i++) { - *coefs++ = pwd->noise_table[pwd->noise_index] * - exponents[i << bsize >> esize] * mult1; - pwd->noise_index = (pwd->noise_index + 1) & - (NOISE_TAB_SIZE - 1); - } n1 = pwd->exponent_high_sizes[bsize]; /* compute power of high bands */ exponents = pwd->exponents[ch] + @@ -790,11 +779,10 @@ static void compute_mdct_coefficients(struct private_wmadec_data *pwd, exponents += n << bsize; } /* main freqs and high freqs */ - exponents = pwd->exponents[ch] + (pwd->coefs_start << bsize); + exponents = pwd->exponents[ch]; for (j = -1; j < n1; j++) { if (j < 0) - n = pwd->high_band_start[bsize] - - pwd->coefs_start; + n = pwd->high_band_start[bsize]; else n = pwd->exponent_high_bands[pwd->frame_len_bits - pwd->block_len_bits][j]; @@ -915,7 +903,7 @@ static int wma_decode_block(struct private_wmadec_data *pwd) coef_nb_bits = wma_total_gain_to_bits(total_gain); /* compute number of coefficients */ - n = pwd->coefs_end[bsize] - pwd->coefs_start; + n = pwd->coefs_end[bsize]; for (ch = 0; ch < pwd->ahi.channels; ch++) nb_coefs[ch] = n; @@ -1199,11 +1187,9 @@ fail: static ssize_t wmadec_convert(char *inbuffer, size_t len, struct filter_node *fn) { - int ret, out_size = fn->bufsize - fn->loaded; + int ret, converted = 0; struct private_wmadec_data *pwd = fn->private_data; - if (out_size < 128 * 1024) - return 0; if (len <= WMA_FRAME_SKIP) return 0; if (!pwd) { @@ -1215,16 +1201,22 @@ static ssize_t wmadec_convert(char *inbuffer, size_t len, fn->fc->samplerate = pwd->ahi.sample_rate; return pwd->ahi.header_len; } - /* skip 31 bytes */ - if (len <= WMA_FRAME_SKIP + pwd->ahi.block_align) - return 0; - ret = wma_decode_superframe(pwd, fn->buf + fn->loaded, - &out_size, (uint8_t *)inbuffer + WMA_FRAME_SKIP, - len - WMA_FRAME_SKIP); - if (ret < 0) - return ret; - fn->loaded += out_size; - return ret + WMA_FRAME_SKIP; + for (;;) { + int out_size; + if (converted + WMA_FRAME_SKIP + pwd->ahi.block_align > len) + break; + out_size = fn->bufsize - fn->loaded; + if (out_size < 128 * 1024) + break; + ret = wma_decode_superframe(pwd, fn->buf + fn->loaded, + &out_size, (uint8_t *)inbuffer + converted + WMA_FRAME_SKIP, + len - WMA_FRAME_SKIP); + if (ret < 0) + return ret; + fn->loaded += out_size; + converted += ret + WMA_FRAME_SKIP; + } + return converted; } static void wmadec_close(struct filter_node *fn)