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

📄 vad1.cpp

📁 实现3GPP的GSM中AMR语音的CODECS。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    return 0;}/*------------------------------------------------------------------------------ FUNCTION NAME: vad1_exit------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    state -- pointer to type vadState1 --  State struct 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 vad1.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 vad1_exit(vadState1 **state){    if (state == NULL || *state == NULL)        return;    /* deallocate memory */    oscl_free(*state);    *state = NULL;    return;}/*------------------------------------------------------------------------------ FUNCTION NAME: vad_complex_detection_update------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    best_corr_hp -- Word16 -- best Corr    state -- pointer to type vadState1 --  State struct Outputs:    state -- pointer to type vadState1 --  State struct Returns:    None Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Purpose      : update vad->bestCorr_hp  complex signal feature state------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES vad1.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 vad_complex_detection_update(    vadState1 *st,       /* i/o : State struct */    Word16 best_corr_hp) /* i   : best Corr    */{    st->best_corr_hp = best_corr_hp;}/*------------------------------------------------------------------------------ FUNCTION NAME: vad_tone_detection------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    st -- pointer to type vadState1 --  State struct    t0 -- Word32 -- autocorrelation maxima    t1 -- Word32 -- energy Outputs:    st -- pointer to type vadState1 --  State struct    pOverflow -- pointer to type Flag -- overflow indicator Returns:    None Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Purpose      : Set tone flag if pitch gain is high. This is used to detect                signaling tones and other signals with high pitch gain. Inputs       : tone: flags indicating presence of a tone Outputs      : tone: flags indicating presence of a tone------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES vad1.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 vad_tone_detection(    vadState1 *st,    /* i/o : State struct                       */    Word32 t0,        /* i   : autocorrelation maxima             */    Word32 t1,        /* i   : energy                             */    Flag  *pOverflow  /* o : Flag set when overflow occurs        */){    Word16 temp;    /*       if (t0 > TONE_THR * t1)       set tone flag       */    temp = pv_round(t1, pOverflow);    if ((temp > 0) && (L_msu(t0, temp, TONE_THR, pOverflow) > 0))    {        st->tone |= 0x4000;    }}/*------------------------------------------------------------------------------ FUNCTION NAME: vad_tone_detection_update------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    one_lag_per_frame -- Word16 -- 1 if one open-loop lag is calculated per                                   each frame, otherwise 0    st -- pointer to type vadState1 --  State struct Outputs:    st -- pointer to type vadState1 --  State struct    pOverflow -- pointer to type Flag -- overflow indicator Returns:    None Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Purpose      : Update the tone flag register. Tone flags are shifted right                by one bit. This function should be called from the speech                encoder before call to Vad_tone_detection() function.------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES vad1.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 vad_tone_detection_update(    vadState1 *st,              /* i/o : State struct           */    Word16 one_lag_per_frame,   /* i   : 1 if one open-loop lag */    /*       is calculated per each */    /*       frame, otherwise 0     */    Flag *pOverflow             /* o   : Flags overflow         */){    /* Shift tone flags right by one bit */    st->tone = shr(st->tone, 1, pOverflow);    /* If open-loop lag is calculated only once in each frame, do extra update       and assume that the other tone flag of the frame is one. */    if (one_lag_per_frame != 0)    {        st->tone = shr(st->tone, 1, pOverflow);        st->tone |= 0x2000;    }}/*------------------------------------------------------------------------------ FUNCTION NAME: vad_pitch_detection------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs:    T_op -- array of type Word16 -- speech encoder open loop lags    st -- pointer to type vadState1 --  State struct Outputs:    st -- pointer to type vadState1 --  State struct    pOverflow -- pointer to type Flag -- overflow indicator Returns:    None Global Variables Used:    None Local Variables Needed:    None------------------------------------------------------------------------------ FUNCTION DESCRIPTION Purpose      : Test whether signal contains pitch or other periodic                component. Return value : Boolean voiced / unvoiced decision in state variable------------------------------------------------------------------------------ REQUIREMENTS None------------------------------------------------------------------------------ REFERENCES vad1.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 vad_pitch_detection(    vadState1 *st,    /* i/o : State struct                  */    Word16 T_op[],    /* i   : speech encoder open loop lags */    Flag  *pOverflow  /* o : Flag set when overflow occurs   */){    Word16 lagcount;    Word16 i;    Word16 temp;    lagcount = 0;    for (i = 0; i < 2; i++)    {        temp = sub(st->oldlag, T_op[i], pOverflow);        temp = abs_s(temp);        if (temp < LTHRESH)        {            lagcount = add(lagcount, 1, pOverflow);        }        /* Save the current LTP lag */        st->oldlag = T_op[i];    }    /* Make pitch decision.       Save flag of the pitch detection to the variable pitch.       */    st->pitch = shr(st->pitch, 1, pOverflow);    temp =        add(            st->oldlag_count,            lagcount,            pOverflow);    if (temp >= NTHRESH)    {        st->pitch |= 0x4000;    }    /* Update oldlagcount */    st->oldlag_count = lagcount

⌨️ 快捷键说明

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