[xiph-cvs] cvs commit: speex/libspeex nb_celp.c sb_celp.c sb_celp.h
Jean-Marc Valin
jm at xiph.org
Thu Dec 12 17:47:24 PST 2002
jm 02/12/12 20:47:24
Modified: libspeex nb_celp.c sb_celp.c sb_celp.h
Log:
VAD should now work on wideband too.
Revision Changes Path
1.92 +1 -1 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- nb_celp.c 12 Dec 2002 07:51:35 -0000 1.91
+++ nb_celp.c 13 Dec 2002 01:47:24 -0000 1.92
@@ -400,7 +400,7 @@
/*VAD only case*/
int mode;
if (st->relative_quality<2.0)
- mode=0;
+ mode=1;
else
mode=st->submodeSelect;
/*speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);*/
<p><p>1.101 +24 -5 speex/libspeex/sb_celp.c
Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- sb_celp.c 12 Dec 2002 03:28:49 -0000 1.100
+++ sb_celp.c 13 Dec 2002 01:47:24 -0000 1.101
@@ -145,7 +145,7 @@
st->bufSize=mode->bufSize;
st->submodes=mode->submodes;
- st->submodeID=mode->defaultSubmode;
+ st->submodeSelect = st->submodeID=mode->defaultSubmode;
{
/* FIXME: Should do this without explicit reference to a mode */
@@ -220,6 +220,7 @@
st->vbr_quality = 8;
st->vbr_enabled = 0;
+ st->vad_enabled = 0;
st->relative_quality=0;
st->complexity=2;
@@ -349,7 +350,7 @@
st->lsp[i] = acos(st->lsp[i]);
/* VBR code */
- if (st->vbr_enabled){
+ if (st->vbr_enabled || st->vad_enabled){
float e_low=0, e_high=0;
float ratio;
for (i=0;i<st->frame_size;i++)
@@ -364,10 +365,11 @@
if (ratio>2)
ratio=2;
/*if (ratio>-2)*/
- st->relative_quality+=1.0*(ratio+2);
+ if (st->vbr_enabled)
{
int modeid;
modeid = mode->nb_modes-1;
+ st->relative_quality+=1.0*(ratio+2);
while (modeid)
{
int v1;
@@ -385,6 +387,16 @@
/*fprintf (stderr, "%f %d\n", low_qual, modeid);*/
speex_encoder_ctl(state, SPEEX_SET_HIGH_MODE, &modeid);
/*fprintf (stderr, "%d %d\n", st->submodeID, modeid);*/
+ } else {
+ /* VAD only */
+ int modeid;
+ if (st->relative_quality<2.0)
+ modeid=1;
+ else
+ modeid=st->submodeSelect;
+ /*speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);*/
+ st->submodeID=modeid;
+
}
/*fprintf (stderr, "%f %f\n", ratio, low_qual);*/
}
@@ -1059,7 +1071,7 @@
(*(int*)ptr) = st->full_frame_size;
break;
case SPEEX_SET_HIGH_MODE:
- st->submodeID = (*(int*)ptr);
+ st->submodeSelect = st->submodeID = (*(int*)ptr);
break;
case SPEEX_SET_LOW_MODE:
speex_encoder_ctl(st->st_low, SPEEX_SET_MODE, ptr);
@@ -1074,6 +1086,13 @@
case SPEEX_GET_VBR:
(*(int*)ptr) = st->vbr_enabled;
break;
+ case SPEEX_SET_VAD:
+ st->vad_enabled = (*(int*)ptr);
+ speex_encoder_ctl(st->st_low, SPEEX_SET_VAD, ptr);
+ break;
+ case SPEEX_GET_VAD:
+ (*(int*)ptr) = st->vad_enabled;
+ break;
case SPEEX_SET_VBR_QUALITY:
{
int q;
@@ -1096,7 +1115,7 @@
quality = 0;
if (quality > 10)
quality = 10;
- st->submodeID = ((SpeexSBMode*)(st->mode->mode))->quality_map[quality];
+ st->submodeSelect = st->submodeID = ((SpeexSBMode*)(st->mode->mode))->quality_map[quality];
nb_qual = ((SpeexSBMode*)(st->mode->mode))->low_quality_map[quality];
speex_encoder_ctl(st->st_low, SPEEX_SET_MODE, &nb_qual);
}
<p><p>1.34 +2 -0 speex/libspeex/sb_celp.h
Index: sb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- sb_celp.h 12 Dec 2002 03:28:49 -0000 1.33
+++ sb_celp.h 13 Dec 2002 01:47:24 -0000 1.34
@@ -92,10 +92,12 @@
float vbr_quality; /**< Quality setting for VBR encoding */
int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */
+ int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */
float relative_quality;
SpeexSubmode **submodes;
int submodeID;
+ int submodeSelect;
int complexity;
int sampling_rate;
<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