Update UNRAR.H
[xy_vsfilter.git] / src / dsutil / GolombBuffer.h
blob78c3febf7665121411c14d4f12ff7e6fd11acf4e
1 /*
2 * (C) 2006-2012 see Authors.txt
4 * This file is part of MPC-HC.
6 * MPC-HC is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * MPC-HC is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 class CGolombBuffer
25 public:
26 CGolombBuffer(BYTE* pBuffer, int nSize);
28 UINT64 BitRead(int nBits, bool fPeek = false);
29 UINT64 UExpGolombRead();
30 INT64 SExpGolombRead();
31 void BitByteAlign();
33 inline BYTE ReadByte() { return (BYTE)BitRead(8); };
34 inline short ReadShort() { return (short)BitRead(16); };
35 inline DWORD ReadDword() { return (DWORD)BitRead(32); };
36 void ReadBuffer(BYTE* pDest, int nSize);
38 void Reset();
39 void Reset(BYTE* pNewBuffer, int nNewSize);
41 void SetSize(int nValue) { m_nSize = nValue; };
42 int GetSize() const { return m_nSize; };
43 int RemainingSize() const { return m_nSize - m_nBitPos; };
44 bool IsEOF() const { return m_nBitPos >= m_nSize; };
45 int GetPos();
46 BYTE* GetBufferPos() { return m_pBuffer + m_nBitPos; };
48 void SkipBytes(int nCount);
50 private:
51 BYTE* m_pBuffer;
52 int m_nSize;
53 int m_nBitPos;
54 int m_bitlen;
55 INT64 m_bitbuff;