📄 syntax.c
字号:
hDecoder->internal_channel[channels] = channels;
hDecoder->internal_channel[channels+1] = channels+1;
}
hDecoder->fr_channels += 2;
hDecoder->fr_ch_ele++;
}
void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
bitfile *ld, program_config *pce, drc_info *drc)
{
uint8_t id_syn_ele;
hDecoder->fr_channels = 0;
hDecoder->fr_ch_ele = 0;
hDecoder->first_syn_ele = 25;
hDecoder->has_lfe = 0;
#ifdef ERROR_RESILIENCE
if (hDecoder->object_type < ER_OBJECT_START)
{
#endif
/* Table 4.4.3: raw_data_block() */
while ((id_syn_ele = (uint8_t)faad_getbits(ld, LEN_SE_ID
DEBUGVAR(1,4,"NeAACDecDecode(): id_syn_ele"))) != ID_END)
{
switch (id_syn_ele) {
case ID_SCE:
if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
if (hInfo->error > 0)
return;
break;
case ID_CPE:
if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
decode_cpe(hDecoder, hInfo, ld, id_syn_ele);
if (hInfo->error > 0)
return;
break;
case ID_LFE:
hDecoder->has_lfe++;
decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
if (hInfo->error > 0)
return;
break;
case ID_CCE: /* not implemented yet, but skip the bits */
#ifdef COUPLING_DEC
hInfo->error = coupling_channel_element(hDecoder, ld);
#else
hInfo->error = 6;
#endif
if (hInfo->error > 0)
return;
break;
case ID_DSE:
data_stream_element(hDecoder, ld);
break;
case ID_PCE:
/* 14496-4: 5.6.4.1.2.1.3: */
/* program_configuration_element()'s in access units shall be ignored */
program_config_element(pce, ld);
//if ((hInfo->error = program_config_element(pce, ld)) > 0)
// return;
//hDecoder->pce_set = 1;
break;
case ID_FIL:
/* one sbr_info describes a channel_element not a channel! */
/* if we encounter SBR data here: error */
/* SBR data will be read directly in the SCE/LFE/CPE element */
if ((hInfo->error = fill_element(hDecoder, ld, drc
#ifdef SBR_DEC
, INVALID_SBR_ELEMENT
#endif
)) > 0)
return;
break;
}
}
#ifdef ERROR_RESILIENCE
} else {
/* Table 262: er_raw_data_block() */
switch (hDecoder->channelConfiguration)
{
case 1:
decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
if (hInfo->error > 0)
return;
break;
case 2:
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
if (hInfo->error > 0)
return;
break;
case 3:
decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
if (hInfo->error > 0)
return;
break;
case 4:
decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
if (hInfo->error > 0)
return;
break;
case 5:
decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
if (hInfo->error > 0)
return;
break;
case 6:
decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE);
if (hInfo->error > 0)
return;
break;
case 7: /* 8 channels */
decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
decode_cpe(hDecoder, hInfo, ld, ID_CPE);
decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE);
if (hInfo->error > 0)
return;
break;
default:
hInfo->error = 7;
return;
}
#if 0
cnt = bits_to_decode() / 8;
while (cnt >= 1)
{
cnt -= extension_payload(cnt);
}
#endif
}
#endif
/* new in corrigendum 14496-3:2002 */
#ifdef DRM
if (hDecoder->object_type != DRM_ER_LC)
#endif
{
faad_byte_align(ld);
}
return;
}
/* Table 4.4.4 and */
/* Table 4.4.9 */
static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channel, uint8_t *tag)
{
uint8_t retval = 0;
ic_stream *ics = &hDecoder->ics1;
hDecoder->common_window = 0;
hDecoder->element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG
DEBUGVAR(1,38,"single_lfe_channel_element(): element_instance_tag"));
*tag = hDecoder->element_instance_tag;
hDecoder->channel = channel;
hDecoder->paired_channel = -1;
retval = individual_channel_stream(hDecoder, ld, ics, 0, hDecoder->d.spec_data[0]);
if (retval > 0)
return retval;
#ifdef SBR_DEC
/* check if next bitstream element is a fill element */
/* if so, read it now so SBR decoding can be done in case of a file with SBR */
if (faad_showbits(ld, LEN_SE_ID) == ID_FIL)
{
faad_flushbits(ld, LEN_SE_ID);
/* one sbr_info describes a channel_element not a channel! */
if ((retval = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0)
{
return retval;
}
}
#endif
/* noiseless coding is done, spectral reconstruction is done now */
retval = reconstruct_single_channel(hDecoder, ics);
if (retval > 0)
return retval;
return 0;
}
static void adjustptr(ic_stream* dst,ic_stream* src)
{
dst->group_end = (ic_group*)((char*)dst->group + ((char*)src->group_end - (char*)src->group));
}
/* Table 4.4.5 */
static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channels, uint8_t *tag)
{
ic_stream *ics1 = &hDecoder->ics1;
ic_stream *ics2 = &hDecoder->ics2;
uint8_t result;
hDecoder->channel = channels;
hDecoder->paired_channel = channels+1;
hDecoder->element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG
DEBUGVAR(1,39,"channel_pair_element(): element_instance_tag"));
*tag = hDecoder->element_instance_tag;
if ((hDecoder->common_window = faad_get1bit(ld
DEBUGVAR(1,40,"channel_pair_element(): common_window"))) & 1)
{
/* both channels have common ics information */
if ((result = ics_info(hDecoder, ics1, ld, hDecoder->common_window)) > 0)
return result;
ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,41,"channel_pair_element(): ms_mask_present"));
if (ics1->ms_mask_present == 1)
{
uint8_t sfb;
ic_group *g;
for (g = ics1->group; g != ics1->group_end; g++)
{
for (sfb = 0; sfb < ics1->max_sfb; sfb++)
{
g->sfb[sfb].ms_used = faad_get1bit(ld
DEBUGVAR(1,42,"channel_pair_element(): faad_get1bit"));
}
}
}
#ifdef ERROR_RESILIENCE
if ((hDecoder->object_type >= ER_OBJECT_START) && (ics1->predictor_data_present))
{
if ((
#ifdef LTP_DEC
ics1->ltp.data_present =
#endif
faad_get1bit(ld DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1)
{
#ifdef LTP_DEC
if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp), ld)) > 0)
{
return result;
}
#else
return 26;
#endif
}
}
#endif
memcpy(ics2, ics1, sizeof(ic_stream));
adjustptr(ics2, ics1);
} else {
ics1->ms_mask_present = 0;
}
if ((result = individual_channel_stream(hDecoder, ld, ics1,
0, hDecoder->d.spec_data[0])) > 0)
{
return result;
}
#ifdef ERROR_RESILIENCE
if (hDecoder->common_window && (hDecoder->object_type >= ER_OBJECT_START) &&
(ics1->predictor_data_present))
{
if ((
#ifdef LTP_DEC
ics1->ltp2.data_present =
#endif
faad_get1bit(ld DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1)
{
#ifdef LTP_DEC
if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp2), ld)) > 0)
{
return result;
}
#else
return 26;
#endif
}
}
#endif
if ((result = individual_channel_stream(hDecoder, ld, ics2,
0, hDecoder->d.spec_data[1])) > 0)
{
return result;
}
#ifdef SBR_DEC
/* check if next bitstream element is a fill element */
/* if so, read it now so SBR decoding can be done in case of a file with SBR */
if (faad_showbits(ld, LEN_SE_ID) == ID_FIL)
{
faad_flushbits(ld, LEN_SE_ID);
/* one sbr_info describes a channel_element not a channel! */
if ((result = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0)
{
return result;
}
}
#endif
/* noiseless coding is done, spectral reconstruction is done now */
if ((result = reconstruct_channel_pair(hDecoder, ics1, ics2)) > 0)
{
return result;
}
return 0;
}
/* Table 4.4.6 */
static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld,
uint8_t common_window)
{
uint8_t retval = 0;
/* ics->ics_reserved_bit = */ faad_get1bit(ld
DEBUGVAR(1,43,"ics_info(): ics_reserved_bit"));
ics->window_sequence = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,44,"ics_info(): window_sequence"));
ics->window_shape = faad_get1bit(ld
DEBUGVAR(1,45,"ics_info(): window_shape"));
if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
{
ics->max_sfb = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,46,"ics_info(): max_sfb (short)"));
ics->scale_factor_grouping = (uint8_t)faad_getbits(ld, 7
DEBUGVAR(1,47,"ics_info(): scale_factor_grouping"));
} else {
ics->max_sfb = (uint8_t)faad_getbits(ld, 6
DEBUGVAR(1,48,"ics_info(): max_sfb (long)"));
}
/* get the grouping information */
if ((retval = window_grouping_info(hDecoder, ics)) > 0)
return retval;
/* should be an error */
/* check the range of max_sfb */
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)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -