1370b324cSopenharmony_ci// BranchMisc.cpp 2370b324cSopenharmony_ci 3370b324cSopenharmony_ci#include "StdAfx.h" 4370b324cSopenharmony_ci 5370b324cSopenharmony_ci#include "../../../C/CpuArch.h" 6370b324cSopenharmony_ci 7370b324cSopenharmony_ci#include "../Common/StreamUtils.h" 8370b324cSopenharmony_ci 9370b324cSopenharmony_ci#include "BranchMisc.h" 10370b324cSopenharmony_ci 11370b324cSopenharmony_cinamespace NCompress { 12370b324cSopenharmony_cinamespace NBranch { 13370b324cSopenharmony_ci 14370b324cSopenharmony_ciZ7_COM7F_IMF(CCoder::Init()) 15370b324cSopenharmony_ci{ 16370b324cSopenharmony_ci _pc = 0; 17370b324cSopenharmony_ci return S_OK; 18370b324cSopenharmony_ci} 19370b324cSopenharmony_ci 20370b324cSopenharmony_ci 21370b324cSopenharmony_ciZ7_COM7F_IMF2(UInt32, CCoder::Filter(Byte *data, UInt32 size)) 22370b324cSopenharmony_ci{ 23370b324cSopenharmony_ci const UInt32 processed = (UInt32)(size_t)(BraFunc(data, size, _pc) - data); 24370b324cSopenharmony_ci _pc += processed; 25370b324cSopenharmony_ci return processed; 26370b324cSopenharmony_ci} 27370b324cSopenharmony_ci 28370b324cSopenharmony_ci 29370b324cSopenharmony_cinamespace NArm64 { 30370b324cSopenharmony_ci 31370b324cSopenharmony_ci#ifndef Z7_EXTRACT_ONLY 32370b324cSopenharmony_ci 33370b324cSopenharmony_ciZ7_COM7F_IMF(CEncoder::Init()) 34370b324cSopenharmony_ci{ 35370b324cSopenharmony_ci _pc = _pc_Init; 36370b324cSopenharmony_ci return S_OK; 37370b324cSopenharmony_ci} 38370b324cSopenharmony_ci 39370b324cSopenharmony_ciZ7_COM7F_IMF2(UInt32, CEncoder::Filter(Byte *data, UInt32 size)) 40370b324cSopenharmony_ci{ 41370b324cSopenharmony_ci const UInt32 processed = (UInt32)(size_t)(Z7_BRANCH_CONV_ENC(ARM64)(data, size, _pc) - data); 42370b324cSopenharmony_ci _pc += processed; 43370b324cSopenharmony_ci return processed; 44370b324cSopenharmony_ci} 45370b324cSopenharmony_ci 46370b324cSopenharmony_ciZ7_COM7F_IMF(CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)) 47370b324cSopenharmony_ci{ 48370b324cSopenharmony_ci UInt32 pc = 0; 49370b324cSopenharmony_ci for (UInt32 i = 0; i < numProps; i++) 50370b324cSopenharmony_ci { 51370b324cSopenharmony_ci const PROPID propID = propIDs[i]; 52370b324cSopenharmony_ci if (propID == NCoderPropID::kDefaultProp || 53370b324cSopenharmony_ci propID == NCoderPropID::kBranchOffset) 54370b324cSopenharmony_ci { 55370b324cSopenharmony_ci const PROPVARIANT &prop = props[i]; 56370b324cSopenharmony_ci if (prop.vt != VT_UI4) 57370b324cSopenharmony_ci return E_INVALIDARG; 58370b324cSopenharmony_ci pc = prop.ulVal; 59370b324cSopenharmony_ci if ((pc & 3) != 0) 60370b324cSopenharmony_ci return E_INVALIDARG; 61370b324cSopenharmony_ci } 62370b324cSopenharmony_ci } 63370b324cSopenharmony_ci _pc_Init = pc; 64370b324cSopenharmony_ci return S_OK; 65370b324cSopenharmony_ci} 66370b324cSopenharmony_ci 67370b324cSopenharmony_ci 68370b324cSopenharmony_ciZ7_COM7F_IMF(CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)) 69370b324cSopenharmony_ci{ 70370b324cSopenharmony_ci if (_pc_Init == 0) 71370b324cSopenharmony_ci return S_OK; 72370b324cSopenharmony_ci Byte buf[4]; 73370b324cSopenharmony_ci SetUi32(buf, _pc_Init) 74370b324cSopenharmony_ci return WriteStream(outStream, buf, 4); 75370b324cSopenharmony_ci} 76370b324cSopenharmony_ci 77370b324cSopenharmony_ci#endif 78370b324cSopenharmony_ci 79370b324cSopenharmony_ci 80370b324cSopenharmony_ciZ7_COM7F_IMF(CDecoder::Init()) 81370b324cSopenharmony_ci{ 82370b324cSopenharmony_ci _pc = _pc_Init; 83370b324cSopenharmony_ci return S_OK; 84370b324cSopenharmony_ci} 85370b324cSopenharmony_ci 86370b324cSopenharmony_ciZ7_COM7F_IMF2(UInt32, CDecoder::Filter(Byte *data, UInt32 size)) 87370b324cSopenharmony_ci{ 88370b324cSopenharmony_ci const UInt32 processed = (UInt32)(size_t)(Z7_BRANCH_CONV_DEC(ARM64)(data, size, _pc) - data); 89370b324cSopenharmony_ci _pc += processed; 90370b324cSopenharmony_ci return processed; 91370b324cSopenharmony_ci} 92370b324cSopenharmony_ci 93370b324cSopenharmony_ciZ7_COM7F_IMF(CDecoder::SetDecoderProperties2(const Byte *props, UInt32 size)) 94370b324cSopenharmony_ci{ 95370b324cSopenharmony_ci UInt32 val = 0; 96370b324cSopenharmony_ci if (size != 0) 97370b324cSopenharmony_ci { 98370b324cSopenharmony_ci if (size != 4) 99370b324cSopenharmony_ci return E_NOTIMPL; 100370b324cSopenharmony_ci val = GetUi32(props); 101370b324cSopenharmony_ci if ((val & 3) != 0) 102370b324cSopenharmony_ci return E_NOTIMPL; 103370b324cSopenharmony_ci } 104370b324cSopenharmony_ci _pc_Init = val; 105370b324cSopenharmony_ci return S_OK; 106370b324cSopenharmony_ci} 107370b324cSopenharmony_ci 108370b324cSopenharmony_ci} 109370b324cSopenharmony_ci 110370b324cSopenharmony_ci}} 111