Path: blob/main/misc/emulator/xnes/snes9x/jma/rcdefs.h
28798 views
/*1Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )2Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )34This library is free software; you can redistribute it and/or5modify it under the terms of the GNU Lesser General Public6License version 2.1 as published by the Free Software Foundation.78This library is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11Lesser General Public License for more details.1213You should have received a copy of the GNU Lesser General Public14License along with this library; if not, write to the Free Software15Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16*/1718#ifndef __RCDEFS_H19#define __RCDEFS_H2021#include "aribitcd.h"22#include "ariconst.h"2324#define RC_INIT_VAR \25UINT32 aRange = aRangeDecoder->m_Range; \26UINT32 aCode = aRangeDecoder->m_Code;2728#define RC_FLUSH_VAR \29aRangeDecoder->m_Range = aRange; \30aRangeDecoder->m_Code = aCode;3132#define RC_NORMALIZE \33if (aRange < NCompression::NArithmetic::kTopValue) \34{ \35aCode = (aCode << 8) | aRangeDecoder->m_Stream.ReadByte(); \36aRange <<= 8; }3738#define RC_GETBIT2(aNumMoveBits, aProb, aModelIndex, Action0, Action1) \39{UINT32 aNewBound = (aRange >> NCompression::NArithmetic::kNumBitModelTotalBits) * aProb; \40if (aCode < aNewBound) \41{ \42Action0; \43aRange = aNewBound; \44aProb += (NCompression::NArithmetic::kBitModelTotal - aProb) >> aNumMoveBits; \45aModelIndex <<= 1; \46} \47else \48{ \49Action1; \50aRange -= aNewBound; \51aCode -= aNewBound; \52aProb -= (aProb) >> aNumMoveBits; \53aModelIndex = (aModelIndex << 1) + 1; \54}} \55RC_NORMALIZE5657#define RC_GETBIT(aNumMoveBits, aProb, aModelIndex) RC_GETBIT2(aNumMoveBits, aProb, aModelIndex, ; , ;)5859#endif606162