📄 aac_dec_api_fp.c
字号:
j++;
}
}// END FOR for (i = 0, j = 0; i < cnt_fill_sbr_element; i++)
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;
} else {
*decodedBytes = state_com->decodedBytes;
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;
}
ippsJoin_32f16s_D2L((const Ipp32f **)(state->m_ordered_samples),
state_com->m_channel_number, state->com.m_up_sample * 1024, outPointer);
state_com->decodedBytes = 0;
state_com->m_frame_number++;
/* AYA: tmp diagn */
//printf("\nframe %i\n", state_com->m_frame_number-1);
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecSetSamplingFrequency(Ipp32s sampling_frequency_index,
AACDec *state)
{
return aacdecSetSamplingFrequencyCom(sampling_frequency_index,
&(state->com));
}
/********************************************************************/
AACStatus aacdecSetSBRModeDecode(Ipp32s ModeDecodeHEAAC,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
if (state->com.ModeDecodeHEAACprofile != ModeDecodeHEAAC) {
state->com.ModeDecodeHEAACprofile = ModeDecodeHEAAC;
sbrdecInitFilter(state);
}
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecSetSBRModeDwnsmpl(Ipp32s ModeDwnsmplHEAAC,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
state->com.ModeDwnsmplHEAACprofile = ModeDwnsmplHEAAC;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecSetSBRSupport(eSBR_SUPPORT flag, AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
state->com.m_flag_SBR_support_lev = flag;
return AAC_OK;
}
/* PARAMETRIC STEREO */
AACStatus aacdecSetPSSupport( Ipp32s flag, AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
state->com.m_flag_PS_support_lev = flag;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecSetAudioObjectType(enum AudioObjectType audio_object_type,
AACDec *state,
Ipp8u *mem,
Ipp32s *size_all)
{
AACStatus aacStatus;
IppStatus ippStatus;
Ipp32s mode = FB_DECODER;
Ipp32s size = 10;
Ipp32s tmpSize, i;
IppStatus ippRes;
if (!state)
return AAC_NULL_PTR;
state->com.m_audio_object_type = audio_object_type;
if (AOT_AAC_LTP == audio_object_type)
mode = mode | FB_ENCODER;
if (mem) {
aacStatus = InitFilterbank(&(state->m_filterbank), mem, mode,
audio_object_type, &tmpSize);
if (aacStatus != AAC_OK) return aacStatus;
size += tmpSize;
mem += tmpSize;
if (AOT_AAC_MAIN == audio_object_type) {
ippStatus = ippsFDPGetSize_32f(1024, &tmpSize);
if (ippStatus != ippStsOk) return AAC_ALLOC;
for (i = 0; i < CH_MAX + COUPL_CH_MAX; i++) {
ippRes = ippsFDPInit_32f(&(state->pFDPState[i]),1024, mem);
if (ippStatus != ippStsOk) return AAC_ALLOC;
size += tmpSize;
mem += tmpSize;
}
}
} else {
aacStatus = InitFilterbank(NULL, mem, mode,
audio_object_type, &tmpSize);
if (aacStatus != AAC_OK) return aacStatus;
size += tmpSize;
if (AOT_AAC_MAIN == audio_object_type) {
ippStatus = ippsFDPGetSize_32f(1024, &tmpSize);
if (ippStatus != ippStsOk) return AAC_ALLOC;
size += (CH_MAX + COUPL_CH_MAX) * tmpSize;
}
}
*size_all = size;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecSetPCE(sProgram_config_element *pce,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
ippsCopy_8u((Ipp8u*)pce, (Ipp8u*)(&(state->com.m_pce)),
sizeof(sProgram_config_element));
state->com.m_is_pce_valid = 1;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecSetAdtsChannelConfiguration(Ipp32s adts_channel_configuration,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
if ((adts_channel_configuration < 0) || (adts_channel_configuration > 7))
return AAC_BAD_PARAMETER;
state->com.adts_channel_configuration = adts_channel_configuration;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecInitCRC(Ipp32s crc_enable,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
bs_CRC_reset((Ipp32u*)&state->com.crc);
state->com.crc_enable = crc_enable;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecSetCRC(Ipp32s crc,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
state->com.crc = crc;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecGetCRC(Ipp32s *crc,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
if (!crc)
return AAC_NULL_PTR;
*crc = state->com.crc;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecGetSbrFlagPresent(Ipp32s *SbrFlagPresent,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
*SbrFlagPresent = state->com.SbrFlagPresent;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecGetFrameSize(Ipp32s *frameSize,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
*frameSize = state->com.m_frame_size * state->com.m_up_sample;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecGetSampleFrequency(Ipp32s *freq,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
*freq = state->com.m_sampling_frequency * state->com.m_up_sample;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecGetNumDecodedFrames(Ipp32s *num,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
*num = state->com.m_frame_number;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecGetChannels(Ipp32s *ch,
AACDec *state)
{
if (!state)
return AAC_NULL_PTR;
*ch = state->com.m_channel_number;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecClose(AACDec *state)
{
if (state == NULL)
return AAC_OK;
FreeFilterbank(&(state->m_filterbank));
/* parametric stereo */
psFreeDecoder_32f( &(state->psState) );
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecGetInfo(cAudioCodecParams *a_info,
AACDec *state)
{
if (!a_info)
return AAC_NULL_PTR;
a_info->m_SuggestedInputSize = CH_MAX * 768;
a_info->m_SuggestedOutputSize = CH_MAX * 1024 * 2 /* upsampling SBR */ * sizeof(Ipp16s);
a_info->is_valid = 0;
if (!state)
return AAC_OK;
if (state->com.m_frame_number > 0) {
a_info->m_info_in.bitPerSample = 0;
a_info->m_info_out.bitPerSample = 16;
a_info->m_info_in.bitrate = 0;
a_info->m_info_out.bitrate = 0;
a_info->m_info_in.channels = state->com.m_channel_number;
a_info->m_info_out.channels = state->com.m_channel_number;
a_info->m_info_in.sample_frequency = state->com.m_sampling_frequency;
a_info->m_info_out.sample_frequency = state->com.m_sampling_frequency * state->com.m_up_sample ;
a_info->m_info_in.stream_type = AAC_AUD;
a_info->m_info_out.stream_type = PCM_AUD;
a_info->m_frame_num = state->com.m_frame_number;
a_info->is_valid = 1;
return AAC_OK;
}
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecGetDuration(Ipp32f *p_duration,
AACDec *state)
{
Ipp32f duration;
duration = (Ipp32f)(state->com.m_frame_number) * 1024;
*p_duration = duration / (Ipp32f)(state->com.m_sampling_frequency);
return AAC_OK;
}
/********************************************************************/
AACStatus aacdec_GetID3Len(Ipp8u *in,
Ipp32s inDataSize,
AACDec *state)
{
if (state->com.FirstID3Search != 0)
return AAC_OK;
if (inDataSize < 10)
return AAC_NOT_ENOUGH_DATA;
if ((in[0] == 'I') && (in[1] == 'D') && (in[2] == '3') && /* 'ID3' */
(in[3] < 0xFF) && (in[4] < 0xFF) && /* Version or revision will never be 0xFF */
(in[6] < 0x80) && (in[7] < 0x80) && (in[8] < 0x80) && (in[9] < 0x80)) { /* size */
state->com.id3_size = (in[6] << 21) + (in[7] << 14) + (in[8] << 7) + in[9] +
(in[5] & 0x10 ? 20 : 10);
} else {
state->com.id3_size = 0;
}
state->com.FirstID3Search = 1;
return AAC_OK;
}
/********************************************************************/
AACStatus aacdec_SkipID3(Ipp32s inDataSize,
Ipp32s *skipped,
AACDec *state)
{
*skipped = 0;
if (state->com.id3_size > 0) {
if (inDataSize < state->com.id3_size) {
*skipped = inDataSize;
state->com.id3_size -= inDataSize;
return AAC_NOT_ENOUGH_DATA;
} else {
*skipped = state->com.id3_size;
state->com.id3_size = 0;
return AAC_OK;
}
}
return AAC_OK;
}
/********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -