diff options
author | Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> | 2008-07-21 07:14:31 +0400 |
---|---|---|
committer | Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> | 2008-07-21 07:14:31 +0400 |
commit | 6361ad8d415a637ac3581390423519bb9f6d254d (patch) | |
tree | 272ff25d4feaca9980d7cdbe0746d109215334fd | |
parent | df38f2bf013670903fa273153c1beabb5d27a6f9 (diff) |
Simplified the folding normalisation by creating renormalise_vector().
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | libcelt/celt.c | 4 | ||||
-rwxr-xr-x | libcelt/match-test.sh | 4 | ||||
-rw-r--r-- | libcelt/vq.c | 61 |
4 files changed, 37 insertions, 36 deletions
diff --git a/configure.ac b/configure.ac index e2387fd..2ca8ba3 100644 --- a/configure.ac +++ b/configure.ac @@ -5,8 +5,8 @@ AC_INIT(libcelt/arch.h) AM_CONFIG_HEADER([config.h]) CELT_MAJOR_VERSION=0 -CELT_MINOR_VERSION=3 -CELT_MICRO_VERSION=2 +CELT_MINOR_VERSION=4 +CELT_MICRO_VERSION=0 CELT_EXTRA_VERSION= CELT_VERSION=$CELT_MAJOR_VERSION.$CELT_MINOR_VERSION.$CELT_MICRO_VERSION$CELT_EXTRA_VERSION diff --git a/libcelt/celt.c b/libcelt/celt.c index b320242..175922c 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -565,8 +565,8 @@ int celt_encode(CELTEncoder * restrict st, celt_int16_t * restrict pcm, unsigned } } #endif - if (ec_enc_tell(&st->enc, 0) < nbCompressedBytes*8 - 7) - celt_warning_int ("many unused bits: ", nbCompressedBytes*8-ec_enc_tell(&st->enc, 0)); + /*if (ec_enc_tell(&st->enc, 0) < nbCompressedBytes*8 - 7) + celt_warning_int ("many unused bits: ", nbCompressedBytes*8-ec_enc_tell(&st->enc, 0));*/ /*printf ("%d\n", ec_enc_tell(&st->enc, 0)-8*nbCompressedBytes);*/ /* Finishing the stream with a 0101... pattern so that the decoder can check is everything's right */ { diff --git a/libcelt/match-test.sh b/libcelt/match-test.sh index d2f18a7..f1714b2 100755 --- a/libcelt/match-test.sh +++ b/libcelt/match-test.sh @@ -9,7 +9,7 @@ outfile=/dev/null if [ -f mono_test_file.sw ]; then echo -n "mono test... " - ./testcelt 44100 1 256 128 32 mono_test_file.sw $outfile + ./testcelt 44100 1 256 32 mono_test_file.sw $outfile if [ $? != 0 ]; then exit 1 fi @@ -19,7 +19,7 @@ fi if [ -f stereo_test_file.sw ]; then echo -n "stereo test... " - ./testcelt 44100 2 256 128 92 stereo_test_file.sw $outfile + ./testcelt 44100 2 256 92 stereo_test_file.sw $outfile if [ $? != 0 ]; then exit 1 fi diff --git a/libcelt/vq.c b/libcelt/vq.c index 6556a63..3e1538c 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -259,21 +259,36 @@ void alg_unquant(celt_norm_t *X, int N, int K, celt_norm_t *P, ec_dec *dec) RESTORE_STACK; } -static celt_word32_t fold(const CELTMode *m, int N, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B) +void renormalise_vector(celt_norm_t *X, celt_word16_t value, int N, int stride) +{ + int i; + celt_word32_t E = EPSILON; + celt_word16_t g; + celt_norm_t *xptr = X; + for (i=0;i<N;i++) + { + E = MAC16_16(E, *xptr, *xptr); + xptr += stride; + } + + g = MULT16_16_Q15(value,celt_rcp(SHL32(celt_sqrt(E),9))); + xptr = X; + for (i=0;i<N;i++) + { + *xptr = PSHR32(MULT16_16(g, *xptr),8); + xptr += stride; + } +} + +static void fold(const CELTMode *m, int N, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B) { int j; - celt_word32_t E; const int C = CHANNELS(m); int id = N0 % (C*B); /* Here, we assume that id will never be greater than N0, i.e. that no band is wider than N0. */ - E = EPSILON; for (j=0;j<C*N;j++) - { P[j] = Y[id++]; - E = MAC16_16(E, P[j],P[j]); - } - return E; } #define KGAIN 6 @@ -283,15 +298,14 @@ void intra_prediction(const CELTMode *m, celt_norm_t * restrict x, celt_mask_t * int j; celt_word16_t s = 1; int sign; - celt_word32_t E; celt_word16_t pred_gain; celt_word32_t xy=0; const int C = CHANNELS(m); - + pred_gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,N),(celt_word32_t)(N+KGAIN*K)); - - E = fold(m, N, Y, P, N0, B); - + + fold(m, N, Y, P, N0, B); + for (j=0;j<C*N;j++) xy = MAC16_16(xy, P[j], x[j]); if (xy<0) @@ -304,17 +318,12 @@ void intra_prediction(const CELTMode *m, celt_norm_t * restrict x, celt_mask_t * } ec_enc_bits(enc,sign,1); - /*pred_gain = pred_gain/sqrt(E);*/ - pred_gain = s*MULT16_16_Q15(pred_gain,celt_rcp(SHL32(celt_sqrt(E),9))); - for (j=0;j<C*N;j++) - P[j] = PSHR32(MULT16_16(pred_gain, P[j]),8); + renormalise_vector(P, s*pred_gain, C*N, 1); } void intra_unquant(const CELTMode *m, celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B, ec_dec *dec) { - int j; celt_word16_t s; - celt_word32_t E; celt_word16_t pred_gain; const int C = CHANNELS(m); @@ -325,25 +334,17 @@ void intra_unquant(const CELTMode *m, celt_norm_t *x, int N, int K, celt_norm_t pred_gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,N),(celt_word32_t)(N+KGAIN*K)); - E = fold(m, N, Y, P, N0, B); + fold(m, N, Y, P, N0, B); - /*pred_gain = pred_gain/sqrt(E);*/ - pred_gain = s*MULT16_16_Q15(pred_gain,celt_rcp(SHL32(celt_sqrt(E),9))); - for (j=0;j<C*N;j++) - P[j] = PSHR32(MULT16_16(pred_gain, P[j]),8); + renormalise_vector(P, s*pred_gain, C*N, 1); } void intra_fold(const CELTMode *m, celt_norm_t *x, int N, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B) { - int j; - celt_word32_t E; - celt_word16_t g; const int C = CHANNELS(m); - E = fold(m, N, Y, P, N0, B); + fold(m, N, Y, P, N0, B); - g = celt_rcp(SHL32(celt_sqrt(E),9)); - for (j=0;j<C*N;j++) - P[j] = PSHR32(MULT16_16(g, P[j]),8); + renormalise_vector(P, Q15ONE, C*N, 1); } |