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

📄 levinson.cpp

📁 实现3GPP的GSM中AMR语音的CODECS。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* ------------------------------------------------------------------ * 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/levinson.c Funtions: Levinson_init           Levinson_reset           Levinson_exit           Levinson     Date: 06/02/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. Description: Synchronized file with UMTS version 3.2.0. Updated coding              template. Removed unnecessary include files. Description: Replaced basic_op.h and oper_32b.h with the header files of              the math functions used in the file. Description: Defined one local variable per line. Description: Added pOverflow as a variable passed into levinson as per              changed needed for EPOC. Description: Removed nested function calls by adding temp variables. Description: Fixed a bug where the returned value (32bit) was being stored in              a 16 bit temp variable. This was changed, and the value is now              stored in temp32_3. Description:  For levinson()              1. Eliminated unused include files.              2. Replaced array addressing by pointers              3. Eliminated math operations that unnecessary checked for                 saturation, by evaluating the operands              4. Combined shift operations to eliminate calls to mult() and                 shr(), extrac_h(), extract_l()              5. Eliminated if-else statements for sign extension when                 right-shifting Description:  1. Replaced OSCL mem type functions and eliminated include                  files that now are chosen by OSCL definitions               2. Modified "int" definition by Word16 Description:  Replaced "int" and/or "char" with OSCL defined types. Description: Changed round function name to pv_round to avoid conflict with              round function in C standard library. Description:------------------------------------------------------------------------------ MODULE DESCRIPTION This file contains the function the implements the Levinson-Durbin algorithm using double-precision arithmetic. This file also includes functions to initialize, allocate, and deallocate memory used by the Levinson function.------------------------------------------------------------------------------*//*----------------------------------------------------------------------------; INCLUDES----------------------------------------------------------------------------*/#include "levinson.h"#include "basicop_malloc.h"#include "basic_op.h"#include "div_32.h"#include "cnst.h"#include "oscl_mem.h"/*----------------------------------------------------------------------------; MACROS; Define module specific macros here----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; 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: Levinson_init------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    state = pointer to an array of pointers to structures of type            LevinsonState Outputs:    pointer pointed to by state points to the newly allocated memory to      be used by Levinson function Returns:    return_value = 0, if initialization was successful; -1, otherwise (int) Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function allocates and initializes the state memory used by the Levinson function.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES levinson.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEint Levinson_init (LevinsonState **state){  LevinsonState* s;  if (state == (LevinsonState **) NULL){      //fprint(stderr, "Levinson_init: invalid parameter\n");      return -1;  }  *state = NULL;  // allocate memory  if ((s= (LevinsonState *) malloc(sizeof(LevinsonState))) == NULL){      //fprint(stderr, "Levinson_init: can not malloc state structure\n");      return -1;  }  Levinson_reset(s);  *state = 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 Levinson_init(LevinsonState **state){    LevinsonState* s;    if (state == (LevinsonState **) NULL)    {        /*  fprint(stderr, "Levinson_init: invalid parameter\n");  */        return(-1);    }    *state = NULL;    /* allocate memory */    if ((s = (LevinsonState *) oscl_malloc(sizeof(LevinsonState))) == NULL)    {        /*  fprint(stderr, "Levinson_init:                            can not malloc state structure\n");  */        return(-1);    }    Levinson_reset(s);    *state = s;    return(0);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: Levinson_reset------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    state = pointer to structures of type LevinsonState Outputs:    old_A field of structure pointed to by state is initialized to 4096      (first location) and the rest to zeros Returns:    return_value = 0, if reset was successful; -1, otherwise (int) Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function initializes the state memory used by the Levinson function to zero.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES levinson.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEint Levinson_reset (LevinsonState *state){  Word16 i;  if (state == (LevinsonState *) NULL){      fprint(stderr, "Levinson_reset: invalid parameter\n");      return -1;  }  state->old_A[0] = 4096;  for(i = 1; i < M + 1; i++)      state->old_A[i] = 0;  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 Levinson_reset(LevinsonState *state){    Word16 i;    if (state == (LevinsonState *) NULL)    {        /*  fprint(stderr, "Levinson_reset: invalid parameter\n");  */        return(-1);    }    state->old_A[0] = 4096;    for (i = 1; i < M + 1; i++)    {        state->old_A[i] = 0;    }    return(0);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: Levinson_exit------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    state = pointer to an array of pointers to structures of type            LevinsonState Outputs:    pointer pointed to by state is set to the NULL address Returns:    None Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function deallocates the state memory used by the Levinson function.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES levinson.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEvoid Levinson_exit (LevinsonState **state){  if (state == NULL || *state == NULL)      return;  // deallocate memory  free(*state);  *state = NULL;  return;}------------------------------------------------------------------------------ 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]------------------------------------------------------------------------------*/void Levinson_exit(LevinsonState **state){    if (state == NULL || *state == NULL)    {        return;    }    /* deallocate memory */    oscl_free(*state);    *state = NULL;    return;}/****************************************************************************/

⌨️ 快捷键说明

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