Commit 4ff068e6 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Some work on assertions.

parent bfcbd184
......@@ -6,8 +6,9 @@
- Dynamic (intra-frame) bit allocation
- Joint encoding of stereo energy
- Disable intra-frame prediction for more than X pulses
- Remove contraction?
- Simplify search?
- Remove pulse spreading?
- Encode band shape (or just tilt)?
- Make pitch less aggressive instead of using contraction?
- Make energy encoding more robust to losses?
- Revisit pulse spreading
......@@ -108,6 +108,11 @@ AC_ARG_ENABLE(static-modes, [ --enable-static-modes],
AC_DEFINE([STATIC_MODES], , [Static modes])
AC_ARG_ENABLE(assertions, [ --enable-assertions],
[if test "$enableval" = yes; then
if test $ac_cv_c_compiler_gnu = yes ; then
CFLAGS="$CFLAGS -fvisibility=hidden -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-parentheses -Wno-unused-parameter -Wno-sign-compare"
#CFLAGS="$CFLAGS -fvisibility=hidden -W -Wstrict-prototypes -Wmissing-prototypes -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wno-parentheses"
......@@ -93,7 +93,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *
maxval = MAX32(maxval, ABS32(X[j*C+c]));
if (maxval > 0)
int shift = celt_ilog2(maxval)-10;
int shift = celt_zlog2(maxval)-10;
for (j=B*eBands[i];j<B*eBands[i+1];j++)
sum += VSHR32(X[j*C+c],shift)*VSHR32(X[j*C+c],shift);
/* We're adding one here to make damn sure we never end up with a pitch vector that's
......@@ -122,7 +122,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t *freq, celt_norm_t *X,
celt_word16_t g;
int j,shift;
celt_word16_t E;
shift = celt_ilog2(bank[i*C+c])-13;
shift = celt_zlog2(bank[i*C+c])-13;
E = VSHR32(bank[i*C+c], shift);
if (E>0)
g = DIV32_16(QCONST32(1.f,28),MULT16_16_Q14(E,sqrtC_1[C-1]));
......@@ -420,7 +420,7 @@ void stereo_mix(const CELTMode *m, celt_norm_t *X, const celt_ener_t *bank, int
celt_word16_t a1, a2;
celt_word16_t norm;
int shift = celt_ilog2(MAX32(bank[i*C], bank[i*C+1]))-13;
int shift = celt_zlog2(MAX32(bank[i*C], bank[i*C+1]))-13;
left = VSHR32(bank[i*C],shift);
right = VSHR32(bank[i*C+1],shift);
......@@ -53,9 +53,17 @@
#include "entcode.h"
#include "os_support.h"
/** Integer log in base2. Undefined for zero and negative numbers */
static inline celt_int16_t celt_ilog2(celt_word32_t x)
celt_assert2(x>0, "celt_ilog2() only defined for strictly positive numbers");
return EC_ILOG(x)-1;
/** Integer log in base2. Defined for zero, but not for negative numbers */
static inline celt_int16_t celt_zlog2(celt_word32_t x)
return EC_ILOG(x)-1;
......@@ -157,18 +157,14 @@ static inline void _celt_putc(int ch, void *file)
#define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__);
#define celt_assert(cond) {if (!(cond)) {celt_fatal("assertion failed: " #cond);}}
#ifndef RELEASE
static inline void print_vec(float *vec, int len, char *name)
int i;
printf ("%s ", name);
for (i=0;i<len;i++)
printf (" %f", vec[i]);
printf ("\n");
#define celt_assert2(cond, message) {if (!(cond)) {celt_fatal("assertion failed: " #cond "\n" message);}}
#define celt_assert(cond)
#define celt_assert2(cond, message)
#endif /* OS_SUPPORT_H */
......@@ -167,8 +167,7 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *
celt_fatal("Rpp > 1");
celt_assert2(Rpp<=NORM_SCALING, "Rpp should never have a norm greater than unity");
/* We only need to initialise the zero because the first iteration only uses that */
for (i=0;i<N;i++)
......@@ -266,8 +265,7 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *
if (!(nbest[0]->score > -VERY_LARGE32))
celt_fatal("Could not find any match in VQ codebook. Something got corrupted somewhere.");
celt_assert2(nbest[0]->score > -VERY_LARGE32, "Could not find any match in VQ codebook. Something got corrupted somewhere.");
/* Only now that we've made the final choice, update ny/iny and others */
for (k=0;k<Lupdate;k++)
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