Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/speexdsp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>2006-11-30 15:23:37 +0300
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>2006-11-30 15:23:37 +0300
commitb544a9278b066617098dd004b66483c94b4f06c3 (patch)
treefd13ed75e41a51abefb3da7668c46768548109e8 /libspeex
parentd901c26e85acd606dee68b82916f98ff06b492da (diff)
Saved innovation from nb to wb is now 16-bit precision.
git-svn-id: http://svn.xiph.org/trunk/speex@12158 0101bb08-14d6-0310-b084-bc0e0c8e3800
Diffstat (limited to 'libspeex')
-rw-r--r--libspeex/fixed_debug.h7
-rw-r--r--libspeex/nb_celp.c16
-rw-r--r--libspeex/nb_celp.h4
-rw-r--r--libspeex/sb_celp.c18
-rw-r--r--libspeex/sb_celp.h8
5 files changed, 28 insertions, 25 deletions
diff --git a/libspeex/fixed_debug.h b/libspeex/fixed_debug.h
index e8179ce..bb8d475 100644
--- a/libspeex/fixed_debug.h
+++ b/libspeex/fixed_debug.h
@@ -169,17 +169,18 @@ static inline int SHL32(long long a, int shift)
//#define SHR(a,shift) ((a) >> (shift))
//#define SHL(a,shift) ((a) << (shift))
-static inline short ADD16(int a, int b)
+#define ADD16(a, b) _ADD16(a, b, __FILE__, __LINE__)
+static inline short _ADD16(int a, int b, char *file, int line)
{
int res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
{
- fprintf (stderr, "ADD16: inputs are not short: %d %d\n", a, b);
+ fprintf (stderr, "ADD16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line);
}
res = a+b;
if (!VERIFY_SHORT(res))
{
- fprintf (stderr, "ADD16: output is not short: %d+%d=%d\n", a,b,res);
+ fprintf (stderr, "ADD16: output is not short: %d+%d=%d in %s: line %d\n", a,b,res, file, line);
}
spx_mips++;
return res;
diff --git a/libspeex/nb_celp.c b/libspeex/nb_celp.c
index 8c65add..ef7b618 100644
--- a/libspeex/nb_celp.c
+++ b/libspeex/nb_celp.c
@@ -720,7 +720,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
int offset;
spx_word16_t *sw;
spx_word16_t *exc;
- spx_sig_t *innov_save = NULL;
+ spx_word16_t *innov_save = NULL;
int pitch;
int response_bound = st->subframeSize;
#ifdef EPIC_48K
@@ -969,7 +969,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
if (innov_save)
{
for (i=0;i<st->subframeSize;i++)
- innov_save[i] = innov[i];
+ innov_save[i] = EXTRACT16(PSHR32(innov[i],SIG_SHIFT));
}
/* In some (rare) modes, we do a second search (more bits) to reduce noise even more */
if (SUBMODE(double_codebook)) {
@@ -989,7 +989,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
if (innov_save)
{
for (i=0;i<st->subframeSize;i++)
- innov_save[i] = ADD32(innov_save[i],innov2[i]);
+ innov_save[i] = ADD16(innov_save[i],EXTRACT16(PSHR32(innov2[i],SIG_SHIFT)));
}
stack = tmp_stack;
}
@@ -1460,7 +1460,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
int offset;
spx_word16_t *exc;
spx_word16_t *sp;
- spx_sig_t *innov_save = NULL;
+ spx_word16_t *innov_save = NULL;
spx_word16_t tmp;
#ifdef EPIC_48K
@@ -1627,7 +1627,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
if (innov_save)
{
for (i=0;i<st->subframeSize;i++)
- innov_save[i] = innov[i];
+ innov_save[i] = EXTRACT16(PSHR32(innov[i], SIG_SHIFT));
}
/* Decode second codebook (only for some modes) */
if (SUBMODE(double_codebook))
@@ -1644,7 +1644,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
if (innov_save)
{
for (i=0;i<st->subframeSize;i++)
- innov_save[i] = ADD32(innov_save[i],innov2[i]);
+ innov_save[i] = ADD16(innov_save[i],EXTRACT16(PSHR32(innov2[i], SIG_SHIFT)));
}
stack = tmp_stack;
}
@@ -1936,7 +1936,7 @@ int nb_encoder_ctl(void *state, int request, void *ptr)
(*(float*)ptr)=st->relative_quality;
break;
case SPEEX_SET_INNOVATION_SAVE:
- st->innov_save = (spx_sig_t*)ptr;
+ st->innov_save = (spx_word16_t*)ptr;
break;
case SPEEX_SET_WIDEBAND:
st->isWideband = *((spx_int32_t*)ptr);
@@ -2044,7 +2044,7 @@ int nb_decoder_ctl(void *state, int request, void *ptr)
*((spx_int32_t*)ptr) = st->dtx_enabled;
break;
case SPEEX_SET_INNOVATION_SAVE:
- st->innov_save = (spx_sig_t*)ptr;
+ st->innov_save = (spx_word16_t*)ptr;
break;
case SPEEX_SET_WIDEBAND:
st->isWideband = *((spx_int32_t*)ptr);
diff --git a/libspeex/nb_celp.h b/libspeex/nb_celp.h
index 9a61d68..92bace9 100644
--- a/libspeex/nb_celp.h
+++ b/libspeex/nb_celp.h
@@ -96,7 +96,7 @@ typedef struct EncState {
spx_mem_t *mem_exc2; /**< Filter memory for excitation (whole frame) */
spx_mem_t mem_hp[2]; /**< High-pass filter memory */
spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
- spx_sig_t *innov_save; /**< If non-NULL, innovation is copied here */
+ spx_word16_t *innov_save; /**< If non-NULL, innovation is copied here */
VBRState *vbr; /**< State of the VBR data */
float vbr_quality; /**< Quality setting for VBR encoding */
@@ -148,7 +148,7 @@ typedef struct DecState {
spx_mem_t *mem_sp; /**< Filter memory for synthesis signal */
spx_mem_t mem_hp[2]; /**< High-pass filter memory */
spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
- spx_sig_t *innov_save; /** If non-NULL, innovation is copied here */
+ spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */
/* This is used in packet loss concealment */
int last_pitch; /**< Pitch of last correctly decoded frame */
diff --git a/libspeex/sb_celp.c b/libspeex/sb_celp.c
index 9a72442..fe4e830 100644
--- a/libspeex/sb_celp.c
+++ b/libspeex/sb_celp.c
@@ -243,7 +243,7 @@ void *sb_encoder_init(const SpeexMode *m)
st->interp_lpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
- st->low_innov = (spx_word32_t*)speex_alloc((st->frame_size)*sizeof(spx_word32_t));
+ st->low_innov = (spx_word16_t*)speex_alloc((st->frame_size)*sizeof(spx_word16_t));
speex_encoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, st->low_innov);
st->innov_save = NULL;
@@ -537,7 +537,8 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
for (sub=0;sub<st->nbSubframes;sub++)
{
- spx_sig_t *exc, *sp, *res, *sw, *innov_save=NULL;
+ spx_sig_t *exc, *sp, *res, *sw;
+ spx_word16_t *innov_save=NULL;
spx_word16_t filter_ratio;
int offset;
spx_word32_t rl, rh;
@@ -595,7 +596,7 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
if (!SUBMODE(innovation_quant)) {/* 1 for spectral folding excitation, 0 for stochastic */
float g;
spx_word16_t el;
- el = compute_rms(st->low_innov+offset, st->subframeSize);
+ el = compute_rms16(st->low_innov+offset, st->subframeSize);
/* Gain to use if we want to use the low-band excitation for high-band */
g=eh/(1.+el);
@@ -818,7 +819,7 @@ void *sb_decoder_init(const SpeexMode *m)
st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
st->mem_sp = (spx_mem_t*)speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t));
- st->low_innov = (spx_word32_t*)speex_alloc((st->frame_size)*sizeof(spx_word32_t));
+ st->low_innov = (spx_word16_t*)speex_alloc((st->frame_size)*sizeof(spx_word16_t));
speex_decoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, st->low_innov);
st->innov_save = NULL;
@@ -1003,7 +1004,8 @@ int sb_decode(void *state, SpeexBits *bits, void *vout)
for (sub=0;sub<st->nbSubframes;sub++)
{
- spx_sig_t *exc, *innov_save=NULL;
+ spx_sig_t *exc;
+ spx_word16_t *innov_save=NULL;
spx_word16_t *sp;
spx_word16_t filter_ratio;
spx_word16_t el=0;
@@ -1077,7 +1079,7 @@ int sb_decode(void *state, SpeexBits *bits, void *vout)
{
float e=tmp*g*mode->folding_gain*st->low_innov[offset+i];
tmp *= -1;
- exc[i] = e;
+ exc[i] = SIG_SCALING*e;
/*float r = speex_rand(g*el,&seed);
exc[i] = .5*(r+tmp2 + e-tmp1);
tmp1 = e;
@@ -1402,7 +1404,7 @@ int sb_encoder_ctl(void *state, int request, void *ptr)
(*(float*)ptr)=st->relative_quality;
break;
case SPEEX_SET_INNOVATION_SAVE:
- st->innov_save = (spx_sig_t*)ptr;
+ st->innov_save = (spx_word16_t*)ptr;
break;
case SPEEX_SET_WIDEBAND:
speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);
@@ -1537,7 +1539,7 @@ int sb_decoder_ctl(void *state, int request, void *ptr)
speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, ptr);
break;
case SPEEX_SET_INNOVATION_SAVE:
- st->innov_save = (spx_sig_t*)ptr;
+ st->innov_save = (spx_word16_t*)ptr;
break;
case SPEEX_SET_WIDEBAND:
speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);
diff --git a/libspeex/sb_celp.h b/libspeex/sb_celp.h
index f215421..a40c98d 100644
--- a/libspeex/sb_celp.h
+++ b/libspeex/sb_celp.h
@@ -86,8 +86,8 @@ typedef struct SBEncState {
spx_mem_t *mem_sp2;
spx_mem_t *mem_sw; /**< Perceptual signal memory */
spx_word32_t *pi_gain;
- spx_sig_t *innov_save; /**< If non-NULL, innovation is copied here */
- spx_sig_t *low_innov; /**< Lower-band innovation is copied here magically */
+ spx_word16_t *innov_save; /**< If non-NULL, innovation is copied here */
+ spx_word16_t *low_innov; /**< Lower-band innovation is copied here magically */
float vbr_quality; /**< Quality setting for VBR encoding */
int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */
@@ -135,8 +135,8 @@ typedef struct SBDecState {
spx_mem_t *mem_sp;
spx_word32_t *pi_gain;
- spx_sig_t *innov_save; /** If non-NULL, innovation is copied here */
- spx_sig_t *low_innov; /** Lower-band innovation is copied here magically */
+ spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */
+ spx_word16_t *low_innov; /** Lower-band innovation is copied here magically */
spx_int32_t seed;