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

📄 cl_ltp.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/cl_ltp.c Funtions: cl_ltp_init           cl_ltp_reset           cl_ltp_exit           cl_ltp     Date: 06/07/2000------------------------------------------------------------------------------ REVISION HISTORY Description:   Placed into PV template and optimized. Description: Synchronized file with UMTS version 3.2.0. Updated coding              template. Removed unnecessary include files. Description: Removed basic_op.h and oper_32b.h in the include section, and              added basicop_malloc.h. Description: Fixed typecasting issue in TI C compiler. Description: Added pOverflow parameter -- fixed minor template problem. Description:              1. Eliminated unused include file typedef.h.              2. Replaced array addressing by pointers              3. Eliminated if-else checks for saturation 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 functions that perform closed-loop fractional pitch search.------------------------------------------------------------------------------*//*----------------------------------------------------------------------------; INCLUDES----------------------------------------------------------------------------*/#include "cl_ltp.h"#include "basicop_malloc.h"#include "cnst.h"#include "convolve.h"#include "g_pitch.h"#include "pred_lt.h"#include "pitch_fr.h"#include "enc_lag3.h"#include "enc_lag6.h"#include "q_gain_p.h"#include "ton_stab.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: cl_ltp_init------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    state = Pointer to a pointer to a clLtpState structure Outputs:    state points to the newly created clLtpState structure. Returns:    This function returns 0 upon success and -1 upon failure. Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Allocates state memory and initializes state memory------------------------------------------------------------------------------ REQUIREMENTS None.------------------------------------------------------------------------------ REFERENCES cl_ltp.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEint cl_ltp_init (clLtpState **state){    clLtpState* s;    if (state == (clLtpState **) NULL){        fprintf(stderr, "cl_ltp_init: invalid parameter\n");        return -1;    }    *state = NULL;    // allocate memory    if ((s= (clLtpState *) malloc(sizeof(clLtpState))) == NULL){        fprintf(stderr, "cl_ltp_init: can not malloc state structure\n");        return -1;  }    // init the sub state    if (Pitch_fr_init(&s->pitchSt)) {        cl_ltp_exit(&s);        return -1;    }    cl_ltp_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 cl_ltp_init(clLtpState **state){    clLtpState* s;    if (state == (clLtpState **) NULL)    {        /*fprint(stderr, "cl_ltp_init: invalid parameter\n");*/        return(-1);    }    *state = NULL;    /* allocate memory */    if ((s = (clLtpState *) oscl_malloc(sizeof(clLtpState))) == NULL)    {        /*fprint(stderr, "cl_ltp_init: can not malloc state structure\n");*/        return(-1);    }    /* init the sub state */    if (Pitch_fr_init(&s->pitchSt))    {        cl_ltp_exit(&s);        return(-1);    }    cl_ltp_reset(s);    *state = s;    return(0);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: cl_ltp_reset------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    state = pointer to the clLtpState structure to be reset Outputs:    The state structure pointed to by clLtpState *state is reset. Returns:    The function returns int 0 if successful, -1 otherwise. Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Initializes state memory to zero.------------------------------------------------------------------------------ REQUIREMENTS------------------------------------------------------------------------------ REFERENCES cl_ltp.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001 ------------------------------------------------------------------------------ PSEUDO-CODEint cl_ltp_reset (clLtpState *state){    if (state == (clLtpState *) NULL){        fprintf(stderr, "cl_ltp_reset: invalid parameter\n");        return -1;    }    // Reset pitch search states    Pitch_fr_reset (state->pitchSt);    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 cl_ltp_reset(clLtpState *state){    if (state == (clLtpState *) NULL)    {        /*fprint(stderr, "cl_ltp_reset: invalid parameter\n");  */        return(-1);    }    /* Reset pitch search states */    Pitch_fr_reset(state->pitchSt);    return(0);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: cl_ltp_exit------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    clLtpState **state = Reference to the state object to be freed. Outputs:    The memory used by the structure which is pointed to by 'state'      is freed. Returns:    None Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION The memory used for state memory is freed------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES cl_ltp.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODEvoid cl_ltp_exit (clLtpState **state){    if (state == NULL || *state == NULL)        return;    // dealloc members    Pitch_fr_exit(&(*state)->pitchSt);

⌨️ 快捷键说明

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