diff options
| author | Michael Giacomelli <giac2000@hotmail.com> | 2008-09-20 22:06:12 +0000 |
|---|---|---|
| committer | Michael Giacomelli <giac2000@hotmail.com> | 2008-09-20 22:06:12 +0000 |
| commit | 4e36a2b991d58a40d7ea12c9bf41e93736b8b024 (patch) | |
| tree | e26deeca8209a689bfebfcca18c4dad028d70260 /apps/codecs/libmad | |
| parent | 3d0d6d6bb25eb933d60ca5451b170eaae17dbb65 (diff) | |
| download | rockbox-4e36a2b991d58a40d7ea12c9bf41e93736b8b024.zip rockbox-4e36a2b991d58a40d7ea12c9bf41e93736b8b024.tar.gz rockbox-4e36a2b991d58a40d7ea12c9bf41e93736b8b024.tar.bz2 rockbox-4e36a2b991d58a40d7ea12c9bf41e93736b8b024.tar.xz | |
Commit FS#9318 - MP3 synthesis filter on COP. Loads the MP3 synth filer on to the CoProcessor on all PortalPlayer devices, resulting in an ~90% speedup according to test_codec on the Sansa. Real world improvement is somewhat less, but still considerable. Allows MP3 decoding at 30MHz without boosting, or use of more DSP/EQ with less boosting/skipping, thus improving battery life. Minor changes to mpegplayer to retain compatibility with libmad changes. Should be no significant changes for other targets or codecs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18557 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libmad')
| -rw-r--r-- | apps/codecs/libmad/frame.c | 9 | ||||
| -rw-r--r-- | apps/codecs/libmad/frame.h | 15 | ||||
| -rw-r--r-- | apps/codecs/libmad/layer12.c | 16 | ||||
| -rw-r--r-- | apps/codecs/libmad/layer3.c | 2 | ||||
| -rw-r--r-- | apps/codecs/libmad/mad.h | 7 | ||||
| -rw-r--r-- | apps/codecs/libmad/synth.c | 14 |
6 files changed, 36 insertions, 27 deletions
diff --git a/apps/codecs/libmad/frame.c b/apps/codecs/libmad/frame.c index 91cf2f9..2c7fdca 100644 --- a/apps/codecs/libmad/frame.c +++ b/apps/codecs/libmad/frame.c @@ -31,6 +31,7 @@ # include "timer.h" # include "layer12.h" # include "layer3.h" +# include "../lib/codeclib.h" static unsigned long const bitrate_table[5][15] = { @@ -467,7 +468,9 @@ int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream) mad_bit_finish(&next_frame); } - + + + return 0; fail: @@ -485,8 +488,8 @@ void mad_frame_mute(struct mad_frame *frame) for (s = 0; s < 36; ++s) { for (sb = 0; sb < 32; ++sb) { - frame->sbsample[0][s][sb] = - frame->sbsample[1][s][sb] = 0; + (*frame->sbsample)[0][s][sb] = + (*frame->sbsample)[1][s][sb] = 0; } } diff --git a/apps/codecs/libmad/frame.h b/apps/codecs/libmad/frame.h index dce573d..d2d6dca 100644 --- a/apps/codecs/libmad/frame.h +++ b/apps/codecs/libmad/frame.h @@ -65,12 +65,15 @@ struct mad_header { }; struct mad_frame { - struct mad_header header; /* MPEG audio header */ - - int options; /* decoding options (from stream) */ - - mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */ - mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ + struct mad_header header; /* MPEG audio header */ + int options; /* decoding options (from stream) */ + + mad_fixed_t (*sbsample)[2][36][32]; /* synthesis subband filter samples */ + mad_fixed_t (*sbsample_prev)[2][36][32]; /* synthesis subband filter samples + from previous frame only needed + when synthesis is on cop */ + + mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ }; # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) diff --git a/apps/codecs/libmad/layer12.c b/apps/codecs/libmad/layer12.c index c71c005..ccac392 100644 --- a/apps/codecs/libmad/layer12.c +++ b/apps/codecs/libmad/layer12.c @@ -185,7 +185,7 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) for (sb = 0; sb < bound; ++sb) { for (ch = 0; ch < nch; ++ch) { nb = allocation[ch][sb]; - frame->sbsample[ch][s][sb] = nb ? + (*frame->sbsample)[ch][s][sb] = nb ? mad_f_mul(I_sample(&stream->ptr, nb), sf_table[scalefactor[ch][sb]]) : 0; } @@ -198,13 +198,13 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) sample = I_sample(&stream->ptr, nb); for (ch = 0; ch < nch; ++ch) { - frame->sbsample[ch][s][sb] = + (*frame->sbsample)[ch][s][sb] = mad_f_mul(sample, sf_table[scalefactor[ch][sb]]); } } else { for (ch = 0; ch < nch; ++ch) - frame->sbsample[ch][s][sb] = 0; + (*frame->sbsample)[ch][s][sb] = 0; } } } @@ -492,13 +492,13 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) II_samples(&stream->ptr, &qc_table[index], samples); for (s = 0; s < 3; ++s) { - frame->sbsample[ch][3 * gr + s][sb] = + (*frame->sbsample)[ch][3 * gr + s][sb] = mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]); } } else { for (s = 0; s < 3; ++s) - frame->sbsample[ch][3 * gr + s][sb] = 0; + (*frame->sbsample)[ch][3 * gr + s][sb] = 0; } } } @@ -512,7 +512,7 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) for (ch = 0; ch < nch; ++ch) { for (s = 0; s < 3; ++s) { - frame->sbsample[ch][3 * gr + s][sb] = + (*frame->sbsample)[ch][3 * gr + s][sb] = mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]); } } @@ -520,7 +520,7 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) else { for (ch = 0; ch < nch; ++ch) { for (s = 0; s < 3; ++s) - frame->sbsample[ch][3 * gr + s][sb] = 0; + (*frame->sbsample)[ch][3 * gr + s][sb] = 0; } } } @@ -528,7 +528,7 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) for (ch = 0; ch < nch; ++ch) { for (s = 0; s < 3; ++s) { for (sb = sblimit; sb < 32; ++sb) - frame->sbsample[ch][3 * gr + s][sb] = 0; + (*frame->sbsample)[ch][3 * gr + s][sb] = 0; } } } diff --git a/apps/codecs/libmad/layer3.c b/apps/codecs/libmad/layer3.c index a95927e..0a53086 100644 --- a/apps/codecs/libmad/layer3.c +++ b/apps/codecs/libmad/layer3.c @@ -3112,7 +3112,7 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, for (ch = 0; ch < nch; ++ch) { struct channel const *channel = &granule->ch[ch]; - mad_fixed_t (*sample)[32] = &frame->sbsample[ch][18 * gr]; + mad_fixed_t (*sample)[32] = &((*frame->sbsample)[ch][18 * gr]); unsigned int sb, l, i, sblimit; mad_fixed_t output[36]; diff --git a/apps/codecs/libmad/mad.h b/apps/codecs/libmad/mad.h index f5d8f1d..52a74d1 100644 --- a/apps/codecs/libmad/mad.h +++ b/apps/codecs/libmad/mad.h @@ -777,10 +777,13 @@ struct mad_header { struct mad_frame { struct mad_header header; /* MPEG audio header */ - int options; /* decoding options (from stream) */ - mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */ + mad_fixed_t (*sbsample)[2][36][32]; /* synthesis subband filter samples */ + mad_fixed_t (*sbsample_prev)[2][36][32]; /* synthesis subband filter samples + from previous frame only needed + when synthesis is on cop */ + mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ }; diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c index c023f01..b1a8491 100644 --- a/apps/codecs/libmad/synth.c +++ b/apps/codecs/libmad/synth.c @@ -592,14 +592,14 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, int sb; unsigned int phase, ch, s, p; mad_fixed_t *pcm, (*filter)[2][2][16][8]; - mad_fixed_t const (*sbsample)[36][32]; + mad_fixed_t (*sbsample)[36][32]; mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; mad_fixed_t const (*D0ptr)[32]; mad_fixed_t const (*D1ptr)[32]; mad_fixed64hi_t hi0, hi1; for (ch = 0; ch < nch; ++ch) { - sbsample = &frame->sbsample[ch]; + sbsample = &*frame->sbsample_prev[ch]; filter = &synth->filter[ch]; phase = synth->phase; pcm = synth->pcm.samples[ch]; @@ -1053,7 +1053,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, int p; unsigned int phase, ch, s; mad_fixed_t *pcm, (*filter)[2][2][16][8]; - mad_fixed_t const (*sbsample)[36][32]; + mad_fixed_t (*sbsample)[36][32]; mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; mad_fixed_t const (*D0ptr)[32], *ptr; mad_fixed_t const (*D1ptr)[32]; @@ -1061,7 +1061,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, mad_fixed64lo_t lo; for (ch = 0; ch < nch; ++ch) { - sbsample = &frame->sbsample[ch]; + sbsample = &(*frame->sbsample_prev)[ch]; filter = &synth->filter[ch]; phase = synth->phase; pcm = synth->pcm.samples[ch]; @@ -1202,7 +1202,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, mad_fixed64lo_t lo; for (ch = 0; ch < nch; ++ch) { - sbsample = &frame->sbsample[ch]; + sbsample = &frame->sbsample_prev[ch]; filter = &synth->filter[ch]; phase = synth->phase; pcm = synth->pcm.samples[ch]; @@ -1403,14 +1403,14 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, { unsigned int phase, ch, s, sb, pe, po; mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8]; - mad_fixed_t const (*sbsample)[36][32]; + mad_fixed_t (*sbsample)[36][32]; register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; register mad_fixed_t const (*Dptr)[32], *ptr; register mad_fixed64hi_t hi; register mad_fixed64lo_t lo; for (ch = 0; ch < nch; ++ch) { - sbsample = &frame->sbsample[ch]; + sbsample = &(*frame->sbsample_prev)[ch]; filter = &synth->filter[ch]; phase = synth->phase; pcm1 = synth->pcm.samples[ch]; |