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

📄 fmt_container.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
字号:
/*////////////////////////////////////////////////////////////////////////
//
// 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-2006 Intel Corporation. All Rights Reserved.
//
//   Intel(R)  Integrated Performance Primitives
//
//     Outlook 2003 Add-In sample
//
// 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.
//
// Purpose: Speech codec and format library.
*/

#include "fmt_container.h"
#include "uscreg.h"
#include "usc_cdcs.h"

typedef struct _fmtInfo {
   Ipp8s codecName[8];
   Ipp32s lFormatTag;
   Ipp32s fmtDetails;
} fmtInfo;

typedef struct _uscFormats {
   Ipp32s nEntries;
   fmtInfo *formatsInfo;
} uscFormats;

#define FORMAT_INFO_VERSION USC_MAKE_FORMAT_DET_VERSION(1,0)

fmtInfo uscFormatsInfo[] = {
   "AMRWB",      WAVE_FORMAT_IPP_AMRWB, USC_MAKE_FORMAT_DET(0,0,0,1,0),
   "AMRWB",   WAVE_FORMAT_IPP_AMRWBVAD, USC_MAKE_FORMAT_DET(1,0,0,1,0),
    "G723",       WAVE_FORMAT_IPP_G723, USC_MAKE_FORMAT_DET(0,1,1,0,0),
    "G723",    WAVE_FORMAT_IPP_G723VAD, USC_MAKE_FORMAT_DET(1,1,1,0,0),
    "G726",       WAVE_FORMAT_IPP_G726, USC_MAKE_FORMAT_DET(0,0,0,0,0),
    "G728",       WAVE_FORMAT_IPP_G728, USC_MAKE_FORMAT_DET(0,0,1,0,0),
   "G729I",      WAVE_FORMAT_IPP_G729I, USC_MAKE_FORMAT_DET(0,0,0,0,0),
   "G729I",   WAVE_FORMAT_IPP_G729IVAD, USC_MAKE_FORMAT_DET(1,0,0,0,0),
   "G729A",      WAVE_FORMAT_IPP_G729A, USC_MAKE_FORMAT_DET(0,0,0,0,0),
   "G729A",   WAVE_FORMAT_IPP_G729AVAD, USC_MAKE_FORMAT_DET(1,0,0,0,0),
  "GSMAMR",        WAVE_FORMAT_IPP_AMR, USC_MAKE_FORMAT_DET(0,0,0,1,0),
  "GSMAMR",     WAVE_FORMAT_IPP_AMRVAD, USC_MAKE_FORMAT_DET(1,0,0,1,0),
   "GSMFR",      WAVE_FORMAT_IPP_GSMFR, USC_MAKE_FORMAT_DET(0,0,0,0,0),
   "GSMFR",   WAVE_FORMAT_IPP_GSMFRVAD, USC_MAKE_FORMAT_DET(1,0,0,0,0),
    "G722",      WAVE_FORMAT_IPP_G7221, USC_MAKE_FORMAT_DET(0,0,0,0,0),
 "G729IFP",    WAVE_FORMAT_IPP_G729IFP, USC_MAKE_FORMAT_DET(0,0,0,0,0),
 "G729IFP", WAVE_FORMAT_IPP_G729IFPVAD, USC_MAKE_FORMAT_DET(1,0,0,0,0),
 "G729AFP",    WAVE_FORMAT_IPP_G729AFP, USC_MAKE_FORMAT_DET(0,0,0,0,0),
 "G729AFP", WAVE_FORMAT_IPP_G729AFPVAD, USC_MAKE_FORMAT_DET(1,0,0,0,0),
  "G722SB",     WAVE_FORMAT_IPP_G722SB, USC_MAKE_FORMAT_DET(0,1,1,0,0),
   "G711A",      WAVE_FORMAT_IPP_G711A, USC_MAKE_FORMAT_DET(0,0,1,0,0),
   "G711A",   WAVE_FORMAT_IPP_G711AVAD, USC_MAKE_FORMAT_DET(1,0,1,0,0),
   "G711U",      WAVE_FORMAT_IPP_G711U, USC_MAKE_FORMAT_DET(0,0,1,0,0),
   "G711U",   WAVE_FORMAT_IPP_G711UVAD, USC_MAKE_FORMAT_DET(1,0,1,0,0)
};

uscFormats USC_FORMATS = {
   24,
   uscFormatsInfo
};

Ipp32s USC_Formats::GetFormatsInfoVersion()
{
   return FORMAT_INFO_VERSION;
}

Ipp32s USC_Formats::GetNumFormats()
{
   return USC_FORMATS.nEntries;
}

Ipp32s USC_Formats::GetNameByFormatTag(Ipp32s lFormatTag, Ipp8s *pDstCodecName)
{
   Ipp32s i;
   for(i=0;i<USC_FORMATS.nEntries;i++) {
      if(USC_FORMATS.formatsInfo[i].lFormatTag==lFormatTag){
         strcpy((char *)pDstCodecName, (char *)USC_FORMATS.formatsInfo[i].codecName);
         return 1;
      }
   }
   return 0;
}

