[xiph-cvs] cvs commit: speex/src speexdec.c
Jean-Marc Valin
jm at xiph.org
Thu Dec 19 21:20:28 PST 2002
jm 02/12/20 00:20:28
Modified: . TODO
libspeex modes.c nb_celp.c sb_celp.c vbr.c
src speexdec.c
Log:
Think DTX now works for wideband too
Revision Changes Path
1.18 +2 -5 speex/TODO
Index: TODO
===================================================================
RCS file: /usr/local/cvsroot/speex/TODO,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- TODO 15 Dec 2002 19:32:21 -0000 1.17
+++ TODO 20 Dec 2002 05:20:28 -0000 1.18
@@ -1,8 +1,6 @@
Features
-*Average bit-rate VBR
-Add maximum/minimum bit-rate control for VBR
-Get the encoder to use the rate of packet loss (more conservative pitch gains)
--No transmission when constant noise/silence
Long-term quality improvements
-Improve perceptual enhancement (including wideband)
@@ -15,7 +13,6 @@
*required for 1.0
ideas:
-peelable stream (double codebook, higher bands, stereo)
-DTX in Ogg? (painful)
+Peelable stream (double codebook, higher bands, stereo)
LPC from spectral domain
-Masking curve from Vorbis
+Better psycho-acoustics? Masking curve from Vorbis
<p><p>1.91 +1 -1 speex/libspeex/modes.c
Index: modes.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- modes.c 12 Dec 2002 03:28:49 -0000 1.90
+++ modes.c 20 Dec 2002 05:20:28 -0000 1.91
@@ -446,7 +446,7 @@
0.0, /*preemph*/
{NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
3,
- {0, 1, 2, 3, 4, 5, 5, 6, 6, 7, 7},
+ {1, 1, 2, 3, 4, 5, 5, 6, 6, 7, 7},
{0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},
vbr_hb_thresh,
5
<p><p>1.98 +10 -3 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- nb_celp.c 19 Dec 2002 08:21:11 -0000 1.97
+++ nb_celp.c 20 Dec 2002 05:20:28 -0000 1.98
@@ -297,7 +297,7 @@
lsp_dist=0;
for (i=0;i<st->lpcSize;i++)
lsp_dist += (st->old_lsp[i] - st->lsp[i])*(st->old_lsp[i] - st->lsp[i]);
- printf ("%f\n", lsp_dist);
+ /*printf ("%f\n", lsp_dist);*/
/* Whole frame analysis (open-loop estimation of pitch and excitation gain) */
{
@@ -428,12 +428,15 @@
} else {
/*VAD only case*/
int mode;
- if (st->relative_quality<2)
+ if (st->relative_quality<4)
{
if (st->submodeID>1 || lsp_dist>.05 || !st->dtx_enabled)
mode=1;
else
+ {
mode=0;
+ fprintf (stderr, "tata\n");
+ }
} else
mode=st->submodeSelect;
/*speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);*/
@@ -1101,7 +1104,7 @@
if (st->submodes[st->submodeID] == NULL)
{
float *lpc;
- lpc = PUSH(st->stack,11, float);
+ lpc = PUSH(stack,11, float);
bw_lpc(.93, st->interp_qlpc, lpc, 10);
/*for (i=0;i<st->frameSize;i++)
st->exc[i]=0;*/
@@ -1618,6 +1621,10 @@
st=(DecState*)state;
switch(request)
{
+ case SPEEX_GET_LOW_MODE:
+ case SPEEX_GET_MODE:
+ (*(int*)ptr) = st->submodeID;
+ break;
case SPEEX_SET_ENH:
st->lpc_enh_enabled = *((int*)ptr);
break;
<p><p>1.105 +64 -12 speex/libspeex/sb_celp.c
Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- sb_celp.c 19 Dec 2002 08:21:11 -0000 1.104
+++ sb_celp.c 20 Dec 2002 05:20:28 -0000 1.105
@@ -278,6 +278,7 @@
float *mem, *innov, *syn_resp;
float *low_pi_gain, *low_exc, *low_innov;
SpeexSBMode *mode;
+ int dtx;
st = (SBEncState*)state;
stack=st->stack;
@@ -305,6 +306,13 @@
speex_encoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc);
speex_encoder_ctl(st->st_low, SPEEX_GET_INNOV, low_innov);
+ speex_encoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, &dtx);
+
+ if (dtx==0)
+ dtx=1;
+ else
+ dtx=0;
+
/* Start encoding the high-band */
for (i=0;i<st->windowSize;i++)
st->buf[i] = st->high[i] * st->window[i];
@@ -343,7 +351,8 @@
st->lsp[i] = acos(st->lsp[i]);
/* VBR code */
- if (st->vbr_enabled || st->vad_enabled){
+ if ((st->vbr_enabled || st->vad_enabled) && !dtx)
+ {
float e_low=0, e_high=0;
float ratio;
if (st->abr_enabled)
@@ -425,10 +434,13 @@
}
speex_bits_pack(bits, 1, 1);
- speex_bits_pack(bits, st->submodeID, SB_SUBMODE_BITS);
+ if (dtx)
+ speex_bits_pack(bits, 0, SB_SUBMODE_BITS);
+ else
+ speex_bits_pack(bits, st->submodeID, SB_SUBMODE_BITS);
/* If null mode (no transmission), just set a couple things to zero*/
- if (st->submodes[st->submodeID] == NULL)
+ if (dtx || st->submodes[st->submodeID] == NULL)
{
for (i=0;i<st->frame_size;i++)
st->exc[i]=st->sw[i]=0;
@@ -786,13 +798,18 @@
speex_free(state);
}
-static void sb_decode_lost(SBDecState *st, float *out, void *stack)
+static void sb_decode_lost(SBDecState *st, float *out, int dtx, void *stack)
{
int i;
float *awk1, *awk2, *awk3;
- for (i=0;i<st->frame_size;i++)
- st->exc[i]*=0.8;
-
+ int saved_modeid=0;
+
+ if (dtx)
+ {
+ saved_modeid=st->submodeID;
+ st->submodeID=1;
+ }
+
st->first=1;
awk1=PUSH(stack, st->lpcSize+1, float);
@@ -821,10 +838,15 @@
/* Final signal synthesis from excitation */
- for (i=0;i<st->frame_size;i++)
- st->exc[i] *= .9;
+ if (!dtx)
+ {
+ for (i=0;i<st->frame_size;i++)
+ st->exc[i] *= .9;
+ }
+
for (i=0;i<st->frame_size;i++)
st->high[i]=st->exc[i];
+
if (st->lpc_enh_enabled)
{
/* Use enhanced LPC filter */
@@ -849,6 +871,11 @@
for (i=0;i<st->full_frame_size;i++)
out[i]=2*(st->y0[i]-st->y1[i]);
+ if (dtx)
+ {
+ st->submodeID=saved_modeid;
+ }
+
return;
}
@@ -861,13 +888,20 @@
void *stack;
float *low_pi_gain, *low_exc, *low_innov;
float *awk1, *awk2, *awk3;
-
+ float dtx;
+
st = (SBDecState*)state;
stack=st->stack;
/* Decode the low-band */
ret = speex_decode(st->st_low, bits, st->x0d);
+ speex_decoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, &dtx);
+ if (dtx==0)
+ dtx=1;
+ else
+ dtx=0;
+
/* If error decoding the narrowband part, propagate error */
if (ret!=0)
{
@@ -876,7 +910,7 @@
if (!bits)
{
- sb_decode_lost(st, out, stack);
+ sb_decode_lost(st, out, 0, stack);
return 0;
}
@@ -893,6 +927,12 @@
st->submodeID = 0;
}
+ if (dtx)
+ {
+ sb_decode_lost(st, out, 1, stack);
+ return 0;
+ }
+
for (i=0;i<st->frame_size;i++)
st->exc[i]=0;
@@ -1097,7 +1137,16 @@
st->submodeSelect = st->submodeID = (*(int*)ptr);
break;
case SPEEX_SET_LOW_MODE:
- speex_encoder_ctl(st->st_low, SPEEX_SET_MODE, ptr);
+ speex_encoder_ctl(st->st_low, SPEEX_SET_LOW_MODE, ptr);
+ break;
+ case SPEEX_SET_DTX:
+ speex_encoder_ctl(st->st_low, SPEEX_SET_DTX, ptr);
+ break;
+ case SPEEX_GET_DTX:
+ speex_encoder_ctl(st->st_low, SPEEX_GET_DTX, ptr);
+ break;
+ case SPEEX_GET_LOW_MODE:
+ speex_encoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, ptr);
break;
case SPEEX_SET_MODE:
speex_encoder_ctl(st, SPEEX_SET_QUALITY, ptr);
@@ -1272,6 +1321,9 @@
st=(SBDecState*)state;
switch(request)
{
+ case SPEEX_GET_LOW_MODE:
+ speex_encoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, ptr);
+ break;
case SPEEX_GET_FRAME_SIZE:
(*(int*)ptr) = st->full_frame_size;
break;
<p><p>1.16 +1 -1 speex/libspeex/vbr.c
Index: vbr.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/vbr.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- vbr.c 12 Dec 2002 07:51:35 -0000 1.15
+++ vbr.c 20 Dec 2002 05:20:28 -0000 1.16
@@ -46,7 +46,7 @@
float vbr_nb_thresh[8][11]={
- {-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /* silence */
+ {-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /* CNG */
{-.01, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7, -0.8, -0.9, -0.9, -1.0}, /* 2 kbps */
{ 8.5, 5.6, 4.7, 4.2, 3.9, 3.5, 3.0, 2.5, 2.0, 1.0, 0.0}, /* 6 kbps */
{11.0, 8.5, 7.5, 6.5, 5.0, 3.9, 3.9, 3.9, 3.5, 3.0, 1.0}, /* 8 kbps */
<p><p>1.62 +2 -1 speex/src/speexdec.c
Index: speexdec.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexdec.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- speexdec.c 15 Dec 2002 19:32:21 -0000 1.61
+++ speexdec.c 20 Dec 2002 05:20:28 -0000 1.62
@@ -48,6 +48,7 @@
#include <io.h>
#include <fcntl.h>
#endif
+#include <math.h>
#ifdef HAVE_SYS_SOUNDCARD_H
#include <sys/soundcard.h>
@@ -551,7 +552,7 @@
}
/*Convert to short and save to output file*/
for (i=0;i<frame_size*channels;i++)
- out[i]=(short)le_short((short)output[i]);
+ out[i]=(short)le_short((short)floor(.5+output[i]));
#if defined WIN32 || defined _WIN32
if (strlen(outFile)==0)
WIN_Play_Samples (out, sizeof(short) * frame_size*channels);
<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