summaryrefslogtreecommitdiff
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
parentdf7deee00f7e092db33f2c4d8ea5d566984c1ec2 (diff)
downloadrockbox-0e7c04e57d48ae5b9d6cb23c58a6e6f0e15c306f.tar.gz
rockbox-0e7c04e57d48ae5b9d6cb23c58a6e6f0e15c306f.zip
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
-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 2c7e5fdf47..3fed4e6a0a 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] =
145 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 145 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33
146}; 146};
147 147
148/* type definitions */
149typedef struct
150{
151 uint8_t frame_len;
152 uint8_t resolution20[3];
153 uint8_t resolution34[5];
154
155 qmf_t work[32+12];
156 qmf_t buffer[5][32];
157 qmf_t temp[32][12];
158} hyb_info;
159
160
161/* static variables */
162static hyb_info s_hyb_info;
163static ps_info s_ps_info;
164 148
165/* static function declarations */ 149/* static function declarations */
166static void ps_data_decode(ps_info *ps); 150static void ps_data_decode(ps_info *ps);
167static hyb_info *hybrid_init(void); 151static void hybrid_init(hyb_info *hyb);
168static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, 152static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
169 qmf_t *buffer, qmf_t X_hybrid[32][12]); 153 qmf_t *buffer, qmf_t X_hybrid[32][12]);
170static INLINE void DCT3_4_unscaled(real_t *y, real_t *x); 154static INLINE void DCT3_4_unscaled(real_t *y, real_t *x);
@@ -200,10 +184,8 @@ static void ps_mix_phase(ps_info *ps,
200/* */ 184/* */
201 185
202 186
203static hyb_info *hybrid_init() 187static void hybrid_init(hyb_info *hyb)
204{ 188{
205 hyb_info *hyb = &s_hyb_info;
206
207 hyb->resolution34[0] = 12; 189 hyb->resolution34[0] = 12;
208 hyb->resolution34[1] = 8; 190 hyb->resolution34[1] = 8;
209 hyb->resolution34[2] = 4; 191 hyb->resolution34[2] = 4;
@@ -219,8 +201,6 @@ static hyb_info *hybrid_init()
219 memset(hyb->work , 0, sizeof(hyb->work)); 201 memset(hyb->work , 0, sizeof(hyb->work));
220 memset(hyb->buffer, 0, sizeof(hyb->buffer)); 202 memset(hyb->buffer, 0, sizeof(hyb->buffer));
221 memset(hyb->temp , 0, sizeof(hyb->temp)); 203 memset(hyb->temp , 0, sizeof(hyb->temp));
222
223 return hyb;
224} 204}
225 205
226/* real filter, size 2 */ 206/* real filter, size 2 */
@@ -1815,16 +1795,12 @@ static void ps_mix_phase(ps_info *ps,
1815 } 1795 }
1816} 1796}
1817 1797
1818ps_info *ps_init(uint8_t sr_index) 1798void ps_init(ps_info *ps)
1819{ 1799{
1820 uint8_t i; 1800 uint8_t i;
1821 uint8_t short_delay_band; 1801 uint8_t short_delay_band;
1822 1802
1823 ps_info *ps = &s_ps_info; 1803 hybrid_init(&ps->hyb);
1824 memset(ps, 0, sizeof(ps_info));
1825
1826 (void)sr_index;
1827 ps->hyb = hybrid_init();
1828 1804
1829 ps->ps_data_available = 0; 1805 ps->ps_data_available = 0;
1830 1806
@@ -1905,8 +1881,6 @@ ps_info *ps_init(uint8_t sr_index)
1905 RE(ps->opd_prev[i][1]) = 0; 1881 RE(ps->opd_prev[i][1]) = 0;
1906 IM(ps->opd_prev[i][1]) = 0; 1882 IM(ps->opd_prev[i][1]) = 0;
1907 } 1883 }
1908
1909 return ps;
1910} 1884}
1911 1885
1912/* main Parametric Stereo decoding function */ 1886/* main Parametric Stereo decoding function */
@@ -1944,8 +1918,7 @@ uint8_t ps_decode(ps_info *ps,
1944 /* Perform further analysis on the lowest subbands to get a higher 1918 /* Perform further analysis on the lowest subbands to get a higher
1945 * frequency resolution 1919 * frequency resolution
1946 */ 1920 */
1947 hybrid_analysis((hyb_info*)ps->hyb, X_left, X_hybrid_left, 1921 hybrid_analysis(&ps->hyb, X_left, X_hybrid_left, ps->use34hybrid_bands);
1948 ps->use34hybrid_bands);
1949 1922
1950 /* decorrelate mono signal */ 1923 /* decorrelate mono signal */
1951 ps_decorrelate(ps, X_left, X_right, X_hybrid_left, X_hybrid_right); 1924 ps_decorrelate(ps, X_left, X_right, X_hybrid_left, X_hybrid_right);
@@ -1954,11 +1927,9 @@ uint8_t ps_decode(ps_info *ps,
1954 ps_mix_phase(ps, X_left, X_right, X_hybrid_left, X_hybrid_right); 1927 ps_mix_phase(ps, X_left, X_right, X_hybrid_left, X_hybrid_right);
1955 1928
1956 /* hybrid synthesis, to rebuild the SBR QMF matrices */ 1929 /* hybrid synthesis, to rebuild the SBR QMF matrices */
1957 hybrid_synthesis((hyb_info*)ps->hyb, X_left, X_hybrid_left, 1930 hybrid_synthesis(&ps->hyb, X_left, X_hybrid_left, ps->use34hybrid_bands);
1958 ps->use34hybrid_bands);
1959 1931
1960 hybrid_synthesis((hyb_info*)ps->hyb, X_right, X_hybrid_right, 1932 hybrid_synthesis(&ps->hyb, X_right, X_hybrid_right, ps->use34hybrid_bands);
1961 ps->use34hybrid_bands);
1962 1933
1963 return 0; 1934 return 0;
1964} 1935}
diff --git a/apps/codecs/libfaad/ps_dec.h b/apps/codecs/libfaad/ps_dec.h
index 9c51e6b4ad..14e4bd54e6 100644
--- a/apps/codecs/libfaad/ps_dec.h
+++ b/apps/codecs/libfaad/ps_dec.h
@@ -43,6 +43,17 @@ extern "C" {
43 43
44typedef struct 44typedef struct
45{ 45{
46 uint8_t frame_len;
47 uint8_t resolution20[3];
48 uint8_t resolution34[5];
49
50 qmf_t work[32+12];
51 qmf_t buffer[5][32];
52 qmf_t temp[32][12];
53} hyb_info;
54
55typedef struct
56{
46 /* bitstream parameters */ 57 /* bitstream parameters */
47 uint8_t enable_iid; 58 uint8_t enable_iid;
48 uint8_t enable_icc; 59 uint8_t enable_icc;
@@ -89,7 +100,7 @@ typedef struct
89 uint8_t header_read; 100 uint8_t header_read;
90 101
91 /* hybrid filterbank parameters */ 102 /* hybrid filterbank parameters */
92 void *hyb; 103 hyb_info hyb;
93 uint8_t use34hybrid_bands; 104 uint8_t use34hybrid_bands;
94 105
95 /**/ 106 /**/
@@ -137,7 +148,7 @@ typedef struct
137uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header); 148uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header);
138 149
139/* ps_dec.c */ 150/* ps_dec.c */
140ps_info *ps_init(uint8_t sr_index); 151void ps_init(ps_info *ps);
141 152
142uint8_t ps_decode(ps_info *ps, 153uint8_t ps_decode(ps_info *ps,
143 qmf_t X_left[MAX_NTSRPS][64], 154 qmf_t X_left[MAX_NTSRPS][64],
diff --git a/apps/codecs/libfaad/sbr_dec.c b/apps/codecs/libfaad/sbr_dec.c
index 678ebfe520..e2f6e4e9fc 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,
95#endif 95#endif
96 memset(sbr, 0, sizeof(sbr_info)); 96 memset(sbr, 0, sizeof(sbr_info));
97 97
98 /* initialize PS variables */
99 ps_init(&sbr->ps);
100
98 /* Allocate XLR temporary variable. Use static allocation if either 101 /* Allocate XLR temporary variable. Use static allocation if either
99 * FAAD_STATIC_ALLOC is set or XLR fits to IRAM. */ 102 * FAAD_STATIC_ALLOC is set or XLR fits to IRAM. */
100#if defined(FAAD_STATIC_ALLOC) || defined(FAAD_HAVE_XLR_IN_IRAM) 103#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
556 } else { 559 } else {
557#endif 560#endif
558#ifdef PS_DEC 561#ifdef PS_DEC
559 ps_decode(sbr->ps, p_XLR->X_L, p_XLR->X_R); 562 ps_decode(&sbr->ps, p_XLR->X_L, p_XLR->X_R);
560#endif 563#endif
561#ifdef DRM_PS 564#ifdef DRM_PS
562 } 565 }
diff --git a/apps/codecs/libfaad/sbr_dec.h b/apps/codecs/libfaad/sbr_dec.h
index 1a1f5b9b32..89fe72b7e9 100644
--- a/apps/codecs/libfaad/sbr_dec.h
+++ b/apps/codecs/libfaad/sbr_dec.h
@@ -176,7 +176,7 @@ typedef struct
176 uint8_t tHFAdj; 176 uint8_t tHFAdj;
177 177
178#ifdef PS_DEC 178#ifdef PS_DEC
179 ps_info *ps; 179 ps_info ps;
180#endif 180#endif
181#if (defined(PS_DEC) || defined(DRM_PS)) 181#if (defined(PS_DEC) || defined(DRM_PS))
182 uint8_t ps_used; 182 uint8_t ps_used;
diff --git a/apps/codecs/libfaad/sbr_syntax.c b/apps/codecs/libfaad/sbr_syntax.c
index eff26e9f46..519a37b137 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,
826 { 826 {
827#ifdef PS_DEC 827#ifdef PS_DEC
828 case EXTENSION_ID_PS: 828 case EXTENSION_ID_PS:
829 if (!sbr->ps) 829 ret = ps_data(&sbr->ps, ld, &header);
830 {
831 sbr->ps = ps_init(get_sr_index(sbr->sample_rate));
832 }
833 ret = ps_data(sbr->ps, ld, &header);
834 830
835 /* enable PS if and only if: a header has been decoded */ 831 /* enable PS if and only if: a header has been decoded */
836 if (sbr->ps_used == 0 && header == 1) 832 if (sbr->ps_used == 0 && header == 1)