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

📄 phi_post.c

📁 语音压缩算法
💻 C
字号:
/*====================================================================*//*         MPEG-4 Audio (ISO/IEC 14496-3) Copyright Header            *//*====================================================================*//*This software module was originally developed by Rakesh Taori and AndyGerrits (Philips Research Laboratories, Eindhoven, The Netherlands) inthe course of development of the MPEG-4 Audio (ISO/IEC 14496-3). Thissoftware module is an implementation of a part of one or more MPEG-4Audio (ISO/IEC 14496-3) tools as specified by the MPEG-4 Audio(ISO/IEC 14496-3). ISO/IEC gives users of the MPEG-4 Audio (ISO/IEC14496-3) free license to this software module or modifications thereoffor use in hardware or software products claiming conformance to theMPEG-4 Audio (ISO/IEC 14496-3). Those intending to use this softwaremodule in hardware or software products are advised that its use mayinfringe existing patents. The original developer of this softwaremodule and his/her company, the subsequent editors and theircompanies, and ISO/IEC have no liability for use of this softwaremodule or modifications thereof in an implementation. Copyright is notreleased for non MPEG-4 Audio (ISO/IEC 14496-3) conforming products.CN1 retains full right to use the code for his/her own purpose, assignor donate the code to a third party and to inhibit third parties fromusing the code for non MPEG-4 Audio (ISO/IEC 14496-3) conformingproducts.  This copyright notice must be included in all copies orderivative works. Copyright 1996.*//*====================================================================*//*======================================================================*//*                                                                      *//*      SOURCE_FILE:    PHI_POST.C                                      *//*      PACKAGE:        WDBxx                                           *//*      COMPONENT:      Post-processing Module                          *//*                                                                      *//*======================================================================*//*======================================================================*//*      I N C L U D E S                                                 *//*======================================================================*/#include <stdio.h>#include <stdlib.h>#include <math.h>#include "phi_post.h"/*======================================================================*//*     L O C A L     D A T A     D E F I N I T I O N S                  *//*======================================================================*//*======================================================================*//* Function Definition: PHI_InitPostProcessor                           *//*======================================================================*/void                            /* Return Value: Void                   */PHI_InitPostProcessor(const long lpc_order,            /* In: Order of LPC                     */PHI_PRIV_TYPE *PHI_Priv         /* In/Out: private data (instance context)*/){    int k;        /* -----------------------------------------------------------------*/    /* Create Arrays for delay line(s)                                  */    /* -----------------------------------------------------------------*/    if    (    (( PHI_Priv->PHI_g1 = (float *)malloc((unsigned int)lpc_order * sizeof(float))) == NULL ) ||    (( PHI_Priv->PHI_g2 = (float *)malloc((unsigned int)lpc_order * sizeof(float))) == NULL ) ||    (( PHI_Priv->PHI_P1_states = (float *)malloc((unsigned int)lpc_order * sizeof(float))) == NULL )||    (( PHI_Priv->PHI_P2_states = (float *)malloc((unsigned int)lpc_order * sizeof(float))) == NULL )    )    {        printf("MALLOC FAILURE in Routine InitPostProcessor \n");        exit(1);    }    /* -----------------------------------------------------------------*/    /* Initialise Arrays for delay line(s)                              */    /* -----------------------------------------------------------------*/    for (k = 0; k < (int)lpc_order; k++)    {         PHI_Priv->PHI_P1_states[k] = PHI_Priv->PHI_P2_states[k] = (float)0.0;    }    PHI_Priv->PHI_Gpf = PHI_Priv->PHI_P3_state = (float)0.0;        /* -----------------------------------------------------------------*/    /* Initialise Gamma Arrys of the postfilter                         */    /* -----------------------------------------------------------------*/    for(PHI_Priv->PHI_g1[0] = (float)0.65, PHI_Priv->PHI_g2[0] = (float)0.75, k = 1; k < (int)lpc_order; k++)    {        PHI_Priv->PHI_g1[k]  = (float)0.65 * PHI_Priv->PHI_g1[k-1];        PHI_Priv->PHI_g2[k]  = (float)0.75 * PHI_Priv->PHI_g2[k-1];    }   }/*======================================================================*//* Function Definition: PHI_ClosePostProcessor                          *//*======================================================================*/void                            /* Return Value: Void                   */PHI_ClosePostProcessor(PHI_PRIV_TYPE *PHI_Priv         /* In/Out: private data (instance context)*/){    free (PHI_Priv->PHI_P1_states);    free (PHI_Priv->PHI_P2_states);    free (PHI_Priv->PHI_g1);    free (PHI_Priv->PHI_g2);}/*======================================================================*//* Function Definition: celp_postprocessing                             *//*======================================================================*/void                            /* Return Value: Void                   */celp_postprocessing(const float synth_signal[],          /*In:  Input sig [0..sbfrm_size -1]*/      float PP_synth_signal[],       /*Out: Postprocessed ooutput       */const float int_Qlpc_coefficients[], /*In:  Decoded LPC coefficients    */  const long  lpc_order,               /*In:  Order of LPC                */const long  sbfrm_size,              /*In:  #Samps to be processed      */const long  acb_delay,               /*In:  Pitch-like information      */const float adaptive_gain,            /*In:  DON'T KNOW WHY IT IS NEEDED */PHI_PRIV_TYPE *PHI_Priv         /* In/Out: private data (instance context)*/){    int   nnn     = (int)sbfrm_size;    const float *in_ptr = synth_signal;    float *out    = PP_synth_signal;     int k;        /* -------------------------------------------------------------*/    /* Begin Post-processing                                        */    /* -------------------------------------------------------------*/    do    {        float tmp          = *in_ptr;        const float *ap_q  = int_Qlpc_coefficients;        float *PHI_g1_ptr  = PHI_Priv->PHI_g1;        float *PHI_g2_ptr  = PHI_Priv->PHI_g2;        for(k = 0; k < (int)lpc_order; k++)        {            tmp = tmp - (PHI_Priv->PHI_P1_states[k] * *PHI_g1_ptr++ - PHI_Priv->PHI_P2_states[k] * *PHI_g2_ptr++) * *ap_q++;        }        *out++ = PHI_Priv->PHI_Gpf * (tmp - (float)0.3 * PHI_Priv->PHI_P3_state);        PHI_Priv->PHI_P3_state = tmp;        for(k = (int)lpc_order - 1; k > 0; k--)        {            PHI_Priv->PHI_P1_states[k] = PHI_Priv->PHI_P1_states[k-1];            PHI_Priv->PHI_P2_states[k] = PHI_Priv->PHI_P2_states[k-1];        }        PHI_Priv->PHI_P1_states[0] = *in_ptr++;        PHI_Priv->PHI_P2_states[0] = tmp;    }    while(--nnn);    /* -------------------------------------------------------------*/    /* Update PHI_Gpf  Borrowed from Friedhelm's report -II pp.29   */    /* -------------------------------------------------------------*/    {        float pwr1 = (float)0.0;        float pwr2 = (float)0.0;        float r    = (float)1.0;        int   nnn;        for(nnn = 0; nnn < (int)sbfrm_size; nnn++)        {            float ss = synth_signal[nnn];            float sy = PP_synth_signal[nnn];                        if (fabs((double)(ss + sy)) > 1e-17)            {                pwr1 += (ss * ss);                pwr2 += (sy * sy);            }        }        if (pwr2 > (float)0.0)        {            r = (float)sqrt((double)pwr1/(double)pwr2);        }        PHI_Priv->PHI_Gpf = (((float)1.0 - (float)0.0625) * PHI_Priv->PHI_Gpf) + ((float)0.0625 * r);    }}/*======================================================================*//*      H I S T O R Y                                                   *//*======================================================================*//* 08-08-96 R. Taori  Initial Version                                   */

⌨️ 快捷键说明

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