From f8d4f4737972c4d5e2982c98c2a9de7281c700bb Mon Sep 17 00:00:00 2001 From: saratoga Date: Mon, 22 Nov 2010 02:51:13 +0000 Subject: [PATCH] Force alignment of various data structures in libmad. Speeds up Gigabeat S decoding by about 1MHz. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28639 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libmad/frame.h | 6 +++--- apps/codecs/libmad/layer3.c | 14 +++++++------- apps/codecs/libmad/stream.h | 2 +- apps/codecs/libmad/synth.c | 2 +- apps/codecs/libmad/synth.h | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/codecs/libmad/frame.h b/apps/codecs/libmad/frame.h index f96a31008..a585b950d 100644 --- a/apps/codecs/libmad/frame.h +++ b/apps/codecs/libmad/frame.h @@ -70,12 +70,12 @@ 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_prev)[2][36][32]; /* synthesis subband filter samples + mad_fixed_t (*sbsample)[2][36][32] MEM_ALIGN_ATTR; /* synthesis subband filter samples */ + mad_fixed_t (*sbsample_prev)[2][36][32] MEM_ALIGN_ATTR; /* 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 */ + mad_fixed_t (*overlap)[2][32][18] MEM_ALIGN_ATTR; /* Layer III block overlap data */ }; # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) diff --git a/apps/codecs/libmad/layer3.c b/apps/codecs/libmad/layer3.c index d8243f13c..a598ff2c9 100644 --- a/apps/codecs/libmad/layer3.c +++ b/apps/codecs/libmad/layer3.c @@ -22,7 +22,7 @@ # ifdef HAVE_CONFIG_H # include "config.h" # endif - + # include "global.h" # include @@ -349,7 +349,7 @@ unsigned long const rq_table[8207] = { * * root_table[3 + x] = 2^(x/4) */ -mad_fixed_t const root_table[7] ICONST_ATTR = { +mad_fixed_t const root_table[7] ICONST_ATTR MEM_ALIGN_ATTR = { MAD_F(0x09837f05) /* 2^(-3/4) == 0.59460355750136 */, MAD_F(0x0b504f33) /* 2^(-2/4) == 0.70710678118655 */, MAD_F(0x0d744fcd) /* 2^(-1/4) == 0.84089641525371 */, @@ -367,14 +367,14 @@ mad_fixed_t const root_table[7] ICONST_ATTR = { * cs[i] = 1 / sqrt(1 + c[i]^2) * ca[i] = c[i] / sqrt(1 + c[i]^2) */ -mad_fixed_t const cs[8] ICONST_ATTR = { +mad_fixed_t const cs[8] ICONST_ATTR MEM_ALIGN_ATTR = { +MAD_F(0x0db84a81) /* +0.857492926 */, +MAD_F(0x0e1b9d7f) /* +0.881741997 */, +MAD_F(0x0f31adcf) /* +0.949628649 */, +MAD_F(0x0fbba815) /* +0.983314592 */, +MAD_F(0x0feda417) /* +0.995517816 */, +MAD_F(0x0ffc8fc8) /* +0.999160558 */, +MAD_F(0x0fff964c) /* +0.999899195 */, +MAD_F(0x0ffff8d3) /* +0.999993155 */ }; -mad_fixed_t const ca[8] ICONST_ATTR = { +mad_fixed_t const ca[8] ICONST_ATTR MEM_ALIGN_ATTR = { -MAD_F(0x083b5fe7) /* -0.514495755 */, -MAD_F(0x078c36d2) /* -0.471731969 */, -MAD_F(0x05039814) /* -0.313377454 */, -MAD_F(0x02e91dd1) /* -0.181913200 */, -MAD_F(0x0183603a) /* -0.094574193 */, -MAD_F(0x00a7cb87) /* -0.040965583 */, @@ -388,7 +388,7 @@ mad_fixed_t const ca[8] ICONST_ATTR = { * imdct_s[i/even][k] = cos((PI / 24) * (2 * (i / 2) + 7) * (2 * k + 1)) * imdct_s[i /odd][k] = cos((PI / 24) * (2 * (6 + (i-1)/2) + 7) * (2 * k + 1)) */ -mad_fixed_t const imdct_s[6][6] ICONST_ATTR = { +mad_fixed_t const imdct_s[6][6] ICONST_ATTR MEM_ALIGN_ATTR = { # include "imdct_s.dat" }; @@ -400,7 +400,7 @@ mad_fixed_t const imdct_s[6][6] ICONST_ATTR = { * window_l[i] = sin((PI / 36) * (i + 1/2)) */ static -mad_fixed_t const window_l[36] ICONST_ATTR = { +mad_fixed_t const window_l[36] ICONST_ATTR MEM_ALIGN_ATTR = { MAD_F(0x00b2aa3e) /* 0.043619387 */, MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x03768962) /* 0.216439614 */, MAD_F(0x04cfb0e2) /* 0.300705800 */, MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x07635284) /* 0.461748613 */, @@ -430,7 +430,7 @@ mad_fixed_t const window_l[36] ICONST_ATTR = { * * window_s[i] = sin((PI / 12) * (i + 1/2)) */ -mad_fixed_t const window_s[12] ICONST_ATTR = { +mad_fixed_t const window_s[12] ICONST_ATTR MEM_ALIGN_ATTR = { MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x09bd7ca0) /* 0.608761429 */, MAD_F(0x0cb19346) /* 0.793353340 */, MAD_F(0x0ec835e8) /* 0.923879533 */, MAD_F(0x0fdcf549) /* 0.991444861 */, diff --git a/apps/codecs/libmad/stream.h b/apps/codecs/libmad/stream.h index d0510d091..046708b06 100644 --- a/apps/codecs/libmad/stream.h +++ b/apps/codecs/libmad/stream.h @@ -73,7 +73,7 @@ struct mad_stream { struct mad_bitptr anc_ptr; /* ancillary bits pointer */ unsigned int anc_bitlen; /* number of ancillary bits */ - unsigned char (*main_data)[MAD_BUFFER_MDLEN]; + unsigned char (*main_data)[MAD_BUFFER_MDLEN] MEM_ALIGN_ATTR; /* Layer III main_data() */ unsigned int md_len; /* bytes in main_data */ diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c index cbffee5e6..ebcf3d501 100644 --- a/apps/codecs/libmad/synth.c +++ b/apps/codecs/libmad/synth.c @@ -534,7 +534,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, # endif static -mad_fixed_t const D[17][32] ICONST_ATTR = { +mad_fixed_t const D[17][32] ICONST_ATTR MEM_ALIGN_ATTR = { # include "D.dat" }; diff --git a/apps/codecs/libmad/synth.h b/apps/codecs/libmad/synth.h index 4cbcf73b2..edb951e47 100644 --- a/apps/codecs/libmad/synth.h +++ b/apps/codecs/libmad/synth.h @@ -29,11 +29,11 @@ struct mad_pcm { unsigned int samplerate; /* sampling frequency (Hz) */ unsigned short channels; /* number of channels */ unsigned short length; /* number of samples per channel */ - mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */ + mad_fixed_t samples[2][1152] MEM_ALIGN_ATTR; /* PCM output samples [ch][sample] */ }; struct mad_synth { - mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */ + mad_fixed_t filter[2][2][2][16][8] MEM_ALIGN_ATTR; /* polyphase filterbank outputs */ /* [ch][eo][peo][s][v] */ unsigned int phase; /* current processing phase */ -- 2.11.4.GIT