This commit is contained in:
Igor Pavlov
2005-05-30 00:00:00 +00:00
committed by Kornel Lesiński
parent 8c1b5c7b7e
commit 3c510ba80b
926 changed files with 40559 additions and 23519 deletions

View File

@@ -4,73 +4,14 @@
#include "PPC.h"
#include "Windows/Defs.h"
#include "BranchPPC.c"
static HRESULT BC_PPC_B_Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UINT64 *inSize, const UINT64 *outSize,
ICompressProgressInfo *progress, BYTE *buffer, bool encoding)
UInt32 CBC_PPC_B_Encoder::SubFilter(Byte *data, UInt32 size)
{
UINT32 nowPos = 0;
UINT64 nowPos64 = 0;
UINT32 bufferPos = 0;
while(true)
{
UINT32 processedSize;
UINT32 size = kBufferSize - bufferPos;
RINOK(inStream->Read(buffer + bufferPos, size, &processedSize));
UINT32 endPos = bufferPos + processedSize;
if (endPos < 4)
{
if (endPos > 0)
{
RINOK(outStream->Write(buffer, endPos, &processedSize));
if (endPos != processedSize)
return E_FAIL;
}
return S_OK;
}
for (bufferPos = 0; bufferPos <= endPos - 4; bufferPos += 4)
{
// PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link)
if ((buffer[bufferPos] >> 2) == 0x12 &&
(
(buffer[bufferPos + 3] & 3) == 1
// || (buffer[bufferPos+3] & 3) == 3
)
)
{
UINT32 src = ((buffer[bufferPos + 0] & 3) << 24) |
(buffer[bufferPos + 1] << 16) |
(buffer[bufferPos + 2] << 8) |
(buffer[bufferPos + 3] & (~3));
UINT32 dest;
if (encoding)
dest = nowPos + bufferPos + src;
else
dest = src - (nowPos + bufferPos);
buffer[bufferPos + 0] = 0x48 | ((dest >> 24) & 0x3);
buffer[bufferPos + 1] = (dest >> 16);
buffer[bufferPos + 2] = (dest >> 8);
buffer[bufferPos + 3] &= 0x3;
buffer[bufferPos + 3] |= dest;
}
}
nowPos += bufferPos;
nowPos64 += bufferPos;
RINOK(outStream->Write(buffer, bufferPos, &processedSize));
if (bufferPos != processedSize)
return E_FAIL;
if (progress != NULL)
{
RINOK(progress->SetRatioInfo(&nowPos64, &nowPos64));
}
UINT32 i = 0;
while(bufferPos < endPos)
buffer[i++] = buffer[bufferPos++];
bufferPos = i;
}
return ::PPC_B_Convert(data, size, _bufferPos, 1);
}
MyClassImp(BC_PPC_B)
UInt32 CBC_PPC_B_Decoder::SubFilter(Byte *data, UInt32 size)
{
return ::PPC_B_Convert(data, size, _bufferPos, 0);
}