summaryrefslogtreecommitdiffstats
path: root/apps
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 /apps
parent22719955179d95279474913ccadd4c1a6efceca6 (diff)
downloadrockbox-15e9053afbcb6f4b0b42739197a7eca40007e093.tar.gz
rockbox-15e9053afbcb6f4b0b42739197a7eca40007e093.tar.bz2
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
Diffstat (limited to 'apps')
-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)
}
}
-static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t rateselect)
+static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[MAX_NTSRPS][64], uint8_t rateselect)
{
uint8_t s, b, k;
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
ps->delay_buf_index_ser[k] = temp_delay_ser[k];
}
-static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64])
+static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64])
{
uint8_t s, b, ifreq, qclass;
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
}
}
-static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64])
+static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64])
{
uint8_t s, b, qclass, ifreq;
real_t tmp, coeff1, coeff2;
@@ -924,7 +928,9 @@ void drm_ps_free(drm_ps_info *ps)
}
/* main DRM PS decoding function */
-uint8_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])
+uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64])
{
uint8_t rateselect = (samplerate >= 24000);
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);
drm_ps_info *drm_ps_init(void);
void drm_ps_free(drm_ps_info *ps);
-uint8_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]);
+uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64]);
#ifdef __cplusplus
}
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);
static void map34indexto20(int8_t *index, uint8_t bins);
#endif
static void ps_data_decode(ps_info *ps);
-static void ps_decorrelate(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64],
- qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]);
-static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64],
- qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]);
+static void ps_decorrelate(ps_info *ps,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64],
+ qmf_t X_hybrid_left[32][32],
+ qmf_t X_hybrid_right[32][32]);
+static void ps_mix_phase(ps_info *ps,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64],
+ qmf_t X_hybrid_left[32][32],
+ qmf_t X_hybrid_right[32][32]);
/* */
@@ -1027,8 +1033,11 @@ static void ps_data_decode(ps_info *ps)
}
/* decorrelate the mono signal using an allpass filter */
-static void ps_decorrelate(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64],
- qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32])
+static void ps_decorrelate(ps_info *ps,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64],
+ qmf_t X_hybrid_left[32][32],
+ qmf_t X_hybrid_right[32][32])
{
uint8_t gr, n, m, bk;
uint8_t temp_delay = 0;
@@ -1423,8 +1432,11 @@ static const real_t ipdopd_sin_tab[] = {
FRAC_CONST(-0.000000000000000)
};
-static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64],
- qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32])
+static void ps_mix_phase(ps_info *ps,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64],
+ qmf_t X_hybrid_left[32][32],
+ qmf_t X_hybrid_right[32][32])
{
uint8_t n;
uint8_t gr;
@@ -1939,13 +1951,15 @@ ps_info *ps_init(uint8_t sr_index)
}
/* main Parametric Stereo decoding function */
-uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
+uint8_t ps_decode(ps_info *ps,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64])
{
static qmf_t X_hybrid_left[32][32];
static qmf_t X_hybrid_right[32][32];
- memset(&X_hybrid_left,0,sizeof(X_hybrid_left));
- memset(&X_hybrid_right,0,sizeof(X_hybrid_right));
+ memset(&X_hybrid_left , 0, sizeof(X_hybrid_left));
+ memset(&X_hybrid_right, 0, sizeof(X_hybrid_right));
/* delta decoding of the bitstream data */
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" {
#define MAX_PS_ENVELOPES 5
#define NO_ALLPASS_LINKS 3
+#define MAX_NTSRPS 38 /* max number_time_slots * rate + 6 (delay) */
+
typedef struct
{
/* bitstream parameters */
@@ -138,7 +140,9 @@ uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header);
ps_info *ps_init(uint8_t sr_index);
void ps_free(ps_info *ps);
-uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]);
+uint8_t ps_decode(ps_info *ps,
+ qmf_t X_left[MAX_NTSRPS][64],
+ qmf_t X_right[MAX_NTSRPS][64]);
#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 @@
/* globals */
-static qmf_t X_left [MAX_NTSRHFG][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
-static qmf_t X_right[MAX_NTSRHFG][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
+#if (defined(PS_DEC) || defined(DRM_PS))
+/* In case of PS_DEC or DRM_PS we need larger buffer data when calling
+ * ps_decode() or drm_ps_decode(). */
+static qmf_t X_left [MAX_NTSRPS][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
+static qmf_t X_right[MAX_NTSRPS][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
+#else
+/* No PS functions called. Keep using MAX_NTSR as array size. */
+static qmf_t X_left [MAX_NTSR][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
+static qmf_t X_right[MAX_NTSR][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
+#endif
/* 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" {
#include "drm_dec.h"
#endif
-/* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */
-#define MAX_NTSRHFG 40
+#define MAX_NTSRHFG 40 /* maximum of number_time_slots * rate + HFGen. 16*2+8 */
#define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */
/* 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)
}
void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
- qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx)
+ qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx)
{
real_t u[64] MEM_ALIGN_ATTR;
#ifndef SBR_LOW_POWER
@@ -224,7 +224,7 @@ void qmfs_end(qmfs_info *qmfs)
#ifdef SBR_LOW_POWER
-void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
real_t *output)
{
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
}
}
-void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
real_t *output)
{
real_t x[64] MEM_ALIGN_ATTR;
@@ -398,7 +398,7 @@ static const complex_t qmf32_pre_twiddle[] =
(MUL_F(QMF_IM(X[l][k]), RE(qmf32_pre_twiddle[k])) + \
MUL_F(QMF_RE(X[l][k]), IM(qmf32_pre_twiddle[k])))
-void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
real_t *output)
{
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
}
}
-void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
real_t *output)
{
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);
void qmfs_end(qmfs_info *qmfs);
void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
- qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx);
-void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+ qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx);
+void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
real_t *output);
-void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
real_t *output);