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

📄 ton_stab.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/ton_stab.c Funtions:     Date: 02/06/2002------------------------------------------------------------------------------ REVISION HISTORY Description:  For check_lsp()              1. Eliminated unused include files.              2. Replaced array addressing by pointers              3. Eliminated math operations that unnecessary checked for                 saturation this by evaluating the operands               For update_gp_clipping()              1. Replaced copy() with more efficient memcpy()              2. Replaced right shift function with right shift 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:------------------------------------------------------------------------------*//*----------------------------------------------------------------------------; INCLUDES----------------------------------------------------------------------------*/#include "ton_stab.h"#include "oper_32b.h"#include "cnst.h"#include "set_zero.h"#include "basic_op.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: ton_stab_init------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    state = pointer to pointer to structure type tonStabState. Outputs:    None Returns:    None. Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION  Function:   ton_stab_init  Purpose:    Allocates state memory and initializes state memory------------------------------------------------------------------------------ REQUIREMENTS  None.------------------------------------------------------------------------------ REFERENCES ton_stab.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEint ton_stab_init (tonStabState **state){    tonStabState* s;    if (state == (tonStabState **) NULL){        // fprintf(stderr, "ton_stab_init: invalid parameter\n");        return -1;    }    *state = NULL;    // allocate memory    if ((s= (tonStabState *) malloc(sizeof(tonStabState))) == NULL){        // fprintf(stderr, "ton_stab_init: can not malloc state structure\n");        return -1;    }    ton_stab_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 ton_stab_init(tonStabState **state){    tonStabState* s;    if (state == (tonStabState **) NULL)    {        /* fprintf(stderr, "ton_stab_init: invalid parameter\n"); */        return -1;    }    *state = NULL;    /* allocate memory */    if ((s = (tonStabState *) oscl_malloc(sizeof(tonStabState))) == NULL)    {        /* fprintf(stderr, "ton_stab_init: can not malloc state structure\n"); */        return -1;    }    ton_stab_reset(s);    *state = s;    return 0;}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: ton_stab_reset------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    st = pointer to pointer to structure type tonStabState. Outputs:    None Returns:    None. Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION  Function:   ton_stab_reset  Purpose:    Initializes state memory to zero------------------------------------------------------------------------------ REQUIREMENTS None.------------------------------------------------------------------------------ REFERENCES ton_stab.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEint ton_stab_reset (tonStabState *st){    if (st == (tonStabState *) NULL){        // fprintf(stderr, "ton_stab_init: invalid parameter\n");        return -1;    }    // initialize tone stabilizer state    st->count = 0;    Set_zero(st->gp, N_FRAME);    // Init Gp_Clipping    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 ton_stab_reset(tonStabState *st){    if (st == (tonStabState *) NULL)    {        /* fprintf(stderr, "ton_stab_init: invalid parameter\n"); */        return -1;    }    /* initialize tone stabilizer state */    st->count = 0;    Set_zero(st->gp, N_FRAME);    /* Init Gp_Clipping */    return 0;}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: ton_stab_exit------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    state = pointer to pointer to structure type tonStabState. Outputs:    None Returns:    None. Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION  Function:   ton_stab_exit  Purpose:    The memory used for state memory is freed------------------------------------------------------------------------------ REQUIREMENTS None.------------------------------------------------------------------------------ REFERENCES ton_stab.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEvoid ton_stab_exit (tonStabState **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 ton_stab_exit(tonStabState **state){    if (state == NULL || *state == NULL)        return;    /* deallocate memory */    oscl_free(*state);    *state = NULL;    return;}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: check_lsp------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:

⌨️ 快捷键说明

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