Removed unneeded files.

This commit is contained in:
n-a-c-h
2004-11-21 01:17:44 +00:00
parent b5d70d6aa1
commit 1aa2f0e542
9 changed files with 131 additions and 460 deletions

View File

@@ -1,40 +0,0 @@
/*
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "aribitcd.h"
#include "ariprice.h"
#include <cmath>
namespace NCompression {
namespace NArithmetic {
static const double kDummyMultMid = (1.0 / kBitPrice) / 2;
CPriceTables::CPriceTables()
{
double aLn2 = log(2);
double aLnAll = log(kBitModelTotal >> kNumMoveReducingBits);
for(UINT32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)
m_StatePrices[i] = UINT32((fabs(aLnAll - log(i)) / aLn2 + kDummyMultMid) * kBitPrice);
}
CPriceTables g_PriceTables;
}}

View File

@@ -11,57 +11,6 @@ const UINT32 kBitModelTotal = (1 << kNumBitModelTotalBits);
const int kNumMoveReducingBits = 2;
class CPriceTables
{
public:
UINT32 m_StatePrices[kBitModelTotal >> kNumMoveReducingBits];
CPriceTables();
};
extern CPriceTables g_PriceTables;
/////////////////////////////
// CBitModel
template <int aNumMoveBits>
class CBitModel
{
public:
UINT32 m_Probability;
void UpdateModel(UINT32 aSymbol)
{
/*
m_Probability -= (m_Probability + ((aSymbol - 1) & ((1 << aNumMoveBits) - 1))) >> aNumMoveBits;
m_Probability += (1 - aSymbol) << (kNumBitModelTotalBits - aNumMoveBits);
*/
if (aSymbol == 0)
m_Probability += (kBitModelTotal - m_Probability) >> aNumMoveBits;
else
m_Probability -= (m_Probability) >> aNumMoveBits;
}
public:
void Init() { m_Probability = kBitModelTotal / 2; }
};
template <int aNumMoveBits>
class CBitEncoder: public CBitModel<aNumMoveBits>
{
public:
void Encode(CRangeEncoder *aRangeEncoder, UINT32 aSymbol)
{
aRangeEncoder->EncodeBit(CBitModel<aNumMoveBits>::m_Probability, kNumBitModelTotalBits, aSymbol);
CBitModel<aNumMoveBits>::UpdateModel(aSymbol);
}
UINT32 GetPrice(UINT32 aSymbol) const
{
return g_PriceTables.m_StatePrices[
(((CBitModel<aNumMoveBits>::m_Probability - aSymbol) ^ ((-(int)aSymbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
}
};
template <int aNumMoveBits>
class CBitDecoder: public CBitModel<aNumMoveBits>
{

View File

@@ -1,64 +0,0 @@
/*
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "outbyte.h"
namespace NStream {
COutByte::COutByte(UINT32 aBufferSize):
m_BufferSize(aBufferSize)
{
m_Buffer = new BYTE[m_BufferSize];
}
COutByte::~COutByte()
{
delete []m_Buffer;
}
void COutByte::Init(ISequentialOutStream *aStream)
{
m_Stream = aStream;
m_ProcessedSize = 0;
m_Pos = 0;
}
HRESULT COutByte::Flush()
{
if (m_Pos == 0)
return S_OK;
UINT32 aProcessedSize;
HRESULT aResult = m_Stream->Write(m_Buffer, m_Pos, &aProcessedSize);
if (aResult != S_OK)
return aResult;
if (m_Pos != aProcessedSize)
return E_FAIL;
m_ProcessedSize += aProcessedSize;
m_Pos = 0;
return S_OK;
}
void COutByte::WriteBlock()
{
HRESULT aResult = Flush();
if (aResult != S_OK)
throw aResult;
}
}

View File

@@ -1,61 +0,0 @@
/*
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __STREAM_OUTBYTE_H
#define __STREAM_OUTBYTE_H
#include "portable.h"
#include "iiostrm.h"
namespace NStream {
class COutByte
{
BYTE *m_Buffer;
UINT32 m_Pos;
UINT32 m_BufferSize;
ISequentialOutStream* m_Stream;
UINT64 m_ProcessedSize;
void WriteBlock();
public:
COutByte(UINT32 aBufferSize = (1 << 20));
~COutByte();
void Init(ISequentialOutStream *aStream);
HRESULT Flush();
void WriteByte(BYTE aByte)
{
m_Buffer[m_Pos++] = aByte;
if(m_Pos >= m_BufferSize)
WriteBlock();
}
void WriteBytes(const void *aBytes, UINT32 aSize)
{
for (UINT32 i = 0; i < aSize; i++)
WriteByte(((const BYTE *)aBytes)[i]);
}
UINT64 GetProcessedSize() const { return m_ProcessedSize + m_Pos; }
};
}
#endif

View File

@@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define __COMPRESSION_RANGECODER_H
#include "inbyte.h"
#include "outbyte.h"
namespace NCompression {
namespace NArithmetic {
@@ -29,112 +28,6 @@ namespace NArithmetic {
const UINT32 kNumTopBits = 24;
const UINT32 kTopValue = (1 << kNumTopBits);
class CRangeEncoder
{
NStream::COutByte m_Stream;
UINT64 m_Low;
UINT32 m_Range;
UINT32 m_FFNum;
BYTE m_Cache;
public:
void Init(ISequentialOutStream *aStream)
{
m_Stream.Init(aStream);
m_Low = 0;
m_Range = UINT32(-1);
m_FFNum = 0;
m_Cache = 0;
}
void FlushData()
{
// m_Low += 1;
for(int i = 0; i < 5; i++)
ShiftLow();
}
HRESULT FlushStream()
{ return m_Stream.Flush(); }
void Encode(UINT32 aStart, UINT32 aSize, UINT32 aTotal)
{
m_Low += aStart * (m_Range /= aTotal);
m_Range *= aSize;
while (m_Range < kTopValue)
{
m_Range <<= 8;
ShiftLow();
}
}
/*
void EncodeDirectBitsDiv(UINT32 aValue, UINT32 aNumTotalBits)
{
m_Low += aValue * (m_Range >>= aNumTotalBits);
Normalize();
}
void EncodeDirectBitsDiv2(UINT32 aValue, UINT32 aNumTotalBits)
{
if (aNumTotalBits <= kNumBottomBits)
EncodeDirectBitsDiv(aValue, aNumTotalBits);
else
{
EncodeDirectBitsDiv(aValue >> kNumBottomBits, (aNumTotalBits - kNumBottomBits));
EncodeDirectBitsDiv(aValue & ((1 << kBottomValueBits) - 1), kNumBottomBits);
}
}
*/
void ShiftLow()
{
if (m_Low < (UINT32)0xFF000000 || UINT32(m_Low >> 32) == 1)
{
m_Stream.WriteByte(m_Cache + BYTE(m_Low >> 32));
for (;m_FFNum != 0; m_FFNum--)
m_Stream.WriteByte(0xFF + BYTE(m_Low >> 32));
m_Cache = BYTE(UINT32(m_Low) >> 24);
}
else
m_FFNum++;
m_Low = UINT32(m_Low) << 8;
}
void EncodeDirectBits(UINT32 aValue, UINT32 aNumTotalBits)
{
for (int i = aNumTotalBits - 1; i >= 0; i--)
{
m_Range >>= 1;
if (((aValue >> i) & 1) == 1)
m_Low += m_Range;
if (m_Range < kTopValue)
{
m_Range <<= 8;
ShiftLow();
}
}
}
void EncodeBit(UINT32 aSize0, UINT32 aNumTotalBits, UINT32 aSymbol)
{
UINT32 aNewBound = (m_Range >> aNumTotalBits) * aSize0;
if (aSymbol == 0)
m_Range = aNewBound;
else
{
m_Low += aNewBound;
m_Range -= aNewBound;
}
while (m_Range < kTopValue)
{
m_Range <<= 8;
ShiftLow();
}
}
UINT64 GetProcessedSize() { return m_Stream.GetProcessedSize() + m_FFNum; }
};
class CRangeDecoder
{
public: