From 73d0e14f4494b98e0c781934fbf19efa8d6d8418 Mon Sep 17 00:00:00 2001 From: Nils Wallménius Date: Thu, 2 Jun 2011 20:52:54 +0000 Subject: Disable some unused code in speex to save binsize. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29949 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libspeex/bits.c | 17 +++++++++++++++++ apps/codecs/libspeex/modes.c | 6 +++--- apps/codecs/libspeex/modes_wb.c | 12 ++++++------ apps/codecs/libspeex/nb_celp.c | 2 +- apps/codecs/libspeex/speex.c | 16 ++++++++-------- apps/codecs/libspeex/speex/speex.h | 4 ++++ apps/codecs/libspeex/speex/speex_bits.h | 10 ++++++++++ apps/codecs/libspeex/speex_callbacks.c | 9 +++++++++ 8 files changed, 58 insertions(+), 18 deletions(-) (limited to 'apps') diff --git a/apps/codecs/libspeex/bits.c b/apps/codecs/libspeex/bits.c index cc63ce0d16..c7a5c14ede 100644 --- a/apps/codecs/libspeex/bits.c +++ b/apps/codecs/libspeex/bits.c @@ -60,6 +60,8 @@ void speex_bits_init(SpeexBits *bits) } #endif +#if 0 +/* Rockbox: unused */ void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size) { bits->chars = (char*)buff; @@ -69,6 +71,7 @@ void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size) speex_bits_reset(bits); } +#endif void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size) { @@ -93,6 +96,7 @@ void speex_bits_destroy(SpeexBits *bits) } #endif +#ifdef ROCKBOX_VOICE_ENCODER void speex_bits_reset(SpeexBits *bits) { /* We only need to clear the first byte now */ @@ -102,13 +106,17 @@ void speex_bits_reset(SpeexBits *bits) bits->bitPtr=0; bits->overflow=0; } +#endif +#if 0 +/* Rockbox: unused */ void speex_bits_rewind(SpeexBits *bits) { bits->charPtr=0; bits->bitPtr=0; bits->overflow=0; } +#endif #if !defined(SPEEX_VOICE_ENCODER) && !defined(ROCKBOX_VOICE_CODEC) void speex_bits_read_from(SpeexBits *bits, char *chars, int len) @@ -277,6 +285,8 @@ void speex_bits_pack(SpeexBits *bits, int data, int nbBits) } #endif /* SPEEX_DISABLE_ENCODER */ +#if 0 +/* Rockbox: unused */ int speex_bits_unpack_signed(SpeexBits *bits, int nbBits) { unsigned int d=speex_bits_unpack_unsigned(bits,nbBits); @@ -287,6 +297,7 @@ int speex_bits_unpack_signed(SpeexBits *bits, int nbBits) } return d; } +#endif unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits) { @@ -310,6 +321,8 @@ unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits) return d; } +#if 0 +/* Rockbox: unused */ unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits) { unsigned int d=0; @@ -338,6 +351,7 @@ unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits) } return d; } +#endif int speex_bits_peek(SpeexBits *bits) { @@ -366,10 +380,13 @@ int speex_bits_remaining(SpeexBits *bits) return bits->nbBits-((bits->charPtr<bitPtr); } +#if 0 +/* Rockbox: unused */ int speex_bits_nbytes(SpeexBits *bits) { return ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); } +#endif #ifndef SPEEX_DISABLE_ENCODER void speex_bits_insert_terminator(SpeexBits *bits) diff --git a/apps/codecs/libspeex/modes.c b/apps/codecs/libspeex/modes.c index 20ea287344..d1046f1cfb 100644 --- a/apps/codecs/libspeex/modes.c +++ b/apps/codecs/libspeex/modes.c @@ -464,13 +464,13 @@ const SpeexMode speex_nb_mode = { &nb_encoder_ctl, &nb_decoder_ctl, #else +/* NULL, NULL, - NULL, - NULL, + NULL, */ &nb_decoder_init, &nb_decoder_destroy, &nb_decode, - NULL, +/* NULL, */ &nb_decoder_ctl, #endif }; diff --git a/apps/codecs/libspeex/modes_wb.c b/apps/codecs/libspeex/modes_wb.c index 7fac15b852..93922afa2f 100644 --- a/apps/codecs/libspeex/modes_wb.c +++ b/apps/codecs/libspeex/modes_wb.c @@ -264,13 +264,13 @@ const SpeexMode speex_wb_mode = { &sb_encoder_ctl, &sb_decoder_ctl, #else +/* NULL, NULL, - NULL, - NULL, + NULL, */ &sb_decoder_init, &sb_decoder_destroy, &sb_decode, - NULL, +/* NULL, */ &sb_decoder_ctl, #endif }; @@ -348,13 +348,13 @@ const SpeexMode speex_uwb_mode = { &sb_encoder_ctl, &sb_decoder_ctl, #else +/* NULL, NULL, - NULL, - NULL, + NULL, */ &sb_decoder_init, &sb_decoder_destroy, &sb_decode, - NULL, +/* NULL, */ &sb_decoder_ctl, #endif }; diff --git a/apps/codecs/libspeex/nb_celp.c b/apps/codecs/libspeex/nb_celp.c index 98f5e2e240..364f987472 100644 --- a/apps/codecs/libspeex/nb_celp.c +++ b/apps/codecs/libspeex/nb_celp.c @@ -1092,7 +1092,7 @@ static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack) #endif /* Just so we don't need to carry the complete wideband mode information */ -static const int wb_skip_table[8] = {0, 36, 112, 192, 352, 0, 0, 0}; +static const unsigned short wb_skip_table[8] = {0, 36, 112, 192, 352, 0, 0, 0}; int nb_decode(void *state, SpeexBits *bits, void *vout) { diff --git a/apps/codecs/libspeex/speex.c b/apps/codecs/libspeex/speex.c index a77653f21a..0dcfb3f7f6 100644 --- a/apps/codecs/libspeex/speex.c +++ b/apps/codecs/libspeex/speex.c @@ -46,34 +46,36 @@ #define MAX_IN_SAMPLES 640 - - +#ifndef SPEEX_DISABLE_ENCODER void *speex_encoder_init(const SpeexMode *mode) { return mode->enc_init(mode); } +#endif void *speex_decoder_init(const SpeexMode *mode) { return mode->dec_init(mode); } +#ifndef SPEEX_DISABLE_ENCODER void speex_encoder_destroy(void *state) { (*((SpeexMode**)state))->enc_destroy(state); } +#endif void speex_decoder_destroy(void *state) { (*((SpeexMode**)state))->dec_destroy(state); } - - +#ifndef SPEEX_DISABLE_ENCODER int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits) { return (*((SpeexMode**)state))->enc(state, in, bits); } +#endif int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out) { @@ -177,20 +179,18 @@ int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out) } #endif - - +#ifndef SPEEX_DISABLE_ENCODER int speex_encoder_ctl(void *state, int request, void *ptr) { return (*((SpeexMode**)state))->enc_ctl(state, request, ptr); } +#endif int speex_decoder_ctl(void *state, int request, void *ptr) { return (*((SpeexMode**)state))->dec_ctl(state, request, ptr); } - - int nb_mode_query(const void *mode, int request, void *ptr) { const SpeexNBMode *m = (const SpeexNBMode*)mode; diff --git a/apps/codecs/libspeex/speex/speex.h b/apps/codecs/libspeex/speex/speex.h index ffb0714f1c..086d492670 100644 --- a/apps/codecs/libspeex/speex/speex.h +++ b/apps/codecs/libspeex/speex/speex.h @@ -263,6 +263,7 @@ typedef struct SpeexMode { bitstream compatibility*/ int bitstream_version; +#ifndef SPEEX_DISABLE_ENCODER /** Pointer to encoder initialization function */ encoder_init_func enc_init; @@ -271,6 +272,7 @@ typedef struct SpeexMode { /** Pointer to frame encoding function */ encode_func enc; +#endif /** Pointer to decoder initialization function */ decoder_init_func dec_init; @@ -281,8 +283,10 @@ typedef struct SpeexMode { /** Pointer to frame decoding function */ decode_func dec; +#ifndef SPEEX_DISABLE_ENCODER /** ioctl-like requests for encoder */ encoder_ctl_func enc_ctl; +#endif /** ioctl-like requests for decoder */ decoder_ctl_func dec_ctl; diff --git a/apps/codecs/libspeex/speex/speex_bits.h b/apps/codecs/libspeex/speex/speex_bits.h index a26fb4ce0c..fee2893380 100644 --- a/apps/codecs/libspeex/speex/speex_bits.h +++ b/apps/codecs/libspeex/speex/speex_bits.h @@ -62,7 +62,9 @@ typedef struct SpeexBits { void speex_bits_init(SpeexBits *bits); /** Initializes SpeexBits struct using a pre-allocated buffer*/ +/* Rockbox: unused void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size); +*/ /** Sets the bits in a SpeexBits struct to use data from an existing buffer (for decoding without copying data) */ void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size); @@ -74,7 +76,9 @@ void speex_bits_destroy(SpeexBits *bits); void speex_bits_reset(SpeexBits *bits); /** Rewind the bit-stream to the beginning (ready for read) without erasing the content */ +/* Rockbox: unused void speex_bits_rewind(SpeexBits *bits); +*/ /** Initializes the bit-stream from the data in an area of memory */ void speex_bits_read_from(SpeexBits *bits, char *bytes, int len); @@ -112,7 +116,9 @@ void speex_bits_pack(SpeexBits *bits, int data, int nbBits); * @param nbBits Number of bits to interpret * @return A signed integer represented by the bits read */ +/* Rockbox: unused int speex_bits_unpack_signed(SpeexBits *bits, int nbBits); +*/ /** Interpret the next bits in the bit-stream as an unsigned integer * @@ -127,7 +133,9 @@ unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits); * @param bits Bit-stream to operate on * @return Number of bytes in the stream */ +/* Rockbox: unused int speex_bits_nbytes(SpeexBits *bits); +*/ /** Same as speex_bits_unpack_unsigned, but without modifying the cursor position * @@ -135,7 +143,9 @@ int speex_bits_nbytes(SpeexBits *bits); * @param nbBits Number of bits to look for * @return Value of the bits peeked, interpreted as unsigned */ +/* Rockbox: unused unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits); +*/ /** Get the value of the next bit in the stream, without modifying the * "cursor" position diff --git a/apps/codecs/libspeex/speex_callbacks.c b/apps/codecs/libspeex/speex_callbacks.c index 9ffe5245f1..f1de038488 100644 --- a/apps/codecs/libspeex/speex_callbacks.c +++ b/apps/codecs/libspeex/speex_callbacks.c @@ -72,6 +72,8 @@ int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *st return 0; } +#if 0 +/* Rockbox: unused */ int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data) { (void)state; @@ -98,6 +100,7 @@ int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data speex_encoder_ctl(data, SPEEX_SET_HIGH_MODE, &m); return 0; } +#endif #ifndef DISABLE_VBR int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data) @@ -110,6 +113,8 @@ int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data) } #endif /* #ifndef DISABLE_VBR */ +#if 0 +/* Rockbox: unused */ int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data) { (void)state; @@ -118,6 +123,7 @@ int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data) speex_decoder_ctl(data, SPEEX_SET_ENH, &enh); return 0; } +#endif #ifndef DISABLE_VBR int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data) @@ -130,6 +136,8 @@ int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *da } #endif /* #ifndef DISABLE_VBR */ +#if 0 +/* Rockbox: unused */ int speex_std_char_handler(SpeexBits *bits, void *state, void *data) { (void)state; @@ -139,6 +147,7 @@ int speex_std_char_handler(SpeexBits *bits, void *state, void *data) /*printf("speex_std_char_handler ch=%x\n", ch);*/ return 0; } +#endif /* Default handler for user callbacks: skip it */ int speex_default_user_handler(SpeexBits *bits, void *state, void *data) -- cgit v1.2.3