[xiph-commits] r11729 - in trunk/speex: include/speex libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Wed Aug 2 17:55:57 PDT 2006
Author: jm
Date: 2006-08-02 17:55:52 -0700 (Wed, 02 Aug 2006)
New Revision: 11729
Modified:
trunk/speex/include/speex/speex.h
trunk/speex/libspeex/cb_search.c
trunk/speex/libspeex/nb_celp.c
trunk/speex/libspeex/nb_celp.h
trunk/speex/libspeex/sb_celp.c
Log:
added highpass (enabled by default) to the encoder and decoder
Modified: trunk/speex/include/speex/speex.h
===================================================================
--- trunk/speex/include/speex/speex.h 2006-08-02 14:36:05 UTC (rev 11728)
+++ trunk/speex/include/speex/speex.h 2006-08-03 00:55:52 UTC (rev 11729)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Jean-Marc Valin*/
+/* Copyright (C) 2002-2006 Jean-Marc Valin*/
/**
@file speex.h
@brief Describes the different modes of the codec
@@ -146,7 +146,12 @@
/** Gets the max bit-rate allowed in VBR mode */
#define SPEEX_GET_VBR_MAX_BITRATE 43
-/* Used internally, not to be used in applications */
+/** Turn on/off input/output high-pass filtering */
+#define SPEEX_SET_HIGHPASS 44
+/** Get status of input/output high-pass filtering */
+#define SPEEX_GET_HIGHPASS 45
+
+/* Used internally, NOT TO BE USED in applications */
/** Used internally*/
#define SPEEX_GET_PI_GAIN 100
/** Used internally*/
@@ -157,6 +162,8 @@
#define SPEEX_GET_DTX_STATUS 103
/** Used internally*/
#define SPEEX_SET_INNOVATION_SAVE 104
+/** Used internally*/
+#define SPEEX_SET_WIDEBAND 105
/* Preserving compatibility:*/
Modified: trunk/speex/libspeex/cb_search.c
===================================================================
--- trunk/speex/libspeex/cb_search.c 2006-08-02 14:36:05 UTC (rev 11728)
+++ trunk/speex/libspeex/cb_search.c 2006-08-03 00:55:52 UTC (rev 11729)
@@ -606,7 +606,7 @@
{
int i;
/* FIXME: This is bad, but I don't think the function ever gets called anyway */
- spx_int32_t seed = 0;
+ static spx_int32_t seed = 0;
for (i=0;i<nsf;i++)
exc[i]=SHL32(EXTEND32(speex_rand(1, &seed)),SIG_SHIFT);
}
Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c 2006-08-02 14:36:05 UTC (rev 11728)
+++ trunk/speex/libspeex/nb_celp.c 2006-08-03 00:55:52 UTC (rev 11729)
@@ -205,7 +205,9 @@
st->complexity=2;
st->sampling_rate=8000;
st->dtx_count=0;
-
+ st->isWideband = 0;
+ st->highpass_enabled = 1;
+
#ifdef ENABLE_VALGRIND
VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st));
#endif
@@ -297,6 +299,9 @@
speex_move(st->excBuf, st->excBuf+st->frameSize, (st->max_pitch+2)*sizeof(spx_word16_t));
speex_move(st->swBuf, st->swBuf+st->frameSize, (st->max_pitch+2)*sizeof(spx_word16_t));
+ if (st->highpass_enabled)
+ highpass(in, in, st->frameSize, (st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_INPUT, st->mem_hp);
+
{
VARDECL(spx_word16_t *w_sig);
VARDECL(spx_word16_t *autocorr);
@@ -1102,6 +1107,9 @@
st->voc_m1=st->voc_m2=st->voc_mean=0;
st->voc_offset=0;
st->dtx_enabled=0;
+ st->isWideband = 0;
+ st->highpass_enabled = 1;
+
#ifdef ENABLE_VALGRIND
VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st));
#endif
@@ -1206,6 +1214,7 @@
bw_lpc(QCONST16(.98,15), st->interp_qlpc, st->interp_qlpc, st->lpcSize);
}
+ highpass(out, out, st->frameSize, HIGHPASS_NARROWBAND|HIGHPASS_OUTPUT, st->mem_hp);
st->first = 0;
st->count_lost++;
@@ -1734,6 +1743,8 @@
}
+ if (st->highpass_enabled)
+ highpass(out, out, st->frameSize, (st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_OUTPUT, st->mem_hp);
/*for (i=0;i<st->frameSize;i++)
printf ("%d\n", (int)st->frame[i]);*/
@@ -1913,8 +1924,13 @@
case SPEEX_GET_VBR_MAX_BITRATE:
(*(spx_int32_t*)ptr) = st->vbr_max;
break;
+ case SPEEX_SET_HIGHPASS:
+ st->highpass_enabled = (*(spx_int32_t*)ptr);
+ break;
+ case SPEEX_GET_HIGHPASS:
+ (*(spx_int32_t*)ptr) = st->highpass_enabled;
+ break;
-
/* This is all internal stuff past this point */
case SPEEX_GET_PI_GAIN:
{
@@ -1938,6 +1954,9 @@
case SPEEX_SET_INNOVATION_SAVE:
st->innov_save = ptr;
break;
+ case SPEEX_SET_WIDEBAND:
+ st->isWideband = *((int*)ptr);
+ break;
default:
speex_warning_int("Unknown nb_ctl request: ", request);
return -1;
@@ -2014,6 +2033,13 @@
case SPEEX_GET_LOOKAHEAD:
(*(int*)ptr)=st->subframeSize;
break;
+ case SPEEX_SET_HIGHPASS:
+ st->highpass_enabled = (*(spx_int32_t*)ptr);
+ break;
+ case SPEEX_GET_HIGHPASS:
+ (*(spx_int32_t*)ptr) = st->highpass_enabled;
+ break;
+
case SPEEX_GET_PI_GAIN:
{
int i;
@@ -2036,6 +2062,9 @@
case SPEEX_SET_INNOVATION_SAVE:
st->innov_save = ptr;
break;
+ case SPEEX_SET_WIDEBAND:
+ st->isWideband = *((int*)ptr);
+ break;
default:
speex_warning_int("Unknown nb_ctl request: ", request);
return -1;
Modified: trunk/speex/libspeex/nb_celp.h
===================================================================
--- trunk/speex/libspeex/nb_celp.h 2006-08-02 14:36:05 UTC (rev 11728)
+++ trunk/speex/libspeex/nb_celp.h 2006-08-03 00:55:52 UTC (rev 11729)
@@ -94,6 +94,7 @@
spx_mem_t *mem_sw_whole; /**< Filter memory for perceptually-weighted signal (whole frame)*/
spx_mem_t *mem_exc; /**< Filter memory for excitation (whole frame) */
spx_mem_t *mem_exc2; /**< Filter memory for excitation (whole frame) */
+ spx_mem_t mem_hp[2]; /**< High-pass filter memory */
spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
spx_sig_t *innov_save; /**< If non-NULL, innovation is copied here */
@@ -116,6 +117,8 @@
const SpeexSubmode * const *submodes; /**< Sub-mode data */
int submodeID; /**< Activated sub-mode */
int submodeSelect; /**< Mode chosen by the user (may differ from submodeID if VAD is on) */
+ int isWideband; /**< Is this used as part of the embedded wideband codec */
+ int highpass_enabled; /**< Is the input filter enabled */
} EncState;
/**Structure representing the full state of the narrowband decoder*/
@@ -143,6 +146,7 @@
spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */
spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs */
spx_mem_t *mem_sp; /**< Filter memory for synthesis signal */
+ spx_mem_t mem_hp[2]; /**< High-pass filter memory */
spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
spx_sig_t *innov_save; /** If non-NULL, innovation is copied here */
@@ -168,6 +172,8 @@
int voc_offset;
int dtx_enabled;
+ int isWideband; /**< Is this used as part of the embedded wideband codec */
+ int highpass_enabled; /**< Is the input filter enabled */
} DecState;
/** Initializes encoder state*/
Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c 2006-08-02 14:36:05 UTC (rev 11728)
+++ trunk/speex/libspeex/sb_celp.c 2006-08-03 00:55:52 UTC (rev 11729)
@@ -256,6 +256,8 @@
i=9;
speex_encoder_ctl(st->st_low, SPEEX_SET_QUALITY, &i);
+ i=1;
+ speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, &i);
st->lag_factor = mode->lag_factor;
st->lpc_floor = mode->lpc_floor;
@@ -833,6 +835,7 @@
void *sb_decoder_init(const SpeexMode *m)
{
+ int tmp;
SBDecState *st;
const SpeexSBMode *mode;
st = (SBDecState*)speex_alloc(sizeof(SBDecState));
@@ -859,6 +862,8 @@
st->lpcSize=mode->lpcSize;
speex_decoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE, &st->sampling_rate);
st->sampling_rate*=2;
+ tmp=1;
+ speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, &tmp);
st->submodes=mode->submodes;
st->submodeID=mode->defaultSubmode;
@@ -1448,6 +1453,12 @@
case SPEEX_GET_VBR_MAX_BITRATE:
(*(spx_int32_t*)ptr) = st->vbr_max;
break;
+ case SPEEX_SET_HIGHPASS:
+ speex_encoder_ctl(st->st_low, SPEEX_SET_HIGHPASS, ptr);
+ break;
+ case SPEEX_GET_HIGHPASS:
+ speex_encoder_ctl(st->st_low, SPEEX_GET_HIGHPASS, ptr);
+ break;
/* This is all internal stuff past this point */
@@ -1485,6 +1496,10 @@
case SPEEX_SET_INNOVATION_SAVE:
st->innov_save = ptr;
break;
+ case SPEEX_SET_WIDEBAND:
+ speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);
+ break;
+
default:
speex_warning_int("Unknown nb_ctl request: ", request);
return -1;
@@ -1575,6 +1590,13 @@
speex_decoder_ctl(st->st_low, SPEEX_GET_LOOKAHEAD, ptr);
(*(int*)ptr) = 2*(*(int*)ptr);
break;
+ case SPEEX_SET_HIGHPASS:
+ speex_decoder_ctl(st->st_low, SPEEX_SET_HIGHPASS, ptr);
+ break;
+ case SPEEX_GET_HIGHPASS:
+ speex_decoder_ctl(st->st_low, SPEEX_GET_HIGHPASS, ptr);
+ break;
+
case SPEEX_GET_PI_GAIN:
{
int i;
@@ -1609,6 +1631,10 @@
case SPEEX_SET_INNOVATION_SAVE:
st->innov_save = ptr;
break;
+ case SPEEX_SET_WIDEBAND:
+ speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);
+ break;
+
default:
speex_warning_int("Unknown nb_ctl request: ", request);
return -1;
More information about the commits
mailing list