📄 gain_q.cpp
字号:
/* ------------------------------------------------------------------ * 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/gain_q.c Functions: Date: 02/05/2002------------------------------------------------------------------------------ REVISION HISTORY Description: Updated template used to PV coding template. Changed to accept the pOverflow flag for EPOC compatibility. Description: Removed everything associated with gc_pred_init and gc_pred_exit. gc_pred_exit was simply removed -- gc_pred_init was replaced with calls to gc_pred_reset. This is because the gc_pred related structures are no longer dynamically allocated via malloc. Description: For gainQuant() 1. Replaced gc_pred_copy() with memcpy. 2. Eliminated unused include file gc_pred.h. 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 Quantazation of gains------------------------------------------------------------------------------*//*----------------------------------------------------------------------------; INCLUDES----------------------------------------------------------------------------*/#include "gain_q.h"#include "typedef.h"#include "basic_op.h"#include "qua_gain.h"#include "cnst.h"#include "mode.h"#include "g_code.h"#include "q_gain_c.h"#include "calc_en.h"#include "qgain795.h"#include "qgain475.h"#include "set_zero.h"#include "oscl_mem.h"/*----------------------------------------------------------------------------; MACROS; Define module specific macros here----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; DEFINES; Include all pre-processor statements here. Include conditional; compile variables also.----------------------------------------------------------------------------*/#define NPRED 4 /* number of prediction taps *//*----------------------------------------------------------------------------; LOCAL FUNCTION DEFINITIONS; Function Prototype declaration----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; LOCAL VARIABLE DEFINITIONS; Variable declaration - defined here and used outside this module----------------------------------------------------------------------------*//*------------------------------------------------------------------------------ FUNCTION NAME: gainQuant_init------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: st -- double pointer to gainQuantState Outputs: st -- double ponter to gainQuantState Returns: -1 if an error occurs during memory initialization 0 if OK Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Allocates state memory and initializes state memory------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES gain_q.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]------------------------------------------------------------------------------*/Word16 gainQuant_init(gainQuantState **state){ gainQuantState* s; if (state == (gainQuantState **) NULL) { /* fprintf(stderr, "gainQuant_init: invalid parameter\n"); */ return -1; } *state = NULL; /* allocate memory */ if ((s = (gainQuantState *) oscl_malloc(sizeof(gainQuantState))) == NULL) { /* fprintf(stderr, "gainQuant_init: can not malloc state structure\n"); */ return -1; } s->gain_idx_ptr = NULL; s->adaptSt = NULL; /* Init sub states */ if (gc_pred_reset(&s->gc_predSt) || gc_pred_reset(&s->gc_predUnqSt) || gain_adapt_init(&s->adaptSt)) { gainQuant_exit(&s); return -1; } gainQuant_reset(s); *state = s; return 0;}/*------------------------------------------------------------------------------ FUNCTION NAME: gainQuant_reset------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: st -- double pointer to gainQuantState Outputs: st -- double ponter to gainQuantState Returns: -1 if an error occurs 0 if OK Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Initializes state memory to zero------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES gain_q.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]------------------------------------------------------------------------------*/Word16 gainQuant_reset(gainQuantState *state){ if (state == (gainQuantState *) NULL) { /* fprintf(stderr, "gainQuant_reset: invalid parameter\n"); */ return -1; } state->sf0_exp_gcode0 = 0; state->sf0_frac_gcode0 = 0; state->sf0_exp_target_en = 0; state->sf0_frac_target_en = 0; Set_zero(state->sf0_exp_coeff, 5); Set_zero(state->sf0_frac_coeff, 5); state->gain_idx_ptr = NULL; gc_pred_reset(&(state->gc_predSt)); gc_pred_reset(&(state->gc_predUnqSt)); gain_adapt_reset(state->adaptSt); return 0;}/*------------------------------------------------------------------------------ FUNCTION NAME: gainQuant_exit------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: st -- double pointer to gainQuantState Outputs: None Returns: None Global Variables Used: None Local Variables Needed: None------------------------------------------------------------------------------ FUNCTION DESCRIPTION The memory used for state memory is freed------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES gain_q.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]------------------------------------------------------------------------------*/void gainQuant_exit(gainQuantState **state){ if (state == NULL || *state == NULL) return; gain_adapt_exit(&(*state)->adaptSt); /* deallocate memory */ oscl_free(*state); *state = NULL; return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -