Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
RishiRecon
GitHub Repository: RishiRecon/exploits
Path: blob/main/misc/emulator/xnes/snes9x/jma/rcdefs.h
28798 views
1
/*
2
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
3
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License version 2.1 as published by the Free Software Foundation.
8
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Lesser General Public License for more details.
13
14
You should have received a copy of the GNU Lesser General Public
15
License along with this library; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#ifndef __RCDEFS_H
20
#define __RCDEFS_H
21
22
#include "aribitcd.h"
23
#include "ariconst.h"
24
25
#define RC_INIT_VAR \
26
UINT32 aRange = aRangeDecoder->m_Range; \
27
UINT32 aCode = aRangeDecoder->m_Code;
28
29
#define RC_FLUSH_VAR \
30
aRangeDecoder->m_Range = aRange; \
31
aRangeDecoder->m_Code = aCode;
32
33
#define RC_NORMALIZE \
34
if (aRange < NCompression::NArithmetic::kTopValue) \
35
{ \
36
aCode = (aCode << 8) | aRangeDecoder->m_Stream.ReadByte(); \
37
aRange <<= 8; }
38
39
#define RC_GETBIT2(aNumMoveBits, aProb, aModelIndex, Action0, Action1) \
40
{UINT32 aNewBound = (aRange >> NCompression::NArithmetic::kNumBitModelTotalBits) * aProb; \
41
if (aCode < aNewBound) \
42
{ \
43
Action0; \
44
aRange = aNewBound; \
45
aProb += (NCompression::NArithmetic::kBitModelTotal - aProb) >> aNumMoveBits; \
46
aModelIndex <<= 1; \
47
} \
48
else \
49
{ \
50
Action1; \
51
aRange -= aNewBound; \
52
aCode -= aNewBound; \
53
aProb -= (aProb) >> aNumMoveBits; \
54
aModelIndex = (aModelIndex << 1) + 1; \
55
}} \
56
RC_NORMALIZE
57
58
#define RC_GETBIT(aNumMoveBits, aProb, aModelIndex) RC_GETBIT2(aNumMoveBits, aProb, aModelIndex, ; , ;)
59
60
#endif
61
62