📄 syntax.c
字号:
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
}
}
else
ics->predictor_data_present = 0;
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;
}
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);
#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
while (count > 0)
{
count -= extension_payload(ld, drc, count);
}
#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
DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
}
}
}
}
}
}
#endif
#ifdef SCALABLE_DEC
/* Table 4.4.13 ASME */
void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
bitfile *ld, program_config *pce, drc_info *drc)
{
uint8_t retval = 0;
uint8_t channels = hDecoder->fr_channels = 0;
uint8_t ch;
uint8_t this_layer_stereo = (hDecoder->channelConfiguration > 1) ? 1 : 0;
element cpe = {0};
ic_stream *ics1 = &(cpe.ics1);
ic_stream *ics2 = &(cpe.ics2);
int16_t *spec_data;
hDecoder->fr_ch_ele = 0;
hInfo->error = aac_scalable_main_header(hDecoder, ics1, ics2, ld, this_layer_stereo);
if (hInfo->error > 0)
return;
cpe.common_window = 1;
if (this_layer_stereo)
{
hDecoder->element_id[0] = ID_CPE;
if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
hDecoder->element_output_channels[hDecoder->fr_ch_ele] = 2;
} else {
hDecoder->element_id[0] = ID_SCE;
}
for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++)
{
ic_stream *ics;
if (ch == 0)
{
ics = ics1;
spec_data = spec_data1;
} else {
ics = ics2;
spec_data = spec_data2;
}
hInfo->error = individual_channel_stream(hDecoder, &cpe, ld, ics, 1, spec_data);
if (hInfo->error > 0)
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -