summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-04-24 13:54:02 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-04-24 13:54:02 +0000
commit15e9053afbcb6f4b0b42739197a7eca40007e093 (patch)
tree821b4249b5522992da3db1b27b00d34a21448ab6
parent22719955179d95279474913ccadd4c1a6efceca6 (diff)
downloadrockbox-15e9053afbcb6f4b0b42739197a7eca40007e093.tar.gz
rockbox-15e9053afbcb6f4b0b42739197a7eca40007e093.zip
Clean up array sizes in the SBR + PS part of libfaad. Add MAX_NTSRPS (=38), use MAX_NTSR and MAX_NTSRHFG at the right places. RAM (IRAM) usage is reduced by 2 KB.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29773 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libfaad/drm_dec.c14
-rw-r--r--apps/codecs/libfaad/drm_dec.h4
-rw-r--r--apps/codecs/libfaad/ps_dec.c36
-rw-r--r--apps/codecs/libfaad/ps_dec.h6
-rw-r--r--apps/codecs/libfaad/sbr_dec.c12
-rw-r--r--apps/codecs/libfaad/sbr_dec.h3
-rw-r--r--apps/codecs/libfaad/sbr_qmf.c10
-rw-r--r--apps/codecs/libfaad/sbr_qmf.h6
8 files changed, 62 insertions, 29 deletions
diff --git a/apps/codecs/libfaad/drm_dec.c b/apps/codecs/libfaad/drm_dec.c
index 8bf905169d..0cf40df23b 100644
--- a/apps/codecs/libfaad/drm_dec.c
+++ b/apps/codecs/libfaad/drm_dec.c
@@ -658,7 +658,7 @@ static void drm_ps_delta_decode(drm_ps_info *ps)
658 } 658 }
659} 659}
660 660
661static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t rateselect) 661static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[MAX_NTSRPS][64], uint8_t rateselect)
662{ 662{
663 uint8_t s, b, k; 663 uint8_t s, b, k;
664 complex_t qfrac, tmp0, tmp, in, R0; 664 complex_t qfrac, tmp0, tmp, in, R0;
@@ -773,7 +773,9 @@ static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t ra
773 ps->delay_buf_index_ser[k] = temp_delay_ser[k]; 773 ps->delay_buf_index_ser[k] = temp_delay_ser[k];
774} 774}
775 775
776static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64]) 776static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect,
777 qmf_t X_left[MAX_NTSRPS][64],
778 qmf_t X_right[MAX_NTSRPS][64])
777{ 779{
778 uint8_t s, b, ifreq, qclass; 780 uint8_t s, b, ifreq, qclass;
779 real_t sa_map[MAX_SA_BAND], sa_dir_map[MAX_SA_BAND], k_sa_map[MAX_SA_BAND], k_sa_dir_map[MAX_SA_BAND]; 781 real_t sa_map[MAX_SA_BAND], sa_dir_map[MAX_SA_BAND], k_sa_map[MAX_SA_BAND], k_sa_dir_map[MAX_SA_BAND];
@@ -833,7 +835,9 @@ static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[3
833 } 835 }
834} 836}
835 837
836static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64]) 838static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect,
839 qmf_t X_left[MAX_NTSRPS][64],
840 qmf_t X_right[MAX_NTSRPS][64])
837{ 841{
838 uint8_t s, b, qclass, ifreq; 842 uint8_t s, b, qclass, ifreq;
839 real_t tmp, coeff1, coeff2; 843 real_t tmp, coeff1, coeff2;
@@ -924,7 +928,9 @@ void drm_ps_free(drm_ps_info *ps)
924} 928}
925 929
926/* main DRM PS decoding function */ 930/* main DRM PS decoding function */
927uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, qmf_t X_left[38][64], qmf_t X_right[38][64]) 931uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate,
932 qmf_t X_left[MAX_NTSRPS][64],
933 qmf_t X_right[MAX_NTSRPS][64])
928{ 934{
929 uint8_t rateselect = (samplerate >= 24000); 935 uint8_t rateselect = (samplerate >= 24000);
930 936
diff --git a/apps/codecs/libfaad/drm_dec.h b/apps/codecs/libfaad/drm_dec.h
index e90b2340bd..34923c6431 100644
--- a/apps/codecs/libfaad/drm_dec.h
+++ b/apps/codecs/libfaad/drm_dec.h
@@ -88,7 +88,9 @@ uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld);
88drm_ps_info *drm_ps_init(void); 88drm_ps_info *drm_ps_init(void);
89void drm_ps_free(drm_ps_info *ps); 89void drm_ps_free(drm_ps_info *ps);
90 90
91uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, qmf_t X_left[38][64], qmf_t X_right[38][64]); 91uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate,
92 qmf_t X_left[MAX_NTSRPS][64],
93 qmf_t X_right[MAX_NTSRPS][64]);
92 94
93#ifdef __cplusplus 95#ifdef __cplusplus
94} 96}
diff --git a/apps/codecs/libfaad/ps_dec.c b/apps/codecs/libfaad/ps_dec.c
index f5d5ca9489..9a176235d0 100644
--- a/apps/codecs/libfaad/ps_dec.c
+++ b/apps/codecs/libfaad/ps_dec.c
@@ -181,10 +181,16 @@ static void map20indexto34(int8_t *index, uint8_t bins);
181static void map34indexto20(int8_t *index, uint8_t bins); 181static void map34indexto20(int8_t *index, uint8_t bins);
182#endif 182#endif
183static void ps_data_decode(ps_info *ps); 183static void ps_data_decode(ps_info *ps);
184static void ps_decorrelate(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64], 184static void ps_decorrelate(ps_info *ps,
185 qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]); 185 qmf_t X_left[MAX_NTSRPS][64],
186static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64], 186 qmf_t X_right[MAX_NTSRPS][64],
187 qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]); 187 qmf_t X_hybrid_left[32][32],
188 qmf_t X_hybrid_right[32][32]);
189static void ps_mix_phase(ps_info *ps,
190 qmf_t X_left[MAX_NTSRPS][64],
191 qmf_t X_right[MAX_NTSRPS][64],
192 qmf_t X_hybrid_left[32][32],
193 qmf_t X_hybrid_right[32][32]);
188 194
189/* */ 195/* */
190 196
@@ -1027,8 +1033,11 @@ static void ps_data_decode(ps_info *ps)
1027} 1033}
1028 1034
1029/* decorrelate the mono signal using an allpass filter */ 1035/* decorrelate the mono signal using an allpass filter */
1030static void ps_decorrelate(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64], 1036static void ps_decorrelate(ps_info *ps,
1031 qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]) 1037 qmf_t X_left[MAX_NTSRPS][64],
1038 qmf_t X_right[MAX_NTSRPS][64],
1039 qmf_t X_hybrid_left[32][32],
1040 qmf_t X_hybrid_right[32][32])
1032{ 1041{
1033 uint8_t gr, n, m, bk; 1042 uint8_t gr, n, m, bk;
1034 uint8_t temp_delay = 0; 1043 uint8_t temp_delay = 0;
@@ -1423,8 +1432,11 @@ static const real_t ipdopd_sin_tab[] = {
1423 FRAC_CONST(-0.000000000000000) 1432 FRAC_CONST(-0.000000000000000)
1424}; 1433};
1425 1434
1426static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64], 1435static void ps_mix_phase(ps_info *ps,
1427 qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]) 1436 qmf_t X_left[MAX_NTSRPS][64],
1437 qmf_t X_right[MAX_NTSRPS][64],
1438 qmf_t X_hybrid_left[32][32],
1439 qmf_t X_hybrid_right[32][32])
1428{ 1440{
1429 uint8_t n; 1441 uint8_t n;
1430 uint8_t gr; 1442 uint8_t gr;
@@ -1939,13 +1951,15 @@ ps_info *ps_init(uint8_t sr_index)
1939} 1951}
1940 1952
1941/* main Parametric Stereo decoding function */ 1953/* main Parametric Stereo decoding function */
1942uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]) 1954uint8_t ps_decode(ps_info *ps,
1955 qmf_t X_left[MAX_NTSRPS][64],
1956 qmf_t X_right[MAX_NTSRPS][64])
1943{ 1957{
1944 static qmf_t X_hybrid_left[32][32]; 1958 static qmf_t X_hybrid_left[32][32];
1945 static qmf_t X_hybrid_right[32][32]; 1959 static qmf_t X_hybrid_right[32][32];
1946 1960
1947 memset(&X_hybrid_left,0,sizeof(X_hybrid_left)); 1961 memset(&X_hybrid_left , 0, sizeof(X_hybrid_left));
1948 memset(&X_hybrid_right,0,sizeof(X_hybrid_right)); 1962 memset(&X_hybrid_right, 0, sizeof(X_hybrid_right));
1949 1963
1950 /* delta decoding of the bitstream data */ 1964 /* delta decoding of the bitstream data */
1951 ps_data_decode(ps); 1965 ps_data_decode(ps);
diff --git a/apps/codecs/libfaad/ps_dec.h b/apps/codecs/libfaad/ps_dec.h
index fca1f775ef..03cefd6fcd 100644
--- a/apps/codecs/libfaad/ps_dec.h
+++ b/apps/codecs/libfaad/ps_dec.h
@@ -39,6 +39,8 @@ extern "C" {
39#define MAX_PS_ENVELOPES 5 39#define MAX_PS_ENVELOPES 5
40#define NO_ALLPASS_LINKS 3 40#define NO_ALLPASS_LINKS 3
41 41
42#define MAX_NTSRPS 38 /* max number_time_slots * rate + 6 (delay) */
43
42typedef struct 44typedef struct
43{ 45{
44 /* bitstream parameters */ 46 /* bitstream parameters */
@@ -138,7 +140,9 @@ uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header);
138ps_info *ps_init(uint8_t sr_index); 140ps_info *ps_init(uint8_t sr_index);
139void ps_free(ps_info *ps); 141void ps_free(ps_info *ps);
140 142
141uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]); 143uint8_t ps_decode(ps_info *ps,
144 qmf_t X_left[MAX_NTSRPS][64],
145 qmf_t X_right[MAX_NTSRPS][64]);
142 146
143 147
144#ifdef __cplusplus 148#ifdef __cplusplus
diff --git a/apps/codecs/libfaad/sbr_dec.c b/apps/codecs/libfaad/sbr_dec.c
index 6fe884639a..c460be0c02 100644
--- a/apps/codecs/libfaad/sbr_dec.c
+++ b/apps/codecs/libfaad/sbr_dec.c
@@ -43,8 +43,16 @@
43 43
44 44
45/* globals */ 45/* globals */
46static qmf_t X_left [MAX_NTSRHFG][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR; 46#if (defined(PS_DEC) || defined(DRM_PS))
47static qmf_t X_right[MAX_NTSRHFG][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR; 47/* In case of PS_DEC or DRM_PS we need larger buffer data when calling
48 * ps_decode() or drm_ps_decode(). */
49static qmf_t X_left [MAX_NTSRPS][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
50static qmf_t X_right[MAX_NTSRPS][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
51#else
52/* No PS functions called. Keep using MAX_NTSR as array size. */
53static qmf_t X_left [MAX_NTSR][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
54static qmf_t X_right[MAX_NTSR][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
55#endif
48 56
49 57
50/* static function declarations */ 58/* static function declarations */
diff --git a/apps/codecs/libfaad/sbr_dec.h b/apps/codecs/libfaad/sbr_dec.h
index 25b3e37f52..aa145fe34a 100644
--- a/apps/codecs/libfaad/sbr_dec.h
+++ b/apps/codecs/libfaad/sbr_dec.h
@@ -39,8 +39,7 @@ extern "C" {
39#include "drm_dec.h" 39#include "drm_dec.h"
40#endif 40#endif
41 41
42/* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */ 42#define MAX_NTSRHFG 40 /* maximum of number_time_slots * rate + HFGen. 16*2+8 */
43#define MAX_NTSRHFG 40
44#define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */ 43#define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */
45 44
46/* MAX_M: maximum value for M */ 45/* MAX_M: maximum value for M */
diff --git a/apps/codecs/libfaad/sbr_qmf.c b/apps/codecs/libfaad/sbr_qmf.c
index bb6e176a3f..7cb62c241a 100644
--- a/apps/codecs/libfaad/sbr_qmf.c
+++ b/apps/codecs/libfaad/sbr_qmf.c
@@ -76,7 +76,7 @@ void qmfa_end(qmfa_info *qmfa)
76} 76}
77 77
78void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, 78void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
79 qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx) 79 qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx)
80{ 80{
81 real_t u[64] MEM_ALIGN_ATTR; 81 real_t u[64] MEM_ALIGN_ATTR;
82#ifndef SBR_LOW_POWER 82#ifndef SBR_LOW_POWER
@@ -224,7 +224,7 @@ void qmfs_end(qmfs_info *qmfs)
224 224
225#ifdef SBR_LOW_POWER 225#ifdef SBR_LOW_POWER
226 226
227void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 227void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
228 real_t *output) 228 real_t *output)
229{ 229{
230 real_t x[16] MEM_ALIGN_ATTR; 230 real_t x[16] MEM_ALIGN_ATTR;
@@ -288,7 +288,7 @@ void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6
288 } 288 }
289} 289}
290 290
291void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 291void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
292 real_t *output) 292 real_t *output)
293{ 293{
294 real_t x[64] MEM_ALIGN_ATTR; 294 real_t x[64] MEM_ALIGN_ATTR;
@@ -398,7 +398,7 @@ static const complex_t qmf32_pre_twiddle[] =
398 (MUL_F(QMF_IM(X[l][k]), RE(qmf32_pre_twiddle[k])) + \ 398 (MUL_F(QMF_IM(X[l][k]), RE(qmf32_pre_twiddle[k])) + \
399 MUL_F(QMF_RE(X[l][k]), IM(qmf32_pre_twiddle[k]))) 399 MUL_F(QMF_RE(X[l][k]), IM(qmf32_pre_twiddle[k])))
400 400
401void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 401void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
402 real_t *output) 402 real_t *output)
403{ 403{
404 real_t x1[32] MEM_ALIGN_ATTR; 404 real_t x1[32] MEM_ALIGN_ATTR;
@@ -461,7 +461,7 @@ void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6
461 } 461 }
462} 462}
463 463
464void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 464void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
465 real_t *output) 465 real_t *output)
466{ 466{
467 real_t real1[32] MEM_ALIGN_ATTR; 467 real_t real1[32] MEM_ALIGN_ATTR;
diff --git a/apps/codecs/libfaad/sbr_qmf.h b/apps/codecs/libfaad/sbr_qmf.h
index f940ccfa05..5ed8ff85df 100644
--- a/apps/codecs/libfaad/sbr_qmf.h
+++ b/apps/codecs/libfaad/sbr_qmf.h
@@ -38,10 +38,10 @@ qmfs_info *qmfs_init(uint8_t channels);
38void qmfs_end(qmfs_info *qmfs); 38void qmfs_end(qmfs_info *qmfs);
39 39
40void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, 40void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
41 qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx); 41 qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx);
42void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 42void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
43 real_t *output); 43 real_t *output);
44void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64], 44void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
45 real_t *output); 45 real_t *output);
46 46
47 47