blob: df7b78b6eb6034deeb2c0ed58156b9a3b68a95e1 (
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
|
/*************************************************************************** *
* MPEG Layer3-Audio Decoder
* © 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: bitsequence.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1997-12-23
* contents/description: HEADER - bitsequence object
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:01 $
* $Id: bitsequence.h,v 1.1 2010/11/17 20:46:01 audiodsp Exp $
*/
#ifndef __BITSEQUENCE_H__
#define __BITSEQUENCE_H__
/* ------------------------ includes --------------------------------------*/
#include "bitstream.h"
/*-------------------------- defines --------------------------------------*/
/*-------------------------------------------------------------------------*/
//
// Bitstream parser class.
//
// This helper class is basically a numerical value that can read itself from
// a CBitStream interface for convenience. The decoder almost completely
// does the bitstream parsing through CBitSequence rather than CBitStream
// directly.
//
class CBitSequence
{
public:
CBitSequence(int nBits = 0) { m_nBits = nBits; m_nValue = 0; }
virtual ~CBitSequence() {}
void SetNumberOfBits(int nBits) { m_nBits = nBits; }
int GetNumberOfBits() const { return m_nBits; }
bool ReadFrom(CBitStream &Bs) { m_nValue = Bs.GetBits(m_nBits); return true; }
bool ReadFrom_Bit(CBitStream &Bs) { m_nValue = Bs.Get1Bit(); return true; }
bool ReadFrom(CBitStream &Bs, int nBits) { SetNumberOfBits(nBits); return ReadFrom(Bs); }
bool Equals(int nValue) const { return (m_nValue == nValue); }
int ToInt() const { return m_nValue; }
void FromInt(int nValue) { m_nValue = nValue; }
protected:
private:
int m_nBits;
int m_nValue;
};
/*-------------------------------------------------------------------------*/
#endif
|