📄 sbrdec_dequant_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) 2005 Intel Corporation. All Rights Reserved.//*//********************************************************************/#include<ipps.h>#include<math.h>#include"sbrdec_api_fp.h"/********************************************************************/#ifndef ID_SCE#define ID_SCE 0x0#endif#ifndef ID_CPE#define ID_CPE 0x1#endif/********************************************************************/#ifndef UMC_MAX#define UMC_MAX(a,b) (((a) > (b)) ? (a) : (b))#endif#ifndef UMC_MIN#define UMC_MIN(a,b) (((a) < (b)) ? (a) : (b))#endif/********************************************************************//* SBR_TABLE_DEQUANT_INVERT[i] = 2^1 / (1 + 2^(12 - i)), FP */static const float SBR_TABLE_DEQUANT_INVERT[25] = { 0.000488162040710f, 0.000976085662842f, 0.001951219514012f, 0.003898635506630f, 0.007782101631165f, 0.015503875911236f, 0.030769230797887f, 0.060606060549617f, 0.117647059261799f, 0.222222222015262f, 0.400000000372529f, 0.666666666977108f, 1.000000000000000f, 1.333333333022893f, 1.599999999627471f, 1.777777777984738f, 1.882352940738201f, 1.939393939450383f, 1.969230769202113f, 1.984496124088764f, 1.992217898368835f, 1.996101364493370f, 1.998048780485988f, 1.999023914337158f, 1.999511837959290f};/********************************************************************/int sbrDequantInvertCouple(Ipp32f *pSrcDstL, Ipp16s *pSrcR, Ipp32f *pDstR, int len, int shift){ Ipp16s expR; int i; for (i = 0; i < len; i++) { expR = (Ipp16s)(pSrcR[i] >> shift);/* * confine expR [0, 24] */ if (expR < 0) expR = 0; if (expR > 24) expR = 24; pDstR[i] = pSrcDstL[i] * SBR_TABLE_DEQUANT_INVERT[24 - expR]; pSrcDstL[i] = pSrcDstL[i] * SBR_TABLE_DEQUANT_INVERT[expR]; } return 0; // OK}/********************************************************************/int sbrDequantNoiseUncouple(Ipp32f *pSrcDstL, Ipp16s *pSrcR, Ipp32f *pDstR, int len){ sbrDequantInvertCouple(pSrcDstL, pSrcR, pDstR, len, 0); return 0; // OK}/********************************************************************/int sbrDequantEnvUncouple(Ipp32f *pSrcDstL, Ipp16s *pSrcR, Ipp32f *pDstR, int len, int ampRes){ int shift = 1 - ampRes; sbrDequantInvertCouple(pSrcDstL, pSrcR, pDstR, len, shift); return 0; // OK}/********************************************************************/int sbrDequantNoiseMono(Ipp16s *pSrc, Ipp32f *pDst, int len){ int l; for (l = 0; l < len; l++) { pDst[l] = (float)pow(2.f, (float)(SBR_DEQUANT_OFFSET - pSrc[l])); } return 0;}/********************************************************************/static int sbrDequantEnvMono(Ipp16s *pSrc, Ipp32f *pDst, int len, int bs_amp_res){ int l; Ipp32f a = (bs_amp_res == 1) ? 1.0f : 0.5f; if (len <= 0) return 0; for (l = 0; l < len; l++) { pDst[l] = (float)pow(2.f, pSrc[l] * a + SBR_DEQUANT_OFFSET); } return 0; // OK}/********************************************************************/Ipp32s sbrDequantization(sSbrDecCommon * pSbrCom, sSbrDecWorkSpace * pSbrWS, Ipp32s ch, int bs_amp_res){ Ipp32s error = 0; // OK/* ORDINARY *//* * envelope */ sbrDequantEnvMono(pSbrCom->vecEnv[ch], pSbrWS->vecEnvOrig[ch], pSbrCom->vSizeEnv[ch][pSbrCom->L_E[ch]], bs_amp_res);/* * noise */ sbrDequantNoiseMono(pSbrCom->vecNoise[ch], pSbrWS->vecNoiseOrig[ch], pSbrCom->vSizeNoise[ch][pSbrCom->L_Q[ch]]);/* COUPLE MODE */ if (pSbrCom->bs_coupling == 1) {/* * envelope */ sbrDequantEnvUncouple(pSbrWS->vecEnvOrig[0], pSbrCom->vecEnv[1], pSbrWS->vecEnvOrig[1], pSbrCom->vSizeEnv[0][pSbrCom->L_E[1]], bs_amp_res);/* * noise */ sbrDequantNoiseUncouple(pSbrWS->vecNoiseOrig[0], pSbrCom->vecNoise[1], pSbrWS->vecNoiseOrig[1], pSbrCom->vSizeNoise[0][pSbrCom->L_Q[0]]); } return error;}/* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -