shithub: opus

Download patch

ref: 31b79d19932ce37c62b4aed8cee2180e6106a25c
parent: d857ac48de795df17d54440579559854a9a4614f
author: Jean-Marc Valin <[email protected]>
date: Wed Mar 12 13:17:23 EDT 2008

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

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -139,8 +139,8 @@
 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 @@
    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 @@
    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;
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -159,8 +159,8 @@
 {
    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 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 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 @@
    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 @@
 {
    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 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 @@
    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);
--- a/libcelt/cwrs.c
+++ b/libcelt/cwrs.c
@@ -112,7 +112,7 @@
 {
    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 @@
 {
    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 @@
 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 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 @@
 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 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 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 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);
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -91,7 +91,7 @@
 {
    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 @@
 {
    int i;
    int N, N2, N4;
-   VARDECL(kiss_fft_scalar *f);
+   VARDECL(kiss_fft_scalar, f);
    SAVE_STACK;
    N = l->n;
    N2 = N/2;
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -105,9 +105,9 @@
 {
    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;
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -90,7 +90,7 @@
    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 @@
 #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 @@
       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++)
       {
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -191,7 +191,7 @@
    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 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;
--- a/libcelt/stack_alloc.h
+++ b/libcelt/stack_alloc.h
@@ -87,7 +87,7 @@
 
 #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
@@ -94,7 +94,7 @@
 
 #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 @@
 #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
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -49,7 +49,7 @@
    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 @@
 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 @@
     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);