summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2007-11-09 01:11:34 +0000
committerThom Johansen <thomj@rockbox.org>2007-11-09 01:11:34 +0000
commite43c1ac338fa57b874c17238452e5fcfa5481489 (patch)
tree38bd693b367317296bdfa4056de5a7c8df6fe149
parentc58673976379953c089340f95c7730e87762199b (diff)
downloadrockbox-e43c1ac338fa57b874c17238452e5fcfa5481489.tar.gz
rockbox-e43c1ac338fa57b874c17238452e5fcfa5481489.zip
Remove some unneeded floating point usage, port some needed floating point code to fixed point.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15547 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libspeex/arch.h4
-rw-r--r--apps/codecs/libspeex/nb_celp.c19
-rw-r--r--apps/codecs/libspeex/speex_callbacks.c3
3 files changed, 17 insertions, 9 deletions
diff --git a/apps/codecs/libspeex/arch.h b/apps/codecs/libspeex/arch.h
index e2d731acc0..1e48e93388 100644
--- a/apps/codecs/libspeex/arch.h
+++ b/apps/codecs/libspeex/arch.h
@@ -68,6 +68,7 @@ typedef spx_word32_t spx_sig_t;
#define LPC_SHIFT 13
#define LSP_SHIFT 13
#define SIG_SHIFT 14
+#define GAIN_SHIFT 6
#define VERY_SMALL 0
#define VERY_LARGE32 ((spx_word32_t)2147483647)
@@ -111,9 +112,6 @@ typedef float spx_word32_t;
#define GAIN_SCALING 1.f
#define GAIN_SCALING_1 1.f
-#define LPC_SHIFT 0
-#define LSP_SHIFT 0
-#define SIG_SHIFT 0
#define VERY_SMALL 1e-15f
#define VERY_LARGE32 1e15f
diff --git a/apps/codecs/libspeex/nb_celp.c b/apps/codecs/libspeex/nb_celp.c
index 4751068153..f3810894e1 100644
--- a/apps/codecs/libspeex/nb_celp.c
+++ b/apps/codecs/libspeex/nb_celp.c
@@ -665,13 +665,17 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
if (SUBMODE(forced_pitch_gain))
{
int quant;
+#ifdef FIXED_POINT
+ quant = PSHR16(MULT16_16_16(15, ol_pitch_coef),GAIN_SHIFT);
+#else
quant = (int)floor(.5+15*ol_pitch_coef*GAIN_SCALING_1);
+#endif
if (quant>15)
quant=15;
if (quant<0)
quant=0;
speex_bits_pack(bits, quant, 4);
- ol_pitch_coef=GAIN_SCALING*0.066667*quant;
+ ol_pitch_coef=MULT16_16_P15(QCONST16(0.066667,15),SHL16(quant,GAIN_SHIFT));
}
@@ -1410,7 +1414,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
{
int quant;
quant = speex_bits_unpack_unsigned(bits, 4);
- ol_pitch_coef=GAIN_SCALING*0.066667*quant;
+ ol_pitch_coef=MULT16_16_P15(QCONST16(0.066667,15),SHL16(quant,GAIN_SHIFT));
}
/* Get global excitation gain */
@@ -1572,11 +1576,9 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
/*Fixed codebook contribution*/
SUBMODE(innovation_unquant)(innov, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed);
/* De-normalize innovation and update excitation */
-#ifdef FIXED_POINT
- signal_mul(innov, innov, ener, st->subframeSize);
-#else
+
signal_mul(innov, innov, ener, st->subframeSize);
-#endif
+
/* Decode second codebook (only for some modes) */
if (SUBMODE(double_codebook))
{
@@ -2026,6 +2028,8 @@ int nb_decoder_ctl(void *state, int request, void *ptr)
break;
case SPEEX_GET_ACTIVITY:
{
+ /* We don't use this, dummy it out to get rid of the float stuff */
+#if 0
float ret;
ret = log(st->level/st->min_level)/log(st->max_level/st->min_level);
if (ret>1)
@@ -2035,6 +2039,9 @@ int nb_decoder_ctl(void *state, int request, void *ptr)
ret = 0;
/*printf ("%f %f %f %f\n", st->level, st->min_level, st->max_level, ret);*/
(*(spx_int32_t*)ptr) = (int)(100*ret);
+#else
+ (*(spx_int32_t*)ptr) = (int)(0);
+#endif
}
break;
case SPEEX_GET_PI_GAIN:
diff --git a/apps/codecs/libspeex/speex_callbacks.c b/apps/codecs/libspeex/speex_callbacks.c
index 9883d72e50..ca29e1b32b 100644
--- a/apps/codecs/libspeex/speex_callbacks.c
+++ b/apps/codecs/libspeex/speex_callbacks.c
@@ -114,9 +114,12 @@ int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data)
int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data)
{
+ /* We don't use this, get rid of the float reference */
+#if 0
float qual;
qual = speex_bits_unpack_unsigned(bits, 4);
speex_encoder_ctl(data, SPEEX_SET_VBR_QUALITY, &qual);
+#endif
return 0;
}