#include <math.h>
#include <string.h>
#include <regex.h>
+#include <sys/select.h>
#include "para.h"
#include "error.h"
#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]);
+#define SINE_WINDOW(x) float sine_ ## x[x] __aligned(16)
-static float *ff_sine_windows[6] = {
- ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024,
- ff_sine_2048, ff_sine_4096
+SINE_WINDOW(128);
+SINE_WINDOW(256);
+SINE_WINDOW(512);
+SINE_WINDOW(1024);
+SINE_WINDOW(2048);
+SINE_WINDOW(4096);
+
+static float *sine_windows[6] = {
+ sine_128, sine_256, sine_512, sine_1024, sine_2048, sine_4096
};
/* Generate a sine window. */
for (i = 0; i < pwd->nb_block_sizes; i++) {
int n;
n = 1 << (pwd->frame_len_bits - i);
- sine_window_init(ff_sine_windows[pwd->frame_len_bits - i - 7], n);
- pwd->windows[i] = ff_sine_windows[pwd->frame_len_bits - i - 7];
+ sine_window_init(sine_windows[pwd->frame_len_bits - i - 7], n);
+ pwd->windows[i] = sine_windows[pwd->frame_len_bits - i - 7];
}
pwd->reset_block_lengths = 1;
if (pwd->use_noise_coding) {
PARA_INFO_LOG("using noise coding\n");
init_vlc(&pwd->hgain_vlc, HGAINVLCBITS,
- sizeof(ff_wma_hgain_huffbits), ff_wma_hgain_huffbits,
- ff_wma_hgain_huffcodes, 2);
+ sizeof(wma_hgain_huffbits), wma_hgain_huffbits,
+ wma_hgain_huffcodes, 2);
}
if (pwd->use_exp_vlc) {
PARA_INFO_LOG("using exp_vlc\n");
init_vlc(&pwd->exp_vlc, EXPVLCBITS,
- sizeof(ff_wma_scale_huffbits), ff_wma_scale_huffbits,
- ff_wma_scale_huffcodes, 4);
+ sizeof(wma_scale_huffbits), wma_scale_huffbits,
+ wma_scale_huffcodes, 4);
} else {
PARA_INFO_LOG("using curve\n");
wma_lsp_to_curve_init(pwd, pwd->frame_len);
val = get_bits(&pwd->gb, 3);
else
val = get_bits(&pwd->gb, 4);
- lsp_coefs[i] = ff_wma_lsp_codebook[i][val];
+ lsp_coefs[i] = wma_lsp_codebook[i][val];
}
wma_lsp_to_curve(pwd, pwd->exponents[ch], &pwd->max_exponent[ch],
return 9;
}
+static int compute_high_band_values(struct private_wmadec_data *pwd,
+ int bsize, int nb_coefs[MAX_CHANNELS])
+{
+ int ch;
+
+ if (pwd->use_noise_coding) {
+ for (ch = 0; ch < pwd->ahi.channels; ch++) {
+ if (pwd->channel_coded[ch]) {
+ int i, m, a;
+ m = pwd->exponent_high_sizes[bsize];
+ for (i = 0; i < m; i++) {
+ a = get_bit(&pwd->gb);
+ pwd->high_band_coded[ch][i] = a;
+ /* if noise coding, the coefficients are not transmitted */
+ if (a)
+ nb_coefs[ch] -=
+ pwd->
+ exponent_high_bands[bsize]
+ [i];
+ }
+ }
+ }
+ for (ch = 0; ch < pwd->ahi.channels; ch++) {
+ if (pwd->channel_coded[ch]) {
+ int i, n, val;
+
+ n = pwd->exponent_high_sizes[bsize];
+ val = (int) 0x80000000;
+ for (i = 0; i < n; i++) {
+ if (pwd->high_band_coded[ch][i]) {
+ if (val == (int) 0x80000000) {
+ val =
+ get_bits(&pwd->gb,
+ 7) - 19;
+ } else {
+ int code =
+ get_vlc(&pwd->gb,
+ pwd->
+ hgain_vlc.
+ table,
+ HGAINVLCBITS,
+ HGAINMAX);
+ if (code < 0)
+ return -1;
+ val += code - 18;
+ }
+ pwd->high_band_values[ch][i] =
+ val;
+ }
+ }
+ }
+ }
+ }
+ return 1;
+}
/**
* @return 0 if OK. 1 if last block of frame. return -1 if
* unrecorrable error.
for (ch = 0; ch < pwd->ahi.channels; ch++)
nb_coefs[ch] = n;
- /* complex coding */
- if (pwd->use_noise_coding) {
- for (ch = 0; ch < pwd->ahi.channels; ch++) {
- if (pwd->channel_coded[ch]) {
- int i, m, a;
- m = pwd->exponent_high_sizes[bsize];
- for (i = 0; i < m; i++) {
- a = get_bit(&pwd->gb);
- pwd->high_band_coded[ch][i] = a;
- /* if noise coding, the coefficients are not transmitted */
- if (a)
- nb_coefs[ch] -=
- pwd->
- exponent_high_bands[bsize]
- [i];
- }
- }
- }
- for (ch = 0; ch < pwd->ahi.channels; ch++) {
- if (pwd->channel_coded[ch]) {
- int i, val;
-
- n = pwd->exponent_high_sizes[bsize];
- val = (int) 0x80000000;
- for (i = 0; i < n; i++) {
- if (pwd->high_band_coded[ch][i]) {
- if (val == (int) 0x80000000) {
- val =
- get_bits(&pwd->gb,
- 7) - 19;
- } else {
- code =
- get_vlc(&pwd->gb,
- pwd->
- hgain_vlc.
- table,
- HGAINVLCBITS,
- HGAINMAX);
- if (code < 0)
- return -1;
- val += code - 18;
- }
- pwd->high_band_values[ch][i] =
- val;
- }
- }
- }
- }
- }
+ if (compute_high_band_values(pwd, bsize, nb_coefs) < 0)
+ return -1;
/* exponents can be reused in short blocks. */
if ((pwd->block_len_bits == pwd->frame_len_bits) || get_bit(&pwd->gb)) {
samples += pwd->ahi.channels * pwd->frame_len;
}
PARA_DEBUG_LOG("frame_count: %d frame_len: %d, block_len: %d, "
- "outbytes: %d, eaten: %d\n",
+ "outbytes: %zd, eaten: %d\n",
frame_count, pwd->frame_len, pwd->block_len,
(int8_t *) samples - (int8_t *) data, pwd->ahi.block_align);
*data_size = (int8_t *)samples - (int8_t *)data;
if (out_size < 128 * 1024)
return 0;
+ if (len <= WMA_FRAME_SKIP)
+ return 0;
if (!pwd) {
ret = wma_decode_init(inbuffer, len, &pwd);
if (ret <= 0)