1
0
Fork 0
forked from len0rd/rockbox

Disable some unused code in speex to save binsize.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29949 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2011-06-02 20:52:54 +00:00
parent d860c87800
commit 73d0e14f44
8 changed files with 58 additions and 18 deletions

View file

@ -60,6 +60,8 @@ void speex_bits_init(SpeexBits *bits)
} }
#endif #endif
#if 0
/* Rockbox: unused */
void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size) void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size)
{ {
bits->chars = (char*)buff; bits->chars = (char*)buff;
@ -69,6 +71,7 @@ void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size)
speex_bits_reset(bits); speex_bits_reset(bits);
} }
#endif
void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size) void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size)
{ {
@ -93,6 +96,7 @@ void speex_bits_destroy(SpeexBits *bits)
} }
#endif #endif
#ifdef ROCKBOX_VOICE_ENCODER
void speex_bits_reset(SpeexBits *bits) void speex_bits_reset(SpeexBits *bits)
{ {
/* We only need to clear the first byte now */ /* We only need to clear the first byte now */
@ -102,13 +106,17 @@ void speex_bits_reset(SpeexBits *bits)
bits->bitPtr=0; bits->bitPtr=0;
bits->overflow=0; bits->overflow=0;
} }
#endif
#if 0
/* Rockbox: unused */
void speex_bits_rewind(SpeexBits *bits) void speex_bits_rewind(SpeexBits *bits)
{ {
bits->charPtr=0; bits->charPtr=0;
bits->bitPtr=0; bits->bitPtr=0;
bits->overflow=0; bits->overflow=0;
} }
#endif
#if !defined(SPEEX_VOICE_ENCODER) && !defined(ROCKBOX_VOICE_CODEC) #if !defined(SPEEX_VOICE_ENCODER) && !defined(ROCKBOX_VOICE_CODEC)
void speex_bits_read_from(SpeexBits *bits, char *chars, int len) 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 */ #endif /* SPEEX_DISABLE_ENCODER */
#if 0
/* Rockbox: unused */
int speex_bits_unpack_signed(SpeexBits *bits, int nbBits) int speex_bits_unpack_signed(SpeexBits *bits, int nbBits)
{ {
unsigned int d=speex_bits_unpack_unsigned(bits,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; return d;
} }
#endif
unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits) 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; return d;
} }
#if 0
/* Rockbox: unused */
unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits) unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits)
{ {
unsigned int d=0; unsigned int d=0;
@ -338,6 +351,7 @@ unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits)
} }
return d; return d;
} }
#endif
int speex_bits_peek(SpeexBits *bits) int speex_bits_peek(SpeexBits *bits)
{ {
@ -366,10 +380,13 @@ int speex_bits_remaining(SpeexBits *bits)
return bits->nbBits-((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr); return bits->nbBits-((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr);
} }
#if 0
/* Rockbox: unused */
int speex_bits_nbytes(SpeexBits *bits) int speex_bits_nbytes(SpeexBits *bits)
{ {
return ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); return ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
} }
#endif
#ifndef SPEEX_DISABLE_ENCODER #ifndef SPEEX_DISABLE_ENCODER
void speex_bits_insert_terminator(SpeexBits *bits) void speex_bits_insert_terminator(SpeexBits *bits)

View file

@ -464,13 +464,13 @@ const SpeexMode speex_nb_mode = {
&nb_encoder_ctl, &nb_encoder_ctl,
&nb_decoder_ctl, &nb_decoder_ctl,
#else #else
/* NULL,
NULL, NULL,
NULL, NULL, */
NULL,
&nb_decoder_init, &nb_decoder_init,
&nb_decoder_destroy, &nb_decoder_destroy,
&nb_decode, &nb_decode,
NULL, /* NULL, */
&nb_decoder_ctl, &nb_decoder_ctl,
#endif #endif
}; };

View file

@ -264,13 +264,13 @@ const SpeexMode speex_wb_mode = {
&sb_encoder_ctl, &sb_encoder_ctl,
&sb_decoder_ctl, &sb_decoder_ctl,
#else #else
/* NULL,
NULL, NULL,
NULL, NULL, */
NULL,
&sb_decoder_init, &sb_decoder_init,
&sb_decoder_destroy, &sb_decoder_destroy,
&sb_decode, &sb_decode,
NULL, /* NULL, */
&sb_decoder_ctl, &sb_decoder_ctl,
#endif #endif
}; };
@ -348,13 +348,13 @@ const SpeexMode speex_uwb_mode = {
&sb_encoder_ctl, &sb_encoder_ctl,
&sb_decoder_ctl, &sb_decoder_ctl,
#else #else
/* NULL,
NULL, NULL,
NULL, NULL, */
NULL,
&sb_decoder_init, &sb_decoder_init,
&sb_decoder_destroy, &sb_decoder_destroy,
&sb_decode, &sb_decode,
NULL, /* NULL, */
&sb_decoder_ctl, &sb_decoder_ctl,
#endif #endif
}; };

View file

@ -1092,7 +1092,7 @@ static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack)
#endif #endif
/* Just so we don't need to carry the complete wideband mode information */ /* 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) int nb_decode(void *state, SpeexBits *bits, void *vout)
{ {

View file

@ -46,34 +46,36 @@
#define MAX_IN_SAMPLES 640 #define MAX_IN_SAMPLES 640
#ifndef SPEEX_DISABLE_ENCODER
void *speex_encoder_init(const SpeexMode *mode) void *speex_encoder_init(const SpeexMode *mode)
{ {
return mode->enc_init(mode); return mode->enc_init(mode);
} }
#endif
void *speex_decoder_init(const SpeexMode *mode) void *speex_decoder_init(const SpeexMode *mode)
{ {
return mode->dec_init(mode); return mode->dec_init(mode);
} }
#ifndef SPEEX_DISABLE_ENCODER
void speex_encoder_destroy(void *state) void speex_encoder_destroy(void *state)
{ {
(*((SpeexMode**)state))->enc_destroy(state); (*((SpeexMode**)state))->enc_destroy(state);
} }
#endif
void speex_decoder_destroy(void *state) void speex_decoder_destroy(void *state)
{ {
(*((SpeexMode**)state))->dec_destroy(state); (*((SpeexMode**)state))->dec_destroy(state);
} }
#ifndef SPEEX_DISABLE_ENCODER
int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits) int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits)
{ {
return (*((SpeexMode**)state))->enc(state, in, bits); return (*((SpeexMode**)state))->enc(state, in, bits);
} }
#endif
int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out) 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 #endif
#ifndef SPEEX_DISABLE_ENCODER
int speex_encoder_ctl(void *state, int request, void *ptr) int speex_encoder_ctl(void *state, int request, void *ptr)
{ {
return (*((SpeexMode**)state))->enc_ctl(state, request, ptr); return (*((SpeexMode**)state))->enc_ctl(state, request, ptr);
} }
#endif
int speex_decoder_ctl(void *state, int request, void *ptr) int speex_decoder_ctl(void *state, int request, void *ptr)
{ {
return (*((SpeexMode**)state))->dec_ctl(state, request, ptr); return (*((SpeexMode**)state))->dec_ctl(state, request, ptr);
} }
int nb_mode_query(const void *mode, int request, void *ptr) int nb_mode_query(const void *mode, int request, void *ptr)
{ {
const SpeexNBMode *m = (const SpeexNBMode*)mode; const SpeexNBMode *m = (const SpeexNBMode*)mode;

View file

@ -263,6 +263,7 @@ typedef struct SpeexMode {
bitstream compatibility*/ bitstream compatibility*/
int bitstream_version; int bitstream_version;
#ifndef SPEEX_DISABLE_ENCODER
/** Pointer to encoder initialization function */ /** Pointer to encoder initialization function */
encoder_init_func enc_init; encoder_init_func enc_init;
@ -271,6 +272,7 @@ typedef struct SpeexMode {
/** Pointer to frame encoding function */ /** Pointer to frame encoding function */
encode_func enc; encode_func enc;
#endif
/** Pointer to decoder initialization function */ /** Pointer to decoder initialization function */
decoder_init_func dec_init; decoder_init_func dec_init;
@ -281,8 +283,10 @@ typedef struct SpeexMode {
/** Pointer to frame decoding function */ /** Pointer to frame decoding function */
decode_func dec; decode_func dec;
#ifndef SPEEX_DISABLE_ENCODER
/** ioctl-like requests for encoder */ /** ioctl-like requests for encoder */
encoder_ctl_func enc_ctl; encoder_ctl_func enc_ctl;
#endif
/** ioctl-like requests for decoder */ /** ioctl-like requests for decoder */
decoder_ctl_func dec_ctl; decoder_ctl_func dec_ctl;

View file

@ -62,7 +62,9 @@ typedef struct SpeexBits {
void speex_bits_init(SpeexBits *bits); void speex_bits_init(SpeexBits *bits);
/** Initializes SpeexBits struct using a pre-allocated buffer*/ /** Initializes SpeexBits struct using a pre-allocated buffer*/
/* Rockbox: unused
void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size); 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) */ /** 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); 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); void speex_bits_reset(SpeexBits *bits);
/** Rewind the bit-stream to the beginning (ready for read) without erasing the content */ /** Rewind the bit-stream to the beginning (ready for read) without erasing the content */
/* Rockbox: unused
void speex_bits_rewind(SpeexBits *bits); void speex_bits_rewind(SpeexBits *bits);
*/
/** Initializes the bit-stream from the data in an area of memory */ /** Initializes the bit-stream from the data in an area of memory */
void speex_bits_read_from(SpeexBits *bits, char *bytes, int len); 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 * @param nbBits Number of bits to interpret
* @return A signed integer represented by the bits read * @return A signed integer represented by the bits read
*/ */
/* Rockbox: unused
int speex_bits_unpack_signed(SpeexBits *bits, int nbBits); int speex_bits_unpack_signed(SpeexBits *bits, int nbBits);
*/
/** Interpret the next bits in the bit-stream as an unsigned integer /** 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 * @param bits Bit-stream to operate on
* @return Number of bytes in the stream * @return Number of bytes in the stream
*/ */
/* Rockbox: unused
int speex_bits_nbytes(SpeexBits *bits); int speex_bits_nbytes(SpeexBits *bits);
*/
/** Same as speex_bits_unpack_unsigned, but without modifying the cursor position /** 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 * @param nbBits Number of bits to look for
* @return Value of the bits peeked, interpreted as unsigned * @return Value of the bits peeked, interpreted as unsigned
*/ */
/* Rockbox: unused
unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits); unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits);
*/
/** Get the value of the next bit in the stream, without modifying the /** Get the value of the next bit in the stream, without modifying the
* "cursor" position * "cursor" position

View file

@ -72,6 +72,8 @@ int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *st
return 0; return 0;
} }
#if 0
/* Rockbox: unused */
int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data) int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data)
{ {
(void)state; (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); speex_encoder_ctl(data, SPEEX_SET_HIGH_MODE, &m);
return 0; return 0;
} }
#endif
#ifndef DISABLE_VBR #ifndef DISABLE_VBR
int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data) 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 */ #endif /* #ifndef DISABLE_VBR */
#if 0
/* Rockbox: unused */
int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data) int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data)
{ {
(void)state; (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); speex_decoder_ctl(data, SPEEX_SET_ENH, &enh);
return 0; return 0;
} }
#endif
#ifndef DISABLE_VBR #ifndef DISABLE_VBR
int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data) 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 */ #endif /* #ifndef DISABLE_VBR */
#if 0
/* Rockbox: unused */
int speex_std_char_handler(SpeexBits *bits, void *state, void *data) int speex_std_char_handler(SpeexBits *bits, void *state, void *data)
{ {
(void)state; (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);*/ /*printf("speex_std_char_handler ch=%x\n", ch);*/
return 0; return 0;
} }
#endif
/* Default handler for user callbacks: skip it */ /* Default handler for user callbacks: skip it */
int speex_default_user_handler(SpeexBits *bits, void *state, void *data) int speex_default_user_handler(SpeexBits *bits, void *state, void *data)