forked from len0rd/rockbox
Implement error handling for libfaad's memory allocation. Do not allocate PS related types dynamically anymore to minimize code changes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29854 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
78b0f94c76
commit
03e23d1113
7 changed files with 66 additions and 35 deletions
|
|
@ -346,6 +346,11 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer,
|
|||
hDecoder->time_out[i] = s_time_buf_2048[i];
|
||||
#else
|
||||
hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t));
|
||||
if (hDecoder->time_out[i] == NULL)
|
||||
{
|
||||
/* could not allocate memory */
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
memset(hDecoder->time_out[i], 0, 2*FRAME_LEN);
|
||||
hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
|
||||
|
|
@ -469,6 +474,11 @@ int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer,
|
|||
hDecoder->time_out[i] = s_time_buf_2048[i];
|
||||
#else
|
||||
hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t));
|
||||
if (hDecoder->time_out[i] == NULL)
|
||||
{
|
||||
/* could not allocate memory */
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
memset(hDecoder->time_out[i], 0, 2*FRAME_LEN);
|
||||
hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ char *err_msg[] = {
|
|||
"Unexpected fill element with SBR data",
|
||||
"Not all elements were provided with SBR data",
|
||||
"LTP decoding not available",
|
||||
"Output data buffer too small"
|
||||
"Output data buffer too small",
|
||||
"Could not allocate enough memory"
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -159,10 +159,8 @@ typedef struct
|
|||
|
||||
|
||||
/* static variables */
|
||||
#ifdef FAAD_STATIC_ALLOC
|
||||
static hyb_info s_hyb_info;
|
||||
static ps_info s_ps_info;
|
||||
#endif
|
||||
|
||||
/* static function declarations */
|
||||
static void ps_data_decode(ps_info *ps);
|
||||
|
|
@ -204,11 +202,7 @@ static void ps_mix_phase(ps_info *ps,
|
|||
|
||||
static hyb_info *hybrid_init()
|
||||
{
|
||||
#ifdef FAAD_STATIC_ALLOC
|
||||
hyb_info *hyb = &s_hyb_info;
|
||||
#else
|
||||
hyb_info *hyb = (hyb_info*)faad_malloc(sizeof(hyb_info));
|
||||
#endif
|
||||
|
||||
hyb->resolution34[0] = 12;
|
||||
hyb->resolution34[1] = 8;
|
||||
|
|
@ -1826,11 +1820,7 @@ ps_info *ps_init(uint8_t sr_index)
|
|||
uint8_t i;
|
||||
uint8_t short_delay_band;
|
||||
|
||||
#ifdef FAAD_STATIC_ALLOC
|
||||
ps_info *ps = &s_ps_info;
|
||||
#else
|
||||
ps_info *ps = (ps_info*)faad_malloc(sizeof(ps_info));
|
||||
#endif
|
||||
memset(ps, 0, sizeof(ps_info));
|
||||
|
||||
(void)sr_index;
|
||||
|
|
|
|||
|
|
@ -73,20 +73,25 @@ static void sbr_save_matrix(sbr_info *sbr, uint8_t ch);
|
|||
|
||||
|
||||
sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele,
|
||||
uint32_t sample_rate, uint8_t downSampledSBR
|
||||
#ifdef DRM
|
||||
, uint8_t IsDRM
|
||||
#endif
|
||||
)
|
||||
uint32_t sample_rate, uint8_t downSampledSBR,
|
||||
uint8_t IsDRM)
|
||||
{
|
||||
(void)downSampledSBR;
|
||||
#ifndef DRM
|
||||
(void)IsDRM;
|
||||
#endif
|
||||
|
||||
/* Allocate sbr_info. */
|
||||
#if defined(FAAD_STATIC_ALLOC)
|
||||
sbr_info *sbr = &s_sbr[id_ele];
|
||||
#else
|
||||
(void)id_ele;
|
||||
sbr_info *sbr =(sbr_info*)faad_malloc(sizeof(sbr_info));
|
||||
sbr_info *sbr = (sbr_info*)faad_malloc(sizeof(sbr_info));
|
||||
if (sbr == NULL)
|
||||
{
|
||||
/* could not allocate memory */
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
memset(sbr, 0, sizeof(sbr_info));
|
||||
|
||||
|
|
@ -95,7 +100,12 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele,
|
|||
#if defined(FAAD_STATIC_ALLOC) || defined(FAAD_HAVE_XLR_IN_IRAM)
|
||||
p_XLR = &s_XLR;
|
||||
#else
|
||||
p_XLR =(XLR_t*)faad_malloc(sizeof(XLR_t));
|
||||
p_XLR = (XLR_t*)faad_malloc(sizeof(XLR_t));
|
||||
if (p_XLR == NULL)
|
||||
{
|
||||
/* could not allocate memory */
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
memset(p_XLR, 0, sizeof(XLR_t));
|
||||
|
||||
|
|
|
|||
|
|
@ -222,11 +222,8 @@ typedef struct
|
|||
} sbr_info;
|
||||
|
||||
sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele,
|
||||
uint32_t sample_rate, uint8_t downSampledSBR
|
||||
#ifdef DRM
|
||||
, uint8_t IsDRM
|
||||
#endif
|
||||
);
|
||||
uint32_t sample_rate, uint8_t downSampledSBR,
|
||||
uint8_t IsDRM);
|
||||
|
||||
uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
|
||||
const uint8_t just_seeked, const uint8_t downSampledSBR);
|
||||
|
|
|
|||
|
|
@ -808,11 +808,14 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
|
|||
hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength,
|
||||
hDecoder->element_id[ele], ele,
|
||||
2*get_sample_rate(hDecoder->sf_index),
|
||||
hDecoder->downSampledSBR
|
||||
#ifdef DRM
|
||||
, 0
|
||||
hDecoder->downSampledSBR, 0);
|
||||
#ifndef FAAD_STATIC_ALLOC
|
||||
if (hDecoder->sbr[ele] == NULL)
|
||||
{
|
||||
/* could not allocate memory */
|
||||
return 28;
|
||||
}
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
|
||||
|
|
@ -1058,11 +1061,14 @@ uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_st
|
|||
hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength,
|
||||
hDecoder->element_id[ele], ele,
|
||||
2*get_sample_rate(hDecoder->sf_index),
|
||||
hDecoder->downSampledSBR
|
||||
#ifdef DRM
|
||||
, 0
|
||||
hDecoder->downSampledSBR, 0);
|
||||
#ifndef FAAD_STATIC_ALLOC
|
||||
if (hDecoder->sbr[ele] == NULL)
|
||||
{
|
||||
/* could not allocate memory */
|
||||
return 28;
|
||||
}
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
|
||||
|
|
|
|||
|
|
@ -1031,11 +1031,14 @@ static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc
|
|||
hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength,
|
||||
hDecoder->element_id[sbr_ele], sbr_ele,
|
||||
2*get_sample_rate(hDecoder->sf_index),
|
||||
hDecoder->downSampledSBR
|
||||
#ifdef DRM
|
||||
, 0
|
||||
hDecoder->downSampledSBR, 0);
|
||||
#ifndef FAAD_STATIC_ALLOC
|
||||
if (hDecoder->sbr[sbr_ele] == NULL)
|
||||
{
|
||||
/* could not allocate memory */
|
||||
return 28;
|
||||
}
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
hDecoder->sbr_present_flag = 1;
|
||||
|
|
@ -1249,10 +1252,24 @@ void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo
|
|||
{
|
||||
hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, hDecoder->element_id[0],
|
||||
2*get_sample_rate(hDecoder->sf_index), 0 /* ds SBR */, 1);
|
||||
#ifndef FAAD_STATIC_ALLOC
|
||||
if (hDecoder->sbr[0] == NULL)
|
||||
{
|
||||
/* could not allocate memory */
|
||||
hInfo->error = 28;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Reverse bit reading of SBR data in DRM audio frame */
|
||||
revbuffer = (uint8_t*)faad_malloc(buffer_size*sizeof(uint8_t));
|
||||
if (revbuffer == NULL)
|
||||
{
|
||||
/* could not allocate memory */
|
||||
hInfo->error = 28;
|
||||
return;
|
||||
}
|
||||
prevbufstart = revbuffer;
|
||||
pbufend = &buffer[buffer_size - 1];
|
||||
for (i = 0; i < buffer_size; i++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue