diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-17 21:48:28 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-17 21:48:28 +0000 |
commit | 4070f4f17b77a030049e146245fc9a399bb68204 (patch) | |
tree | 460355644ba5a1207a9269c6d1e955c98a8f37a6 | |
parent | 1da1b70e269b16d381c892fb7003ec5526471b60 (diff) |
Reduce memory consumption of VGM codec for low memry targets at the costs of some performance for tracks using the 2616 emulator.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30326 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/libgme/ym2612_emu.c | 26 | ||||
-rw-r--r-- | apps/codecs/libgme/ym2612_emu.h | 8 |
2 files changed, 28 insertions, 6 deletions
diff --git a/apps/codecs/libgme/ym2612_emu.c b/apps/codecs/libgme/ym2612_emu.c index 003be394dd..a1f96e3d70 100644 --- a/apps/codecs/libgme/ym2612_emu.c +++ b/apps/codecs/libgme/ym2612_emu.c @@ -490,7 +490,7 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double { assert( sample_rate ); assert( !clock_rate || clock_rate > sample_rate ); - + int i; // 144 = 12 * (prescale * 2) = 12 * 6 * 2 @@ -505,6 +505,7 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double // [0 - 4095] = +output [4095 - ...] = +output overflow (fill with 0) // [12288 - 16383] = -output [16384 - ...] = -output overflow (fill with 0) +#ifdef YM2612_USE_TL_TAB for ( i = 0; i < TL_LENGHT; i++ ) { if (i >= PG_CUT_OFF) // YM2612 cut off sound after 78 dB (14 bits output ?) @@ -522,6 +523,7 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double impl->g.TL_TAB [TL_LENGHT + i] = -impl->g.TL_TAB [i]; } } +#endif // Tableau SIN : // impl->g.SIN_TAB [x] [y] = sin(x) * y; @@ -908,8 +910,24 @@ short const* const ENV_TAB = g->ENV_TAB; \ CALC_EN( 0 ) \ CALC_EN( 1 ) \ CALC_EN( 2 ) \ -CALC_EN( 3 ) \ -int const* const TL_TAB = g->TL_TAB; +CALC_EN( 3 ) + +#ifndef YM2612_USE_TL_TAB +static inline int tl_level( int i ) +{ + if (i >= (PG_CUT_OFF + TL_LENGHT)) { + return 0; + } else if (i >= TL_LENGHT) { + return -tl_coeff [i - TL_LENGHT]; + } else if (i >= PG_CUT_OFF) { + return 0; + } else + return tl_coeff [i]; +} +#define SINT( i, o ) (tl_level (g->SIN_TAB [(i)] + (o))) +#else +#define SINT( i, o ) (g->TL_TAB [g->SIN_TAB [(i)] + (o)]) +#endif #define DO_FEEDBACK \ int CH_S0_OUT_0 = ch->S0_OUT [0]; \ @@ -919,8 +937,6 @@ int CH_S0_OUT_0 = ch->S0_OUT [0]; \ CH_S0_OUT_0 = SINT( (temp >> SIN_LBITS) & SIN_MASK, en0 ); \ } \ -#define SINT( i, o ) (TL_TAB [g->SIN_TAB [(i)] + (o)]) - #define DO_LIMIT \ CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \ diff --git a/apps/codecs/libgme/ym2612_emu.h b/apps/codecs/libgme/ym2612_emu.h index 96e3eae94b..146d92a0a3 100644 --- a/apps/codecs/libgme/ym2612_emu.h +++ b/apps/codecs/libgme/ym2612_emu.h @@ -10,6 +10,10 @@ #define YM2612_CALCUL_TABLES #endif +#if MEMORYSIZE > 2 + #define YM2612_USE_TL_TAB +#endif + enum { ym2612_out_chan_count = 2 }; // stereo enum { ym2612_channel_count = 6 }; enum { ym2612_disabled_time = -1 }; @@ -172,7 +176,9 @@ struct tables_t short LFO_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB) short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE #endif - int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus) +#ifdef YM2612_USE_TL_TAB + int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus) +#endif unsigned int DECAY_TO_ATTACK [ENV_LENGHT]; // Conversion from decay to attack phase unsigned int FINC_TAB [2048]; // Frequency step table }; |