Skip to content

Commit 39cb42e

Browse files
committed
Added speex_ctl call to set codec parameters (e.g. enable/disable
post-filter) git-svn-id: http://svn.xiph.org/trunk/speex@3339 0101bb08-14d6-0310-b084-bc0e0c8e3800
1 parent 7f96fad commit 39cb42e

File tree

13 files changed

+98
-8
lines changed

13 files changed

+98
-8
lines changed

OPTIMIZE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Narrowband:
2+
3+
- pitch_gain_search_3tap calls syn_filt_zero more times than it should (we're
4+
computing some things twice)
5+
6+
Wideband
7+
8+
- All narrowband optimizations apply
9+
- Lots of time spent in the codebook search. We could speed that up by using
10+
a hierarchical codebook

Speex.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Version: %ver
88
Release: %rel
99
Copyright: LGPL
1010
Group: Application/Devel
11-
Source: http://download.sourceforge.net/speex/%{name}-%{ver}.tar.gz
11+
Source: http://prdownloads.sourceforge.net/speex/%{name}-%{ver}.tar.gz
1212
URL: http://speex.sourceforge.net/
1313
Vendor: Speex
1414
Packager: Jean-Marc Valin ([email protected])

Speex.spec.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Version: %ver
88
Release: %rel
99
Copyright: LGPL
1010
Group: Application/Devel
11-
Source: http://download.sourceforge.net/speex/%{name}-%{ver}.tar.gz
11+
Source: http://prdownloads.sourceforge.net/speex/%{name}-%{ver}.tar.gz
1212
URL: http://speex.sourceforge.net/
1313
Vendor: Speex
1414
Packager: Jean-Marc Valin ([email protected])

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ AC_INIT(libspeex/speex.h)
44

55
SPEEX_MAJOR_VERSION=0
66
SPEEX_MINOR_VERSION=1
7-
SPEEX_MICRO_VERSION=1
7+
SPEEX_MICRO_VERSION=2
88
SPEEX_VERSION=$SPEEX_MAJOR_VERSION.$SPEEX_MINOR_VERSION.$SPEEX_MICRO_VERSION
99
SPEEX_BINARY_AGE=0
1010
SPEEX_INTERFACE_AGE=0

libspeex/modes.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ SpeexMode low_wb_mode = {
141141
&nb_decoder_init,
142142
&nb_decoder_destroy,
143143
&nb_decode,
144+
&nb_ctl,
144145
160
145146
};
146147

@@ -152,6 +153,7 @@ SpeexMode speex_nb_mode = {
152153
&nb_decoder_init,
153154
&nb_decoder_destroy,
154155
&nb_decode,
156+
&nb_ctl,
155157
160
156158
};
157159

@@ -186,6 +188,7 @@ SpeexMode speex_wb_mode = {
186188
&sb_decoder_init,
187189
&sb_decoder_destroy,
188190
&sb_decode,
191+
&sb_ctl,
189192
320
190193
};
191194

@@ -221,3 +224,9 @@ void speex_decode(void *state, SpeexBits *bits, float *out, int lost)
221224
{
222225
(*((SpeexMode**)state))->dec(state, bits, out, lost);
223226
}
227+
228+
229+
void speex_ctl(void *state, int request, void *ptr)
230+
{
231+
(*((SpeexMode**)state))->ctl(state, request, ptr);
232+
}

libspeex/nb_celp.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ void *nb_decoder_init(SpeexMode *m)
585585

586586
st->post_filter_func = mode->post_filter_func;
587587
st->post_filter_params = mode->post_filter_params;
588+
st->pf_enabled=0;
588589

589590
st->stack = calloc(10000, sizeof(float));
590591

@@ -717,7 +718,7 @@ void nb_decode(void *state, SpeexBits *bits, float *out, int lost)
717718
for (i=0;i<st->subframeSize;i++)
718719
exc2[i]=exc[i];
719720

