📄 aac_dec_api_fp.c
字号:
/*
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright(c) 2003-2007 Intel Corporation. All Rights Reserved.
//
// Intel(R) Integrated Performance Primitives AAC Decode Sample for Windows*
//
// By downloading and installing this sample, you hereby agree that the
// accompanying Materials are being provided to you under the terms and
// conditions of the End User License Agreement for the Intel(R) Integrated
// Performance Primitives product previously accepted by you. Please refer
// to the file ippEULA.rtf or ippEULA.txt located in the root directory of your Intel(R) IPP
// product installation for more information.
//
// MPEG-4 and AAC are international standards promoted by ISO, IEC, ITU, ETSI
// and other organizations. Implementations of these standards, or the standard
// enabled platforms may require licenses from various entities, including
// Intel Corporation.
//
*/
/********************************************************************/
/* #define NEW_FDP_VERSION */
/* There are 2 possible ways to process frequency domain prediction (FDP) and */
/* intensity stereo (IS): */
/* 1. Process IS before FDP */
/* 2. Process IS after FDP */
/* Unfortunately, various sets of test vectors use both ways, for example set */
/* 2 use 1 way, 7 - 2. */
/********************************************************************/
#include <stdlib.h>
#include "aac_dec_fp.h"
#include "aac_dec_decoding_fp.h"
#include "aac_dec_own_fp.h"
#include "aac_dec_huff_tables_fp.h"
/* SBR */
#include "aac_dec_sbr_fp.h"
#include "sbr_dec_tabs_fp.h"
/* PS */
#include "ps_dec_parser.h"
/********************************************************************/
AACStatus aacdecReset(AACDec *state)
{
Ipp32s i, j;
if (!state)
return AAC_NULL_PTR;
state->com.decodedBytes = 0;
state->com.m_frame_number = 0;
state->com.m_index_1st = 0;
state->com.m_index_2nd = 1;
state->com.m_index_3rd = 2;
state->com.noiseState = 0;
state->com.SbrFlagPresent = 0;
/* set default params: (HQ, DWNSMPL_ON, SBR_ENABLE) */
//------------------------------------------------------------
if( HEAAC_PARAMS_UNDEF == state->com.ModeDecodeHEAACprofile){
state->com.ModeDecodeHEAACprofile = HEAAC_HQ_MODE;
}
if ( HEAAC_PARAMS_UNDEF == state->com.ModeDwnsmplHEAACprofile ) {
state->com.ModeDwnsmplHEAACprofile = HEAAC_DWNSMPL_ON;
}
if (SBR_UNDEF == state->com.m_flag_SBR_support_lev) {
state->com.m_flag_SBR_support_lev = SBR_ENABLE;
}
//------------------------------------------------------------
for (i = 0; i < CH_MAX + COUPL_CH_MAX; i++) {
ippsZero_32f(state->m_ltp_buf[i][0], 2048);
ippsZero_32f(state->m_ltp_buf[i][1], 2048);
ippsZero_32f(state->m_ltp_buf[i][2], 2048);
ippsZero_32f(state->m_prev_samples[i], 2048);
ippsZero_32f(state->m_gcOverlapBuffer[i], 2048);
ippsZero_32f(state->SSR_IPQFState[i].app_pqfbuf0, 24);
ippsZero_32f(state->SSR_IPQFState[i].app_pqfbuf1, 24);
ippsZero_32f(state->SSR_IPQFState[i].app_pqfbuf2, 24);
ippsZero_32f(state->SSR_IPQFState[i].app_pqfbuf3, 24);
state->com.m_prev_win_shape[i] = 0;
for (j = 0; j < 4; j++) {
state->com.prevSSRInfo[i][j].adjust_num = 0;
}
for (j = 0; j < 8; j++) {
state->com.SSRInfo[i][0][j].adjust_num = 0;
state->com.SSRInfo[i][1][j].adjust_num = 0;
state->com.SSRInfo[i][2][j].adjust_num = 0;
state->com.SSRInfo[i][3][j].adjust_num = 0;
}
}
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecGetSize(Ipp32s *pStateSize)
{
Ipp32s i;
/* HE-AAC */
Ipp32s SizeWorkBuf = 0, mStateSize;
Ipp32s pSize[12], mSize;
Ipp32s pSbrSize[10], mSbrSize;
Ipp32s pPsSize[10], mPsSize = 0;
Ipp32s mOneFilterSize, mFilterSize;
Ipp32s pOneFilterSize[7];
Ipp32s mSBRDecSize, mPSDecSize = 0;
/* aligned size of AACDec */
mStateSize = __ALIGNED(sizeof(AACDec));
/* size of huffman_tables */
mSize = 0;
for (i = 0; i < 12; i++) {
if(ippsVLCDecodeGetSize_32s(vlcBooks[i],
vlcTableSizes[i],
vlcSubTablesSizes[i],
vlcNumSubTables[i],
&(pSize[i])) != ippStsOk) {
return AAC_ALLOC;
} else {
pSize[i] = __ALIGNED(pSize[i]);
mSize += pSize[i];
}
}
/* size of sbrHuffTables */
mSbrSize = 0;
for (i = 0; i < 10; i++) {
if (ippsVLCDecodeGetSize_32s(vlcSbrBooks[i],
vlcSbrTableSizes[i],
vlcSbrSubTablesSizes[i],
vlcSbrNumSubTables[i],
&(pSbrSize[i])) != ippStsOk) {
return AAC_ALLOC;
} else {
pSbrSize[i] = __ALIGNED(pSbrSize[i]);
mSbrSize += pSbrSize[i];
}
}
#if 1
/* size of psHuffTabs */
mPsSize = 0;
for (i = 0; i < 10; i++) {
if (ippsVLCDecodeGetSize_32s(vlcPsBooks[i],
vlcPsTableSizes[i],
vlcPsSubTablesSizes[i],
vlcPsNumSubTables[i],
&(pPsSize[i])) != ippStsOk) {
return AAC_ALLOC;
} else {
pPsSize[i] = __ALIGNED(pPsSize[i]);
mPsSize += pPsSize[i];
}
}
#endif
if (sbrdecGetFilterSize(pOneFilterSize))
return AAC_ALLOC;
mOneFilterSize = pOneFilterSize[0] + pOneFilterSize[0] + pOneFilterSize[1];
mOneFilterSize += pOneFilterSize[2] + pOneFilterSize[2] + pOneFilterSize[3];
mOneFilterSize += pOneFilterSize[4] + pOneFilterSize[4] + pOneFilterSize[5];
SizeWorkBuf = IPP_MAX(pOneFilterSize[6], SBR_MINSIZE_OF_WORK_BUFFER);
mFilterSize = __ALIGNED(mOneFilterSize * CH_MAX + SizeWorkBuf);
sbrDecoderGetSize(&mSBRDecSize);
psDecoderGetSize(&mPSDecSize);
pStateSize[0] = mStateSize + mSize + mSbrSize + mPsSize +
mFilterSize + __ALIGNED( mSBRDecSize ) + __ALIGNED( mPSDecSize );
return AAC_OK;
}
/********************************************************************/
AACStatus aacdecInit(AACDec *state)
{
Ipp32s i;
/* HE-AAC */
Ipp32s SizeWorkBuf = 0, mStateSize;
Ipp32s pSize[12], mSize;
Ipp32s pSbrSize[10], mSbrSize, mSBRDecSize;
Ipp32s pPsSize[10], mPsSize = 0;
Ipp8u *pMem;
Ipp32s mOneFilterSize, mFilterSize;
Ipp32s pOneFilterSize[7];
sSbrDecFilter* sbr_filter[CH_MAX];
sSBRBlock* sbrBlock[CH_MAX];
if (!state)
return AAC_NULL_PTR;
for (i = 0; i < CH_MAX; i++) {
sbr_filter[i] = &(state->sbr_filter[i]);
sbrBlock[i] = &(state->sbrBlock[i]);
}
/* aligned size of AACDec */
mStateSize = __ALIGNED(sizeof(AACDec));
/* size of huffman_tables */
mSize = 0;
for (i = 0; i < 12; i++) {
if(ippsVLCDecodeGetSize_32s(vlcBooks[i],
vlcTableSizes[i],
vlcSubTablesSizes[i],
vlcNumSubTables[i],
&(pSize[i])) != ippStsOk) {
return AAC_ALLOC;
} else {
pSize[i] = __ALIGNED(pSize[i]);
mSize += pSize[i];
}
}
/* size of sbrHuffTables */
mSbrSize = 0;
for (i = 0; i < 10; i++) {
if (ippsVLCDecodeGetSize_32s(vlcSbrBooks[i],
vlcSbrTableSizes[i],
vlcSbrSubTablesSizes[i],
vlcSbrNumSubTables[i],
&(pSbrSize[i])) != ippStsOk) {
return AAC_ALLOC;
} else {
pSbrSize[i] = __ALIGNED(pSbrSize[i]);
mSbrSize += pSbrSize[i];
}
}
#if 1
/* size of psHuffTables */
mPsSize = 0;
for (i = 0; i < 10; i++) {
if (ippsVLCDecodeGetSize_32s(vlcPsBooks[i],
vlcPsTableSizes[i],
vlcPsSubTablesSizes[i],
vlcPsNumSubTables[i],
&(pPsSize[i])) != ippStsOk) {
return AAC_ALLOC;
} else {
pPsSize[i] = __ALIGNED(pPsSize[i]);
mPsSize += pPsSize[i];
}
}
#endif
if (sbrdecGetFilterSize(pOneFilterSize))
return AAC_ALLOC;
mOneFilterSize = pOneFilterSize[0] + pOneFilterSize[0] + pOneFilterSize[1];
mOneFilterSize += pOneFilterSize[2] + pOneFilterSize[2] + pOneFilterSize[3];
mOneFilterSize += pOneFilterSize[4] + pOneFilterSize[4] + pOneFilterSize[5];
SizeWorkBuf = IPP_MAX(pOneFilterSize[6], SBR_MINSIZE_OF_WORK_BUFFER);
mFilterSize = __ALIGNED(mOneFilterSize * CH_MAX + SizeWorkBuf);
/* important: here HEAAC params must be UNDEF */
state->com.ModeDecodeHEAACprofile = HEAAC_PARAMS_UNDEF;
state->com.ModeDwnsmplHEAACprofile= HEAAC_PARAMS_UNDEF;
state->com.m_flag_SBR_support_lev = SBR_UNDEF;
state->com.m_flag_PS_support_lev = PS_DISABLE;
aacdecReset(state);
state->com.FirstID3Search = 0;
state->com.id3_size = 0;
state->com.m_is_chmap_valid = 0;
state->com.m_is_pce_valid = 0;
state->com.m_sampling_frequency = 0;
state->com.m_sampling_frequency_index = 0;
state->com.m_channel_number = 1;
state->com.m_channel_number_save = 1;
state->com.m_channel_number_all = 0;
state->com.m_element_number = 0;
state->com.m_channel_config = 0;
state->com.m_frame_size = 1024;
state->com.adts_channel_configuration = -1;
state->com.m_audio_object_type = AOT_UNDEF;
for (i = 0; i < 16; i++) {
state->com.huffman_tables[i] = NULL;
}
for (i = 0; i < 10; i++) {
state->com.sbrHuffTables[i] = NULL;
}
for (i = 0; i < CH_MAX + COUPL_CH_MAX; i++) {
state->pFDPState[i] = NULL;
}
state->pWorkBuffer = NULL;
state->m_filterbank.p_mdct_inv_long = NULL;
state->m_filterbank.p_mdct_inv_short = NULL;
state->m_filterbank.p_buffer_inv = NULL;
state->m_filterbank.p_mdct_fwd_long = NULL;
state->m_filterbank.p_mdct_fwd_short = NULL;
state->m_filterbank.p_buffer_fwd = NULL;
pMem = (Ipp8u *)state + mStateSize;
for (i = 0; i < 12; i++) {
state->com.huffman_tables[i] = pMem;
if (ippsVLCDecodeInit_32s(vlcBooks[i],
vlcTableSizes[i],
vlcSubTablesSizes[i],
vlcNumSubTables[i],
state->com.huffman_tables[i]) != ippStsOk) {
// aacdecClose(state);
return AAC_ALLOC;
} else {
pMem += pSize[i];
}
}
for (i = 0; i < 10; i++) {
state->com.sbrHuffTables[i] = (IppsVLCDecodeSpec_32s *)pMem;
if(ippsVLCDecodeInit_32s(vlcSbrBooks[i],
vlcSbrTableSizes[i],
vlcSbrSubTablesSizes[i],
vlcSbrNumSubTables[i],
state->com.sbrHuffTables[i]) != ippStsOk) {
// aacdecClose(state);
return AAC_ALLOC;
} else {
pMem += pSbrSize[i];
}
}
#if 1
for (i = 0; i < 10; i++) {
state->psState.comState.psHuffTables[i] = (IppsVLCDecodeSpec_32s *)pMem;
if(ippsVLCDecodeInit_32s(vlcPsBooks[i],
vlcPsTableSizes[i],
vlcPsSubTablesSizes[i],
vlcPsNumSubTables[i],
state->psState.comState.psHuffTables[i]) != ippStsOk) {
// aacdecClose(state);
return AAC_ALLOC;
} else {
pMem += pPsSize[i];
}
}
#endif
(state->com.m_sce).stream.p_huffman_tables = (void **)&(state->com.huffman_tables[0]);
(state->com.m_cpe).streams[0].p_huffman_tables = (void **)&(state->com.huffman_tables[0]);
(state->com.m_cpe).streams[1].p_huffman_tables = (void **)&(state->com.huffman_tables[0]);
(state->com.m_cce).stream.p_huffman_tables = (void **)&(state->com.huffman_tables[0]);
(state->com.m_lfe).stream.p_huffman_tables = (void **)&(state->com.huffman_tables[0]);
(state->com.m_sce).stream.vlcShifts = vlcShifts;
(state->com.m_cpe).streams[0].vlcShifts = vlcShifts;
(state->com.m_cpe).streams[1].vlcShifts = vlcShifts;
(state->com.m_cce).stream.vlcShifts = vlcShifts;
(state->com.m_lfe).stream.vlcShifts = vlcShifts;
(state->com.m_sce).stream.vlcOffsets = vlcOffsets;
(state->com.m_cpe).streams[0].vlcOffsets = vlcOffsets;
(state->com.m_cpe).streams[1].vlcOffsets = vlcOffsets;
(state->com.m_cce).stream.vlcOffsets = vlcOffsets;
(state->com.m_lfe).stream.vlcOffsets = vlcOffsets;
(state->com.m_sce).stream.vlcTypes = vlcTypes;
(state->com.m_cpe).streams[0].vlcTypes = vlcTypes;
(state->com.m_cpe).streams[1].vlcTypes = vlcTypes;
(state->com.m_cce).stream.vlcTypes = vlcTypes;
(state->com.m_lfe).stream.vlcTypes = vlcTypes;
sbrdecDrawMemMap(sbr_filter, pMem, pOneFilterSize);
state->pWorkBuffer = pMem + mOneFilterSize * CH_MAX;
if (sbrdecInitFilter(state))
return AAC_ALLOC;
pMem += mFilterSize;
sbrInitDecoder(sbrBlock, pMem);
for (i = 0; i < CH_MAX; i++) {
ippsCopy_8u((const Ipp8u *)(state->com.sbrHuffTables),
(Ipp8u *)(state->sbrBlock[i].comState.sbrHuffTables), 10 * sizeof(void *));
}
/* PS DEC */
sbrDecoderGetSize( &mSBRDecSize );
pMem += __ALIGNED(mSBRDecSize);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -