www.pudn.com > g7x.rar > mp4auenc.c


/**********************************************************************
MPEG-4 Audio VM
Encoder frame work



This software module was originally developed by

Heiko Purnhagen (University of Hannover / ACTS-MoMuSys)

and edited by

in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard
ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an
implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools
as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives
users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this
software module or modifications thereof for use in hardware or
software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio
standards. Those intending to use this software module in hardware or
software products are advised that this use may infringe existing
patents. The original developer of this software module and his/her
company, the subsequent editors and their companies, and ISO/IEC have
no liability for use of this software module or modifications thereof
in an implementation. Copyright is not released for non MPEG-2
NBC/MPEG-4 Audio conforming products. The original developer retains
full right to use the code for his/her own purpose, assign or donate
the code to a third party and to inhibit third party from using the
code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This
copyright notice must be included in all copies or derivative works.

Copyright (c) 1997.



Source file: mp4enc.c

$Id: mp4auenc.c,v 1.6 1999/07/28 14:08:13 purnhage Exp $

Required modules:
common.o		common module
cmdline.o		command line module
bitstream.o		bit stream module
audio.o			audio i/o module
enc_par.o		encoder core (parametric)
enc_lpc.o		encoder core (CELP)
enc_tf.o		encoder core (T/F)
enc_g729.o		encoder core (G729)
enc_g723.o		encoder core (G723)

Authors:
HP    Heiko Purnhagen, Uni Hannover 
BG    Bernhard Grill, Uni Erlangen 
NI    Naoki Iwakami, NTT 
SE    Sebastien ETienne, Jean Bernard Rault CCETT 

Changes:
13-jun-96   HP    first version
14-jun-96   HP    added debug code
17-jun-96   HP    added bit reservoir control / switches -r -b
18-jun-96   HP    added delay compensation
19-jun-96   HP    using new ComposeFileName()
25-jun-96   HP    changed frameNumBit
26-jun-96   HP    improved handling of switch -o
04-jul-96   HP    joined with t/f code by BG (check "DISABLE_TF")
14-aug-96   HP    adapted to new cmdline module, added mp4.h
16-aug-96   HP    adapted to new enc.h
		  added multichannel signal handling
21-aug-96   HP    added NBC_RM4 switches by BG
26-aug-96   HP    CVS
28-aug-96   NI    moved "static CmdLineSwitch switchList[]" into main routine.
29-aug-96   HP    moved "switchlist[]" back again
		  NI stated, that it just was a locally required bug-fix:
		  This table is moved into the main routine,
		  because there was a run-time problem on a
		  SGI (IRIX-5.3) system (using g++).
30-oct-96   HP    additional frame work options
15-nov-96   HP    adapted to new bitstream module
18-nov-96   HP    changed int to long where required
		  added bit stream header options
		  removed NBC_RM4 switches (new -nh, -ms, -bi options)
10-dec-96   HP    new -ni, -vr options, added variable bit rate
23-jan-97   HP    added audio i/o module
07-apr-97   HP    i/o filename handling improved / "-" supported
08-apr-97   SE    added G729-based coder
15-may-97   HP    clean up
30-jun-97   HP    fixed totNumSample bug / calc encNumFrame
05-nov-97   HP    update by FhG/UER
12-nov-97   HP    added options -n & -s
02-dec-98   HP    merged most FDIS contributions ...
20-jan-99   HP    due to the nature of some of the modifications merged
                  into this code, I disclaim any responsibility for this
		  code and/or its readability -- sorry ...
21-jan-99   HP	  trying to clean up a bit ...
22-jan-99   HP    stdin/stdout "-" support, -d 1 uses stderr
22-apr-99   HP    merging all contributions
**********************************************************************/

#include 
#include 
#include 
#include 

#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 "audio.h"	/* audio i/o module */
#include "mp4au.h"	/* frame work declarations */
#include "enc_par.h"	/* encoder cores ... */
#include "enc_lpc.h"
#include "enc_tf.h"
#include "enc_g723.h"
#include "enc_g729.h"
#include "fir_filt.h"	/* fir lowpass filter */
#include "tf_main.h"	/* TM9902 */


/* ---------- declarations ---------- */

#define PROGVER "MPEG-4 Natural Audio Encoder V1.0 30-Jul-1999"
#define CVSID "$Id: mp4auenc.c,v 1.6 1999/07/28 14:08:13 purnhage Exp $"

/* the framework should be independent from files in the codec */
/* core directories    HP 970515*/
/* #include "tf_main.h" */
#ifndef MONO_CHAN
#define MONO_CHAN 0
#endif

#define max(a,b) ((a) > (b) ? (a) : (b))


/* ---------- variables ---------- */

/* command line module */

static char *codecMode;
static float bitRate;
static int varBitRate;
static int bitReservSize;
static int bitReservInit;
static int bitReservInitUsed;
static float regionStart;
static float regionDurat;
static int regionDuratUsed;
static char *encPara;
static char *outFileName;
static int outFileNameUsed;
static int numChannelOut;
static float fSampleOut;
static char *oriPath,*bitPath;
static int oriPathUsed,bitPathUsed;
static char *oriExt,*bitExt;
static int oriExtUsed;
static int noInfo;
static int noHeader;
static char *magicString;
static int bitBufSize;
static int mainDebugLevel;
static int audioDebugLevel;
static int bitDebugLevel;
static int cmdDebugLevel;
static int quantDebugLevel;
static int *varArgIdx;

static ENC_FRAME_DATA encFrameData;
static OBJECT_DESCRIPTOR objDescr;

#ifdef DEBUGPLOT
int frame; /* global for debugging */
#else 
static  int frame;
#endif 



static CmdLinePara paraList[] = {
  {&varArgIdx,NULL,"