mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-13 14:11:34 -06:00
4.44 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
804edc5756
commit
d9666cf046
38
CPP/7zip/Compress/ByteSwap/ByteSwap.cpp
Executable file
38
CPP/7zip/Compress/ByteSwap/ByteSwap.cpp
Executable file
@@ -0,0 +1,38 @@
|
||||
// ByteSwap.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ByteSwap.h"
|
||||
|
||||
STDMETHODIMP CByteSwap2::Init() { return S_OK; }
|
||||
|
||||
STDMETHODIMP_(UInt32) CByteSwap2::Filter(Byte *data, UInt32 size)
|
||||
{
|
||||
const UInt32 kStep = 2;
|
||||
UInt32 i;
|
||||
for (i = 0; i + kStep <= size; i += kStep)
|
||||
{
|
||||
Byte b = data[i];
|
||||
data[i] = data[i + 1];
|
||||
data[i + 1] = b;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
STDMETHODIMP CByteSwap4::Init() { return S_OK; }
|
||||
|
||||
STDMETHODIMP_(UInt32) CByteSwap4::Filter(Byte *data, UInt32 size)
|
||||
{
|
||||
const UInt32 kStep = 4;
|
||||
UInt32 i;
|
||||
for (i = 0; i + kStep <= size; i += kStep)
|
||||
{
|
||||
Byte b0 = data[i];
|
||||
Byte b1 = data[i + 1];
|
||||
data[i] = data[i + 3];
|
||||
data[i + 1] = data[i + 2];
|
||||
data[i + 2] = b1;
|
||||
data[i + 3] = b0;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
Reference in New Issue
Block a user