📄 aac_dec_api_int.c
字号:
break;
case ID_CPE:
state_com->m_curr_win_shape[ch] = (state_com->m_cpe).streams[0].window_shape;
state_com->m_curr_win_sequence[ch] = (state_com->m_cpe).streams[0].window_sequence;
state_com->m_curr_win_shape[ch + 1] = (state_com->m_cpe).streams[1].window_shape;
state_com->m_curr_win_sequence[ch + 1] = (state_com->m_cpe).streams[1].window_sequence;
if (0 != (state_com->m_cpe).streams[0].pulse_data_present) {
ics_apply_pulse_I(&(state_com->m_cpe).streams[0]);
}
if (0 != (state_com->m_cpe).streams[1].pulse_data_present) {
ics_apply_pulse_I(&(state_com->m_cpe).streams[1]);
}
aacidec_ics_apply_scale_factors(&(state_com->m_cpe).streams[0], state->m_spectrum_data[ch]);
aacidec_ics_apply_scale_factors(&(state_com->m_cpe).streams[1],
state->m_spectrum_data[ch + 1]);
/* Joint stereo */
aacidec_cpe_apply_ms(&(state_com->m_cpe), state->m_spectrum_data[ch],
state->m_spectrum_data[ch + 1]);
aacidec_apply_pns(&(state_com->m_cpe).streams[0], &(state_com->m_cpe).streams[1],
state->m_spectrum_data[ch], state->m_spectrum_data[ch + 1], 2,
(state_com->m_cpe).ms_mask_present, (state_com->m_cpe).ms_used,
&(state_com->noiseState));
aacidec_cpe_apply_intensity(&(state_com->m_cpe), state->m_spectrum_data[ch],
state->m_spectrum_data[ch + 1]);
aacidec_ics_calc_tns_data(&(state_com->m_cpe).streams[0], &(state->tns_data[ch]));
aacidec_ics_calc_tns_data(&(state_com->m_cpe).streams[1], &(state->tns_data[ch + 1]));
aacidec_deinterlieve(&(state_com->m_cpe).streams[0], state->m_spectrum_data[ch]);
aacidec_deinterlieve(&(state_com->m_cpe).streams[1], state->m_spectrum_data[ch + 1]);
if (AOT_AAC_LTP == state_com->m_audio_object_type) {
state->m_ltp.p_samples_1st_part = state->m_ltp_buf[ch][state_com->m_index_1st];
state->m_ltp.p_samples_2nd_part = state->m_ltp_buf[ch][state_com->m_index_2nd];
state->m_ltp.p_samples_3rd_part = state->m_ltp_buf[ch][state_com->m_index_3rd];
state->m_ltp.prev_windows_shape = state_com->m_prev_win_shape[ch];
state->m_ltp.p_tns_data = &(state->tns_data[ch]);
aacidec_ics_apply_ltp_I(&(state->m_ltp), &(state_com->m_cpe).streams[0],
state->m_spectrum_data[ch]);
state->m_ltp.p_samples_1st_part = state->m_ltp_buf[ch + 1][state_com->m_index_1st];
state->m_ltp.p_samples_2nd_part = state->m_ltp_buf[ch + 1][state_com->m_index_2nd];
state->m_ltp.p_samples_3rd_part = state->m_ltp_buf[ch + 1][state_com->m_index_3rd];
state->m_ltp.prev_windows_shape = state_com->m_prev_win_shape[ch + 1];
state->m_ltp.p_tns_data = &(state->tns_data[ch + 1]);
aacidec_ics_apply_ltp_I(&(state->m_ltp), &(state_com->m_cpe).streams[1],
state->m_spectrum_data[ch + 1]);
}
break;
case ID_CCE:
state_com->m_curr_win_shape[CH_MAX + ncch] =
(state_com->m_cce).stream.window_shape;
state_com->m_curr_win_sequence[CH_MAX + ncch] =
(state_com->m_cce).stream.window_sequence;
if (0 != (state_com->m_cce).stream.pulse_data_present) {
ics_apply_pulse_I(&(state_com->m_cce).stream);
}
aacidec_ics_apply_scale_factors(&(state_com->m_cce).stream,
state->m_spectrum_data[CH_MAX + ncch]);
aacidec_apply_pns(&(state_com->m_cce).stream, NULL,
state->m_spectrum_data[CH_MAX + ncch], NULL, 1,
0, NULL, &(state_com->noiseState));
aacidec_deinterlieve(&(state_com->m_cce).stream,
state->m_spectrum_data[CH_MAX + ncch]);
aacidec_ics_calc_tns_data(&(state_com->m_cce).stream, &tns_data0);
if (AOT_AAC_LTP == state_com->m_audio_object_type) {
state->m_ltp.p_samples_1st_part =
state->m_ltp_buf[CH_MAX + ncch][state_com->m_index_1st];
state->m_ltp.p_samples_2nd_part =
state->m_ltp_buf[CH_MAX + ncch][state_com->m_index_2nd];
state->m_ltp.p_samples_3rd_part =
state->m_ltp_buf[CH_MAX + ncch][state_com->m_index_3rd];
state->m_ltp.prev_windows_shape =
state_com->m_prev_win_shape[CH_MAX + ncch];
state->m_ltp.p_tns_data = &tns_data0;
aacidec_ics_apply_ltp_I(&(state->m_ltp), &(state_com->m_cce).stream,
state->m_spectrum_data[CH_MAX + ncch]);
}
if (0 != tns_data0.m_tns_data_present) {
aacidec_ics_apply_tns_dec_I(&tns_data0, state->m_spectrum_data[CH_MAX + ncch]);
}
aacidec_coupling_gain_calculation(&(state_com->m_cce), &(state_com->m_cdata[ncch]),
state->cc_gain[ncch], state->cc_gain_factor[ncch]);
ncch++;
break;
case ID_LFE:
state_com->m_curr_win_shape[ch] = (state_com->m_lfe).stream.window_shape;
state_com->m_curr_win_sequence[ch] = (state_com->m_lfe).stream.window_sequence;
if (0 != (state_com->m_lfe).stream.pulse_data_present) {
ics_apply_pulse_I(&(state_com->m_lfe).stream);
}
aacidec_ics_apply_scale_factors(&(state_com->m_lfe).stream, state->m_spectrum_data[ch]);
state->tns_data[ch].m_tns_data_present = 0;
break;
default:
break;
}
GET_BITS(pBS, id, 3, Ipp32s)
}
if (1 == state_com->m_is_pce_valid) {
if (state_com->m_is_chmap_valid == 0) {
if (chmap_create_by_pce(&(state_com->m_pce), state_com->m_chmap) < 0)
RETURN_AAC_BAD_STREAM;
state_com->m_is_chmap_valid = 1;
}
order_counter = chmap_order(state_com->m_chmap, m_elmap,
cur_frame_el_num, state_com->m_order);
} else if (state_com->adts_channel_configuration > 0) {
if (chmap_create_by_adts(state_com->adts_channel_configuration,
state_com->m_chmap, m_elmap, cur_frame_el_num) < 0)
RETURN_AAC_BAD_STREAM;
order_counter = chmap_order(state_com->m_chmap, m_elmap,
cur_frame_el_num, state_com->m_order);
}
state_com->m_channel_number = order_counter;
state_com->m_channel_number_all = ch_num;
state_com->m_element_number = el_num;
for (i = 0; i < order_counter; i++) {
ch = state_com->m_order[i];
state->m_ordered_samples[i] = state->m_spectrum_data[ch];
}
if (AOT_AAC_LTP == state_com->m_audio_object_type) {
state_com->m_index_1st++;
if (state_com->m_index_1st == 3)
state_com->m_index_1st = 0;
state_com->m_index_2nd++;
if (state_com->m_index_2nd == 3)
state_com->m_index_2nd = 0;
state_com->m_index_3rd++;
if (state_com->m_index_3rd == 3)
state_com->m_index_3rd = 0;
}
/* coupling channel process */
for (ch = 0; ch < ncch; ch++) {
Ipp32s c;
for (c = 0; c < state_com->m_cdata[ch].num_coupled_elements + 1; c++) {
Ipp32s id = state_com->m_cdata[ch].cc_target_id[c];
Ipp32s tag = state_com->m_cdata[ch].cc_target_tag[c];
state_com->m_cdata[ch].cc_target_ch[c] =
aacGetChannel(id, tag, state_com->m_element_number, state_com->m_elmap);
}
}
scaleFactorCoreAAC = 7;
for (ch = 0; ch < ncch; ch++) {
if ((state_com->m_cdata[ch].ind_sw_cce_flag) ||
(AOT_AAC_LTP == state_com->m_audio_object_type)) {
ippsMDCTInv_AAC_32s_I(state->m_spectrum_data[CH_MAX + ch],
state->m_prev_samples[CH_MAX + ch],
state_com->m_curr_win_sequence[CH_MAX + ch],
state_com->m_curr_win_shape[CH_MAX + ch],
state_com->m_prev_win_shape[CH_MAX + ch], 1024);
state_com->m_prev_win_shape[CH_MAX + ch] =
state_com->m_curr_win_shape[CH_MAX + ch];
/* Update buffers for LTP */
if (AOT_AAC_LTP == state_com->m_audio_object_type) {
ippsConvert_32s16s_Sfs(state->m_curr_samples[CH_MAX + ch],
state->m_ltp_buf[ch][state_com->m_index_2nd],
1024, scaleFactorCoreAAC);
ippsConvert_32s16s_Sfs(state->m_prev_samples[CH_MAX + ch],
state->m_ltp_buf[ch][state_com->m_index_3rd],
1024, scaleFactorCoreAAC);
}
}
}
for (ch = 0; ch < ncch; ch++) {
if ((!state_com->m_cdata[ch].ind_sw_cce_flag) &&
(!state_com->m_cdata[ch].cc_domain)) {
aacidec_coupling_spectrum(state, &(state_com->m_cdata[ch]),
state->m_spectrum_data[CH_MAX + ch],
state_com->m_curr_win_sequence[CH_MAX + ch],
state->cc_gain[ch], state->cc_gain_factor[ch]);
}
}
for (i = 0; i < state_com->m_channel_number; i++) {
ch = state_com->m_order[i];
if (0 != state->tns_data[ch].m_tns_data_present) {
aacidec_ics_apply_tns_dec_I(&(state->tns_data[ch]), state->m_spectrum_data[ch]);
}
}
for (ch = 0; ch < ncch; ch++) {
if ((!state_com->m_cdata[ch].ind_sw_cce_flag) &&
(state_com->m_cdata[ch].cc_domain)) {
aacidec_coupling_spectrum(state, &(state_com->m_cdata[ch]),
state->m_spectrum_data[CH_MAX + ch],
state_com->m_curr_win_sequence[CH_MAX + ch],
state->cc_gain[ch], state->cc_gain_factor[ch]);
}
}
for (ch_counter = 0; ch_counter < state_com->m_channel_number; ch_counter++) {
ch = state_com->m_order[ch_counter];
ippsMDCTInv_AAC_32s_I(state->m_spectrum_data[ch],
state->m_prev_samples[ch],
state_com->m_curr_win_sequence[ch],
state_com->m_curr_win_shape[ch],
state_com->m_prev_win_shape[ch], 1024);
state_com->m_prev_win_shape[ch] = state_com->m_curr_win_shape[ch];
}
for (ch = 0; ch < ncch; ch++) {
if (state_com->m_cdata[ch].ind_sw_cce_flag) {
aacidec_coupling_samples(state, &(state_com->m_cdata[ch]),
state->m_spectrum_data[CH_MAX + ch],
state->cc_gain[ch], state->cc_gain_factor[ch]);
}
}
for (ch_counter = 0; ch_counter < state_com->m_channel_number; ch_counter++) {
ch = state_com->m_order[ch_counter];
/* Update buffers for LTP */
if (AOT_AAC_LTP == state_com->m_audio_object_type) {
ippsConvert_32s16s_Sfs(state->m_spectrum_data[ch],
state->m_ltp_buf[ch][state_com->m_index_2nd],
1024, scaleFactorCoreAAC);
ippsConvert_32s16s_Sfs(state->m_prev_samples[ch],
state->m_ltp_buf[ch][state_com->m_index_3rd],
1024, scaleFactorCoreAAC);
}
}
/* HE-AAC patch */
if ((sbrFlagPresentLFE) && (cnt_fill_sbr_element)) {
/* we passed LFE if ER AAC mode is used */
if (cnt_fill_sbr_element != cnt_idaac_sbr_element) {
cnt_fill_sbr_element++;
}
/* may be error? if yes then we isn't doing sbr process */
if (cnt_fill_sbr_element != cnt_idaac_sbr_element) {
cnt_fill_sbr_element = 0;
}
}
// be careful !!!
scaleFactorAAC = scaleFactorCoreAAC;
for (i = 0, j = 0; i < cnt_fill_sbr_element; i++) {
scaleFactorAAC = scaleFactorCoreAAC;
sbriGetFrame(state->m_spectrum_data[j],// implace call
state->m_spectrum_data[j],
&(state->sbrBlock[i]), &(state->sbr_filter[i]),
0, //ch L
state_com->ModeDecodeHEAACprofile,
state_com->ModeDwnsmplHEAACprofile,
state->pWorkBuffer,
&scaleFactorAAC ); //sf will be changed
j++;
if (state->sbrBlock[i].comState.id_aac == ID_CPE) {
/* we "forget" New scaleFactorAAC from L_CHANNEL
* because OUT scaleFactor for L & R channel the same
*/
scaleFactorAAC = scaleFactorCoreAAC;
sbriGetFrame(state->m_spectrum_data[j],// implace call
state->m_spectrum_data[j],
&(state->sbrBlock[i]),
&(state->sbr_filter[i]),
1,//ch R
state_com->ModeDecodeHEAACprofile,
state_com->ModeDwnsmplHEAACprofile,
state->pWorkBuffer,
&scaleFactorAAC );//sf will be changed
j++;
}
}
if (cnt_fill_sbr_element) {
if (state_com->ModeDwnsmplHEAACprofile == HEAAC_DWNSMPL_OFF) {
state->com.m_up_sample = 2;
}
state_com->SbrFlagPresent = 1;
}
Byte_alignment(pBS);
GET_BITS_COUNT(pBS, (*decodedBytes))
*decodedBytes >>= 3;
state_com->m_channel_number_save = state_com->m_channel_number;
state->scaleFactorAAC = scaleFactorAAC;
} else {
*decodedBytes = state_com->decodedBytes;
scaleFactorAAC = state->scaleFactorAAC;
state_com->crc = state_com->saved_crc;
}
if (outBufferSize < (state_com->m_channel_number *
state->com.m_up_sample * 1024 * (Ipp32s)(sizeof(Ipp16s)))) {
state_com->decodedBytes = *decodedBytes;
state_com->saved_crc = state_com->crc;
return AAC_NOT_ENOUGH_BUFFER;
}
m_channel_number = state_com->m_channel_number;
if (m_channel_number == 1) {
for (j = 0; j < m_channel_number; j++) {
Ipp16s *tmpPtr = outPointer + j;
Ipp32s num = state->com.m_up_sample * 1024;
Ipp32s *srcPrt = state->m_ordered_samples[j];
for (i = 0; i < num; i++) {
Ipp32s tmp = *srcPrt;
Ipp32s tmp0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -