⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sbrdec_hf_adjust_int.c

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*//////////////////////////////////////////////////////////////////////////////////                  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 "ipps.h"#include "ippsr.h"#include "sbrdec_element.h"#include "sbrdec_tables_int.h"#include "sbrdec_api_int.h"#include "sbrdec_own_int.h"#include <stdio.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/********************************************************************//* (1.584893192)^2 * Q28 */static const int THRESHOLD_GAIN_BOOST = 0x2830AFD3;/********************************************************************/static const Ipp32s POW_MINUS_UNIT[] =  { 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,  1, -1, 1, -1, 1, -1, 1, -1, 1, -1,  1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1,  1, -1, 1, -1, 1, -1, 1, -1, 1, -1};/********************************************************************/static const Ipp32s SIN_FI_RE[4] = { 1, 0, -1, 0 };/********************************************************************/static const Ipp32s SIN_FI_IM[4] = { 0, 1, 0, -1 };/********************************************************************//* Q30 */static const int TABLE_LIMIT_GAIN_INT_Q30[4] =  { 0x20138CA7, 0x40000000, 0x7FB27DCE, THRESHOLD_GAIN };/********************************************************************//* Q31 */static const int ihSmoothFilter[] = {  0x04130598, 0x0EBDB043, 0x1BECFA68, 0x2697A512, 0x2AAAAAAB};/**************************************************** * * SBR_TABLE_INVERT[i] = 2^0 / (i + 1), Q31 * see <sbrdec_math_int.c> && <sbrdec_own_int.h> * ****************************************************/static Ipp32s sbrUpdate_lA(Ipp32s bs_pointer, Ipp32s bs_frame_class, Ipp32s L_E){  Ipp32s  table_lA[3][3] = { {-1, -1, -1},  {-1, L_E + 1 - bs_pointer, -1},  {-1, L_E + 1 - bs_pointer, bs_pointer - 1}  };  Ipp32s  indx1, indx2;  Ipp32s  lA;  if ((bs_pointer > 1) || (bs_pointer < 0))    indx1 = 2;  else    indx1 = bs_pointer;  if (bs_frame_class == VARVAR)    indx2 = 1;  else    indx2 = bs_frame_class;  lA = table_lA[indx1][indx2];  return lA;}/********************************************************************/int sbrScale_64s32s(Ipp64s InData, int *scaleFactor){  int     OutData;  int     nGuardBit;  int     shift = 0;  if (InData >> 32) {    nGuardBit = sbrCalcGuardBit((int)(InData >> 32)) - 1; //remove "sign" bit    shift = 32 - nGuardBit;    OutData = (int)(InData >> shift);  } else if (InData >> 31) {    shift = 1;    OutData = (int)(InData >> shift);  } else {    OutData = (int)InData;  }  *scaleFactor = -shift;  return OutData;}/********************************************************************/int tmpCLIP_32s32s(int InData){  int     OutData;  if (InData > 0X3FFFFFFF)    OutData = 0X3FFFFFFF;  else if (InData < -0X3FFFFFFF)    OutData = -0X3FFFFFFF;  else    OutData = (int)(InData);  return OutData;}/********************************************************************/int sbrCheckUpDate(int gain_max, int scaleFactorGainMax, int gain,                   int scaleFactorGain){  int     flagUpDate = 0;  int     shift;  if (gain_max != THRESHOLD_GAIN) {    if (scaleFactorGain >= scaleFactorGainMax) {      shift = UMC_MIN(scaleFactorGain - scaleFactorGainMax, 31);      flagUpDate = ((gain >> shift) > gain_max ? 1 : 0);    } else {      shift = UMC_MIN(scaleFactorGainMax - scaleFactorGain, 31);      flagUpDate = (gain > (gain_max >> shift) ? 1 : 0);    }  }  return flagUpDate;}/********************************************************************/void sbrAdjustmentHF(Ipp32s** iYBufRe, Ipp32s** iYBufIm, Ipp32s *vEOrig,                     Ipp32s *vNoiseOrig, Ipp32s *vScaleFactorsEOrig,                     int iBufGain[][MAX_NUM_ENV_VAL],                     int iBufNoise[][MAX_NUM_ENV_VAL], sSbrDecCommon * sbr_com,                     Ipp32f *degPatched, Ipp8u *WorkBuffer, Ipp32s reset,                     Ipp32s ch, Ipp32s decode_mode){  /* VALUES */  Ipp32s  k, m, n, pos, kl, kh, l, p, i, j, delta_step, delta;  Ipp32s  sumEOrig, sumECurr, sumSM, sumQM, sumECurrGLim;  Ipp32s  gainMax, gainBoost, gainFilt, noiseFilt;  Ipp32s  iStart, iEnd;  Ipp32s  denominator;  Ipp32s  nResolution;  Ipp64s  sumE, sumEWoInterpol;  Ipp32s  bufSM[64];  Ipp32s  bufQM[64];  Ipp32s  bufEOrig[64];  Ipp32s  bufG[64];  Ipp32s  bufQMapped[64];  Ipp32s  bufECurr[64];  Ipp32s  resolution[2];  Ipp32s  scaleFactorsECurr[64];  Ipp32s  scaleFactorsGain[64];  Ipp32s  scaleFactorInterpolation;  Ipp32s  scaleFactorECurrMax;  Ipp32s  scaleFactorGainBoost;  Ipp32s  scaleFactorGainMax;  Ipp32s  scalef;  Ipp32s  iECurrWoInterpol;  Ipp32s  mulQ, mulQQ;  Ipp32s  data;  Ipp32s  iLimiterGains = TABLE_LIMIT_GAIN_INT_Q30[sbr_com->bs_limiter_gains];  Ipp32s  interpolation = sbr_com->bs_interpol_freq;  Ipp32s  fIndexNoise = 0;  Ipp32s  fIndexSine = 0;  Ipp32s  hSmoothLen = (sbr_com->bs_smoothing_mode == 0) ? 4 : 0;  Ipp32s  hSmoothLenConst = hSmoothLen;  Ipp32s  kx = sbr_com->kx;  Ipp32s  M = sbr_com->M;  Ipp32s  LE = sbr_com->L_E[ch];  Ipp32s  NQ = sbr_com->N_Q;  Ipp32s  lA = 0;  Ipp32s  offset_32s = 64 * sizeof(Ipp32s);  Ipp32s *pFreqTbl;  Ipp32s *pEOrigCurrAddress;  Ipp32s *sineIndxMap;  Ipp32s *sineIndxMapPrev;  Ipp32s *F[2];  Ipp32s** pYRe = iYBufRe + SBR_TIME_HFADJ;  Ipp32s** pYIm = iYBufIm + SBR_TIME_HFADJ;  /* CODE */  F[0] = sbr_com->f_TableLow;  F[1] = sbr_com->f_TableHigh;  resolution[0] = sbr_com->N_low;  resolution[1] = sbr_com->N_high;/* set memory */  sineIndxMap = (Ipp32s *)(WorkBuffer + 5 * offset_32s);  sineIndxMapPrev = sbr_com->S_index_mapped_prev[ch];  if (reset) {    sbr_com->FlagUpdate[ch] = 1;    sbr_com->indexNoise[ch] = 0;  }  ippsZero_32s(sineIndxMap, 64);  for (i = 0; i < sbr_com->N_high; i++) {    m = (sbr_com->f_TableHigh[i + 1] + sbr_com->f_TableHigh[i]) >> 1;    sineIndxMap[m - kx] = sbr_com->bs_add_harmonic[ch][i];  }  lA =    sbrUpdate_lA(sbr_com->bs_pointer[ch], sbr_com->bs_frame_class[ch],                 sbr_com->L_E[ch]);/* main loop */  for (l = 0; l < LE; l++) {    for (k = 0; k < sbr_com->L_Q[ch]; k++) {      if (sbr_com->tE[ch][l] >= sbr_com->tQ[ch][k] &&          sbr_com->tE[ch][l + 1] <= sbr_com->tQ[ch][k + 1])        break;    }    for (i = 0; i < NQ; i++) {      for (m = sbr_com->f_TableNoise[i]; m < sbr_com->f_TableNoise[i + 1]; m++) {        bufQMapped[m - kx] = vNoiseOrig[sbr_com->vSizeNoise[ch][k] + i];      }    }    delta = (l == lA || l == sbr_com->lA_prev[ch]) ? 1 : 0;    if (decode_mode == HEAAC_HQ_MODE)      hSmoothLen = (delta ? 0 : hSmoothLenConst);    else      hSmoothLen = 0;/* --------------------------------  Estimation envelope ---------------------------- *//* * new envelope's reset */    pos = 0;    scaleFactorECurrMax = 0;    nResolution = resolution[sbr_com->r[ch][l]];    pFreqTbl = F[sbr_com->r[ch][l]];    iStart = RATE * sbr_com->tE[ch][l];    iEnd = RATE * sbr_com->tE[ch][1 + l];    pEOrigCurrAddress = &vEOrig[sbr_com->vSizeEnv[ch][l]];    scaleFactorInterpolation = 0;    iECurrWoInterpol = 0;    for (p = 0; p < nResolution; p++) {      kl = pFreqTbl[p];      kh = pFreqTbl[p + 1];      delta_step = 0;      sumEWoInterpol = 0L;      for (j = kl; j < kh; j++) {        sumE = 0L;        for (i = iStart; i < iEnd; i++) {  // tmp PATCH          {            int     yRe, yIm;            yRe = tmpCLIP_32s32s(pYRe[i][j] >> 5);            yIm = tmpCLIP_32s32s(pYIm[i][j] >> 5);            sumE +=              _IPPS_MUL64_SBR_64S(yRe, yRe) + _IPPS_MUL64_SBR_64S(yIm, yIm);          }        }        delta_step = (sineIndxMap[pos] &&                      (l >= lA || sineIndxMapPrev[pos + kx])) ? 1 : delta_step;        /*         * PS: out scaleFactor is negative         */        bufECurr[pos] = sbrScale_64s32s(sumE, scaleFactorsECurr + pos);        denominator = SBR_TABLE_INVERT[(iEnd - iStart) - 1]; // Q31        // Q(-scaleFactorsECurr[pos]) * Q(31) * Q(-32) = Q(-... - 1)        bufECurr[pos] = MUL32_SBR_32S(bufECurr[pos], denominator);        scaleFactorsECurr[pos] -= 1;        if (!interpolation) {          sumEWoInterpol += sumE;        }        pos++;      } // end for (j = kl; j < kh; j++) {      if (!interpolation) {        int     scaleFactor;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -