📄 aac_dec_api_fp.c
字号:
}
if (0 != (state_com->m_cpe).streams[1].pulse_data_present) {
ics_apply_pulse_I(&(state_com->m_cpe).streams[1]);
}
ics_apply_scale_factors(&(state_com->m_cpe).streams[0], state->m_spectrum_data[ch]);
ics_apply_scale_factors(&(state_com->m_cpe).streams[1],
state->m_spectrum_data[ch + 1]);
/* Joint stereo */
cpe_apply_ms(&(state_com->m_cpe), state->m_spectrum_data[ch],
state->m_spectrum_data[ch + 1]);
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));
#ifndef NEW_FDP_VERSION
cpe_apply_intensity(&(state_com->m_cpe), state->m_spectrum_data[ch],
state->m_spectrum_data[ch + 1]);
#endif
if (AOT_AAC_MAIN == state_com->m_audio_object_type) {
FDP(state->m_spectrum_data[ch], &(state_com->m_cpe).streams[0],
state->pFDPState[ch]);
FDP(state->m_spectrum_data[ch+1], &(state_com->m_cpe).streams[1],
state->pFDPState[ch+1]);
}
#ifdef NEW_FDP_VERSION
cpe_apply_intensity(&(state_com->m_cpe), state->m_spectrum_data[ch],
state->m_spectrum_data[ch + 1]);
#endif
ics_calc_tns_data(&(state_com->m_cpe).streams[0], &(state->tns_data[ch]));
ics_calc_tns_data(&(state_com->m_cpe).streams[1], &(state->tns_data[ch + 1]));
deinterlieve(&(state_com->m_cpe).streams[0], state->m_spectrum_data[ch]);
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_filterbank_data = &(state->m_filterbank);
state->m_ltp.p_tns_data = &(state->tns_data[ch]);
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]);
ics_apply_ltp_I(&(state->m_ltp), &(state_com->m_cpe).streams[1],
state->m_spectrum_data[ch + 1]);
} else if (AOT_AAC_SSR == state_com->m_audio_object_type) {
save_gain_control_data(ch, &(state_com->m_cpe).streams[0], state_com);
save_gain_control_data(ch+1, &(state_com->m_cpe).streams[1], state_com);
}
//if (0 != state->tns_data[ch].m_tns_data_present) {
// ics_apply_tns_dec_I(&(state->tns_data[ch]), state->m_spectrum_data[ch]);
//}
//if (0 != state->tns_data[ch + 1].m_tns_data_present) {
// ics_apply_tns_dec_I(&(state->tns_data[ch + 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);
}
ics_apply_scale_factors(&(state_com->m_cce).stream,
state->m_spectrum_data[CH_MAX + ncch]);
apply_pns(&(state_com->m_cce).stream, NULL,
state->m_spectrum_data[CH_MAX + ncch], NULL, 1,
0, NULL, &(state_com->noiseState));
deinterlieve(&(state_com->m_cce).stream, state->m_spectrum_data[CH_MAX + ncch]);
ics_calc_tns_data(&(state_com->m_cce).stream, &tns_data0);
if (AOT_AAC_MAIN == state_com->m_audio_object_type) {
FDP(state->m_spectrum_data[CH_MAX + ncch], &(state_com->m_cce).stream,
state->pFDPState[CH_MAX + ncch]);
} else 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_filterbank_data = &(state->m_filterbank);
state->m_ltp.p_tns_data = &tns_data0;
ics_apply_ltp_I(&(state->m_ltp), &(state_com->m_cce).stream,
state->m_spectrum_data[CH_MAX + ncch]);
} else if (AOT_AAC_SSR == state_com->m_audio_object_type) {
save_gain_control_data(CH_MAX + ncch, &(state_com->m_cce).stream,
state_com);
}
if (0 != tns_data0.m_tns_data_present) {
ics_apply_tns_dec_I(&tns_data0, state->m_spectrum_data[CH_MAX + ncch]);
}
coupling_gain_calculation(&(state_com->m_cce), &(state_com->m_cdata[ncch]),
state->cc_gain[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);
}
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_curr_samples[ch];
// AYA: important! PS tool will correct it later
}
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);
}
}
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)) {
if (AOT_AAC_SSR == state_com->m_audio_object_type) {
SSR_GAIN *tmpSSRInfo[4];
for (i = 0; i < 4; i++) {
tmpSSRInfo[i] = state_com->SSRInfo[CH_MAX + ch][i];
}
ssr_gain_control(state->m_spectrum_data[CH_MAX + ch],
state_com->m_curr_win_shape[CH_MAX + ch],
state_com->m_prev_win_shape[CH_MAX + ch],
state_com->m_curr_win_sequence[CH_MAX + ch],
tmpSSRInfo,
state_com->prevSSRInfo[CH_MAX + ch],
state->m_curr_samples[CH_MAX + ch],
state->m_gcOverlapBuffer[CH_MAX + ch],
&(state->SSR_IPQFState[CH_MAX + ch]),
&(state->m_filterbank),
1024);
state_com->m_prev_win_shape[CH_MAX + ch] =
state_com->m_curr_win_shape[CH_MAX + ch];
} else {
FilterbankDec(&(state->m_filterbank), 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],
state->m_curr_samples[CH_MAX + ch],
state->m_prev_samples[CH_MAX + ch]);
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) {
for (i = 0; i < 1024; i++) {
Ipp32f tmp;
tmp = state->m_curr_samples[CH_MAX + ch][i];
if (tmp > 0) tmp += 0.5f;
else tmp -= 0.5f;
if (tmp > 32767) tmp = 32767;
if (tmp < -32768) tmp = -32768;
state->m_ltp_buf[CH_MAX + ch][state_com->m_index_2nd][i] = (Ipp32f)(Ipp32s)tmp;
tmp = state->m_prev_samples[CH_MAX + ch][i];
if (tmp > 0) tmp += 0.5f;
else tmp -= 0.5f;
if (tmp > 32767) tmp = 32767;
if (tmp < -32768) tmp = -32768;
state->m_ltp_buf[CH_MAX + ch][state_com->m_index_3rd][i] = (Ipp32f)(Ipp32s)tmp;
}
}
}
}
}
for (ch = 0; ch < ncch; ch++) {
if ((!state_com->m_cdata[ch].ind_sw_cce_flag) &&
(!state_com->m_cdata[ch].cc_domain)) {
coupling_spectrum(state, &(state_com->m_cdata[ch]),
state->m_spectrum_data[CH_MAX + ch],
state->cc_gain[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) {
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)) {
coupling_spectrum(state, &(state_com->m_cdata[ch]),
state->m_spectrum_data[CH_MAX + ch],
state->cc_gain[ch]);
}
}
if (AOT_AAC_SSR == state_com->m_audio_object_type) {
SSR_GAIN *tmpSSRInfo[4];
for (ch_counter = 0; ch_counter < state_com->m_channel_number; ch_counter++) {
ch = state_com->m_order[ch_counter];
for (i = 0; i < 4; i++) {
tmpSSRInfo[i] = state_com->SSRInfo[ch][i];
}
ssr_gain_control(state->m_spectrum_data[ch],
state_com->m_curr_win_shape[ch],
state_com->m_prev_win_shape[ch],
state_com->m_curr_win_sequence[ch],
tmpSSRInfo,
state_com->prevSSRInfo[ch],
state->m_curr_samples[ch],
state->m_gcOverlapBuffer[ch],
&(state->SSR_IPQFState[ch]),
&(state->m_filterbank),
1024);
state_com->m_prev_win_shape[ch] = state_com->m_curr_win_shape[ch];
}
} else {
for (ch_counter = 0; ch_counter < state_com->m_channel_number; ch_counter++) {
ch = state_com->m_order[ch_counter];
FilterbankDec(&(state->m_filterbank), 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],
state->m_curr_samples[ch], state->m_prev_samples[ch]);
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) {
coupling_spectrum(state, &(state_com->m_cdata[ch]),
state->m_spectrum_data[CH_MAX + ch],
state->cc_gain[ch]);
}
}
/* Update buffers for LTP */
if (AOT_AAC_LTP == state_com->m_audio_object_type) {
for (ch_counter = 0; ch_counter < state_com->m_channel_number; ch_counter++) {
ch = state_com->m_order[ch_counter];
for (i = 0; i < 1024; i++) {
Ipp32f tmp;
tmp = state->m_curr_samples[ch][i];
if (tmp > 0) tmp += 0.5f;
else tmp -= 0.5f;
if (tmp > 32767) tmp = 32767;
if (tmp < -32768) tmp = -32768;
state->m_ltp_buf[ch][state_com->m_index_2nd][i] = (Ipp32f)(Ipp32s)tmp;
tmp = state->m_prev_samples[ch][i];
if (tmp > 0) tmp += 0.5f;
else tmp -= 0.5f;
if (tmp > 32767) tmp = 32767;
if (tmp < -32768) tmp = -32768;
state->m_ltp_buf[ch][state_com->m_index_3rd][i] = (Ipp32f)(Ipp32s)tmp;
}
}
}
/* 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;
}
}
/* ****** PARAMETRIC STEREO PATCH ******************/
/* PS is applied for */
/* (1) mono signal only [i = 0]. */
/* (2) MPEG4 container */
/* (3) SBR explicit */
/* so, if PS active, decoder will convert mono2stereo*/
/* ************************************************* */
if( 0xA & state->com.m_flag_PS_support_lev){
if( state->com.m_channel_number == 1 ){ // m_channel_number must be mono every call this function
state->sbrBlock[0].pPSDecState = &(state->psState);
state->com.m_channel_number = 2;
state->m_ordered_samples[1] = state->m_curr_samples[1];
} else {
// vm_debug_trace(VM_DEBUG_ALL, VM_STRING("Err PS: ch > 1 !\n"));
state->com.m_flag_PS_support_lev = PS_DISABLE;
}
}
for (i = 0, j = 0; i < cnt_fill_sbr_element; i++) {
Ipp32s nCall = (state->sbrBlock[i].comState.id_aac == ID_CPE) ? 2 : 1;
Ipp32s call = 0;
for( call = 0; call < nCall; call++ ){
sbrGetFrame(state->m_curr_samples[j], //input
state->m_curr_samples[j], //output
(0xA & state->com.m_flag_PS_support_lev) ? state->m_curr_samples[j + 1] : NULL,
&(state->sbrBlock[i]),
&(state->sbr_filter[i]),
call, // number of "current" channel
state_com->ModeDecodeHEAACprofile, //HQ or LP
state_com->ModeDwnsmplHEAACprofile,//DWNSMPL ON or OFF
state_com->m_flag_PS_support_lev, // HEAACv1 or v2
state->pWorkBuffer );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -