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

📄 dec_lpc.c

📁 MPEG2/MPEG4编解码参考程序(实现了MPEG4的部分功能)
💻 C
📖 第 1 页 / 共 2 页
字号:
/**********************************************************************MPEG-4 Audio VMDecoder 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: dec_lpc.c$Id: dec_lpc.c,v 1.29 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>PD    Paul Dillen, Philips Consumer ElectronicsTN    Toshiyuki Nomura, NEC <t-nomura@dsp.cl.nec.co.jp>RF    Ralf Funken, Philips <ralf.funken@ehv.ce.philips.com>Changes:24-jun-96   HP    dummy core15-aug-96   HP    adapted to new dec.h26-aug-96   HP    CVS04-Sep-96   NT    LPC 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                    - replaced synthesis filter module with Philips module                    - I/Fs revision for common I/Fs with Philips modules15-nov-96   HP    adapted to new bitstream module26-nov-96   AG    changed abs_xxx() to celp_xxx()27-Feb-97   TN    adapted to rate control functionality27-Mar-97   AG    new functionalities for decoder added18-Mar-98   PD    Philips private data (for multi-instance) added**********************************************************************//* =====================================================================*//* Standard Includes                                                    *//* =====================================================================*/#include <stdio.h>#include <stdlib.h>#include <string.h>/* =====================================================================*//* MPEG-4 VM Includes                                                   *//* =====================================================================*/#include "block.h"               /* handler, defines, enums */#include "buffersHandle.h"       /* handler, defines, enums */#include "concealmentHandle.h"   /* handler, defines, enums */#include "interface.h"           /* handler, defines, enums */#include "mod_bufHandle.h"       /* handler, defines, enums */#include "reorderspecHandle.h"   /* handler, defines, enums */#include "resilienceHandle.h"    /* handler, defines, enums */#include "tf_mainHandle.h"       /* handler, defines, enums */#include "lpc_common.h"          /* structs */#include "nok_ltp_common.h"      /* structs */#include "obj_descr.h"           /* structs */#include "tf_mainStruct.h"       /* structs */#include "common_m4a.h"        /* common module                             */#include "cmdline.h"       /* command line module                       */#include "bitstream.h"     /* bit stream module                         */#include "lpc_common.h"#include "dec_lpc.h"           /* decoder cores                             */#include "mp4_lpc.h"       /* common lpc defs                           *//* =====================================================================*//* PHILIPS Includes                                                     *//* =====================================================================*/#include "phi_cons.h"#include "celp_decoder.h"/* =====================================================================*//* Panasonic Includes                                                   *//* =====================================================================*/#include "celp_proto_dec.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 "CELP-based decoder 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                                                 *//* =====================================================================*/extern int samplFreqIndex[];	/* undesired, but ... *//*Table 5.2   CELP coder (Mode II) configuration for 8 kHz sampling rate MPE_Configuration | Frame_size (#samples) | nrof_subframes | sbfrm_size (#samples) 0,1,2        320          4   80 3,4,5        240          3   80 6 ... 12     160          2   80  13 ... 21    160          4   40 22 ... 26    80           2   40 27           240          4   60 28 ... 31 Reserved*/#if 0static int MPE_Table[]={  320,/*0 */  320,/*1 */  320,/*2 */  240,/*3 */  240,/*4 */  240,/*5 */  160,/*6 */  160,/*7*/  160,/*8 */  160,/*9 */  160,/*10 */  160,/*11 */  160,/*12 */  160,/*13 */  160,/*14 */  160,/*15 */  160,/*16 */  160,/*17 */  160,/*18 */  160,/*19 */  160,/*20 */  160,/*21 */  80,/*22 */  80,/*23 */  80,/*24 */  80,/*25 */  80,/*26 */  240,/*27*/  0,0,0,0,0,0,0,0,0,0,0};#endifstatic 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 *org_frame_bit_allocation;    static long SampleRateMode     = 1;  /* Default: 16 kHz */static long QuantizationMode   = 1;  /* Default: Vector Quantizer */static long FineRateControl    = 0;  /* Default: FineRateControl is OFF */static long LosslessCodingMode = 0;  /* Default: Lossless coding is OFF */static long RPE_configuration;static long Wideband_VQ = Optimized_VQ;static long MPE_Configuration;static long NumEnhLayers;static long BandwidthScalabilityMode;static long BWS_configuration;static long reduced_order = 0;static long complexity_level = 0;static long PostFilterSW;static long ExcitationMode;extern int CELPdecDebugLevel;	/* HP 971120 */static long  DecEnhStage;static long  DecBwsMode;static int  dummysw;static int sysFlag;static CmdLineSwitch switchList[] = {  {"h",NULL,NULL,NULL,NULL,"print help"},  {"lpc_n",&DecEnhStage,"%d","0",NULL,NULL},  {"lpc_b",&DecBwsMode,"%d","0",NULL,NULL},  {"lpc_p",&PostFilterSW,"%d","0",NULL,NULL},  {"lpc_d",&CELPdecDebugLevel,"%d","0",NULL,"debug level"},  {"-celp_sys",&sysFlag,NULL,NULL,NULL,"use system interface(flexmux)"},/* to make celp ignor aac scalable switches in case of celp + aac decoding" */  {"-mp4ff",&dummysw,NULL,NULL,NULL,"do nothing"},   {"-out",&dummysw,"%d",NULL,NULL,"do nothing"},  {NULL,NULL,NULL,NULL,NULL,NULL}};/* =====================================================================*//* 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              *//* =====================================================================*//* ---------------------------------------------------------------------*//* DecLpcInfo()                                                         *//* Get info about LPC-based decoder core.                               *//* ---------------------------------------------------------------------*/char *DecLpcInfo (  FILE *helpStream)       /* in: print decPara 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: mp4dec -c \"<options>\" <name bitstream file>\n");    fprintf(helpStream, "       where <options> are:\n");    fprintf(helpStream, "             n <DecEnhStage> : Decoded number of enhancement layers (0, 1, 2, 3)\n");    fprintf(helpStream, "             b <0/1>         : Decoding NarrowBand speech (0) or WideBand speech (1)\n");    fprintf(helpStream, "             p <0/1>         : Post filter OFF (0) or ON (1). Default: OFF\n");    fprintf(helpStream, "             -celp_sys       : use system interface(flexmux)\n");    fprintf(helpStream, "             d <0/1>         : Debug Level OFF (0) or ON (1). Default: OFF\n");    fprintf(helpStream, "--------------------------------------------------------\n");  }  return PROGVER;}/* ------------------------------------------------------------------- *//* DecLpcInit()                                                        *//* Init LPC-based decoder core.                                        *//* ------------------------------------------------------------------- */void DecLpcInit (  int numChannel,                  /* in: num audio channels           */  float fSample,                   /* in: sampling frequency [Hz]      */  float bitRate,                   /* in: total bit rate [bit/sec]     */  char *decPara,                   /* in: decoder parameter string     */  BsBitBuffer *bitHeader,          /* in: header from bit stream       */  int *frameNumSample,             /* out: num samples per frame       */  int *delayNumSample)             /* out: decoder delay (num samples) */{  BsBitStream *hdrStream;  int parac;  char **parav;  int result;  int mp4ffFlag    =0;  if (numChannel != 1 )   {    CommonExit(1,"EncLpcInit: Multi-channel audio input is not supported");  }    /* evalute decoder parameter string */  parav = CmdLineParseString(decPara,SEPACHAR,&parac);  result = CmdLineEval(parac,parav,NULL,switchList,1,NULL);  if (result)   {    if (result==1) 	{	  DecLpcInfo(stdout);	  exit (1);    }    else {            CommonExit(1,"Decoder parameter string error");    }  }    if ( (ExcitationMode == MultiPulseExc) && (SampleRateMode==fs16kHz) ) {    Wideband_VQ = Optimized_VQ;  }  /* -------------------------------------------------------------------*/  /* Memory allocation                                                  */  /* -------------------------------------------------------------------*/  hdrStream = BsOpenBufferRead(bitHeader);  /* ---------------------------------------------------------------- */  /* Conversion of parameters from float to longs                     */  /* ---------------------------------------------------------------- */  bit_rate           = (long)(bitRate+.5);  sampling_frequency = (long)(fSample+.5);

⌨️ 快捷键说明

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