720-
if (1)
721+
if (st->pf_enabled)
721722
st->post_filter_func(exc, exc2, st->interp_qlpc, st->lpcSize, st->subframeSize,
722723
pitch, pitch_gain, st->post_filter_params, st->stack);
723724

@@ -744,3 +745,20 @@ void nb_decode(void *state, SpeexBits *bits, float *out, int lost)
744745
st->first = 0;
745746

746747
}
748+
749+
750+
void nb_ctl(void *state, int request, void *ptr)
751+
{
752+
switch(request)
753+
{
754+
case SPEEX_SET_PF:
755+
{
756+
DecState *st;
757+
st=state;
758+
st->pf_enabled = *((int*)ptr);
759+
}
760+
break;
761+
default:
762+
fprintf(stderr, "Unknown nb_ctl request: %d\n", request);
763+
}
764+
}

libspeex/nb_celp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ typedef struct DecState {
122122
void *innovation_params;
123123
nb_post_filter_func post_filter_func;
124124
void *post_filter_params;
125-
125+
int pf_enabled;
126126
} DecState;
127127

128128
/**Initializes encoder state*/
@@ -144,6 +144,7 @@ void nb_decoder_destroy(void *state);
144144
/**Decodes one frame*/
145145
void nb_decode(void *state, SpeexBits *bits, float *out, int lost);
146146

147+
void nb_ctl(void *state, int request, void *ptr);
147148

148149

149150
#endif

libspeex/sb_celp.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,3 +867,21 @@ void sb_decode(void *state, SpeexBits *bits, float *out, int lost)
867867
st->first=0;
868868

869869
}
870+
871+
872+
void sb_ctl(void *state, int request, void *ptr)
873+
{
874+
switch(request)
875+
{
876+
case SPEEX_SET_PF:
877+
{
878+
SBDecState *st;
879+
st=state;
880+
speex_ctl(st->st_low, request, ptr);
881+
}
882+
break;
883+
default:
884+
fprintf(stderr, "Unknown nb_ctl request: %d\n", request);
885+
}
886+
887+
}

libspeex/sb_celp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,7 @@ void sb_decoder_destroy(void *state);
139139
/**Decodes one frame*/
140140
void sb_decode(void *state, SpeexBits *bits, float *out, int lost);
141141

142+
void sb_ctl(void *state, int request, void *ptr);
143+
142144

143145
#endif

libspeex/speex.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
extern "C" {
2929
#endif
3030

31+
#define SPEEX_SET_PF 0
32+
3133
struct SpeexMode;
3234

3335
typedef void *(*encoder_init_func)(struct SpeexMode *mode);
@@ -36,6 +38,7 @@ typedef void (*encode_func)(void *state, float *in, SpeexBits *bits);
3638
typedef void *(*decoder_init_func)(struct SpeexMode *mode);
3739
typedef void (*decoder_destroy_func)(void *st);
3840
typedef void (*decode_func)(void *state, SpeexBits *bits, float *out, int lost);
41+
typedef void (*ctl_func)(void *state, int request, void *ptr);
3942

4043
/** Struct defining a Speex mode */
4144
typedef struct SpeexMode {
@@ -60,6 +63,9 @@ typedef struct SpeexMode {
6063
/** Pointer to frame decoding function */
6164
decode_func dec;
6265

66+
/** ioctl-like requests for codec state */
67+
ctl_func ctl;
68+
6369
/** Frame size used for the current mode */
6470
int frameSize;
6571

@@ -91,6 +97,9 @@ void speex_decoder_destroy(void *state);
9197
bits. The output speech is saved written to out. */
9298
void speex_decode(void *state, SpeexBits *bits, float *out, int lost);
9399

100+
101+
void speex_ctl(void *state, int request, void *ptr);
102+
94103
/** Default narrowband mode */
95104
extern SpeexMode speex_nb_mode;
96105

0 commit comments

Comments
 (0)