📄 sbrdec_hf_gen_int.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) 2005 Intel Corporation. All Rights Reserved.//*//********************************************************************/#include<math.h>#include<string.h>#include "ipps.h"#include "ippac.h"#include "sbrdec_element.h"#include "sbrdec_setting_int.h"#include "sbrdec_own_int.h"/********************************************************************/#ifndef UMC_MIN#define UMC_MIN(a,b) (((a) < (b)) ? (a) : (b))#endif#ifndef UMC_MAX#define UMC_MAX(a,b) (((a) > (b)) ? (a) : (b))#endif/********************************************************************//* Q(31) */static Ipp32s SBR_TABLE_NEW_BW_INT_Q31[4][4] = { {0x00000000, 0x4ccccccd, 0x73333333, 0x7d70a3d7}, {0x4ccccccd, 0x60000000, 0x73333333, 0x7d70a3d7}, {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7}, {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7},};/******************************************************************** * * OutPut data: iBwArray, Q(14) ********************************************************************/static Ipp32s sbrCalcChirpFactors(Ipp32s N_Q, Ipp32s *bs_invf_mode_prev, Ipp32s *bs_invf_mode, Ipp32s *iBwArray ){ Ipp32s i; Ipp32s iNewBw, iTmpBw; for (i = 0; i < N_Q; i++) { iNewBw = SBR_TABLE_NEW_BW_INT_Q31[bs_invf_mode_prev[i]][bs_invf_mode[i]]; if (iNewBw < iBwArray[i]) iTmpBw = MUL32_SBR_32S(0x60000000, iNewBw) + MUL32_SBR_32S(0x20000000, iBwArray[i]); else iTmpBw = MUL32_SBR_32S(0x74000000, iNewBw) + MUL32_SBR_32S(0x0C000000, iBwArray[i]); iTmpBw = iTmpBw << 1; iBwArray[i] = iTmpBw; if (iTmpBw < 0x02000000) iBwArray[i] = 0; bs_invf_mode_prev[i] = bs_invf_mode[i]; } return 0;}/********************************************************************/static Ipp32s sbrHFGenerator( /* * in data */ Ipp32s** iXBufRe, Ipp32s** iXBufIm, Ipp32s *vbwArray, Ipp32s *alpha_0Re, Ipp32s *alpha_0Im, Ipp32s *alpha_1Re, Ipp32s *alpha_1Im, sSbrDecCommon * pSbr, int ch, Ipp32f *deg, Ipp32f *degPatched, /* * out data */ Ipp32s** iYBufRe, Ipp32s** iYBufIm, Ipp32s mode){ /* values */ Ipp32s i, x, q, k_0, k, p, g, l; Ipp32s l_start = RATE * pSbr->tE[ch][0]; Ipp32s l_end = RATE * pSbr->tE[ch][pSbr->L_E[ch]]; int iBwAr, iBwAr2; int sumYRe, sumYIm; int icA0Re, icA0Im, icA1Re, icA1Im; int** pXRe = iXBufRe + SBR_TIME_HFADJ; int** pXIm = iXBufIm + SBR_TIME_HFADJ; int** pYRe = iYBufRe + SBR_TIME_HFADJ; int** pYIm = iYBufIm + SBR_TIME_HFADJ; /* code */ for (i = 0; i < pSbr->numPatches; i++) { k_0 = 0; for (q = 0; q < i; q++) { k_0 += pSbr->patchNumSubbands[q]; } k_0 += pSbr->kx; for (x = 0; x < pSbr->patchNumSubbands[i]; x++) { k = k_0 + x; p = pSbr->patchStartSubband[i] + x; for (g = 0; g < pSbr->N_Q; g++) { if ((k >= pSbr->f_TableNoise[g]) && (k < pSbr->f_TableNoise[g + 1])) break; }/* if (mode == HEAAC_LP_MODE) { if (x == 0) degPatched[k] = 0.0f; else degPatched[k] = deg[p]; }*/ iBwAr = vbwArray[g];// Q(31) /****************************************** * code may be optimized because: * if ( 0 == iBwAr ) * pY[ l ][ k ] = pX[ l ][ p ] ONLY!!! * else * ippsPredictCoef_SBR_C_32s_D2L(...) * and code is written below, * but it is impossible because * ipp function works only k = [0, k0) * ******************************************/ // Q(31) * Q(31) * Q(-32) = Q(30) iBwAr2 = MUL32_SBR_32S(vbwArray[g], vbwArray[g]); iBwAr2 <<= 1; // Q(31)// BwArray // Q(31) * Q(29) * Q(-32) = Q(28) icA0Re = MUL32_SBR_32S(iBwAr, alpha_0Re[p]); // Q(31) * Q(29) * Q(-32) = Q(28) icA0Im = MUL32_SBR_32S(iBwAr, alpha_0Im[p]); // Q(31) * Q(29) * Q(-32) = Q(28) icA1Re = MUL32_SBR_32S(iBwAr2, alpha_1Re[p]); // Q(31) * Q(29) * Q(-32) = Q(28) icA1Im = MUL32_SBR_32S(iBwAr2, alpha_1Im[p]); for (l = l_start; l < l_end; l++) {/* * bw * Alpha0 * XLow[l-1] = Q(28) * Q(5) * Q(-32) = Q(1) */ sumYRe = MUL32_SBR_32S(pXRe[l - 1][p],icA0Re) - MUL32_SBR_32S(pXIm[l - 1][p], icA0Im); sumYIm = MUL32_SBR_32S(pXRe[l - 1][p],icA0Im) + MUL32_SBR_32S(pXIm[l - 1][p], icA0Re);/* * bw^2 * Alpha1 * XLow[l-2] = Q(28) * Q(5) * Q(-32) = Q(1) */ sumYRe += MUL32_SBR_32S(pXRe[l - 2][p],icA1Re) - MUL32_SBR_32S(pXIm[l - 2][p], icA1Im); sumYIm += MUL32_SBR_32S(pXRe[l - 2][p], icA1Im) + MUL32_SBR_32S(pXIm[l - 2][p], icA1Re);/* * this check may be improved in the future */ if (abs(sumYRe) < (((1 << 30) - 1) >> 4) && abs(sumYIm) < (((1 << 30) - 1) >> 4)) { sumYRe <<= 4; sumYIm <<= 4; } else { sumYRe = (sumYRe > 0) ? (1 << 30) - 1 : -(1 << 30); sumYIm = (sumYIm > 0) ? (1 << 30) - 1 : -(1 << 30); } pYRe[l][k] = pXRe[l - 0][p] + sumYRe; pYIm[l][k] = pXIm[l - 0][p] + sumYIm; } } }/* * if (mode == HEAAC_LP_MODE) { k_0 = 0; for (q = 0; q < pSbr->numPatches; * q++) k_0 += pSbr->patchNumSubbands[q]; * * for (k = pSbr->kx + k_0; k < MAX_NUM_ENV_VAL; k++) degPatched[k] = 0; } */ return 0; // OK}/********************************************************************/Ipp32s sbrGenerationHF(Ipp32s** iXBufRe, Ipp32s** iXBufIm, Ipp32s** iYBufRe, Ipp32s** iYBufIm, sSbrDecCommon * sbr_com, Ipp32s *bwArray, Ipp32f *degPatched, Ipp32s ch, int decode_mode, Ipp32s *pWorkBuffer){ Ipp32s *alpha_0Re = pWorkBuffer; Ipp32s *alpha_1Re = pWorkBuffer + 1 * MAX_NUM_ENV_VAL; Ipp32s *alpha_0Im = 0; Ipp32s *alpha_1Im = 0; alpha_0Im = pWorkBuffer + 2 * MAX_NUM_ENV_VAL; alpha_1Im = pWorkBuffer + 3 * MAX_NUM_ENV_VAL; ippsZero_32s(pWorkBuffer, 4 * MAX_NUM_ENV_VAL); sbrCalcChirpFactors(sbr_com->N_Q, &(sbr_com->bs_invf_mode_prev[ch][0]), &(sbr_com->bs_invf_mode[ch][0]), bwArray); /******************************************************************** * see comment about ippsPredictCoef_SBR_C_32s_D2L in sbrHFGenerator ********************************************************************/ ippsPredictCoef_SBR_C_32s_D2L(iXBufRe, iXBufIm, alpha_0Re, alpha_0Im, alpha_1Re, alpha_1Im, sbr_com->k0, NUM_TIME_SLOTS * RATE + 6, 0); sbrHFGenerator(iXBufRe, iXBufIm, bwArray, alpha_0Re, alpha_0Im, alpha_1Re, alpha_1Im, sbr_com, ch, 0, 0, iYBufRe, iYBufIm, decode_mode); return 0; // OK}/********************************************************************//* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -