summaryrefslogtreecommitdiff
path: root/apps/codecs/libfaad
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-05-11 18:52:05 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-05-11 18:52:05 +0000
commit0e7c04e57d48ae5b9d6cb23c58a6e6f0e15c306f (patch)
treede66ecc90e00e54850d373cb4156a59139b45b88 /apps/codecs/libfaad
parentdf7deee00f7e092db33f2c4d8ea5d566984c1ec2 (diff)
downloadrockbox-0e7c04e57d48ae5b9d6cb23c58a6e6f0e15c306f.zip
rockbox-0e7c04e57d48ae5b9d6cb23c58a6e6f0e15c306f.tar.gz
rockbox-0e7c04e57d48ae5b9d6cb23c58a6e6f0e15c306f.tar.bz2
rockbox-0e7c04e57d48ae5b9d6cb23c58a6e6f0e15c306f.tar.xz
libfaad: Move PS related variables to sbr_info struct. This allows dynamic allocation including error handling.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29857 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libfaad')
-rw-r--r--apps/codecs/libfaad/ps_dec.c43
-rw-r--r--apps/codecs/libfaad/ps_dec.h15
-rw-r--r--apps/codecs/libfaad/sbr_dec.c5
-rw-r--r--apps/codecs/libfaad/sbr_dec.h2
-rw-r--r--apps/codecs/libfaad/sbr_syntax.c6
5 files changed, 26 insertions, 45 deletions
diff --git a/apps/codecs/libfaad/ps_dec.c b/apps/codecs/libfaad/ps_dec.c
index 2c7e5fd..3fed4e6 100644
--- a/apps/codecs/libfaad/ps_dec.c
+++ b/apps/codecs/libfaad/ps_dec.c
@@ -145,26 +145,10 @@ static const uint16_t map_group2bk34[32+18] =
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33
};
-/* type definitions */
-typedef struct
-{
- uint8_t frame_len;
- uint8_t resolution20[3];
- uint8_t resolution34[5];
-
- qmf_t work[32+12];
- qmf_t buffer[5][32];
- qmf_t temp[32][12];
-} hyb_info;
-
-
-/* static variables */
-static hyb_info s_hyb_info;
-static ps_info s_ps_info;
/* static function declarations */
static void ps_data_decode(ps_info *ps);
-static hyb_info *hybrid_init(void);
+static void hybrid_init(hyb_info *hyb);
static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
qmf_t *buffer, qmf_t X_hybrid[32][12]);
static INLINE void DCT3_4_unscaled(real_t *y, real_t *x);
@@ -200,10 +184,8 @@ static void ps_mix_phase(ps_info *ps,
/* */
-static hyb_info *hybrid_init()
+static void hybrid_init(hyb_info *hyb)
{
- hyb_info *hyb = &s_hyb_info;
-
hyb->resolution34[0] = 12;
hyb->resolution34[1] = 8;
hyb->resolution34[2] = 4;
@@ -219,8 +201,6 @@ static hyb_info *hybrid_init()
memset(hyb->work , 0, sizeof(hyb->work));
memset(hyb->buffer, 0, sizeof(hyb->buffer));
memset(hyb->temp , 0, sizeof(hyb->temp));
-
- return hyb;
}
/* real filter, size 2 */
@@ -1815,16 +1795,12 @@ static void ps_mix_phase(ps_info *ps,
}
}
-ps_info *ps_init(uint8_t sr_index)
+void ps_init(ps_info *ps)
{
uint8_t i;
uint8_t short_delay_band;
- ps_info *ps = &s_ps_info;
- memset(ps, 0, sizeof(ps_info));
-
- (void)sr_index;
- ps->hyb = hybrid_init();
+ hybrid_init(&ps->hyb);
ps->ps_data_available = 0;
@@ -1905,8 +1881,6 @@ ps_info *ps_init(uint8_t sr_index)
RE(ps->opd_prev[i][1]) = 0;
IM(ps->opd_prev[i][1]) = 0;
}
-
- return ps;
}
/* main Parametric Stereo decoding function */
@@ -1944,8 +1918,7 @@ uint8_t ps_decode(ps_info *ps,
/* Perform further analysis on the lowest subbands to get a higher
* frequency resolution
*/
- hybrid_analysis((hyb_info*)ps->hyb, X_left, X_hybrid_left,
- ps->use34hybrid_bands);
+ hybrid_analysis(&ps->hyb, X_left, X_hybrid_left, ps->use34hybrid_bands);
/* decorrelate mono signal */
ps_decorrelate(ps, X_left, X_right, X_hybrid_left, X_hybrid_right);
@@ -1954,11 +1927,9 @@ uint8_t ps_decode(ps_info *ps,
ps_mix_phase(ps, X_left, X_right, X_hybrid_left, X_hybrid_right);
/* hybrid synthesis, to rebuild the SBR QMF matrices */
- hybrid_synthesis((hyb_info*)ps->hyb, X_left, X_hybrid_left,
- ps->use34hybrid_bands);
+ hybrid_synthesis(&ps->hyb, X_left, X_hybrid_left, ps->use34hybrid_bands);
- hybrid_synthesis((hyb_info*)ps->hyb, X_right, X_hybrid_right,
- ps->use34hybrid_bands);
+ hybrid_synthesis(&ps->hyb, X_right, X_hybrid_right, ps->use34hybrid_bands);
return 0;
}
diff --git a/apps/codecs/libfaad/ps_dec.h b/apps/codecs/libfaad/ps_dec.h
index 9c51e6b..14e4bd5 100644
--- a/apps/codecs/libfaad/ps_dec.h
+++ b/apps/codecs/libfaad/ps_dec.h
@@ -43,6 +43,17 @@ extern "C" {
typedef struct
{
+ uint8_t frame_len;
+ uint8_t resolution20[3];
+ uint8_t resolution34[5];
+
+ qmf_t work[32+12];
+ qmf_t buffer[5][32];
+ qmf_t temp[32][12];
+} hyb_info;
+
+typedef struct
+{
/* bitstream parameters */
uint8_t enable_iid;
uint8_t enable_icc;
@@ -89,7 +100,7 @@ typedef struct
uint8_t header_read;
/* hybrid filterbank parameters */
- void *hyb;
+ hyb_info hyb;
uint8_t use34hybrid_bands;
/**/
@@ -137,7 +148,7 @@ typedef struct
uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header);
/* ps_dec.c */
-ps_info *ps_init(uint8_t sr_index);
+void ps_init(ps_info *ps);
uint8_t ps_decode(ps_info *ps,
qmf_t X_left[MAX_NTSRPS][64],
diff --git a/apps/codecs/libfaad/sbr_dec.c b/apps/codecs/libfaad/sbr_dec.c
index 678ebfe..e2f6e4e 100644
--- a/apps/codecs/libfaad/sbr_dec.c
+++ b/apps/codecs/libfaad/sbr_dec.c
@@ -95,6 +95,9 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele,
#endif
memset(sbr, 0, sizeof(sbr_info));
+ /* initialize PS variables */
+ ps_init(&sbr->ps);
+
/* Allocate XLR temporary variable. Use static allocation if either
* FAAD_STATIC_ALLOC is set or XLR fits to IRAM. */
#if defined(FAAD_STATIC_ALLOC) || defined(FAAD_HAVE_XLR_IN_IRAM)
@@ -556,7 +559,7 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ
} else {
#endif
#ifdef PS_DEC
- ps_decode(sbr->ps, p_XLR->X_L, p_XLR->X_R);
+ ps_decode(&sbr->ps, p_XLR->X_L, p_XLR->X_R);
#endif
#ifdef DRM_PS
}
diff --git a/apps/codecs/libfaad/sbr_dec.h b/apps/codecs/libfaad/sbr_dec.h
index 1a1f5b9..89fe72b 100644
--- a/apps/codecs/libfaad/sbr_dec.h
+++ b/apps/codecs/libfaad/sbr_dec.h
@@ -176,7 +176,7 @@ typedef struct
uint8_t tHFAdj;
#ifdef PS_DEC
- ps_info *ps;
+ ps_info ps;
#endif
#if (defined(PS_DEC) || defined(DRM_PS))
uint8_t ps_used;
diff --git a/apps/codecs/libfaad/sbr_syntax.c b/apps/codecs/libfaad/sbr_syntax.c
index eff26e9..519a37b 100644
--- a/apps/codecs/libfaad/sbr_syntax.c
+++ b/apps/codecs/libfaad/sbr_syntax.c
@@ -826,11 +826,7 @@ static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr,
{
#ifdef PS_DEC
case EXTENSION_ID_PS:
- if (!sbr->ps)
- {
- sbr->ps = ps_init(get_sr_index(sbr->sample_rate));
- }
- ret = ps_data(sbr->ps, ld, &header);
+ ret = ps_data(&sbr->ps, ld, &header);
/* enable PS if and only if: a header has been decoded */
if (sbr->ps_used == 0 && header == 1)