diff --git a/libs/celt/cc6_celt.c b/libs/celt/cc6_celt.c index e7fff079..aefbcc23 100755 --- a/libs/celt/cc6_celt.c +++ b/libs/celt/cc6_celt.c @@ -665,7 +665,7 @@ int cc6_celt_encode_float(cc6_CELTEncoder * __restrict st, const cc6_celt_sig_t cc6_compute_band_energies(st->mode, freq, bandE); for (i=0;imode->nbEBands*C;i++) - bandLogE[i] = amp2Log(bandE[i]); + bandLogE[i] = cc6_amp2Log(bandE[i]); /* Don't use intra energy when we're operating at low bit-rate */ intra_ener = st->force_intra || (st->delayedIntra && nbCompressedBytes > st->mode->nbEBands); diff --git a/libs/celt/cc6_pitch.h b/libs/celt/cc6_pitch.h index e0aa4275..7a60bf4b 100755 --- a/libs/celt/cc6_pitch.h +++ b/libs/celt/cc6_pitch.h @@ -35,19 +35,19 @@ */ -#ifndef _PITCH_H -#define _PITCH_H +#ifndef cc6__PITCH_H +#define cc6__PITCH_H #include "cc6_kiss_fftr.h" #include "cc6_psy.h" #include "cc6_modes.h" -kiss_fftr_cfg pitch_state_alloc(int max_lag); -void pitch_state_free(kiss_fftr_cfg st); +cc6_kiss_fftr_cfg cc6_pitch_state_alloc(int max_lag); +void cc6_pitch_state_free(cc6_kiss_fftr_cfg st); /** Find the optimal delay for the pitch prediction. Computation is done in the frequency domain, both to save time and to make it easier to apply psychoacoustic weighting */ -void find_spectral_pitch(const CELTMode *m, kiss_fftr_cfg fft, const struct PsyDecay *decay, const celt_sig_t *x, const celt_sig_t *y, const celt_word16_t *window, celt_word16_t * __restrict X, int len, int max_pitch, int *pitch); +void cc6_find_spectral_pitch(const cc6_CELTMode *m, cc6_kiss_fftr_cfg fft, const struct cc6_PsyDecay *decay, const cc6_celt_sig_t *x, const cc6_celt_sig_t *y, const cc6_celt_word16_t *window, cc6_celt_word16_t * __restrict X, int len, int max_pitch, int *pitch); #endif diff --git a/libs/celt/cc6_psy.h b/libs/celt/cc6_psy.h index 6669bc57..9f9951b2 100755 --- a/libs/celt/cc6_psy.h +++ b/libs/celt/cc6_psy.h @@ -28,29 +28,29 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef PSY_H -#define PSY_H +#ifndef cc6_PSY_H +#define cc6_PSY_H #include "cc6_arch.h" #include "cc6_celt.h" -struct PsyDecay { - /*celt_word16_t *decayL;*/ - const celt_word16_t * __restrict decayR; +struct cc6_PsyDecay { + /*cc6_celt_word16_t *decayL;*/ + const cc6_celt_word16_t * __restrict decayR; }; /** Pre-compute the decay of the psycho-acoustic spreading function */ -void psydecay_init(struct PsyDecay *decay, int len, celt_int32_t Fs); +void cc6_psydecay_init(struct cc6_PsyDecay *decay, int len, cc6_celt_int32_t Fs); /** Free the memory allocated for the spreading function */ -void psydecay_clear(struct PsyDecay *decay); +void cc6_psydecay_clear(struct cc6_PsyDecay *decay); /** Compute the masking curve for an input (DFT) spectrum X */ -void compute_masking(const struct PsyDecay *decay, celt_word16_t *X, celt_mask_t *mask, int len); +void cc6_compute_masking(const struct cc6_PsyDecay *decay, cc6_celt_word16_t *X, cc6_celt_mask_t *mask, int len); /** Compute the masking curve for an input (MDCT) spectrum X */ -void compute_mdct_masking(const struct PsyDecay *decay, celt_word32_t *X, celt_word16_t *tonality, celt_word16_t *long_window, celt_mask_t *mask, int len); +void cc6_compute_mdct_masking(const struct cc6_PsyDecay *decay, cc6_celt_word32_t *X, cc6_celt_word16_t *tonality, cc6_celt_word16_t *long_window, cc6_celt_mask_t *mask, int len); -void compute_tonality(const CELTMode *m, celt_word16_t * __restrict X, celt_word16_t * mem, int len, celt_word16_t *tonality, int mdct_size); +void cc6_compute_tonality(const cc6_CELTMode *m, cc6_celt_word16_t * __restrict X, cc6_celt_word16_t * mem, int len, cc6_celt_word16_t *tonality, int mdct_size); -#endif /* PSY_H */ +#endif /* cc6_PSY_H */ diff --git a/libs/celt/cc6_quant_bands.h b/libs/celt/cc6_quant_bands.h index e66d3fdd..1e790937 100755 --- a/libs/celt/cc6_quant_bands.h +++ b/libs/celt/cc6_quant_bands.h @@ -29,8 +29,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef QUANT_BANDS -#define QUANT_BANDS +#ifndef cc6_QUANT_BANDS +#define cc6_QUANT_BANDS #include "cc6_arch.h" #include "cc6_modes.h" @@ -38,33 +38,33 @@ #include "cc6_entdec.h" #include "cc6_mathops.h" -static __inline celt_word16_t amp2Log(celt_word32_t amp) +static __inline cc6_celt_word16_t cc6_amp2Log(cc6_celt_word32_t amp) { - return celt_log2(MAX32(QCONST32(.001f,14),SHL32(amp,2))); + return cc6_celt_log2(cc6_MAX32(cc6_QCONST32(.001f,14),cc6_SHL32(amp,2))); } -static __inline celt_word32_t log2Amp(celt_word16_t lg) +static __inline cc6_celt_word32_t cc6_log2Amp(cc6_celt_word16_t lg) { - return PSHR32(celt_exp2(SHL16(lg,3)),4); + return cc6_PSHR32(cc6_celt_exp2(cc6_SHL16(lg,3)),4); } -int *quant_prob_alloc(const CELTMode *m); -void quant_prob_free(int *freq); +int *cc6_quant_prob_alloc(const cc6_CELTMode *m); +void cc6_quant_prob_free(int *freq); -void compute_fine_allocation(const CELTMode *m, int *bits, int budget); +void cc6_compute_fine_allocation(const cc6_CELTMode *m, int *bits, int budget); -int intra_decision(celt_word16_t *eBands, celt_word16_t *oldEBands, int len); +int cc6_intra_decision(cc6_celt_word16_t *eBands, cc6_celt_word16_t *oldEBands, int len); -unsigned quant_coarse_energy(const CELTMode *m, celt_word16_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, celt_word16_t *error, ec_enc *enc); +unsigned cc6_quant_coarse_energy(const cc6_CELTMode *m, cc6_celt_word16_t *eBands, cc6_celt_word16_t *oldEBands, int budget, int intra, int *prob, cc6_celt_word16_t *error, cc6_ec_enc *enc); -void quant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, celt_word16_t *error, int *fine_quant, ec_enc *enc); +void cc6_quant_fine_energy(const cc6_CELTMode *m, cc6_celt_ener_t *eBands, cc6_celt_word16_t *oldEBands, cc6_celt_word16_t *error, int *fine_quant, cc6_ec_enc *enc); -void quant_energy_finalise(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, celt_word16_t *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc); +void cc6_quant_energy_finalise(const cc6_CELTMode *m, cc6_celt_ener_t *eBands, cc6_celt_word16_t *oldEBands, cc6_celt_word16_t *error, int *fine_quant, int *fine_priority, int bits_left, cc6_ec_enc *enc); -void unquant_coarse_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, ec_dec *dec); +void cc6_unquant_coarse_energy(const cc6_CELTMode *m, cc6_celt_ener_t *eBands, cc6_celt_word16_t *oldEBands, int budget, int intra, int *prob, cc6_ec_dec *dec); -void unquant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int *fine_quant, ec_dec *dec); +void cc6_unquant_fine_energy(const cc6_CELTMode *m, cc6_celt_ener_t *eBands, cc6_celt_word16_t *oldEBands, int *fine_quant, cc6_ec_dec *dec); -void unquant_energy_finalise(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec); +void cc6_unquant_energy_finalise(const cc6_CELTMode *m, cc6_celt_ener_t *eBands, cc6_celt_word16_t *oldEBands, int *fine_quant, int *fine_priority, int bits_left, cc6_ec_dec *dec); -#endif /* QUANT_BANDS */ +#endif /* cc6_QUANT_BANDS */ diff --git a/libs/celt/cc6_rate.h b/libs/celt/cc6_rate.h index ac8a3170..5cc3bfac 100755 --- a/libs/celt/cc6_rate.h +++ b/libs/celt/cc6_rate.h @@ -29,32 +29,32 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef RATE_H -#define RATE_H +#ifndef cc6_RATE_H +#define cc6_RATE_H -#define MAX_PULSES 128 -#define LOG_MAX_PULSES 7 +#define cc6_MAX_PULSES 128 +#define cc6_LOG_MAX_PULSES 7 -#define BITRES 4 -#define BITROUND 8 -#define BITOVERFLOW 30000 +#define cc6_BITRES 4 +#define cc6_BITROUND 8 +#define cc6_BITOVERFLOW 30000 #include "cc6_cwrs.h" -static __inline int bits2pulses(const CELTMode *m, const celt_int16_t *cache, int N, int bits) +static __inline int cc6_bits2pulses(const cc6_CELTMode *m, const cc6_celt_int16_t *cache, int N, int bits) { int i; int lo, hi; lo = 0; - hi = MAX_PULSES-1; + hi = cc6_MAX_PULSES-1; #if 0 /* Disabled until we can make that useful */ - /* Use of more than MAX_PULSES is disabled until we are able to cwrs that decently */ - if (bits > cache[MAX_PULSES-1] && N<=4) + /* Use of more than cc6_MAX_PULSES is disabled until we are able to cwrs that decently */ + if (bits > cache[cc6_MAX_PULSES-1] && N<=4) { /*int pulses; pulses = 127; - while (16 + log2_frac(2*(pulses+1)*(pulses+1) + 1, 4) <= bits && pulses < 32767) + while (16 + cc6_log2_frac(2*(pulses+1)*(pulses+1) + 1, 4) <= bits && pulses < 32767) pulses++;*/ lo = 127; switch (N) @@ -64,7 +64,7 @@ static __inline int bits2pulses(const CELTMode *m, const celt_int16_t *cache, in for (i=0;i<10;i++) { int pulses = (lo+hi)>>1; - if (log2_frac(((UMUL16_16(pulses,pulses)>>1)+1)>>1, 4) > bits) + if (cc6_log2_frac(((cc6_UMUL16_16(pulses,pulses)>>1)+1)>>1, 4) > bits) hi = pulses; else lo = pulses; @@ -75,7 +75,7 @@ static __inline int bits2pulses(const CELTMode *m, const celt_int16_t *cache, in for (i=0;i<10;i++) { int pulses = (lo+hi)>>1; - if (log2_frac((UMUL32(UMUL16_16(pulses,pulses)+2,pulses))/3<<3, 4) > bits) + if (cc6_log2_frac((cc6_UMUL32(cc6_UMUL16_16(pulses,pulses)+2,pulses))/3<<3, 4) > bits) hi = pulses; else lo = pulses; @@ -88,7 +88,7 @@ static __inline int bits2pulses(const CELTMode *m, const celt_int16_t *cache, in /* Instead of using the "bisection condition" we use a fixed number of iterations because it should be faster */ /*while (hi-lo != 1)*/ - for (i=0;i>1; /* OPT: Make sure this is implemented with a conditional move */ @@ -104,19 +104,19 @@ static __inline int bits2pulses(const CELTMode *m, const celt_int16_t *cache, in } -static __inline int pulses2bits(const celt_int16_t *cache, int N, int pulses) +static __inline int cc6_pulses2bits(const cc6_celt_int16_t *cache, int N, int pulses) { -#if 0 /* Use of more than MAX_PULSES is disabled until we are able to cwrs that decently */ +#if 0 /* Use of more than cc6_MAX_PULSES is disabled until we are able to cwrs that decently */ if (pulses > 127) { int bits; switch (N) { case 3: - bits = log2_frac(((UMUL16_16(pulses,pulses)>>1)+1)>>1, 4); + bits = cc6_log2_frac(((cc6_UMUL16_16(pulses,pulses)>>1)+1)>>1, 4); break; case 4: - bits = log2_frac((UMUL32(UMUL16_16(pulses,pulses)+2,pulses))/3<<3, 4); + bits = cc6_log2_frac((cc6_UMUL32(cc6_UMUL16_16(pulses,pulses)+2,pulses))/3<<3, 4); break; } /*printf ("%d <- %d\n", bits, pulses);*/ @@ -127,7 +127,7 @@ static __inline int pulses2bits(const celt_int16_t *cache, int N, int pulses) } /** Computes a cache of the pulses->bits mapping in each band */ -celt_int16_t **compute_alloc_cache(CELTMode *m, int C); +cc6_celt_int16_t **cc6_compute_alloc_cache(cc6_CELTMode *m, int C); /** Compute the pulse allocation, i.e. how many pulses will go in each * band. @@ -138,7 +138,7 @@ celt_int16_t **compute_alloc_cache(CELTMode *m, int C); @param pulses Number of pulses per band (returned) @return Total number of bits allocated */ -void compute_allocation(const CELTMode *m, int *offsets, int total, int *pulses, int *ebits, int *fine_priority); +void cc6_compute_allocation(const cc6_CELTMode *m, int *offsets, int total, int *pulses, int *ebits, int *fine_priority); #endif diff --git a/libs/celt/cc6_stack_alloc.h b/libs/celt/cc6_stack_alloc.h index 789d7ff5..f168fafb 100755 --- a/libs/celt/cc6_stack_alloc.h +++ b/libs/celt/cc6_stack_alloc.h @@ -1,144 +1,144 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file stack_alloc.h - @brief Temporary memory allocation on stack -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef STACK_ALLOC_H -#define STACK_ALLOC_H - -#ifdef USE_ALLOCA -# ifdef WIN32 -# include -# else -# ifdef HAVE_ALLOCA_H -# include -# else -# include -# endif -# endif -#endif - -/** - * @def ALIGN(stack, size) - * - * Aligns the stack to a 'size' boundary - * - * @param stack Stack - * @param size New size boundary - */ - -/** - * @def PUSH(stack, size, type) - * - * Allocates 'size' elements of type 'type' on the stack - * - * @param stack Stack - * @param size Number of elements - * @param type Type of element - */ - -/** - * @def VARDECL(var) - * - * Declare variable on stack - * - * @param var Variable to declare - */ - -/** - * @def ALLOC(var, size, type) - * - * Allocate 'size' elements of 'type' on stack - * - * @param var Name of variable to allocate - * @param size Number of elements - * @param type Type of element - */ - - -#if defined(VAR_ARRAYS) - -#define VARDECL(type, var) -#define ALLOC(var, size, type) type var[size] -#define SAVE_STACK -#define RESTORE_STACK -#define ALLOC_STACK - -#elif defined(USE_ALLOCA) - -#define VARDECL(type, var) type *var -#define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size))) -#define SAVE_STACK -#define RESTORE_STACK -#define ALLOC_STACK - -#else - -#ifdef CELT_C -char *global_stack=0; -#else -extern char *global_stack; -#endif /*CELT_C*/ - -#ifdef ENABLE_VALGRIND - -#include - -#ifdef CELT_C -char *global_stack_top=0; -#else -extern char *global_stack_top; -#endif /*CELT_C*/ - -#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) -#define PUSH(stack, size, type) (VALGRIND_MAKE_MEM_NOACCESS(stack, global_stack_top-stack),ALIGN((stack),sizeof(type)/sizeof(char)),VALGRIND_MAKE_MEM_UNDEFINED(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=(2*(size)*sizeof(type)/sizeof(char)),(type*)((stack)-(2*(size)*sizeof(type)/sizeof(char)))) -#define RESTORE_STACK ((global_stack = _saved_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)) -#define ALLOC_STACK ((global_stack = (global_stack==0) ? ((global_stack_top=celt_alloc_scratch(GLOBAL_STACK_SIZE*2)+(GLOBAL_STACK_SIZE*2))-(GLOBAL_STACK_SIZE*2)) : global_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)) - -#else - -#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) -#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/sizeof(char)),(stack)+=(size)*(sizeof(type)/sizeof(char)),(type*)((stack)-(size)*(sizeof(type)/sizeof(char)))) -#define RESTORE_STACK (global_stack = _saved_stack) -#define ALLOC_STACK (global_stack = (global_stack==0) ? celt_alloc_scratch(GLOBAL_STACK_SIZE) : global_stack) - -#endif /*ENABLE_VALGRIND*/ - -#include "os_support.h" -#define VARDECL(type, var) type *var -#define ALLOC(var, size, type) var = PUSH(global_stack, size, type) -#define SAVE_STACK char *_saved_stack = global_stack; - -#endif /*VAR_ARRAYS*/ - - -#endif /*STACK_ALLOC_H*/ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file stack_alloc.h + @brief Temporary memory allocation on stack +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef cc6_STACK_ALLOC_H +#define cc6_STACK_ALLOC_H + +#ifdef USE_ALLOCA +# ifdef WIN32 +# include +# else +# ifdef HAVE_ALLOCA_H +# include +# else +# include +# endif +# endif +#endif + +/** + * @def cc6_ALIGN(stack, size) + * + * Aligns the stack to a 'size' boundary + * + * @param stack Stack + * @param size New size boundary + */ + +/** + * @def cc6_PUSH(stack, size, type) + * + * Allocates 'size' elements of type 'type' on the stack + * + * @param stack Stack + * @param size Number of elements + * @param type Type of element + */ + +/** + * @def cc6_VARDECL(var) + * + * Declare variable on stack + * + * @param var Variable to declare + */ + +/** + * @def cc6_ALLOC(var, size, type) + * + * Allocate 'size' elements of 'type' on stack + * + * @param var Name of variable to allocate + * @param size Number of elements + * @param type Type of element + */ + + +#if defined(VAR_ARRAYS) + +#define cc6_VARDECL(type, var) +#define cc6_ALLOC(var, size, type) type var[size] +#define cc6_SAVE_STACK +#define cc6_RESTORE_STACK +#define cc6_ALLOC_STACK + +#elif defined(USE_ALLOCA) + +#define cc6_VARDECL(type, var) type *var +#define cc6_ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size))) +#define cc6_SAVE_STACK +#define cc6_RESTORE_STACK +#define cc6_ALLOC_STACK + +#else + +#ifdef CELT_C +char *cc6_global_stack=0; +#else +extern char *cc6_global_stack; +#endif /*CELT_C*/ + +#ifdef ENABLE_VALGRIND + +#include + +#ifdef CELT_C +char *cc6_global_stack_top=0; +#else +extern char *cc6_global_stack_top; +#endif /*CELT_C*/ + +#define cc6_ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) +#define cc6_PUSH(stack, size, type) (VALGRIND_MAKE_MEM_NOACCESS(stack, cc6_global_stack_top-stack),cc6_ALIGN((stack),sizeof(type)/sizeof(char)),VALGRIND_MAKE_MEM_UNDEFINED(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=(2*(size)*sizeof(type)/sizeof(char)),(type*)((stack)-(2*(size)*sizeof(type)/sizeof(char)))) +#define cc6_RESTORE_STACK ((cc6_global_stack = _saved_stack),VALGRIND_MAKE_MEM_NOACCESS(cc6_global_stack, cc6_global_stack_top-cc6_global_stack)) +#define cc6_ALLOC_STACK ((cc6_global_stack = (cc6_global_stack==0) ? ((cc6_global_stack_top=cc6_celt_alloc_scratch(cc6_GLOBAL_STACK_SIZE*2)+(cc6_GLOBAL_STACK_SIZE*2))-(cc6_GLOBAL_STACK_SIZE*2)) : cc6_global_stack),VALGRIND_MAKE_MEM_NOACCESS(cc6_global_stack, cc6_global_stack_top-cc6_global_stack)) + +#else + +#define cc6_ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) +#define cc6_PUSH(stack, size, type) (cc6_ALIGN((stack),sizeof(type)/sizeof(char)),(stack)+=(size)*(sizeof(type)/sizeof(char)),(type*)((stack)-(size)*(sizeof(type)/sizeof(char)))) +#define cc6_RESTORE_STACK (cc6_global_stack = _saved_stack) +#define cc6_ALLOC_STACK (cc6_global_stack = (cc6_global_stack==0) ? cc6_celt_alloc_scratch(cc6_GLOBAL_STACK_SIZE) : cc6_global_stack) + +#endif /*ENABLE_VALGRIND*/ + +#include "os_support.h" +#define cc6_VARDECL(type, var) type *var +#define cc6_ALLOC(var, size, type) var = cc6_PUSH(cc6_global_stack, size, type) +#define cc6_SAVE_STACK char *_saved_stack = cc6_global_stack; + +#endif /*VAR_ARRAYS*/ + + +#endif /*cc6_STACK_ALLOC_H*/ diff --git a/libs/celt/cc6_vq.h b/libs/celt/cc6_vq.h index 000aa56f..45932113 100755 --- a/libs/celt/cc6_vq.h +++ b/libs/celt/cc6_vq.h @@ -33,8 +33,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef VQ_H -#define VQ_H +#ifndef cc6_VQ_H +#define cc6_VQ_H #include "cc6_entenc.h" #include "cc6_entdec.h" @@ -50,7 +50,7 @@ * @param p Pitch vector (it is assumed that p+x is a unit vector) * @param enc Entropy encoder state */ -void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, ec_enc *enc); +void cc6_alg_quant(cc6_celt_norm_t *X, cc6_celt_mask_t *W, int N, int K, cc6_celt_norm_t *P, cc6_ec_enc *enc); /** Algebraic pulse decoder * @param x Decoded normalised spectrum (returned) @@ -59,9 +59,9 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, ec_ * @param p Pitch vector (automatically added to x) * @param dec Entropy decoder state */ -void alg_unquant(celt_norm_t *X, int N, int K, celt_norm_t *P, ec_dec *dec); +void cc6_alg_unquant(cc6_celt_norm_t *X, int N, int K, cc6_celt_norm_t *P, cc6_ec_dec *dec); -celt_word16_t renormalise_vector(celt_norm_t *X, celt_word16_t value, int N, int stride); +cc6_celt_word16_t cc6_renormalise_vector(cc6_celt_norm_t *X, cc6_celt_word16_t value, int N, int stride); /** Intra-frame predictor that matches a section of the current frame (at lower * frequencies) to encode the current band. @@ -74,6 +74,6 @@ celt_word16_t renormalise_vector(celt_norm_t *X, celt_word16_t value, int N, int * @param B Stride (number of channels multiplied by the number of MDCTs per frame) * @param N0 Number of valid offsets */ -void intra_fold(const CELTMode *m, celt_norm_t * __restrict x, int N, int *pulses, celt_norm_t *Y, celt_norm_t * __restrict P, int N0, int B); +void cc6_intra_fold(const cc6_CELTMode *m, cc6_celt_norm_t * __restrict x, int N, int *pulses, cc6_celt_norm_t *Y, cc6_celt_norm_t * __restrict P, int N0, int B); -#endif /* VQ_H */ +#endif /* cc6_VQ_H */ diff --git a/src/buffer.cpp b/src/buffer.cpp index a2fef15d..381d8009 100755 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -96,7 +96,7 @@ bool CNetBuf::Get ( CVector& vecbyData ) // in case we have a buffer underrun, invalidate the next 15 blocks // to avoid the unmusical noise resulting from a very short drop // out (note that if you want to change this value, also change - // the value in celt_decode_lost in celt.c) + // the value in cc6_celt_decode_lost in cc6_celt.c) iNumInvalidElements = 10; return false; diff --git a/src/client.cpp b/src/client.cpp index 8b43682a..26053de3 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -52,29 +52,29 @@ CClient::CClient ( const quint16 iPortNumber ) : iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ) { // init audio encoder/decoder (mono) - CeltModeMono = celt_mode_create ( + CeltModeMono = cc6_celt_mode_create ( SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); - CeltEncoderMono = celt_encoder_create ( CeltModeMono ); - CeltDecoderMono = celt_decoder_create ( CeltModeMono ); + CeltEncoderMono = cc6_celt_encoder_create ( CeltModeMono ); + CeltDecoderMono = cc6_celt_decoder_create ( CeltModeMono ); #ifdef USE_LOW_COMPLEXITY_CELT_ENC // set encoder low complexity - celt_encoder_ctl ( CeltEncoderMono, - CELT_SET_COMPLEXITY_REQUEST, celt_int32_t ( 1 ) ); + cc6_celt_encoder_ctl ( CeltEncoderMono, + cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) ); #endif // init audio encoder/decoder (stereo) - CeltModeStereo = celt_mode_create ( + CeltModeStereo = cc6_celt_mode_create ( SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); - CeltEncoderStereo = celt_encoder_create ( CeltModeStereo ); - CeltDecoderStereo = celt_decoder_create ( CeltModeStereo ); + CeltEncoderStereo = cc6_celt_encoder_create ( CeltModeStereo ); + CeltDecoderStereo = cc6_celt_decoder_create ( CeltModeStereo ); #ifdef USE_LOW_COMPLEXITY_CELT_ENC // set encoder low complexity - celt_encoder_ctl ( CeltEncoderStereo, - CELT_SET_COMPLEXITY_REQUEST, celt_int32_t ( 1 ) ); + cc6_celt_encoder_ctl ( CeltEncoderStereo, + cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) ); #endif @@ -861,20 +861,20 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) if ( bUseStereo ) { // encode current audio frame with CELT encoder - celt_encode ( CeltEncoderStereo, - &vecsNetwork[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES], - NULL, - &vecCeltData[0], - iCeltNumCodedBytes ); + cc6_celt_encode ( CeltEncoderStereo, + &vecsNetwork[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES], + NULL, + &vecCeltData[0], + iCeltNumCodedBytes ); } else { // encode current audio frame with CELT encoder - celt_encode ( CeltEncoderMono, - &vecsNetwork[i * SYSTEM_FRAME_SIZE_SAMPLES], - NULL, - &vecCeltData[0], - iCeltNumCodedBytes ); + cc6_celt_encode ( CeltEncoderMono, + &vecsNetwork[i * SYSTEM_FRAME_SIZE_SAMPLES], + NULL, + &vecCeltData[0], + iCeltNumCodedBytes ); } // send coded audio through the network @@ -904,17 +904,17 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) { if ( bUseStereo ) { - celt_decode ( CeltDecoderStereo, - &vecbyNetwData[0], - iCeltNumCodedBytes, - &vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] ); + cc6_celt_decode ( CeltDecoderStereo, + &vecbyNetwData[0], + iCeltNumCodedBytes, + &vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] ); } else { - celt_decode ( CeltDecoderMono, - &vecbyNetwData[0], - iCeltNumCodedBytes, - &vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] ); + cc6_celt_decode ( CeltDecoderMono, + &vecbyNetwData[0], + iCeltNumCodedBytes, + &vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] ); } } else @@ -922,17 +922,17 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) // lost packet if ( bUseStereo ) { - celt_decode ( CeltDecoderStereo, - NULL, - 0, - &vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] ); + cc6_celt_decode ( CeltDecoderStereo, + NULL, + 0, + &vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES] ); } else { - celt_decode ( CeltDecoderMono, - NULL, - 0, - &vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] ); + cc6_celt_decode ( CeltDecoderMono, + NULL, + 0, + &vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES] ); } } } diff --git a/src/client.h b/src/client.h index 0166d3da..ca7d0754 100755 --- a/src/client.h +++ b/src/client.h @@ -265,12 +265,12 @@ protected: CProtocol ConnLessProtocol; // audio encoder/decoder - CELTMode* CeltModeMono; - CELTEncoder* CeltEncoderMono; - CELTDecoder* CeltDecoderMono; - CELTMode* CeltModeStereo; - CELTEncoder* CeltEncoderStereo; - CELTDecoder* CeltDecoderStereo; + cc6_CELTMode* CeltModeMono; + cc6_CELTEncoder* CeltEncoderMono; + cc6_CELTDecoder* CeltDecoderMono; + cc6_CELTMode* CeltModeStereo; + cc6_CELTEncoder* CeltEncoderStereo; + cc6_CELTDecoder* CeltDecoderStereo; int iCeltNumCodedBytes; bool bCeltDoHighQuality; bool bUseStereo; diff --git a/src/server.cpp b/src/server.cpp index f470134b..44979a31 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -194,29 +194,29 @@ CServer::CServer ( const int iNewNumChan, for ( i = 0; i < iNumChannels; i++ ) { // init audio endocder/decoder (mono) - CeltModeMono[i] = celt_mode_create ( + CeltModeMono[i] = cc6_celt_mode_create ( SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); - CeltEncoderMono[i] = celt_encoder_create ( CeltModeMono[i] ); - CeltDecoderMono[i] = celt_decoder_create ( CeltModeMono[i] ); + CeltEncoderMono[i] = cc6_celt_encoder_create ( CeltModeMono[i] ); + CeltDecoderMono[i] = cc6_celt_decoder_create ( CeltModeMono[i] ); #ifdef USE_LOW_COMPLEXITY_CELT_ENC // set encoder low complexity - celt_encoder_ctl ( CeltEncoderMono[i], - CELT_SET_COMPLEXITY_REQUEST, celt_int32_t ( 1 ) ); + cc6_celt_encoder_ctl ( CeltEncoderMono[i], + cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) ); #endif // init audio endocder/decoder (stereo) - CeltModeStereo[i] = celt_mode_create ( + CeltModeStereo[i] = cc6_celt_mode_create ( SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); - CeltEncoderStereo[i] = celt_encoder_create ( CeltModeStereo[i] ); - CeltDecoderStereo[i] = celt_decoder_create ( CeltModeStereo[i] ); + CeltEncoderStereo[i] = cc6_celt_encoder_create ( CeltModeStereo[i] ); + CeltDecoderStereo[i] = cc6_celt_decoder_create ( CeltModeStereo[i] ); #ifdef USE_LOW_COMPLEXITY_CELT_ENC // set encoder low complexity - celt_encoder_ctl ( CeltEncoderStereo[i], - CELT_SET_COMPLEXITY_REQUEST, celt_int32_t ( 1 ) ); + cc6_celt_encoder_ctl ( CeltEncoderStereo[i], + cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) ); #endif } @@ -584,18 +584,18 @@ void CServer::OnTimer() if ( iCurNumAudChan == 1 ) { // mono - celt_decode ( CeltDecoderMono[iCurChanID], - &vecbyData[0], - iCeltNumCodedBytes, - &vecvecsData[i][0] ); + cc6_celt_decode ( CeltDecoderMono[iCurChanID], + &vecbyData[0], + iCeltNumCodedBytes, + &vecvecsData[i][0] ); } else { // stereo - celt_decode ( CeltDecoderStereo[iCurChanID], - &vecbyData[0], - iCeltNumCodedBytes, - &vecvecsData[i][0] ); + cc6_celt_decode ( CeltDecoderStereo[iCurChanID], + &vecbyData[0], + iCeltNumCodedBytes, + &vecvecsData[i][0] ); } } else @@ -604,18 +604,18 @@ void CServer::OnTimer() if ( iCurNumAudChan == 1 ) { // mono - celt_decode ( CeltDecoderMono[iCurChanID], - NULL, - 0, - &vecvecsData[i][0] ); + cc6_celt_decode ( CeltDecoderMono[iCurChanID], + NULL, + 0, + &vecvecsData[i][0] ); } else { // stereo - celt_decode ( CeltDecoderStereo[iCurChanID], - NULL, - 0, - &vecvecsData[i][0] ); + cc6_celt_decode ( CeltDecoderStereo[iCurChanID], + NULL, + 0, + &vecvecsData[i][0] ); } } @@ -669,20 +669,20 @@ void CServer::OnTimer() if ( vecChannels[iCurChanID].GetNumAudioChannels() == 1 ) { // mono - celt_encode ( CeltEncoderMono[iCurChanID], - &vecsSendData[0], - NULL, - &vecCeltData[0], - iCeltNumCodedBytes ); + cc6_celt_encode ( CeltEncoderMono[iCurChanID], + &vecsSendData[0], + NULL, + &vecCeltData[0], + iCeltNumCodedBytes ); } else { // stereo - celt_encode ( CeltEncoderStereo[iCurChanID], - &vecsSendData[0], - NULL, - &vecCeltData[0], - iCeltNumCodedBytes ); + cc6_celt_encode ( CeltEncoderStereo[iCurChanID], + &vecsSendData[0], + NULL, + &vecCeltData[0], + iCeltNumCodedBytes ); } // send separate mix to current clients diff --git a/src/server.h b/src/server.h index d5bf565d..b4e313ac 100755 --- a/src/server.h +++ b/src/server.h @@ -207,12 +207,12 @@ protected: QMutex Mutex; // audio encoder/decoder - CELTMode* CeltModeMono[MAX_NUM_CHANNELS]; - CELTEncoder* CeltEncoderMono[MAX_NUM_CHANNELS]; - CELTDecoder* CeltDecoderMono[MAX_NUM_CHANNELS]; - CELTMode* CeltModeStereo[MAX_NUM_CHANNELS]; - CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS]; - CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS]; + cc6_CELTMode* CeltModeMono[MAX_NUM_CHANNELS]; + cc6_CELTEncoder* CeltEncoderMono[MAX_NUM_CHANNELS]; + cc6_CELTDecoder* CeltDecoderMono[MAX_NUM_CHANNELS]; + cc6_CELTMode* CeltModeStereo[MAX_NUM_CHANNELS]; + cc6_CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS]; + cc6_CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS]; CVector vstrChatColors;