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

📄 dtx_enc.cpp

📁 实现3GPP的GSM中AMR语音的CODECS。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* ------------------------------------------------------------------ * Copyright (C) 2008 PacketVideo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. * See the License for the specific language governing permissions * and limitations under the License. * ------------------------------------------------------------------- *//****************************************************************************************Portions of this file are derived from the following 3GPP standard:    3GPP TS 26.073    ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec    Available from http://www.3gpp.org(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)Permission to distribute, modify and use this file under the standard licenseterms listed above has been obtained from the copyright holder.****************************************************************************************//*------------------------------------------------------------------------------ Pathname: ./audio/gsm-amr/c/src/dtx_enc.c Funtions: dtx_enc_init           dtx_enc_reset           dtx_enc_exit           dtx_enc           dtx_buffer           tx_dtx_handler     Date: 06/08/2000------------------------------------------------------------------------------ REVISION HISTORY Description: Updated template used to PV coding template. First attempt at          optimizing C code. Description: Updated file per comments gathered from Phase 2/3 review.          Synched up with new template (Inputs/Outputs section). Deleted          lines leftover from original code prior to the code section of          dtx_enc_exit function. Deleted confusing comment in the log_en          calculation in dtx_enc function. Restructured IF statement in          the calculation of the sum of squares of speech signals in          dtx_buffer. Description: Added setting of Overflow flag in inlined code. Description: Synchronized file with UTMS version 3.2.0. Updated coding              template. Removed unnecessary include files. Description: Made the following changes per comments from Phase 2/3 review:              1. Modified FOR loops to count down.              2. Fixed typecasting issue with TI C compiler.              3. Fixed comment in dtx_enc pseudo-code.              4. Added dtx_enc code comment pertaining to possible assembly                 implementation. Description: Added calls to add() in tx_dtx_handler. Updated copyright year. Description: Pass in pointer to overflow flag to all functions requiring this              flag. This is to make the library EPOC compatible. Description:  For dtx_enc_reset() only              1. Replaced copy() with memcpy.              2. Eliminated include file copy.h              3. Eliminated printf statement              For dtx_buffer()              1. Replaced copy() with memcpy.              2. Eliminated math operations that unnecessary checked for                 saturation, in some cases this by shifting before adding and                 in other cases by evaluating the operands              3. Unrolled loop to speed up execution Description:  For dtx_buffer()              1. Modified scaling and added check for saturation. Previous                 scaling was correct but altered precision, this cause bit                 exactness test failure. Description:  For dtx_buffer()              1. Modified scaling and saturation checks. Previous                 scaling was correct but altered precision, this cause bit                 exactness test failure for dtx vad2. Description:  Replaced OSCL mem type functions and eliminated include               files that now are chosen by OSCL definitions Description:  Replaced "int" and/or "char" with OSCL defined types. Description:------------------------------------------------------------------------------ MODULE DESCRIPTION This file contains the various functions that perform the computation of the Silence Indicator (SID) parameters when in Discontinuous Transmission (DTX) mode.------------------------------------------------------------------------------*//*----------------------------------------------------------------------------; INCLUDES----------------------------------------------------------------------------*/#include "dtx_enc.h"#include "q_plsf.h"#include "typedef.h"#include "mode.h"#include "basic_op.h"#include "log2.h"#include "lsp_lsf.h"#include "reorder.h"#include "oscl_mem.h"/*----------------------------------------------------------------------------; MACROS; Define module specific macros here----------------------------------------------------------------------------*/extern Word32 L_add(register Word32 L_var1, register Word32 L_var2, Flag *pOverflow);/*----------------------------------------------------------------------------; DEFINES; Include all pre-processor statements here. Include conditional; compile variables also.----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; LOCAL FUNCTION DEFINITIONS; Function Prototype declaration----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; LOCAL VARIABLE DEFINITIONS; Variable declaration - defined here and used outside this module----------------------------------------------------------------------------*//*------------------------------------------------------------------------------ FUNCTION NAME: dtx_enc_init------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    st = pointer to an array of pointers to structures of type         dtx_encState Outputs:    pointer pointed to by st is set to the address of the allocated      memory Returns:    return_value = 0, if initialization was successful; -1, otherwise (int) Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function allocates the state memory used by the dtx_enc function.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES dtx_enc.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEint dtx_enc_init (dtx_encState **st){  dtx_encState* s;  if (st == (dtx_encState **) NULL){    fprintf(stderr, "dtx_enc_init: invalid parameter\n");    return -1;  }  *st = NULL;  // allocate memory  if ((s= (dtx_encState *) malloc(sizeof(dtx_encState))) == NULL){    fprintf(stderr, "dtx_enc_init: can not malloc state structure\n");    return -1;  }  dtx_enc_reset(s);  *st = s;  return 0;}------------------------------------------------------------------------------ RESOURCES USED [optional] When the code is written for a specific target processor the the resources used should be documented below. HEAP MEMORY USED: x bytes STACK MEMORY USED: x bytes CLOCK CYCLES: (cycle count equation for this function) + (variable                used to represent cycle count for each subroutine                called)     where: (cycle count variable) = cycle count for [subroutine                                     name]------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function]------------------------------------------------------------------------------*/Word16 dtx_enc_init(dtx_encState **st){    dtx_encState* s;    if (st == (dtx_encState **) NULL)    {        return(-1);    }    *st = NULL;    /* allocate memory */    if ((s = (dtx_encState *) oscl_malloc(sizeof(dtx_encState))) == NULL)    {        return(-1);    }    dtx_enc_reset(s);    *st = s;    return(0);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: dtx_enc_reset------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    st = pointer to structures of type dtx_encState Outputs:    structure pointed to by st is initialized to its reset value Returns:    return_value = 1, if reset was successful; -1, otherwise (int) Global Variables Used:    None Local Variables Needed:    lsp_init_data = table containing LSP initialization values;            table elements are constants of type Word16;            table length is M------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function initializes the fields of the state memory used by dtx_enc to their reset values.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES dtx_enc.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEint dtx_enc_reset (dtx_encState *st){  Word16 i;  if (st == (dtx_encState *) NULL){    fprintf(stderr, "dtx_enc_reset: invalid parameter\n");    return -1;  }  st->hist_ptr = 0;  st->log_en_index = 0;  st->init_lsf_vq_index = 0;  st->lsp_index[0] = 0;  st->lsp_index[1] = 0;  st->lsp_index[2] = 0;  // Init lsp_hist[]  for(i = 0; i < DTX_HIST_SIZE; i++)  {    Copy(lsp_init_data, &st->lsp_hist[i * M], M);  }  // Reset energy history  Set_zero(st->log_en_hist, M);  st->dtxHangoverCount = DTX_HANG_CONST;  st->decAnaElapsedCount = 32767;  return 1;}------------------------------------------------------------------------------ RESOURCES USED [optional] When the code is written for a specific target processor the the resources used should be documented below. HEAP MEMORY USED: x bytes STACK MEMORY USED: x bytes CLOCK CYCLES: (cycle count equation for this function) + (variable                used to represent cycle count for each subroutine                called)     where: (cycle count variable) = cycle count for [subroutine                                     name]------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function]------------------------------------------------------------------------------*/Word16 dtx_enc_reset(dtx_encState *st){    Word16 i;    if (st == (dtx_encState *) NULL)    {        return(-1);    }    st->hist_ptr = 0;    st->log_en_index = 0;    st->init_lsf_vq_index = 0;    st->lsp_index[0] = 0;    st->lsp_index[1] = 0;    st->lsp_index[2] = 0;    /* Init lsp_hist[] */    for (i = 0; i < DTX_HIST_SIZE; i++)    {        oscl_memcpy(&st->lsp_hist[i * M], lsp_init_data, M*sizeof(Word16));    }    /* Reset energy history */    oscl_memset(st->log_en_hist, 0, sizeof(Word16)*M);    st->dtxHangoverCount = DTX_HANG_CONST;    st->decAnaElapsedCount = 32767;    return(1);}/****************************************************************************/

⌨️ 快捷键说明

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