aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/nsmp3dec/huffmandecoder.h
blob: 5c4d46152b3ac7a7be15013cf2a9356183801bf3 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*************************************************************************** *
*                    MPEG Layer3-Audio Decoder
*                  © 1997-2006 by Fraunhofer IIS
 *                        All Rights Reserved
 *
 *   filename: huffmandecoder.h
 *   project : MPEG Decoder
 *   author  : Martin Sieler
 *   date    : 1998-02-08
 *   contents/description: HEADER - huffman decoder
 *
 *
\***************************************************************************/

/*
 * $Date: 2011/01/21 22:25:58 $
 * $Id: huffmandecoder.h,v 1.4 2011/01/21 22:25:58 audiodsp Exp $
 */

#ifndef __HUFFMANDECODER_H__
#define __HUFFMANDECODER_H__

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

#include "bitsequence.h"
#include "huffmanbitobj.h"
#include "huffmantable.h"

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

class CBitStream;

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

//
// Huffman decoder (helper) class.
//
//  This object reads and decodes MPEG Layer-3 huffman data.
//

class CHuffmanDecoder
{
public:
  CHuffmanDecoder();
  virtual ~CHuffmanDecoder();

  int ReadHuffmanCode(CBitStream &Bs,
                      int        *pIsp,
                      const int  *pTableSelect,
                      const int  *pRegionEnd,
                      int         Count1TableSelect,
                      int         Part2_3Length);

protected:

private:
  int  ReadBigValues(CBitStream  &Bs,
                     int         *pIsp,
                     const int   *pTableSelect,
                     const int   *pRegionEnd);

  int  ReadCount1Area(CBitStream &Bs,
                      int        *pIsp,
                      int         Count1TableSelect,
                      int         Count1Start,
                      int         Part2_3Length);
#ifdef _MSC_VER
	// these only have one caller and inlining shows notable improvements in the profiler
  __forceinline void ReadHuffmanDual   (CBitStream &Bs, int *pIsp);
  __forceinline void ReadHuffmanDualLin(CBitStream &Bs, int *pIsp);
  __forceinline bool ReadHuffmanQuad   (CBitStream &Bs, int *pIsp);
#else
	void ReadHuffmanDual   (CBitStream &Bs, int *pIsp);
  void ReadHuffmanDualLin(CBitStream &Bs, int *pIsp);
  bool ReadHuffmanQuad   (CBitStream &Bs, int *pIsp);
#endif

  CHuffmanTable  m_HuffmanTable;
  CHuffmanBitObj m_HuffmanBitObj;
  CBitSequence   m_LinBits;
};

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