📄 syntax.c
字号:
if (ics->max_sfb > ics->num_swb)
return 16;
if (ics->window_sequence != EIGHT_SHORT_SEQUENCE)
{
if ((ics->predictor_data_present = faad_get1bit(ld
DEBUGVAR(1,49,"ics_info(): predictor_data_present"))) & 1)
{
if (hDecoder->object_type == MAIN) /* MPEG2 style AAC predictor */
{
uint8_t sfb;
uint8_t limit = min(ics->max_sfb, max_pred_sfb(hDecoder->sf_index));
#ifdef MAIN_DEC
ics->pred.limit = limit;
#endif
if ((
#ifdef MAIN_DEC
ics->pred.predictor_reset =
#endif
faad_get1bit(ld DEBUGVAR(1,53,"ics_info(): pred.predictor_reset"))) & 1)
{
#ifdef MAIN_DEC
ics->pred.predictor_reset_group_number =
#endif
(uint8_t)faad_getbits(ld, 5 DEBUGVAR(1,54,"ics_info(): pred.predictor_reset_group_number"));
}
for (sfb = 0; sfb < limit; sfb++)
{
#ifdef MAIN_DEC
ics->pred.prediction_used[sfb] =
#endif
faad_get1bit(ld DEBUGVAR(1,55,"ics_info(): pred.prediction_used"));
}
}
#ifdef LTP_DEC
else { /* Long Term Prediction */
if (hDecoder->object_type < ER_OBJECT_START)
{
if ((ics->ltp.data_present = faad_get1bit(ld
DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
{
if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0)
{
return retval;
}
}
if (common_window)
{
if ((ics->ltp2.data_present = faad_get1bit(ld
DEBUGVAR(1,51,"ics_info(): ltp2.data_present"))) & 1)
{
if ((retval = ltp_data(hDecoder, ics, &(ics->ltp2), ld)) > 0)
{
return retval;
}
}
}
}
#ifdef ERROR_RESILIENCE
if (!common_window && (hDecoder->object_type >= ER_OBJECT_START))
{
if ((ics->ltp.data_present = faad_get1bit(ld
DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
{
ltp_data(hDecoder, ics, &(ics->ltp), ld);
}
}
#endif
}
#endif
}
}
return retval;
}
/* Table 4.4.7 */
static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld)
{
uint8_t i;
pul->number_pulse = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,56,"pulse_data(): number_pulse"));
pul->pulse_start_sfb = (uint8_t)faad_getbits(ld, 6
DEBUGVAR(1,57,"pulse_data(): pulse_start_sfb"));
/* check the range of pulse_start_sfb */
if (pul->pulse_start_sfb > ics->num_swb)
return 16;
for (i = 0; i < pul->number_pulse+1; i++)
{
pul->pulse_offset[i] = (uint8_t)faad_getbits(ld, 5
DEBUGVAR(1,58,"pulse_data(): pulse_offset"));
#if 0
printf("%d\n", pul->pulse_offset[i]);
#endif
pul->pulse_amp[i] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,59,"pulse_data(): pulse_amp"));
#if 0
printf("%d\n", pul->pulse_amp[i]);
#endif
}
return 0;
}
#ifdef COUPLING_DEC
/* Table 4.4.8: Currently just for skipping the bits... */
static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld)
{
uint8_t c, result = 0;
uint8_t ind_sw_cce_flag = 0;
uint8_t num_gain_element_lists = 0;
uint8_t num_coupled_elements = 0;
element el_empty = {0};
ic_stream ics_empty = {0};
int16_t sh_data[1024];
c = faad_getbits(ld, LEN_TAG
DEBUGVAR(1,900,"coupling_channel_element(): element_instance_tag"));
ind_sw_cce_flag = faad_get1bit(ld
DEBUGVAR(1,901,"coupling_channel_element(): ind_sw_cce_flag"));
num_coupled_elements = faad_getbits(ld, 3
DEBUGVAR(1,902,"coupling_channel_element(): num_coupled_elements"));
for (c = 0; c < num_coupled_elements + 1; c++)
{
uint8_t cc_target_is_cpe, cc_target_tag_select;
num_gain_element_lists++;
cc_target_is_cpe = faad_get1bit(ld
DEBUGVAR(1,903,"coupling_channel_element(): cc_target_is_cpe"));
cc_target_tag_select = faad_getbits(ld, 4
DEBUGVAR(1,904,"coupling_channel_element(): cc_target_tag_select"));
if (cc_target_is_cpe)
{
uint8_t cc_l = faad_get1bit(ld
DEBUGVAR(1,905,"coupling_channel_element(): cc_l"));
uint8_t cc_r = faad_get1bit(ld
DEBUGVAR(1,906,"coupling_channel_element(): cc_r"));
if (cc_l && cc_r)
num_gain_element_lists++;
}
}
faad_get1bit(ld
DEBUGVAR(1,907,"coupling_channel_element(): cc_domain"));
faad_get1bit(ld
DEBUGVAR(1,908,"coupling_channel_element(): gain_element_sign"));
faad_getbits(ld, 2
DEBUGVAR(1,909,"coupling_channel_element(): gain_element_scale"));
if ((result = individual_channel_stream(hDecoder, &el_empty, ld, &ics_empty,
0, sh_data)) > 0)
{
return result;
}
/* IS not allowed in single channel */
if (ics->is_used)
return 32;
for (c = 1; c < num_gain_element_lists; c++)
{
uint8_t cge;
if (ind_sw_cce_flag)
{
cge = 1;
} else {
cge = faad_get1bit(ld
DEBUGVAR(1,910,"coupling_channel_element(): common_gain_element_present"));
}
if (cge)
{
huffman_scale_factor(ld);
} else {
uint8_t g, sfb;
for (g = 0; g < ics_empty.num_window_groups; g++)
{
for (sfb = 0; sfb < ics_empty.max_sfb; sfb++)
{
if (ics_empty.sfb_cb[g][sfb] != ZERO_HCB)
huffman_scale_factor(ld);
}
}
}
}
return 0;
}
#endif
/* Table 4.4.10 */
static uint16_t data_stream_element(NeAACDecHandle hDecoder, bitfile *ld)
{
uint8_t byte_aligned;
uint16_t i, count;
/* element_instance_tag = */ faad_getbits(ld, LEN_TAG
DEBUGVAR(1,60,"data_stream_element(): element_instance_tag"));
byte_aligned = faad_get1bit(ld
DEBUGVAR(1,61,"data_stream_element(): byte_aligned"));
count = (uint16_t)faad_getbits(ld, 8
DEBUGVAR(1,62,"data_stream_element(): count"));
if (count == 255)
{
count += (uint16_t)faad_getbits(ld, 8
DEBUGVAR(1,63,"data_stream_element(): extra count"));
}
if (byte_aligned)
faad_byte_align(ld);
for (i = 0; i < count; i++)
{
faad_getbits(ld, LEN_BYTE
DEBUGVAR(1,64,"data_stream_element(): data_stream_byte"));
}
return count;
}
/* Table 4.4.11 */
static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc
#ifdef SBR_DEC
,uint8_t sbr_ele
#endif
)
{
uint16_t count;
#ifdef SBR_DEC
uint8_t bs_extension_type;
#endif
count = (uint16_t)faad_getbits(ld, 4
DEBUGVAR(1,65,"fill_element(): count"));
if (count == 15)
{
count += (uint16_t)faad_getbits(ld, 8
DEBUGVAR(1,66,"fill_element(): extra count")) - 1;
}
if (count > 0)
{
#ifdef SBR_DEC
bs_extension_type = (uint8_t)faad_showbits(ld, 4);
if ((bs_extension_type == EXT_SBR_DATA) ||
(bs_extension_type == EXT_SBR_DATA_CRC))
{
if (sbr_ele == INVALID_SBR_ELEMENT)
return 24;
if (!hDecoder->sbr[sbr_ele])
{
hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength,
hDecoder->element_id[sbr_ele], 2*get_sample_rate(hDecoder->sf_index),
hDecoder->downSampledSBR
#ifdef DRM
, 0
#endif
);
}
hDecoder->sbr_present_flag = 1;
/* parse the SBR data */
hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count,
hDecoder->postSeekResetFlag);
#if 0
if (hDecoder->sbr[sbr_ele]->ret > 0)
{
printf("%s\n", NeAACDecGetErrorMessage(hDecoder->sbr[sbr_ele]->ret));
}
#endif
#if (defined(PS_DEC) || defined(DRM_PS))
if (hDecoder->sbr[sbr_ele]->ps_used)
{
hDecoder->ps_used[sbr_ele] = 1;
/* set element independent flag to 1 as well */
hDecoder->ps_used_global = 1;
}
#endif
} else {
#endif
#ifndef DRM
while (count > 0)
{
count -= extension_payload(ld, drc, count);
}
#else
return 30;
#endif
#ifdef SBR_DEC
}
#endif
}
return 0;
}
/* Table 4.4.12 */
#ifdef SSR_DEC
static void gain_control_data(bitfile *ld, ic_stream *ics)
{
uint8_t bd, wd, ad;
ssr_info *ssr = &(ics->ssr);
ssr->max_band = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,1000,"gain_control_data(): max_band"));
if (ics->window_sequence == ONLY_LONG_SEQUENCE)
{
for (bd = 1; bd <= ssr->max_band; bd++)
{
for (wd = 0; wd < 1; wd++)
{
ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
{
ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
}
}
}
} else if (ics->window_sequence == LONG_START_SEQUENCE) {
for (bd = 1; bd <= ssr->max_band; bd++)
{
for (wd = 0; wd < 2; wd++)
{
ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
{
ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
if (wd == 0)
{
ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
} else {
ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
}
}
}
}
} else if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) {
for (bd = 1; bd <= ssr->max_band; bd++)
{
for (wd = 0; wd < 8; wd++)
{
ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
{
ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
}
}
}
} else if (ics->window_sequence == LONG_STOP_SEQUENCE) {
for (bd = 1; bd <= ssr->max_band; bd++)
{
for (wd = 0; wd < 2; wd++)
{
ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
{
ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
if (wd == 0)
{
ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
} else {
ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -