add multiple textures for different book type dvd
This commit is contained in:
parent
98be1813ba
commit
c62b2e6ac2
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -9,10 +9,12 @@ libdvdcss/msvc/.vs/*
|
||||||
Lib9660/Release/*
|
Lib9660/Release/*
|
||||||
Lib9660/Debug/*
|
Lib9660/Debug/*
|
||||||
|
|
||||||
|
|
||||||
ImGui/Release/*
|
ImGui/Release/*
|
||||||
ImGui/Debug/*
|
ImGui/Debug/*
|
||||||
|
|
||||||
|
LZMA/Release/*
|
||||||
|
LZMA/Debug/*
|
||||||
|
|
||||||
DumpDVD/Debug/*
|
DumpDVD/Debug/*
|
||||||
DumpDVD/Release/*
|
DumpDVD/Release/*
|
||||||
|
|
||||||
|
|
11
DumpDVD.sln
11
DumpDVD.sln
|
@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DumpDVD", "DumpDVD\DumpDVD.vcxproj", "{A9A5F041-541F-47EA-B583-DE84B59D9B62}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DumpDVD", "DumpDVD\DumpDVD.vcxproj", "{A9A5F041-541F-47EA-B583-DE84B59D9B62}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{50F2BF62-8520-4B37-97DD-578EA282EC04} = {50F2BF62-8520-4B37-97DD-578EA282EC04}
|
{50F2BF62-8520-4B37-97DD-578EA282EC04} = {50F2BF62-8520-4B37-97DD-578EA282EC04}
|
||||||
|
{7E31483B-ECA1-4D72-9D21-BC80E56D00BE} = {7E31483B-ECA1-4D72-9D21-BC80E56D00BE}
|
||||||
{7F404DED-08FF-4092-97EF-0F63C5788DD2} = {7F404DED-08FF-4092-97EF-0F63C5788DD2}
|
{7F404DED-08FF-4092-97EF-0F63C5788DD2} = {7F404DED-08FF-4092-97EF-0F63C5788DD2}
|
||||||
{B2BCCCDA-BDB0-4FBE-84A3-EA1E8429F732} = {B2BCCCDA-BDB0-4FBE-84A3-EA1E8429F732}
|
{B2BCCCDA-BDB0-4FBE-84A3-EA1E8429F732} = {B2BCCCDA-BDB0-4FBE-84A3-EA1E8429F732}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
|
@ -16,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImGui", "ImGui\ImGui.vcxpro
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lib9660", "Lib9660\Lib9660.vcxproj", "{7F404DED-08FF-4092-97EF-0F63C5788DD2}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lib9660", "Lib9660\Lib9660.vcxproj", "{7F404DED-08FF-4092-97EF-0F63C5788DD2}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LZMA", "LZMA\LZMA.vcxproj", "{7E31483B-ECA1-4D72-9D21-BC80E56D00BE}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
|
@ -56,6 +59,14 @@ Global
|
||||||
{7F404DED-08FF-4092-97EF-0F63C5788DD2}.Release|x64.Build.0 = Release|x64
|
{7F404DED-08FF-4092-97EF-0F63C5788DD2}.Release|x64.Build.0 = Release|x64
|
||||||
{7F404DED-08FF-4092-97EF-0F63C5788DD2}.Release|x86.ActiveCfg = Release|Win32
|
{7F404DED-08FF-4092-97EF-0F63C5788DD2}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{7F404DED-08FF-4092-97EF-0F63C5788DD2}.Release|x86.Build.0 = Release|Win32
|
{7F404DED-08FF-4092-97EF-0F63C5788DD2}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{7E31483B-ECA1-4D72-9D21-BC80E56D00BE}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{7E31483B-ECA1-4D72-9D21-BC80E56D00BE}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{7E31483B-ECA1-4D72-9D21-BC80E56D00BE}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{7E31483B-ECA1-4D72-9D21-BC80E56D00BE}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{7E31483B-ECA1-4D72-9D21-BC80E56D00BE}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{7E31483B-ECA1-4D72-9D21-BC80E56D00BE}.Release|x64.Build.0 = Release|x64
|
||||||
|
{7E31483B-ECA1-4D72-9D21-BC80E56D00BE}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{7E31483B-ECA1-4D72-9D21-BC80E56D00BE}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Dvd\DvdRipper.cpp" />
|
<ClCompile Include="Dvd\DvdRipper.cpp" />
|
||||||
<ClCompile Include="Dvd\TitleKey.cpp" />
|
<ClCompile Include="Dvd\TitleKey.cpp" />
|
||||||
|
<ClCompile Include="Gui\DvdSpin\CdTex.cpp" />
|
||||||
<ClCompile Include="Gui\DvdSpin\D3DSpin.cpp" />
|
<ClCompile Include="Gui\DvdSpin\D3DSpin.cpp" />
|
||||||
<ClCompile Include="Gui\DvdSpin\RenderDvdSpin.cpp" />
|
<ClCompile Include="Gui\DvdSpin\RenderDvdSpin.cpp" />
|
||||||
<ClCompile Include="Main.cpp" />
|
<ClCompile Include="Main.cpp" />
|
||||||
|
@ -37,7 +38,11 @@
|
||||||
<ClInclude Include="Dvd\TitleKey.hpp" />
|
<ClInclude Include="Dvd\TitleKey.hpp" />
|
||||||
<ClInclude Include="Gui\D3D.hpp" />
|
<ClInclude Include="Gui\D3D.hpp" />
|
||||||
<ClInclude Include="Gui\DumpDVD.hpp" />
|
<ClInclude Include="Gui\DumpDVD.hpp" />
|
||||||
|
<ClInclude Include="Gui\DvdSpin\CdTex.hpp" />
|
||||||
|
<ClInclude Include="Gui\DvdSpin\CdType.hpp" />
|
||||||
|
<ClInclude Include="Gui\DvdSpin\ceedee_tex.h" />
|
||||||
<ClInclude Include="Gui\DvdSpin\D3DSpin.hpp" />
|
<ClInclude Include="Gui\DvdSpin\D3DSpin.hpp" />
|
||||||
|
<ClInclude Include="Gui\DvdSpin\diff.hpp" />
|
||||||
<ClInclude Include="Gui\DvdSpin\RenderDvdSpin.hpp" />
|
<ClInclude Include="Gui\DvdSpin\RenderDvdSpin.hpp" />
|
||||||
<ClInclude Include="Gui\DvdSpin\SpinShaderVarients.h" />
|
<ClInclude Include="Gui\DvdSpin\SpinShaderVarients.h" />
|
||||||
<ClInclude Include="Gui\MainWindow.hpp" />
|
<ClInclude Include="Gui\MainWindow.hpp" />
|
||||||
|
@ -107,7 +112,7 @@
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)include\PFD;$(SolutionDir)include\SDL;$(SolutionDir)Lib9660;$(SolutionDir)ImGui;$(SolutionDir)libdvdcss\src\dvdcss;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)include\PFD;$(SolutionDir)include\SDL;$(SolutionDir)Lib9660;$(SolutionDir)ImGui;$(SolutionDir)libdvdcss\src\dvdcss;$(SolutionDir)LZMA;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -115,7 +120,7 @@
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>d3d11.lib;winmm.lib;version.lib;Imm32.lib;Setupapi.lib;SDL2.lib;ImGui.lib;Lib9660.lib;libdvdcss.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>d3d11.lib;winmm.lib;version.lib;Imm32.lib;Setupapi.lib;SDL2.lib;ImGui.lib;Lib9660.lib;libdvdcss.lib;lzma.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EntryPointSymbol>
|
<EntryPointSymbol>
|
||||||
</EntryPointSymbol>
|
</EntryPointSymbol>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -128,7 +133,7 @@
|
||||||
<SDLCheck>false</SDLCheck>
|
<SDLCheck>false</SDLCheck>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)include\PFD;$(SolutionDir)include\SDL;$(SolutionDir)Lib9660;$(SolutionDir)ImGui;$(SolutionDir)libdvdcss\src\dvdcss;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)include\PFD;$(SolutionDir)include\SDL;$(SolutionDir)Lib9660;$(SolutionDir)ImGui;$(SolutionDir)libdvdcss\src\dvdcss;$(SolutionDir)LZMA;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
@ -139,7 +144,7 @@
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>d3d11.lib;winmm.lib;version.lib;Imm32.lib;Setupapi.lib;SDL2.lib;ImGui.lib;Lib9660.lib;libdvdcss.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>d3d11.lib;winmm.lib;version.lib;Imm32.lib;Setupapi.lib;SDL2.lib;ImGui.lib;Lib9660.lib;libdvdcss.lib;lzma.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -150,10 +155,12 @@
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)include\PFD;$(SolutionDir)include\SDL;$(SolutionDir)Lib9660;$(SolutionDir)ImGui;$(SolutionDir)libdvdcss\src\dvdcss;$(SolutionDir)LZMA;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>d3d11.lib;winmm.lib;version.lib;Imm32.lib;Setupapi.lib;SDL2.lib;ImGui.lib;Lib9660.lib;libdvdcss.lib;lzma.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -166,12 +173,14 @@
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)include\PFD;$(SolutionDir)include\SDL;$(SolutionDir)Lib9660;$(SolutionDir)ImGui;$(SolutionDir)libdvdcss\src\dvdcss;$(SolutionDir)LZMA;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>d3d11.lib;winmm.lib;version.lib;Imm32.lib;Setupapi.lib;SDL2.lib;ImGui.lib;Lib9660.lib;libdvdcss.lib;lzma.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -51,6 +51,9 @@
|
||||||
<ClCompile Include="Gui\DvdSpin\RenderDvdSpin.cpp">
|
<ClCompile Include="Gui\DvdSpin\RenderDvdSpin.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Gui\DvdSpin\CdTex.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Scsi\IoCtl.hpp">
|
<ClInclude Include="Scsi\IoCtl.hpp">
|
||||||
|
@ -98,5 +101,17 @@
|
||||||
<ClInclude Include="Gui\DvdSpin\RenderDvdSpin.hpp">
|
<ClInclude Include="Gui\DvdSpin\RenderDvdSpin.hpp">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Gui\DvdSpin\ceedee_tex.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Gui\DvdSpin\diff.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Gui\DvdSpin\CdTex.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Gui\DvdSpin\CdType.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -9,6 +9,6 @@
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ShowAllFiles>true</ShowAllFiles>
|
<ShowAllFiles>false</ShowAllFiles>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -16,18 +16,15 @@ namespace Li::Dvd {
|
||||||
uint32_t DvdRipper::FailedReads() {
|
uint32_t DvdRipper::FailedReads() {
|
||||||
return this->failedReads;
|
return this->failedReads;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DvdRipper::RetriedReads() {
|
uint32_t DvdRipper::RetriedReads() {
|
||||||
return this->retriedReads;
|
return this->retriedReads;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DvdRipper::FileSoFar() {
|
uint32_t DvdRipper::FileSoFar() {
|
||||||
return this->fileReadSoFar;
|
return this->fileReadSoFar;
|
||||||
}
|
}
|
||||||
uint32_t DvdRipper::FileLen() {
|
uint32_t DvdRipper::FileLen() {
|
||||||
return this->fileRemain;
|
return this->fileRemain;
|
||||||
}
|
}
|
||||||
|
|
||||||
float DvdRipper::PercentDone() {
|
float DvdRipper::PercentDone() {
|
||||||
return (((float)this->sectorsReadSoFar / (float)this->drive->Sectors()));
|
return (((float)this->sectorsReadSoFar / (float)this->drive->Sectors()));
|
||||||
}
|
}
|
||||||
|
@ -37,23 +34,18 @@ namespace Li::Dvd {
|
||||||
std::string DvdRipper::OutputPath() {
|
std::string DvdRipper::OutputPath() {
|
||||||
return this->outputPath;
|
return this->outputPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::byte* DvdRipper::GetDiscKey() {
|
std::byte* DvdRipper::GetDiscKey() {
|
||||||
return this->drive->DiscKey();
|
return this->drive->DiscKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::byte* DvdRipper::GetTitleKey() {
|
std::byte* DvdRipper::GetTitleKey() {
|
||||||
return this->titleKey;
|
return this->titleKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DvdRipper::Decrypt() {
|
bool DvdRipper::Decrypt() {
|
||||||
return this->decrypt;
|
return this->decrypt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DvdRipper::Starting() {
|
bool DvdRipper::Starting() {
|
||||||
return this->starting;
|
return this->starting;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DvdRipper::Done() {
|
bool DvdRipper::Done() {
|
||||||
return this->done;
|
return this->done;
|
||||||
}
|
}
|
||||||
|
@ -63,41 +55,79 @@ namespace Li::Dvd {
|
||||||
std::string DvdRipper::ErrorMessage() {
|
std::string DvdRipper::ErrorMessage() {
|
||||||
return this->errorMsg;
|
return this->errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to handle bad sectors
|
||||||
|
// the way this algorithm essentially works is as follows:
|
||||||
|
// Attempt to read total num of sectors, one at a time
|
||||||
|
//
|
||||||
|
// - if total read sectors count is < 0 (i.e read failed),
|
||||||
|
// - check if the last read was also an error, if it was not,
|
||||||
|
// - try to read the sector again, retry it 5 times
|
||||||
|
// -- if it still fails, set that sector to all 0x00, and skip it
|
||||||
|
// --- also set a flag saying the last sector read failed, keep skipping until get a successful read,
|
||||||
int DvdRipper::read1SectorATimeSkippingBadSectors(int toRead) {
|
int DvdRipper::read1SectorATimeSkippingBadSectors(int toRead) {
|
||||||
int nmRd = 0;
|
int nmRd = 0;
|
||||||
int numRetry = 5;
|
int numRetry = 5;
|
||||||
for (int i = 0; i < toRead; i++) {
|
for (int i = 0; i < toRead; i++) {
|
||||||
for (int retry = 0; retry < numRetry; retry++) {
|
for (int retry = 0; retry < numRetry; retry++) {
|
||||||
memset(this->tmpBuffer, 0x00, DVDCSS_BLOCK_SIZE);
|
|
||||||
int dataRd = dvdcss_read(driveIoCtl->GetDvdCssHandle(), this->tmpBuffer, 1, (this->decrypt ? DVDCSS_READ_DECRYPT : DVDCSS_NOFLAGS));
|
int dataRd = dvdcss_read(driveIoCtl->GetDvdCssHandle(), this->tmpBuffer, 1, (this->decrypt ? DVDCSS_READ_DECRYPT : DVDCSS_NOFLAGS));
|
||||||
if (dataRd < 0) {
|
if (dataRd < 0) {
|
||||||
dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar, (this->decrypt ? DVDCSS_SEEK_KEY : DVDCSS_NOFLAGS) );
|
|
||||||
|
// if the last read was an error, and this read is an error, give up trying as were still in
|
||||||
|
// the section of bad sectors,
|
||||||
|
|
||||||
|
// otherwise retry a few times, to see if we can read this sector
|
||||||
|
if (this->lastReadWasErr || ((retry + 1) >= numRetry)) {
|
||||||
|
this->errorMsg = "one or more sectors failed to be read.";
|
||||||
|
|
||||||
if ((retry + 1) >= numRetry) {
|
// try seek forward 1 sector
|
||||||
dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar + 1, (this->decrypt ? DVDCSS_SEEK_KEY : DVDCSS_NOFLAGS));
|
if (dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar + 1, DVDCSS_NOFLAGS) < 0) break;
|
||||||
|
|
||||||
|
// set the last read was error flag,
|
||||||
|
// increment the number of failed reads
|
||||||
|
// and set the error flag to trigger the "This ISO Was created with errors" message.
|
||||||
this->failedReads++;
|
this->failedReads++;
|
||||||
|
this->lastReadWasErr = true;
|
||||||
|
this->error = true;
|
||||||
|
|
||||||
|
// set current sector to all 0x00 ...
|
||||||
|
memset(this->tmpBuffer, 0x00, DVDCSS_BLOCK_SIZE);
|
||||||
|
|
||||||
|
// write null sector to the ISO ...
|
||||||
|
this->iso->write((const char*)this->tmpBuffer, DVDCSS_BLOCK_SIZE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// if we have not reached max retry count, then set the position back to the current sector
|
||||||
|
// and attempt a read again ..
|
||||||
|
if (dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar, DVDCSS_NOFLAGS) < 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->retriedReads++;
|
this->retriedReads++;
|
||||||
continue; // retry
|
continue; // retry
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// if there was a successful read,
|
||||||
|
this->lastReadWasErr = false;
|
||||||
this->iso->write((const char*)this->tmpBuffer, DVDCSS_BLOCK_SIZE * dataRd);
|
this->iso->write((const char*)this->tmpBuffer, DVDCSS_BLOCK_SIZE * dataRd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// increment the num sectors read counter
|
||||||
nmRd += 1;
|
nmRd += 1;
|
||||||
this->sectorsReadSoFar += 1;
|
this->sectorsReadSoFar += 1;
|
||||||
this->fileReadSoFar += 1;
|
this->fileReadSoFar += 1;
|
||||||
|
|
||||||
if (this->sectorsReadSoFar > this->drive->Sectors()) // check if we've read the last sector ...
|
// check if we've read the last sector ...
|
||||||
|
if (this->sectorsReadSoFar > this->drive->Sectors())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nmRd;
|
return nmRd;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this function is main function for reading & decrypting sectors
|
||||||
|
// on a Content Scramble System enabled DVD.
|
||||||
void DvdRipper::readCssSectors() {
|
void DvdRipper::readCssSectors() {
|
||||||
do {
|
do {
|
||||||
int toRead = this->sectorsAtOnce;
|
int toRead = this->sectorsAtOnce;
|
||||||
|
@ -127,7 +157,6 @@ namespace Li::Dvd {
|
||||||
this->fileReadSoFar = 0;
|
this->fileReadSoFar = 0;
|
||||||
this->fileRemain = 0;
|
this->fileRemain = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DvdRipper::readNonFileSectors() {
|
void DvdRipper::readNonFileSectors() {
|
||||||
dvdcss_title(this->driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar);
|
dvdcss_title(this->driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar);
|
||||||
this->fileRemain = Li::Dvd::TitleKey::GetDistanceToNextFile(this->sectorsReadSoFar);
|
this->fileRemain = Li::Dvd::TitleKey::GetDistanceToNextFile(this->sectorsReadSoFar);
|
||||||
|
@ -238,6 +267,7 @@ namespace Li::Dvd {
|
||||||
this->errorMsg = "";
|
this->errorMsg = "";
|
||||||
this->keepRunning = false;
|
this->keepRunning = false;
|
||||||
this->starting = false;
|
this->starting = false;
|
||||||
|
this->lastReadWasErr = false;
|
||||||
|
|
||||||
this->ripinThread = nullptr;
|
this->ripinThread = nullptr;
|
||||||
this->tmpBuffer = new std::byte[DVDCSS_BLOCK_SIZE * this->sectorsAtOnce];
|
this->tmpBuffer = new std::byte[DVDCSS_BLOCK_SIZE * this->sectorsAtOnce];
|
||||||
|
@ -282,9 +312,13 @@ namespace Li::Dvd {
|
||||||
this->error = false;
|
this->error = false;
|
||||||
this->errorMsg = "";
|
this->errorMsg = "";
|
||||||
|
|
||||||
|
this->inFile = false;
|
||||||
|
this->keepRunning = false;
|
||||||
|
this->starting = false;
|
||||||
|
this->lastReadWasErr = false;
|
||||||
|
|
||||||
this->sectorsReadSoFar = 0;
|
this->sectorsReadSoFar = 0;
|
||||||
this->fileReadSoFar = 0;
|
this->fileReadSoFar = 0;
|
||||||
this->keepRunning = false;
|
|
||||||
this->ripinThread->join();
|
this->ripinThread->join();
|
||||||
|
|
||||||
delete this->driveIoCtl;
|
delete this->driveIoCtl;
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace Li::Dvd {
|
||||||
bool error;
|
bool error;
|
||||||
bool done;
|
bool done;
|
||||||
|
|
||||||
|
bool lastReadWasErr;
|
||||||
bool keepRunning;
|
bool keepRunning;
|
||||||
bool starting;
|
bool starting;
|
||||||
bool decrypt;
|
bool decrypt;
|
||||||
|
|
|
@ -141,7 +141,7 @@ namespace Li::Gui {
|
||||||
|
|
||||||
this->d3dDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
this->d3dDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D::Render() {
|
void D3D::Render() {
|
||||||
|
|
||||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
|
@ -323,7 +323,7 @@ namespace Li::Gui {
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||||
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize, ImGuiCond_Always);
|
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize, ImGuiCond_Always);
|
||||||
|
|
||||||
ImGui::Begin("DVD Dumper", NULL, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |
|
ImGui::Begin("DVD Dumper", NULL, /* ImGuiWindowFlags_NoCollapse | */ ImGuiWindowFlags_NoMove |
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing);
|
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||||
|
|
||||||
if (this->imRippinIt)
|
if (this->imRippinIt)
|
||||||
|
|
72
DumpDVD/Gui/DvdSpin/CdTex.cpp
Normal file
72
DumpDVD/Gui/DvdSpin/CdTex.cpp
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#include <lzma.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include "diff.hpp"
|
||||||
|
#include "ceedee_tex.h"
|
||||||
|
|
||||||
|
#include "CdTex.hpp"
|
||||||
|
#include "CdType.hpp"
|
||||||
|
|
||||||
|
namespace Li::Gui::DvdSpin {
|
||||||
|
CdTex::CdTex() {
|
||||||
|
this->uncompressedTextureSz = ceedeeImgUncompressedSz;
|
||||||
|
this->SetUnknownTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CdTex::applyDiff(uint32_t numChanges, ImgDiff* changesList) {
|
||||||
|
uint32_t* uncompressedTextureRGBA = (uint32_t*)this->uncompressedTexture;
|
||||||
|
for (unsigned int i = 0; i < numChanges; i++) {
|
||||||
|
ImgDiff curChange = changesList[i];
|
||||||
|
uncompressedTextureRGBA[curChange.Location] = curChange.NewColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CdTex::SetCdTexture() {
|
||||||
|
if (this->currentCdType != CdType::UNKNOWN_DISC) this->SetUnknownTexture();
|
||||||
|
this->applyDiff(ceedeeCdDiffSz, ceedeeCdDiff);
|
||||||
|
this->currentCdType = CdType::COMPACT_DISC;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CdTex::SetDvdTexture() {
|
||||||
|
if (this->currentCdType != CdType::UNKNOWN_DISC) this->SetUnknownTexture();
|
||||||
|
this->applyDiff(ceedeeDvdDiffSz, ceedeeDvdDiff);
|
||||||
|
this->currentCdType = CdType::DIGITAL_VERSITLE_DISC;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CdTex::SetBdTexture() {
|
||||||
|
if (this->currentCdType != CdType::UNKNOWN_DISC) this->SetUnknownTexture();
|
||||||
|
this->applyDiff(ceedeeBluRayDiffSz, ceedeeBluRayDiff);
|
||||||
|
this->currentCdType = CdType::BLU_RAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CdTex::SetUnknownTexture() {
|
||||||
|
this->uncompressedTexture = new std::byte[this->uncompressedTextureSz];
|
||||||
|
uint32_t compressedSize = ceedeeImgCompressedDataSz;
|
||||||
|
lzma2decompress((unsigned char*)&ceedeeImgCompressedData, &compressedSize, (unsigned char*)this->uncompressedTexture, &this->uncompressedTextureSz);
|
||||||
|
this->currentCdType = CdType::UNKNOWN_DISC;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CdTex::Width() {
|
||||||
|
return ceedeeImgWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CdTex::Height() {
|
||||||
|
return ceedeeImgHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CdTex::Channels() {
|
||||||
|
return ceedeeImgChannels;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CdTex::Stride() {
|
||||||
|
return (this->Width() * this->Channels());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::byte* CdTex::GetCurrentTexture() {
|
||||||
|
return this->uncompressedTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
CdTex::~CdTex() {
|
||||||
|
this->currentCdType = CdType::UNKNOWN_DISC;
|
||||||
|
delete this->uncompressedTexture;
|
||||||
|
}
|
||||||
|
}
|
30
DumpDVD/Gui/DvdSpin/CdTex.hpp
Normal file
30
DumpDVD/Gui/DvdSpin/CdTex.hpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef _LI_CDTEX_H
|
||||||
|
#define _LI_CDTEX_H 1
|
||||||
|
#include <iostream>
|
||||||
|
#include "CdType.hpp"
|
||||||
|
#include "diff.hpp"
|
||||||
|
|
||||||
|
namespace Li::Gui::DvdSpin {
|
||||||
|
class CdTex {
|
||||||
|
private:
|
||||||
|
std::byte* uncompressedTexture;
|
||||||
|
uint32_t uncompressedTextureSz;
|
||||||
|
CdType currentCdType;
|
||||||
|
void applyDiff(uint32_t numChanges, ImgDiff* changesList);
|
||||||
|
public:
|
||||||
|
CdTex();
|
||||||
|
~CdTex();
|
||||||
|
void SetUnknownTexture();
|
||||||
|
void SetBdTexture();
|
||||||
|
void SetDvdTexture();
|
||||||
|
void SetCdTexture();
|
||||||
|
|
||||||
|
uint32_t Width();
|
||||||
|
uint32_t Height();
|
||||||
|
uint32_t Channels();
|
||||||
|
uint32_t Stride();
|
||||||
|
std::byte* GetCurrentTexture();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
13
DumpDVD/Gui/DvdSpin/CdType.hpp
Normal file
13
DumpDVD/Gui/DvdSpin/CdType.hpp
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef _LI_CDTYPE_H
|
||||||
|
#define _LI_CDTYPE_H 1
|
||||||
|
|
||||||
|
namespace Li::Gui::DvdSpin {
|
||||||
|
enum class CdType {
|
||||||
|
UNKNOWN_DISC,
|
||||||
|
COMPACT_DISC,
|
||||||
|
DIGITAL_VERSITLE_DISC,
|
||||||
|
BLU_RAY
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ceedee.h"
|
#include "ceedee.h"
|
||||||
#include "vec.hpp"
|
#include "vec.hpp"
|
||||||
#include "SpinShaderVarients.h"
|
#include "SpinShaderVarients.h"
|
||||||
|
#include "CdTex.hpp"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
|
@ -14,7 +15,9 @@ namespace Li::Gui::DvdSpin {
|
||||||
|
|
||||||
|
|
||||||
// dvd spin
|
// dvd spin
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void D3DSpin::setupSpinningDVD() {
|
void D3DSpin::setupSpinningDVD() {
|
||||||
this->createCdVertexShader();
|
this->createCdVertexShader();
|
||||||
this->createCdVertexLayout();
|
this->createCdVertexLayout();
|
||||||
|
@ -120,11 +123,19 @@ namespace Li::Gui::DvdSpin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void D3DSpin::updateCdTexture() {
|
||||||
|
this->d3d->D3dDeviceContext()->UpdateSubresource(this->cdTexture,
|
||||||
|
NULL,
|
||||||
|
nullptr,
|
||||||
|
this->TextureProvider()->GetCurrentTexture(),
|
||||||
|
this->TextureProvider()->Stride(),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT D3DSpin::createCdTexture() {
|
HRESULT D3DSpin::createCdTexture() {
|
||||||
D3D11_TEXTURE2D_DESC tdesc;
|
D3D11_TEXTURE2D_DESC tdesc;
|
||||||
tdesc.Width = ceedeeImgWidth;
|
tdesc.Width = this->TextureProvider()->Width();
|
||||||
tdesc.Height = ceedeeImgHeight;
|
tdesc.Height = this->TextureProvider()->Height();
|
||||||
tdesc.MipLevels = 1;
|
tdesc.MipLevels = 1;
|
||||||
tdesc.ArraySize = 1;
|
tdesc.ArraySize = 1;
|
||||||
tdesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
tdesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||||
|
@ -136,8 +147,10 @@ namespace Li::Gui::DvdSpin {
|
||||||
tdesc.MiscFlags = 0;
|
tdesc.MiscFlags = 0;
|
||||||
|
|
||||||
D3D11_SUBRESOURCE_DATA tres = {};
|
D3D11_SUBRESOURCE_DATA tres = {};
|
||||||
tres.pSysMem = ceedeeImgData;
|
|
||||||
tres.SysMemPitch = (ceedeeImgWidth * ceedeeImgChannels);
|
|
||||||
|
tres.pSysMem = this->TextureProvider()->GetCurrentTexture();
|
||||||
|
tres.SysMemPitch = this->TextureProvider()->Stride();
|
||||||
tres.SysMemSlicePitch = 0;
|
tres.SysMemSlicePitch = 0;
|
||||||
|
|
||||||
return d3d->D3dDevice()->CreateTexture2D(&tdesc, &tres, &this->cdTexture);
|
return d3d->D3dDevice()->CreateTexture2D(&tdesc, &tres, &this->cdTexture);
|
||||||
|
@ -172,7 +185,6 @@ namespace Li::Gui::DvdSpin {
|
||||||
this->counter++;
|
this->counter++;
|
||||||
this->camWorld = DirectX::XMMatrixRotationY((float)((float)this->counter / 10.0f));
|
this->camWorld = DirectX::XMMatrixRotationY((float)((float)this->counter / 10.0f));
|
||||||
|
|
||||||
|
|
||||||
DirectX::XMMATRIX camBufData[3];
|
DirectX::XMMATRIX camBufData[3];
|
||||||
camBufData[0] = XMMatrixTranspose(this->camWorld);
|
camBufData[0] = XMMatrixTranspose(this->camWorld);
|
||||||
camBufData[1] = XMMatrixTranspose(this->camView);
|
camBufData[1] = XMMatrixTranspose(this->camView);
|
||||||
|
@ -189,16 +201,39 @@ namespace Li::Gui::DvdSpin {
|
||||||
|
|
||||||
this->updateCamBuffer();
|
this->updateCamBuffer();
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
|
||||||
ImGui::Begin("Debug Position");
|
ImGui::Begin("Debug Position");
|
||||||
ImGui::DragFloat4("Eye", (float*)this->eye.m128_f32);
|
ImGui::DragFloat4("Eye", (float*)this->eye.m128_f32);
|
||||||
ImGui::DragFloat4("At", (float*)this->at.m128_f32);
|
ImGui::DragFloat4("At", (float*)this->at.m128_f32);
|
||||||
ImGui::DragFloat4("Up", (float*)this->up.m128_f32);
|
ImGui::DragFloat4("Up", (float*)this->up.m128_f32);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
ImGui::Begin("Change Tex");
|
||||||
|
if (ImGui::Button("Unknown Texture")) {
|
||||||
|
this->TextureProvider()->SetUnknownTexture();
|
||||||
|
this->updateCdTexture();
|
||||||
|
}
|
||||||
|
if(ImGui::Button("Blu-Ray")){
|
||||||
|
this->TextureProvider()->SetBdTexture();
|
||||||
|
this->updateCdTexture();
|
||||||
|
}
|
||||||
|
if (ImGui::Button("Dvd")) {
|
||||||
|
this->TextureProvider()->SetDvdTexture();
|
||||||
|
this->updateCdTexture();
|
||||||
|
}
|
||||||
|
if (ImGui::Button("Cd")) {
|
||||||
|
this->TextureProvider()->SetCdTexture();
|
||||||
|
this->updateCdTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CdTex* D3DSpin::TextureProvider() {
|
||||||
|
return this->cdTextureProvider;
|
||||||
|
}
|
||||||
|
|
||||||
D3DSpin::D3DSpin(D3D* d3d) {
|
D3DSpin::D3DSpin(D3D* d3d) {
|
||||||
this->eye = DirectX::XMVectorSet(0.0f, 2.0f, 3.0f, 0.0f);
|
this->eye = DirectX::XMVectorSet(0.0f, 2.0f, 3.0f, 0.0f);
|
||||||
this->at = DirectX::XMVectorSet(0.0f, 2.0f, 0.0f, 0.0f);
|
this->at = DirectX::XMVectorSet(0.0f, 2.0f, 0.0f, 0.0f);
|
||||||
|
@ -217,6 +252,8 @@ namespace Li::Gui::DvdSpin {
|
||||||
this->cdSampler = nullptr;
|
this->cdSampler = nullptr;
|
||||||
this->cdResourceView = nullptr;
|
this->cdResourceView = nullptr;
|
||||||
|
|
||||||
|
this->cdTextureProvider = new CdTex();
|
||||||
|
|
||||||
this->setupSpinningDVD();
|
this->setupSpinningDVD();
|
||||||
}
|
}
|
||||||
D3DSpin::~D3DSpin() {
|
D3DSpin::~D3DSpin() {
|
||||||
|
@ -232,5 +269,8 @@ namespace Li::Gui::DvdSpin {
|
||||||
this->cdSampler->Release();
|
this->cdSampler->Release();
|
||||||
this->cdResourceView->Release();
|
this->cdResourceView->Release();
|
||||||
|
|
||||||
|
delete this->cdTextureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,11 +3,14 @@
|
||||||
|
|
||||||
#include <DirectXMath.h>
|
#include <DirectXMath.h>
|
||||||
#include "RenderDvdSpin.hpp"
|
#include "RenderDvdSpin.hpp"
|
||||||
|
#include "CdTex.hpp"
|
||||||
#include "../D3D.hpp"
|
#include "../D3D.hpp"
|
||||||
|
|
||||||
namespace Li::Gui::DvdSpin {
|
namespace Li::Gui::DvdSpin {
|
||||||
class D3DSpin : public RenderDvdSpin {
|
class D3DSpin : public RenderDvdSpin {
|
||||||
private:
|
private:
|
||||||
|
CdTex* cdTextureProvider;
|
||||||
|
|
||||||
D3D* d3d;
|
D3D* d3d;
|
||||||
uint32_t counter;
|
uint32_t counter;
|
||||||
|
|
||||||
|
@ -38,7 +41,6 @@ namespace Li::Gui::DvdSpin {
|
||||||
// dvd spin model
|
// dvd spin model
|
||||||
void setupSpinningDVD();
|
void setupSpinningDVD();
|
||||||
|
|
||||||
HRESULT createViewport();
|
|
||||||
HRESULT createCdVertexShader();
|
HRESULT createCdVertexShader();
|
||||||
HRESULT createCdPixelShader();
|
HRESULT createCdPixelShader();
|
||||||
HRESULT createCdVertexLayout();
|
HRESULT createCdVertexLayout();
|
||||||
|
@ -51,6 +53,7 @@ namespace Li::Gui::DvdSpin {
|
||||||
void setCdIndexBuffer();
|
void setCdIndexBuffer();
|
||||||
void setCdVertexLayout();
|
void setCdVertexLayout();
|
||||||
|
|
||||||
|
void updateCdTexture();
|
||||||
void updateCamBuffer();
|
void updateCamBuffer();
|
||||||
|
|
||||||
// dvd spin texture
|
// dvd spin texture
|
||||||
|
@ -59,6 +62,7 @@ namespace Li::Gui::DvdSpin {
|
||||||
HRESULT createCdResourceView();
|
HRESULT createCdResourceView();
|
||||||
public:
|
public:
|
||||||
void RenderDVD();
|
void RenderDVD();
|
||||||
|
CdTex* TextureProvider();
|
||||||
D3DSpin(D3D* d3d);
|
D3DSpin(D3D* d3d);
|
||||||
~D3DSpin();
|
~D3DSpin();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#ifndef _LI_RENDER_DVD_SPIN
|
#ifndef _LI_RENDER_DVD_SPIN
|
||||||
#define _LI_RENDER_DVD_SPIN 1
|
#define _LI_RENDER_DVD_SPIN 1
|
||||||
|
#include "CdTex.hpp"
|
||||||
#include "../Renderer.hpp"
|
#include "../Renderer.hpp"
|
||||||
|
|
||||||
namespace Li::Gui::DvdSpin {
|
namespace Li::Gui::DvdSpin {
|
||||||
class RenderDvdSpin {
|
class RenderDvdSpin {
|
||||||
public:
|
public:
|
||||||
virtual void RenderDVD() {};
|
virtual void RenderDVD() {};
|
||||||
|
virtual CdTex* TextureProvider() { return nullptr; };
|
||||||
static RenderDvdSpin* CreateDvdSpinner(Renderer* renderer);
|
static RenderDvdSpin* CreateDvdSpinner(Renderer* renderer);
|
||||||
static void DeleteDvdSpinner(RenderDvdSpin* spinner);
|
static void DeleteDvdSpinner(RenderDvdSpin* spinner);
|
||||||
};
|
};
|
||||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
7698
DumpDVD/Gui/DvdSpin/ceedee.pdn
Normal file
7698
DumpDVD/Gui/DvdSpin/ceedee.pdn
Normal file
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 2.5 MiB |
Binary file not shown.
BIN
DumpDVD/Gui/DvdSpin/ceedeeBluRay.png
Normal file
BIN
DumpDVD/Gui/DvdSpin/ceedeeBluRay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 MiB |
BIN
DumpDVD/Gui/DvdSpin/ceedeeCd.png
Normal file
BIN
DumpDVD/Gui/DvdSpin/ceedeeCd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 MiB |
BIN
DumpDVD/Gui/DvdSpin/ceedeeDvd.png
Normal file
BIN
DumpDVD/Gui/DvdSpin/ceedeeDvd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 MiB |
19
DumpDVD/Gui/DvdSpin/ceedee_tex.h
Normal file
19
DumpDVD/Gui/DvdSpin/ceedee_tex.h
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,38 +1,15 @@
|
||||||
import struct
|
import struct
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import lzma
|
||||||
|
|
||||||
imgName = "ceedee"
|
imgName = "ceedee"
|
||||||
hdr = "#ifndef _LI_"+imgName.upper()+"_H\n"
|
hdr = "#ifndef _LI_"+imgName.upper()+"_H\n"
|
||||||
hdr += "#define _LI_"+imgName.upper()+"_H 1\n"
|
hdr += "#define _LI_"+imgName.upper()+"_H 1\n"
|
||||||
hdr += "#include \"vec.hpp\"\n"
|
hdr += "#include \"vec.hpp\"\n"
|
||||||
hdr += "#include <stdint.h>\n"
|
hdr += "#include <cstdint>\n"
|
||||||
|
|
||||||
def readTexture(imgName):
|
|
||||||
global hdr
|
|
||||||
with Image.open(imgName+".png") as img:
|
|
||||||
img = img.convert("RGBA")
|
|
||||||
imgWidth, imgHeight = img.size
|
|
||||||
|
|
||||||
hdr += "const uint32_t "+imgName+"ImgWidth = "+hex(imgWidth)+";\n"
|
|
||||||
hdr += "const uint32_t "+imgName+"ImgHeight = "+hex(imgHeight)+";\n"
|
|
||||||
hdr += "const uint32_t "+imgName+"ImgChannels = "+hex(4)+";\n"
|
|
||||||
|
|
||||||
rgbaValues = []
|
|
||||||
for y in range(0, imgHeight):
|
|
||||||
for x in range(0, imgWidth):
|
|
||||||
r, g, b, a = img.getpixel((x, y))
|
|
||||||
|
|
||||||
rgba = 0;
|
|
||||||
rgba |= a << 24
|
|
||||||
rgba |= b << 16
|
|
||||||
rgba |= g << 8
|
|
||||||
rgba |= r
|
|
||||||
|
|
||||||
rgbaValues.append(hex(rgba))
|
|
||||||
|
|
||||||
hdr += "const uint32_t "+imgName+"ImgDataSz = "+hex(len(rgbaValues))+";\n"
|
|
||||||
|
|
||||||
hdr += "static uint32_t "+imgName+"ImgData["+hex(len(rgbaValues))+"] {"+", ".join(rgbaValues)+"};\n"
|
|
||||||
|
|
||||||
def read3D(vboName):
|
def read3D(vboName):
|
||||||
global hdr
|
global hdr
|
||||||
with open(vboName + ".vbo", "rb") as vbo:
|
with open(vboName + ".vbo", "rb") as vbo:
|
||||||
|
@ -53,11 +30,9 @@ def read3D(vboName):
|
||||||
index = struct.unpack("H", vbo.read(2))
|
index = struct.unpack("H", vbo.read(2))
|
||||||
indicies.append(hex(index[0]))
|
indicies.append(hex(index[0]))
|
||||||
|
|
||||||
hdr += "static ModelVertex "+imgName+"ModelVertexBuffer["+hex(len(verticies))+"] { "+", ".join(verticies)+"};\n"
|
hdr += "static ModelVertex "+imgName+"ModelVertexBuffer["+imgName+"ModelTotalVertices] { "+", ".join(verticies)+"};\n"
|
||||||
hdr += "static uint16_t "+imgName+"ModelIndexBuffer["+hex(len(indicies))+"] { "+", ".join(indicies)+" };\n"
|
hdr += "static uint16_t "+imgName+"ModelIndexBuffer["+imgName+"ModelTotalIndices] { "+", ".join(indicies)+" };\n"
|
||||||
|
|
||||||
readTexture(imgName)
|
|
||||||
read3D(imgName)
|
read3D(imgName)
|
||||||
hdr += "#endif"
|
hdr += "#endif"
|
||||||
|
|
||||||
print(hdr)
|
print(hdr)
|
81
DumpDVD/Gui/DvdSpin/compile_cd_tex_to_h.py
Normal file
81
DumpDVD/Gui/DvdSpin/compile_cd_tex_to_h.py
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
import struct
|
||||||
|
from PIL import Image
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import lzma
|
||||||
|
|
||||||
|
imgName = "ceedee"
|
||||||
|
hdr = "#ifndef _LI_"+imgName.upper()+"_TEX_H\n"
|
||||||
|
hdr += "#define _LI_"+imgName.upper()+"_TEX_H 1\n"
|
||||||
|
hdr += "#include <cstdint>\n"
|
||||||
|
hdr += "#include \"diff.hpp\"\n"
|
||||||
|
|
||||||
|
def readImg(imgName):
|
||||||
|
with Image.open(imgName+".png") as img:
|
||||||
|
img = img.convert("RGBA")
|
||||||
|
imgWidth, imgHeight = img.size
|
||||||
|
with io.BytesIO(b"") as bio:
|
||||||
|
for y in range(0, imgHeight):
|
||||||
|
for x in range(0, imgWidth):
|
||||||
|
r, g, b, a = img.getpixel((x, y))
|
||||||
|
|
||||||
|
rgba = 0;
|
||||||
|
rgba |= a << 24
|
||||||
|
rgba |= b << 16
|
||||||
|
rgba |= g << 8
|
||||||
|
rgba |= r
|
||||||
|
|
||||||
|
bio.write(struct.pack("I", rgba))
|
||||||
|
bio.seek(0, os.SEEK_SET)
|
||||||
|
return (imgName, imgWidth, imgHeight, 0x4, bio.read())
|
||||||
|
|
||||||
|
def diffTexture(firstImg, otherImg):
|
||||||
|
global hdr
|
||||||
|
|
||||||
|
imgName, imgWidth, imgHeight, imgChannels, imgData = firstImg
|
||||||
|
otherImgName, otherImgWidth, otherImgHeight, otherImgChannels, otherImgData = otherImg
|
||||||
|
|
||||||
|
lst = []
|
||||||
|
for i in range(0, len(otherImgData), imgChannels):
|
||||||
|
c1 = struct.unpack("I", otherImgData[i:i+otherImgChannels])[0]
|
||||||
|
c2 = struct.unpack("I", imgData[i:i+imgChannels])[0]
|
||||||
|
if c1 == c2:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
lst.append("ImgDiff({ "+hex(int(i/4))+", "+hex(c1)+" })")
|
||||||
|
hdr += "const uint32_t "+otherImgName+"DiffSz = "+hex(len(lst))+";\n"
|
||||||
|
hdr += "static ImgDiff "+otherImgName+"Diff["+otherImgName+"DiffSz] { " + ", ".join(lst) +"};\n"
|
||||||
|
|
||||||
|
def readTexture(img):
|
||||||
|
global hdr
|
||||||
|
imgName, imgWidth, imgHeight, imgChannels, imgData = img
|
||||||
|
|
||||||
|
hdr += "const uint32_t "+imgName+"ImgWidth = "+hex(imgWidth)+";\n"
|
||||||
|
hdr += "const uint32_t "+imgName+"ImgHeight = "+hex(imgHeight)+";\n"
|
||||||
|
hdr += "const uint32_t "+imgName+"ImgChannels = "+hex(imgChannels)+";\n"
|
||||||
|
|
||||||
|
compressedRgbaValues = []
|
||||||
|
compressedData = bytearray(lzma.compress(imgData, format=lzma.FORMAT_RAW, filters=[{'id': lzma.FILTER_LZMA2, 'preset': 9 | lzma.PRESET_EXTREME}]))
|
||||||
|
|
||||||
|
for i in range(0, len(compressedData)):
|
||||||
|
compressedRgbaValues.append(hex(compressedData[i]))
|
||||||
|
|
||||||
|
hdr += "const uint32_t "+imgName+"ImgCompressedDataSz = "+hex(len(compressedRgbaValues))+";\n"
|
||||||
|
hdr += "const uint32_t "+imgName+"ImgUncompressedSz = (("+imgName+"ImgWidth * "+imgName+"ImgHeight) * "+imgName+"ImgChannels);\n"
|
||||||
|
hdr += "static uint8_t "+imgName+"ImgCompressedData["+imgName+"ImgCompressedDataSz] { "+", ".join(compressedRgbaValues)+" };\n"
|
||||||
|
|
||||||
|
hdr += "/* Texture */\n"
|
||||||
|
|
||||||
|
img = readImg(imgName)
|
||||||
|
imgCd = readImg(imgName+"Cd")
|
||||||
|
imgDvd = readImg(imgName+"Dvd")
|
||||||
|
imgBd = readImg(imgName+"BluRay")
|
||||||
|
|
||||||
|
readTexture(img)
|
||||||
|
|
||||||
|
hdr += "/* Diff */\n"
|
||||||
|
diffTexture(img, imgCd)
|
||||||
|
diffTexture(img, imgDvd)
|
||||||
|
diffTexture(img, imgBd)
|
||||||
|
hdr += "#endif"
|
||||||
|
print(hdr)
|
9
DumpDVD/Gui/DvdSpin/diff.hpp
Normal file
9
DumpDVD/Gui/DvdSpin/diff.hpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef _LI_DIFF_H
|
||||||
|
#define _LI_DIFF_H 1
|
||||||
|
|
||||||
|
typedef struct ImgDiff{
|
||||||
|
uint32_t Location;
|
||||||
|
uint32_t NewColor;
|
||||||
|
} ImgDiff;
|
||||||
|
|
||||||
|
#endif
|
375
LZMA/7zTypes.h
Normal file
375
LZMA/7zTypes.h
Normal file
|
@ -0,0 +1,375 @@
|
||||||
|
/* 7zTypes.h -- Basic types
|
||||||
|
2018-08-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_TYPES_H
|
||||||
|
#define __7Z_TYPES_H
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* #include <windows.h> */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifndef EXTERN_C_BEGIN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN_C_BEGIN extern "C" {
|
||||||
|
#define EXTERN_C_END }
|
||||||
|
#else
|
||||||
|
#define EXTERN_C_BEGIN
|
||||||
|
#define EXTERN_C_END
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
#define SZ_OK 0
|
||||||
|
|
||||||
|
#define SZ_ERROR_DATA 1
|
||||||
|
#define SZ_ERROR_MEM 2
|
||||||
|
#define SZ_ERROR_CRC 3
|
||||||
|
#define SZ_ERROR_UNSUPPORTED 4
|
||||||
|
#define SZ_ERROR_PARAM 5
|
||||||
|
#define SZ_ERROR_INPUT_EOF 6
|
||||||
|
#define SZ_ERROR_OUTPUT_EOF 7
|
||||||
|
#define SZ_ERROR_READ 8
|
||||||
|
#define SZ_ERROR_WRITE 9
|
||||||
|
#define SZ_ERROR_PROGRESS 10
|
||||||
|
#define SZ_ERROR_FAIL 11
|
||||||
|
#define SZ_ERROR_THREAD 12
|
||||||
|
|
||||||
|
#define SZ_ERROR_ARCHIVE 16
|
||||||
|
#define SZ_ERROR_NO_ARCHIVE 17
|
||||||
|
|
||||||
|
typedef int SRes;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
/* typedef DWORD WRes; */
|
||||||
|
typedef unsigned WRes;
|
||||||
|
#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef int WRes;
|
||||||
|
#define MY__FACILITY_WIN32 7
|
||||||
|
#define MY__FACILITY__WRes MY__FACILITY_WIN32
|
||||||
|
#define MY_SRes_HRESULT_FROM_WRes(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (MY__FACILITY__WRes << 16) | 0x80000000)))
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef RINOK
|
||||||
|
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned char Byte;
|
||||||
|
typedef short Int16;
|
||||||
|
typedef unsigned short UInt16;
|
||||||
|
|
||||||
|
#ifdef _LZMA_UINT32_IS_ULONG
|
||||||
|
typedef long Int32;
|
||||||
|
typedef unsigned long UInt32;
|
||||||
|
#else
|
||||||
|
typedef int Int32;
|
||||||
|
typedef unsigned int UInt32;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _SZ_NO_INT_64
|
||||||
|
|
||||||
|
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
|
||||||
|
NOTES: Some code will work incorrectly in that case! */
|
||||||
|
|
||||||
|
typedef long Int64;
|
||||||
|
typedef unsigned long UInt64;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
|
typedef __int64 Int64;
|
||||||
|
typedef unsigned __int64 UInt64;
|
||||||
|
#define UINT64_CONST(n) n
|
||||||
|
#else
|
||||||
|
typedef long long int Int64;
|
||||||
|
typedef unsigned long long int UInt64;
|
||||||
|
#define UINT64_CONST(n) n ## ULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LZMA_NO_SYSTEM_SIZE_T
|
||||||
|
typedef UInt32 SizeT;
|
||||||
|
#else
|
||||||
|
typedef size_t SizeT;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int BoolInt;
|
||||||
|
/* typedef BoolInt Bool; */
|
||||||
|
#define True 1
|
||||||
|
#define False 0
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define MY_STD_CALL __stdcall
|
||||||
|
#else
|
||||||
|
#define MY_STD_CALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1300
|
||||||
|
#define MY_NO_INLINE __declspec(noinline)
|
||||||
|
#else
|
||||||
|
#define MY_NO_INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MY_FORCE_INLINE __forceinline
|
||||||
|
|
||||||
|
#define MY_CDECL __cdecl
|
||||||
|
#define MY_FAST_CALL __fastcall
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define MY_NO_INLINE
|
||||||
|
#define MY_FORCE_INLINE
|
||||||
|
#define MY_CDECL
|
||||||
|
#define MY_FAST_CALL
|
||||||
|
|
||||||
|
/* inline keyword : for C++ / C99 */
|
||||||
|
|
||||||
|
/* GCC, clang: */
|
||||||
|
/*
|
||||||
|
#if defined (__GNUC__) && (__GNUC__ >= 4)
|
||||||
|
#define MY_FORCE_INLINE __attribute__((always_inline))
|
||||||
|
#define MY_NO_INLINE __attribute__((noinline))
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* The following interfaces use first parameter as pointer to structure */
|
||||||
|
|
||||||
|
typedef struct IByteIn IByteIn;
|
||||||
|
struct IByteIn
|
||||||
|
{
|
||||||
|
Byte (*Read)(const IByteIn *p); /* reads one byte, returns 0 in case of EOF or error */
|
||||||
|
};
|
||||||
|
#define IByteIn_Read(p) (p)->Read(p)
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct IByteOut IByteOut;
|
||||||
|
struct IByteOut
|
||||||
|
{
|
||||||
|
void (*Write)(const IByteOut *p, Byte b);
|
||||||
|
};
|
||||||
|
#define IByteOut_Write(p, b) (p)->Write(p, b)
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct ISeqInStream ISeqInStream;
|
||||||
|
struct ISeqInStream
|
||||||
|
{
|
||||||
|
SRes (*Read)(const ISeqInStream *p, void *buf, size_t *size);
|
||||||
|
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
||||||
|
(output(*size) < input(*size)) is allowed */
|
||||||
|
};
|
||||||
|
#define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size)
|
||||||
|
|
||||||
|
/* it can return SZ_ERROR_INPUT_EOF */
|
||||||
|
SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size);
|
||||||
|
SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType);
|
||||||
|
SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf);
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct ISeqOutStream ISeqOutStream;
|
||||||
|
struct ISeqOutStream
|
||||||
|
{
|
||||||
|
size_t (*Write)(const ISeqOutStream *p, const void *buf, size_t size);
|
||||||
|
/* Returns: result - the number of actually written bytes.
|
||||||
|
(result < size) means error */
|
||||||
|
};
|
||||||
|
#define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size)
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SZ_SEEK_SET = 0,
|
||||||
|
SZ_SEEK_CUR = 1,
|
||||||
|
SZ_SEEK_END = 2
|
||||||
|
} ESzSeek;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct ISeekInStream ISeekInStream;
|
||||||
|
struct ISeekInStream
|
||||||
|
{
|
||||||
|
SRes (*Read)(const ISeekInStream *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
|
||||||
|
SRes (*Seek)(const ISeekInStream *p, Int64 *pos, ESzSeek origin);
|
||||||
|
};
|
||||||
|
#define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size)
|
||||||
|
#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct ILookInStream ILookInStream;
|
||||||
|
struct ILookInStream
|
||||||
|
{
|
||||||
|
SRes (*Look)(const ILookInStream *p, const void **buf, size_t *size);
|
||||||
|
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
||||||
|
(output(*size) > input(*size)) is not allowed
|
||||||
|
(output(*size) < input(*size)) is allowed */
|
||||||
|
SRes (*Skip)(const ILookInStream *p, size_t offset);
|
||||||
|
/* offset must be <= output(*size) of Look */
|
||||||
|
|
||||||
|
SRes (*Read)(const ILookInStream *p, void *buf, size_t *size);
|
||||||
|
/* reads directly (without buffer). It's same as ISeqInStream::Read */
|
||||||
|
SRes (*Seek)(const ILookInStream *p, Int64 *pos, ESzSeek origin);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size)
|
||||||
|
#define ILookInStream_Skip(p, offset) (p)->Skip(p, offset)
|
||||||
|
#define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size)
|
||||||
|
#define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
|
||||||
|
|
||||||
|
|
||||||
|
SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size);
|
||||||
|
SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset);
|
||||||
|
|
||||||
|
/* reads via ILookInStream::Read */
|
||||||
|
SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType);
|
||||||
|
SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ILookInStream vt;
|
||||||
|
const ISeekInStream *realStream;
|
||||||
|
|
||||||
|
size_t pos;
|
||||||
|
size_t size; /* it's data size */
|
||||||
|
|
||||||
|
/* the following variables must be set outside */
|
||||||
|
Byte *buf;
|
||||||
|
size_t bufSize;
|
||||||
|
} CLookToRead2;
|
||||||
|
|
||||||
|
void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead);
|
||||||
|
|
||||||
|
#define LookToRead2_Init(p) { (p)->pos = (p)->size = 0; }
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ISeqInStream vt;
|
||||||
|
const ILookInStream *realStream;
|
||||||
|
} CSecToLook;
|
||||||
|
|
||||||
|
void SecToLook_CreateVTable(CSecToLook *p);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ISeqInStream vt;
|
||||||
|
const ILookInStream *realStream;
|
||||||
|
} CSecToRead;
|
||||||
|
|
||||||
|
void SecToRead_CreateVTable(CSecToRead *p);
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct ICompressProgress ICompressProgress;
|
||||||
|
|
||||||
|
struct ICompressProgress
|
||||||
|
{
|
||||||
|
SRes (*Progress)(const ICompressProgress *p, UInt64 inSize, UInt64 outSize);
|
||||||
|
/* Returns: result. (result != SZ_OK) means break.
|
||||||
|
Value (UInt64)(Int64)-1 for size means unknown value. */
|
||||||
|
};
|
||||||
|
#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct ISzAlloc ISzAlloc;
|
||||||
|
typedef const ISzAlloc * ISzAllocPtr;
|
||||||
|
|
||||||
|
struct ISzAlloc
|
||||||
|
{
|
||||||
|
void *(*Alloc)(ISzAllocPtr p, size_t size);
|
||||||
|
void (*Free)(ISzAllocPtr p, void *address); /* address can be 0 */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size)
|
||||||
|
#define ISzAlloc_Free(p, a) (p)->Free(p, a)
|
||||||
|
|
||||||
|
/* deprecated */
|
||||||
|
#define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size)
|
||||||
|
#define IAlloc_Free(p, a) ISzAlloc_Free(p, a)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MY_offsetof
|
||||||
|
#ifdef offsetof
|
||||||
|
#define MY_offsetof(type, m) offsetof(type, m)
|
||||||
|
/*
|
||||||
|
#define MY_offsetof(type, m) FIELD_OFFSET(type, m)
|
||||||
|
*/
|
||||||
|
#else
|
||||||
|
#define MY_offsetof(type, m) ((size_t)&(((type *)0)->m))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MY_container_of
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define MY_container_of(ptr, type, m) container_of(ptr, type, m)
|
||||||
|
#define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m)
|
||||||
|
#define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m)))
|
||||||
|
#define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m))))
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly"
|
||||||
|
GCC 3.4.4 : classes with constructor
|
||||||
|
GCC 4.8.1 : classes with non-public variable members"
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MY_container_of(ptr, type, m) ((type *)((char *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m)))
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(ptr))
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
|
||||||
|
*/
|
||||||
|
#define CONTAINER_FROM_VTBL(ptr, type, m) MY_container_of(ptr, type, m)
|
||||||
|
|
||||||
|
#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
|
||||||
|
/*
|
||||||
|
#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#define CHAR_PATH_SEPARATOR '\\'
|
||||||
|
#define WCHAR_PATH_SEPARATOR L'\\'
|
||||||
|
#define STRING_PATH_SEPARATOR "\\"
|
||||||
|
#define WSTRING_PATH_SEPARATOR L"\\"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define CHAR_PATH_SEPARATOR '/'
|
||||||
|
#define WCHAR_PATH_SEPARATOR L'/'
|
||||||
|
#define STRING_PATH_SEPARATOR "/"
|
||||||
|
#define WSTRING_PATH_SEPARATOR L"/"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
455
LZMA/Alloc.c
Normal file
455
LZMA/Alloc.c
Normal file
|
@ -0,0 +1,455 @@
|
||||||
|
/* Alloc.c -- Memory allocation functions
|
||||||
|
2018-04-27 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
|
|
||||||
|
/* #define _SZ_ALLOC_DEBUG */
|
||||||
|
|
||||||
|
/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
|
||||||
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
int g_allocCount = 0;
|
||||||
|
int g_allocCountMid = 0;
|
||||||
|
int g_allocCountBig = 0;
|
||||||
|
|
||||||
|
|
||||||
|
#define CONVERT_INT_TO_STR(charType, tempSize) \
|
||||||
|
unsigned char temp[tempSize]; unsigned i = 0; \
|
||||||
|
while (val >= 10) { temp[i++] = (unsigned char)('0' + (unsigned)(val % 10)); val /= 10; } \
|
||||||
|
*s++ = (charType)('0' + (unsigned)val); \
|
||||||
|
while (i != 0) { i--; *s++ = temp[i]; } \
|
||||||
|
*s = 0;
|
||||||
|
|
||||||
|
static void ConvertUInt64ToString(UInt64 val, char *s)
|
||||||
|
{
|
||||||
|
CONVERT_INT_TO_STR(char, 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10)))))
|
||||||
|
|
||||||
|
static void ConvertUInt64ToHex(UInt64 val, char *s)
|
||||||
|
{
|
||||||
|
UInt64 v = val;
|
||||||
|
unsigned i;
|
||||||
|
for (i = 1;; i++)
|
||||||
|
{
|
||||||
|
v >>= 4;
|
||||||
|
if (v == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s[i] = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned t = (unsigned)(val & 0xF);
|
||||||
|
val >>= 4;
|
||||||
|
s[--i] = GET_HEX_CHAR(t);
|
||||||
|
}
|
||||||
|
while (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEBUG_OUT_STREAM stderr
|
||||||
|
|
||||||
|
static void Print(const char *s)
|
||||||
|
{
|
||||||
|
fputs(s, DEBUG_OUT_STREAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintAligned(const char *s, size_t align)
|
||||||
|
{
|
||||||
|
size_t len = strlen(s);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
fputc(' ', DEBUG_OUT_STREAM);
|
||||||
|
if (len >= align)
|
||||||
|
break;
|
||||||
|
++len;
|
||||||
|
}
|
||||||
|
Print(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintLn()
|
||||||
|
{
|
||||||
|
Print("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintHex(UInt64 v, size_t align)
|
||||||
|
{
|
||||||
|
char s[32];
|
||||||
|
ConvertUInt64ToHex(v, s);
|
||||||
|
PrintAligned(s, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintDec(UInt64 v, size_t align)
|
||||||
|
{
|
||||||
|
char s[32];
|
||||||
|
ConvertUInt64ToString(v, s);
|
||||||
|
PrintAligned(s, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintAddr(void *p)
|
||||||
|
{
|
||||||
|
PrintHex((UInt64)(size_t)(ptrdiff_t)p, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define PRINT_ALLOC(name, cnt, size, ptr) \
|
||||||
|
Print(name " "); \
|
||||||
|
PrintDec(cnt++, 10); \
|
||||||
|
PrintHex(size, 10); \
|
||||||
|
PrintAddr(ptr); \
|
||||||
|
PrintLn();
|
||||||
|
|
||||||
|
#define PRINT_FREE(name, cnt, ptr) if (ptr) { \
|
||||||
|
Print(name " "); \
|
||||||
|
PrintDec(--cnt, 10); \
|
||||||
|
PrintAddr(ptr); \
|
||||||
|
PrintLn(); }
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define PRINT_ALLOC(name, cnt, size, ptr)
|
||||||
|
#define PRINT_FREE(name, cnt, ptr)
|
||||||
|
#define Print(s)
|
||||||
|
#define PrintLn()
|
||||||
|
#define PrintHex(v, align)
|
||||||
|
#define PrintDec(v, align)
|
||||||
|
#define PrintAddr(p)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void *MyAlloc(size_t size)
|
||||||
|
{
|
||||||
|
if (size == 0)
|
||||||
|
return NULL;
|
||||||
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
{
|
||||||
|
void *p = malloc(size);
|
||||||
|
PRINT_ALLOC("Alloc ", g_allocCount, size, p);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return malloc(size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFree(void *address)
|
||||||
|
{
|
||||||
|
PRINT_FREE("Free ", g_allocCount, address);
|
||||||
|
|
||||||
|
free(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
void *MidAlloc(size_t size)
|
||||||
|
{
|
||||||
|
if (size == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
PRINT_ALLOC("Alloc-Mid", g_allocCountMid, size, NULL);
|
||||||
|
|
||||||
|
return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MidFree(void *address)
|
||||||
|
{
|
||||||
|
PRINT_FREE("Free-Mid", g_allocCountMid, address);
|
||||||
|
|
||||||
|
if (!address)
|
||||||
|
return;
|
||||||
|
VirtualFree(address, 0, MEM_RELEASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef MEM_LARGE_PAGES
|
||||||
|
#undef _7ZIP_LARGE_PAGES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _7ZIP_LARGE_PAGES
|
||||||
|
SIZE_T g_LargePageSize = 0;
|
||||||
|
typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void SetLargePageSize()
|
||||||
|
{
|
||||||
|
#ifdef _7ZIP_LARGE_PAGES
|
||||||
|
SIZE_T size;
|
||||||
|
GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
|
||||||
|
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
|
||||||
|
if (!largePageMinimum)
|
||||||
|
return;
|
||||||
|
size = largePageMinimum();
|
||||||
|
if (size == 0 || (size & (size - 1)) != 0)
|
||||||
|
return;
|
||||||
|
g_LargePageSize = size;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *BigAlloc(size_t size)
|
||||||
|
{
|
||||||
|
if (size == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
PRINT_ALLOC("Alloc-Big", g_allocCountBig, size, NULL);
|
||||||
|
|
||||||
|
#ifdef _7ZIP_LARGE_PAGES
|
||||||
|
{
|
||||||
|
SIZE_T ps = g_LargePageSize;
|
||||||
|
if (ps != 0 && ps <= (1 << 30) && size > (ps / 2))
|
||||||
|
{
|
||||||
|
size_t size2;
|
||||||
|
ps--;
|
||||||
|
size2 = (size + ps) & ~ps;
|
||||||
|
if (size2 >= size)
|
||||||
|
{
|
||||||
|
void *res = VirtualAlloc(NULL, size2, MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
|
||||||
|
if (res)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BigFree(void *address)
|
||||||
|
{
|
||||||
|
PRINT_FREE("Free-Big", g_allocCountBig, address);
|
||||||
|
|
||||||
|
if (!address)
|
||||||
|
return;
|
||||||
|
VirtualFree(address, 0, MEM_RELEASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void *SzAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
|
||||||
|
static void SzFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); MyFree(address); }
|
||||||
|
const ISzAlloc g_Alloc = { SzAlloc, SzFree };
|
||||||
|
|
||||||
|
static void *SzMidAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MidAlloc(size); }
|
||||||
|
static void SzMidFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); MidFree(address); }
|
||||||
|
const ISzAlloc g_MidAlloc = { SzMidAlloc, SzMidFree };
|
||||||
|
|
||||||
|
static void *SzBigAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return BigAlloc(size); }
|
||||||
|
static void SzBigFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); BigFree(address); }
|
||||||
|
const ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree };
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
uintptr_t : <stdint.h> C99 (optional)
|
||||||
|
: unsupported in VS6
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
typedef UINT_PTR UIntPtr;
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
typedef uintptr_t UIntPtr;
|
||||||
|
*/
|
||||||
|
typedef ptrdiff_t UIntPtr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ADJUST_ALLOC_SIZE 0
|
||||||
|
/*
|
||||||
|
#define ADJUST_ALLOC_SIZE (sizeof(void *) - 1)
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
Use (ADJUST_ALLOC_SIZE = (sizeof(void *) - 1)), if
|
||||||
|
MyAlloc() can return address that is NOT multiple of sizeof(void *).
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((char *)(p) - ((size_t)(UIntPtr)(p) & ((align) - 1))))
|
||||||
|
*/
|
||||||
|
#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((((UIntPtr)(p)) & ~((UIntPtr)(align) - 1))))
|
||||||
|
|
||||||
|
#define MY_ALIGN_PTR_UP_PLUS(p, align) MY_ALIGN_PTR_DOWN(((char *)(p) + (align) + ADJUST_ALLOC_SIZE), align)
|
||||||
|
|
||||||
|
|
||||||
|
#if (_POSIX_C_SOURCE >= 200112L) && !defined(_WIN32)
|
||||||
|
#define USE_posix_memalign
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
This posix_memalign() is for test purposes only.
|
||||||
|
We also need special Free() function instead of free(),
|
||||||
|
if this posix_memalign() is used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
static int posix_memalign(void **ptr, size_t align, size_t size)
|
||||||
|
{
|
||||||
|
size_t newSize = size + align;
|
||||||
|
void *p;
|
||||||
|
void *pAligned;
|
||||||
|
*ptr = NULL;
|
||||||
|
if (newSize < size)
|
||||||
|
return 12; // ENOMEM
|
||||||
|
p = MyAlloc(newSize);
|
||||||
|
if (!p)
|
||||||
|
return 12; // ENOMEM
|
||||||
|
pAligned = MY_ALIGN_PTR_UP_PLUS(p, align);
|
||||||
|
((void **)pAligned)[-1] = p;
|
||||||
|
*ptr = pAligned;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
ALLOC_ALIGN_SIZE >= sizeof(void *)
|
||||||
|
ALLOC_ALIGN_SIZE >= cache_line_size
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ALLOC_ALIGN_SIZE ((size_t)1 << 7)
|
||||||
|
|
||||||
|
static void *SzAlignedAlloc(ISzAllocPtr pp, size_t size)
|
||||||
|
{
|
||||||
|
#ifndef USE_posix_memalign
|
||||||
|
|
||||||
|
void *p;
|
||||||
|
void *pAligned;
|
||||||
|
size_t newSize;
|
||||||
|
UNUSED_VAR(pp);
|
||||||
|
|
||||||
|
/* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned
|
||||||
|
block to prevent cache line sharing with another allocated blocks */
|
||||||
|
|
||||||
|
newSize = size + ALLOC_ALIGN_SIZE * 1 + ADJUST_ALLOC_SIZE;
|
||||||
|
if (newSize < size)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
p = MyAlloc(newSize);
|
||||||
|
|
||||||
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
pAligned = MY_ALIGN_PTR_UP_PLUS(p, ALLOC_ALIGN_SIZE);
|
||||||
|
|
||||||
|
Print(" size="); PrintHex(size, 8);
|
||||||
|
Print(" a_size="); PrintHex(newSize, 8);
|
||||||
|
Print(" ptr="); PrintAddr(p);
|
||||||
|
Print(" a_ptr="); PrintAddr(pAligned);
|
||||||
|
PrintLn();
|
||||||
|
|
||||||
|
((void **)pAligned)[-1] = p;
|
||||||
|
|
||||||
|
return pAligned;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void *p;
|
||||||
|
UNUSED_VAR(pp);
|
||||||
|
if (posix_memalign(&p, ALLOC_ALIGN_SIZE, size))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Print(" posix_memalign="); PrintAddr(p);
|
||||||
|
PrintLn();
|
||||||
|
|
||||||
|
return p;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void SzAlignedFree(ISzAllocPtr pp, void *address)
|
||||||
|
{
|
||||||
|
UNUSED_VAR(pp);
|
||||||
|
#ifndef USE_posix_memalign
|
||||||
|
if (address)
|
||||||
|
MyFree(((void **)address)[-1]);
|
||||||
|
#else
|
||||||
|
free(address);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const ISzAlloc g_AlignedAlloc = { SzAlignedAlloc, SzAlignedFree };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define MY_ALIGN_PTR_DOWN_1(p) MY_ALIGN_PTR_DOWN(p, sizeof(void *))
|
||||||
|
|
||||||
|
/* we align ptr to support cases where CAlignOffsetAlloc::offset is not multiply of sizeof(void *) */
|
||||||
|
#define REAL_BLOCK_PTR_VAR(p) ((void **)MY_ALIGN_PTR_DOWN_1(p))[-1]
|
||||||
|
/*
|
||||||
|
#define REAL_BLOCK_PTR_VAR(p) ((void **)(p))[-1]
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void *AlignOffsetAlloc_Alloc(ISzAllocPtr pp, size_t size)
|
||||||
|
{
|
||||||
|
CAlignOffsetAlloc *p = CONTAINER_FROM_VTBL(pp, CAlignOffsetAlloc, vt);
|
||||||
|
void *adr;
|
||||||
|
void *pAligned;
|
||||||
|
size_t newSize;
|
||||||
|
size_t extra;
|
||||||
|
size_t alignSize = (size_t)1 << p->numAlignBits;
|
||||||
|
|
||||||
|
if (alignSize < sizeof(void *))
|
||||||
|
alignSize = sizeof(void *);
|
||||||
|
|
||||||
|
if (p->offset >= alignSize)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned
|
||||||
|
block to prevent cache line sharing with another allocated blocks */
|
||||||
|
extra = p->offset & (sizeof(void *) - 1);
|
||||||
|
newSize = size + alignSize + extra + ADJUST_ALLOC_SIZE;
|
||||||
|
if (newSize < size)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
adr = ISzAlloc_Alloc(p->baseAlloc, newSize);
|
||||||
|
|
||||||
|
if (!adr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
pAligned = (char *)MY_ALIGN_PTR_DOWN((char *)adr +
|
||||||
|
alignSize - p->offset + extra + ADJUST_ALLOC_SIZE, alignSize) + p->offset;
|
||||||
|
|
||||||
|
PrintLn();
|
||||||
|
Print("- Aligned: ");
|
||||||
|
Print(" size="); PrintHex(size, 8);
|
||||||
|
Print(" a_size="); PrintHex(newSize, 8);
|
||||||
|
Print(" ptr="); PrintAddr(adr);
|
||||||
|
Print(" a_ptr="); PrintAddr(pAligned);
|
||||||
|
PrintLn();
|
||||||
|
|
||||||
|
REAL_BLOCK_PTR_VAR(pAligned) = adr;
|
||||||
|
|
||||||
|
return pAligned;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void AlignOffsetAlloc_Free(ISzAllocPtr pp, void *address)
|
||||||
|
{
|
||||||
|
if (address)
|
||||||
|
{
|
||||||
|
CAlignOffsetAlloc *p = CONTAINER_FROM_VTBL(pp, CAlignOffsetAlloc, vt);
|
||||||
|
PrintLn();
|
||||||
|
Print("- Aligned Free: ");
|
||||||
|
PrintLn();
|
||||||
|
ISzAlloc_Free(p->baseAlloc, REAL_BLOCK_PTR_VAR(address));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p)
|
||||||
|
{
|
||||||
|
p->vt.Alloc = AlignOffsetAlloc_Alloc;
|
||||||
|
p->vt.Free = AlignOffsetAlloc_Free;
|
||||||
|
}
|
51
LZMA/Alloc.h
Normal file
51
LZMA/Alloc.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* Alloc.h -- Memory allocation functions
|
||||||
|
2018-02-19 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __COMMON_ALLOC_H
|
||||||
|
#define __COMMON_ALLOC_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
void *MyAlloc(size_t size);
|
||||||
|
void MyFree(void *address);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
void SetLargePageSize();
|
||||||
|
|
||||||
|
void *MidAlloc(size_t size);
|
||||||
|
void MidFree(void *address);
|
||||||
|
void *BigAlloc(size_t size);
|
||||||
|
void BigFree(void *address);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define MidAlloc(size) MyAlloc(size)
|
||||||
|
#define MidFree(address) MyFree(address)
|
||||||
|
#define BigAlloc(size) MyAlloc(size)
|
||||||
|
#define BigFree(address) MyFree(address)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern const ISzAlloc g_Alloc;
|
||||||
|
extern const ISzAlloc g_BigAlloc;
|
||||||
|
extern const ISzAlloc g_MidAlloc;
|
||||||
|
extern const ISzAlloc g_AlignedAlloc;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ISzAlloc vt;
|
||||||
|
ISzAllocPtr baseAlloc;
|
||||||
|
unsigned numAlignBits; /* ((1 << numAlignBits) >= sizeof(void *)) */
|
||||||
|
size_t offset; /* (offset == (k * sizeof(void *)) && offset < (1 << numAlignBits) */
|
||||||
|
} CAlignOffsetAlloc;
|
||||||
|
|
||||||
|
void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p);
|
||||||
|
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
33
LZMA/Compiler.h
Normal file
33
LZMA/Compiler.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/* Compiler.h
|
||||||
|
2017-04-03 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_COMPILER_H
|
||||||
|
#define __7Z_COMPILER_H
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#ifdef UNDER_CE
|
||||||
|
#define RPC_NO_WINDOWS_H
|
||||||
|
/* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */
|
||||||
|
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
|
||||||
|
#pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1300
|
||||||
|
#pragma warning(disable : 4996) // This function or variable may be unsafe
|
||||||
|
#else
|
||||||
|
#pragma warning(disable : 4511) // copy constructor could not be generated
|
||||||
|
#pragma warning(disable : 4512) // assignment operator could not be generated
|
||||||
|
#pragma warning(disable : 4514) // unreferenced inline function has been removed
|
||||||
|
#pragma warning(disable : 4702) // unreachable code
|
||||||
|
#pragma warning(disable : 4710) // not inlined
|
||||||
|
#pragma warning(disable : 4714) // function marked as __forceinline not inlined
|
||||||
|
#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define UNUSED_VAR(x) (void)x;
|
||||||
|
/* #define UNUSED_VAR(x) x=x; */
|
||||||
|
|
||||||
|
#endif
|
175
LZMA/LZMA.vcxproj
Normal file
175
LZMA/LZMA.vcxproj
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Alloc.c" />
|
||||||
|
<ClCompile Include="lzma.c" />
|
||||||
|
<ClCompile Include="Lzma2Dec.c" />
|
||||||
|
<ClCompile Include="LzmaDec.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="7zTypes.h" />
|
||||||
|
<ClInclude Include="Alloc.h" />
|
||||||
|
<ClInclude Include="Compiler.h" />
|
||||||
|
<ClInclude Include="lzma.h" />
|
||||||
|
<ClInclude Include="Lzma2Dec.h" />
|
||||||
|
<ClInclude Include="LzmaDec.h" />
|
||||||
|
<ClInclude Include="Precomp.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{7e31483b-eca1-4d72-9d21-bc80e56d00be}</ProjectGuid>
|
||||||
|
<RootNamespace>LZMA</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)lib\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)lib\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(SolutionDir)lib\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(SolutionDir)lib\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
54
LZMA/LZMA.vcxproj.filters
Normal file
54
LZMA/LZMA.vcxproj.filters
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Lzma2Dec.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="lzma.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Alloc.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="LzmaDec.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Lzma2Dec.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="LzmaDec.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Alloc.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="lzma.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Compiler.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Precomp.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="7zTypes.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
6
LZMA/LZMA.vcxproj.user
Normal file
6
LZMA/LZMA.vcxproj.user
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ShowAllFiles>true</ShowAllFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
488
LZMA/Lzma2Dec.c
Normal file
488
LZMA/Lzma2Dec.c
Normal file
|
@ -0,0 +1,488 @@
|
||||||
|
/* Lzma2Dec.c -- LZMA2 Decoder
|
||||||
|
2019-02-02 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
/* #define SHOW_DEBUG_INFO */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#ifdef SHOW_DEBUG_INFO
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "Lzma2Dec.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
00000000 - End of data
|
||||||
|
00000001 U U - Uncompressed, reset dic, need reset state and set new prop
|
||||||
|
00000010 U U - Uncompressed, no reset
|
||||||
|
100uuuuu U U P P - LZMA, no reset
|
||||||
|
101uuuuu U U P P - LZMA, reset state
|
||||||
|
110uuuuu U U P P S - LZMA, reset state + set new prop
|
||||||
|
111uuuuu U U P P S - LZMA, reset state + set new prop, reset dic
|
||||||
|
|
||||||
|
u, U - Unpack Size
|
||||||
|
P - Pack Size
|
||||||
|
S - Props
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LZMA2_CONTROL_COPY_RESET_DIC 1
|
||||||
|
|
||||||
|
#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & (1 << 7)) == 0)
|
||||||
|
|
||||||
|
#define LZMA2_LCLP_MAX 4
|
||||||
|
#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11))
|
||||||
|
|
||||||
|
#ifdef SHOW_DEBUG_INFO
|
||||||
|
#define PRF(x) x
|
||||||
|
#else
|
||||||
|
#define PRF(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LZMA2_STATE_CONTROL,
|
||||||
|
LZMA2_STATE_UNPACK0,
|
||||||
|
LZMA2_STATE_UNPACK1,
|
||||||
|
LZMA2_STATE_PACK0,
|
||||||
|
LZMA2_STATE_PACK1,
|
||||||
|
LZMA2_STATE_PROP,
|
||||||
|
LZMA2_STATE_DATA,
|
||||||
|
LZMA2_STATE_DATA_CONT,
|
||||||
|
LZMA2_STATE_FINISHED,
|
||||||
|
LZMA2_STATE_ERROR
|
||||||
|
} ELzma2State;
|
||||||
|
|
||||||
|
static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props)
|
||||||
|
{
|
||||||
|
UInt32 dicSize;
|
||||||
|
if (prop > 40)
|
||||||
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop);
|
||||||
|
props[0] = (Byte)LZMA2_LCLP_MAX;
|
||||||
|
props[1] = (Byte)(dicSize);
|
||||||
|
props[2] = (Byte)(dicSize >> 8);
|
||||||
|
props[3] = (Byte)(dicSize >> 16);
|
||||||
|
props[4] = (Byte)(dicSize >> 24);
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc)
|
||||||
|
{
|
||||||
|
Byte props[LZMA_PROPS_SIZE];
|
||||||
|
RINOK(Lzma2Dec_GetOldProps(prop, props));
|
||||||
|
return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc);
|
||||||
|
}
|
||||||
|
|
||||||
|
SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc)
|
||||||
|
{
|
||||||
|
Byte props[LZMA_PROPS_SIZE];
|
||||||
|
RINOK(Lzma2Dec_GetOldProps(prop, props));
|
||||||
|
return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lzma2Dec_Init(CLzma2Dec *p)
|
||||||
|
{
|
||||||
|
p->state = LZMA2_STATE_CONTROL;
|
||||||
|
p->needInitLevel = 0xE0;
|
||||||
|
p->isExtraMode = False;
|
||||||
|
p->unpackSize = 0;
|
||||||
|
|
||||||
|
// p->decoder.dicPos = 0; // we can use it instead of full init
|
||||||
|
LzmaDec_Init(&p->decoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
||||||
|
{
|
||||||
|
switch (p->state)
|
||||||
|
{
|
||||||
|
case LZMA2_STATE_CONTROL:
|
||||||
|
p->isExtraMode = False;
|
||||||
|
p->control = b;
|
||||||
|
PRF(printf("\n %8X", (unsigned)p->decoder.dicPos));
|
||||||
|
PRF(printf(" %02X", (unsigned)b));
|
||||||
|
if (b == 0)
|
||||||
|
return LZMA2_STATE_FINISHED;
|
||||||
|
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
|
||||||
|
{
|
||||||
|
if (b == LZMA2_CONTROL_COPY_RESET_DIC)
|
||||||
|
p->needInitLevel = 0xC0;
|
||||||
|
else if (b > 2 || p->needInitLevel == 0xE0)
|
||||||
|
return LZMA2_STATE_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (b < p->needInitLevel)
|
||||||
|
return LZMA2_STATE_ERROR;
|
||||||
|
p->needInitLevel = 0;
|
||||||
|
p->unpackSize = (UInt32)(b & 0x1F) << 16;
|
||||||
|
}
|
||||||
|
return LZMA2_STATE_UNPACK0;
|
||||||
|
|
||||||
|
case LZMA2_STATE_UNPACK0:
|
||||||
|
p->unpackSize |= (UInt32)b << 8;
|
||||||
|
return LZMA2_STATE_UNPACK1;
|
||||||
|
|
||||||
|
case LZMA2_STATE_UNPACK1:
|
||||||
|
p->unpackSize |= (UInt32)b;
|
||||||
|
p->unpackSize++;
|
||||||
|
PRF(printf(" %7u", (unsigned)p->unpackSize));
|
||||||
|
return LZMA2_IS_UNCOMPRESSED_STATE(p) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
|
||||||
|
|
||||||
|
case LZMA2_STATE_PACK0:
|
||||||
|
p->packSize = (UInt32)b << 8;
|
||||||
|
return LZMA2_STATE_PACK1;
|
||||||
|
|
||||||
|
case LZMA2_STATE_PACK1:
|
||||||
|
p->packSize |= (UInt32)b;
|
||||||
|
p->packSize++;
|
||||||
|
// if (p->packSize < 5) return LZMA2_STATE_ERROR;
|
||||||
|
PRF(printf(" %5u", (unsigned)p->packSize));
|
||||||
|
return (p->control & 0x40) ? LZMA2_STATE_PROP : LZMA2_STATE_DATA;
|
||||||
|
|
||||||
|
case LZMA2_STATE_PROP:
|
||||||
|
{
|
||||||
|
unsigned lc, lp;
|
||||||
|
if (b >= (9 * 5 * 5))
|
||||||
|
return LZMA2_STATE_ERROR;
|
||||||
|
lc = b % 9;
|
||||||
|
b /= 9;
|
||||||
|
p->decoder.prop.pb = (Byte)(b / 5);
|
||||||
|
lp = b % 5;
|
||||||
|
if (lc + lp > LZMA2_LCLP_MAX)
|
||||||
|
return LZMA2_STATE_ERROR;
|
||||||
|
p->decoder.prop.lc = (Byte)lc;
|
||||||
|
p->decoder.prop.lp = (Byte)lp;
|
||||||
|
return LZMA2_STATE_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return LZMA2_STATE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT size)
|
||||||
|
{
|
||||||
|
memcpy(p->dic + p->dicPos, src, size);
|
||||||
|
p->dicPos += size;
|
||||||
|
if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size)
|
||||||
|
p->checkDicSize = p->prop.dicSize;
|
||||||
|
p->processedPos += (UInt32)size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState);
|
||||||
|
|
||||||
|
|
||||||
|
SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
||||||
|
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
|
||||||
|
{
|
||||||
|
SizeT inSize = *srcLen;
|
||||||
|
*srcLen = 0;
|
||||||
|
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||||
|
|
||||||
|
while (p->state != LZMA2_STATE_ERROR)
|
||||||
|
{
|
||||||
|
SizeT dicPos;
|
||||||
|
|
||||||
|
if (p->state == LZMA2_STATE_FINISHED)
|
||||||
|
{
|
||||||
|
*status = LZMA_STATUS_FINISHED_WITH_MARK;
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
dicPos = p->decoder.dicPos;
|
||||||
|
|
||||||
|
if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY)
|
||||||
|
{
|
||||||
|
*status = LZMA_STATUS_NOT_FINISHED;
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT)
|
||||||
|
{
|
||||||
|
if (*srcLen == inSize)
|
||||||
|
{
|
||||||
|
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
(*srcLen)++;
|
||||||
|
p->state = Lzma2Dec_UpdateState(p, *src++);
|
||||||
|
if (dicPos == dicLimit && p->state != LZMA2_STATE_FINISHED)
|
||||||
|
break;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SizeT inCur = inSize - *srcLen;
|
||||||
|
SizeT outCur = dicLimit - dicPos;
|
||||||
|
ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY;
|
||||||
|
|
||||||
|
if (outCur >= p->unpackSize)
|
||||||
|
{
|
||||||
|
outCur = (SizeT)p->unpackSize;
|
||||||
|
curFinishMode = LZMA_FINISH_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
|
||||||
|
{
|
||||||
|
if (inCur == 0)
|
||||||
|
{
|
||||||
|
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->state == LZMA2_STATE_DATA)
|
||||||
|
{
|
||||||
|
BoolInt initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC);
|
||||||
|
LzmaDec_InitDicAndState(&p->decoder, initDic, False);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inCur > outCur)
|
||||||
|
inCur = outCur;
|
||||||
|
if (inCur == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
LzmaDec_UpdateWithUncompressed(&p->decoder, src, inCur);
|
||||||
|
|
||||||
|
src += inCur;
|
||||||
|
*srcLen += inCur;
|
||||||
|
p->unpackSize -= (UInt32)inCur;
|
||||||
|
p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SRes res;
|
||||||
|
|
||||||
|
if (p->state == LZMA2_STATE_DATA)
|
||||||
|
{
|
||||||
|
BoolInt initDic = (p->control >= 0xE0);
|
||||||
|
BoolInt initState = (p->control >= 0xA0);
|
||||||
|
LzmaDec_InitDicAndState(&p->decoder, initDic, initState);
|
||||||
|
p->state = LZMA2_STATE_DATA_CONT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inCur > p->packSize)
|
||||||
|
inCur = (SizeT)p->packSize;
|
||||||
|
|
||||||
|
res = LzmaDec_DecodeToDic(&p->decoder, dicPos + outCur, src, &inCur, curFinishMode, status);
|
||||||
|
|
||||||
|
src += inCur;
|
||||||
|
*srcLen += inCur;
|
||||||
|
p->packSize -= (UInt32)inCur;
|
||||||
|
outCur = p->decoder.dicPos - dicPos;
|
||||||
|
p->unpackSize -= (UInt32)outCur;
|
||||||
|
|
||||||
|
if (res != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (*status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
||||||
|
{
|
||||||
|
if (p->packSize == 0)
|
||||||
|
break;
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inCur == 0 && outCur == 0)
|
||||||
|
{
|
||||||
|
if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
|
||||||
|
|| p->unpackSize != 0
|
||||||
|
|| p->packSize != 0)
|
||||||
|
break;
|
||||||
|
p->state = LZMA2_STATE_CONTROL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||||
|
p->state = LZMA2_STATE_ERROR;
|
||||||
|
return SZ_ERROR_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p,
|
||||||
|
SizeT outSize,
|
||||||
|
const Byte *src, SizeT *srcLen,
|
||||||
|
int checkFinishBlock)
|
||||||
|
{
|
||||||
|
SizeT inSize = *srcLen;
|
||||||
|
*srcLen = 0;
|
||||||
|
|
||||||
|
while (p->state != LZMA2_STATE_ERROR)
|
||||||
|
{
|
||||||
|
if (p->state == LZMA2_STATE_FINISHED)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_FINISHED_WITH_MARK;
|
||||||
|
|
||||||
|
if (outSize == 0 && !checkFinishBlock)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED;
|
||||||
|
|
||||||
|
if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT)
|
||||||
|
{
|
||||||
|
if (*srcLen == inSize)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
|
(*srcLen)++;
|
||||||
|
|
||||||
|
p->state = Lzma2Dec_UpdateState(p, *src++);
|
||||||
|
|
||||||
|
if (p->state == LZMA2_STATE_UNPACK0)
|
||||||
|
{
|
||||||
|
// if (p->decoder.dicPos != 0)
|
||||||
|
if (p->control == LZMA2_CONTROL_COPY_RESET_DIC || p->control >= 0xE0)
|
||||||
|
return LZMA2_PARSE_STATUS_NEW_BLOCK;
|
||||||
|
// if (outSize == 0) return LZMA_STATUS_NOT_FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The following code can be commented.
|
||||||
|
// It's not big problem, if we read additional input bytes.
|
||||||
|
// It will be stopped later in LZMA2_STATE_DATA / LZMA2_STATE_DATA_CONT state.
|
||||||
|
|
||||||
|
if (outSize == 0 && p->state != LZMA2_STATE_FINISHED)
|
||||||
|
{
|
||||||
|
// checkFinishBlock is true. So we expect that block must be finished,
|
||||||
|
// We can return LZMA_STATUS_NOT_SPECIFIED or LZMA_STATUS_NOT_FINISHED here
|
||||||
|
// break;
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->state == LZMA2_STATE_DATA)
|
||||||
|
return LZMA2_PARSE_STATUS_NEW_CHUNK;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outSize == 0)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED;
|
||||||
|
|
||||||
|
{
|
||||||
|
SizeT inCur = inSize - *srcLen;
|
||||||
|
|
||||||
|
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
|
||||||
|
{
|
||||||
|
if (inCur == 0)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
|
if (inCur > p->unpackSize)
|
||||||
|
inCur = p->unpackSize;
|
||||||
|
if (inCur > outSize)
|
||||||
|
inCur = outSize;
|
||||||
|
p->decoder.dicPos += inCur;
|
||||||
|
src += inCur;
|
||||||
|
*srcLen += inCur;
|
||||||
|
outSize -= inCur;
|
||||||
|
p->unpackSize -= (UInt32)inCur;
|
||||||
|
p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p->isExtraMode = True;
|
||||||
|
|
||||||
|
if (inCur == 0)
|
||||||
|
{
|
||||||
|
if (p->packSize != 0)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
|
}
|
||||||
|
else if (p->state == LZMA2_STATE_DATA)
|
||||||
|
{
|
||||||
|
p->state = LZMA2_STATE_DATA_CONT;
|
||||||
|
if (*src != 0)
|
||||||
|
{
|
||||||
|
// first byte of lzma chunk must be Zero
|
||||||
|
*srcLen += 1;
|
||||||
|
p->packSize--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inCur > p->packSize)
|
||||||
|
inCur = (SizeT)p->packSize;
|
||||||
|
|
||||||
|
src += inCur;
|
||||||
|
*srcLen += inCur;
|
||||||
|
p->packSize -= (UInt32)inCur;
|
||||||
|
|
||||||
|
if (p->packSize == 0)
|
||||||
|
{
|
||||||
|
SizeT rem = outSize;
|
||||||
|
if (rem > p->unpackSize)
|
||||||
|
rem = p->unpackSize;
|
||||||
|
p->decoder.dicPos += rem;
|
||||||
|
p->unpackSize -= (UInt32)rem;
|
||||||
|
outSize -= rem;
|
||||||
|
if (p->unpackSize == 0)
|
||||||
|
p->state = LZMA2_STATE_CONTROL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p->state = LZMA2_STATE_ERROR;
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NOT_SPECIFIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
|
||||||
|
{
|
||||||
|
SizeT outSize = *destLen, inSize = *srcLen;
|
||||||
|
*srcLen = *destLen = 0;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
SizeT inCur = inSize, outCur, dicPos;
|
||||||
|
ELzmaFinishMode curFinishMode;
|
||||||
|
SRes res;
|
||||||
|
|
||||||
|
if (p->decoder.dicPos == p->decoder.dicBufSize)
|
||||||
|
p->decoder.dicPos = 0;
|
||||||
|
dicPos = p->decoder.dicPos;
|
||||||
|
curFinishMode = LZMA_FINISH_ANY;
|
||||||
|
outCur = p->decoder.dicBufSize - dicPos;
|
||||||
|
|
||||||
|
if (outCur >= outSize)
|
||||||
|
{
|
||||||
|
outCur = outSize;
|
||||||
|
curFinishMode = finishMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = Lzma2Dec_DecodeToDic(p, dicPos + outCur, src, &inCur, curFinishMode, status);
|
||||||
|
|
||||||
|
src += inCur;
|
||||||
|
inSize -= inCur;
|
||||||
|
*srcLen += inCur;
|
||||||
|
outCur = p->decoder.dicPos - dicPos;
|
||||||
|
memcpy(dest, p->decoder.dic + dicPos, outCur);
|
||||||
|
dest += outCur;
|
||||||
|
outSize -= outCur;
|
||||||
|
*destLen += outCur;
|
||||||
|
if (res != 0)
|
||||||
|
return res;
|
||||||
|
if (outCur == 0 || outSize == 0)
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
||||||
|
Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAllocPtr alloc)
|
||||||
|
{
|
||||||
|
CLzma2Dec p;
|
||||||
|
SRes res;
|
||||||
|
SizeT outSize = *destLen, inSize = *srcLen;
|
||||||
|
*destLen = *srcLen = 0;
|
||||||
|
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||||
|
Lzma2Dec_Construct(&p);
|
||||||
|
RINOK(Lzma2Dec_AllocateProbs(&p, prop, alloc));
|
||||||
|
p.decoder.dic = dest;
|
||||||
|
p.decoder.dicBufSize = outSize;
|
||||||
|
Lzma2Dec_Init(&p);
|
||||||
|
*srcLen = inSize;
|
||||||
|
res = Lzma2Dec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
|
||||||
|
*destLen = p.decoder.dicPos;
|
||||||
|
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
||||||
|
res = SZ_ERROR_INPUT_EOF;
|
||||||
|
Lzma2Dec_FreeProbs(&p, alloc);
|
||||||
|
return res;
|
||||||
|
}
|
120
LZMA/Lzma2Dec.h
Normal file
120
LZMA/Lzma2Dec.h
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/* Lzma2Dec.h -- LZMA2 Decoder
|
||||||
|
2018-02-19 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __LZMA2_DEC_H
|
||||||
|
#define __LZMA2_DEC_H
|
||||||
|
|
||||||
|
#include "LzmaDec.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
/* ---------- State Interface ---------- */
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned state;
|
||||||
|
Byte control;
|
||||||
|
Byte needInitLevel;
|
||||||
|
Byte isExtraMode;
|
||||||
|
Byte _pad_;
|
||||||
|
UInt32 packSize;
|
||||||
|
UInt32 unpackSize;
|
||||||
|
CLzmaDec decoder;
|
||||||
|
} CLzma2Dec;
|
||||||
|
|
||||||
|
#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder)
|
||||||
|
#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc)
|
||||||
|
#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc)
|
||||||
|
|
||||||
|
SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc);
|
||||||
|
SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc);
|
||||||
|
void Lzma2Dec_Init(CLzma2Dec *p);
|
||||||
|
|
||||||
|
/*
|
||||||
|
finishMode:
|
||||||
|
It has meaning only if the decoding reaches output limit (*destLen or dicLimit).
|
||||||
|
LZMA_FINISH_ANY - use smallest number of input bytes
|
||||||
|
LZMA_FINISH_END - read EndOfStream marker after decoding
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
SZ_OK
|
||||||
|
status:
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK
|
||||||
|
LZMA_STATUS_NOT_FINISHED
|
||||||
|
LZMA_STATUS_NEEDS_MORE_INPUT
|
||||||
|
SZ_ERROR_DATA - Data error
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
||||||
|
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
||||||
|
|
||||||
|
SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen,
|
||||||
|
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- LZMA2 block and chunk parsing ---------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
Lzma2Dec_Parse() parses compressed data stream up to next independent block or next chunk data.
|
||||||
|
It can return LZMA_STATUS_* code or LZMA2_PARSE_STATUS_* code:
|
||||||
|
- LZMA2_PARSE_STATUS_NEW_BLOCK - there is new block, and 1 additional byte (control byte of next block header) was read from input.
|
||||||
|
- LZMA2_PARSE_STATUS_NEW_CHUNK - there is new chunk, and only lzma2 header of new chunk was read.
|
||||||
|
CLzma2Dec::unpackSize contains unpack size of that chunk
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
LZMA_STATUS_NOT_SPECIFIED // data error
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK
|
||||||
|
LZMA_STATUS_NOT_FINISHED //
|
||||||
|
LZMA_STATUS_NEEDS_MORE_INPUT
|
||||||
|
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK // unused
|
||||||
|
*/
|
||||||
|
LZMA2_PARSE_STATUS_NEW_BLOCK = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + 1,
|
||||||
|
LZMA2_PARSE_STATUS_NEW_CHUNK
|
||||||
|
} ELzma2ParseStatus;
|
||||||
|
|
||||||
|
ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p,
|
||||||
|
SizeT outSize, // output size
|
||||||
|
const Byte *src, SizeT *srcLen,
|
||||||
|
int checkFinishBlock // set (checkFinishBlock = 1), if it must read full input data, if decoder.dicPos reaches blockMax position.
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
LZMA2 parser doesn't decode LZMA chunks, so we must read
|
||||||
|
full input LZMA chunk to decode some part of LZMA chunk.
|
||||||
|
|
||||||
|
Lzma2Dec_GetUnpackExtra() returns the value that shows
|
||||||
|
max possible number of output bytes that can be output by decoder
|
||||||
|
at current input positon.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define Lzma2Dec_GetUnpackExtra(p) ((p)->isExtraMode ? (p)->unpackSize : 0);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- One Call Interface ---------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
finishMode:
|
||||||
|
It has meaning only if the decoding reaches output limit (*destLen).
|
||||||
|
LZMA_FINISH_ANY - use smallest number of input bytes
|
||||||
|
LZMA_FINISH_END - read EndOfStream marker after decoding
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
SZ_OK
|
||||||
|
status:
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK
|
||||||
|
LZMA_STATUS_NOT_FINISHED
|
||||||
|
SZ_ERROR_DATA - Data error
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||||
|
SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
||||||
|
Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAllocPtr alloc);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
1185
LZMA/LzmaDec.c
Normal file
1185
LZMA/LzmaDec.c
Normal file
File diff suppressed because it is too large
Load Diff
234
LZMA/LzmaDec.h
Normal file
234
LZMA/LzmaDec.h
Normal file
|
@ -0,0 +1,234 @@
|
||||||
|
/* LzmaDec.h -- LZMA Decoder
|
||||||
|
2018-04-21 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __LZMA_DEC_H
|
||||||
|
#define __LZMA_DEC_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
/* #define _LZMA_PROB32 */
|
||||||
|
/* _LZMA_PROB32 can increase the speed on some CPUs,
|
||||||
|
but memory usage for CLzmaDec::probs will be doubled in that case */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
#ifdef _LZMA_PROB32
|
||||||
|
UInt32
|
||||||
|
#else
|
||||||
|
UInt16
|
||||||
|
#endif
|
||||||
|
CLzmaProb;
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- LZMA Properties ---------- */
|
||||||
|
|
||||||
|
#define LZMA_PROPS_SIZE 5
|
||||||
|
|
||||||
|
typedef struct _CLzmaProps
|
||||||
|
{
|
||||||
|
Byte lc;
|
||||||
|
Byte lp;
|
||||||
|
Byte pb;
|
||||||
|
Byte _pad_;
|
||||||
|
UInt32 dicSize;
|
||||||
|
} CLzmaProps;
|
||||||
|
|
||||||
|
/* LzmaProps_Decode - decodes properties
|
||||||
|
Returns:
|
||||||
|
SZ_OK
|
||||||
|
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- LZMA Decoder state ---------- */
|
||||||
|
|
||||||
|
/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
|
||||||
|
Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
|
||||||
|
|
||||||
|
#define LZMA_REQUIRED_INPUT_MAX 20
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Don't change this structure. ASM code can use it. */
|
||||||
|
CLzmaProps prop;
|
||||||
|
CLzmaProb *probs;
|
||||||
|
CLzmaProb *probs_1664;
|
||||||
|
Byte *dic;
|
||||||
|
SizeT dicBufSize;
|
||||||
|
SizeT dicPos;
|
||||||
|
const Byte *buf;
|
||||||
|
UInt32 range;
|
||||||
|
UInt32 code;
|
||||||
|
UInt32 processedPos;
|
||||||
|
UInt32 checkDicSize;
|
||||||
|
UInt32 reps[4];
|
||||||
|
UInt32 state;
|
||||||
|
UInt32 remainLen;
|
||||||
|
|
||||||
|
UInt32 numProbs;
|
||||||
|
unsigned tempBufSize;
|
||||||
|
Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
|
||||||
|
} CLzmaDec;
|
||||||
|
|
||||||
|
#define LzmaDec_Construct(p) { (p)->dic = NULL; (p)->probs = NULL; }
|
||||||
|
|
||||||
|
void LzmaDec_Init(CLzmaDec *p);
|
||||||
|
|
||||||
|
/* There are two types of LZMA streams:
|
||||||
|
- Stream with end mark. That end mark adds about 6 bytes to compressed size.
|
||||||
|
- Stream without end mark. You must know exact uncompressed size to decompress such stream. */
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LZMA_FINISH_ANY, /* finish at any point */
|
||||||
|
LZMA_FINISH_END /* block must be finished at the end */
|
||||||
|
} ELzmaFinishMode;
|
||||||
|
|
||||||
|
/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
|
||||||
|
|
||||||
|
You must use LZMA_FINISH_END, when you know that current output buffer
|
||||||
|
covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
|
||||||
|
|
||||||
|
If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
|
||||||
|
and output value of destLen will be less than output buffer size limit.
|
||||||
|
You can check status result also.
|
||||||
|
|
||||||
|
You can use multiple checks to test data integrity after full decompression:
|
||||||
|
1) Check Result and "status" variable.
|
||||||
|
2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
|
||||||
|
3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
|
||||||
|
You must use correct finish mode in that case. */
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
|
||||||
|
LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
|
||||||
|
LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
|
||||||
|
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */
|
||||||
|
} ELzmaStatus;
|
||||||
|
|
||||||
|
/* ELzmaStatus is used only as output value for function call */
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- Interfaces ---------- */
|
||||||
|
|
||||||
|
/* There are 3 levels of interfaces:
|
||||||
|
1) Dictionary Interface
|
||||||
|
2) Buffer Interface
|
||||||
|
3) One Call Interface
|
||||||
|
You can select any of these interfaces, but don't mix functions from different
|
||||||
|
groups for same object. */
|
||||||
|
|
||||||
|
|
||||||
|
/* There are two variants to allocate state for Dictionary Interface:
|
||||||
|
1) LzmaDec_Allocate / LzmaDec_Free
|
||||||
|
2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
|
||||||
|
You can use variant 2, if you set dictionary buffer manually.
|
||||||
|
For Buffer Interface you must always use variant 1.
|
||||||
|
|
||||||
|
LzmaDec_Allocate* can return:
|
||||||
|
SZ_OK
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);
|
||||||
|
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc);
|
||||||
|
|
||||||
|
SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);
|
||||||
|
void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc);
|
||||||
|
|
||||||
|
/* ---------- Dictionary Interface ---------- */
|
||||||
|
|
||||||
|
/* You can use it, if you want to eliminate the overhead for data copying from
|
||||||
|
dictionary to some other external buffer.
|
||||||
|
You must work with CLzmaDec variables directly in this interface.
|
||||||
|
|
||||||
|
STEPS:
|
||||||
|
LzmaDec_Construct()
|
||||||
|
LzmaDec_Allocate()
|
||||||
|
for (each new stream)
|
||||||
|
{
|
||||||
|
LzmaDec_Init()
|
||||||
|
while (it needs more decompression)
|
||||||
|
{
|
||||||
|
LzmaDec_DecodeToDic()
|
||||||
|
use data from CLzmaDec::dic and update CLzmaDec::dicPos
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LzmaDec_Free()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* LzmaDec_DecodeToDic
|
||||||
|
|
||||||
|
The decoding to internal dictionary buffer (CLzmaDec::dic).
|
||||||
|
You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
|
||||||
|
|
||||||
|
finishMode:
|
||||||
|
It has meaning only if the decoding reaches output limit (dicLimit).
|
||||||
|
LZMA_FINISH_ANY - Decode just dicLimit bytes.
|
||||||
|
LZMA_FINISH_END - Stream must be finished after dicLimit.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
SZ_OK
|
||||||
|
status:
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK
|
||||||
|
LZMA_STATUS_NOT_FINISHED
|
||||||
|
LZMA_STATUS_NEEDS_MORE_INPUT
|
||||||
|
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
|
||||||
|
SZ_ERROR_DATA - Data error
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
|
||||||
|
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- Buffer Interface ---------- */
|
||||||
|
|
||||||
|
/* It's zlib-like interface.
|
||||||
|
See LzmaDec_DecodeToDic description for information about STEPS and return results,
|
||||||
|
but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
|
||||||
|
to work with CLzmaDec variables manually.
|
||||||
|
|
||||||
|
finishMode:
|
||||||
|
It has meaning only if the decoding reaches output limit (*destLen).
|
||||||
|
LZMA_FINISH_ANY - Decode just destLen bytes.
|
||||||
|
LZMA_FINISH_END - Stream must be finished after (*destLen).
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
|
||||||
|
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- One Call Interface ---------- */
|
||||||
|
|
||||||
|
/* LzmaDecode
|
||||||
|
|
||||||
|
finishMode:
|
||||||
|
It has meaning only if the decoding reaches output limit (*destLen).
|
||||||
|
LZMA_FINISH_ANY - Decode just destLen bytes.
|
||||||
|
LZMA_FINISH_END - Stream must be finished after (*destLen).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
SZ_OK
|
||||||
|
status:
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK
|
||||||
|
LZMA_STATUS_NOT_FINISHED
|
||||||
|
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
|
||||||
|
SZ_ERROR_DATA - Data error
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||||
|
SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
||||||
|
const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
|
||||||
|
ELzmaStatus *status, ISzAllocPtr alloc);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
10
LZMA/Precomp.h
Normal file
10
LZMA/Precomp.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/* Precomp.h -- StdAfx
|
||||||
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_PRECOMP_H
|
||||||
|
#define __7Z_PRECOMP_H
|
||||||
|
|
||||||
|
#include "Compiler.h"
|
||||||
|
/* #include "7zTypes.h" */
|
||||||
|
|
||||||
|
#endif
|
8
LZMA/lzma.c
Normal file
8
LZMA/lzma.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include "lzma.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
int lzma2decompress(const unsigned char* in, uint32_t* in_len, unsigned char* out, uint32_t* out_len)
|
||||||
|
{
|
||||||
|
ELzmaStatus status;
|
||||||
|
return Lzma2Decode(out, out_len, in, in_len, 40, LZMA_FINISH_ANY, &status, &g_Alloc);
|
||||||
|
}
|
16
LZMA/lzma.h
Normal file
16
LZMA/lzma.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef _LI_LZMA2
|
||||||
|
#define _LI_LZMA2 1
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#include "Alloc.h"
|
||||||
|
#include "LzmaDec.h"
|
||||||
|
#include "Lzma2Dec.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
int lzma2decompress(const unsigned char* in, uint32_t* in_len, unsigned char* out, uint32_t* out_len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -79,6 +79,9 @@
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<OutDir>$(SolutionDir)lib\</OutDir>
|
<OutDir>$(SolutionDir)lib\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)lib\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
|
BIN
lib/ImGui.lib
BIN
lib/ImGui.lib
Binary file not shown.
BIN
lib/LZMA.idb
Normal file
BIN
lib/LZMA.idb
Normal file
Binary file not shown.
BIN
lib/LZMA.lib
Normal file
BIN
lib/LZMA.lib
Normal file
Binary file not shown.
BIN
lib/Lib9660.lib
BIN
lib/Lib9660.lib
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user