home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / mpgaudio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-29  |  4.1 KB  |  141 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. //  PURPOSE.
  7. //
  8. //  Copyright (c) 1992 - 1996  Microsoft Corporation.  All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11.  
  12. /******************************Module*Header*******************************\
  13. * Module Name: MpgAudio.h
  14. *
  15. * Prototype Mpeg Audio codec
  16. *
  17. *
  18. \**************************************************************************/
  19. #ifndef _INC_MPGAUDIO_H
  20. #define _INC_MPGAUDIO_H
  21. #include <streams.h>
  22. #include <windowsx.h>
  23. #include <mmsystem.h>
  24. #include <mmreg.h>
  25. #include <stddef.h>
  26. #include <string.h>
  27.  
  28. #include "decoder.h"
  29.  
  30.  
  31. class CMpegAudioCodec : public CTransformFilter {
  32. public:
  33.     //
  34.     // --- Com stuff ---
  35.     //
  36.     static CUnknown *CreateInstance(LPUNKNOWN, HRESULT *);
  37.     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
  38.     DECLARE_IUNKNOWN;
  39.  
  40.  
  41.     //
  42.     // --- CTransform overrides ---
  43.     //
  44.     HRESULT Receive(IMediaSample *pSample);
  45.     HRESULT CheckInputType(const CMediaType* mtIn);
  46.     HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
  47.     HRESULT DecideBufferSize(IMemAllocator * pAllocator,
  48.                              ALLOCATOR_PROPERTIES * pProperties);
  49.     HRESULT StartStreaming();
  50.     HRESULT StopStreaming();
  51.     HRESULT SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt);
  52.     HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
  53.     HRESULT EndOfStream(void);
  54.     HRESULT EndFlush(void);
  55.  
  56.     CMpegAudioCodec(TCHAR *pName, LPUNKNOWN pUnk, HRESULT *pHr);
  57.     ~CMpegAudioCodec();
  58.  
  59.     // setup
  60.  
  61.     LPAMOVIESETUP_FILTER GetSetupData();
  62.  
  63. private:
  64.     //  Serialize access to the output pin
  65.     long            m_FrameSize;        // Frame input size (bytes)
  66.     long            m_FrameSizeOutput;  // Frame output size (bytes)
  67.  
  68.     LPBYTE          m_lpStart;
  69.     LPBYTE          m_lpCurr;
  70.     LPBYTE          m_lpEnd;
  71.     BOOL            m_bPayloadOnly;
  72.  
  73.     enum            {MAX_FRAMES_PER_OUTPUT_SAMPLE = 4};
  74.     enum            {AUDIO_BUFF_SIZE = (1024 * 8)};
  75.  
  76.     DWORD           m_dwCtrl;
  77.     AudioCtrl       m_AudioControl;
  78.     CAudioDecoder   *m_pAudioDecoder;
  79.  
  80.     CRefTime        m_TimePerFrame;
  81.     CRefTime        m_TimeAtLastSyncPoint;
  82.     CRefTime        m_TimeSinceLastSyncPoint;
  83.  
  84.     int             m_FreqDiv;
  85.     int             m_PrefChan;
  86.     int             m_Quality;
  87.     int             m_QuarterInt;
  88.     int             m_WordSize;
  89.  
  90.     BYTE            m_Buffer[AUDIO_BUFF_SIZE];
  91.  
  92.     void    ProcessDiscontiuity(IMediaSample *pSample);
  93.     void    ProcessSyncPoint(IMediaSample *pSample, BYTE *pSrc);
  94.     HRESULT DeliverSample(IMediaSample *pOutSample, CRefTime &TimeDecoded,
  95.                           int iSampleSize);
  96.  
  97.     void    ResetAudioDecoder();
  98.     BOOL    LookForSyncWord();
  99.     int     Padding();
  100.     void    GetNextPacketChunk(LPBYTE &lpPacket,
  101.                                long &LenLeftInBuffer, long &LenLeftInPacket);
  102.  
  103.     CRefTime        m_tStop;
  104.     MPEG1WAVEFORMAT m_Format;
  105.  
  106. };
  107.  
  108.  
  109. // -------------------------------------------------------------------------
  110. // Helper functions that can be used by audio and video codecs.
  111. // -------------------------------------------------------------------------
  112. //
  113.  
  114. /******************************Public*Routine******************************\
  115. * ByteSwap
  116. *
  117. * Converts dwX from little endian to big endian and vice-versa.
  118. *
  119. *
  120. \**************************************************************************/
  121. __inline DWORD
  122. ByteSwap(
  123.     DWORD dwX
  124.     )
  125. {
  126. #ifdef _X86_
  127.     _asm    mov     eax, dwX
  128.     _asm    bswap   eax
  129.     _asm    mov     dwX, eax
  130.  
  131.     return dwX;
  132. #else
  133.     return _lrotl(((dwX & 0xFF00FF00) >> 8) | ((dwX & 0x00FF00FF) << 8), 16);
  134. #endif
  135. }
  136.  
  137. LPBYTE SkipToPacketData(LPBYTE pSrc, long &LenLeftInPacket);
  138. int GetDecoderInteger(const TCHAR *pKey,int iDefault);
  139.  
  140. #endif
  141.