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

📄 d8_31pf.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/d8_31pf.c Functions:     Date: 01/28/2002------------------------------------------------------------------------------ REVISION HISTORY Description: Modified to pass overflow flag through to basic math function. The flag is passed back to the calling function by pointer reference. Description: Per review comments... (1) Removed include of "count.h" and "basic_op.h" (2) Added includes of mult.h, shl.h, shr.h, add.h, sub.h, negate.h,     L_mult.h, and L_shr.h Description:  Replaced "int" and/or "char" with OSCL defined types. Description:------------------------------------------------------------------------------ MODULE DESCRIPTION*//*----------------------------------------------------------------------------; INCLUDES----------------------------------------------------------------------------*/#include "d8_31pf.h"#include "typedef.h"#include "basic_op.h"#include "cnst.h"/*----------------------------------------------------------------------------; MACROS; Define module specific macros here----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; DEFINES; Include all pre-processor statements here. Include conditional; compile variables also.----------------------------------------------------------------------------*/#define NB_PULSE  8           /* number of pulses  *//* define values/representation for output codevector and sign */#define POS_CODE  8191#define NEG_CODE  8191/*----------------------------------------------------------------------------; LOCAL FUNCTION DEFINITIONS; Function Prototype declaration----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; LOCAL VARIABLE DEFINITIONS; Variable declaration - defined here and used outside this module----------------------------------------------------------------------------*//*------------------------------------------------------------------------------ FUNCTION NAME: decompress10------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:   MSBs -- Word16 -- MSB part of the index   LSBs -- Word16 -- LSB part of the index   index1 -- Word16 -- index for first pos in pos_index[]   index2 -- Word16 -- index for second pos in pos_index[]   index3 -- Word16 -- index for third pos in pos_index[] Outputs:   pos_indx[] -- array of type Word16 -- position of 3 pulses (decompressed)   pOverflow  Flag set when overflow occurs, pointer of type Flag * Returns:    None Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES d8_31pf.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODE------------------------------------------------------------------------------ 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]------------------------------------------------------------------------------*/static void decompress10(    Word16 MSBs,        /* i : MSB part of the index                 */    Word16 LSBs,        /* i : LSB part of the index                 */    Word16 index1,      /* i : index for first pos in pos_index[]    */    Word16 index2,      /* i : index for second pos in pos_index[]   */    Word16 index3,      /* i : index for third pos in pos_index[]    */    Word16 pos_indx[],  /* o : position of 3 pulses (decompressed)   */    Flag  *pOverflow)   /* o : Flag set when overflow occurs         */{    Word16 ia;    Word16 ib;    Word16 ic;    Word32 tempWord32;    /*      pos_indx[index1] = ((MSBs-25*(MSBs/25))%5)*2 + (LSBs-4*(LSBs/4))%2;      pos_indx[index2] = ((MSBs-25*(MSBs/25))/5)*2 + (LSBs-4*(LSBs/4))/2;      pos_indx[index3] = (MSBs/25)*2 + LSBs/4;    */    if (MSBs > 124)    {        MSBs = 124;    }    ia =        mult(            MSBs,            1311,            pOverflow);    tempWord32 =        L_mult(            ia,            25,            pOverflow);    ia =        (Word16)        L_shr(            tempWord32,            1,            pOverflow);    ia =        sub(            MSBs,            ia,            pOverflow);    ib =        mult(            ia,            6554,            pOverflow);    tempWord32 =        L_mult(            ib,            5,            pOverflow);    ib =        (Word16)        L_shr(            tempWord32,            1,            pOverflow);    ib =        sub(            ia,            ib,            pOverflow);    ib =        shl(            ib,            1,            pOverflow);    ic =        shr(            LSBs,            2,            pOverflow);    ic =        shl(            ic,            2,            pOverflow);    ic =        sub(            LSBs,            ic,            pOverflow);    pos_indx[index1] =        add(            (Word16)ib,            (Word16)(ic & 0x1),            pOverflow);    ib =        mult(            ia,            6554,            pOverflow);    ib =        shl(            ib,            1,            pOverflow);    ic =        shr(            ic,            1,            pOverflow);    pos_indx[index2] =        add(            ib,            ic,            pOverflow);    ib =        shr(            LSBs,            2,            pOverflow);    ic =        mult(            MSBs,            1311,            pOverflow);    ic =        shl(            ic,            1,            pOverflow);    pos_indx[index3] =        add(            ib,            ic,            pOverflow);    return;}/*------------------------------------------------------------------------------ FUNCTION NAME: decompress_code------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    indx[] -- array of type Word16 -- position and sign of                                      8 pulses (compressed) Outputs:    sign_indx[] -- array of type Word16 -- signs of 4 pulses (signs only)    pos_indx[]  -- array of type Word16 -- position index of 8 pulses                                           (position only)    pOverflow pointer to type Flag -- Flag set when overflow occurs Returns:    None Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION    PURPOSE: decompression of the linear codewords to 4+three indeces             one bit from each pulse is made robust to errors by             minimizing the phase shift of a bit error.             4 signs (one for each track)             i0,i4,i1 => one index (7+3) bits, 3   LSBs more robust             i2,i6,i5 => one index (7+3) bits, 3   LSBs more robust             i3,i7    => one index (5+2) bits, 2-3 LSbs more robust------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES d8_31pf.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001------------------------------------------------------------------------------ PSEUDO-CODE------------------------------------------------------------------------------ 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

⌨️ 快捷键说明

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