mpegbitstream.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /***************************************************************************\
  2. *
  3. * MPEG Layer3-Audio Decoder
  4. * © 1997-2006 by Fraunhofer IIS
  5. * All Rights Reserved
  6. *
  7. * filename: mpegbitstream.h
  8. * project : MPEG Decoder
  9. * author : Martin Sieler
  10. * date : 1997-12-05
  11. * contents/description: MPEG bitstream - HEADER
  12. *
  13. *
  14. \***************************************************************************/
  15. /*
  16. * $Date: 2010/11/17 20:46:04 $
  17. * $Id: mpegbitstream.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
  18. */
  19. #ifndef __MPEGBITSTREAM_H__
  20. #define __MPEGBITSTREAM_H__
  21. /* ------------------------ includes --------------------------------------*/
  22. #include "bitstream.h"
  23. #include "mpegheader.h"
  24. #include "mp3sscdef.h"
  25. /*-------------------------- defines --------------------------------------*/
  26. /*-------------------------------------------------------------------------*/
  27. //
  28. // MPEG bitstream class.
  29. //
  30. // This object is derived from CBitStream. In addition to CBitStream
  31. // this object is able to sync to the next ISO/MPEG header position.
  32. //
  33. class CMpegBitStream : public CBitStream
  34. {
  35. public:
  36. CMpegBitStream(int cbSize);
  37. CMpegBitStream(unsigned char *pBuf, int cbSize, bool fDataValid = false);
  38. virtual ~CMpegBitStream();
  39. virtual void Reset();
  40. SSC DoSync();
  41. int GetSyncPosition() const { return m_SyncPosition; }
  42. const CMpegHeader *GetHdr() const { return &m_Hdr; }
  43. protected:
  44. private:
  45. SSC DoSyncInitial();
  46. SSC DoSyncContinue();
  47. enum { FRAMES_TO_CHECK = 10 };
  48. CMpegHeader m_Hdr; // mpeg header
  49. unsigned long m_FirstHdr; // "relevant" bits of first good header
  50. unsigned long m_nFramesToCheck; // # frames to be checked for next mpeg header
  51. int m_SyncPosition; // offset of first sync in bits
  52. SSC m_SyncState; // last sync state
  53. };
  54. /*-------------------------------------------------------------------------*/
  55. #endif