diff options
-rw-r--r-- | Speex.kdevelop | 12 | ||||
-rw-r--r-- | doc/manual.lyx | 12 | ||||
-rw-r--r-- | libspeex/filters.c | 2 | ||||
-rw-r--r-- | libspeex/filters.h | 2 | ||||
-rw-r--r-- | libspeex/jitter.c | 8 | ||||
-rw-r--r-- | libspeex/modes.c | 102 | ||||
-rw-r--r-- | libspeex/modes.h | 2 | ||||
-rw-r--r-- | libspeex/nb_celp.c | 8 | ||||
-rw-r--r-- | libspeex/nb_celp.h | 4 | ||||
-rw-r--r-- | libspeex/sb_celp.c | 22 | ||||
-rw-r--r-- | libspeex/sb_celp.h | 4 | ||||
-rw-r--r-- | libspeex/speex.h | 26 | ||||
-rw-r--r-- | libspeex/speex_stereo.h | 10 | ||||
-rw-r--r-- | libspeex/stereo.c | 70 | ||||
-rw-r--r-- | libspeex/testenc.c | 4 | ||||
-rw-r--r-- | libspeex/testenc_uwb.c | 4 | ||||
-rw-r--r-- | libspeex/testenc_wb.c | 4 | ||||
-rw-r--r-- | libspeex/vbr.c | 2 | ||||
-rw-r--r-- | libspeex/vbr.h | 4 | ||||
-rw-r--r-- | src/speexdec.c | 6 | ||||
-rw-r--r-- | src/speexenc.c | 17 |
21 files changed, 254 insertions, 71 deletions
diff --git a/Speex.kdevelop b/Speex.kdevelop index 369fa06..1e8004c 100644 --- a/Speex.kdevelop +++ b/Speex.kdevelop @@ -9,7 +9,7 @@ <ignoreparts/> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description></description> + <description/> <secondaryLanguages/> </general> <kdevautoproject> @@ -57,11 +57,11 @@ <kdevdebugger> <general> <dbgshell>libtool</dbgshell> - <programargs></programargs> - <gdbpath></gdbpath> - <configGdbScript></configGdbScript> - <runShellScript></runShellScript> - <runGdbScript></runGdbScript> + <programargs/> + <gdbpath/> + <configGdbScript/> + <runShellScript/> + <runGdbScript/> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> diff --git a/doc/manual.lyx b/doc/manual.lyx index b518d52..2e41b0b 100644 --- a/doc/manual.lyx +++ b/doc/manual.lyx @@ -5515,7 +5515,7 @@ Ogg Speex files (I prefer to call them just Speex files). One difference with Vorbis however, is that Speex is less tied with Ogg. - Actually, if you just do Voice of IP (VoIP), you don't need Ogg at all. + Actually, if you just do Voice over IP (VoIP), you don't need Ogg at all. \layout Subsection* What's the extension for Speex? @@ -5664,7 +5664,11 @@ What is your (Jean-Marc) relationship with the University of Sherbrooke and how does Speex fit into that? \layout Standard -Currently (2003/03/09), I'm doing a Ph.D. +Currently (2004/04/06), I'm doing my +\emph on +Ph.D. + +\emph default at the University of Sherbrooke in mobile robotics. Although I did my master with the Sherbrooke speech coding group (in speech enhancement, not coding), I am not associated with them anymore. @@ -5672,8 +5676,8 @@ Currently (2003/03/09), I'm doing a Ph.D. \series bold not \series default - be understood that they or the University of Sherbrooke endorse the Speex - project in any way. + be understood that they or the University of Sherbrooke have anything to + do with the Speex project. Furthermore, Speex does not make use of any code or proprietary technology developed in the Sherbrooke speech coding group. diff --git a/libspeex/filters.c b/libspeex/filters.c index 806ed76..0e121dd 100644 --- a/libspeex/filters.c +++ b/libspeex/filters.c @@ -345,7 +345,7 @@ void residue_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_co fir_mem2(y, awk2, y, N, ord, mem); } -void qmf_decomp(const short *xx, const spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack) +void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack) { int i,j,k,M2; spx_word16_t *a; diff --git a/libspeex/filters.h b/libspeex/filters.h index 075515f..df43fc8 100644 --- a/libspeex/filters.h +++ b/libspeex/filters.h @@ -52,7 +52,7 @@ typedef struct CombFilterMem { } CombFilterMem; -void qmf_decomp(const short *xx, const spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack); +void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack); void fir_mem_up(const spx_sig_t *x, const spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack); diff --git a/libspeex/jitter.c b/libspeex/jitter.c index 4cc0c5e..b43453c 100644 --- a/libspeex/jitter.c +++ b/libspeex/jitter.c @@ -130,7 +130,7 @@ void speex_jitter_get(SpeexJitter *jitter, short *out) /* Handle frame interpolation (receiving too fast) */ if (jitter->interp_frame) { - speex_decode(jitter->dec, NULL, out); + speex_decode_int(jitter->dec, NULL, out); jitter->interp_frame = 0; return; } @@ -166,7 +166,7 @@ void speex_jitter_get(SpeexJitter *jitter, short *out) if (jitter->valid_bits) { /* Try decoding last received packet */ - ret = speex_decode(jitter->dec, &jitter->current_packet, out); + ret = speex_decode_int(jitter->dec, &jitter->current_packet, out); if (ret == 0) return; else @@ -174,13 +174,13 @@ void speex_jitter_get(SpeexJitter *jitter, short *out) } /*Packet is late or lost*/ - speex_decode(jitter->dec, NULL, out); + speex_decode_int(jitter->dec, NULL, out); } else { /* Found the right packet */ speex_bits_read_from(&jitter->current_packet, jitter->buf[i], jitter->len[i]); jitter->len[i]=-1; /* Decode packet */ - ret = speex_decode(jitter->dec, &jitter->current_packet, out); + ret = speex_decode_int(jitter->dec, &jitter->current_packet, out); if (ret == 0) { jitter->valid_bits = 1; diff --git a/libspeex/modes.c b/libspeex/modes.c index b2f164c..f844580 100644 --- a/libspeex/modes.c +++ b/libspeex/modes.c @@ -40,11 +40,14 @@ #include "nb_celp.h" #include "vbr.h" #include "misc.h" +#include <math.h> #ifndef NULL #define NULL 0 #endif +#define MAX_IN_SAMPLES 640 + const SpeexMode *speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode}; /* Extern declarations for all codebooks we use here */ @@ -702,21 +705,112 @@ void speex_encoder_destroy(void *state) (*((SpeexMode**)state))->enc_destroy(state); } -int speex_encode(void *state, short *in, SpeexBits *bits) +void speex_decoder_destroy(void *state) +{ + (*((SpeexMode**)state))->dec_destroy(state); +} + + + +int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits) { return (*((SpeexMode**)state))->enc(state, in, bits); } -void speex_decoder_destroy(void *state) +int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out) { - (*((SpeexMode**)state))->dec_destroy(state); + return (*((SpeexMode**)state))->dec(state, bits, out); +} + + + +#ifdef FIXED_POINT + +int speex_encode(void *state, float *in, SpeexBits *bits) +{ + int i; + int N; + short short_in[MAX_IN_SAMPLES]; + speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); + for (i=0;i<N;i++) + { + if (in[i]>32767.f) + short_in[i] = 32767; + else if (in[i]<-32768.f) + short_in[i] = -32768; + else + short_in[i] = (short)floor(.5+in[i]); + } + return (*((SpeexMode**)state))->enc(state, short_in, bits); +} + +int speex_encode_int(void *state, short *in, SpeexBits *bits) +{ + return (*((SpeexMode**)state))->enc(state, in, bits); } -int speex_decode(void *state, SpeexBits *bits, short *out) +int speex_decode(void *state, SpeexBits *bits, float *out) +{ + int i, ret; + int N; + float short_out[MAX_IN_SAMPLES]; + speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); + ret = (*((SpeexMode**)state))->dec(state, bits, short_out); + for (i=0;i<N;i++) + out[i] = short_out[i]; + return ret; +} + +int speex_decode_int(void *state, SpeexBits *bits, short *out) +{ + return (*((SpeexMode**)state))->dec(state, bits, out); +} + +#else + +int speex_encode(void *state, float *in, SpeexBits *bits) +{ + return (*((SpeexMode**)state))->enc(state, in, bits); +} + +int speex_encode_int(void *state, short *in, SpeexBits *bits) +{ + int i; + int N; + float float_in[MAX_IN_SAMPLES]; + speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); + for (i=0;i<N;i++) + float_in[i] = in[i]; + return (*((SpeexMode**)state))->enc(state, float_in, bits); +} + +int speex_decode(void *state, SpeexBits *bits, float *out) { return (*((SpeexMode**)state))->dec(state, bits, out); } +int speex_decode_int(void *state, SpeexBits *bits, short *out) +{ + int i; + int N; + float float_out[MAX_IN_SAMPLES]; + int ret; + speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); + ret = (*((SpeexMode**)state))->dec(state, bits, float_out); + for (i=0;i<N;i++) + { + if (float_out[i]>32767.f) + out[i] = 32767; + else if (float_out[i]<-32768.f) + out[i] = -32768; + else + out[i] = (short)floor(.5+float_out[i]); + } + return ret; +} +#endif + + int speex_encoder_ctl(void *state, int request, void *ptr) { diff --git a/libspeex/modes.h b/libspeex/modes.h index 5cad744..01e2b54 100644 --- a/libspeex/modes.h +++ b/libspeex/modes.h @@ -145,5 +145,7 @@ typedef struct SpeexSBMode { int nb_modes; } SpeexSBMode; +int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits); +int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out); #endif diff --git a/libspeex/nb_celp.c b/libspeex/nb_celp.c index 775bf6d..e8fa4ca 100644 --- a/libspeex/nb_celp.c +++ b/libspeex/nb_celp.c @@ -215,7 +215,7 @@ void nb_encoder_destroy(void *state) speex_free(st); } -int nb_encode(void *state, short *in, SpeexBits *bits) +int nb_encode(void *state, void *vin, SpeexBits *bits) { EncState *st; int i, sub, roots; @@ -231,6 +231,7 @@ int nb_encode(void *state, short *in, SpeexBits *bits) int pitch_half[2]; int ol_pitch_id=0; #endif + spx_word16_t *in = vin; st=(EncState *)state; stack=st->stack; @@ -1024,7 +1025,7 @@ void nb_decoder_destroy(void *state) #define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a)))) -static void nb_decode_lost(DecState *st, short *out, char *stack) +static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack) { int i, sub; spx_coef_t *awk1, *awk2, *awk3; @@ -1137,7 +1138,7 @@ static void nb_decode_lost(DecState *st, short *out, char *stack) st->pitch_gain_buf_idx = 0; } -int nb_decode(void *state, SpeexBits *bits, short *out) +int nb_decode(void *state, SpeexBits *bits, void *vout) { DecState *st; int i, sub; @@ -1157,6 +1158,7 @@ int nb_decode(void *state, SpeexBits *bits, short *out) int pitch_half[2]; int ol_pitch_id=0; #endif + spx_word16_t *out = vout; st=(DecState*)state; stack=st->stack; diff --git a/libspeex/nb_celp.h b/libspeex/nb_celp.h index 155e0ce..583c9e0 100644 --- a/libspeex/nb_celp.h +++ b/libspeex/nb_celp.h @@ -183,7 +183,7 @@ void *nb_encoder_init(const SpeexMode *m); void nb_encoder_destroy(void *state); /** Encodes one frame*/ -int nb_encode(void *state, short *in, SpeexBits *bits); +int nb_encode(void *state, void *in, SpeexBits *bits); /** Initializes decoder state*/ @@ -193,7 +193,7 @@ void *nb_decoder_init(const SpeexMode *m); void nb_decoder_destroy(void *state); /** Decodes one frame*/ -int nb_decode(void *state, SpeexBits *bits, short *out); +int nb_decode(void *state, SpeexBits *bits, void *out); /** ioctl-like function for controlling a narrowband encoder */ int nb_encoder_ctl(void *state, int request, void *ptr); diff --git a/libspeex/sb_celp.c b/libspeex/sb_celp.c index aa75a4a..5e83e7a 100644 --- a/libspeex/sb_celp.c +++ b/libspeex/sb_celp.c @@ -147,7 +147,7 @@ static const float h1[64] = { }; #endif -static void mix_and_saturate(spx_word32_t *y0, spx_word32_t *y1, short *out, int len) +static void mix_and_saturate(spx_word32_t *y0, spx_word32_t *y1, spx_word16_t *out, int len) { int i; for (i=0;i<len;i++) @@ -279,7 +279,7 @@ void sb_encoder_destroy(void *state) } -int sb_encode(void *state, short *in, SpeexBits *bits) +int sb_encode(void *state, void *vin, SpeexBits *bits) { SBEncState *st; int i, roots, sub; @@ -290,13 +290,14 @@ int sb_encode(void *state, short *in, SpeexBits *bits) spx_sig_t *low_exc, *low_innov; SpeexSBMode *mode; int dtx; + spx_word16_t *in = vin; st = (SBEncState*)state; stack=st->stack; mode = (SpeexSBMode*)(st->mode->mode); { - short *low = PUSH(stack, st->frame_size, short); + spx_word16_t *low = PUSH(stack, st->frame_size, spx_word16_t); /* Compute the two sub-bands by filtering with h0 and h1*/ qmf_decomp(in, h0, st->x0d, st->x1d, st->full_frame_size, QMF_ORDER, st->h0_mem, stack); @@ -305,7 +306,7 @@ int sb_encode(void *state, short *in, SpeexBits *bits) low[i] = PSHR(st->x0d[i],SIG_SHIFT); /* Encode the narrowband part*/ - speex_encode(st->st_low, low, bits); + speex_encode_native(st->st_low, low, bits); for (i=0;i<st->frame_size;i++) st->x0d[i] = SHL(low[i],SIG_SHIFT); @@ -777,7 +778,7 @@ void sb_decoder_destroy(void *state) speex_free(state); } -static void sb_decode_lost(SBDecState *st, short *out, int dtx, char *stack) +static void sb_decode_lost(SBDecState *st, spx_word16_t *out, int dtx, char *stack) { int i; spx_coef_t *awk1, *awk2, *awk3; @@ -857,7 +858,7 @@ static void sb_decode_lost(SBDecState *st, short *out, int dtx, char *stack) return; } -int sb_decode(void *state, SpeexBits *bits, short *out) +int sb_decode(void *state, SpeexBits *bits, void *vout) { int i, sub; SBDecState *st; @@ -869,17 +870,18 @@ int sb_decode(void *state, SpeexBits *bits, short *out) spx_coef_t *awk1, *awk2, *awk3; int dtx; SpeexSBMode *mode; - + spx_word16_t *out = vout; + st = (SBDecState*)state; stack=st->stack; mode = (SpeexSBMode*)(st->mode->mode); { - short *low; - low = PUSH(stack, st->frame_size, short); + spx_word16_t *low; + low = PUSH(stack, st->frame_size, spx_word16_t); /* Decode the low-band */ - ret = speex_decode(st->st_low, bits, low); + ret = speex_decode_native(st->st_low, bits, low); for (i=0;i<st->frame_size;i++) st->x0d[i] = low[i]*SIG_SCALING; diff --git a/libspeex/sb_celp.h b/libspeex/sb_celp.h index be30006..705727e 100644 --- a/libspeex/sb_celp.h +++ b/libspeex/sb_celp.h @@ -150,7 +150,7 @@ void *sb_encoder_init(const SpeexMode *m); void sb_encoder_destroy(void *state); /**Encodes one frame*/ -int sb_encode(void *state, short *in, SpeexBits *bits); +int sb_encode(void *state, void *in, SpeexBits *bits); /**Initializes decoder state*/ @@ -160,7 +160,7 @@ void *sb_decoder_init(const SpeexMode *m); void sb_decoder_destroy(void *state); /**Decodes one frame*/ -int sb_decode(void *state, SpeexBits *bits, short *out); +int sb_decode(void *state, SpeexBits *bits, void *out); int sb_encoder_ctl(void *state, int request, void *ptr); diff --git a/libspeex/speex.h b/libspeex/speex.h index 9899c49..610e320 100644 --- a/libspeex/speex.h +++ b/libspeex/speex.h @@ -173,7 +173,7 @@ typedef void *(*encoder_init_func)(const struct SpeexMode *mode); typedef void (*encoder_destroy_func)(void *st); /** Main encoding function */ -typedef int (*encode_func)(void *state, short *in, SpeexBits *bits); +typedef int (*encode_func)(void *state, void *in, SpeexBits *bits); /** Function for controlling the encoder options */ typedef int (*encoder_ctl_func)(void *state, int request, void *ptr); @@ -185,7 +185,7 @@ typedef void *(*decoder_init_func)(const struct SpeexMode *mode); typedef void (*decoder_destroy_func)(void *st); /** Main decoding function */ -typedef int (*decode_func)(void *state, SpeexBits *bits, short *out); +typedef int (*decode_func)(void *state, SpeexBits *bits, void *out); /** Function for controlling the decoder options */ typedef int (*decoder_ctl_func)(void *state, int request, void *ptr); @@ -259,7 +259,15 @@ void speex_encoder_destroy(void *state); @param in Frame that will be encoded with a +-2^16 range @param bits Bit-stream where the data will be written */ -int speex_encode(void *state, short *in, SpeexBits *bits); +int speex_encode(void *state, float *in, SpeexBits *bits); + +/** Uses an existing encoder state to encode one frame of speech pointed to by + "in". The encoded bit-stream is saved in "bits". + @param state Encoder state + @param in Frame that will be encoded with a +-2^16 range + @param bits Bit-stream where the data will be written + */ +int speex_encode_int(void *state, short *in, SpeexBits *bits); /** Used like the ioctl function to control the encoder parameters * @@ -295,7 +303,17 @@ void speex_decoder_destroy(void *state); * @param out Where to write the decoded frame * @return return status (0 for no error, -1 for end of stream, -2 other) */ -int speex_decode(void *state, SpeexBits *bits, short *out); +int speex_decode(void *state, SpeexBits *bits, float *out); + +/** Uses an existing decoder state to decode one frame of speech from + * bit-stream bits. The output speech is saved written to out. + * + * @param state Decoder state + * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost) + * @param out Where to write the decoded frame + * @return return status (0 for no error, -1 for end of stream, -2 other) + */ +int speex_decode_int(void *state, SpeexBits *bits, short *out); /** Used like the ioctl function to control the encoder parameters * diff --git a/libspeex/speex_stereo.h b/libspeex/speex_stereo.h index 07131af..90b4e98 100644 --- a/libspeex/speex_stereo.h +++ b/libspeex/speex_stereo.h @@ -55,10 +55,16 @@ typedef struct SpeexStereoState { #define SPEEX_STEREO_STATE_INIT {1,.5,1,1} /** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ -void speex_encode_stereo(short *data, int frame_size, SpeexBits *bits); +void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits); + +/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ +void speex_encode_stereo_int(short *data, int frame_size, SpeexBits *bits); + +/** Transforms a mono frame into a stereo frame using intensity stereo info */ +void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo); /** Transforms a mono frame into a stereo frame using intensity stereo info */ -void speex_decode_stereo(short *data, int frame_size, SpeexStereoState *stereo); +void speex_decode_stereo_int(short *data, int frame_size, SpeexStereoState *stereo); /** Callback handler for intensity stereo info */ int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data); diff --git a/libspeex/stereo.c b/libspeex/stereo.c index 342ecca..97ec41a 100644 --- a/libspeex/stereo.c +++ b/libspeex/stereo.c @@ -37,7 +37,7 @@ /*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/ static const float e_ratio_quant[4] = {.25f, .315f, .397f, .5f}; -void speex_encode_stereo(short *data, int frame_size, SpeexBits *bits) +void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits) { int i, tmp; float e_left=0, e_right=0, e_tot=0; @@ -74,7 +74,73 @@ void speex_encode_stereo(short *data, int frame_size, SpeexBits *bits) speex_bits_pack(bits, tmp, 2); } -void speex_decode_stereo(short *data, int frame_size, SpeexStereoState *stereo) +void speex_encode_stereo_int(short *data, int frame_size, SpeexBits *bits) +{ + int i, tmp; + float e_left=0, e_right=0, e_tot=0; + float balance, e_ratio; + for (i=0;i<frame_size;i++) + { + e_left += ((float)data[2*i])*data[2*i]; + e_right += ((float)data[2*i+1])*data[2*i+1]; + data[i] = .5*(((float)data[2*i])+data[2*i+1]); + e_tot += ((float)data[i])*data[i]; + } + balance=(e_left+1)/(e_right+1); + e_ratio = e_tot/(1+e_left+e_right); + + /*Quantization*/ + speex_bits_pack(bits, 14, 5); + speex_bits_pack(bits, SPEEX_INBAND_STEREO, 4); + + balance=4*log(balance); + + /*Pack sign*/ + if (balance>0) + speex_bits_pack(bits, 0, 1); + else + speex_bits_pack(bits, 1, 1); + balance=floor(.5+fabs(balance)); + if (balance>30) + balance=31; + + speex_bits_pack(bits, (int)balance, 5); + + /*Quantize energy ratio*/ + tmp=vq_index(&e_ratio, e_ratio_quant, 1, 4); + speex_bits_pack(bits, tmp, 2); +} + +void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo) +{ + float balance, e_ratio; + int i; + float e_tot=0, e_left, e_right, e_sum; + + balance=stereo->balance; + e_ratio=stereo->e_ratio; + for (i=frame_size-1;i>=0;i--) + { + e_tot += ((float)data[i])*data[i]; + } + e_sum=e_tot/e_ratio; + e_left = e_sum*balance / (1+balance); + e_right = e_sum-e_left; + + e_left = sqrt(e_left/(e_tot+.01)); + e_right = sqrt(e_right/(e_tot+.01)); + + for (i=frame_size-1;i>=0;i--) + { + float ftmp=data[i]; + stereo->smooth_left = .98*stereo->smooth_left + .02*e_left; + stereo->smooth_right = .98*stereo->smooth_right + .02*e_right; + data[2*i] = stereo->smooth_left*ftmp; + data[2*i+1] = stereo->smooth_right*ftmp; + } +} + +void speex_decode_stereo_int(short *data, int frame_size, SpeexStereoState *stereo) { float balance, e_ratio; int i; diff --git a/libspeex/testenc.c b/libspeex/testenc.c index e0c2a26..4bcc20f 100644 --- a/libspeex/testenc.c +++ b/libspeex/testenc.c @@ -82,7 +82,7 @@ int main(int argc, char **argv) in_float[i]=in_short[i]; speex_bits_reset(&bits); - speex_encode(st, in_short, &bits); + speex_encode_int(st, in_short, &bits); nbBits = speex_bits_write(&bits, cbits, 200); bitCount+=bits.nbBits; @@ -90,7 +90,7 @@ int main(int argc, char **argv) fwrite(cbits, 1, nbBits, fbits); speex_bits_rewind(&bits); - speex_decode(dec, &bits, out_short); + speex_decode_int(dec, &bits, out_short); speex_bits_reset(&bits); fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout); diff --git a/libspeex/testenc_uwb.c b/libspeex/testenc_uwb.c index 5115516..fdb6636 100644 --- a/libspeex/testenc_uwb.c +++ b/libspeex/testenc_uwb.c @@ -82,7 +82,7 @@ int main(int argc, char **argv) in_float[i]=in_short[i]; speex_bits_reset(&bits); - speex_encode(st, in_short, &bits); + speex_encode_int(st, in_short, &bits); nbBits = speex_bits_write(&bits, cbits, 200); bitCount+=bits.nbBits; @@ -90,7 +90,7 @@ int main(int argc, char **argv) fwrite(cbits, 1, nbBits, fbits); speex_bits_rewind(&bits); - speex_decode(dec, &bits, out_short); + speex_decode_int(dec, &bits, out_short); speex_bits_reset(&bits); fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout); diff --git a/libspeex/testenc_wb.c b/libspeex/testenc_wb.c index 1d94c65..d1fca50 100644 --- a/libspeex/testenc_wb.c +++ b/libspeex/testenc_wb.c @@ -87,7 +87,7 @@ int main(int argc, char **argv) in_float[i]=in_short[i]; speex_bits_reset(&bits); - speex_encode(st, in_short, &bits); + speex_encode_int(st, in_short, &bits); nbBits = speex_bits_write(&bits, cbits, 200); bitCount+=bits.nbBits; @@ -95,7 +95,7 @@ int main(int argc, char **argv) fwrite(cbits, 1, nbBits, fbits); speex_bits_rewind(&bits); - speex_decode(dec, &bits, out_short); + speex_decode_int(dec, &bits, out_short); speex_bits_reset(&bits); fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout); diff --git a/libspeex/vbr.c b/libspeex/vbr.c index e5b424e..5496519 100644 --- a/libspeex/vbr.c +++ b/libspeex/vbr.c @@ -116,7 +116,7 @@ void vbr_init(VBRState *vbr) */ -float vbr_analysis(VBRState *vbr, short *sig, int len, int pitch, float pitch_coef) +float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef) { int i; float ener=0, ener1=0, ener2=0; diff --git a/libspeex/vbr.h b/libspeex/vbr.h index 17a4c25..c49e56d 100644 --- a/libspeex/vbr.h +++ b/libspeex/vbr.h @@ -36,6 +36,8 @@ #ifndef VBR_H #define VBR_H +#include "misc.h" + #define VBR_MEMORY_SIZE 5 extern float vbr_nb_thresh[9][11]; @@ -59,7 +61,7 @@ typedef struct VBRState { void vbr_init(VBRState *vbr); -float vbr_analysis(VBRState *vbr, short *sig, int len, int pitch, float pitch_coef); +float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef); void vbr_destroy(VBRState *vbr); diff --git a/src/speexdec.c b/src/speexdec.c index aaaada3..b11d548 100644 --- a/src/speexdec.c +++ b/src/speexdec.c @@ -624,9 +624,9 @@ int main(int argc, char **argv) int ret; /*Decode frame*/ if (!lost) - ret = speex_decode(st, &bits, output); + ret = speex_decode_int(st, &bits, output); else - ret = speex_decode(st, NULL, output); + ret = speex_decode_int(st, NULL, output); /*for (i=0;i<frame_size*channels;i++) printf ("%d\n", (int)output[i]);*/ @@ -644,7 +644,7 @@ int main(int argc, char **argv) break; } if (channels==2) - speex_decode_stereo(output, frame_size, &stereo); + speex_decode_stereo_int(output, frame_size, &stereo); if (print_bitrate) { int tmp; diff --git a/src/speexenc.c b/src/speexenc.c index 9016891..b933a2e 100644 --- a/src/speexenc.c +++ b/src/speexenc.c @@ -573,19 +573,6 @@ int main(int argc, char **argv) ogg_stream_packetin(&os, &op); free(op.packet); - while((result = ogg_stream_flush(&os, &og))) - { - if(!result) break; - ret = oe_write_page(&og, fout); - if(ret != og.header_len + og.body_len) - { - fprintf (stderr,"Error: failed writing header to output stream\n"); - exit(1); - } - else - bytes_written += ret; - } - op.packet = (unsigned char *)comments; op.bytes = comments_length; op.b_o_s = 0; @@ -674,12 +661,12 @@ int main(int argc, char **argv) id++; /*Encode current frame*/ if (chan==2) - speex_encode_stereo(input, frame_size, &bits); + speex_encode_stereo_int(input, frame_size, &bits); if (preprocess) speex_preprocess(preprocess, input, NULL); - speex_encode(st, input, &bits); + speex_encode_int(st, input, &bits); if (print_bitrate) { int tmp; |