Ipp32s USC_Formats::GetFormatDetailsByFormatTag(Ipp32s lFormatTag, Ipp32s *pFormatDetails)
{
   Ipp32s i;
   for(i=0;i<USC_FORMATS.nEntries;i++) {
      if(USC_FORMATS.formatsInfo[i].lFormatTag==lFormatTag){
         *pFormatDetails = USC_FORMATS.formatsInfo[i].fmtDetails;
         return 1;
      }
   }
   return 0;
}

Ipp32s USC_Formats::CompareDetails(Ipp32s SrcDetails, Ipp32s RefDetails)
{
   if((GET_VAD_FROM_FORMAT_DET(SrcDetails)==GET_VAD_FROM_FORMAT_DET(RefDetails)) &&
      (GET_HPF_FROM_FORMAT_DET(SrcDetails)==GET_HPF_FROM_FORMAT_DET(RefDetails)) &&
      (GET_PF_FROM_FORMAT_DET(SrcDetails)==GET_PF_FROM_FORMAT_DET(RefDetails)) &&
      (GET_TRUNC_FROM_FORMAT_DET(SrcDetails)==GET_TRUNC_FROM_FORMAT_DET(RefDetails)) &&
      (GET_LAW_FROM_FORMAT_DET(SrcDetails)==GET_LAW_FROM_FORMAT_DET(RefDetails)))
      return 1;
   return 0;
}

Ipp32s USC_Formats::GetFormatTagByNameAndByDetails(const Ipp8s *pSrcCodecName, Ipp32s fmtDetails, Ipp32s *lFormatTag)
{
   Ipp32s i;
   for(i=0;i<USC_FORMATS.nEntries;i++) {
      if((strcmp((char *)USC_FORMATS.formatsInfo[i].codecName, (char *)pSrcCodecName)==0)&&
         CompareDetails(fmtDetails, USC_FORMATS.formatsInfo[i].fmtDetails)){
         *lFormatTag = USC_FORMATS.formatsInfo[i].lFormatTag;
         return 1;
      }
   }
   return 0;
}

typedef struct _StaticCodecs {
   Ipp8s codecName[8];
   void *funcPtr;
}StaticCodecs;

#define NUM_LINKED_CODECS 2

StaticCodecs LinkedCodecs[NUM_LINKED_CODECS] =
{
   "AMRWB", &USC_AMRWB_Fxns,
   "GSMAMR", &USC_GSMAMR_Fxns,
};

Ipp32s USC_LoadCodec::GetNumCodecs()
{
   return NUM_LINKED_CODECS;
}

Ipp8s *USC_LoadCodec::GetCodecName(Ipp32s index)
{
   if((index<0)||(index >= NUM_LINKED_CODECS)) return NULL;
   return LinkedCodecs[index].codecName;
}

void *TryToFindStatic(const Ipp8s *nameCodec)
{
   void *pAddr = NULL;
   Ipp32s i;
   for(i=0;i<NUM_LINKED_CODECS;i++) {
      if(strcmp((char *)nameCodec, (char *)LinkedCodecs[i].codecName) == 0) {
         pAddr = LinkedCodecs[i].funcPtr;
      }
   }
   return pAddr;
}

Ipp32s USC_LoadCodec::LoadUSCCodecByName(LoadedCodec *codec)
{
   codec->USC_Fns = NULL;

   codec->USC_Fns = (USC_Fxns*)TryToFindStatic(codec->codecName);
   if(codec->USC_Fns) {
      return 0;
   }
   return -1;
}

Ipp32s USC_LoadCodec::GetUSCCodecParamsByFormat(LoadedCodec *codec, Ipp32s lQuery, Ipp32s VADEnabled, UMC::SpeechCodecParams *cParams)
{
   Ipp32s CallResult;
   Ipp32s version;

   version = uscFmtContainer->GetFormatsInfoVersion();
   version = (version>>8)&0xFF;
   /* Check version of the format library. We estimate that ig greater or equal than 1.0*/
   if(version >= 1) {
      if(lQuery&BY_FORMATTAG) {
         CallResult = uscFmtContainer->GetNameByFormatTag(codec->lFormatTag, codec->codecName);
         if(CallResult==1) {
            uscFmtContainer->GetFormatDetailsByFormatTag(codec->lFormatTag, &codec->lIsVad);
            codec->lIsVad = GET_VAD_FROM_FORMAT_DET(codec->lIsVad);
            return 0;
         }
      } else if(lQuery&BY_NAME) {
         if(cParams==NULL) return -1;
         Ipp32s det = USC_MAKE_FORMAT_DET(codec->lIsVad,cParams->m_Hpf, cParams->m_Pf,cParams->m_Truncate,0);
         CallResult = uscFmtContainer->GetFormatTagByNameAndByDetails(codec->codecName, det, &codec->lFormatTag);
         if(CallResult==1) {
            return 0;
         }
      }
   }
   return -1;
}

⌨️ 快捷键说明

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