Skip to content

Commit 08aae93

Browse files
committed
Started the decoder part, I think we now update filters in a better way
to take into account the encoding error. git-svn-id: http://svn.xiph.org/trunk/speex@3112 0101bb08-14d6-0310-b084-bc0e0c8e3800
1 parent cab5ca5 commit 08aae93

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

Diff for: libspeex/cb_search.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int nsf /* number of samples in subframe */
8383
d += target[i]*resp[i];
8484
e += resp[i]*resp[i]+1;
8585
}
86-
g = d/e;
86+
g = d/(e+.1);
8787
score = g*d;
8888
/*printf ("score: %f %f %f %f\n", target[0],d,e,score);*/
8989
if (score >= bscore) {

Diff for: libspeex/speex.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -248,27 +248,32 @@ void encode(EncState *st, float *in, int *outSize, void *bits)
248248
for (i=0;i<st->subframeSize;i++)
249249
exc[i]=0;
250250

251-
252251
/* Compute zero response of A(z/g1) / ( A(z/g2) * Aq(z) ) */
253252
for (i=0;i<st->lpcSize;i++)
254253
st->mem4[i]=st->mem5[i];
255254
syn_filt_mem(exc, st->interp_qlpc, exc, st->subframeSize, st->lpcSize, st->mem4);
256255
for (i=0;i<st->lpcSize;i++)
257256
st->mem4[i]=st->mem5[i];
258257
residue_mem(exc, st->bw_lpc1, res, st->subframeSize, st->lpcSize, st->mem4);
259-
syn_filt_mem(res, st->bw_lpc2, res, st->subframeSize, st->lpcSize, st->mem3);
258+
for (i=0;i<st->lpcSize;i++)
259+
st->mem4[i]=st->mem2[i];
260+
syn_filt_mem(res, st->bw_lpc2, res, st->subframeSize, st->lpcSize, st->mem4);
260261

261262
/* Compute weighted signal */
262-
residue_mem(sp, st->bw_lpc1, sw, st->subframeSize, st->lpcSize, st->mem1);
263-
syn_filt_mem(sw, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem2);
264-
263+
residue(sp, st->bw_lpc1, sw, st->subframeSize, st->lpcSize);
265264
for (i=0;i<st->lpcSize;i++)
266-
st->mem3[i]=sw[st->subframeSize-i-1];
265+
st->mem4[i]=st->mem2[i];
266+
syn_filt_mem(sw, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem4);
267+
268+
/*for (i=0;i<st->lpcSize;i++)
269+
st->mem3[i]=sw[st->subframeSize-i-1];*/
267270

268271
/* Compute target signal */
269272
for (i=0;i<st->subframeSize;i++)
270273
target[i]=sw[i]-res[i];
271274

275+
for (i=0;i<st->subframeSize;i++)
276+
exc[i]=0;
272277
#if 1 /*If set to 0, we compute the excitation directly from the target, i.e. we're cheating */
273278

274279
/* Perform adaptive codebook search (3-tap pitch predictor) */
@@ -277,7 +282,7 @@ void encode(EncState *st, float *in, int *outSize, void *bits)
277282
st->subframeSize);
278283
for (i=0;i<st->subframeSize;i++)
279284
exc[i]=gain[0]*exc[i-pitch]+gain[1]*exc[i-pitch-1]+gain[2]*exc[i-pitch-2];
280-
printf ("3tap pitch = %d, gains = [%f %f %f]\n",pitch, gain[0], gain[1], gain[2]);
285+
printf ("3-tap pitch = %d, gains = [%f %f %f]\n",pitch, gain[0], gain[1], gain[2]);
281286

282287
/* Update target for adaptive codebook contribution */
283288
residue_zero(exc, st->bw_lpc1, res, st->subframeSize, st->lpcSize);
@@ -315,8 +320,6 @@ void encode(EncState *st, float *in, int *outSize, void *bits)
315320
/* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */
316321
residue_mem(sp, st->bw_lpc1, sw, st->subframeSize, st->lpcSize, st->mem1);
317322
syn_filt_mem(sw, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem2);
318-
for (i=0;i<st->lpcSize;i++)
319-
st->mem3[i]=sw[st->subframeSize-i-1];
320323
}
321324

322325
/* Store the LSPs for interpolation in the next frame */

Diff for: libspeex/speex.h

+16
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ typedef struct EncState {
6363
} EncState;
6464

6565
typedef struct DecState {
66+
int first; /* Is this the first frame? */
67+
int frameSize; /* Size of frames */
68+
int subframeSize; /* Size of sub-frames */
69+
int nbSubframes; /* Number of sub-frames */
70+
int windowSize; /* Analysis (LPC) window length */
71+
int lpcSize; /* LPC order */
72+
int bufSize; /* Buffer size */
73+
float *inBuf; /* Input buffer (original signal) */
74+
float *frame; /* Start of original frame */
75+
float *excBuf; /* Excitation buffer */
76+
float *exc; /* Start of excitation frame */
77+
float *qlsp; /* Quantized LSPs for current frame */
78+
float *old_qlsp; /* Quantized LSPs for previous frame */
79+
float *interp_qlsp; /* Interpolated quantized LSPs */
80+
float *interp_qlpc; /* Interpolated quantized LPCs */
81+
6682
} DecState;
6783

6884
/**Initializes encoder state*/

0 commit comments

Comments
 (0)