1
0
Fork 0
forked from len0rd/rockbox

First attempt at ifdeffing out as much of the encoder stuff as possible from Speex. Gives a smaller binary and allows me to remove a couple more files from SOURCES.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15394 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thom Johansen 2007-11-01 21:30:51 +00:00
parent 6d88717f69
commit bf1b7f131c
12 changed files with 253 additions and 43 deletions

View file

@ -14,7 +14,7 @@ ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
endif
SPEEXOPTS = -DHAVE_CONFIG_H
SPEEXOPTS = -DHAVE_CONFIG_H -DSPEEX_DISABLE_ENCODER
# We're faster on ARM-targets with -O1 instead of -O2
ifeq ($(CPU),arm)

View file

@ -28,9 +28,6 @@ speex.c
speex_callbacks.c
speex_header.c
stereo.c
vbr.c
vq.c
window.c
#ifdef CPU_COLDFIRE
filters_cf.S
ltp_cf.S

View file

@ -49,6 +49,7 @@
#include "cb_search_bfin.h"
#endif
#ifndef SPEEX_DISABLE_ENCODER
#ifndef OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
{
@ -511,6 +512,7 @@ int update_target
target[j]=SUB16(target[j],PSHR16(r2[j],2));
}
}
#endif
void split_cb_shape_sign_unquant(
@ -571,6 +573,7 @@ spx_int32_t *seed
}
}
#ifndef SPEEX_DISABLE_ENCODER
void noise_codebook_quant(
spx_word16_t target[], /* target vector */
spx_coef_t ak[], /* LPCs for this subframe */
@ -597,6 +600,7 @@ int update_target
for (i=0;i<nsf;i++)
target[i]=0;
}
#endif
void noise_codebook_unquant(

View file

@ -124,6 +124,7 @@ void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len)
}
}
#ifndef SPEEX_DISABLE_ENCODER
void signal_div(const spx_word16_t *x, spx_word16_t *y, spx_word32_t scale, int len)
{
int i;
@ -156,6 +157,7 @@ void signal_div(const spx_word16_t *x, spx_word16_t *y, spx_word32_t scale, int
}
}
}
#endif
#else
@ -320,6 +322,7 @@ spx_word16_t compute_rms16(const spx_word16_t *x, int len)
#ifndef SPEEX_DISABLE_ENCODER
#ifndef OVERRIDE_FILTER_MEM16
void filter_mem16(const spx_word16_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
{
@ -339,6 +342,7 @@ void filter_mem16(const spx_word16_t *x, const spx_coef_t *num, const spx_coef_t
}
}
#endif
#endif
#ifndef OVERRIDE_IIR_MEM16
void iir_mem16(const spx_word16_t *x, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
@ -360,6 +364,7 @@ void iir_mem16(const spx_word16_t *x, const spx_coef_t *den, spx_word16_t *y, in
}
#endif
#ifndef SPEEX_DISABLE_ENCODER
#ifndef OVERRIDE_FIR_MEM16
void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
{
@ -477,6 +482,7 @@ void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_word16_t *y1
y2[k] = EXTRACT16(SATURATE(PSHR32(y2k,15),32767));
}
}
#endif
#ifndef OVERRIDE_QMF_SYNTH
/* Re-synthesised a signal from the QMF low-band and high-band signals */

View file

@ -75,6 +75,7 @@ spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
}
#endif
#ifndef SPEEX_DISABLE_ENCODER
#ifndef OVERRIDE_PITCH_XCORR
#if 0 /* HINT: Enable this for machines with enough registers (i.e. not x86) */
void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
@ -659,6 +660,7 @@ spx_word32_t *cumul_gain
#endif
return pitch;
}
#endif
void pitch_unquant_3tap(
spx_word16_t exc[], /* Input excitation */
@ -760,6 +762,7 @@ int cdbk_offset
}
#ifndef SPEEX_DISABLE_ENCODER
/** Forced pitch delay and gain */
int forced_pitch_quant(
spx_word16_t target[], /* Target vector */
@ -809,6 +812,7 @@ spx_word32_t *cumul_gain
target[i]=EXTRACT16(SATURATE(SUB32(EXTEND32(target[i]),EXTEND32(res[i])),32700));
return start;
}
#endif
/** Unquantize forced pitch delay and gain */
void forced_pitch_unquant(

View file

@ -153,6 +153,7 @@ static const SpeexSubmode nb_submode1 = {
1,
0,
0,
#ifndef SPEEX_DISABLE_ENCODER
/* LSP quantization */
lsp_quant_lbr,
lsp_unquant_lbr,
@ -163,6 +164,18 @@ static const SpeexSubmode nb_submode1 = {
/* No innovation quantization (noise only) */
noise_codebook_quant,
noise_codebook_unquant,
#else
/* LSP quantization */
NULL,
lsp_unquant_lbr,
/* No pitch quantization */
NULL,
forced_pitch_unquant,
NULL,
/* No innovation quantization (noise only) */
NULL,
noise_codebook_unquant,
#endif
NULL,
-1,
43
@ -174,6 +187,7 @@ static const SpeexSubmode nb_submode8 = {
1,
0,
0,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_lbr,
lsp_unquant_lbr,
@ -185,6 +199,19 @@ static const SpeexSubmode nb_submode8 = {
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb_ulbr,
#else
/*LSP quantization*/
NULL,
lsp_unquant_lbr,
/*No pitch quantization*/
NULL,
forced_pitch_unquant,
NULL,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
&split_cb_nb_ulbr,
#endif
QCONST16(.5,15),
79
};
@ -195,6 +222,7 @@ static const SpeexSubmode nb_submode2 = {
0,
0,
0,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_lbr,
lsp_unquant_lbr,
@ -206,6 +234,19 @@ static const SpeexSubmode nb_submode2 = {
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb_vlbr,
#else
/*LSP quantization*/
NULL,
lsp_unquant_lbr,
/*No pitch quantization*/
NULL,
pitch_unquant_3tap,
&ltp_params_vlbr,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
&split_cb_nb_vlbr,
#endif
QCONST16(.6,15),
119
};
@ -216,6 +257,7 @@ static const SpeexSubmode nb_submode3 = {
0,
1,
0,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_lbr,
lsp_unquant_lbr,
@ -227,6 +269,19 @@ static const SpeexSubmode nb_submode3 = {
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb_lbr,
#else
/*LSP quantization*/
NULL,
lsp_unquant_lbr,
/*Pitch quantization*/
NULL,
pitch_unquant_3tap,
&ltp_params_lbr,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
&split_cb_nb_lbr,
#endif
QCONST16(.55,15),
160
};
@ -237,6 +292,7 @@ static const SpeexSubmode nb_submode4 = {
0,
1,
0,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_lbr,
lsp_unquant_lbr,
@ -248,6 +304,19 @@ static const SpeexSubmode nb_submode4 = {
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb_med,
#else
/*LSP quantization*/
NULL,
lsp_unquant_lbr,
/*Pitch quantization*/
NULL,
pitch_unquant_3tap,
&ltp_params_med,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
&split_cb_nb_med,
#endif
QCONST16(.45,15),
220
};
@ -258,6 +327,7 @@ static const SpeexSubmode nb_submode5 = {
0,
3,
0,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_nb,
lsp_unquant_nb,
@ -269,6 +339,19 @@ static const SpeexSubmode nb_submode5 = {
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb,
#else
/*LSP quantization*/
NULL,
lsp_unquant_nb,
/*Pitch quantization*/
NULL,
pitch_unquant_3tap,
&ltp_params_nb,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
&split_cb_nb,
#endif
QCONST16(.3,15),
300
};
@ -279,6 +362,7 @@ static const SpeexSubmode nb_submode6 = {
0,
3,
0,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_nb,
lsp_unquant_nb,
@ -290,6 +374,19 @@ static const SpeexSubmode nb_submode6 = {
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_sb,
#else
/*LSP quantization*/
NULL,
lsp_unquant_nb,
/*Pitch quantization*/
NULL,
pitch_unquant_3tap,
&ltp_params_nb,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
&split_cb_sb,
#endif
QCONST16(.2,15),
364
};
@ -300,6 +397,7 @@ static const SpeexSubmode nb_submode7 = {
0,
3,
1,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_nb,
lsp_unquant_nb,
@ -311,6 +409,19 @@ static const SpeexSubmode nb_submode7 = {
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb,
#else
/*LSP quantization*/
NULL,
lsp_unquant_nb,
/*Pitch quantization*/
NULL,
pitch_unquant_3tap,
&ltp_params_nb,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
&split_cb_nb,
#endif
QCONST16(.1,15),
492
};
@ -347,6 +458,7 @@ const SpeexMode speex_nb_mode = {
"narrowband",
0,
4,
#ifndef SPEEX_DISABLE_ENCODER
&nb_encoder_init,
&nb_encoder_destroy,
&nb_encode,
@ -355,6 +467,16 @@ const SpeexMode speex_nb_mode = {
&nb_decode,
&nb_encoder_ctl,
&nb_decoder_ctl,
#else
NULL,
NULL,
NULL,
&nb_decoder_init,
&nb_decoder_destroy,
&nb_decode,
NULL,
&nb_decoder_ctl,
#endif
};
@ -388,6 +510,7 @@ static const SpeexSubmode nb_48k_submode = {
0,
0,
0,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_48k,
lsp_unquant_48k,
@ -399,6 +522,19 @@ static const SpeexSubmode nb_48k_submode = {
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
&split_cb_nb_48k,
#else
/*LSP quantization*/
NULL,
lsp_unquant_48k,
/*No pitch quantization*/
NULL,
pitch_unquant_3tap,
&ltp_params_48k,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
&split_cb_nb_48k,
#endif
QCONST16(.7,15),
144
};
@ -429,6 +565,7 @@ const SpeexMode speex_nb_48k_mode = {
"narrowband 4.8 kbps",
1000,
4,
#ifndef SPEEX_DISABLE_ENCODER
&nb_encoder_init,
&nb_encoder_destroy,
&nb_encode,
@ -437,6 +574,16 @@ const SpeexMode speex_nb_48k_mode = {
&nb_decode,
&nb_encoder_ctl,
&nb_decoder_ctl,
#else
NULL,
NULL,
NULL,
&nb_decoder_init,
&nb_decoder_destroy,
&nb_decode,
NULL,
&nb_decoder_ctl,
#endif
};

View file

@ -87,8 +87,13 @@ static const SpeexSubmode wb_submode1 = {
1,
0,
/*LSP quantization*/
#ifndef SPEEX_DISABLE_ENCODER
lsp_quant_high,
lsp_unquant_high,
#else
NULL,
lsp_unquant_high,
#endif
/*Pitch quantization*/
NULL,
NULL,
@ -107,6 +112,7 @@ static const SpeexSubmode wb_submode2 = {
0,
1,
0,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_high,
lsp_unquant_high,
@ -117,6 +123,18 @@ static const SpeexSubmode wb_submode2 = {
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
#else
/*LSP quantization*/
NULL,
lsp_unquant_high,
/*Pitch quantization*/
NULL,
NULL,
NULL,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
#endif
#ifdef DISABLE_WIDEBAND
NULL,
#else
@ -132,6 +150,7 @@ static const SpeexSubmode wb_submode3 = {
0,
1,
0,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_high,
lsp_unquant_high,
@ -142,6 +161,18 @@ static const SpeexSubmode wb_submode3 = {
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
#else
/*LSP quantization*/
NULL,
lsp_unquant_high,
/*Pitch quantization*/
NULL,
NULL,
NULL,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
#endif
#ifdef DISABLE_WIDEBAND
NULL,
#else
@ -156,6 +187,7 @@ static const SpeexSubmode wb_submode4 = {
0,
1,
1,
#ifndef SPEEX_DISABLE_ENCODER
/*LSP quantization*/
lsp_quant_high,
lsp_unquant_high,
@ -166,6 +198,18 @@ static const SpeexSubmode wb_submode4 = {
/*Innovation quantization*/
split_cb_search_shape_sign,
split_cb_shape_sign_unquant,
#else
/*LSP quantization*/
NULL,
lsp_unquant_high,
/*Pitch quantization*/
NULL,
NULL,
NULL,
/*Innovation quantization*/
NULL,
split_cb_shape_sign_unquant,
#endif
#ifdef DISABLE_WIDEBAND
NULL,
#else
@ -195,7 +239,11 @@ static const SpeexSBMode sb_wb_mode = {
3,
{1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7},
{1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},
#ifndef SPEEX_DISABLE_ENCODER
vbr_hb_thresh,
#else
NULL,
#endif
5
};
@ -206,6 +254,7 @@ const SpeexMode speex_wb_mode = {
"wideband (sub-band CELP)",
1,
4,
#ifndef SPEEX_DISABLE_ENCODER
&sb_encoder_init,
&sb_encoder_destroy,
&sb_encode,
@ -214,6 +263,16 @@ const SpeexMode speex_wb_mode = {
&sb_decode,
&sb_encoder_ctl,
&sb_decoder_ctl,
#else
NULL,
NULL,
NULL,
&sb_decoder_init,
&sb_decoder_destroy,
&sb_decode,
NULL,
&sb_decoder_ctl,
#endif
};
@ -241,7 +300,11 @@ static const SpeexSBMode sb_uwb_mode = {
1,
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
#ifndef SPEEX_DISABLE_ENCODER
vbr_uhb_thresh,
#else
NULL,
#endif
2
};
@ -276,6 +339,7 @@ const SpeexMode speex_uwb_mode = {
"ultra-wideband (sub-band CELP)",
2,
4,
#ifndef SPEEX_DISABLE_ENCODER
&sb_encoder_init,
&sb_encoder_destroy,
&sb_encode,
@ -284,6 +348,16 @@ const SpeexMode speex_uwb_mode = {
&sb_decode,
&sb_encoder_ctl,
&sb_decoder_ctl,
#else
NULL,
NULL,
NULL,
&sb_decoder_init,
&sb_decoder_destroy,
&sb_decode,
NULL,
&sb_decoder_ctl,
#endif
};
/* We have defined speex_lib_get_mode() as a macro in speex.h */

View file

@ -109,8 +109,8 @@ const float exc_gain_quant_scal1[2]={0.70469f, 1.05127f};
#define sqr(x) ((x)*(x))
extern const spx_word16_t lpc_window[];
#if 0
void *nb_encoder_init(const speexmode *m)
#ifndef SPEEX_DISABLE_ENCODER
void *nb_encoder_init(const SpeexMode *m)
{
EncState *st;
const SpeexNBMode *mode;
@ -1024,18 +1024,6 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
return 1;
}
#else
void *nb_encoder_init(const SpeexMode *m)
{
return NULL;
}
void nb_encoder_destroy(void *state)
{
}
int nb_encode(void *state, void *vin, SpeexBits *bits)
{
return 1;
}
#endif
static DecState global_decstate IBSS_ATTR;
@ -1763,7 +1751,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
return 0;
}
#if 0
#ifndef SPEEX_DISABLE_ENCODER
int nb_encoder_ctl(void *state, int request, void *ptr)
{
EncState *st;
@ -1959,11 +1947,6 @@ int nb_encoder_ctl(void *state, int request, void *ptr)
}
return 0;
}
#else
int nb_encoder_ctl(void *state, int request, void *ptr)
{
return 0;
}
#endif
int nb_decoder_ctl(void *state, int request, void *ptr)

View file

@ -68,6 +68,7 @@
#endif
#ifndef SPEEX_DISABLE_ENCODER
static void compute_quant_weights(spx_lsp_t *qlsp, spx_word16_t *quant_weight, int order)
{
int i;
@ -209,6 +210,7 @@ void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
for (i=0;i<order;i++)
qlsp[i]=lsp[i]-qlsp[i];
}
#endif
void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits)
{
@ -239,6 +241,7 @@ void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits)
}
#ifndef SPEEX_DISABLE_ENCODER
void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
{
int i;
@ -279,6 +282,7 @@ void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
for (i=0;i<order;i++)
qlsp[i]=lsp[i]-qlsp[i];
}
#endif
void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits)
{
@ -316,6 +320,7 @@ extern const signed char high_lsp_cdbk[];
extern const signed char high_lsp_cdbk2[];
#ifndef SPEEX_DISABLE_ENCODER
void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
{
int i;
@ -362,6 +367,7 @@ void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
for (i=0;i<order;i++)
qlsp[i]=lsp[i]-qlsp[i];
}
#endif
void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits)
{
@ -389,6 +395,7 @@ void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits)
extern const signed char cdbk_lsp_vlbr[5120];
extern const signed char cdbk_lsp2_vlbr[160];
#ifndef SPEEX_DISABLE_ENCODER
void lsp_quant_48k(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
{
int i;
@ -427,6 +434,7 @@ void lsp_quant_48k(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
for (i=0;i<order;i++)
qlsp[i]=lsp[i]-qlsp[i];
}
#endif
void lsp_unquant_48k(spx_lsp_t *lsp, int order, SpeexBits *bits)
{

View file

@ -185,7 +185,7 @@ static const float h0[64] = {
extern const spx_word16_t lpc_window[];
#if 0
#ifndef SPEEX_DISABLE_ENCODER
void *sb_encoder_init(const SpeexMode *m)
{
int i;
@ -751,18 +751,6 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
return 1;
}
#else
void *sb_encoder_init(const SpeexMode *m)
{
return NULL;
}
void sb_encoder_destroy(void *state)
{
}
int sb_encode(void *state, void *vin, SpeexBits *bits)
{
return 1;
}
#endif
@ -1127,7 +1115,7 @@ int sb_decode(void *state, SpeexBits *bits, void *vout)
return 0;
}
#if 0
#ifndef SPEEX_DISABLE_ENCODER
int sb_encoder_ctl(void *state, int request, void *ptr)
{
SBEncState *st;
@ -1375,11 +1363,6 @@ int sb_encoder_ctl(void *state, int request, void *ptr)
}
return 0;
}
#else
int sb_encoder_ctl(void *state, int request, void *ptr)
{
return 0;
}
#endif
int sb_decoder_ctl(void *state, int request, void *ptr)

View file

@ -67,6 +67,7 @@ typedef struct SpeexHeader {
} SpeexHeader;
*/
#ifndef SPEEX_DISABLE_ENCODER
void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const SpeexMode *m)
{
int i;
@ -125,6 +126,7 @@ char *speex_header_to_packet(SpeexHeader *header, int *size)
*size = sizeof(SpeexHeader);
return (char *)le_header;
}
#endif
SpeexHeader *speex_packet_to_header(char *packet, int size)
{

View file

@ -41,6 +41,7 @@
/*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/
static const float e_ratio_quant[4] = {.25f, .315f, .397f, .5f};
#ifndef SPEEX_DISABLE_ENCODER
void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits)
{
int i, tmp;
@ -114,6 +115,7 @@ void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits)
tmp=vq_index(&e_ratio, e_ratio_quant, 1, 4);
speex_bits_pack(bits, tmp, 2);
}
#endif
void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo)
{