Merge some MPC-HC Rev.3895 code to get HdmvSub and DVBSub support.
[xy_vsfilter.git] / src / dsutil / GolombBuffer.h
blob0a7bbd7f09867106ade7a84650cc3f7c0bb9b80a
1 /*
2 * $Id: GolombBuffer.h 2533 2010-09-12 12:45:26Z xhmikosr $
4 * (C) 2006-2010 see AUTHORS
6 * This file is part of mplayerc.
8 * Mplayerc is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * Mplayerc is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #pragma once
25 class CGolombBuffer
27 public:
28 CGolombBuffer(BYTE* pBuffer, int nSize);
30 UINT64 BitRead(int nBits, bool fPeek = false);
31 UINT64 UExpGolombRead();
32 INT64 SExpGolombRead();
33 void BitByteAlign();
35 inline BYTE ReadByte() {
36 return (BYTE) BitRead ( 8);
38 inline SHORT ReadShort() {
39 return (SHORT)BitRead (16);
41 inline DWORD ReadDword() {
42 return (DWORD)BitRead (32);
44 void ReadBuffer(BYTE* pDest, int nSize);
46 void Reset();
47 void Reset(BYTE* pNewBuffer, int nNewSize);
49 void SetSize(int nValue) {
50 m_nSize = nValue;
52 int GetSize() const {
53 return m_nSize;
55 int RemainingSize() const {
56 return m_nSize - m_nBitPos;
58 bool IsEOF() const {
59 return m_nBitPos >= m_nSize;
61 INT64 GetPos();
62 BYTE* GetBufferPos() {
63 return m_pBuffer + m_nBitPos;
66 void SkipBytes(int nCount);
68 private :
69 BYTE* m_pBuffer;
70 int m_nSize;
71 int m_nBitPos;
72 int m_bitlen;
73 INT64 m_bitbuff;