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

📄 amrencode.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.****************************************************************************************//*------------------------------------------------------------------------------ Filename:  /audio/gsm-amr/c/src/amrencode.c Functions: AMREncode            AMREncodeInit            AMREncodeReset            AMREncodeExit     Date: 01/26/2002------------------------------------------------------------------------------ REVISION HISTORY Description: Added input_type in the parameter list and updated code to              check the type of output formatting to use. Description: Corrected typo in Include section. Description: Added code to support ETS format. Description: Modified file by adding the return of the number of encoder              frame bytes. Description: Added call to sid_sync function to support TX_NO_DATA case.              Added SID type and mode info to ets_output_bfr for ETS SID              frames. Created AMREncodeInit, AMREncodeReset, and AMREncodeExit              functions. Description: Modified design of handling of ETS outputs such that the ETS              testvectors could be compared directly to the output of this              function. Description: Added conditional compile around calls to AMR Encoder interface              functions to allow amrencode.c to be used in the ETS reference              console. Description:  Replaced "int" and/or "char" with OSCL defined types. Description:------------------------------------------------------------------------------ MODULE DESCRIPTION This file contains the functions required to initialize, reset, exit, and invoke the ETS 3GPP GSM AMR encoder.------------------------------------------------------------------------------*//*----------------------------------------------------------------------------; INCLUDES----------------------------------------------------------------------------*/#include "cnst.h"#include "mode.h"#include "frame_type_3gpp.h"#include "typedef.h"#include "amrencode.h"#include "ets_to_if2.h"#include "ets_to_wmf.h"#include "sid_sync.h"#include "sp_enc.h"/*----------------------------------------------------------------------------; MACROS [optional]; [Define module specific macros here]----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; DEFINES [optional]; [Include all pre-processor statements here. Include conditional; compile variables also.]----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; LOCAL FUNCTION DEFINITIONS; [List function prototypes here]----------------------------------------------------------------------------*//*----------------------------------------------------------------------------; LOCAL VARIABLE DEFINITIONS; [Variable declaration - defined here and used outside this module]----------------------------------------------------------------------------*//*------------------------------------------------------------------------------ FUNCTION NAME: AMREncodeInit------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    pEncStructure = pointer containing the pointer to a structure used by                    the encoder (void)    pSidSyncStructure = pointer containing the pointer to a structure used for                        SID synchronization (void)    dtx_enable = flag to turn off or turn on DTX (Flag) Outputs:    None Returns:    init_status = 0, if initialization was successful; -1, otherwise (int) Global Variables Used:    None Local Variables Needed:    speech_encoder_state = pointer to encoder frame structure                           (Speech_Encode_FrameState)    sid_state = pointer to SID sync structure (sid_syncState)------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function initializes the GSM AMR Encoder library by calling GSMInitEncode and sid_sync_init. If initialization was successful, init_status is set to zero, otherwise, it is set to -1.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES None------------------------------------------------------------------------------ PSEUDO-CODE // Initialize GSM AMR Encoder CALL GSMInitEncode(state_data = &pEncStructure,                    dtx = dtx_enable,                    id = char_id            )   MODIFYING(nothing)   RETURNING(return_value = enc_init_status) // Initialize SID synchronization CALL sid_sync_init(state = &pSidSyncStructure)   MODIFYING(nothing)   RETURNING(return_value = sid_sync_init_status) IF ((enc_init_status != 0) || (sid_sync_init != 0)) THEN     init_status = -1 ENDIF MODIFY(nothing) RETURN(init_status)------------------------------------------------------------------------------ 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 AMREncodeInit(    void **pEncStructure,    void **pSidSyncStructure,    Flag dtx_enable){    Word16 enc_init_status = 0;    Word16 sid_sync_init_status = 0;    Word16 init_status = 0;    /* Initialize GSM AMR Encoder */#ifdef CONSOLE_ENCODER_REF    /* Change to original ETS input types */    Speech_Encode_FrameState **speech_encode_frame =        (Speech_Encode_FrameState **)(pEncStructure);    sid_syncState **sid_sync_state = (sid_syncState **)(pSidSyncStructure);    /* Use ETS version of sp_enc.c */    enc_init_status = Speech_Encode_Frame_init(speech_encode_frame,                      dtx_enable,                      (Word8*)"encoder");    /* Initialize SID synchronization */    sid_sync_init_status = sid_sync_init(sid_sync_state);#else    /* Use PV version of sp_enc.c */    enc_init_status = GSMInitEncode(pEncStructure,                                    dtx_enable,                                    (Word8*)"encoder");    /* Initialize SID synchronization */    sid_sync_init_status = sid_sync_init(pSidSyncStructure);#endif    if ((enc_init_status != 0) || (sid_sync_init_status != 0))    {        init_status = -1;    }    return(init_status);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: AMREncodeReset------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    pEncStructure = pointer to a structure used by the encoder (void)    pSidSyncStructure = pointer to a structure used for SID synchronization                        (void) Outputs:    None Returns:    reset_status = 0, if reset was successful; -1, otherwise (int) Global Variables Used:    None Local Variables Needed:    speech_encoder_state = pointer to encoder frame structure                           (Speech_Encode_FrameState)    sid_state = pointer to SID sync structure (sid_syncState)------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function resets the state memory used by the Encoder and SID sync function. If reset was successful, reset_status is set to zero, otherwise, it is set to -1.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES None------------------------------------------------------------------------------ PSEUDO-CODE // Reset GSM AMR Encoder CALL Speech_Encode_Frame_reset(state_data = pEncStructure)   MODIFYING(nothing)   RETURNING(return_value = enc_reset_status) // Reset SID synchronization CALL sid_sync_reset(state = pSidSyncStructure)   MODIFYING(nothing)   RETURNING(return_value = sid_sync_reset_status) IF ((enc_reset_status != 0) || (sid_sync_reset_status != 0)) THEN     reset_status = -1 ENDIF MODIFY(nothing) RETURN(reset_status)------------------------------------------------------------------------------ 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 AMREncodeReset(    void *pEncStructure,    void *pSidSyncStructure){    Word16 enc_reset_status = 0;    Word16 sid_sync_reset_status = 0;    Word16 reset_status = 0;    /* Reset GSM AMR Encoder */    enc_reset_status = Speech_Encode_Frame_reset(pEncStructure);    /* Reset SID synchronization */    sid_sync_reset_status = sid_sync_reset(pSidSyncStructure);    if ((enc_reset_status != 0) || (sid_sync_reset_status != 0))    {        reset_status = -1;    }    return(reset_status);}/****************************************************************************//*------------------------------------------------------------------------------ FUNCTION NAME: AMREncodeExit------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    pEncStructure = pointer containing the pointer to a structure used by                    the encoder (void)    pSidSyncStructure = pointer containing the pointer to a structure used for                        SID synchronization (void) Outputs:    None Returns:    None Global Variables Used:    None Local Variables Needed:    speech_encoder_state = pointer to encoder frame structure                           (Speech_Encode_FrameState)    sid_state = pointer to SID sync structure (sid_syncState)------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function frees up the state memory used by the Encoder and SID synchronization function.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES None------------------------------------------------------------------------------ PSEUDO-CODE // Exit GSM AMR Encoder CALL GSMEncodeFrameExit(state_data = &pEncStructure)   MODIFYING(nothing)   RETURNING(nothing) // Exit SID synchronization CALL sid_sync_exit(state = &pSidSyncStructure)   MODIFYING(nothing)   RETURNING(nothing) MODIFY(nothing) RETURN(nothing)------------------------------------------------------------------------------ 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 AMREncodeExit(    void **pEncStructure,

⌨️ 快捷键说明

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