[xiph-cvs] cvs commit: speex/libspeex cb_search.c ltp.c nb_celp.c nb_celp.h sb_celp.c
Jean-Marc Valin
jm at xiph.org
Wed Oct 23 12:06:20 PDT 2002
jm 02/10/23 15:06:20
Modified: libspeex cb_search.c ltp.c nb_celp.c nb_celp.h sb_celp.c
Log:
fixed a double_codebook bug and prevented pitch from doing weird things
in VBR mode when the last frame was vocoded.
Revision Changes Path
1.74 +6 -5 speex/libspeex/cb_search.c
Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- cb_search.c 23 Oct 2002 16:35:37 -0000 1.73
+++ cb_search.c 23 Oct 2002 19:06:19 -0000 1.74
@@ -68,7 +68,7 @@
{
int i,j,k,m,n,q;
float *resp;
- float *t, *e, *E;
+ float *t, *e, *E, *r2;
/*FIXME: Should make this dynamic*/
float *tmp, *_ot[20], *_nt[20];
float *ndist, *odist;
@@ -89,8 +89,6 @@
oind=_oind;
nind=_nind;
N=complexity;
- if (N<1)
- N=1;
if (N>10)
N=10;
@@ -103,6 +101,7 @@
resp = PUSH(stack, shape_cb_size*subvect_size);
t = PUSH(stack, nsf);
e = PUSH(stack, nsf);
+ r2 = PUSH(stack, nsf);
E = PUSH(stack, shape_cb_size);
/*FIXME: This breaks if sizeof(int) != sizeof(float) */
ind = (int*)PUSH(stack, nb_subvect);
@@ -222,6 +221,8 @@
{
/*previous target (we don't care what happened before*/
+ for (m=0;m<(i+1)*subvect_size;m++)
+ t[m]=ct[m];
for (m=(i+1)*subvect_size;m<nsf;m++)
t[m]=ct[m];
/* New code: update the rest of the target only if it's worth it */
@@ -313,9 +314,9 @@
exc[j]+=e[j];
/* Update target */
- syn_percep_zero(e, ak, awk1, awk2, r, nsf,p, stack);
+ syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
for (j=0;j<nsf;j++)
- target[j]-=r[j];
+ target[j]-=r2[j];
}
<p><p>1.59 +9 -3 speex/libspeex/ltp.c
Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- ltp.c 23 Oct 2002 16:35:37 -0000 1.58
+++ ltp.c 23 Oct 2002 19:06:19 -0000 1.59
@@ -352,15 +352,21 @@
float *gains;
N=complexity;
- if (N<1)
- N=1;
if (N>10)
N=10;
-
/*FIXME: This breaks if sizeof(int) != sizeof(float) */
nbest=(int*)PUSH(stack, N);
gains = PUSH(stack, N);
params = (ltp_params*) par;
+
+ if (N==0 || end<start)
+ {
+ speex_bits_pack(bits, 0, params->pitch_bits);
+ speex_bits_pack(bits, 0, params->gain_bits);
+ for (i=0;i<nsf;i++)
+ exc[i]=0;
+ return start;
+ }
best_exc=PUSH(stack,nsf);
<p><p>1.67 +15 -3 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- nb_celp.c 23 Oct 2002 16:35:37 -0000 1.66
+++ nb_celp.c 23 Oct 2002 19:06:19 -0000 1.67
@@ -89,6 +89,7 @@
st->submodeID=mode->defaultSubmode;
st->pre_mem=0;
st->pre_mem2=0;
+ st->bounded_pitch = 0;
/* Allocating input buffer */
st->inBuf = speex_alloc(st->bufSize*sizeof(float));
@@ -302,10 +303,13 @@
/*Open-loop pitch*/
- if (SUBMODE(lbr_pitch) != -1 || st->vbr_enabled || SUBMODE(forced_pitch_gain)) {
+ /*if (SUBMODE(lbr_pitch) != -1 || st->vbr_enabled || SUBMODE(forced_pitch_gain))*/
+ if (!st->submodes[st->submodeID] || st->vbr_enabled || SUBMODE(forced_pitch_gain) ||
+ SUBMODE(lbr_pitch) != -1)
+ {
int nol_pitch[4];
float nol_pitch_coef[4];
-
+
bw_lpc(st->gamma1, st->interp_lpc, st->bw_lpc1, st->lpcSize);
bw_lpc(st->gamma2, st->interp_lpc, st->bw_lpc2, st->lpcSize);
@@ -570,7 +574,9 @@
pit_min = st->min_pitch;
pit_max = st->max_pitch;
}
-
+
+ if (st->bounded_pitch && pit_max>offset)
+ pit_max=offset;
pitch = SUBMODE(ltp_quant)(target, sw, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2,
exc, SUBMODE(ltp_params), pit_min, pit_max, ol_pitch_coef,
st->lpcSize, st->subframeSize, bits, stack,
@@ -724,6 +730,10 @@
in[i]=st->frame[i] + st->preemph*in[i-1];
st->pre_mem2=in[st->frameSize-1];
+ if (SUBMODE(innovation_quant) == noise_codebook_quant)
+ st->bounded_pitch = 1;
+ else
+ st->bounded_pitch = 0;
}
@@ -1238,6 +1248,8 @@
break;
case SPEEX_SET_COMPLEXITY:
st->complexity = (*(int*)ptr);
+ if (st->complexity<1)
+ st->complexity=1;
break;
case SPEEX_GET_COMPLEXITY:
(*(int*)ptr) = st->complexity;
<p><p>1.31 +2 -0 speex/libspeex/nb_celp.h
Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- nb_celp.h 11 Oct 2002 03:39:34 -0000 1.30
+++ nb_celp.h 23 Oct 2002 19:06:19 -0000 1.31
@@ -54,6 +54,8 @@
int min_pitch; /**< Minimum pitch value allowed */
int max_pitch; /**< Maximum pitch value allowed */
+ int safe_pitch; /**< Don't use too large values for pitch (in case we lose a packet) */
+ int bounded_pitch; /**< Next frame should not rely on previous frames for pitch */
int ol_pitch; /**< Open-loop pitch */
int ol_voiced; /**< Open-loop voiced/non-voiced decision */
int *pitch;
<p><p>1.79 +2 -0 speex/libspeex/sb_celp.c
Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- sb_celp.c 23 Oct 2002 16:35:37 -0000 1.78
+++ sb_celp.c 23 Oct 2002 19:06:19 -0000 1.79
@@ -1037,6 +1037,8 @@
case SPEEX_SET_COMPLEXITY:
speex_encoder_ctl(st->st_low, SPEEX_SET_COMPLEXITY, ptr);
st->complexity = (*(int*)ptr);
+ if (st->complexity<1)
+ st->complexity=1;
break;
case SPEEX_GET_COMPLEXITY:
(*(int*)ptr) = st->complexity;
<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