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

📄 phi_nec_lpc.c

📁 MPEG2/MPEG4编解码参考程序(实现了MPEG4的部分功能)
💻 C
📖 第 1 页 / 共 2 页
字号:
/*====================================================================*//*         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_LPC.C                                       *//*      PACKAGE:        WDBxx                                           *//*      COMPONENT:      Linear Prediction Subroutines                   *//*                                                                      *//*======================================================================*//*======================================================================*//*      I N C L U D E S                                                 *//*======================================================================*/#include <stdio.h>#include <stdlib.h>#include <math.h>#include <malloc.h> #include <float.h>#include <assert.h>#include "phi_cons.h"  #include "phi_nec_lpc.h"#include "nec_abs_const.h"/*======================================================================*//*     L O C A L     D A T A     D E F I N I T I O N S                  *//*======================================================================*/static float **HammingWindow;              /* For Haming Window         */static float *PHI_GammaArrayBE;            /* For Bandwidth Expansion   *//*----------------------------------------------------------------------*//*    Variables for dynamic threshold                                   *//* ---------------------------------------------------------------------*//*======================================================================*//*     L O C A L    F U N C T I O N S     P R O T O T Y P E S           */ /*=======================================================================*//*======================================================================*//*   Function Prototype: PHI_CalcAcf                                    *//*======================================================================*/static void PHI_CalcAcf(double sp_in[],         /* In:  Input segment [0..N-1]                  */double acf[],           /* Out: Autocorrelation coeffs [0..P]           */int N,                  /* In:  Number of samples in the segment        */ int P                   /* In:  LPC Order                               */);/*======================================================================*//*   Function Prototype: PHI_LevinsonDurbin                             *//*======================================================================*/static int              /* Retun Value: 1 if unstable filter            */ PHI_LevinsonDurbin( double acf[],           /* In:  Autocorrelation coeffs [0..P]           */         double apar[],          /* Out: Polynomial coeffciients  [0..P-1]       */           double rfc[],           /* Out: Reflection coefficients [0..P-1]        */int P,                  /* In:  LPC Order                               */double * E              /* Out: Residual energy at the last stage       */);/*======================================================================*//*   Function Prototype: PHI_lpc_analysis                               *//*======================================================================*/static voidNEC_lpc_analysis(float PP_InputSignal[],         /* In:  Input Signal                    */float lpc_coefficients[],       /* Out: LPC Coefficients[0..lpc_order-1]*/float *first_order_lpc_par,     /* Out: a_parameter for 1st-order fit   */long  frame_size,               /* In:  Number of samples in frame      */float  HamWin[],                /* In:  Hamming Window                  */long  window_offset,            /* In:  offset for window w.r.t curr. fr*/long  window_size,              /* In:  LPC Analysis-Window Size        */long  lpc_order                 /* In:  Order of LPC                    */);/*======================================================================*//*   Function Definition:NEC_InitLpcAnalysisEncoder                     *//*     Sep. 07 97  - Added for narrowband coder                         *//*======================================================================*/voidNEC_InitLpcAnalysisEncoder(long  win_size[],               /* In:  LPC Analysis-Window Size        */long  n_lpc_analysis,           /* In:  Numberof LPC Analysis Frame     */long  order,                    /* In:  Order of LPC                    */float gamma_be,                 /* In:  Bandwidth Expansion Coefficient */long  bit_rate                  /* In:  Bit Rate                        */){    int     x;    float   *pin;    float   *pout;    long i;        /* -----------------------------------------------------------------*/    /* Create Arrays for Hamming Window and gamma array                 */    /* -----------------------------------------------------------------*/    if    (    (( PHI_GammaArrayBE = (float *)malloc((unsigned int)order * sizeof(float))) == NULL )    )    {		printf("MALLOC FAILURE in Routine InitLpcAnalysis \n");		exit(1);    }    if((HammingWindow=(float **)calloc((unsigned int)n_lpc_analysis, sizeof(float *)))==NULL){		printf("MALLOC FAILURE in Routine InitLpcAnalysis \n");		exit(1);    }    for(i=0;i<n_lpc_analysis;i++) {        if((HammingWindow[i]=(float *)calloc((unsigned int)win_size[i], sizeof(float)))                ==NULL){		    printf("MALLOC FAILURE in Routine InitLpcAnalysis \n");		    exit(1);        }    /* -----------------------------------------------------------------*/           /* Generate Hamming Window For Lpc                                  */    /* -----------------------------------------------------------------*/ /* using asymmetric windows */		if((NEC_ASW_LEN1_FRQ16+NEC_ASW_LEN2_FRQ16)!=win_size[i]) {		    printf("\n LPC window size is not matched\n");		    exit(1);		}       	pout = HammingWindow[i];   	       	for(x=0;x<NEC_ASW_LEN1_FRQ16;x++) {          		    *pout++ = (float)(.54-.46*cos(NEC_PI*2.*((double)x)		    /(double)(NEC_ASW_LEN1_FRQ16*2-1)));       	}       	for(x=0;x<NEC_ASW_LEN2_FRQ16;x++) {          		    *pout++ = (float)(cos(NEC_PI*2.*((double)x)		    /(double)(NEC_ASW_LEN2_FRQ16*4-1)));       	}    }             /* -----------------------------------------------------------------*/           /* Generate Gamma Array for Bandwidth Expansion                     */    /* -----------------------------------------------------------------*/           pin     = PHI_GammaArrayBE;    pout    = PHI_GammaArrayBE;    *pout++ = gamma_be;    for(x=1; x < (int)order; x++)    {        *pout++ = gamma_be * *pin++;    }}/*======================================================================*//* Function Definition: NEC_FreeLpcAnalysisEncoder                      *//*     Sep. 07 97  - Added for narrowband coder                         *//*======================================================================*/voidNEC_FreeLpcAnalysisEncoder(long n_lpc_analysis){    long i;    /* -----------------------------------------------------------------*/    /* Free the arrays that were malloc'd                               */           /* -----------------------------------------------------------------*/    for(i=0;i<n_lpc_analysis;i++) {        free(HammingWindow[i]);    }    free(HammingWindow);    free(PHI_GammaArrayBE);} /*======================================================================*//*   Function Definition:celp_lpc_analysis                              *//*======================================================================*/voidcelp_lpc_analysis_bws(float PP_InputSignal[],         /* In:  Input Signal                    */float lpc_coefficients[],       /* Out: LPC Coefficients[0..lpc_order-1]*/float *first_order_lpc_par,     /* Out: a_parameter for 1st-order fit   */long  frame_size,               /* In:  Number of samples in frame      */long  window_offsets[],         /* In:  offset for window w.r.t curr. fr*/long  window_sizes[],           /* In:  LPC Analysis-Window Size        */long  lpc_order,                /* In:  Order of LPC                    */long  n_lpc_analysis            /* In:  Number of LP analysis/frame     */){    int i;            for(i = 0; i < (int)n_lpc_analysis; i++)    {         NEC_lpc_analysis(PP_InputSignal,lpc_coefficients+lpc_order*(long)i,              first_order_lpc_par,             frame_size, HammingWindow[i], window_offsets[i], window_sizes[i],

⌨️ 快捷键说明

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