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
This commit is contained in:
parent
df7deee00f
commit
0e7c04e57d
5 changed files with 26 additions and 45 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,17 @@ extern "C" {
|
|||
|
||||
#define MAX_NTSRPS 38 /* max number_time_slots * rate + 6 (delay) */
|
||||
|
||||
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 */
|
||||
|
@ -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],
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue