📄 aac_dec_stream_elements.c
字号:
Ipp32s dec_ltp_data(s_SE_Individual_channel_stream *pData,
sBitsreamBuffer *pBS,
enum AudioObjectType audioObjectType)
{
Ipp32s i;
Ipp32s w;
Ipp32s pred_max_sfb;
pred_max_sfb =
MAX_LTP_SFB_LONG < pData->max_sfb ? MAX_LTP_SFB_LONG : pData->max_sfb;
if (audioObjectType == AOT_ER_AAC_LD) {
GET_BITS(pBS, pData->ltp_lag_update, 1, Ipp32s)
if (pData->ltp_lag_update) {
GET_BITS(pBS, pData->ltp_lag, 10, Ipp32s)
} else {
}
GET_BITS(pBS, pData->ltp_coef, 3, Ipp32s)
for (i = 0; i < pred_max_sfb; i++) {
GET_BITS(pBS, pData->ltp_long_used[i], 1, Ipp32s)
}
} else {
GET_BITS(pBS, pData->ltp_lag, 11, Ipp32s)
GET_BITS(pBS, pData->ltp_coef, 3, Ipp32s)
if (pData->window_sequence == EIGHT_SHORT_SEQUENCE) {
for (w = 0; w < pData->num_windows; w++) {
GET_BITS(pBS, pData->ltp_short_used[w], 1, Ipp32s)
if (pData->ltp_short_used[w]) {
GET_BITS(pBS, pData->ltp_short_lag_present[w], 1, Ipp32s)
if (pData->ltp_short_lag_present[w]) {
GET_BITS(pBS, pData->ltp_short_lag[w], 4, Ipp32s)
} else {
pData->ltp_short_lag[w] = 0;
}
}
}
} else {
for (i = 0; i < pred_max_sfb; i++) {
GET_BITS(pBS, pData->ltp_long_used[i], 1, Ipp32s)
}
for (i = pred_max_sfb; i < pData->max_sfb; i++) {
pData->ltp_long_used[i] = 0;
}
}
}
return 0;
}
/********************************************************************/
Ipp32s dec_section_data(s_SE_Individual_channel_stream *pData,
sBitsreamBuffer *pBS)
{
Ipp32s sfb;
Ipp32s k;
Ipp32s g;
Ipp32s sect_esc_val;
Ipp32s sect_len_incr;
Ipp32s esc_code_len;
Ipp32s sect_cb;
Ipp32s sect_len;
if (pData->window_sequence == EIGHT_SHORT_SEQUENCE) {
sect_esc_val = (1 << 3) - 1;
esc_code_len = 3;
} else {
sect_esc_val = (1 << 5) - 1;
esc_code_len = 5;
}
for (g = 0; g < pData->num_window_groups; g++) {
k = 0;
while (k < pData->max_sfb) {
GET_BITS(pBS, sect_cb, 4, Ipp32s)
sect_len = 0;
GET_BITS(pBS, sect_len_incr, esc_code_len, Ipp32s)
while (sect_len_incr == sect_esc_val) {
sect_len += sect_esc_val;
GET_BITS(pBS, sect_len_incr, esc_code_len, Ipp32s)
}
sect_len += sect_len_incr;
for (sfb = k; sfb < k + sect_len; sfb++) {
pData->sfb_cb[g][sfb] = sect_cb;
}
k += sect_len;
if (k > pData->max_sfb) {
return -1;
}
}
for (; k < 51; k++) {
pData->sfb_cb[g][k] = 0;
}
}
return 0;
}
/********************************************************************/
Ipp32s dec_scale_factor_data(s_SE_Individual_channel_stream *pData,
Ipp16s scalef[8][51],
Ipp32s scale_factor,
Ipp32s noise_nrg,
sBitsreamBuffer *pBS)
{
Ipp32s g;
Ipp32s sfb;
Ipp16s t;
Ipp32s is_pos;
Ipp32s noise_pcm_flag;
Ipp8u *pSrc;
Ipp32s bitoffset;
IppsVLCDecodeSpec_32s *pVLCDecSpec =
(IppsVLCDecodeSpec_32s *) pData->p_huffman_tables[0];
is_pos = 0;
noise_pcm_flag = 1;
pSrc = (Ipp8u *)pBS->pCurrent_dword + ((32 - pBS->nBit_offset) >> 3);
bitoffset = (32 - pBS->nBit_offset) & 0x7;
for (g = 0; g < pData->num_window_groups; g++) {
for (sfb = 0; sfb < pData->max_sfb; sfb++) {
switch (pData->sfb_cb[g][sfb]) {
case ZERO_HCB:
scalef[g][sfb] = 0;
break;
case INTENSITY_HCB:
case INTENSITY_HCB2:
ippsVLCDecodeOne_1u16s(&pSrc, &bitoffset, &t, pVLCDecSpec);
is_pos += t - SF_MID;
scalef[g][sfb] = (Ipp16s)is_pos;
break;
case NOISE_HCB:
if (noise_pcm_flag) {
pBS->pCurrent_dword = (Ipp32u *)(pSrc - ((Ipp32s)(pSrc) & 3));
pBS->dword = BSWAP(pBS->pCurrent_dword[0]);
pBS->nBit_offset =
32 - ((pSrc - (Ipp8u *)pBS->pCurrent_dword) << 3) - bitoffset;
noise_pcm_flag = 0;
GET_BITS(pBS, t, 9, Ipp16s)
pSrc = (Ipp8u *)pBS->pCurrent_dword + ((32 - pBS->nBit_offset) >> 3);
bitoffset = (32 - pBS->nBit_offset) & 0x7;
t -= 256;
} else {
ippsVLCDecodeOne_1u16s(&pSrc, &bitoffset, &t, pVLCDecSpec);
t -= SF_MID;
}
noise_nrg += t;
scalef[g][sfb] = (Ipp16s)noise_nrg;
break;
default:
ippsVLCDecodeOne_1u16s(&pSrc, &bitoffset, &t, pVLCDecSpec);
scale_factor += t - SF_MID;
scalef[g][sfb] = (Ipp16s)scale_factor;
break;
}
}
}
pBS->pCurrent_dword = (Ipp32u *)(pSrc - ((Ipp32s)(pSrc) & 3));
pBS->dword = BSWAP(pBS->pCurrent_dword[0]);
pBS->nBit_offset =
32 - ((pSrc - (Ipp8u *)pBS->pCurrent_dword) << 3) - bitoffset;
return 0;
}
/********************************************************************/
Ipp32s dec_spectral_data(s_SE_Individual_channel_stream *pData,
sBitsreamBuffer *pBS)
{
Ipp32s g;
Ipp32s sfb;
Ipp32s *sfb_offset;
Ipp16s *qp;
Ipp8u *pSrc;
Ipp16s pDst[512];
Ipp32s bitoffset, i, num;
if (pData->window_sequence == EIGHT_SHORT_SEQUENCE) {
sfb_offset = pData->sfb_offset_short_window;
} else {
sfb_offset = pData->sfb_offset_long_window;
}
pSrc = (Ipp8u *)pBS->pCurrent_dword + ((32 - pBS->nBit_offset) >> 3);
bitoffset = (32 - pBS->nBit_offset) & 0x7;
qp = pData->spectrum_data;
for (g = 0; g < pData->num_window_groups; g++) {
for (sfb = 0; sfb < pData->max_sfb; sfb++) {
Ipp32s sfb_cb = pData->sfb_cb[g][sfb];
Ipp32s sfb_begin = sfb_offset[sfb];
Ipp32s sfb_end = sfb_offset[sfb + 1];
Ipp32s shift = pData->vlcShifts[sfb_cb];
Ipp32s offset = pData->vlcOffsets[sfb_cb];
Ipp32s mask = (1 << (shift)) - 1;
IppsVLCDecodeSpec_32s *pVLCDecSpec =
(IppsVLCDecodeSpec_32s *) pData->p_huffman_tables[sfb_cb];
IppsVLCDecodeUTupleSpec_32s *pVLCDecSpecTuple =
(IppsVLCDecodeUTupleSpec_32s *) pData->p_huffman_tables[sfb_cb];
switch (pData->vlcTypes[sfb_cb]) {
case 0: /* 4 tuples */
num = ((sfb_end - sfb_begin) >> 2) * pData->len_window_group[g];
ippsVLCDecodeBlock_1u16s(&pSrc, &bitoffset, pDst,
num, pVLCDecSpec);
for (i = 0; i < num; i++) {
Ipp32s tmp = pDst[i];
qp[0] = (Ipp16s)(tmp >> (3 * shift));
qp[1] = (Ipp16s)(((tmp >> (2 * shift)) & mask) - offset);
qp[2] = (Ipp16s)(((tmp >> (shift)) & mask) - offset);
qp[3] = (Ipp16s)((tmp & mask) - offset);
qp += 4;
}
break;
case 1: /* 2 tuples */
num = ((sfb_end - sfb_begin) >> 1) * pData->len_window_group[g];
ippsVLCDecodeBlock_1u16s(&pSrc, &bitoffset, pDst,
num, pVLCDecSpec);
for (i = 0; i < num; i++) {
Ipp32s tmp = pDst[i];
qp[0] = (Ipp16s)(tmp >> shift);
qp[1] = (Ipp16s)((tmp & mask) - offset);
qp += 2;
}
break;
case 2: /* esc */
num = ((sfb_end - sfb_begin)) * pData->len_window_group[g];
ippsVLCDecodeEscBlock_AAC_1u16s(&pSrc, &bitoffset, qp,
num, pVLCDecSpec);
qp += num;
break;
case 3: /* esc Ipp32u */
num = ((sfb_end - sfb_begin)) * pData->len_window_group[g];
ippsVLCDecodeUTupleEscBlock_AAC_1u16s(&pSrc, &bitoffset, qp,
num, pVLCDecSpecTuple);
qp += num;
break;
case 4: /* 2, 4 tuples Ipp32u */
num = ((sfb_end - sfb_begin)) * pData->len_window_group[g];
ippsVLCDecodeUTupleBlock_1u16s(&pSrc, &bitoffset, qp,
num, pVLCDecSpecTuple);
qp += num;
break;
default:
num = ((sfb_end - sfb_begin)) * pData->len_window_group[g];
for (i = 0; i < num; i++) {
qp[0] = 0;
qp++;
}
break;
}
}
}
pBS->pCurrent_dword = (Ipp32u *)(pSrc - ((Ipp32s)(pSrc) & 3));
pBS->dword = BSWAP(pBS->pCurrent_dword[0]);
pBS->nBit_offset =
32 - ((pSrc - (Ipp8u *)pBS->pCurrent_dword) << 3) - bitoffset;
return 0;
}
/********************************************************************/
Ipp32s dec_pulse_data(s_SE_Individual_channel_stream *pData,
sBitsreamBuffer *pBS)
{
Ipp32s i, k;
GET_BITS(pBS, pData->number_pulse, 2, Ipp32s)
GET_BITS(pBS, pData->pulse_start_sfb, 6, Ipp32s)
if (pData->pulse_start_sfb > pData->num_swb_long)
return -1;
k = pData->sfb_offset_long_window[pData->pulse_start_sfb];
for (i = 0; i < pData->number_pulse + 1; i++) {
GET_BITS(pBS, pData->pulse_offset[i], 5, Ipp32s)
GET_BITS(pBS, pData->pulse_amp[i], 4, Ipp32s)
k += pData->pulse_offset[i];
}
if (k > 1024)
return -1;
return 0;
}
/********************************************************************/
Ipp32s dec_tns_data(s_SE_Individual_channel_stream *pData,
sBitsreamBuffer *pBS)
{
Ipp32s w;
Ipp32s filt;
Ipp32s i;
Ipp32s coef_len;
for (w = 0; w < pData->num_windows; w++) {
Ipp32s nbits;
nbits = (pData->num_windows == 8) ? 1 : 2;
GET_BITS(pBS, pData->n_filt[w], nbits, Ipp32s)
if (pData->n_filt[w] == 0)
continue;
GET_BITS(pBS, pData->coef_res[w], 1, Ipp32s)
for (filt = 0; filt < pData->n_filt[w]; filt++) {
nbits = (pData->num_windows == 8) ? 4 : 6;
GET_BITS(pBS, pData->length[w][filt], nbits, Ipp32s)
nbits = (pData->num_windows == 8) ? 3 : 5;
GET_BITS(pBS, pData->order[w][filt], nbits, Ipp32s)
if (pData->order[w][filt] == 0)
continue;
GET_BITS(pBS, pData->direction[w][filt], 1, Ipp32s)
GET_BITS(pBS, pData->coef_compress[w][filt], 1, Ipp32s)
coef_len = 3 + pData->coef_res[w] - pData->coef_compress[w][filt];
for (i = 0; i < pData->order[w][filt]; i++) {
GET_BITS(pBS, pData->coef[w][filt][i], coef_len, Ipp32s)
}
}
}
return 0;
}
/********************************************************************/
Ipp32s dec_coupling_channel_element(sCoupling_channel_element *pElement,
sCoupling_channel_data *pData,
sBitsreamBuffer *pBS,
enum AudioObjectType audioObjectType)
{
Ipp32s c, cc_l, cc_r;
Ipp16s t;
Ipp8u *pSrc;
Ipp32s bitoffset;
IppsVLCDecodeSpec_32s *pVLCDecSpec =
(IppsVLCDecodeSpec_32s *) pElement->stream.p_huffman_tables[0];
Ipp32u *crc_ptr = 0;
Ipp32s crc_offset = 0;
Ipp32s decodedBits0 = 0, decodedBits2 = 0;
if (pElement->crc_enable) {
crc_ptr = pBS->pCurrent_dword;
crc_offset = pBS->nBit_offset;
GET_BITS_COUNT(pBS, decodedBits0)
}
GET_BITS(pBS, pElement->element_instance_tag, 4, Ipp32s)
GET_BITS(pBS, pData->ind_sw_cce_flag, 1, Ipp32s)
GET_BITS(pBS, pData->num_coupled_elements, 3, Ipp32s)
pData->num_gain_element_lists = 0;
for (c = 0; c < pData->num_coupled_elements + 1; c++) {
pData->num_gain_element_lists++;
GET_BITS(pBS, pData->cc_target_id[c], 1, Ipp32s)
GET_BITS(pBS, pData->cc_target_tag[c], 4, Ipp32s)
if (pData->cc_target_id[c]) {
GET_BITS(pBS, cc_l, 1, Ipp32s)
GET_BITS(pBS, cc_r, 1, Ipp32s)
pData->cc_lr[pData->num_gain_element_lists - 1] = (cc_l << 1) + cc_r;
if (pData->cc_lr[pData->num_gain_element_lists - 1] == 3) {
pData->num_gain_element_lists++;
pData->cc_lr[pData->num_gain_element_lists - 1] = 3;
}
}
}
GET_BITS(pBS, pData->cc_domain, 1, Ipp32s)
GET_BITS(pBS, pData->gain_element_sign, 1, Ipp32s)
GET_BITS(pBS, pData->gain_element_scale, 2, Ipp32s)
if (dec_individual_channel_stream
(&pElement->stream, pBS, 0, 0, audioObjectType) < 0)
return -1;
pData->max_sfb = pElement->stream.max_sfb;
pData->num_window_groups = pElement->stream.num_window_groups;
for (c = 0; c < pData->num_window_groups; c++) {
pData->len_window_group[c] = pElement->stream.len_window_group[c];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -