reman3/Rayman_X/cpa/tempgrp/SND/src/mpeg/mpeg.hxx

159 lines
4.2 KiB
C++

/*
// ================================================================
// MPEG.hxx
// Ubi Sound Studios
// 18/03/1997
// Guillaume Michel
// ================================================================
*/
#ifndef _MPEG_AUDIO_H_
#define _MPEG_AUDIO_H_
#include "SND.h"
#if defined(_DLL_COMPILATION_MODE)
#include "snddll.h"
#else
#include "sndtest.h"
#endif
#include "bitstrm.h"
// number of voices we can do...
#define kNumVoice 2 // MODE SINGLE CHANNEL
// TWO VOICES -> Current and Next one...
// MONO STEREO Management
#define kStereo 0
#define kJointStereo 1
#define kMono 3
#define kNumChannel 32
#define kSubBandLimit 27
#define kAnalysisSize 512
#define kFFTSize 1024
#define kFrameSize 1152
#define kNumScaleFactor 64
typedef struct sb_alloc{
unsigned short steps;
unsigned short bits;
unsigned short group;
unsigned short quant;
} sb_alloc;
typedef struct SND_tdstMPEGVoice voice;
// Structure of one MPEG voice...
typedef struct SND_tdstMPEGVoice {
// Bits allocations
unsigned char *pucBitAlloc;
// Scale factors and scale factors patterns
unsigned char *pucScaleFactorPattern;
unsigned char *pucScaleFactor;
double *pdDiviseur;
double *pdScaleFactor;
double *pdSumFactor;
// Quantized samples and dequantized samples...
short *pwSample;
short *pwFraction; // dequantized for MMX
double *pdFraction; // dequantized for Pentium
// CallBack management
unsigned long ulParam;
SND_td_pfn_vSoundCallback pfnCallBack;
// VOICE management
SndBool bIsFree;
SndBool bIsPlaying;
SndBool bIsPaused;
SndBool bIsMuted;
SndBool bVolable;
SndBool bIsOneShot;
SndBool bIsFinishing;
// Fade out/in:
SndBool bIsFading;
int iFadeVolume;
int iFadeIncrement;
// loop mode
unsigned long ulPos;
unsigned long ulFinalSize;
unsigned long ulNumSampleBeforeEnd;
// INPUT management
SND_tdstBitStream bitstream; // bitstream
SND_tdstBitStream *pRealBitStream;
// MONO/STEREO management
unsigned char ucNbChannel; // mono/stereo
unsigned char ucJointBound; // joint stereo boundary
unsigned char ucVolume;
unsigned char ucCurrentVolume;
unsigned char ucVolumeIndex;
// SURROUND MANAGEMENT
SndBool bIsSurround;
SndBool bIsFullSurround;
voice *pAssociatedVoice;
// Fade Management
SndReal rDuration;
unsigned long ulMaxTab;
} SND_tdstMPEGVoice;
// INITIALISATIONS AND DESINITS...
SndBool SND_fn_bInitMPEG(void);
SndBool SND_fn_bDesInitMPEG(void);
void SND_fn_vInitSignalProcessing(void);
SndBool SND_fn_bInitMPEGMemory(void);
SndBool SND_fn_bInitDone(void);
SndBool SND_fn_bStartMPEGEngine(void);
// VOICE Management...
SND_tdstMPEGVoice* SND_fn_pAllocateMPEGVoiceFile(char* pFileName, unsigned long ulOffset);
SND_tdstMPEGVoice* SND_fn_pAllocateMPEGVoiceMem(unsigned char* pBuffer, unsigned long ulSize);
SND_tdstMPEGVoice* SND_fn_pSimpleAllocateMPEGVoiceFile(char* pFileName, unsigned long ulOffset);
SND_tdstMPEGVoice* SND_fn_pSimpleAllocateMPEGVoiceMem(unsigned char* pBuffer, unsigned long ulSize);
SND_tdstMPEGVoice* SND_fn_pSampleAllocateMPEGVoiceFile(char* pFileName, unsigned long ulOffset);
SND_tdstMPEGVoice* SND_fn_pSampleAllocateMPEGVoiceMem(unsigned char* pBuffer, unsigned long ulSize);
SndBool SND_fn_bFreeMPEGVoice(SND_tdstMPEGVoice* pVoice);
SndBool SND_fn_bAllocateMPEGMemory(SND_tdstMPEGVoice* pVoice);
SndBool SND_fn_bFreeMPEGMemory(SND_tdstMPEGVoice* pVoice);
// READING (PART I)
SndBool SND_fn_bReadPartI(SND_tdstMPEGVoice* pVoice);
void SND_fn_vEvaluateSCF(SND_tdstMPEGVoice* pVoice);
// READING (PART II)
void SND_fn_vInitMPEGMix(void);
void SND_fn_vInitMPEGFraction();
void SND_fn_vReadPartII(SND_tdstMPEGVoice* voice);
// SYNTHESIS
void SND_fn_vSynthesis(short *pwOut,int iChannel);
// ENGINE WORKS
SndBool SND_fn_bFillBufferTwice(short* pwBuffer, unsigned long ulSize);
SndBool SND_fn_bRead(SND_tdstMPEGVoice* pVoice);
SndBool SND_fn_bFinishRead(SND_tdstMPEGVoice* pVoice);
int SND_fn_iGetOneFrame(short* pwOut, int i);
void WINAPI SND_fn_vRefreshMPEG(long idBuffer,unsigned long idSample, unsigned long nbSample, void* pvBuffer);
void SND_fnvStopAllVoicesMPEGTheme();
typedef struct callback_paramMPEG {
SND_td_pfn_vSoundCallback fct;
long param;
} callback_paramMPEG;
void __stdcall start_callbackMPEG(SND_tdstMPEGVoice* pVoice);
extern tduRefRes SND_g_uFadeRes;
#endif