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

📄 enc_lpc.c

📁 MPEG2/MPEG4编解码参考程序(实现了MPEG4的部分功能)
💻 C
📖 第 1 页 / 共 2 页
字号:
/*====================================================================*//*         MPEG-4 Audio (ISO/IEC 14496-3) Copyright Header            *//*====================================================================*//*This software module was originally developed by HP, NT, AG and TN 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.*//**********************************************************************MPEG-4 Audio VMEncoder core (LPC-based)This software module was originally developed byHeiko Purnhagen (University of Hannover)Naoya Tanaka (Matsushita Communication Industrial Co., Ltd.)Rakesh Taori, Andy Gerrits (Philips Research Laboratories, Eindhoven, The Netherlands),Toshiyuki Nomura (NEC Corporation)and edited byin the course of development of the MPEG-2 NBC/MPEG-4 Audio standardISO/IEC 13818-7, 14496-1,2 and 3. This software module is animplementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio toolsas specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC givesusers of the MPEG-2 NBC/MPEG-4 Audio standards free license to thissoftware module or modifications thereof for use in hardware orsoftware products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audiostandards. Those intending to use this software module in hardware orsoftware products are advised that this use may infringe existingpatents. The original developer of this software module and his/hercompany, the subsequent editors and their companies, and ISO/IEC haveno liability for use of this software module or modifications thereofin an implementation. Copyright is not released for non MPEG-2NBC/MPEG-4 Audio conforming products. The original developer retainsfull right to use the code for his/her own purpose, assign or donatethe code to a third party and to inhibit third party from using thecode for non MPEG-2 NBC/MPEG-4 Audio conforming products. Thiscopyright notice must be included in all copies or derivative works.Copyright (c) 1996.Source file: enc_lpc.c$Id: enc_lpc.c,v 1.25 1999/07/28 14:08:13 purnhage Exp $Required modules:common.o         common modulecmdline.o        command line modulebitstream.o      bits stream moduleAuthors:HP    Heiko Purnhagen, Uni Hannover <purnhage@tnt.uni-hannover.de>NT    Naoya Tanaka, Panasonic <natanaka@telecom.mci.mei.co.jp>AG    Andy Gerrits, Philips <gerritsa@natlab.research.philips.com>TN    Toshiyuki Nomura, NEC <t-nomura@dsp.cl.nec.co.jp>Changes:20-jun-96   HP    dummy core14-aug-96   HP    added EncLpcInfo(), EncLpcFree()15-aug-96   HP    adapted to new enc.h26-aug-96   HP    CVS03-Sep-96   NT    LPC-abs Core Ver. 1.1126-Sep-96   AG    adapted for PHILIPS25-oct-96   HP    joined Panasonic and Philips LPC frameworks                  made function names unique                    e.g.: abs_lpc_decode() -> PAN_abs_lpc_decode()                    NOTE: pan_xxx() and PAN_xxx() are different functions!		  I changed the PAN (and not the PHI) function names                  just because thus less files had to be modified ...28-oct-96   HP    added auto-select for pan/phi lpc modes08-Nov-96   NT    Narrowband LPC Ver. 2.00                    - replased preprocessing, LP analysis and weighting modules                    with Philips modules                    - I/Fs revision for common I/Fs with Philips modules15-nov-96   HP    adapted to new bitstream module26-nov-96   AG    abs_xxx() changed to celp_xxx()27-Feb-97   TN    adapted to Rate Control functionality**********************************************************************//* =====================================================================*//* Standard Includes                                                    *//* =====================================================================*/#include <stdio.h>#include <stdlib.h>#include <string.h>/* =====================================================================*//* MPEG-4 VM Includes                                                   *//* =====================================================================*/#include "buffersHandle.h"       /* handler, defines, enums */#include "common_m4a.h"        /* common module                             */#include "cmdline.h"       /* command line module                       */#include "bitstream.h"     /* bit stream module                         */#include "enc_lpc.h"       /* encoder cores                             */#include "mp4_lpc.h"       /* common lpc defs                           */#include "flex_mux.h"#include "lpc_common.h"		/* HP 961025 *//* =====================================================================*//* PHILIPS Includes                                                     *//* =====================================================================*/#include "phi_cons.h"#include "celp_encoder.h"/* =====================================================================*//* Panasonic Includes                                                   *//* =====================================================================*/#include "celp_proto_enc.h"#include "pan_celp_const.h"/* =====================================================================*//* NEC Includes                                                         *//* =====================================================================*/#include "nec_abs_const.h"/* =====================================================================*//* L O C A L     S Y M B O L     D E C L A R A T I O N S                *//* =====================================================================*/#define PROGVER "LPC-based encoder core V5.0 13-nov-97"#define SEPACHAR " ,="/* =====================================================================*//* L O C A L     D A T A      D E C L A R A T I O N S                   *//* =====================================================================*//* configuration inputs                                                 *//* =====================================================================*/static long bit_rate;static long sampling_frequency;static long frame_size;static long n_subframes;static long sbfrm_size;static long lpc_order;static long num_lpc_indices;static long num_shape_cbks;static long num_gain_cbks;static long n_lpc_analysis;static long *window_offsets;static long *window_sizes;static long n_lag_candidates; static float min_pitch_frequency;    static float max_pitch_frequency;    static long *org_frame_bit_allocation;    static long QuantizationMode; static long FineRateControl;  static long LosslessCodingMode;static long SampleRateMode;static long RPE_configuration;static long Wideband_VQ;static long MPE_Configuration;static long NumEnhLayers;static long BandwidthScalabilityMode;static long BWS_configuration;static long BWS_nb_bitrate;static long PreProcessingSW;static long ExcitationMode;static long InputConfiguration = -1;extern int CELPencDebugLevel;	/* HP 971120 */static int ELmode;	/* enum MP4ModeLpc */static int sysFlag;static CmdLineSwitch switchList[] = {  {"h",NULL,NULL,NULL,NULL,"print help"},  {"e",&ExcitationMode,"%d",NULL,NULL,NULL},  {"n",&NumEnhLayers,"%d",NULL,NULL,NULL},  {"f",&FineRateControl,"%d",NULL,NULL,NULL},  {"b",&BWS_nb_bitrate,"%d",NULL,NULL,NULL},  {"p",&PreProcessingSW,"%d",NULL,NULL,NULL},  {"cf",&InputConfiguration,"%d",NULL,NULL,NULL},  {"d",&CELPencDebugLevel,"%d","0",NULL,"debug level"},  {"-celp_sys",&sysFlag,NULL,NULL,NULL,"use system interface(flexmux)"},  {NULL,NULL,NULL,NULL,NULL,NULL}};static BsBitBuffer *tmpBitBuf;/* =====================================================================*//* instance context                                                     *//* =====================================================================*/static	void	*InstanceContext;	/*handle to one instance context *//* =====================================================================*//* L O C A L    F U N C T I O N      D E F I N I T I O N S              *//* =====================================================================*//* ---------------------------------------------------------------------*//* EncLpcInfo()                                                         *//* Get info about LPC-based encoder core.                               *//* ---------------------------------------------------------------------*/char *EncLpcInfo (  FILE *helpStream)     /* in: print encPara help text to helpStream    */                        /*     if helpStream not NULL                   */                        /* returns: core version string                 */{  if (helpStream != NULL)  {    fprintf(helpStream, "--------------------------------------------------------\n");    fprintf(helpStream, PROGVER "\n");    fprintf(helpStream, "Usage:\n");    fprintf(helpStream, "     mp4enc -m lpc -r <rate> -c \"<options>\" <speech file>\n");    fprintf(helpStream, "      where <rate> is the desired bit rate\n");    fprintf(helpStream, "            <speech file> is a 8kHz/16kHz speech file\n");    fprintf(helpStream, "            <options> are:\n");    fprintf(helpStream, "                e <0/1> : Multi-Pulse Excitation (0) or Regular-Pulse Excitation (1)\n");    fprintf(helpStream, "                n <NumEnhStage> : the number of enhancement layers \n");    fprintf(helpStream, "                f <0/1> : Fine Rate Control OFF (0) or ON (1)\n");    fprintf(helpStream, "                b <NBbitrate> : the bitrate for NarrowBand speech in the BandWidthScalable coder\n");    fprintf(helpStream, "                p <0/1> : Pre-processing OFF (0) or ON (1)\n");    fprintf(helpStream, "                cf <0,...,max>   : RPE/MPE Configuration\n");    fprintf(helpStream, "                                 : max = 3 for RPE \n");    fprintf(helpStream, "                                 : max = 31 for MPE \n");    fprintf(helpStream, "                -celp_sys : use system interface(flexmux)\n");    fprintf(helpStream, "                d <0/1> : Debug Level OFF (0) or ON (1)\n");    fprintf(helpStream, "\n");    fprintf(helpStream, "--------------------------------------------------------\n"); }   return PROGVER;}/* ---------------------------------------------------------------------*//* EncLpcInit()                                                         *//* Init LPC-based encoder core.                                         *//* ---------------------------------------------------------------------*/void EncLpcInit (    int numChannel,                 /* in: num audio channels           */    float fSample,                  /* in: sampling frequency [Hz]      */    float bitRate,                  /* in: total bit rate [bit/sec]     */    char *encPara,                  /* in: encoder parameter string     */    int varBitRate,		    /* in: variable bit rate            */    int *frameNumSample,            /* out: num samples per frame       */    int *delayNumSample,            /* out: encoder delay (num samples) */    BsBitBuffer *bitHeader,         /* out: header for bit stream       */    ENC_FRAME_DATA* frameData)	    /* out: system interface */{  int parac;  char **parav;  int result;  BsBitStream *hdrStream;  int layer, numLayer;  /* default selection */  Wideband_VQ = Optimized_VQ;  QuantizationMode = VectorQuantizer;  LosslessCodingMode = OFF;  if (fSample < 12000.)  {          ExcitationMode = MultiPulseExc;	  SampleRateMode = fs8kHz;	  FineRateControl  = OFF;	  NumEnhLayers = 0;	  BandwidthScalabilityMode = OFF;	  BWS_nb_bitrate = 0;  }  else  {        ExcitationMode = RegularPulseExc;

⌨️ 快捷键说明

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