[xiph-cvs] cvs commit: speex/libspeex nb_celp.c nb_celp.h
Jean-Marc Valin
jm at xiph.org
Fri Nov 28 21:17:32 PST 2003
jm 03/11/29 00:17:31
Modified: libspeex nb_celp.c nb_celp.h
Log:
fixed-point: pitch gain again
Revision Changes Path
1.159 +21 -20 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -r1.158 -r1.159
--- nb_celp.c 29 Nov 2003 02:45:02 -0000 1.158
+++ nb_celp.c 29 Nov 2003 05:17:31 -0000 1.159
@@ -217,7 +217,7 @@
EncState *st;
int i, sub, roots;
int ol_pitch;
- float ol_pitch_coef;
+ spx_word16_t ol_pitch_coef;
spx_word32_t ol_gain;
spx_sig_t *res, *target;
spx_mem_t *mem;
@@ -345,10 +345,6 @@
&pitch_half[1], nol_pitch_coef, 1, stack);
}
#endif
-
-#ifdef FIXED_POINT
- ol_pitch_coef *= GAIN_SCALING_1;
-#endif
} else {
ol_pitch=0;
ol_pitch_coef=0;
@@ -370,7 +366,7 @@
ol_gain2=ol1;
if (ol2>ol1)
ol_gain2=ol2;
- ol_gain2 = sqrt(2*ol_gain2*(ol1+ol2))*1.3*(1-.5*ol_pitch_coef*ol_pitch_coef);
+ ol_gain2 = sqrt(2*ol_gain2*(ol1+ol2))*1.3*(1-.5*GAIN_SCALING_1*GAIN_SCALING_1*ol_pitch_coef*ol_pitch_coef);
ol_gain=SHR(sqrt(1+ol_gain2/st->frameSize),SIG_SHIFT);
@@ -409,7 +405,7 @@
st->vbr_quality=0;
}
- st->relative_quality = vbr_analysis(st->vbr, in, st->frameSize, ol_pitch, ol_pitch_coef);
+ st->relative_quality = vbr_analysis(st->vbr, in, st->frameSize, ol_pitch, GAIN_SCALING_1*ol_pitch_coef);
/*if (delta_qual<0)*/
/* delta_qual*=.1*(3+st->vbr_quality);*/
if (st->vbr_enabled)
@@ -545,14 +541,14 @@
speex_bits_pack(bits, pitch_half[1]-pitch_half[0]+1, 2);
{
- int quant = (int)floor(.5+7.4*ol_pitch_coef);
+ int quant = (int)floor(.5+7.4*GAIN_SCALING_1*ol_pitch_coef);
if (quant>7)
quant=7;
if (quant<0)
quant=0;
ol_pitch_id=quant;
speex_bits_pack(bits, quant, 3);
- ol_pitch_coef=0.13514*quant;
+ ol_pitch_coef=GAIN_SCALING*0.13514*quant;
}
{
@@ -577,13 +573,13 @@
if (SUBMODE(forced_pitch_gain))
{
int quant;
- quant = (int)floor(.5+15*ol_pitch_coef);
+ quant = (int)floor(.5+15*ol_pitch_coef*GAIN_SCALING_1);
if (quant>15)
quant=15;
if (quant<0)
quant=0;
speex_bits_pack(bits, quant, 4);
- ol_pitch_coef=0.066667*quant;
+ ol_pitch_coef=GAIN_SCALING*0.066667*quant;
}
@@ -761,7 +757,7 @@
if (st->lbr_48k)
{
pitch = SUBMODE(ltp_quant)(target, sw, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2,
- exc, SUBMODE(ltp_params), pit_min, pit_max, GAIN_SCALING*ol_pitch_coef,
+ exc, SUBMODE(ltp_params), pit_min, pit_max, ol_pitch_coef,
st->lpcSize, st->subframeSize, bits, stack,
exc2, syn_resp, st->complexity, ol_pitch_id);
} else {
@@ -769,7 +765,7 @@
/* Perform pitch search */
pitch = SUBMODE(ltp_quant)(target, sw, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2,
- exc, SUBMODE(ltp_params), pit_min, pit_max, GAIN_SCALING*ol_pitch_coef,
+ exc, SUBMODE(ltp_params), pit_min, pit_max, ol_pitch_coef,
st->lpcSize, st->subframeSize, bits, stack,
exc2, syn_resp, st->complexity, 0);
#ifdef EPIC_48K
@@ -1018,14 +1014,15 @@
{
int i, sub;
spx_coef_t *awk1, *awk2, *awk3;
- float pitch_gain, fact, gain_med;
+ float pitch_gain, fact;
+ spx_word16_t gain_med;
fact = exp(-.04*st->count_lost*st->count_lost);
gain_med = median3(st->pitch_gain_buf[0], st->pitch_gain_buf[1], st->pitch_gain_buf[2]);
if (gain_med < st->last_pitch_gain)
st->last_pitch_gain = gain_med;
- pitch_gain = st->last_pitch_gain;
+ pitch_gain = GAIN_SCALING_1*st->last_pitch_gain;
if (pitch_gain>.95)
pitch_gain=.95;
@@ -1127,7 +1124,7 @@
st->first = 0;
st->count_lost++;
- st->pitch_gain_buf[st->pitch_gain_buf_idx++] = pitch_gain;
+ st->pitch_gain_buf[st->pitch_gain_buf_idx++] = GAIN_SCALING*pitch_gain;
if (st->pitch_gain_buf_idx > 2) /* rollover */
st->pitch_gain_buf_idx = 0;
}
@@ -1265,7 +1262,7 @@
st->exc[i]=0;*/
{
float innov_gain=0;
- float pgain=st->last_pitch_gain;
+ float pgain=GAIN_SCALING_1*st->last_pitch_gain;
if (pgain>.6)
pgain=.6;
for (i=0;i<st->frameSize;i++)
@@ -1488,13 +1485,13 @@
{
SUBMODE(ltp_unquant)(exc, pit_min, pit_max, ol_pitch_coef, SUBMODE(ltp_params),
st->subframeSize, &pitch, &pitch_gain[0], bits, stack,
- st->count_lost, offset, GAIN_SCALING*st->last_pitch_gain, ol_pitch_id);
+ st->count_lost, offset, st->last_pitch_gain, ol_pitch_id);
} else {
#endif
SUBMODE(ltp_unquant)(exc, pit_min, pit_max, ol_pitch_coef, SUBMODE(ltp_params),
st->subframeSize, &pitch, &pitch_gain[0], bits, stack,
- st->count_lost, offset, GAIN_SCALING*st->last_pitch_gain, 0);
+ st->count_lost, offset, st->last_pitch_gain, 0);
#ifdef EPIC_48K
}
@@ -1654,7 +1651,11 @@
st->first = 0;
st->count_lost=0;
st->last_pitch = best_pitch;
- st->last_pitch_gain = .25*GAIN_SCALING_1*pitch_average;
+#ifdef FIXED_POINT
+ st->last_pitch_gain = PSHR(pitch_average,2);
+#else
+ st->last_pitch_gain = .25*pitch_average;
+#endif
st->pitch_gain_buf[st->pitch_gain_buf_idx++] = st->last_pitch_gain;
if (st->pitch_gain_buf_idx > 2) /* rollover */
st->pitch_gain_buf_idx = 0;
<p><p>1.62 +2 -2 speex/libspeex/nb_celp.h
Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- nb_celp.h 27 Nov 2003 08:42:07 -0000 1.61
+++ nb_celp.h 29 Nov 2003 05:17:31 -0000 1.62
@@ -156,8 +156,8 @@
spx_mem_t *mem_sp; /**< Filter memory for synthesis signal */
spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
int last_pitch; /**< Pitch of last correctly decoded frame */
- float last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
- float pitch_gain_buf[3]; /**< Pitch gain of last decoded frames */
+ spx_word16_t last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
+ spx_word16_t pitch_gain_buf[3]; /**< Pitch gain of last decoded frames */
int pitch_gain_buf_idx; /**< Tail of the buffer */
int encode_submode;
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list