Commit 31b79d19 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Changed definition of VARDECL to make it more flexible. No actual code change.

parent d857ac48
......@@ -139,8 +139,8 @@ void normalise_bands(const CELTMode *m, const celt_sig_t *freq, celt_norm_t *X,
void renormalise_bands(const CELTMode *m, celt_norm_t *X)
{
int i;
VARDECL(celt_ener_t *tmpE);
VARDECL(celt_sig_t *freq);
VARDECL(celt_ener_t, tmpE);
VARDECL(celt_sig_t, freq);
SAVE_STACK;
ALLOC(tmpE, m->nbEBands*m->nbChannels, celt_ener_t);
ALLOC(freq, m->nbMdctBlocks*m->nbChannels*m->eBands[m->nbEBands+1], celt_sig_t);
......@@ -291,9 +291,9 @@ void quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_mask_t
int i, j, B, bits;
const celt_int16_t *eBands = m->eBands;
celt_word16_t alpha;
VARDECL(celt_norm_t *norm);
VARDECL(int *pulses);
VARDECL(int *offsets);
VARDECL(celt_norm_t, norm);
VARDECL(int, pulses);
VARDECL(int, offsets);
SAVE_STACK;
B = m->nbMdctBlocks*m->nbChannels;
......@@ -355,9 +355,9 @@ void unquant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, int total_
int i, j, B, bits;
const celt_int16_t *eBands = m->eBands;
celt_word16_t alpha;
VARDECL(celt_norm_t *norm);
VARDECL(int *pulses);
VARDECL(int *offsets);
VARDECL(celt_norm_t, norm);
VARDECL(int, pulses);
VARDECL(int, offsets);
SAVE_STACK;
B = m->nbMdctBlocks*m->nbChannels;
......
......@@ -159,8 +159,8 @@ static celt_word32_t compute_mdcts(const mdct_lookup *mdct_lookup, const celt_wo
{
int i, c, N4;
celt_word32_t E = 0;
VARDECL(celt_word32_t *x);
VARDECL(celt_word32_t *tmp);
VARDECL(celt_word32_t, x);
VARDECL(celt_word32_t, tmp);
SAVE_STACK;
N4 = (N-overlap)/2;
ALLOC(x, 2*N, celt_word32_t);
......@@ -198,8 +198,8 @@ static celt_word32_t compute_mdcts(const mdct_lookup *mdct_lookup, const celt_wo
static void compute_inv_mdcts(const mdct_lookup *mdct_lookup, const celt_word16_t *window, celt_sig_t *X, celt_sig_t *out_mem, celt_sig_t *mdct_overlap, int N, int overlap, int B, int C)
{
int i, c, N4;
VARDECL(celt_word32_t *x);
VARDECL(celt_word32_t *tmp);
VARDECL(celt_word32_t, x);
VARDECL(celt_word32_t, tmp);
SAVE_STACK;
ALLOC(x, 2*N, celt_word32_t);
ALLOC(tmp, N, celt_word32_t);
......@@ -237,12 +237,12 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i
int has_pitch;
int pitch_index;
celt_word32_t curr_power, pitch_power;
VARDECL(celt_sig_t *in);
VARDECL(celt_sig_t *freq);
VARDECL(celt_norm_t *X);
VARDECL(celt_norm_t *P);
VARDECL(celt_ener_t *bandE);
VARDECL(celt_pgain_t *gains);
VARDECL(celt_sig_t, in);
VARDECL(celt_sig_t, freq);
VARDECL(celt_norm_t, X);
VARDECL(celt_norm_t, P);
VARDECL(celt_ener_t, bandE);
VARDECL(celt_pgain_t, gains);
SAVE_STACK;
if (check_mode(st->mode) != CELT_OK)
......@@ -322,7 +322,7 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i
if (MULT16_32_Q15(QCONST16(.1f, 15),curr_power) + SHR16(10000,8) < pitch_power)
{
/* Normalise the pitch vector as well (discard the energies) */
VARDECL(celt_ener_t *bandEp);
VARDECL(celt_ener_t, bandEp);
ALLOC(bandEp, st->mode->nbEBands*st->mode->nbChannels, celt_ener_t);
compute_band_energies(st->mode, freq, bandEp);
normalise_bands(st->mode, freq, P, bandEp);
......@@ -511,7 +511,7 @@ static void celt_decode_lost(CELTDecoder *st, short *pcm)
{
int i, c, N, B, C;
int pitch_index;
VARDECL(celt_sig_t *freq);
VARDECL(celt_sig_t, freq);
SAVE_STACK;
N = st->block_size;
B = st->nb_blocks;
......@@ -551,11 +551,11 @@ int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm
int pitch_index;
ec_dec dec;
ec_byte_buffer buf;
VARDECL(celt_sig_t *freq);
VARDECL(celt_norm_t *X);
VARDECL(celt_norm_t *P);
VARDECL(celt_ener_t *bandE);
VARDECL(celt_pgain_t *gains);
VARDECL(celt_sig_t, freq);
VARDECL(celt_norm_t, X);
VARDECL(celt_norm_t, P);
VARDECL(celt_ener_t, bandE);
VARDECL(celt_pgain_t, gains);
SAVE_STACK;
if (check_mode(st->mode) != CELT_OK)
......@@ -607,7 +607,7 @@ int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm
compute_mdcts(&st->mode->mdct, st->mode->window, st->out_mem+pitch_index*C, freq, N, st->overlap, B, C);
{
VARDECL(celt_ener_t *bandEp);
VARDECL(celt_ener_t, bandEp);
ALLOC(bandEp, st->mode->nbEBands*C, celt_ener_t);
compute_band_energies(st->mode, freq, bandEp);
normalise_bands(st->mode, freq, P, bandEp);
......
......@@ -112,7 +112,7 @@ celt_uint32_t ncwrs(int _n,int _m)
{
int i;
celt_uint32_t ret;
VARDECL(celt_uint32_t *nc);
VARDECL(celt_uint32_t, nc);
SAVE_STACK;
ALLOC(nc,_n+1, celt_uint32_t);
for (i=0;i<_n+1;i++)
......@@ -130,7 +130,7 @@ celt_uint64_t ncwrs64(int _n,int _m)
{
int i;
celt_uint64_t ret;
VARDECL(celt_uint64_t *nc);
VARDECL(celt_uint64_t, nc);
SAVE_STACK;
ALLOC(nc,_n+1, celt_uint64_t);
for (i=0;i<_n+1;i++)
......@@ -150,7 +150,7 @@ celt_uint64_t ncwrs64(int _n,int _m)
void cwrsi(int _n,int _m,celt_uint32_t _i,int *_x,int *_s){
int j;
int k;
VARDECL(celt_uint32_t *nc);
VARDECL(celt_uint32_t, nc);
SAVE_STACK;
ALLOC(nc,_n+1, celt_uint32_t);
for (j=0;j<_n+1;j++)
......@@ -196,7 +196,7 @@ celt_uint32_t icwrs(int _n,int _m,const int *_x,const int *_s, celt_uint32_t *bo
celt_uint32_t i;
int j;
int k;
VARDECL(celt_uint32_t *nc);
VARDECL(celt_uint32_t, nc);
SAVE_STACK;
ALLOC(nc,_n+1, celt_uint32_t);
for (j=0;j<_n+1;j++)
......@@ -240,7 +240,7 @@ celt_uint32_t icwrs(int _n,int _m,const int *_x,const int *_s, celt_uint32_t *bo
void cwrsi64(int _n,int _m,celt_uint64_t _i,int *_x,int *_s){
int j;
int k;
VARDECL(celt_uint64_t *nc);
VARDECL(celt_uint64_t, nc);
SAVE_STACK;
ALLOC(nc,_n+1, celt_uint64_t);
for (j=0;j<_n+1;j++)
......@@ -286,7 +286,7 @@ celt_uint64_t icwrs64(int _n,int _m,const int *_x,const int *_s, celt_uint64_t *
celt_uint64_t i;
int j;
int k;
VARDECL(celt_uint64_t *nc);
VARDECL(celt_uint64_t, nc);
SAVE_STACK;
ALLOC(nc,_n+1, celt_uint64_t);
for (j=0;j<_n+1;j++)
......@@ -364,8 +364,8 @@ void pulse2comb(int _n,int _m,int *_x,int *_s,const int *_y){
void encode_pulses(int *_y, int N, int K, ec_enc *enc)
{
VARDECL(int *comb);
VARDECL(int *signs);
VARDECL(int, comb);
VARDECL(int, signs);
SAVE_STACK;
ALLOC(comb, K, int);
......@@ -388,8 +388,8 @@ void encode_pulses(int *_y, int N, int K, ec_enc *enc)
void decode_pulses(int *_y, int N, int K, ec_dec *dec)
{
VARDECL(int *comb);
VARDECL(int *signs);
VARDECL(int, comb);
VARDECL(int, signs);
SAVE_STACK;
ALLOC(comb, K, int);
......
......@@ -91,7 +91,7 @@ void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *ou
{
int i;
int N, N2, N4;
VARDECL(kiss_fft_scalar *f);
VARDECL(kiss_fft_scalar, f);
SAVE_STACK;
N = l->n;
N2 = N/2;
......@@ -136,7 +136,7 @@ void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *o
{
int i;
int N, N2, N4;
VARDECL(kiss_fft_scalar *f);
VARDECL(kiss_fft_scalar, f);
SAVE_STACK;
N = l->n;
N2 = N/2;
......
......@@ -105,9 +105,9 @@ void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const
{
int c, i;
celt_word32_t max_corr;
VARDECL(celt_word16_t *X);
VARDECL(celt_word16_t *Y);
VARDECL(celt_mask_t *curve);
VARDECL(celt_word16_t, X);
VARDECL(celt_word16_t, Y);
VARDECL(celt_mask_t, curve);
int n2;
int L2;
const int *bitrev;
......
......@@ -90,7 +90,7 @@ static void quant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_word1
celt_word16_t prev = 0;
celt_word16_t coef = m->ePredCoef;
celt_word16_t beta;
VARDECL(celt_word16_t *error);
VARDECL(celt_word16_t, error);
SAVE_STACK;
/* The .7 is a heuristic */
beta = MULT16_16_Q15(QCONST16(.7f,15),coef);
......@@ -223,7 +223,7 @@ void quant_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBan
#if 1
{
int c;
VARDECL(celt_ener_t *E);
VARDECL(celt_ener_t, E);
ALLOC(E, m->nbEBands, celt_ener_t);
for (c=0;c<C;c++)
{
......@@ -282,7 +282,7 @@ void unquant_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEB
unquant_energy_mono(m, eBands, oldEBands, budget, dec);
else {
int c;
VARDECL(celt_ener_t *E);
VARDECL(celt_ener_t, E);
ALLOC(E, m->nbEBands, celt_ener_t);
for (c=0;c<C;c++)
{
......
......@@ -191,7 +191,7 @@ int interp_bits2pulses(const CELTMode *m, int *bits1, int *bits2, int total, int
int lo, hi, out;
int j;
int firstpass;
VARDECL(int *bits);
VARDECL(int, bits);
SAVE_STACK;
ALLOC(bits, len, int);
lo = 0;
......@@ -243,8 +243,8 @@ int interp_bits2pulses(const CELTMode *m, int *bits1, int *bits2, int total, int
int compute_allocation(const CELTMode *m, int *offsets, int total, int *pulses)
{
int lo, hi, len, ret;
VARDECL(int *bits1);
VARDECL(int *bits2);
VARDECL(int, bits1);
VARDECL(int, bits2);
SAVE_STACK;
len = m->nbEBands;
......
......@@ -87,14 +87,14 @@
#if defined(VAR_ARRAYS)
#define VARDECL(var)
#define VARDECL(type, var)
#define ALLOC(var, size, type) type var[size]
#define SAVE_STACK
#define RESTORE_STACK
#elif defined(USE_ALLOCA)
#define VARDECL(var) var
#define VARDECL(type, var) type *var
#define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size)))
#define SAVE_STACK
#define RESTORE_STACK
......@@ -128,7 +128,7 @@ extern char *global_stack;
#endif
#include "os_support.h"
#define VARDECL(var) var
#define VARDECL(type, var) type *var
#define ALLOC(var, size, type) var = PUSH(global_stack, size, type)
#define SAVE_STACK char *_saved_stack; ALLOC_STACK(global_stack);_saved_stack = global_stack;
#endif
......
......@@ -49,7 +49,7 @@ static void mix_pitch_and_residual(int *iy, celt_norm_t *X, int N, int K, const
int i;
celt_word32_t Ryp, Ryy, Rpp;
celt_word32_t g;
VARDECL(celt_norm_t *y);
VARDECL(celt_norm_t, y);
#ifdef FIXED_POINT
int yshift;
#endif
......@@ -106,21 +106,21 @@ struct NBest {
void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *P, celt_word16_t alpha, ec_enc *enc)
{
int L = 3;
VARDECL(celt_norm_t *_y);
VARDECL(celt_norm_t *_ny);
VARDECL(int *_iy);
VARDECL(int *_iny);
VARDECL(celt_norm_t **y);
VARDECL(celt_norm_t **ny);
VARDECL(int **iy);
VARDECL(int **iny);
VARDECL(celt_norm_t, _y);
VARDECL(celt_norm_t, _ny);
VARDECL(int, _iy);
VARDECL(int, _iny);
VARDECL(celt_norm_t *, y);
VARDECL(celt_norm_t *, ny);
VARDECL(int *, iy);
VARDECL(int *, iny);
int i, j, k, m;
int pulsesLeft;
VARDECL(celt_word32_t *xy);
VARDECL(celt_word32_t *yy);
VARDECL(celt_word32_t *yp);
VARDECL(struct NBest *_nbest);
VARDECL(struct NBest **nbest);
VARDECL(celt_word32_t, xy);
VARDECL(celt_word32_t, yy);
VARDECL(celt_word32_t, yp);
VARDECL(struct NBest, _nbest);
VARDECL(struct NBest *, nbest);
celt_word32_t Rpp=0, Rxp=0;
int maxL = 1;
#ifdef FIXED_POINT
......@@ -343,7 +343,7 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *
the final normalised signal in the current band. */
void alg_unquant(celt_norm_t *X, int N, int K, celt_norm_t *P, celt_word16_t alpha, ec_dec *dec)
{
VARDECL(int *iy);
VARDECL(int, iy);
SAVE_STACK;
ALLOC(iy, N, int);
decode_pulses(iy, N, K, dec);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment