aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/nsmp3dec/mpegbitstream.h
blob: ec37626a861d6477ffd8cdc3c5e7d03b9d4c1af9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*************************************************************************** *
*                    MPEG Layer3-Audio Decoder
*                  © 1997-2006 by Fraunhofer IIS
 *                        All Rights Reserved
 *
 *   filename: mpegbitstream.h
 *   project : MPEG Decoder
 *   author  : Martin Sieler
 *   date    : 1997-12-05
 *   contents/description: MPEG bitstream - HEADER
 *
 *
\***************************************************************************/

/*
 * $Date: 2010/11/17 20:46:04 $
 * $Id: mpegbitstream.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
 */

#ifndef __MPEGBITSTREAM_H__
#define __MPEGBITSTREAM_H__

/* ------------------------ includes --------------------------------------*/

#include "bitstream.h"
#include "mpegheader.h"
#include "mp3sscdef.h"

/*-------------------------- defines --------------------------------------*/

/*-------------------------------------------------------------------------*/

//
// MPEG bitstream class.
//
//  This object is derived from CBitStream. In addition to CBitStream
//  this object is able to sync to the next ISO/MPEG header position.
//

class CMpegBitStream : public CBitStream
{
public:
  CMpegBitStream(int cbSize);
  CMpegBitStream(unsigned char *pBuf, int cbSize, bool fDataValid = false);
  virtual ~CMpegBitStream();

  virtual void       Reset();

  SSC                DoSync();
  int                GetSyncPosition() const { return m_SyncPosition; }
  const CMpegHeader *GetHdr() const { return &m_Hdr; }

protected:

private:

  SSC DoSyncInitial();
  SSC DoSyncContinue();

  enum { FRAMES_TO_CHECK = 10 };

  CMpegHeader   m_Hdr;            // mpeg header
  unsigned long m_FirstHdr;       // "relevant" bits of first good header
  unsigned long m_nFramesToCheck; // # frames to be checked for next mpeg header
  int           m_SyncPosition;   // offset of first sync in bits
  SSC           m_SyncState;      // last sync state
};

/*-------------------------------------------------------------------------*/
#endif