/* ------------------------------------------------------------------
* 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 license
terms listed above has been obtained from the copyright holder.
****************************************************************************************/
/*
------------------------------------------------------------------------------
Pathname: ./audio/gsm-amr/c/src/dec_amr.c
Funtions: Decoder_amr_init
Decoder_amr_reset
Decoder_amr
Date: 04/11/2000
------------------------------------------------------------------------------
REVISION HISTORY
Description: Updated template used to PV coding template. First attempt at
optimizing C code.
Description: Synchronized file with UMTS version 3.2.0. Updated coding
template. Removed unnecessary include files.
Description: Made the following changes per comments from Phase 2/3 review:
1. Fixed Input/Output descriptions by adding typedefs and
clarifying definitions.
2. Used #define instead of hard-coded loop counts.
3. Modified FOR loops to count down.
4. Copied function descriptions from dec_amr.h header file.
5. Defined one local variable per line.
Description: Copied function descriptions from header file (forgot to do it
prior to checking-in -- oops!).
Description: Removed the function decoder_amr_exit.
The decoder_amr related structure is no longer dynamically allocated.
Also, modified function calls throughout to reflect the fact that the members
of the structure Decoder_amrState are no longer pointers to be set via
malloc, but full-blown structures. (Changes of the type D_plsfState *lsfState
to D_plsfState lsfState)
Description: Fixed bug in the Decoder_amr() caused non-bit exactness. The
Overflow flag was inadvertently taken out of the IF statement
that calls agc2 and Syn_filt. It was restored to the original
form. Updated copyright year.
Description: Adding changes for EPOC regarding pOverflow being passed in
rather than being a global variable.
Description: Initialize overflow flag in Decoder_amr_init() and
Decoder_amr_reset(). Initialize pointer to overflow flag in
Decoder_amr().
Description: Changed round function name to pv_round to avoid conflict with
round function in C standard library.
Description: Replaced OSCL mem type functions and eliminated include
files that now are chosen by OSCL definitions
Description: Replaced "int" and/or "char" with defined types.
Added proper casting (Word32) to some left shifting operations
Description:
------------------------------------------------------------------------------
MODULE DESCRIPTION
This file contains the function used to decode one speech frame using a given
codec mode. The functions used to initialize, reset, and exit are also
included in this file.
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "dec_amr.h"
#include "typedef.h"
#include "cnst.h"
#include "copy.h"
#include "set_zero.h"
#include "syn_filt.h"
#include "d_plsf.h"
#include "agc.h"
#include "int_lpc.h"
#include "dec_gain.h"
#include "dec_lag3.h"
#include "dec_lag6.h"
#include "d2_9pf.h"
#include "d2_11pf.h"
#include "d3_14pf.h"
#include "d4_17pf.h"
#include "d8_31pf.h"
#include "d1035pf.h"
#include "pred_lt.h"
#include "d_gain_p.h"
#include "d_gain_c.h"
#include "dec_gain.h"
#include "ec_gains.h"
#include "ph_disp.h"
#include "c_g_aver.h"
#include "int_lsf.h"
#include "lsp_lsf.h"
#include "lsp_avg.h"
#include "bgnscd.h"
#include "ex_ctrl.h"
#include "sqrt_l.h"
#include "frame.h"
#include "bitno_tab.h"
#include "b_cn_cod.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: Decoder_amr_init
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
state = pointer to a pointer to structures of type Decoder_amrState
Outputs:
structure pointed to by the pointer which is pointed to by state is
initialized to each field's initial values
state pointer points to the address of the memory allocated by
Decoder_amr_init function
Returns:
return_value = 0, if the initialization was successful; -1, otherwise (int)
Global Variables Used:
None
Local Variables Needed:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function allocates and initializes state memory used by the Decoder_amr
function. It stores the pointer to the filter status structure in state. This
pointer has to be passed to Decoder_amr in each call. The function returns
0, if initialization was successful and -1, otherwise.
------------------------------------------------------------------------------
REQUIREMENTS
None
------------------------------------------------------------------------------
REFERENCES
dec_amr.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
------------------------------------------------------------------------------
PSEUDO-CODE
int Decoder_amr_init (Decoder_amrState **state)
{
Decoder_amrState* s;
Word16 i;
if (state == (Decoder_amrState **) NULL){
fprintf(stderr, "Decoder_amr_init: invalid parameter\n");
return -1;
}
*state = NULL;
// allocate memory
if ((s= (Decoder_amrState *) malloc(sizeof(Decoder_amrState))) == NULL){
fprintf(stderr, "Decoder_amr_init: can not malloc state structure\n");
return -1;
}
s->T0_lagBuff = 40;
s->inBackgroundNoise = 0;
s->voicedHangov
- 1
- 2
前往页