├── SiglusTranslationToolkit ├── skf │ ├── pd32 │ ├── pd64 │ ├── App.config │ ├── skf.csproj.user │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Program.cs │ ├── ProcessDump.cs │ ├── skf.csproj │ └── SiglusKeyFinder.cs ├── stt │ ├── util.cpp │ ├── config.h │ ├── omvt.h │ ├── error.h │ ├── datt.h │ ├── dbst.h │ ├── pckt.h │ ├── util.h │ ├── decryption.h │ ├── stt.vcxproj.user │ ├── wgetopt.h │ ├── wgetopt.cpp │ ├── stt.vcxproj.filters │ ├── datt.cpp │ ├── decryption.cpp │ ├── stt.vcxproj │ ├── stt.cpp │ ├── omvt.cpp │ ├── dbst.cpp │ └── pckt.cpp └── SiglusTranslationToolkit.sln ├── ExternelLib ├── lib │ ├── libogg │ │ └── libogg_static.lib │ └── theora │ │ └── libtheora_static.lib └── include │ ├── libogg │ └── ogg │ │ ├── Makefile.am │ │ ├── config_types.h.in │ │ ├── os_types.h │ │ ├── ogg.h │ │ └── Makefile.in │ └── theora │ ├── Makefile.am │ ├── Makefile.in │ ├── theoradec.h │ └── theoraenc.h ├── .gitignore └── README.md /SiglusTranslationToolkit/skf/pd32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renanc1332/SiglusTranslationToolkit/HEAD/SiglusTranslationToolkit/skf/pd32 -------------------------------------------------------------------------------- /SiglusTranslationToolkit/skf/pd64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renanc1332/SiglusTranslationToolkit/HEAD/SiglusTranslationToolkit/skf/pd64 -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/util.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renanc1332/SiglusTranslationToolkit/HEAD/SiglusTranslationToolkit/stt/util.cpp -------------------------------------------------------------------------------- /ExternelLib/lib/libogg/libogg_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renanc1332/SiglusTranslationToolkit/HEAD/ExternelLib/lib/libogg/libogg_static.lib -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define INCLUDE_DATT 3 | #define INCLUDE_DBST 4 | #define INCLUDE_OMVT 5 | #define INCLUDE_PCKT -------------------------------------------------------------------------------- /ExternelLib/lib/theora/libtheora_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/renanc1332/SiglusTranslationToolkit/HEAD/ExternelLib/lib/theora/libtheora_static.lib -------------------------------------------------------------------------------- /ExternelLib/include/libogg/ogg/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | oggincludedir = $(includedir)/ogg 4 | 5 | ogginclude_HEADERS = ogg.h os_types.h 6 | nodist_ogginclude_HEADERS = config_types.h 7 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/skf/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # 이 .gitignore 파일은 Microsoft(R) Visual Studio에서 자동으로 만들어졌습니다. 3 | ################################################################################ 4 | 5 | /.vs 6 | -------------------------------------------------------------------------------- /ExternelLib/include/theora/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | theoraincludedir = $(includedir)/theora 4 | 5 | theorainclude_HEADERS = theora.h theoradec.h theoraenc.h codec.h 6 | 7 | noinst_HEADERS = codec.h theoradec.h 8 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/omvt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "config.h" 3 | 4 | #ifdef INCLUDE_OMVT 5 | namespace stt 6 | { 7 | void UnpackOMV(std::wstring inFile, std::wstring outPath); 8 | void RepackOMV(std::wstring inFile, std::wstring outPath); 9 | } 10 | #endif //INCLUDE_OMVT -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/error.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace stt 3 | { 4 | enum STTERROR { 5 | ERR_INVALID_INPUT, 6 | ERR_CANNOT_MAKE_CFG, 7 | ERR_INVALID_FILE, 8 | ERR_NO_SUPPORT, 9 | ERR_NO_SUPPORT2, 10 | ERR_NO_SUPPORT3, 11 | ERR_INVALID_KEY, 12 | ERR_INVALID_KEY2, 13 | ERR_NO_REPACK_AND_UNPACK_SAME_TIME 14 | }; 15 | } -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/datt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "config.h" 3 | 4 | #ifdef INCLUDE_DATT 5 | #include 6 | #include 7 | namespace stt 8 | { 9 | void RepackDAT(std::wstring inFile, std::wstring outPath, int compressionLevel); 10 | void UnpackDAT(std::wstring inFile, std::wstring outPath, std::vector keyArray); 11 | } 12 | #endif //INCLUDE_DATT -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/dbst.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "config.h" 3 | 4 | #ifdef INCLUDE_DBST 5 | #include 6 | namespace stt 7 | { 8 | void RepackDBS(std::wstring inFile, std::wstring outPath, int compressionLevel, int codePage, bool koreanForceSpacing); 9 | void UnpackDBS(std::wstring inFile, std::wstring outPath, bool useComment, int codePage, bool koreanForceSpacing); 10 | } 11 | #endif //INCLUDE_DBST -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/pckt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "config.h" 3 | 4 | #ifdef INCLUDE_PCKT 5 | #include 6 | #include 7 | 8 | namespace stt 9 | { 10 | void UnpackPCK(std::wstring inFile, std::wstring outPath, bool useComment, std::vector keyArray, bool koreanForceSpacing); 11 | void RepackPCK(std::wstring inFile, std::wstring outPath, int compressionLevel, bool koreanForceSpacing); 12 | } 13 | #endif //INCLUDE_PCKT -------------------------------------------------------------------------------- /SiglusTranslationToolkit/skf/skf.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | ko-KR 11 | false 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # STT(Siglus Translation Toolkit) 1.01 rev.A 2 | 3 | STT(Siglus Translation Toolkit) : An Un/Repack Toolkit for Siglus engine. It support *.dbs, *.omv, Scene.pck, Gameexe.dat. 4 |
5 | # References 6 | The Program has referenced some of the following source repositories: 7 | 8 | https://github.com/marcussacana/SiglusSceneManager 9 | https://github.com/yanhua0518/GALgameScriptTools 10 | https://github.com/jansonseth/Summer-Pockets-Tools 11 | https://github.com/iotivity/iotivity 12 | 13 | # Release Note 14 | - 1.01 rev.A(20/10/13) 15 | - Bug fix (dbs Script truncation) 16 | - Block comment, fixed spacing function added. 17 | -------------------------------------------------------------------------------- /ExternelLib/include/libogg/ogg/config_types.h.in: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_TYPES_H__ 2 | #define __CONFIG_TYPES_H__ 3 | 4 | /* these are filled in by configure */ 5 | #define INCLUDE_INTTYPES_H @INCLUDE_INTTYPES_H@ 6 | #define INCLUDE_STDINT_H @INCLUDE_STDINT_H@ 7 | #define INCLUDE_SYS_TYPES_H @INCLUDE_SYS_TYPES_H@ 8 | 9 | #if INCLUDE_INTTYPES_H 10 | # include 11 | #endif 12 | #if INCLUDE_STDINT_H 13 | # include 14 | #endif 15 | #if INCLUDE_SYS_TYPES_H 16 | # include 17 | #endif 18 | 19 | typedef @SIZE16@ ogg_int16_t; 20 | typedef @USIZE16@ ogg_uint16_t; 21 | typedef @SIZE32@ ogg_int32_t; 22 | typedef @USIZE32@ ogg_uint32_t; 23 | typedef @SIZE64@ ogg_int64_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #define IN 6 | #define OUT 7 | #define DECOMP_SIZE_PADDING 1000 8 | namespace stt 9 | { 10 | std::wstring getExtension(std::wstring path); 11 | std::wstring getPartialFileName(std::wstring path); 12 | std::wstring getFileName(std::wstring path); 13 | std::wstring getDirectory(std::wstring path); 14 | void checkAvailablePath(std::wstring path, bool write = false); 15 | void addBackSlashToPath(std::wstring& path); 16 | std::vector getFileList(const std::wstring& dirPath, const std::wstring searchOption); 17 | void parseCfg(IN OUT std::map& map); 18 | void parseKey(IN OUT std::vector& keyArray, IN std::wstring key); 19 | } -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/decryption.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace stt 3 | { 4 | void decrypt0(unsigned short* buf, size_t size, unsigned int k); 5 | void decrypt1(unsigned char* buf, size_t size, unsigned char* key, bool noDecrypt4bytePadding = false); 6 | void decrypt2(unsigned char* buf, size_t size, unsigned char type); 7 | void decrypt3(unsigned char* buf, size_t size); 8 | void decompress(unsigned char* inBuf, unsigned char* outBuf, int size); 9 | void fakeCompress(unsigned char* inBuf, unsigned char* outBuf, int size); 10 | unsigned char* compress(unsigned char* inBuf, int inSize, int *compLen, int level); 11 | int searchData(unsigned char *buf, int dataSize, int compLevel, unsigned char *compBuf, int *compLen); 12 | int match(unsigned char *inBuf, unsigned char *matchBuf, int size); 13 | } -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/stt.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | WindowsLocalDebugger 7 | $(SolutionDir)Bin\ 8 | 9 | 10 | 11 | 12 | WindowsLocalDebugger 13 | $(SolutionDir)Bin\ 14 | 15 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/skf/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 6 | // 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 7 | // 이러한 특성 값을 변경하세요. 8 | [assembly: AssemblyTitle("skf")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("skf")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 18 | // 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 19 | // 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. 20 | [assembly: ComVisible(false)] 21 | 22 | // 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. 23 | [assembly: Guid("e897157d-97b6-4449-8f32-a27f1bb8ec95")] 24 | 25 | // 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. 26 | // 27 | // 주 버전 28 | // 부 버전 29 | // 빌드 번호 30 | // 수정 버전 31 | // 32 | // 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 33 | // 지정되도록 할 수 있습니다. 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/wgetopt.h: -------------------------------------------------------------------------------- 1 | /* =============================================== 2 | This source code referenced the following Repo: 3 | https://github.com/iotivity/iotivity/blob/master/resource/c_common/windows/src/getopt.c 4 | ================================================== */ 5 | 6 | /* ***************************************************************** 7 | * 8 | * Copyright 2016 Microsoft 9 | * 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************/ 24 | 25 | #ifndef GETOPT_H__ 26 | #define GETOPT_H__ 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | extern wchar_t *optarg; 33 | extern int optind; 34 | extern wchar_t optopt; 35 | int wgetopt(int argc, wchar_t *const argv[], const wchar_t *optstring); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/wgetopt.cpp: -------------------------------------------------------------------------------- 1 | /* =============================================== 2 | This source code referenced the following Repo: 3 | https://github.com/iotivity/iotivity/blob/master/resource/c_common/windows/src/getopt.c 4 | ================================================== */ 5 | 6 | /* ***************************************************************** 7 | * 8 | * Copyright 2016 Microsoft 9 | * 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************/ 24 | 25 | #include "wgetopt.h" 26 | #include 27 | 28 | wchar_t* optarg = NULL; 29 | int optind = 1; 30 | wchar_t optopt = -1; 31 | 32 | int wgetopt(int argc, wchar_t *const argv[], const wchar_t *optstring) 33 | { 34 | if ((optind >= argc) || (argv[optind][0] != L'-') || (argv[optind][0] == 0)) 35 | { 36 | return -1; 37 | } 38 | 39 | wchar_t opt = argv[optind][1]; 40 | const wchar_t *p = wcschr(optstring, opt); 41 | optopt = opt; 42 | if (p == NULL) 43 | { 44 | return L'?'; 45 | } 46 | if (p[1] == L':') 47 | { 48 | optind++; 49 | if (optind >= argc) 50 | { 51 | return L'?'; 52 | } 53 | optarg = argv[optind]; 54 | } 55 | 56 | optind++; 57 | return opt; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/stt.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 소스 파일 20 | 21 | 22 | 소스 파일 23 | 24 | 25 | 소스 파일 26 | 27 | 28 | 소스 파일 29 | 30 | 31 | 소스 파일 32 | 33 | 34 | 소스 파일 35 | 36 | 37 | 소스 파일 38 | 39 | 40 | 소스 파일 41 | 42 | 43 | 44 | 45 | 헤더 파일 46 | 47 | 48 | 헤더 파일 49 | 50 | 51 | 헤더 파일 52 | 53 | 54 | 헤더 파일 55 | 56 | 57 | 헤더 파일 58 | 59 | 60 | 헤더 파일 61 | 62 | 63 | 헤더 파일 64 | 65 | 66 | 헤더 파일 67 | 68 | 69 | 헤더 파일 70 | 71 | 72 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/SiglusTranslationToolkit.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.757 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stt", "stt\stt.vcxproj", "{2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skf", "skf\skf.csproj", "{E897157D-97B6-4449-8F32-A27F1BB8EC95}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Debug|Any CPU.ActiveCfg = Debug|Win32 21 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Debug|x64.ActiveCfg = Debug|x64 22 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Debug|x64.Build.0 = Debug|x64 23 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Debug|x86.ActiveCfg = Debug|Win32 24 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Debug|x86.Build.0 = Debug|Win32 25 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Release|Any CPU.ActiveCfg = Release|Win32 26 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Release|x64.ActiveCfg = Release|x64 27 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Release|x64.Build.0 = Release|x64 28 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Release|x86.ActiveCfg = Release|Win32 29 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE}.Release|x86.Build.0 = Release|Win32 30 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Debug|x64.ActiveCfg = Debug|Any CPU 33 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Debug|x64.Build.0 = Debug|Any CPU 34 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Debug|x86.ActiveCfg = Debug|Any CPU 35 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Debug|x86.Build.0 = Debug|Any CPU 36 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Release|x64.ActiveCfg = Release|Any CPU 39 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Release|x64.Build.0 = Release|Any CPU 40 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Release|x86.ActiveCfg = Release|Any CPU 41 | {E897157D-97B6-4449-8F32-A27F1BB8EC95}.Release|x86.Build.0 = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | GlobalSection(ExtensibilityGlobals) = postSolution 47 | SolutionGuid = {237614A3-487E-49C1-A446-DE69789E9804} 48 | EndGlobalSection 49 | EndGlobal 50 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/skf/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace skf 10 | { 11 | class Program 12 | { 13 | static int GetPID() 14 | { 15 | while (true) 16 | { 17 | string Name=""; 18 | Process[] Procs = Process.GetProcesses(); 19 | foreach (Process Proc in Procs) 20 | { 21 | Name = Proc.ProcessName; 22 | if (Name.Contains("SiglusEngine")) 23 | { 24 | return Proc.Id; 25 | } 26 | } 27 | } 28 | } 29 | 30 | static void Main(string[] args) 31 | { 32 | System.Console.WriteLine("Please run a siglus engine exe. The process name must contain 'SiglusEngine'."); 33 | System.Console.WriteLine("Process Finding..."); 34 | int PID = GetPID(); 35 | if (PID != -1) 36 | { 37 | System.Console.WriteLine("Process Found."); 38 | System.Console.WriteLine("Keys Finding..."); 39 | try 40 | { 41 | SiglusKeyFinder.KeyFinder.Key[] Keys = SiglusKeyFinder.KeyFinder.ReadProcess(PID); 42 | string MSG = "Keys found:\n"; 43 | foreach (SiglusKeyFinder.KeyFinder.Key Key in Keys) 44 | MSG += Key.KeyStr + "\n---------------------------\n"; 45 | System.Console.WriteLine(MSG); 46 | 47 | StreamReader sr = new StreamReader(new FileStream("stt.cfg", FileMode.Open)); 48 | 49 | List fileLines = new List(); 50 | while (sr.EndOfStream == false) 51 | { 52 | fileLines.Add(sr.ReadLine()); 53 | } 54 | 55 | sr.Close(); 56 | 57 | for (int i = 0; i < fileLines.Count; ++i) 58 | { 59 | fileLines[i].TrimStart(' '); 60 | if (fileLines[i].Length > 3 && fileLines[i].Substring(0, 3) == "key") 61 | fileLines[i] = "key=" + Keys[0].KeyStr; 62 | } 63 | 64 | if (Keys.Length > 1) 65 | { 66 | for (int i = 1; i < Keys.Length; ++i) 67 | { 68 | fileLines.Add("// Alternate key" + i + ": " + Keys[i].KeyStr); 69 | } 70 | } 71 | 72 | StreamWriter sw = new StreamWriter(new FileStream("stt.cfg", FileMode.Create)); 73 | 74 | foreach (string line in fileLines) 75 | { 76 | sw.WriteLine(line); 77 | } 78 | 79 | sw.Close(); 80 | 81 | System.Console.WriteLine("The keys are stored in stt.cfg."); 82 | } 83 | catch 84 | { 85 | System.Console.WriteLine("Error. Process crashed or stt.cfg is corrupted."); 86 | } 87 | } 88 | 89 | 90 | System.Console.WriteLine("\n==Press Any Key=="); 91 | Console.ReadKey(false); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/skf/ProcessDump.cs: -------------------------------------------------------------------------------- 1 | /* =============================================== 2 | This source code referenced the following Repo: 3 | https://github.com/marcussacana/SiglusSceneManager 4 | ================================================== */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Diagnostics; 9 | using System.IO; 10 | using System.Linq; 11 | using System.Reflection; 12 | using System.Text; 13 | using System.Windows.Forms; 14 | 15 | namespace SiglusKeyFinder { 16 | class ProcessDump { 17 | internal static string FILE; 18 | internal static uint BASEADDRESS; 19 | internal static Stream OpenProcess(int PID, bool CrashIfCantDump = false) { 20 | while (!CheckRequeriments()) { 21 | if (CrashIfCantDump) 22 | throw new Exception("VS15 C++ Redist not installed."); 23 | 24 | DialogResult Result = MessageBox.Show("Install the VS2015 Redist Packget before continue", "Requried Library Not Installed", MessageBoxButtons.RetryCancel); 25 | if (Result == DialogResult.Cancel) 26 | throw new Exception("VS15 C++ Redist not installed."); 27 | } 28 | string WorkDir = Path.GetTempPath() + "PDWDIR-" + new Random().Next(100, 999); 29 | if (!Directory.Exists(WorkDir)) 30 | Directory.CreateDirectory(WorkDir); 31 | string PD = GetTmp(Environment.Is64BitOperatingSystem ? "pd64" : "pd32"); 32 | string Arguments = string.Format("-pid {0} -o \"{1}\"", PID, WorkDir); 33 | ProcessStartInfo SI = new ProcessStartInfo() { 34 | FileName = PD, 35 | Arguments = Arguments, 36 | UseShellExecute = false, 37 | RedirectStandardOutput = true, 38 | CreateNoWindow = true 39 | }; 40 | Process Proc = Process.Start(SI); 41 | Proc.StandardOutput.ReadToEnd(); 42 | Proc.WaitForExit(); 43 | Proc.Close(); 44 | File.Delete(PD); 45 | string EXE = Path.GetFileName(Process.GetProcessById(PID).ProcessName) + ".exe"; 46 | 47 | string TMP = Path.GetTempFileName(); 48 | string Filter = EXE.Replace(".", "_") + "*" + EXE + "_*.exe"; 49 | string[] Modules = Directory.GetFiles(WorkDir, Filter); 50 | if (Modules.Length == 0) 51 | throw new Exception("Failed to dump the process"); 52 | string Dump = Modules[0]; 53 | string[] Parts = Path.GetFileNameWithoutExtension(Dump).Split('_'); 54 | BASEADDRESS = Convert.ToUInt32(Parts[Parts.Length - 2], 16); 55 | if (File.Exists(TMP)) 56 | File.Delete(TMP); 57 | File.Move(Dump, TMP); 58 | Directory.Delete(WorkDir, true); 59 | FILE = TMP; 60 | return new StreamReader(TMP).BaseStream; 61 | } 62 | 63 | private static bool CheckRequeriments() { 64 | const string DLL = "msvcp140.dll"; 65 | string Dir = Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\"; 66 | if (!File.Exists(Dir + DLL)) 67 | return false; 68 | return true; 69 | } 70 | 71 | private static string GetTmp(string Resource) { 72 | Stream Reader = Assembly.GetExecutingAssembly().GetManifestResourceStream("skf." + Resource); 73 | string tmp = Path.GetTempFileName(); 74 | Stream Out = new StreamWriter(tmp).BaseStream; 75 | int count = 0; 76 | byte[] Buffer = new byte[1024]; 77 | do { 78 | count = Reader.Read(Buffer, 0, Buffer.Length); 79 | Out.Write(Buffer, 0, count); 80 | } while (count > 0); 81 | Out.Close(); 82 | Reader.Close(); 83 | return tmp; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/skf/skf.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E897157D-97B6-4449-8F32-A27F1BB8EC95} 8 | Exe 9 | skf 10 | skf 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | publish\ 16 | true 17 | Disk 18 | false 19 | Foreground 20 | 7 21 | Days 22 | false 23 | false 24 | true 25 | 0 26 | 1.0.0.%2a 27 | false 28 | false 29 | true 30 | 31 | 32 | AnyCPU 33 | true 34 | full 35 | false 36 | ..\bin\ 37 | DEBUG;TRACE 38 | prompt 39 | 4 40 | 41 | 42 | AnyCPU 43 | pdbonly 44 | true 45 | ..\bin\ 46 | TRACE 47 | prompt 48 | 4 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | False 75 | Microsoft .NET Framework 4.6.1%28x86 및 x64%29 76 | true 77 | 78 | 79 | False 80 | .NET Framework 3.5 SP1 81 | false 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /ExternelLib/include/libogg/ogg/os_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 14 | last mod: $Id: os_types.h 19098 2014-02-26 19:06:45Z giles $ 15 | 16 | ********************************************************************/ 17 | #ifndef _OS_TYPES_H 18 | #define _OS_TYPES_H 19 | 20 | /* make it easy on the folks that want to compile the libs with a 21 | different malloc than stdlib */ 22 | #define _ogg_malloc malloc 23 | #define _ogg_calloc calloc 24 | #define _ogg_realloc realloc 25 | #define _ogg_free free 26 | 27 | #if defined(_WIN32) 28 | 29 | # if defined(__CYGWIN__) 30 | # include 31 | typedef int16_t ogg_int16_t; 32 | typedef uint16_t ogg_uint16_t; 33 | typedef int32_t ogg_int32_t; 34 | typedef uint32_t ogg_uint32_t; 35 | typedef int64_t ogg_int64_t; 36 | typedef uint64_t ogg_uint64_t; 37 | # elif defined(__MINGW32__) 38 | # include 39 | typedef short ogg_int16_t; 40 | typedef unsigned short ogg_uint16_t; 41 | typedef int ogg_int32_t; 42 | typedef unsigned int ogg_uint32_t; 43 | typedef long long ogg_int64_t; 44 | typedef unsigned long long ogg_uint64_t; 45 | # elif defined(__MWERKS__) 46 | typedef long long ogg_int64_t; 47 | typedef int ogg_int32_t; 48 | typedef unsigned int ogg_uint32_t; 49 | typedef short ogg_int16_t; 50 | typedef unsigned short ogg_uint16_t; 51 | # else 52 | /* MSVC/Borland */ 53 | typedef __int64 ogg_int64_t; 54 | typedef __int32 ogg_int32_t; 55 | typedef unsigned __int32 ogg_uint32_t; 56 | typedef __int16 ogg_int16_t; 57 | typedef unsigned __int16 ogg_uint16_t; 58 | # endif 59 | 60 | #elif defined(__MACOS__) 61 | 62 | # include 63 | typedef SInt16 ogg_int16_t; 64 | typedef UInt16 ogg_uint16_t; 65 | typedef SInt32 ogg_int32_t; 66 | typedef UInt32 ogg_uint32_t; 67 | typedef SInt64 ogg_int64_t; 68 | 69 | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ 70 | 71 | # include 72 | typedef int16_t ogg_int16_t; 73 | typedef uint16_t ogg_uint16_t; 74 | typedef int32_t ogg_int32_t; 75 | typedef uint32_t ogg_uint32_t; 76 | typedef int64_t ogg_int64_t; 77 | 78 | #elif defined(__HAIKU__) 79 | 80 | /* Haiku */ 81 | # include 82 | typedef short ogg_int16_t; 83 | typedef unsigned short ogg_uint16_t; 84 | typedef int ogg_int32_t; 85 | typedef unsigned int ogg_uint32_t; 86 | typedef long long ogg_int64_t; 87 | 88 | #elif defined(__BEOS__) 89 | 90 | /* Be */ 91 | # include 92 | typedef int16_t ogg_int16_t; 93 | typedef uint16_t ogg_uint16_t; 94 | typedef int32_t ogg_int32_t; 95 | typedef uint32_t ogg_uint32_t; 96 | typedef int64_t ogg_int64_t; 97 | 98 | #elif defined (__EMX__) 99 | 100 | /* OS/2 GCC */ 101 | typedef short ogg_int16_t; 102 | typedef unsigned short ogg_uint16_t; 103 | typedef int ogg_int32_t; 104 | typedef unsigned int ogg_uint32_t; 105 | typedef long long ogg_int64_t; 106 | 107 | #elif defined (DJGPP) 108 | 109 | /* DJGPP */ 110 | typedef short ogg_int16_t; 111 | typedef int ogg_int32_t; 112 | typedef unsigned int ogg_uint32_t; 113 | typedef long long ogg_int64_t; 114 | 115 | #elif defined(R5900) 116 | 117 | /* PS2 EE */ 118 | typedef long ogg_int64_t; 119 | typedef int ogg_int32_t; 120 | typedef unsigned ogg_uint32_t; 121 | typedef short ogg_int16_t; 122 | 123 | #elif defined(__SYMBIAN32__) 124 | 125 | /* Symbian GCC */ 126 | typedef signed short ogg_int16_t; 127 | typedef unsigned short ogg_uint16_t; 128 | typedef signed int ogg_int32_t; 129 | typedef unsigned int ogg_uint32_t; 130 | typedef long long int ogg_int64_t; 131 | 132 | #elif defined(__TMS320C6X__) 133 | 134 | /* TI C64x compiler */ 135 | typedef signed short ogg_int16_t; 136 | typedef unsigned short ogg_uint16_t; 137 | typedef signed int ogg_int32_t; 138 | typedef unsigned int ogg_uint32_t; 139 | typedef long long int ogg_int64_t; 140 | 141 | #else 142 | 143 | # include 144 | 145 | #endif 146 | 147 | #endif /* _OS_TYPES_H */ 148 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/datt.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #ifdef INCLUDE_DATT 4 | #define _X86_ 5 | #include "datt.h" 6 | #include "decryption.h" 7 | #include 8 | #include 9 | #include 10 | #include "util.h" 11 | #include "error.h" 12 | 13 | namespace stt 14 | { 15 | void RepackDAT(std::wstring inFile, std::wstring outPath, int compressionLevel) 16 | { 17 | std::wstring inFileINI = getDirectory(inFile) + getPartialFileName(inFile) + L".ini"; 18 | std::wstring inFileDAX = getDirectory(inFile) + getPartialFileName(inFile) + L".dax"; 19 | std::wstring outFileDAT = outPath + getPartialFileName(inFile) + L".dat"; 20 | 21 | std::vector keyArray; 22 | 23 | std::ifstream ifStream; 24 | checkAvailablePath(inFileDAX); 25 | ifStream.open(inFileDAX, std::ios::binary); 26 | 27 | ifStream.seekg(0, std::ifstream::end); 28 | int size = static_cast(ifStream.tellg()); 29 | ifStream.seekg(0); 30 | 31 | if (size == 12) 32 | { 33 | std::string str(12,0); 34 | ifStream.read(reinterpret_cast(&str[0]), 12); 35 | if (str != "NO EXTRA KEY") 36 | { 37 | ifStream.close(); 38 | throw(ERR_INVALID_KEY2); 39 | } 40 | } 41 | else if (size == 16) 42 | { 43 | keyArray.resize(16); 44 | ifStream.read(reinterpret_cast(&keyArray[0]), 16); 45 | } 46 | else 47 | { 48 | ifStream.close(); 49 | throw(ERR_INVALID_KEY2); 50 | } 51 | 52 | ifStream.close(); 53 | 54 | checkAvailablePath(inFileINI); 55 | ifStream.open(inFileINI, std::ios::binary); 56 | 57 | ifStream.seekg(0, std::ifstream::end); 58 | size = static_cast(ifStream.tellg()); 59 | ifStream.seekg(0); 60 | 61 | if (size <= 2) 62 | { 63 | std::wcout << getFileName(inFileINI) << " is corrupted." << std::endl; 64 | ifStream.close(); 65 | throw(ERR_INVALID_FILE); 66 | } 67 | 68 | std::vector decomp(size); 69 | ifStream.read(reinterpret_cast(&decomp[0]), size); 70 | ifStream.close(); 71 | 72 | std::string header(2, 0); 73 | std::copy(decomp.begin(), decomp.begin() + 2, reinterpret_cast(&header[0])); 74 | 75 | if (header != "\xff\xfe") 76 | throw(ERR_NO_SUPPORT); 77 | 78 | decomp = std::vector(decomp.begin() + 2, decomp.end()); 79 | 80 | std::vector comp; 81 | if (compressionLevel > 0) 82 | { 83 | int newSize = 0; 84 | unsigned char* compDataPtr = compress(&decomp[0], decomp.size(), &newSize, compressionLevel); 85 | comp.assign(compDataPtr, compDataPtr + newSize); 86 | } 87 | else 88 | { 89 | /* This block has not been tested!! */ 90 | 91 | int prevSize = decomp.size(); 92 | int newSize = prevSize + int(prevSize / 8) + 8; 93 | if (prevSize % 8 != 0) 94 | newSize += 1; 95 | comp.resize(newSize - 8, 0); 96 | comp.insert(comp.begin(), reinterpret_cast(&newSize), reinterpret_cast(&newSize) + sizeof(int)); 97 | comp.insert(comp.begin() + sizeof(int), reinterpret_cast(&prevSize), reinterpret_cast(&prevSize) + sizeof(int)); 98 | fakeCompress(&decomp[0], &comp[0], prevSize); 99 | } 100 | 101 | if (!keyArray.empty()) //needKey == true 102 | { 103 | decrypt1(&comp[0], comp.size(), &keyArray[0]); 104 | } 105 | 106 | decrypt2(&comp[0], comp.size(), 1); 107 | 108 | std::ofstream ofStream; 109 | checkAvailablePath(outFileDAT, true); 110 | ofStream.open(outFileDAT, std::ios::binary); 111 | 112 | ofStream.write(keyArray.empty() ? "\x00\x00\x00\x00\x00\x00\x00\x00" : "\x00\x00\x00\x00\x01\x00\x00\x00", 8); 113 | ofStream.write(reinterpret_cast(&comp[0]), comp.size()); 114 | 115 | ofStream.close(); 116 | } 117 | 118 | void UnpackDAT(std::wstring inFile, std::wstring outPath, std::vector keyArray) 119 | { 120 | std::wstring outFileINI = outPath + getPartialFileName(inFile) + L".ini"; 121 | std::wstring outFileDAX = outPath + getPartialFileName(inFile) + L".dax"; 122 | 123 | std::ifstream ifStream; 124 | checkAvailablePath(inFile); 125 | ifStream.open(inFile, std::ios::binary); 126 | 127 | ifStream.seekg(0, std::ifstream::end); 128 | int size = static_cast(ifStream.tellg()); 129 | ifStream.seekg(0); 130 | std::vector buf(size); 131 | ifStream.read(reinterpret_cast(&buf[0]), size); 132 | 133 | ifStream.close(); 134 | 135 | int header; 136 | std::copy(buf.begin(), buf.begin() + sizeof(int), reinterpret_cast(&header)); 137 | 138 | int needKey; 139 | std::copy(buf.begin() + sizeof(int), buf.begin() + sizeof(int) * 2, reinterpret_cast(&needKey)); 140 | 141 | buf = std::vector(buf.begin() + 8, buf.end()); 142 | 143 | decrypt2(&buf[0], buf.size(), 1); 144 | 145 | if (needKey > 0) 146 | { 147 | if (keyArray.size() != 16) 148 | { 149 | throw(ERR_INVALID_KEY); 150 | } 151 | 152 | decrypt1(&buf[0], buf.size(), &keyArray[0]); 153 | } 154 | 155 | int compSize; 156 | std::copy(buf.begin(), buf.begin() + sizeof(int), reinterpret_cast(&compSize)); 157 | 158 | int decompSize; 159 | std::copy(buf.begin() + sizeof(int), buf.begin() + sizeof(int) * 2, reinterpret_cast(&decompSize)); 160 | 161 | buf = std::vector(buf.begin() + 8, buf.end()); 162 | 163 | std::vector decomp(decompSize+ DECOMP_SIZE_PADDING); 164 | 165 | decompress(&buf[0], &decomp[0], decompSize); 166 | 167 | std::ofstream ofStream; 168 | checkAvailablePath(outFileINI, true); 169 | ofStream.open(outFileINI, std::ios::binary); 170 | 171 | ofStream.write("\xff\xfe", 2); 172 | ofStream.write(reinterpret_cast(&decomp[0]), decompSize); 173 | 174 | ofStream.close(); 175 | 176 | checkAvailablePath(outFileDAX, true); 177 | ofStream.open(outFileDAX, std::ios::binary); 178 | 179 | if (needKey>0) 180 | { 181 | ofStream.write(reinterpret_cast(&keyArray[0]), 16); 182 | } 183 | else 184 | { 185 | ofStream.write("NO EXTRA KEY", 12); 186 | } 187 | ofStream.close(); 188 | } 189 | } 190 | #endif //INCLUDE_DATT -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/decryption.cpp: -------------------------------------------------------------------------------- 1 | /* =============================================== 2 | This source code referenced the following Repo: 3 | https://github.com/yanhua0518/GALgameScriptTools 4 | ================================================== */ 5 | 6 | #include "decryption.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | namespace stt 12 | { 13 | void decrypt0(unsigned short* buf, size_t size, unsigned int k) 14 | { 15 | unsigned int key = 28807; 16 | unsigned short localKey = key*k%65536; 17 | 18 | for (size_t i = 0; i < size; ++i) 19 | buf[i] ^= localKey; 20 | } 21 | 22 | void decrypt1(unsigned char* buf, size_t size, unsigned char* key, bool noDecrypt4bytePadding) 23 | { 24 | size_t keyIndex = 0; 25 | for (size_t index = 0; index < size; index++) 26 | { 27 | if (noDecrypt4bytePadding && keyIndex % 4 == 0 && size-index < 4) 28 | { 29 | break; 30 | } 31 | buf[index] ^= key[keyIndex]; 32 | keyIndex++; 33 | if (keyIndex > 15) 34 | keyIndex = 0; 35 | } 36 | } 37 | 38 | void decrypt2(unsigned char* buf, size_t size, unsigned char type) 39 | { 40 | static unsigned char key[2][256] = { { 41 | 0x70,0xF8,0xA6,0xB0,0xA1,0xA5,0x28,0x4F,0xB5,0x2F,0x48,0xFA,0xE1,0xE9,0x4B,0xDE, 42 | 0xB7,0x4F,0x62,0x95,0x8B,0xE0,0x03,0x80,0xE7,0xCF,0x0F,0x6B,0x92,0x01,0xEB,0xF8, 43 | 0xA2,0x88,0xCE,0x63,0x04,0x38,0xD2,0x6D,0x8C,0xD2,0x88,0x76,0xA7,0x92,0x71,0x8F, 44 | 0x4E,0xB6,0x8D,0x01,0x79,0x88,0x83,0x0A,0xF9,0xE9,0x2C,0xDB,0x67,0xDB,0x91,0x14, 45 | 0xD5,0x9A,0x4E,0x79,0x17,0x23,0x08,0x96,0x0E,0x1D,0x15,0xF9,0xA5,0xA0,0x6F,0x58, 46 | 0x17,0xC8,0xA9,0x46,0xDA,0x22,0xFF,0xFD,0x87,0x12,0x42,0xFB,0xA9,0xB8,0x67,0x6C, 47 | 0x91,0x67,0x64,0xF9,0xD1,0x1E,0xE4,0x50,0x64,0x6F,0xF2,0x0B,0xDE,0x40,0xE7,0x47, 48 | 0xF1,0x03,0xCC,0x2A,0xAD,0x7F,0x34,0x21,0xA0,0x64,0x26,0x98,0x6C,0xED,0x69,0xF4, 49 | 0xB5,0x23,0x08,0x6E,0x7D,0x92,0xF6,0xEB,0x93,0xF0,0x7A,0x89,0x5E,0xF9,0xF8,0x7A, 50 | 0xAF,0xE8,0xA9,0x48,0xC2,0xAC,0x11,0x6B,0x2B,0x33,0xA7,0x40,0x0D,0xDC,0x7D,0xA7, 51 | 0x5B,0xCF,0xC8,0x31,0xD1,0x77,0x52,0x8D,0x82,0xAC,0x41,0xB8,0x73,0xA5,0x4F,0x26, 52 | 0x7C,0x0F,0x39,0xDA,0x5B,0x37,0x4A,0xDE,0xA4,0x49,0x0B,0x7C,0x17,0xA3,0x43,0xAE, 53 | 0x77,0x06,0x64,0x73,0xC0,0x43,0xA3,0x18,0x5A,0x0F,0x9F,0x02,0x4C,0x7E,0x8B,0x01, 54 | 0x9F,0x2D,0xAE,0x72,0x54,0x13,0xFF,0x96,0xAE,0x0B,0x34,0x58,0xCF,0xE3,0x00,0x78, 55 | 0xBE,0xE3,0xF5,0x61,0xE4,0x87,0x7C,0xFC,0x80,0xAF,0xC4,0x8D,0x46,0x3A,0x5D,0xD0, 56 | 0x36,0xBC,0xE5,0x60,0x77,0x68,0x08,0x4F,0xBB,0xAB,0xE2,0x78,0x07,0xE8,0x73,0xBF 57 | },{ 58 | 0xD8,0x29,0xB9,0x16,0x3D,0x1A,0x76,0xD0,0x87,0x9B,0x2D,0x0C,0x7B,0xD1,0xA9,0x19, 59 | 0x22,0x9F,0x91,0x73,0x6A,0x35,0xB1,0x7E,0xD1,0xB5,0xE7,0xE6,0xD5,0xF5,0x06,0xD6, 60 | 0xBA,0xBF,0xF3,0x45,0x3F,0xF1,0x61,0xDD,0x4C,0x67,0x6A,0x6F,0x74,0xEC,0x7A,0x6F, 61 | 0x26,0x74,0x0E,0xDB,0x27,0x4C,0xA5,0xF1,0x0E,0x2D,0x70,0xC4,0x40,0x5D,0x4F,0xDA, 62 | 0x9E,0xC5,0x49,0x7B,0xBD,0xE8,0xDF,0xEE,0xCA,0xF4,0x92,0xDE,0xE4,0x76,0x10,0xDD, 63 | 0x2A,0x52,0xDC,0x73,0x4E,0x54,0x8C,0x30,0x3D,0x9A,0xB2,0x9B,0xB8,0x93,0x29,0x55, 64 | 0xFA,0x7A,0xC9,0xDA,0x10,0x97,0xE5,0xB6,0x23,0x02,0xDD,0x38,0x4C,0x9B,0x1F,0x9A, 65 | 0xD5,0x49,0xE9,0x34,0x0F,0x28,0x2D,0x1B,0x52,0x39,0x5C,0x36,0x89,0x56,0xA7,0x96, 66 | 0x14,0xBE,0x2E,0xC5,0x3E,0x08,0x5F,0x47,0xA9,0xDF,0x88,0x9F,0xD4,0xCC,0x69,0x1F, 67 | 0x30,0x9F,0xE7,0xCD,0x80,0x45,0xF3,0xE7,0x2A,0x1D,0x16,0xB2,0xF1,0x54,0xC8,0x6C, 68 | 0x2B,0x0D,0xD4,0x65,0xF7,0xE3,0x36,0xD4,0xA5,0x3B,0xD1,0x79,0x4C,0x54,0xF0,0x2A, 69 | 0xB4,0xB2,0x56,0x45,0x2E,0xAB,0x7B,0x88,0xC5,0xFA,0x74,0xAD,0x03,0xB8,0x9E,0xD5, 70 | 0xF5,0x6F,0xDC,0xFA,0x44,0x49,0x31,0xF6,0x83,0x32,0xFF,0xC2,0xB1,0xE9,0xE1,0x98, 71 | 0x3D,0x6F,0x31,0x0D,0xAC,0xB1,0x08,0x83,0x9D,0x0D,0x10,0xD1,0x41,0xF9,0x00,0xBA, 72 | 0x1A,0xCF,0x13,0x71,0xE4,0x86,0x21,0x2F,0x23,0x65,0xC3,0x45,0xA0,0xC3,0x92,0x48, 73 | 0x9D,0xEA,0xDD,0x31,0x2C,0xE9,0xE2,0x10,0x22,0xAA,0xE1,0xAD,0x2C,0xC4,0x2D,0x7F} }; 74 | 75 | size_t keyIndex = 0; 76 | for (size_t index = 0; index < size; index++) 77 | { 78 | buf[index] ^= key[type][keyIndex]; 79 | keyIndex++; 80 | if (keyIndex > 255) 81 | keyIndex = 0; 82 | } 83 | } 84 | 85 | void decrypt3(unsigned char* buf, size_t size) 86 | { 87 | static unsigned char key[2][4] = { {0x0E, 0xC7, 0x90, 0x71},{0x35, 0xF1, 0x9B, 0x49} }; 88 | static unsigned char r[] = { 89 | 0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0, 90 | 1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1, 91 | 0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0, 92 | 1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1, 93 | 1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1 }; 94 | size_t keyIndex = 0, rIndex = 0; 95 | for (size_t index = 0; index < size; index++) 96 | { 97 | buf[index] ^= key[r[rIndex]][keyIndex]; 98 | keyIndex++; 99 | if (keyIndex > 3) 100 | { 101 | keyIndex = 0; 102 | rIndex++; 103 | if (rIndex > 79) 104 | { 105 | rIndex = 0; 106 | } 107 | } 108 | } 109 | } 110 | 111 | 112 | 113 | void decompress(unsigned char* inBuf, unsigned char* outBuf, int size) { 114 | void *end = outBuf + size; 115 | while (outBuf < end) { 116 | short s = 8, byte = *inBuf++; 117 | while (s > 0 && outBuf < end) { 118 | if (byte & 1) { 119 | *outBuf++ = *inBuf++; 120 | } 121 | else { 122 | unsigned short data = *(unsigned short*)inBuf++; 123 | int tempData = (data & 0x0f) + 2; 124 | data >>= 4; 125 | while (tempData-- > 0) { 126 | *outBuf = *(outBuf - data); 127 | *outBuf++; 128 | } 129 | *inBuf++; 130 | } 131 | s--; 132 | byte >>= 1; 133 | } 134 | } 135 | } 136 | 137 | void fakeCompress(unsigned char* inBuf, unsigned char* outBuf, int size) { 138 | void *end = inBuf + size; 139 | unsigned char* byte = outBuf + 8; 140 | outBuf += 8; 141 | int count = 8; 142 | for (; inBuf < end; count++) { 143 | if (count == 8) { 144 | byte = outBuf; 145 | *outBuf++ = 0xFF; 146 | count = 0; 147 | } 148 | *outBuf++ = *inBuf++; 149 | } 150 | if (count < 8) { 151 | for (count--; count < 8; count++) { 152 | *byte -= 1 << count; 153 | } 154 | } 155 | } 156 | 157 | unsigned char* compress(unsigned char* inBuf, int inSize, int *compLen, int level) { 158 | if (level < 2) { 159 | level = 2; 160 | } 161 | else if (level > 17) { 162 | level = 17; 163 | } 164 | unsigned char *outBuf = (unsigned char*)calloc(inSize * 2, sizeof(unsigned char)), *outPtr = outBuf; 165 | int ptr = 0, outLen = 0, s = 0; 166 | outBuf += 8; 167 | while (ptr < inSize) { 168 | unsigned char *byteBuf = outBuf; 169 | outLen++, outBuf++; 170 | for (s = 0; (s < 8) & (ptr < inSize); s++) { 171 | int offset = 0, copyLen = 0, scan = ptr, curLevel = level; 172 | if (scan > 0xFFF) { 173 | scan = 0xFFF; 174 | } 175 | if (ptr < curLevel) { 176 | curLevel = ptr; 177 | } 178 | if (ptr + curLevel > inSize) { 179 | curLevel = inSize - ptr; 180 | } 181 | if (curLevel > 1) { 182 | offset = searchData(inBuf, scan, curLevel, inBuf, ©Len); 183 | if (ptr + copyLen >= inSize) { 184 | offset = 0; 185 | } 186 | } 187 | if (offset == 0) { 188 | *byteBuf += 1 << s; 189 | *outBuf++ = *inBuf++; 190 | ptr++; 191 | outLen++; 192 | } 193 | else { 194 | *(unsigned short*)outBuf = (offset << 4) + (copyLen - 2); 195 | inBuf += copyLen; 196 | ptr += copyLen; 197 | outBuf += 2; 198 | outLen += 2; 199 | } 200 | } 201 | } 202 | outLen += 8; 203 | *(int*)outPtr = outLen; 204 | *(int*)(outPtr + 4) = inSize; 205 | *compLen = outLen; 206 | return outPtr; 207 | } 208 | 209 | int searchData(unsigned char *buf, int dataSize, int compLevel, unsigned char *compBuf, int *compLen) { 210 | unsigned char *ptr = buf; 211 | int curOffset = 0, curCompLen = 0, tempLen = 0; 212 | for (ptr = buf - 1; ptr >= buf - dataSize; ptr--) { 213 | if (*(unsigned short*)ptr == *(unsigned short*)compBuf) { 214 | tempLen = match(ptr, compBuf, compLevel); 215 | if (tempLen > curCompLen) { 216 | curCompLen = tempLen; 217 | curOffset = buf - ptr; 218 | if (curCompLen == compLevel) { 219 | break; 220 | } 221 | } 222 | } 223 | } 224 | *compLen = curCompLen; 225 | return curOffset; 226 | } 227 | 228 | int match(unsigned char *inBuf, unsigned char *matchBuf, int size) { 229 | int i = 2; 230 | for (; i < size; i++) { 231 | if (inBuf[i] != matchBuf[i]) { 232 | break; 233 | } 234 | } 235 | return i; 236 | } 237 | } -------------------------------------------------------------------------------- /ExternelLib/include/libogg/ogg/ogg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: toplevel libogg include 14 | last mod: $Id: ogg.h 18044 2011-08-01 17:55:20Z gmaxwell $ 15 | 16 | ********************************************************************/ 17 | #ifndef _OGG_H 18 | #define _OGG_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include 25 | #include "os_types.h" 26 | 27 | typedef struct { 28 | void *iov_base; 29 | size_t iov_len; 30 | } ogg_iovec_t; 31 | 32 | typedef struct { 33 | long endbyte; 34 | int endbit; 35 | 36 | unsigned char *buffer; 37 | unsigned char *ptr; 38 | long storage; 39 | } oggpack_buffer; 40 | 41 | /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ 42 | 43 | typedef struct { 44 | unsigned char *header; 45 | long header_len; 46 | unsigned char *body; 47 | long body_len; 48 | } ogg_page; 49 | 50 | /* ogg_stream_state contains the current encode/decode state of a logical 51 | Ogg bitstream **********************************************************/ 52 | 53 | typedef struct { 54 | unsigned char *body_data; /* bytes from packet bodies */ 55 | long body_storage; /* storage elements allocated */ 56 | long body_fill; /* elements stored; fill mark */ 57 | long body_returned; /* elements of fill returned */ 58 | 59 | 60 | int *lacing_vals; /* The values that will go to the segment table */ 61 | ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact 62 | this way, but it is simple coupled to the 63 | lacing fifo */ 64 | long lacing_storage; 65 | long lacing_fill; 66 | long lacing_packet; 67 | long lacing_returned; 68 | 69 | unsigned char header[282]; /* working space for header encode */ 70 | int header_fill; 71 | 72 | int e_o_s; /* set when we have buffered the last packet in the 73 | logical bitstream */ 74 | int b_o_s; /* set after we've written the initial page 75 | of a logical bitstream */ 76 | long serialno; 77 | long pageno; 78 | ogg_int64_t packetno; /* sequence number for decode; the framing 79 | knows where there's a hole in the data, 80 | but we need coupling so that the codec 81 | (which is in a separate abstraction 82 | layer) also knows about the gap */ 83 | ogg_int64_t granulepos; 84 | 85 | } ogg_stream_state; 86 | 87 | /* ogg_packet is used to encapsulate the data and metadata belonging 88 | to a single raw Ogg/Vorbis packet *************************************/ 89 | 90 | typedef struct { 91 | unsigned char *packet; 92 | long bytes; 93 | long b_o_s; 94 | long e_o_s; 95 | 96 | ogg_int64_t granulepos; 97 | 98 | ogg_int64_t packetno; /* sequence number for decode; the framing 99 | knows where there's a hole in the data, 100 | but we need coupling so that the codec 101 | (which is in a separate abstraction 102 | layer) also knows about the gap */ 103 | } ogg_packet; 104 | 105 | typedef struct { 106 | unsigned char *data; 107 | int storage; 108 | int fill; 109 | int returned; 110 | 111 | int unsynced; 112 | int headerbytes; 113 | int bodybytes; 114 | } ogg_sync_state; 115 | 116 | /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ 117 | 118 | extern void oggpack_writeinit(oggpack_buffer *b); 119 | extern int oggpack_writecheck(oggpack_buffer *b); 120 | extern void oggpack_writetrunc(oggpack_buffer *b,long bits); 121 | extern void oggpack_writealign(oggpack_buffer *b); 122 | extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); 123 | extern void oggpack_reset(oggpack_buffer *b); 124 | extern void oggpack_writeclear(oggpack_buffer *b); 125 | extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); 126 | extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); 127 | extern long oggpack_look(oggpack_buffer *b,int bits); 128 | extern long oggpack_look1(oggpack_buffer *b); 129 | extern void oggpack_adv(oggpack_buffer *b,int bits); 130 | extern void oggpack_adv1(oggpack_buffer *b); 131 | extern long oggpack_read(oggpack_buffer *b,int bits); 132 | extern long oggpack_read1(oggpack_buffer *b); 133 | extern long oggpack_bytes(oggpack_buffer *b); 134 | extern long oggpack_bits(oggpack_buffer *b); 135 | extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); 136 | 137 | extern void oggpackB_writeinit(oggpack_buffer *b); 138 | extern int oggpackB_writecheck(oggpack_buffer *b); 139 | extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); 140 | extern void oggpackB_writealign(oggpack_buffer *b); 141 | extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); 142 | extern void oggpackB_reset(oggpack_buffer *b); 143 | extern void oggpackB_writeclear(oggpack_buffer *b); 144 | extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); 145 | extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); 146 | extern long oggpackB_look(oggpack_buffer *b,int bits); 147 | extern long oggpackB_look1(oggpack_buffer *b); 148 | extern void oggpackB_adv(oggpack_buffer *b,int bits); 149 | extern void oggpackB_adv1(oggpack_buffer *b); 150 | extern long oggpackB_read(oggpack_buffer *b,int bits); 151 | extern long oggpackB_read1(oggpack_buffer *b); 152 | extern long oggpackB_bytes(oggpack_buffer *b); 153 | extern long oggpackB_bits(oggpack_buffer *b); 154 | extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); 155 | 156 | /* Ogg BITSTREAM PRIMITIVES: encoding **************************/ 157 | 158 | extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); 159 | extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, 160 | int count, long e_o_s, ogg_int64_t granulepos); 161 | extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); 162 | extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill); 163 | extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og); 164 | extern int ogg_stream_flush_fill(ogg_stream_state *os, ogg_page *og, int nfill); 165 | 166 | /* Ogg BITSTREAM PRIMITIVES: decoding **************************/ 167 | 168 | extern int ogg_sync_init(ogg_sync_state *oy); 169 | extern int ogg_sync_clear(ogg_sync_state *oy); 170 | extern int ogg_sync_reset(ogg_sync_state *oy); 171 | extern int ogg_sync_destroy(ogg_sync_state *oy); 172 | extern int ogg_sync_check(ogg_sync_state *oy); 173 | 174 | extern char *ogg_sync_buffer(ogg_sync_state *oy, long size); 175 | extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes); 176 | extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og); 177 | extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); 178 | extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og); 179 | extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); 180 | extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op); 181 | 182 | /* Ogg BITSTREAM PRIMITIVES: general ***************************/ 183 | 184 | extern int ogg_stream_init(ogg_stream_state *os,int serialno); 185 | extern int ogg_stream_clear(ogg_stream_state *os); 186 | extern int ogg_stream_reset(ogg_stream_state *os); 187 | extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno); 188 | extern int ogg_stream_destroy(ogg_stream_state *os); 189 | extern int ogg_stream_check(ogg_stream_state *os); 190 | extern int ogg_stream_eos(ogg_stream_state *os); 191 | 192 | extern void ogg_page_checksum_set(ogg_page *og); 193 | 194 | extern int ogg_page_version(const ogg_page *og); 195 | extern int ogg_page_continued(const ogg_page *og); 196 | extern int ogg_page_bos(const ogg_page *og); 197 | extern int ogg_page_eos(const ogg_page *og); 198 | extern ogg_int64_t ogg_page_granulepos(const ogg_page *og); 199 | extern int ogg_page_serialno(const ogg_page *og); 200 | extern long ogg_page_pageno(const ogg_page *og); 201 | extern int ogg_page_packets(const ogg_page *og); 202 | 203 | extern void ogg_packet_clear(ogg_packet *op); 204 | 205 | 206 | #ifdef __cplusplus 207 | } 208 | #endif 209 | 210 | #endif /* _OGG_H */ 211 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/stt.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {2211B5EB-6E6F-430C-8A34-D7DCEB2AA2EE} 24 | Win32Proj 25 | stt 26 | 10.0.17763.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v141 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v141 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v141 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v141 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | $(SolutionDir)Bin\ 76 | 77 | 78 | true 79 | 80 | 81 | false 82 | $(SolutionDir)Bin\ 83 | 84 | 85 | false 86 | 87 | 88 | 89 | NotUsing 90 | Level3 91 | Disabled 92 | true 93 | _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 94 | true 95 | pch.h 96 | ..\..\ExternelLib\include;%(AdditionalIncludeDirectories) 97 | Async 98 | 99 | 100 | Console 101 | true 102 | ..\..\ExternelLib\lib\libogg;..\..\ExternelLib\lib\theora;%(AdditionalLibraryDirectories) 103 | libogg_static.lib;libtheora_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 104 | LIBCMT;MSVCRT 105 | 106 | 107 | 108 | 109 | Use 110 | Level3 111 | Disabled 112 | true 113 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 114 | true 115 | pch.h 116 | 117 | 118 | Console 119 | true 120 | 121 | 122 | 123 | 124 | NotUsing 125 | Level3 126 | MaxSpeed 127 | true 128 | true 129 | true 130 | _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 131 | true 132 | pch.h 133 | ..\..\ExternelLib\include; 134 | Speed 135 | 136 | 137 | Console 138 | true 139 | true 140 | true 141 | ..\..\ExternelLib\lib\libogg;..\..\ExternelLib\lib\theora; 142 | libogg_static.lib;libtheora_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 143 | 144 | 145 | /LTCG %(AdditionalOptions) 146 | 147 | 148 | 149 | 150 | NotUsing 151 | Level3 152 | MaxSpeed 153 | true 154 | true 155 | true 156 | _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 157 | true 158 | pch.h 159 | C:\PrivateSourceCode\ExternelLib\include; 160 | 161 | 162 | Console 163 | true 164 | true 165 | true 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/stt.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include "TCHAR.h" 3 | #include "dbst.h" 4 | #include "datt.h" 5 | #include "pckt.h" 6 | #include "omvt.h" 7 | #include "wgetopt.h" 8 | #include "util.h" 9 | #include 10 | #include 11 | #include "error.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace stt; 18 | 19 | namespace stt 20 | { 21 | void printUsage() 22 | { 23 | std::wcout << L"Siglus Translation Toolkit 1.01 rev.A (2020/10/13) -- made by renan" << std::endl; 24 | std::wcout << L"git repo : https://github.com/renanc1332/SiglusTranslationToolkit" << std::endl << std::endl; 25 | 26 | std::wcout << L"Usage: stt " << std::endl << std::endl; 27 | 28 | int oldflag = std::wcout.setf(std::ios::left); 29 | std::wcout << std::endl; 30 | std::wcout << std::setw(22) << L"-o [path]" << L"Output dir path" << std::endl; 31 | std::wcout << std::setw(22) << L"-c [0,2-17]" << L"Compression level(dxt -> dbs, sxt -> pkg, ini -> dat) [0:fake compress, 2~17:compress]" << std::endl; 32 | std::wcout << std::setw(22) << L"-e [codepage(int)]" << L"ASCII dbs codepage (e.g. 932 : shift-jis)" << std::endl; 33 | std::wcout << std::setw(22) << L"-k [keystring]" << L"Resource key(pkg -> sxt, dat -> ini)" << std::endl; 34 | std::wcout << std::setw(22) << L"-m [0,1]" << L"Use comment(dbs -> dxt, pkg -> sxt) [1:true, 0:false]" << std::endl; 35 | std::wcout << std::setw(22) << L"-p [0,1]" << L"When finished, wait without exiting the console window. [1:true, 0:false]" << std::endl; 36 | std::wcout << std::setw(22) << L"-s [0,1]" << L"Use korean forced space insertion(automatic removal of spaces when unpacking) [1:true, 0:false]" << std::endl; 37 | std::wcout.setf(oldflag); 38 | } 39 | 40 | bool isRepackType(std::wstring fileType) 41 | { 42 | if (fileType == L"dbx" || fileType == L"DBX" || fileType == L"dxt" || fileType == L"DXT" || 43 | fileType == L"ini" || fileType == L"INI" || fileType == L"dax" || fileType == L"DAX" || 44 | fileType == L"pkx" || fileType == L"PKX" || fileType == L"ogv" || fileType == L"OGV") 45 | return true; 46 | else 47 | return false; 48 | } 49 | 50 | bool isUnpackType(std::wstring fileType) 51 | { 52 | if (fileType == L"dbs" || fileType == L"DBS" || fileType == L"dat" || fileType == L"DAT" || 53 | fileType == L"pck" || fileType == L"PCK" || fileType == L"omv" || fileType == L"OMV") 54 | return true; 55 | else 56 | return false; 57 | } 58 | } 59 | 60 | int _tmain(int argc, wchar_t *argv[]) 61 | { 62 | bool pause = false; 63 | 64 | try 65 | { 66 | int c; // option 67 | 68 | bool runRepack = false, runUnpack = false, useComment = false, koreanForceSpacing = false; 69 | std::wstring fileType, outPath; 70 | int complevel = 17; // max level 71 | int codepage = 932; // sjis 72 | 73 | std::vector keyArray; 74 | 75 | std::map cfgMap; 76 | parseCfg(cfgMap); 77 | 78 | if (!cfgMap[L"comment"].empty()) 79 | { 80 | if (cfgMap[L"comment"] == L"1") 81 | useComment = true; 82 | } 83 | 84 | if (!cfgMap[L"complevel"].empty()) 85 | { 86 | complevel = std::stoi(cfgMap[L"complevel"]); 87 | } 88 | 89 | if (!cfgMap[L"outpath"].empty()) 90 | { 91 | outPath = cfgMap[L"outpath"]; 92 | } 93 | 94 | if (!cfgMap[L"key"].empty()) 95 | { 96 | parseKey(keyArray, cfgMap[L"key"]); 97 | } 98 | 99 | if (!cfgMap[L"koreanforcespacing"].empty()) 100 | { 101 | if (cfgMap[L"koreanforcespacing"] == L"1") 102 | koreanForceSpacing = true; 103 | } 104 | 105 | if (!cfgMap[L"pause"].empty()) 106 | { 107 | if (cfgMap[L"pause"] == L"1") 108 | pause = true; 109 | } 110 | 111 | if (argc < 2 || std::wstring(argv[1]).empty()) 112 | { 113 | throw(ERR_INVALID_INPUT); 114 | } 115 | 116 | while ((c = wgetopt(argc, argv, L"o:c:e:k:m:p:s:")) != -1) { 117 | // -1 means getopt() parse all options 118 | switch (c) { 119 | case L'm': 120 | useComment = (1 == std::stoi(optarg)) ? true : false; 121 | break; 122 | case L'o': 123 | outPath = optarg; 124 | break; 125 | case L'c': 126 | complevel = std::stoi(optarg); 127 | break; 128 | case L'e': 129 | codepage = std::stoi(optarg); 130 | break; 131 | case L'k': 132 | parseKey(keyArray, optarg); 133 | break; 134 | case L'p': 135 | pause = (1 == std::stoi(optarg)) ? true : false; 136 | break; 137 | case L's': 138 | koreanForceSpacing = (1 == std::stoi(optarg)) ? true : false; 139 | break; 140 | case L'?': 141 | if (optopt == L'o') 142 | std::wcout << L"Please enter a output directory." << std::endl; 143 | else if (optopt == L'c') 144 | std::wcout << L"Please enter a compression level." << std::endl; 145 | else if (optopt == L'e') 146 | std::wcout << L"Please enter a codepage." << std::endl; 147 | else if (optopt == L'k') 148 | std::wcout << L"Please enter a key string." << std::endl; 149 | 150 | throw(ERR_INVALID_INPUT); 151 | } 152 | } 153 | 154 | if (complevel != 0) 155 | { 156 | complevel = std::max(2, std::min(complevel, 17)); 157 | } 158 | 159 | std::vector inFileList; 160 | std::vector outPathList; 161 | 162 | for (int i = optind; i < argc; ++i) 163 | { 164 | std::wstring inFile(argv[i]); 165 | 166 | fileType = getExtension(inFile); 167 | 168 | bool repackType = isRepackType(fileType); 169 | bool unpackType = isUnpackType(fileType); 170 | 171 | if (!repackType && !unpackType) 172 | { 173 | if (fileType == L"ss" || fileType == L"SS" || fileType == L"sxt" || fileType == L"SXT") 174 | { 175 | throw(ERR_NO_SUPPORT2); 176 | } 177 | 178 | throw(ERR_NO_SUPPORT); 179 | } 180 | 181 | if (repackType) 182 | runRepack = true; 183 | 184 | if (unpackType) 185 | runUnpack = true; 186 | 187 | std::wstring inFileDir = getDirectory(inFile); 188 | if (outPath.empty()) 189 | outPath = inFileDir; 190 | 191 | addBackSlashToPath(outPath); 192 | 193 | if (getPartialFileName(inFile) == L"*") 194 | { 195 | inFileList = getFileList(inFileDir, L"*." + fileType); 196 | 197 | for (std::wstring & j : inFileList) 198 | { 199 | j = inFileDir + j; 200 | outPathList.push_back(outPath); 201 | } 202 | } 203 | else 204 | { 205 | inFileList.push_back(inFile); 206 | outPathList.push_back(outPath); 207 | } 208 | } 209 | 210 | 211 | if (runRepack && runUnpack) 212 | throw(ERR_NO_REPACK_AND_UNPACK_SAME_TIME); 213 | 214 | 215 | for (size_t i = 0; i < inFileList.size(); ++i) 216 | { 217 | std::wcout << L"Converting " << getFileName(inFileList[i]) << L"..." << std::endl; 218 | 219 | if (fileType == L"dbs" || fileType == L"DBS") 220 | { 221 | #ifdef INCLUDE_DBST 222 | UnpackDBS(inFileList[i], outPathList[i], useComment, codepage, koreanForceSpacing); 223 | #else //INCLUDE_DBST 224 | throw(ERR_NO_SUPPORT); 225 | #endif //INCLUDE_DBST 226 | } 227 | else if (fileType == L"dbx" || fileType == L"DBX" || fileType == L"dxt" || fileType == L"DXT") 228 | { 229 | #ifdef INCLUDE_DBST 230 | RepackDBS(inFileList[i], outPathList[i], complevel, codepage, koreanForceSpacing); 231 | #else //INCLUDE_DBST 232 | throw(ERR_NO_SUPPORT); 233 | #endif //INCLUDE_DBST 234 | } 235 | else if (fileType == L"dat" || fileType == L"DAT") 236 | { 237 | #ifdef INCLUDE_DATT 238 | UnpackDAT(inFileList[i], outPathList[i], keyArray); 239 | #else //INCLUDE_DATT 240 | throw(ERR_NO_SUPPORT); 241 | #endif //INCLUDE_DATT 242 | } 243 | else if (fileType == L"ini" || fileType == L"INI" || fileType == L"dax" || fileType == L"DAX") 244 | { 245 | #ifdef INCLUDE_DATT 246 | RepackDAT(inFileList[i], outPathList[i], complevel); 247 | #else //INCLUDE_DATT 248 | throw(ERR_NO_SUPPORT); 249 | #endif //INCLUDE_DATT 250 | } 251 | else if (fileType == L"pck" || fileType == L"PCK") 252 | { 253 | #ifdef INCLUDE_PCKT 254 | UnpackPCK(inFileList[i], outPathList[i], useComment, keyArray, koreanForceSpacing); 255 | #else //INCLUDE_PCKT 256 | throw(ERR_NO_SUPPORT); 257 | #endif //INCLUDE_PCKT 258 | } 259 | else if (fileType == L"pkx" || fileType == L"PKX") 260 | { 261 | #ifdef INCLUDE_PCKT 262 | RepackPCK(inFileList[i], outPathList[i], complevel, koreanForceSpacing); 263 | #else //INCLUDE_PCKT 264 | throw(ERR_NO_SUPPORT); 265 | #endif //INCLUDE_PCKT 266 | } 267 | else if (fileType == L"omv" || fileType == L"OMV") 268 | { 269 | #ifdef INCLUDE_OMVT 270 | UnpackOMV(inFileList[i], outPathList[i]); 271 | #else //INCLUDE_OMVT 272 | throw(ERR_NO_SUPPORT); 273 | #endif //INCLUDE_OMVT 274 | } 275 | else if (fileType == L"ogv" || fileType == L"OGV") 276 | { 277 | #ifdef INCLUDE_OMVT 278 | RepackOMV(inFileList[i], outPathList[i]); 279 | #else //INCLUDE_OMVT 280 | throw(ERR_NO_SUPPORT); 281 | #endif //INCLUDE_OMVT 282 | } 283 | std::wcout << L"Success!" << std::endl; 284 | } 285 | 286 | std::wcout << L"Process Complete." << std::endl; 287 | 288 | 289 | if (pause) 290 | { 291 | std::wcout << L"\n==Press Any Key==" << std::endl; 292 | std::wcin.get(); 293 | } 294 | 295 | return 0; 296 | } 297 | catch (STTERROR val) 298 | { 299 | switch (val) 300 | { 301 | case ERR_INVALID_INPUT: 302 | printUsage(); 303 | break; 304 | case ERR_CANNOT_MAKE_CFG: 305 | std::wcout << L"Cannot make cfg file." << std::endl; 306 | break; 307 | case ERR_INVALID_FILE: 308 | std::wcout << L"Cannot handle file." << std::endl; 309 | break; 310 | case ERR_NO_SUPPORT: 311 | std::wcout << L"File format is not supported. If the file is not corrupted, make sure that the extension is not wrong." << std::endl; 312 | break; 313 | case ERR_NO_SUPPORT2: 314 | std::wcout << L"ss or sxt files are not used as input. Please load the pkx file." << std::endl; 315 | break; 316 | case ERR_NO_SUPPORT3: 317 | std::wcout << L"Cannot unpack 32bit omv file." << std::endl; 318 | break; 319 | case ERR_NO_REPACK_AND_UNPACK_SAME_TIME: 320 | std::wcout << L"Unpack and repack cannot be performed at the same time." << std::endl; 321 | break; 322 | case ERR_INVALID_KEY: 323 | std::wcout << L"Invalid key error. The key must be 16 byte array. Please use skf.exe." << std::endl; 324 | break; 325 | case ERR_INVALID_KEY2: 326 | std::wcout << L"Invalid key error. The dax or pkx file is corrupted." << std::endl; 327 | break; 328 | default: 329 | std::wcout << L"Unknown error." << std::endl; 330 | break; 331 | } 332 | 333 | if (pause) 334 | { 335 | std::wcout << L"\n==Press Any Key==" << std::endl; 336 | std::wcin.get(); 337 | } 338 | return -1; 339 | } 340 | catch (...) 341 | { 342 | std::wcout << L"Unknown error. This can be caused by incorrect key." << std::endl; 343 | 344 | if (pause) 345 | { 346 | std::wcout << L"\n==Press Any Key==" << std::endl; 347 | std::wcin.get(); 348 | } 349 | } 350 | } -------------------------------------------------------------------------------- /ExternelLib/include/theora/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.6.3 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 5 | # Free Software Foundation, Inc. 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | SHELL = @SHELL@ 17 | 18 | srcdir = @srcdir@ 19 | top_srcdir = @top_srcdir@ 20 | VPATH = @srcdir@ 21 | prefix = @prefix@ 22 | exec_prefix = @exec_prefix@ 23 | 24 | bindir = @bindir@ 25 | sbindir = @sbindir@ 26 | libexecdir = @libexecdir@ 27 | datadir = @datadir@ 28 | sysconfdir = @sysconfdir@ 29 | sharedstatedir = @sharedstatedir@ 30 | localstatedir = @localstatedir@ 31 | libdir = @libdir@ 32 | infodir = @infodir@ 33 | mandir = @mandir@ 34 | includedir = @includedir@ 35 | oldincludedir = /usr/include 36 | pkgdatadir = $(datadir)/@PACKAGE@ 37 | pkglibdir = $(libdir)/@PACKAGE@ 38 | pkgincludedir = $(includedir)/@PACKAGE@ 39 | top_builddir = ../.. 40 | 41 | ACLOCAL = @ACLOCAL@ 42 | AUTOCONF = @AUTOCONF@ 43 | AUTOMAKE = @AUTOMAKE@ 44 | AUTOHEADER = @AUTOHEADER@ 45 | 46 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 47 | INSTALL = @INSTALL@ 48 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 49 | INSTALL_DATA = @INSTALL_DATA@ 50 | install_sh_DATA = $(install_sh) -c -m 644 51 | install_sh_PROGRAM = $(install_sh) -c 52 | install_sh_SCRIPT = $(install_sh) -c 53 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 54 | INSTALL_HEADER = $(INSTALL_DATA) 55 | transform = @program_transform_name@ 56 | NORMAL_INSTALL = : 57 | PRE_INSTALL = : 58 | POST_INSTALL = : 59 | NORMAL_UNINSTALL = : 60 | PRE_UNINSTALL = : 61 | POST_UNINSTALL = : 62 | host_alias = @host_alias@ 63 | host_triplet = @host@ 64 | 65 | EXEEXT = @EXEEXT@ 66 | OBJEXT = @OBJEXT@ 67 | PATH_SEPARATOR = @PATH_SEPARATOR@ 68 | ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ 69 | AMTAR = @AMTAR@ 70 | AR = @AR@ 71 | ARGZ_H = @ARGZ_H@ 72 | AS = @AS@ 73 | AWK = @AWK@ 74 | BUILDABLE_EXAMPLES = @BUILDABLE_EXAMPLES@ 75 | CAIRO_CFLAGS = @CAIRO_CFLAGS@ 76 | CAIRO_LIBS = @CAIRO_LIBS@ 77 | CC = @CC@ 78 | CPP = @CPP@ 79 | CXX = @CXX@ 80 | CXXCPP = @CXXCPP@ 81 | DEBUG = @DEBUG@ 82 | DEPDIR = @DEPDIR@ 83 | DLLTOOL = @DLLTOOL@ 84 | DSYMUTIL = @DSYMUTIL@ 85 | DUMPBIN = @DUMPBIN@ 86 | F77 = @F77@ 87 | GCJ = @GCJ@ 88 | GCJFLAGS = @GCJFLAGS@ 89 | GETOPT_OBJS = @GETOPT_OBJS@ 90 | GREP = @GREP@ 91 | HAVE_BIBTEX = @HAVE_BIBTEX@ 92 | HAVE_DOXYGEN = @HAVE_DOXYGEN@ 93 | HAVE_PDFLATEX = @HAVE_PDFLATEX@ 94 | HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@ 95 | HAVE_TRANSFIG = @HAVE_TRANSFIG@ 96 | HAVE_VALGRIND = @HAVE_VALGRIND@ 97 | INCLTDL = @INCLTDL@ 98 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 99 | LD = @LD@ 100 | LIBADD_DL = @LIBADD_DL@ 101 | LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ 102 | LIBADD_DLOPEN = @LIBADD_DLOPEN@ 103 | LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ 104 | LIBLTDL = @LIBLTDL@ 105 | LIBM = @LIBM@ 106 | LIBTOOL = @LIBTOOL@ 107 | LIPO = @LIPO@ 108 | LN_S = @LN_S@ 109 | LTDLDEPS = @LTDLDEPS@ 110 | LTDLINCL = @LTDLINCL@ 111 | LTDLOPEN = @LTDLOPEN@ 112 | LT_CONFIG_H = @LT_CONFIG_H@ 113 | LT_DLLOADERS = @LT_DLLOADERS@ 114 | LT_DLPREOPEN = @LT_DLPREOPEN@ 115 | MAINT = @MAINT@ 116 | NM = @NM@ 117 | NMEDIT = @NMEDIT@ 118 | OBJDUMP = @OBJDUMP@ 119 | OGG_CFLAGS = @OGG_CFLAGS@ 120 | OGG_LIBS = @OGG_LIBS@ 121 | OSS_LIBS = @OSS_LIBS@ 122 | OTOOL = @OTOOL@ 123 | OTOOL64 = @OTOOL64@ 124 | PACKAGE = @PACKAGE@ 125 | PKG_CONFIG = @PKG_CONFIG@ 126 | PNG_CFLAGS = @PNG_CFLAGS@ 127 | PNG_LIBS = @PNG_LIBS@ 128 | PROFILE = @PROFILE@ 129 | RANLIB = @RANLIB@ 130 | RC = @RC@ 131 | SDL_CFLAGS = @SDL_CFLAGS@ 132 | SDL_CONFIG = @SDL_CONFIG@ 133 | SDL_LIBS = @SDL_LIBS@ 134 | SED = @SED@ 135 | STRIP = @STRIP@ 136 | THDEC_LIB_AGE = @THDEC_LIB_AGE@ 137 | THDEC_LIB_CURRENT = @THDEC_LIB_CURRENT@ 138 | THDEC_LIB_REVISION = @THDEC_LIB_REVISION@ 139 | THENC_LIB_AGE = @THENC_LIB_AGE@ 140 | THENC_LIB_CURRENT = @THENC_LIB_CURRENT@ 141 | THENC_LIB_REVISION = @THENC_LIB_REVISION@ 142 | THEORADEC_LDFLAGS = @THEORADEC_LDFLAGS@ 143 | THEORAENC_LDFLAGS = @THEORAENC_LDFLAGS@ 144 | THEORA_LDFLAGS = @THEORA_LDFLAGS@ 145 | TH_LIB_AGE = @TH_LIB_AGE@ 146 | TH_LIB_CURRENT = @TH_LIB_CURRENT@ 147 | TH_LIB_REVISION = @TH_LIB_REVISION@ 148 | VALGRIND_ENVIRONMENT = @VALGRIND_ENVIRONMENT@ 149 | VERSION = @VERSION@ 150 | VORBISENC_LIBS = @VORBISENC_LIBS@ 151 | VORBISFILE_LIBS = @VORBISFILE_LIBS@ 152 | VORBIS_CFLAGS = @VORBIS_CFLAGS@ 153 | VORBIS_LIBS = @VORBIS_LIBS@ 154 | am__include = @am__include@ 155 | am__quote = @am__quote@ 156 | install_sh = @install_sh@ 157 | lt_ECHO = @lt_ECHO@ 158 | ltdl_LIBOBJS = @ltdl_LIBOBJS@ 159 | ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ 160 | sys_symbol_underscore = @sys_symbol_underscore@ 161 | 162 | theoraincludedir = $(includedir)/theora 163 | 164 | theorainclude_HEADERS = theora.h theoradec.h theoraenc.h codec.h 165 | 166 | noinst_HEADERS = codec.h theoradec.h 167 | subdir = include/theora 168 | mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs 169 | CONFIG_HEADER = $(top_builddir)/config.h 170 | CONFIG_CLEAN_FILES = 171 | DIST_SOURCES = 172 | HEADERS = $(noinst_HEADERS) $(theorainclude_HEADERS) 173 | 174 | DIST_COMMON = $(noinst_HEADERS) $(theorainclude_HEADERS) Makefile.am \ 175 | Makefile.in 176 | all: all-am 177 | 178 | .SUFFIXES: 179 | $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) 180 | cd $(top_srcdir) && \ 181 | $(AUTOMAKE) --gnu include/theora/Makefile 182 | Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status 183 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) 184 | 185 | mostlyclean-libtool: 186 | -rm -f *.lo 187 | 188 | clean-libtool: 189 | -rm -rf .libs _libs 190 | 191 | distclean-libtool: 192 | -rm -f libtool 193 | uninstall-info-am: 194 | theoraincludeHEADERS_INSTALL = $(INSTALL_HEADER) 195 | install-theoraincludeHEADERS: $(theorainclude_HEADERS) 196 | @$(NORMAL_INSTALL) 197 | $(mkinstalldirs) $(DESTDIR)$(theoraincludedir) 198 | @list='$(theorainclude_HEADERS)'; for p in $$list; do \ 199 | if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 200 | f="`echo $$p | sed -e 's|^.*/||'`"; \ 201 | echo " $(theoraincludeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(theoraincludedir)/$$f"; \ 202 | $(theoraincludeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(theoraincludedir)/$$f; \ 203 | done 204 | 205 | uninstall-theoraincludeHEADERS: 206 | @$(NORMAL_UNINSTALL) 207 | @list='$(theorainclude_HEADERS)'; for p in $$list; do \ 208 | f="`echo $$p | sed -e 's|^.*/||'`"; \ 209 | echo " rm -f $(DESTDIR)$(theoraincludedir)/$$f"; \ 210 | rm -f $(DESTDIR)$(theoraincludedir)/$$f; \ 211 | done 212 | 213 | ETAGS = etags 214 | ETAGSFLAGS = 215 | 216 | tags: TAGS 217 | 218 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 219 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 220 | unique=`for i in $$list; do \ 221 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 222 | done | \ 223 | $(AWK) ' { files[$$0] = 1; } \ 224 | END { for (i in files) print i; }'`; \ 225 | mkid -fID $$unique 226 | 227 | TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 228 | $(TAGS_FILES) $(LISP) 229 | tags=; \ 230 | here=`pwd`; \ 231 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 232 | unique=`for i in $$list; do \ 233 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 234 | done | \ 235 | $(AWK) ' { files[$$0] = 1; } \ 236 | END { for (i in files) print i; }'`; \ 237 | test -z "$(ETAGS_ARGS)$$tags$$unique" \ 238 | || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 239 | $$tags $$unique 240 | 241 | GTAGS: 242 | here=`$(am__cd) $(top_builddir) && pwd` \ 243 | && cd $(top_srcdir) \ 244 | && gtags -i $(GTAGS_ARGS) $$here 245 | 246 | distclean-tags: 247 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH 248 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 249 | 250 | top_distdir = ../.. 251 | distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) 252 | 253 | distdir: $(DISTFILES) 254 | @list='$(DISTFILES)'; for file in $$list; do \ 255 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 256 | dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ 257 | if test "$$dir" != "$$file" && test "$$dir" != "."; then \ 258 | dir="/$$dir"; \ 259 | $(mkinstalldirs) "$(distdir)$$dir"; \ 260 | else \ 261 | dir=''; \ 262 | fi; \ 263 | if test -d $$d/$$file; then \ 264 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 265 | cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ 266 | fi; \ 267 | cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ 268 | else \ 269 | test -f $(distdir)/$$file \ 270 | || cp -p $$d/$$file $(distdir)/$$file \ 271 | || exit 1; \ 272 | fi; \ 273 | done 274 | check-am: all-am 275 | check: check-am 276 | all-am: Makefile $(HEADERS) 277 | 278 | installdirs: 279 | $(mkinstalldirs) $(DESTDIR)$(theoraincludedir) 280 | 281 | install: install-am 282 | install-exec: install-exec-am 283 | install-data: install-data-am 284 | uninstall: uninstall-am 285 | 286 | install-am: all-am 287 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 288 | 289 | installcheck: installcheck-am 290 | install-strip: 291 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 292 | INSTALL_STRIP_FLAG=-s \ 293 | `test -z '$(STRIP)' || \ 294 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 295 | mostlyclean-generic: 296 | 297 | clean-generic: 298 | 299 | distclean-generic: 300 | -rm -f Makefile $(CONFIG_CLEAN_FILES) 301 | 302 | maintainer-clean-generic: 303 | @echo "This command is intended for maintainers to use" 304 | @echo "it deletes files that may require special tools to rebuild." 305 | clean: clean-am 306 | 307 | clean-am: clean-generic clean-libtool mostlyclean-am 308 | 309 | distclean: distclean-am 310 | 311 | distclean-am: clean-am distclean-generic distclean-libtool \ 312 | distclean-tags 313 | 314 | dvi: dvi-am 315 | 316 | dvi-am: 317 | 318 | info: info-am 319 | 320 | info-am: 321 | 322 | install-data-am: install-theoraincludeHEADERS 323 | 324 | install-exec-am: 325 | 326 | install-info: install-info-am 327 | 328 | install-man: 329 | 330 | installcheck-am: 331 | 332 | maintainer-clean: maintainer-clean-am 333 | 334 | maintainer-clean-am: distclean-am maintainer-clean-generic 335 | 336 | mostlyclean: mostlyclean-am 337 | 338 | mostlyclean-am: mostlyclean-generic mostlyclean-libtool 339 | 340 | uninstall-am: uninstall-info-am uninstall-theoraincludeHEADERS 341 | 342 | .PHONY: GTAGS all all-am check check-am clean clean-generic \ 343 | clean-libtool distclean distclean-generic distclean-libtool \ 344 | distclean-tags distdir dvi dvi-am info info-am install \ 345 | install-am install-data install-data-am install-exec \ 346 | install-exec-am install-info install-info-am install-man \ 347 | install-strip install-theoraincludeHEADERS installcheck \ 348 | installcheck-am installdirs maintainer-clean \ 349 | maintainer-clean-generic mostlyclean mostlyclean-generic \ 350 | mostlyclean-libtool tags uninstall uninstall-am \ 351 | uninstall-info-am uninstall-theoraincludeHEADERS 352 | 353 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 354 | # Otherwise a system limit (for SysV at least) may be exceeded. 355 | .NOEXPORT: 356 | -------------------------------------------------------------------------------- /ExternelLib/include/theora/theoradec.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: 14 | last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $ 15 | 16 | ********************************************************************/ 17 | 18 | /**\file 19 | * The libtheoradec C decoding API.*/ 20 | 21 | #if !defined(_O_THEORA_THEORADEC_H_) 22 | # define _O_THEORA_THEORADEC_H_ (1) 23 | # include 24 | # include "../libogg/ogg/ogg.h" 25 | # include "codec.h" 26 | 27 | #if defined(__cplusplus) 28 | extern "C" { 29 | #endif 30 | 31 | 32 | 33 | /**\name th_decode_ctl() codes 34 | * \anchor decctlcodes 35 | * These are the available request codes for th_decode_ctl(). 36 | * By convention, these are odd, to distinguish them from the 37 | * \ref encctlcodes "encoder control codes". 38 | * Keep any experimental or vendor-specific values above \c 0x8000.*/ 39 | /*@{*/ 40 | /**Gets the maximum post-processing level. 41 | * The decoder supports a post-processing filter that can improve 42 | * the appearance of the decoded images. This returns the highest 43 | * level setting for this post-processor, corresponding to maximum 44 | * improvement and computational expense. 45 | * 46 | * \param[out] _buf int: The maximum post-processing level. 47 | * \retval TH_EFAULT \a _dec_ctx or \a _buf is NULL. 48 | * \retval TH_EINVAL \a _buf_sz is not sizeof(int). 49 | * \retval TH_EIMPL Not supported by this implementation.*/ 50 | #define TH_DECCTL_GET_PPLEVEL_MAX (1) 51 | /**Sets the post-processing level. 52 | * By default, post-processing is disabled. 53 | * 54 | * Sets the level of post-processing to use when decoding the 55 | * compressed stream. This must be a value between zero (off) 56 | * and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX. 57 | * 58 | * \param[in] _buf int: The new post-processing level. 59 | * 0 to disable; larger values use more CPU. 60 | * \retval TH_EFAULT \a _dec_ctx or \a _buf is NULL. 61 | * \retval TH_EINVAL \a _buf_sz is not sizeof(int), or the 62 | * post-processing level is out of bounds. 63 | * The maximum post-processing level may be 64 | * implementation-specific, and can be obtained via 65 | * #TH_DECCTL_GET_PPLEVEL_MAX. 66 | * \retval TH_EIMPL Not supported by this implementation.*/ 67 | #define TH_DECCTL_SET_PPLEVEL (3) 68 | /**Sets the granule position. 69 | * Call this after a seek, before decoding the first frame, to ensure that the 70 | * proper granule position is returned for all subsequent frames. 71 | * If you track timestamps yourself and do not use the granule position 72 | * returned by the decoder, then you need not call this function. 73 | * 74 | * \param[in] _buf ogg_int64_t: The granule position of the next 75 | * frame. 76 | * \retval TH_EFAULT \a _dec_ctx or \a _buf is NULL. 77 | * \retval TH_EINVAL \a _buf_sz is not sizeof(ogg_int64_t), or the 78 | * granule position is negative.*/ 79 | #define TH_DECCTL_SET_GRANPOS (5) 80 | /**Sets the striped decode callback function. 81 | * If set, this function will be called as each piece of a frame is fully 82 | * decoded in th_decode_packetin(). 83 | * You can pass in a #th_stripe_callback with 84 | * th_stripe_callback#stripe_decoded set to NULL to disable the 85 | * callbacks at any point. 86 | * Enabling striped decode does not prevent you from calling 87 | * th_decode_ycbcr_out() after the frame is fully decoded. 88 | * 89 | * \param[in] _buf #th_stripe_callback: The callback parameters. 90 | * \retval TH_EFAULT \a _dec_ctx or \a _buf is NULL. 91 | * \retval TH_EINVAL \a _buf_sz is not 92 | * sizeof(th_stripe_callback).*/ 93 | #define TH_DECCTL_SET_STRIPE_CB (7) 94 | 95 | /**Enables telemetry and sets the macroblock display mode */ 96 | #define TH_DECCTL_SET_TELEMETRY_MBMODE (9) 97 | /**Enables telemetry and sets the motion vector display mode */ 98 | #define TH_DECCTL_SET_TELEMETRY_MV (11) 99 | /**Enables telemetry and sets the adaptive quantization display mode */ 100 | #define TH_DECCTL_SET_TELEMETRY_QI (13) 101 | /**Enables telemetry and sets the bitstream breakdown visualization mode */ 102 | #define TH_DECCTL_SET_TELEMETRY_BITS (15) 103 | /*@}*/ 104 | 105 | 106 | 107 | /**A callback function for striped decode. 108 | * This is a function pointer to an application-provided function that will be 109 | * called each time a section of the image is fully decoded in 110 | * th_decode_packetin(). 111 | * This allows the application to process the section immediately, while it is 112 | * still in cache. 113 | * Note that the frame is decoded bottom to top, so \a _yfrag0 will steadily 114 | * decrease with each call until it reaches 0, at which point the full frame 115 | * is decoded. 116 | * The number of fragment rows made available in each call depends on the pixel 117 | * format and the number of post-processing filters enabled, and may not even 118 | * be constant for the entire frame. 119 | * If a non-NULL \a _granpos pointer is passed to 120 | * th_decode_packetin(), the granule position for the frame will be stored 121 | * in it before the first callback is made. 122 | * If an entire frame is dropped (a 0-byte packet), then no callbacks will be 123 | * made at all for that frame. 124 | * \param _ctx An application-provided context pointer. 125 | * \param _buf The image buffer for the decoded frame. 126 | * \param _yfrag0 The Y coordinate of the first row of 8x8 fragments 127 | * decoded. 128 | * Multiply this by 8 to obtain the pixel row number in the 129 | * luma plane. 130 | * If the chroma planes are subsampled in the Y direction, 131 | * this will always be divisible by two. 132 | * \param _yfrag_end The Y coordinate of the first row of 8x8 fragments past 133 | * the newly decoded section. 134 | * If the chroma planes are subsampled in the Y direction, 135 | * this will always be divisible by two. 136 | * I.e., this section contains fragment rows 137 | * \a _yfrag0 ...\a _yfrag_end -1.*/ 138 | typedef void (*th_stripe_decoded_func)(void *_ctx,th_ycbcr_buffer _buf, 139 | int _yfrag0,int _yfrag_end); 140 | 141 | /**The striped decode callback data to pass to #TH_DECCTL_SET_STRIPE_CB.*/ 142 | typedef struct{ 143 | /**An application-provided context pointer. 144 | * This will be passed back verbatim to the application.*/ 145 | void *ctx; 146 | /**The callback function pointer.*/ 147 | th_stripe_decoded_func stripe_decoded; 148 | }th_stripe_callback; 149 | 150 | 151 | 152 | /**\name Decoder state 153 | The following data structures are opaque, and their contents are not 154 | publicly defined by this API. 155 | Referring to their internals directly is unsupported, and may break without 156 | warning.*/ 157 | /*@{*/ 158 | /**The decoder context.*/ 159 | typedef struct th_dec_ctx th_dec_ctx; 160 | /**Setup information. 161 | This contains auxiliary information (Huffman tables and quantization 162 | parameters) decoded from the setup header by th_decode_headerin() to be 163 | passed to th_decode_alloc(). 164 | It can be re-used to initialize any number of decoders, and can be freed 165 | via th_setup_free() at any time.*/ 166 | typedef struct th_setup_info th_setup_info; 167 | /*@}*/ 168 | 169 | 170 | 171 | /**\defgroup decfuncs Functions for Decoding*/ 172 | /*@{*/ 173 | /**\name Functions for decoding 174 | * You must link to libtheoradec if you use any of the 175 | * functions in this section. 176 | * 177 | * The functions are listed in the order they are used in a typical decode. 178 | * The basic steps are: 179 | * - Parse the header packets by repeatedly calling th_decode_headerin(). 180 | * - Allocate a #th_dec_ctx handle with th_decode_alloc(). 181 | * - Call th_setup_free() to free any memory used for codec setup 182 | * information. 183 | * - Perform any additional decoder configuration with th_decode_ctl(). 184 | * - For each video data packet: 185 | * - Submit the packet to the decoder via th_decode_packetin(). 186 | * - Retrieve the uncompressed video data via th_decode_ycbcr_out(). 187 | * - Call th_decode_free() to release all decoder memory.*/ 188 | /*@{*/ 189 | /**Decodes the header packets of a Theora stream. 190 | * This should be called on the initial packets of the stream, in succession, 191 | * until it returns 0, indicating that all headers have been 192 | * processed, or an error is encountered. 193 | * At least three header packets are required, and additional optional header 194 | * packets may follow. 195 | * This can be used on the first packet of any logical stream to determine if 196 | * that stream is a Theora stream. 197 | * \param _info A #th_info structure to fill in. 198 | * This must have been previously initialized with 199 | * th_info_init(). 200 | * The application may immediately begin using the contents of 201 | * this structure after the first header is decoded, though it 202 | * must continue to be passed in on all subsequent calls. 203 | * \param _tc A #th_comment structure to fill in. 204 | * The application may immediately begin using the contents of 205 | * this structure after the second header is decoded, though it 206 | * must continue to be passed in on all subsequent calls. 207 | * \param _setup Returns a pointer to additional, private setup information 208 | * needed by the decoder. 209 | * The contents of this pointer must be initialized to 210 | * NULL on the first call, and the returned value must 211 | * continue to be passed in on all subsequent calls. 212 | * \param _op An ogg_packet structure which contains one of the 213 | * initial packets of an Ogg logical stream. 214 | * \return A positive value indicates that a Theora header was successfully 215 | * processed. 216 | * \retval 0 The first video data packet was encountered after all 217 | * required header packets were parsed. 218 | * The packet just passed in on this call should be saved 219 | * and fed to th_decode_packetin() to begin decoding 220 | * video data. 221 | * \retval TH_EFAULT One of \a _info, \a _tc, or \a _setup was 222 | * NULL. 223 | * \retval TH_EBADHEADER \a _op was NULL, the packet was not the next 224 | * header packet in the expected sequence, or the format 225 | * of the header data was invalid. 226 | * \retval TH_EVERSION The packet data was a Theora info header, but for a 227 | * bitstream version not decodable with this version of 228 | * libtheoradec. 229 | * \retval TH_ENOTFORMAT The packet was not a Theora header. 230 | */ 231 | extern int th_decode_headerin(th_info *_info,th_comment *_tc, 232 | th_setup_info **_setup,ogg_packet *_op); 233 | /**Allocates a decoder instance. 234 | * 235 | * Security Warning: The Theora format supports very large frame sizes, 236 | * potentially even larger than the address space of a 32-bit machine, and 237 | * creating a decoder context allocates the space for several frames of data. 238 | * If the allocation fails here, your program will crash, possibly at some 239 | * future point because the OS kernel returned a valid memory range and will 240 | * only fail when it tries to map the pages in it the first time they are 241 | * used. 242 | * Even if it succeeds, you may experience a denial of service if the frame 243 | * size is large enough to cause excessive paging. 244 | * If you are integrating libtheora in a larger application where such things 245 | * are undesirable, it is highly recommended that you check the frame size in 246 | * \a _info before calling this function and refuse to decode streams where it 247 | * is larger than some reasonable maximum. 248 | * libtheora will not check this for you, because there may be machines that 249 | * can handle such streams and applications that wish to. 250 | * \param _info A #th_info struct filled via th_decode_headerin(). 251 | * \param _setup A #th_setup_info handle returned via 252 | * th_decode_headerin(). 253 | * \return The initialized #th_dec_ctx handle. 254 | * \retval NULL If the decoding parameters were invalid.*/ 255 | extern th_dec_ctx *th_decode_alloc(const th_info *_info, 256 | const th_setup_info *_setup); 257 | /**Releases all storage used for the decoder setup information. 258 | * This should be called after you no longer want to create any decoders for 259 | * a stream whose headers you have parsed with th_decode_headerin(). 260 | * \param _setup The setup information to free. 261 | * This can safely be NULL.*/ 262 | extern void th_setup_free(th_setup_info *_setup); 263 | /**Decoder control function. 264 | * This is used to provide advanced control of the decoding process. 265 | * \param _dec A #th_dec_ctx handle. 266 | * \param _req The control code to process. 267 | * See \ref decctlcodes "the list of available control codes" 268 | * for details. 269 | * \param _buf The parameters for this control code. 270 | * \param _buf_sz The size of the parameter buffer.*/ 271 | extern int th_decode_ctl(th_dec_ctx *_dec,int _req,void *_buf, 272 | size_t _buf_sz); 273 | /**Submits a packet containing encoded video data to the decoder. 274 | * \param _dec A #th_dec_ctx handle. 275 | * \param _op An ogg_packet containing encoded video data. 276 | * \param _granpos Returns the granule position of the decoded packet. 277 | * If non-NULL, the granule position for this specific 278 | * packet is stored in this location. 279 | * This is computed incrementally from previously decoded 280 | * packets. 281 | * After a seek, the correct granule position must be set via 282 | * #TH_DECCTL_SET_GRANPOS for this to work properly. 283 | * \retval 0 Success. 284 | * A new decoded frame can be retrieved by calling 285 | * th_decode_ycbcr_out(). 286 | * \retval TH_DUPFRAME The packet represented a dropped (0-byte) frame. 287 | * The player can skip the call to th_decode_ycbcr_out(), 288 | * as the contents of the decoded frame buffer have not 289 | * changed. 290 | * \retval TH_EFAULT \a _dec or \a _op was NULL. 291 | * \retval TH_EBADPACKET \a _op does not contain encoded video data. 292 | * \retval TH_EIMPL The video data uses bitstream features which this 293 | * library does not support.*/ 294 | extern int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op, 295 | ogg_int64_t *_granpos); 296 | /**Outputs the next available frame of decoded Y'CbCr data. 297 | * If a striped decode callback has been set with #TH_DECCTL_SET_STRIPE_CB, 298 | * then the application does not need to call this function. 299 | * \param _dec A #th_dec_ctx handle. 300 | * \param _ycbcr A video buffer structure to fill in. 301 | * libtheoradec will fill in all the members of this 302 | * structure, including the pointers to the uncompressed video 303 | * data. 304 | * The memory for this video data is owned by 305 | * libtheoradec. 306 | * It may be freed or overwritten without notification when 307 | * subsequent frames are decoded. 308 | * \retval 0 Success 309 | * \retval TH_EFAULT \a _dec or \a _ycbcr was NULL. 310 | */ 311 | extern int th_decode_ycbcr_out(th_dec_ctx *_dec, 312 | th_ycbcr_buffer _ycbcr); 313 | /**Frees an allocated decoder instance. 314 | * \param _dec A #th_dec_ctx handle.*/ 315 | extern void th_decode_free(th_dec_ctx *_dec); 316 | /*@}*/ 317 | /*@}*/ 318 | 319 | 320 | 321 | #if defined(__cplusplus) 322 | } 323 | #endif 324 | 325 | #endif 326 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/omvt.cpp: -------------------------------------------------------------------------------- 1 | /* =============================================== 2 | This source code referenced the following Repo: 3 | https://github.com/jansonseth/Summer-Pockets-Tools 4 | ================================================== */ 5 | 6 | #include "config.h" 7 | 8 | #ifdef INCLUDE_OMVT 9 | #define _X86_ 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "theora/theoradec.h" 16 | #include "libogg/ogg/ogg.h" 17 | 18 | #include 19 | #include "util.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "error.h" 26 | #include 27 | 28 | #define _TAG4(s) ( \ 29 | (((s) >> 24) & 0xFF) | \ 30 | (((s) >> 8 ) & 0xFF00) | \ 31 | (((s) << 24) & 0xFF000000) | \ 32 | (((s) << 8 ) & 0x00FF0000) \ 33 | ) 34 | 35 | #define TAG4(s) _TAG4((UINT32)(s)) 36 | 37 | static th_info ti; 38 | static th_comment tc; 39 | static th_setup_info *ts; 40 | static th_dec_ctx *td; 41 | 42 | static int theora_p = 0; 43 | static int theora_processing_headers; 44 | static int stateflag = 0; 45 | 46 | static th_ycbcr_buffer ycbcr; 47 | 48 | typedef struct 49 | { 50 | int hdrlen; 51 | int ver; 52 | 53 | int zero[8]; 54 | int wtf1; //colordepth? 55 | int width; 56 | int height; 57 | int zero1; 58 | 59 | int zero2; 60 | int frametime; //microseconds, inverse of framerate 61 | int serial; //ogg stream serialno 62 | int zero3; 63 | int wtf2; 64 | int pages_count; 65 | int frames_count; 66 | 67 | int zero4[7]; 68 | int unkkk[7]; 69 | int zero5[7]; 70 | } OMV_HDR; 71 | 72 | //index for Ogg pages 73 | typedef struct 74 | { 75 | unsigned int idx; 76 | unsigned int wtf; 77 | unsigned int len; 78 | unsigned int offset; 79 | int idx_start; 80 | int numframes; //frames in packet 81 | int framestart; 82 | } OMV_PAGEIDX; 83 | 84 | //index for frame timings and corresponding ogg pages 85 | typedef struct 86 | { 87 | int frame; 88 | int pageidx; 89 | int seqcount; //frame idx within page 90 | int wtf; 91 | int keyframe; //typically multiple of 16 92 | int keyframe_pageidx; 93 | int start; //time in millisec 94 | int end; //time in millisec 95 | } OMV_FRAMEIDX; 96 | 97 | 98 | typedef struct 99 | { 100 | ogg_sync_state *oy; 101 | ogg_stream_state *to; 102 | 103 | unsigned int offset; 104 | long page_check; 105 | unsigned int frame; 106 | unsigned int subframe; 107 | 108 | unsigned int keyframe, keyframepage; 109 | 110 | float frametime; 111 | 112 | OMV_HDR omvhdr; 113 | OMV_PAGEIDX *idxpage; 114 | OMV_FRAMEIDX *idxframe; 115 | } STREAMSTAT; 116 | 117 | static void init_streamstat(STREAMSTAT *s, ogg_sync_state *oy, ogg_stream_state *to) 118 | { 119 | //indexing 120 | s->oy = oy; 121 | s->to = to; 122 | s->offset = 0; 123 | s->page_check = 0; 124 | s->keyframe = 0; 125 | s->frame = 0; 126 | //s->frametime = (float)ti.fps_denominator / (float)ti.fps_numerator; 127 | 128 | s->to->pageno = 0; 129 | 130 | s->idxpage = (OMV_PAGEIDX*)malloc(sizeof(OMV_PAGEIDX) * 32 * 1024); 131 | s->idxframe = (OMV_FRAMEIDX*)malloc(sizeof(OMV_FRAMEIDX) * 32 * 1024); 132 | } 133 | static void uninit_streamstat(STREAMSTAT *s) 134 | { 135 | free(s->idxpage); 136 | free(s->idxframe); 137 | } 138 | static void setpage(STREAMSTAT *s) 139 | { 140 | OMV_PAGEIDX *p; 141 | printf("\npage %lu, pos %u, len %u\n", s->to->pageno, s->offset, s->oy->returned); 142 | 143 | if (s->page_check != s->to->pageno) 144 | { 145 | printf("wtf, mispatch page number | expected %ld\n", s->page_check); 146 | exit(1); 147 | } 148 | 149 | //set up page entry 150 | p = s->idxpage + s->page_check; 151 | p->idx = s->page_check; 152 | p->wtf = 256; 153 | p->len = s->oy->returned; 154 | p->offset = s->offset; 155 | p->idx_start = 0; //p->idx; ///wip 156 | p->numframes = 0; 157 | p->framestart = -1; 158 | 159 | /*if (p->idx > 0) 160 | { 161 | if (p[-1].framestart < 0) 162 | { 163 | p->wtf = 0; 164 | p->idx_start--; 165 | } 166 | }*/ 167 | 168 | //stat 169 | s->offset += s->oy->returned; 170 | s->page_check++; 171 | s->subframe = 0; 172 | } 173 | static void setframe(STREAMSTAT *s) 174 | { 175 | OMV_PAGEIDX *p; 176 | OMV_FRAMEIDX *f; 177 | 178 | //printf("%u ", s->frame); 179 | 180 | //page entry 181 | p = s->idxpage + s->page_check - 1; 182 | if (p->framestart < 0) 183 | p->framestart = s->frame; 184 | 185 | p->numframes++; 186 | 187 | //set up frame entry 188 | f = s->idxframe + s->frame; 189 | 190 | f->frame = s->frame; 191 | f->pageidx = s->page_check - 1; 192 | f->seqcount = s->subframe; 193 | f->wtf = 0; //1629440; 194 | f->keyframe = s->keyframe; 195 | f->keyframe_pageidx = s->keyframepage; 196 | 197 | f->start = (int)round((float)s->frame * s->frametime); 198 | f->end = (int)round(f->start + s->frametime); 199 | 200 | if (s->frame > 0) 201 | { 202 | OMV_FRAMEIDX *fprev = f - 1; 203 | if (f->start == fprev->end) f->start++; 204 | } 205 | 206 | if (f->frame == f->keyframe) { f->wtf |= 1; } 207 | 208 | //stat 209 | s->frame++; 210 | s->subframe++; 211 | } 212 | 213 | static void omv_setup(STREAMSTAT *s) 214 | { 215 | OMV_HDR *h = &s->omvhdr; 216 | memset(h, 0, sizeof(OMV_HDR)); 217 | 218 | h->hdrlen = sizeof(OMV_HDR); 219 | h->ver = 0x101; 220 | h->wtf1 = 2; ///????? 221 | h->width = ti.frame_width; 222 | h->height = ti.frame_height; 223 | 224 | h->frametime = (int)((float)ti.fps_denominator / (float)ti.fps_numerator * 1000000.0f); 225 | h->serial = s->to->serialno; 226 | h->wtf2 = 1; 227 | h->pages_count = s->page_check; 228 | h->frames_count = s->frame; 229 | 230 | h->unkkk[2] = -1; 231 | h->unkkk[3] = -1; 232 | } 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | static void stripe_decoded(th_ycbcr_buffer _dst, th_ycbcr_buffer _src, int _fragy0, int _fragy_end) 241 | { 242 | } 243 | 244 | static void open_video(void) 245 | { 246 | th_stripe_callback cb; 247 | int pli; 248 | 249 | for (pli = 0; pli < 3; pli++) 250 | { 251 | int xshift; 252 | int yshift; 253 | xshift = pli != 0 && !(ti.pixel_fmt & 1); 254 | yshift = pli != 0 && !(ti.pixel_fmt & 2); 255 | ycbcr[pli].data = (unsigned char *)malloc((ti.frame_width >> xshift)*(ti.frame_height >> yshift) * sizeof(char)); 256 | ycbcr[pli].stride = ti.frame_width >> xshift; 257 | ycbcr[pli].width = ti.frame_width >> xshift; 258 | ycbcr[pli].height = ti.frame_height >> yshift; 259 | } 260 | 261 | cb.ctx = ycbcr; 262 | cb.stripe_decoded = (th_stripe_decoded_func)stripe_decoded; 263 | th_decode_ctl(td, TH_DECCTL_SET_STRIPE_CB, &cb, sizeof(cb)); 264 | } 265 | 266 | 267 | static int buffer_data(FILE *in, ogg_sync_state *oy) 268 | { 269 | const int readlen = 16; 270 | char *buffer = ogg_sync_buffer(oy, readlen); 271 | int bytes = fread(buffer, 1, readlen, in); 272 | ogg_sync_wrote(oy, bytes); 273 | return bytes; 274 | } 275 | static int queue_page(ogg_stream_state *to, ogg_page *page) 276 | { 277 | if (theora_p) 278 | ogg_stream_pagein(to, page); 279 | return 0; 280 | } 281 | 282 | static void omv_filegen(const char *fname_out, FILE *fpin, STREAMSTAT *s) 283 | { 284 | FILE *outfile; 285 | unsigned char readbuf[1024]; 286 | 287 | outfile = fopen(fname_out, "wb"); 288 | if (outfile == NULL) 289 | { 290 | printf("error creating %s\n", fname_out); 291 | return; 292 | } 293 | 294 | s->idxpage[0].numframes = -1; 295 | s->idxpage[1].numframes = -1; 296 | 297 | omv_setup(s); 298 | 299 | printf("\n\n -- writing final output to %s\n", fname_out); 300 | fwrite(&s->omvhdr, 1, sizeof(OMV_HDR), outfile); 301 | fwrite(s->idxpage, 1, sizeof(OMV_PAGEIDX) * s->page_check, outfile); 302 | fwrite(s->idxframe, 1, sizeof(OMV_FRAMEIDX) * s->frame, outfile); 303 | 304 | #if 1 305 | fseek(fpin, 0, SEEK_SET); 306 | while (1) 307 | { 308 | int rlen = fread(readbuf, 1, sizeof(readbuf), fpin); 309 | if (rlen <= 0) { break; } 310 | fwrite(readbuf, 1, rlen, outfile); 311 | } 312 | #endif 313 | fclose(outfile); 314 | } 315 | 316 | 317 | 318 | void pack_omv(const char *fname_in, const char *fname_out) 319 | { 320 | ogg_sync_state oy; 321 | ogg_page og; 322 | ogg_stream_state to; 323 | ogg_packet op; 324 | 325 | int videobuf_ready = 0; 326 | ogg_int64_t videobuf_granulepos = -1; 327 | double videobuf_time = 0; 328 | 329 | STREAMSTAT s; 330 | FILE *infile = NULL; 331 | 332 | infile = fopen(fname_in, "rb"); 333 | if (infile == NULL) 334 | { 335 | printf("error opening %s\n", fname_in); 336 | exit(1); 337 | } 338 | 339 | ogg_sync_init(&oy); 340 | 341 | th_comment_init(&tc); 342 | th_info_init(&ti); 343 | 344 | init_streamstat(&s, &oy, &to); 345 | 346 | while (!stateflag) 347 | { 348 | int ret = buffer_data(infile, &oy); 349 | if (ret == 0) 350 | break; 351 | while (ogg_sync_pageout(&oy, &og) > 0) 352 | { 353 | int got_packet; 354 | ogg_stream_state test; 355 | 356 | setpage(&s); 357 | 358 | if (!ogg_page_bos(&og)) 359 | { 360 | //don't leak the page; get it into the appropriate stream 361 | queue_page(&to, &og); 362 | stateflag = 1; 363 | break; 364 | } 365 | 366 | ogg_stream_init(&test, ogg_page_serialno(&og)); 367 | ogg_stream_pagein(&test, &og); 368 | got_packet = ogg_stream_packetpeek(&test, &op); 369 | 370 | if ((got_packet == 1) && !theora_p && (theora_processing_headers = th_decode_headerin(&ti, &tc, &ts, &op)) >= 0) 371 | { 372 | memcpy(&to, &test, sizeof(test)); 373 | theora_p = 1; 374 | 375 | //header ok 376 | if (theora_processing_headers) 377 | ogg_stream_packetout(&to, NULL); 378 | } 379 | else { ogg_stream_clear(&test); } 380 | } 381 | // fall through to non-bos page parsing 382 | } 383 | 384 | while (theora_p && theora_processing_headers) 385 | { 386 | int ret; 387 | 388 | while (theora_processing_headers) 389 | { 390 | ret = ogg_stream_packetpeek(&to, &op); 391 | if (ret == 0) { break; } 392 | else if (ret < 0) { continue; } 393 | 394 | theora_processing_headers = th_decode_headerin(&ti, &tc, &ts, &op); 395 | if (theora_processing_headers < 0) 396 | { 397 | printf("Error parsing Theora stream headers; corrupt stream?\n"); 398 | exit(1); 399 | } 400 | else if (theora_processing_headers > 0) 401 | { 402 | //Advance past the successfully processed header. 403 | ogg_stream_packetout(&to, NULL); 404 | } 405 | theora_p++; 406 | } 407 | 408 | if (!(theora_p && theora_processing_headers)) break; 409 | 410 | if (ogg_sync_pageout(&oy, &og) > 0) 411 | { 412 | setpage(&s); 413 | queue_page(&to, &og); 414 | } 415 | else 416 | { 417 | int ret = buffer_data(infile, &oy); 418 | if (ret == 0) 419 | { 420 | printf("End of file while searching for codec headers.\n"); 421 | exit(1); 422 | } 423 | } 424 | } 425 | 426 | //codecs ready 427 | if (theora_p) 428 | { 429 | td = th_decode_alloc(&ti, ts); 430 | //printf("Ogg logical stream %lx is Theora %dx%d %.02f fps video\n" "Encoded frame content is %dx%d with %dx%d offset\n", to.serialno,ti.frame_width,ti.frame_height, (double)ti.fps_numerator/ti.fps_denominator, ti.pic_width,ti.pic_height,ti.pic_x,ti.pic_y); 431 | 432 | s.frametime = (float)ti.fps_denominator / (float)ti.fps_numerator * 1000.0f; 433 | //omv_setup(&s); //DEBUG ONLY 434 | } 435 | else 436 | { 437 | th_info_clear(&ti); 438 | th_comment_clear(&tc); 439 | } 440 | th_setup_free(ts); 441 | 442 | if (theora_p) open_video(); 443 | 444 | if (1) 445 | { 446 | static const char *CHROMA_TYPES[4] = { "420jpeg",NULL,"422","444" }; 447 | if (ti.pixel_fmt >= 4 || ti.pixel_fmt == TH_PF_RSVD) 448 | { 449 | printf("Unknown pixel format: %i\n", ti.pixel_fmt); 450 | exit(1); 451 | } 452 | //printf("YUV4MPEG2 C%s %dx%d F%d/%d I%c A%d:%d\n", CHROMA_TYPES[ti.pixel_fmt],ti.frame_width,ti.frame_height, ti.fps_numerator,ti.fps_denominator,'p', ti.aspect_numerator,ti.aspect_denominator); 453 | } 454 | 455 | ///main loop 456 | stateflag = 0; //playback has not begun 457 | //queue any remaining pages from data we buffered but that did not contain headers 458 | //while(ogg_sync_pageout(&oy,&og)>0) { queue_page(&to, &og); } 459 | 460 | while (1) 461 | { 462 | while (theora_p && !videobuf_ready) 463 | { 464 | if (ogg_stream_packetout(&to, &op) > 0) 465 | { 466 | if (th_decode_packetin(td, &op, &videobuf_granulepos) >= 0) 467 | { 468 | if (th_packet_iskeyframe(&op)) 469 | { 470 | s.keyframe = s.frame; 471 | s.keyframepage = s.page_check - 1; 472 | //printf("k"); 473 | } 474 | 475 | setframe(&s); 476 | 477 | videobuf_time = th_granule_time(td, videobuf_granulepos); 478 | videobuf_ready = 1; 479 | } 480 | } 481 | else 482 | break; 483 | } 484 | 485 | if (!videobuf_ready && feof(infile)) 486 | break; 487 | 488 | if (!videobuf_ready) 489 | { 490 | //no data yet for somebody. Grab another page 491 | buffer_data(infile, &oy); 492 | while (ogg_sync_pageout(&oy, &og) > 0) 493 | { 494 | //printf("\nogg page %ld | %d byte | FRAME %d\n", to.pageno, oy.returned, frames); 495 | setpage(&s); 496 | queue_page(&to, &og); 497 | } 498 | } 499 | 500 | videobuf_ready = 0; 501 | } 502 | 503 | //output omv file 504 | omv_filegen(fname_out, infile, &s); 505 | 506 | //cleanup 507 | if (theora_p) 508 | { 509 | ogg_stream_clear(&to); 510 | th_decode_free(td); 511 | th_comment_clear(&tc); 512 | th_info_clear(&ti); 513 | } 514 | ogg_sync_clear(&oy); 515 | 516 | fclose(infile); 517 | 518 | uninit_streamstat(&s); 519 | 520 | //printf("\n\n%d frames\n", s.frame); 521 | printf("\nDone.\n"); 522 | } 523 | 524 | namespace stt 525 | { 526 | struct OMVHeader 527 | { 528 | unsigned int DataOffset; //ogv(1.0) or package index(1.1) 529 | unsigned char MainVersion; 530 | unsigned char SubVersion; 531 | unsigned short Unknown1; 532 | unsigned int UnkArray[8]; 533 | unsigned int EncryptType; //1--32bit(Alpha) 2--24bit(Non Alpha) 534 | unsigned int Width; 535 | unsigned int Height; 536 | unsigned int UnkArray2[2]; 537 | unsigned int FrameTime; 538 | ULARGE_INTEGER StreamID; 539 | int Flag2; 540 | unsigned int DataPackageCount; 541 | unsigned int FrameCount; 542 | 543 | OMVHeader() {} 544 | 545 | OMVHeader(std::vector& raw) 546 | { 547 | std::copy(raw.begin(), raw.begin() + sizeof(OMVHeader), reinterpret_cast(this)); 548 | } 549 | }; 550 | 551 | struct DataPackage 552 | { 553 | unsigned int PackageId; 554 | unsigned int PackageType; 555 | unsigned int PackageSize; 556 | unsigned int PackageOffset; 557 | unsigned int Unk; 558 | unsigned int FrameCount; 559 | unsigned int IndexOfFirstFrame; 560 | }; 561 | 562 | struct FramePackage 563 | { 564 | unsigned int FrameId; 565 | unsigned int PackageId; 566 | unsigned int IndexOfThisPackage; 567 | unsigned int FrameTime; 568 | unsigned int Unk[2]; 569 | unsigned int FrameStartTime; 570 | unsigned int FrameEndTime; 571 | }; 572 | 573 | void UnpackOMV(std::wstring inFile, std::wstring outPath) 574 | { 575 | std::wstring outFileOGV = outPath + getPartialFileName(inFile) + L".ogv"; 576 | 577 | std::ifstream ifStream; 578 | checkAvailablePath(inFile); 579 | ifStream.open(inFile, std::ios::binary); 580 | 581 | ifStream.seekg(0, std::ifstream::end); 582 | int size = static_cast(ifStream.tellg()); 583 | ifStream.seekg(0); 584 | 585 | std::vector buf(size); 586 | ifStream.read(reinterpret_cast(&buf[0]), size); 587 | 588 | ifStream.close(); 589 | 590 | OMVHeader omvHeader(buf); 591 | 592 | if (omvHeader.MainVersion != 1) 593 | { 594 | throw(ERR_NO_SUPPORT); 595 | } 596 | 597 | unsigned int offset = 0; 598 | if (omvHeader.SubVersion == 1) 599 | offset = omvHeader.DataOffset + omvHeader.DataPackageCount * sizeof(DataPackage) + omvHeader.FrameCount * sizeof(FramePackage); 600 | else if (omvHeader.SubVersion == 0) 601 | offset = omvHeader.DataOffset; 602 | 603 | unsigned int oggsTag = 0; 604 | std::copy(buf.begin() + offset, buf.begin() + offset + sizeof(oggsTag), reinterpret_cast(&oggsTag)); 605 | 606 | if (oggsTag != TAG4('OggS')) 607 | { 608 | throw(ERR_NO_SUPPORT); 609 | } 610 | 611 | std::wcout << getPartialFileName(inFile) << L" Converting..." << std::endl; 612 | 613 | if (omvHeader.EncryptType == 1) 614 | { 615 | throw(ERR_NO_SUPPORT3); 616 | } 617 | 618 | buf = std::vector(buf.begin() + offset, buf.end()); 619 | 620 | std::ofstream ofStream; 621 | checkAvailablePath(outFileOGV, true); 622 | ofStream.open(outFileOGV, std::ios::binary); 623 | ofStream.write(reinterpret_cast(&buf[0]), buf.size()); 624 | ofStream.close(); 625 | } 626 | 627 | void RepackOMV(std::wstring inFile, std::wstring outPath) 628 | { 629 | std::wstring outFileOMV = outPath + getPartialFileName(inFile) + L".omv"; 630 | 631 | int len = WideCharToMultiByte(CP_ACP, 0, &inFile[0], -1, nullptr, 0, nullptr, nullptr); 632 | std::string inFileA(len, 0); 633 | WideCharToMultiByte(CP_ACP, 0, &inFile[0], -1, &inFileA[0], len, nullptr, nullptr); 634 | 635 | len = WideCharToMultiByte(CP_ACP, 0, &outFileOMV[0], -1, nullptr, 0, nullptr, nullptr); 636 | std::string outFileOMVA(len, 0); 637 | WideCharToMultiByte(CP_ACP, 0, &outFileOMV[0], -1, &outFileOMVA[0], len, nullptr, nullptr); 638 | 639 | 640 | pack_omv(inFileA.c_str(), outFileOMVA.c_str()); 641 | } 642 | } 643 | // 644 | //int main(int argc, char **argv) 645 | //{ 646 | // if (argc < 3) 647 | // { 648 | // printf("\nusage:\n" 649 | // " siglus_omv \n" 650 | // ); 651 | // return 1; 652 | // } 653 | // 654 | // pack_omv(argv[1], argv[2]); 655 | // 656 | // return 0; 657 | //} 658 | #endif //INCLUDE_OMVT -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/dbst.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #ifdef INCLUDE_DBST 4 | #define _X86_ 5 | #include "dbst.h" 6 | #include "decryption.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "util.h" 15 | #include "error.h" 16 | 17 | namespace stt 18 | { 19 | struct DBSHeader 20 | { 21 | unsigned int fileSize; 22 | unsigned int lineCount; 23 | unsigned int dataCount; 24 | unsigned int lineIndexOffset; 25 | unsigned int dataFormatOffset; 26 | unsigned int lineDataIndexOffset; 27 | unsigned int textOffset; 28 | 29 | DBSHeader() {} 30 | 31 | DBSHeader(std::vector& raw) 32 | { 33 | std::copy(raw.begin(), raw.begin() + sizeof(DBSHeader), reinterpret_cast(this)); 34 | } 35 | }; 36 | 37 | struct LineData 38 | { 39 | enum DataType 40 | { 41 | STRING, 42 | INT, 43 | } lineType; 44 | 45 | std::wstring stringData; 46 | int intData; 47 | }; 48 | 49 | unsigned char dbskey[] = { 0x2D, 0x62, 0xF4, 0x89, 0x2D, 0x62, 0xF4, 0x89, 0x2D, 0x62, 0xF4, 0x89, 0x2D, 0x62, 0xF4, 0x89 }; 50 | 51 | void ReadDecompressedDBS(IN std::vector& decomp, IN bool isUTF, IN int codePage, OUT DBSHeader& header, OUT std::vector& lineIndex, 52 | OUT std::vector& dataIndex, OUT std::vector& dataType, OUT std::vector>& lineData, bool koreanForceSpacing) 53 | { 54 | header = DBSHeader(decomp); 55 | 56 | lineIndex.resize(header.lineCount); // signed int 57 | std::copy(decomp.begin() + header.lineIndexOffset, decomp.begin() + header.lineIndexOffset + header.lineCount * sizeof(int), reinterpret_cast(&lineIndex[0])); 58 | 59 | for (unsigned int i = 0; i < header.dataCount; ++i) 60 | { 61 | unsigned int dataInfo[2]; //dataInfo[0] : dataIndex, dataInfo[1] : dataType 62 | std::copy(decomp.begin() + header.dataFormatOffset + sizeof(dataInfo) * i, decomp.begin() + header.dataFormatOffset + sizeof(dataInfo) * (i + 1), reinterpret_cast(&dataInfo[0])); 63 | 64 | dataIndex.push_back(dataInfo[0]); 65 | dataType.push_back(dataInfo[1]); 66 | } 67 | 68 | for (unsigned int i = 0; i < header.lineCount; ++i) 69 | { 70 | lineData.emplace_back(); 71 | 72 | for (unsigned int j = 0; j < header.dataCount; ++j) 73 | { 74 | LineData lineDataBlock; 75 | 76 | unsigned int tempData; 77 | 78 | std::copy(decomp.begin() + header.lineDataIndexOffset + sizeof(tempData) * (header.dataCount * i + j), decomp.begin() + header.lineDataIndexOffset + sizeof(tempData) * (header.dataCount * i + j + 1), reinterpret_cast(&tempData)); 79 | if (dataType[j] == 0x53) 80 | { 81 | if (isUTF) 82 | { 83 | wchar_t tempChar = 0; 84 | int loopCount = 0; 85 | 86 | std::copy(decomp.begin() + header.textOffset + tempData + sizeof(tempChar) * loopCount, decomp.begin() + header.textOffset + tempData + sizeof(tempChar) * (loopCount + 1), reinterpret_cast(&tempChar)); 87 | ++loopCount; 88 | 89 | bool kor = false; 90 | while (tempChar != L'\0') 91 | { 92 | if (!kor || tempChar != L' ') 93 | { 94 | lineDataBlock.stringData.push_back(tempChar); 95 | } 96 | 97 | if (koreanForceSpacing) 98 | { 99 | kor = false; 100 | 101 | if (tempChar >= L'가' && tempChar <= L'힣') 102 | { 103 | kor = true; 104 | } 105 | } 106 | std::copy(decomp.begin() + header.textOffset + tempData + sizeof(tempChar) * loopCount, decomp.begin() + header.textOffset + tempData + sizeof(tempChar) * (loopCount + 1), reinterpret_cast(&tempChar)); 107 | ++loopCount; 108 | } 109 | lineDataBlock.lineType = LineData::STRING; 110 | lineData[i].push_back(lineDataBlock); 111 | } 112 | else 113 | { 114 | /* This block has not been tested!! */ 115 | 116 | char tempChar = 0; 117 | int loopCount = 0; 118 | 119 | std::copy(decomp.begin() + header.textOffset + tempData + sizeof(tempChar) * loopCount, decomp.begin() + header.textOffset + tempData + sizeof(tempChar) * (loopCount + 1), reinterpret_cast(&tempChar)); 120 | ++loopCount; 121 | 122 | std::string tempString; 123 | while (tempChar != '\0') 124 | { 125 | tempString.push_back(tempChar); 126 | std::copy(decomp.begin() + header.textOffset + tempData + sizeof(tempChar) * loopCount, decomp.begin() + header.textOffset + tempData + sizeof(tempChar) * (loopCount + 1), reinterpret_cast(&tempChar)); 127 | ++loopCount; 128 | } 129 | lineDataBlock.lineType = LineData::STRING; 130 | int nLen = MultiByteToWideChar(codePage, 0, &tempString[0], tempString.size(), nullptr, NULL); 131 | lineDataBlock.stringData.resize(nLen); 132 | MultiByteToWideChar(codePage, 0, &tempString[0], tempString.size(), &lineDataBlock.stringData[0], nLen); 133 | lineData[i].push_back(lineDataBlock); 134 | } 135 | } 136 | else 137 | { 138 | lineDataBlock.lineType = LineData::INT; 139 | lineDataBlock.intData = tempData; 140 | lineData[i].push_back(lineDataBlock); 141 | } 142 | } 143 | } 144 | } 145 | 146 | void RepackDBS(std::wstring inFile, std::wstring outPath, int compressionLevel, int codePage, bool koreanForceSpacing) 147 | { 148 | std::wstring inFileDBX = getDirectory(inFile) + getPartialFileName(inFile) + L".dbx"; 149 | std::wstring inFileDXT = getDirectory(inFile) + getPartialFileName(inFile) + L".dxt"; 150 | 151 | std::wstring outFileDBS = outPath + getPartialFileName(inFile) + L".dbs"; 152 | 153 | std::ifstream ifStream; 154 | checkAvailablePath(inFileDBX); 155 | ifStream.open(inFileDBX, std::ios::binary); 156 | 157 | ifStream.seekg(0, std::ifstream::end); 158 | int size = static_cast(ifStream.tellg()); 159 | ifStream.seekg(0); 160 | 161 | std::vector decomp(size); 162 | ifStream.read(reinterpret_cast(&decomp[0]), size); 163 | ifStream.close(); 164 | 165 | bool isUTF = false; 166 | 167 | std::wifstream wifStream; 168 | checkAvailablePath(inFileDXT); 169 | wifStream.open(inFileDXT, std::ios::binary); 170 | 171 | wifStream.imbue(std::locale(wifStream.getloc(), new std::codecvt_utf16)); 172 | 173 | wifStream.seekg(0, std::ifstream::end); 174 | size = static_cast(wifStream.tellg()); 175 | wifStream.seekg(0); 176 | if (size < 2) 177 | { 178 | std::wcout << getFileName(inFileDXT) << " is corrupted." << std::endl; 179 | wifStream.close(); 180 | throw(ERR_INVALID_FILE); 181 | } 182 | 183 | std::wstring head; 184 | std::getline(wifStream, head); 185 | if (!head.empty() && head.back() == L'\r') 186 | head.pop_back(); 187 | if (head == L"ASCII") 188 | isUTF = false; 189 | else if (head == L"Unicode") 190 | isUTF = true; 191 | else 192 | { 193 | std::wcout << getFileName(inFileDXT) << " is corrupted." << std::endl; 194 | wifStream.close(); 195 | throw(ERR_INVALID_FILE); 196 | } 197 | 198 | if (isUTF && codePage != 932) 199 | { 200 | std::wcout << "The encoding of this file is UTF-16. The codepage option is ignored." << std::endl; 201 | } 202 | 203 | DBSHeader header; 204 | std::vector lineIndex; 205 | std::vector dataIndex; 206 | std::vector dataType; 207 | std::vector> lineData; 208 | 209 | ReadDecompressedDBS(decomp, isUTF, codePage, header, lineIndex, dataIndex, dataType, lineData, koreanForceSpacing); 210 | 211 | int index = 0, correctIndex = 0, count = 0, correctCount = 0; 212 | 213 | while (!wifStream.eof()) 214 | { 215 | std::wstring line; 216 | std::getline(wifStream, line); 217 | if (!line.empty() && line.back() == L'\r') 218 | line.pop_back(); 219 | 220 | if (line.empty()) 221 | continue; 222 | else if (line[0] == L'[') 223 | { 224 | int closeBracketPos = line.find(L']',1); 225 | if (closeBracketPos == std::wstring::npos) 226 | { 227 | continue; 228 | } 229 | 230 | index = stoi(std::wstring(line.begin() + 1, line.begin() + closeBracketPos)); 231 | std::vector::iterator it = std::find(lineIndex.begin(), lineIndex.end(), index); 232 | if (it == lineIndex.end()) 233 | continue; 234 | 235 | correctIndex = std::distance(lineIndex.begin(), it); 236 | } 237 | else if (line[0] == L'●') 238 | { 239 | int closeBracketPos = line.find(L'●', 1); 240 | if (closeBracketPos == std::wstring::npos) 241 | { 242 | continue; 243 | } 244 | 245 | count = stoi(std::wstring(line.begin() + 1, line.begin() + closeBracketPos)); 246 | std::vector::iterator it = std::find(dataIndex.begin(), dataIndex.end(), count); 247 | if (it == dataIndex.end()) 248 | continue; 249 | 250 | correctCount = std::distance(dataIndex.begin(), it); 251 | 252 | line = std::wstring(line.begin() + line.find(L'●', 1) + 1, line.end()); 253 | 254 | int commentBracketIndex[2] = { 0,0 }; 255 | commentBracketIndex[0] = line.find(L"/*"); 256 | commentBracketIndex[1] = line.find(L"*/"); 257 | 258 | if (commentBracketIndex[0] != std::wstring::npos && commentBracketIndex[1] != std::wstring::npos && commentBracketIndex[0] < commentBracketIndex[1]) 259 | { 260 | line.erase(commentBracketIndex[0], commentBracketIndex[1] - commentBracketIndex[0] + 2); 261 | } 262 | 263 | 264 | bool fixSpacing = false; 265 | std::wstring fixSpacingCommand = L"%%{fix_spacing}:"; 266 | if (line.length() >= fixSpacingCommand.length() && line.substr(0, fixSpacingCommand.length()) == fixSpacingCommand) 267 | { 268 | fixSpacing = true; 269 | line.erase(0, fixSpacingCommand.length()); 270 | } 271 | 272 | if (!fixSpacing && isUTF && koreanForceSpacing) 273 | { 274 | std::wstring line2; 275 | for (wchar_t ch : line) 276 | { 277 | line2.push_back(ch); 278 | if (ch>= L'가' && ch <= L'힣') 279 | { 280 | line2 += L' '; 281 | } 282 | } 283 | line = line2; 284 | } 285 | 286 | lineData[correctIndex][correctCount].stringData = line; 287 | } 288 | } 289 | 290 | std::stringstream dbs; 291 | 292 | dbs.write(reinterpret_cast(&header), sizeof(header)); 293 | dbs.write(reinterpret_cast(&lineIndex[0]), header.lineCount * sizeof(int)); 294 | 295 | 296 | for (unsigned int i = 0; i < header.dataCount; ++i) 297 | { 298 | dbs.write(reinterpret_cast(&dataIndex[i]), sizeof(unsigned int)); 299 | dbs.write(reinterpret_cast(&dataType[i]), sizeof(unsigned int)); 300 | } 301 | std::vector textData; 302 | int textOffset=0; 303 | 304 | for (unsigned int i = 0; i < header.lineCount; ++i) 305 | { 306 | for (unsigned int j = 0; j < header.dataCount; ++j) 307 | { 308 | if (dataType[j] == 0x53) 309 | { 310 | std::vector tempString; 311 | if (isUTF) 312 | { 313 | tempString.assign(reinterpret_cast(&lineData[i][j].stringData[0]), 314 | reinterpret_cast(&lineData[i][j].stringData[0]) 315 | + lineData[i][j].stringData.length() * sizeof(wchar_t)); 316 | tempString.push_back('\x00'); 317 | tempString.push_back('\x00'); 318 | } 319 | else 320 | { 321 | /* This block has not been tested!! */ 322 | 323 | int len = WideCharToMultiByte(codePage, 0, &lineData[i][j].stringData[0], -1, nullptr, 0, nullptr, nullptr); 324 | std::string strMulti(len, 0); 325 | WideCharToMultiByte(codePage, 0, &lineData[i][j].stringData[0], -1, &strMulti[0], len, nullptr, nullptr); 326 | 327 | tempString.assign(reinterpret_cast(&strMulti[0]), 328 | reinterpret_cast(&strMulti[0]) 329 | + strMulti.length() * sizeof(char)); 330 | //tempString.push_back('\x00'); -> Unnecessary 331 | } 332 | dbs.write(reinterpret_cast(&textOffset), sizeof(int)); 333 | textData.insert(textData.end(), tempString.begin(), tempString.end()); 334 | textOffset += tempString.size(); 335 | } 336 | else 337 | dbs.write(reinterpret_cast(&lineData[i][j].intData), sizeof(int)); 338 | } 339 | } 340 | 341 | dbs.write(reinterpret_cast(&textData[0]), textData.size()); 342 | unsigned int dbsSize = static_cast(dbs.tellp()); 343 | dbs.seekp(0); 344 | dbs.write(reinterpret_cast(&dbsSize), sizeof(unsigned int)); 345 | dbs.seekp(0, std::stringstream::end); 346 | 347 | /* 348 | // BUG : Script truncation occurred. 349 | // This solved by setting the default size of the dummy to 64 or more. 350 | */ 351 | 352 | // std::vector dummy(32-dbsSize%32, 0); 353 | std::vector dummy(64-dbsSize%32, 0); 354 | 355 | dbs.write(reinterpret_cast(&dummy[0]), dummy.size()); 356 | 357 | std::string rawstr = dbs.str(); 358 | std::vector rawData; 359 | rawData.assign(reinterpret_cast(&rawstr[0]), 360 | reinterpret_cast(&rawstr[0]) 361 | + rawstr.length() * sizeof(char)); 362 | 363 | decrypt3(&rawData[0], rawData.size()); 364 | 365 | std::vector comp; 366 | if (compressionLevel > 0) 367 | { 368 | int newSize = 0; 369 | unsigned char* compDataPtr = compress(&rawData[0], rawData.size(), &newSize, compressionLevel); 370 | comp.assign(compDataPtr, compDataPtr + newSize); 371 | } 372 | else 373 | { 374 | /* This block has not been tested!! */ 375 | 376 | int prevSize = rawData.size(); 377 | int newSize = prevSize + int(prevSize / 8) + 8; 378 | if (prevSize % 8 != 0) 379 | newSize += 1; 380 | comp.resize(newSize - 8, 0); 381 | comp.insert(comp.begin(), reinterpret_cast(&newSize), reinterpret_cast(&newSize) + sizeof(int)); 382 | comp.insert(comp.begin() + sizeof(int), reinterpret_cast(&prevSize), reinterpret_cast(&prevSize) + sizeof(int)); 383 | fakeCompress(&decomp[0], &comp[0], prevSize); 384 | } 385 | 386 | decrypt1(&comp[0], comp.size(), dbskey, true); 387 | 388 | std::ofstream ofStream; 389 | checkAvailablePath(outFileDBS, true); 390 | ofStream.open(outFileDBS, std::ios::binary); 391 | 392 | ofStream.write(isUTF ? "\x01\x00\x00\x00" : "\x00\x00\x00\x00", 4); 393 | ofStream.write(reinterpret_cast(&comp[0]), comp.size()); 394 | ofStream.close(); 395 | } 396 | 397 | void UnpackDBS(std::wstring inFile, std::wstring outPath, bool useComment, int codePage, bool koreanForceSpacing) 398 | { 399 | std::wstring outFileDBX = outPath + getPartialFileName(inFile) + L".dbx"; 400 | std::wstring outFileDXT = outPath + getPartialFileName(inFile) + L".dxt"; 401 | 402 | std::ifstream ifStream; 403 | checkAvailablePath(inFile); 404 | ifStream.open(inFile, std::ios::binary); 405 | 406 | ifStream.seekg(0, std::ifstream::end); 407 | int size = static_cast(ifStream.tellg()); 408 | ifStream.seekg(0); 409 | 410 | std::vector buf(size); 411 | ifStream.read(reinterpret_cast(&buf[0]), size); 412 | ifStream.close(); 413 | 414 | std::ofstream ofStream; 415 | bool isUTF = (buf[0] == '\x00' && buf[1] == '\x00' && buf[2] == '\x00' && buf[3] == '\x00') ? false : true; 416 | 417 | if (isUTF && codePage != 932) 418 | { 419 | std::wcout << "The encoding of this file is UTF-16. The codepage option is ignored." << std::endl; 420 | } 421 | 422 | buf = std::vector(buf.begin() + 4, buf.end()); 423 | 424 | decrypt1(&buf[0], buf.size(), dbskey, true); 425 | 426 | int compSize; 427 | std::copy(buf.begin(), buf.begin() + sizeof(int), reinterpret_cast(&compSize)); 428 | 429 | int decompSize; 430 | std::copy(buf.begin() + sizeof(int), buf.begin() + sizeof(int) * 2, reinterpret_cast(&decompSize)); 431 | 432 | buf = std::vector(buf.begin() + 8, buf.end()); 433 | 434 | std::vector decomp(decompSize+DECOMP_SIZE_PADDING); 435 | 436 | decompress(&buf[0], &decomp[0], decompSize); 437 | 438 | decrypt3(&decomp[0], decompSize); 439 | 440 | checkAvailablePath(outFileDBX, true); 441 | ofStream.open(outFileDBX, std::ios::binary); 442 | 443 | ofStream.write(reinterpret_cast(&decomp[0]), decompSize); 444 | 445 | ofStream.close(); 446 | 447 | DBSHeader header; 448 | std::vector lineIndex; 449 | std::vector dataIndex; 450 | std::vector dataType; 451 | std::vector> lineData; 452 | 453 | ReadDecompressedDBS(decomp, isUTF, codePage, header, lineIndex, dataIndex, dataType, lineData, koreanForceSpacing); 454 | 455 | std::wofstream wofStream; 456 | checkAvailablePath(outFileDXT, true); 457 | wofStream.open(outFileDXT, std::ios::binary); 458 | wofStream.imbue(std::locale(wofStream.getloc(), new std::codecvt_utf16)); 459 | 460 | if (isUTF) 461 | wofStream << L"Unicode\r\n"; 462 | else 463 | wofStream << L"ASCII\r\n"; 464 | 465 | for (unsigned int i = 0; i < header.lineCount; ++i) 466 | { 467 | wofStream << L"[" << std::internal << std::setw(4) << std::setfill(L'0') << lineIndex[i] << L"]\r\n"; 468 | for (unsigned int j = 0; j < header.dataCount; ++j) 469 | { 470 | if (dataType[j] == 0x53 && !lineData[i][j].stringData.empty()) 471 | { 472 | if (useComment) 473 | wofStream << L"○" << std::internal << std::setw(2) << std::setfill(L'0') << dataIndex[j] << L"○" << lineData[i][j].stringData << L"\r\n●" << std::setw(2) << std::setfill(L'0') << dataIndex[j] << L"●" << lineData[i][j].stringData << L"\r\n\r\n"; 474 | else 475 | wofStream << L"●" << std::internal << std::setw(2) << std::setfill(L'0') << dataIndex[j] << L"●" << lineData[i][j].stringData << L"\r\n"; 476 | } 477 | } 478 | wofStream << L"\r\n"; 479 | } 480 | wofStream.close(); 481 | } 482 | } 483 | #endif //INCLUDE_DBST -------------------------------------------------------------------------------- /SiglusTranslationToolkit/skf/SiglusKeyFinder.cs: -------------------------------------------------------------------------------- 1 | /* =============================================== 2 | This source code referenced the following Repo: 3 | https://github.com/marcussacana/SiglusSceneManager 4 | ================================================== */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Diagnostics; 9 | using System.IO; 10 | using System.Linq; 11 | using System.Text; 12 | 13 | namespace SiglusKeyFinder 14 | { 15 | public class KeyFinder { 16 | //A0 ? ? ? ? 17 | //MOV AL, OFF; 18 | 19 | /* 20 | MOVZX 0F B6 + 21 | 0D = ECX 22 | 15 = EDX 23 | 1D = EBX 24 | 25 = ESP 25 | 2D = EBP 26 | 35 = ESI 27 | 3D = EDI 28 | + DWORD; 29 | 30 | E?? = 32Bits == 0x11223344 31 | ?X = 16Bits == 0x1122 32 | ?H = 8Bits == 0x33 33 | ?L = 8Bits == 0x44 34 | 35 | MOV_Long 88 ?? 36 | 84 == AL 37 | 9C == BL 38 | 8C == CL 39 | 94 == DL 40 | + 24 + DWORD 41 | MOV OFFSET, Register; 42 | ^------- 43 | */ 44 | 45 | public static Key[] ReadProcess(int PID) { 46 | Stream Memory = ProcessDump.OpenProcess(PID); 47 | Key[] Keys = ReadManually(Memory, (int)ProcessDump.BASEADDRESS); 48 | Memory.Close(); 49 | File.Delete(ProcessDump.FILE); 50 | return Keys; 51 | } 52 | 53 | public static Key[] ReadManually(Stream Stream, int baseAddress) { 54 | return Process(Stream, baseAddress); 55 | } 56 | public static Key[] ReadFromPD(string ProcessDump) { 57 | string[] arr = Path.GetFileNameWithoutExtension(ProcessDump).Split('_'); 58 | int Base; 59 | try { 60 | Base = int.Parse(arr[arr.Length - 1], System.Globalization.NumberStyles.HexNumber); 61 | } 62 | catch { return null; } 63 | return Process(new StreamReader(ProcessDump).BaseStream, Base); 64 | } 65 | private static Key[] Process(Stream Memory, int BASEOFFSET) { 66 | Result[] Results = Scan(Memory, Alg1Cmds, Algorithm.Type1); 67 | Result[] Results2 = Scan(Memory, Alg2Cmds, Algorithm.Type2); 68 | List Keys = new List(); 69 | foreach (Result Result in Results.Concat(Results2)) 70 | switch (Result.Type) { 71 | case Algorithm.Type1: 72 | Keys.Add(Interpreter(Result.Buffer, new BinaryReader(Memory), Alg1Cmds, BASEOFFSET)); 73 | break; 74 | case Algorithm.Type2: 75 | Keys.Add(Interpreter(Result.Buffer, new BinaryReader(Memory), Alg2Cmds, BASEOFFSET)); 76 | break; 77 | } 78 | return Keys.ToArray(); 79 | } 80 | 81 | private static Key Interpreter(byte[] buffer, BinaryReader Mem, Command[] Cmds, int BASEOFFSET) { 82 | RegisterEmu Reg = new RegisterEmu(); 83 | Dictionary Stack = new Dictionary(); 84 | for (int i = 0, StepPos = 0; StepPos < Cmds.Length; StepPos++) { 85 | Command Step = Cmds[StepPos]; 86 | Register REG; 87 | int Pointer; 88 | switch (Step) { 89 | case Command.MOVXZ: 90 | REG = ((Register)buffer[i + 2]); 91 | Pointer = GetDW(buffer, i + 3) - BASEOFFSET; 92 | Mem.BaseStream.Position = Pointer; 93 | Mem.BaseStream.Flush(); 94 | Reg[REG] = Mem.ReadInt32(); 95 | break; 96 | case Command.MOV_L: 97 | REG = ((Register)buffer[i + 1]); 98 | Pointer = GetDW(buffer, i + 3); 99 | Stack.Add(Pointer, (byte)Reg[REG]); 100 | break; 101 | case Command.MOV_M: 102 | REG = Register.AL; 103 | Pointer = GetDW(buffer, i + 1) - BASEOFFSET; 104 | Mem.BaseStream.Position = Pointer; 105 | Reg[REG] = Mem.ReadByte(); 106 | break; 107 | case Command.MOV_S: 108 | REG = Register.AL; 109 | int Pos = Tools.int8(buffer[i + 2]); 110 | Stack.Add(Pos, (byte)Reg[REG]); 111 | break; 112 | case Command.MOV_ESI: 113 | //We can ignore the MOV ESI, DS. 114 | break; 115 | } 116 | i += GetLen(Step); 117 | } 118 | int[] Keys = Stack.Keys.ToArray(); 119 | byte[] Values = Stack.Values.ToArray(); 120 | Array.Sort(Keys, Values); 121 | return new Key(Values); 122 | } 123 | 124 | private static int GetDW(byte[] Buff, int pos) => Tools.int32(new byte[] { Buff[pos], Buff[pos + 1], Buff[pos + 2], Buff[pos + 3] }); 125 | enum Command { 126 | MOVXZ, MOV_L, MOV_M, MOV_S, MOV_ESI 127 | } 128 | 129 | private static int GetLen(Command Type) { 130 | switch (Type){ 131 | case Command.MOV_L: 132 | case Command.MOVXZ: 133 | return 7; 134 | case Command.MOV_M: 135 | return 5; 136 | case Command.MOV_ESI: 137 | return 6; 138 | case Command.MOV_S: 139 | return 3; 140 | default: 141 | throw new Exception("Unsupported Command"); 142 | } 143 | } 144 | 145 | static Command[] Alg1Cmds = new Command[] { 146 | Command.MOVXZ, Command.MOVXZ, 147 | Command.MOVXZ, Command.MOV_L, 148 | Command.MOVXZ, Command.MOV_L, 149 | Command.MOVXZ, Command.MOV_L, 150 | Command.MOVXZ, Command.MOV_L, 151 | Command.MOVXZ, Command.MOV_L, 152 | Command.MOVXZ, Command.MOV_L, 153 | Command.MOVXZ, Command.MOV_L, 154 | Command.MOVXZ, Command.MOV_L, 155 | Command.MOVXZ, Command.MOV_L, 156 | Command.MOVXZ, Command.MOV_L, 157 | Command.MOVXZ, Command.MOV_L, 158 | Command.MOVXZ, Command.MOV_L, 159 | Command.MOVXZ, Command.MOV_L, 160 | Command.MOVXZ, Command.MOV_L, 161 | Command.MOV_L, Command.MOV_L 162 | }; 163 | 164 | static Command[] Alg2Cmds = new Command[] { 165 | Command.MOV_M, Command.MOV_S, 166 | Command.MOV_M, Command.MOV_S, 167 | Command.MOV_M, Command.MOV_S, 168 | Command.MOV_M, Command.MOV_S, 169 | Command.MOV_M, Command.MOV_S, 170 | Command.MOV_M, Command.MOV_S, 171 | Command.MOV_M, Command.MOV_S, 172 | Command.MOV_M, Command.MOV_S, 173 | Command.MOV_M, Command.MOV_S, 174 | Command.MOV_M, Command.MOV_S, 175 | Command.MOV_M, Command.MOV_S, 176 | Command.MOV_M, Command.MOV_S, 177 | Command.MOV_M, Command.MOV_S, 178 | Command.MOV_M, Command.MOV_S, 179 | Command.MOV_M, Command.MOV_S, 180 | Command.MOV_M, Command.MOV_ESI, 181 | Command.MOV_S 182 | }; 183 | 184 | private static Result[] Scan(Stream Mem, Command[] Cmds, Algorithm Type) { 185 | List Results = new List(); 186 | byte Header = GetCmdByte(Cmds[0]); 187 | for (long i = 0; i < Mem.Length - 1024; i = Mem.Position) { 188 | byte[] Buffer = new byte[1024]; 189 | Mem.Read(Buffer, 0, Buffer.Length); 190 | bool Found = SearchByte(ref Mem, Buffer, Header); 191 | 192 | if (Found) { 193 | Buffer = new byte[300]; 194 | Peek(ref Buffer, Mem); 195 | if (AlgValidate(Buffer, Cmds)) { 196 | Results.Add(new Result() { 197 | Buffer = Buffer, 198 | Type = Type 199 | }); 200 | Mem.Position += GetAlgLen(Cmds); 201 | } else 202 | Mem.Position++; 203 | } 204 | } 205 | Mem.Position = 0; 206 | return Results.ToArray(); 207 | } 208 | 209 | private static void Peek(ref byte[] Buffer, Stream Mem) { 210 | long pos = Mem.Position; 211 | Mem.Read(Buffer, 0, Buffer.Length); 212 | Mem.Position = pos; 213 | } 214 | 215 | private static bool SearchByte(ref Stream Mem, byte[] Buffer, byte Byte) { 216 | for (int x = 0; x < Buffer.Length; x++) { 217 | if (Buffer[x] == Byte) { 218 | Mem.Position -= Buffer.Length; 219 | Mem.Position += x; 220 | Mem.Flush(); 221 | return true; 222 | } 223 | } 224 | return false; 225 | } 226 | 227 | private static byte GetCmdByte(Command Cmd) { 228 | switch (Cmd) { 229 | case Command.MOVXZ: 230 | return 0x0F; 231 | case Command.MOV_L: 232 | case Command.MOV_S: 233 | return 0x88; 234 | case Command.MOV_ESI: 235 | return 0x8B; 236 | case Command.MOV_M: 237 | return 0xA0; 238 | default: 239 | throw new Exception("Unsupported Command"); 240 | } 241 | } 242 | private static int GetAlgLen(Command[] Cmds) { 243 | int LEN = 0; 244 | foreach (Command cmd in Cmds) 245 | LEN += GetLen(cmd); 246 | return LEN; 247 | } 248 | 249 | private static bool AlgType1Test(byte[] Buffer) { 250 | int StepPos = 0; 251 | for (int Pos = 0; StepPos < Alg1Cmds.Length; StepPos++) { 252 | Command Step = Alg1Cmds[StepPos]; 253 | if (Step == Command.MOVXZ ? !Tools.isMOVZX(Buffer, Pos) : !Tools.isLongMOV(Buffer, Pos)) 254 | return false; 255 | Pos += GetLen(Step); 256 | } 257 | return true; 258 | } 259 | 260 | private static bool AlgValidate(byte[] Buffer, Command[] Cmds) { 261 | int StepPos = 0; 262 | for (int Pos = 0; StepPos < Cmds.Length; StepPos++) { 263 | Command Step = Cmds[StepPos]; 264 | switch (Step) { 265 | case Command.MOVXZ: 266 | if (!Tools.isMOVZX(Buffer, Pos)) 267 | return false; 268 | break; 269 | case Command.MOV_L: 270 | if (!Tools.isLongMOV(Buffer, Pos)) 271 | return false; 272 | break; 273 | case Command.MOV_M: 274 | if (!Tools.IsMOVAL(Buffer, Pos)) 275 | return false; 276 | break; 277 | case Command.MOV_ESI: 278 | if (!Tools.IsMOVESI(Buffer, Pos)) 279 | return false; 280 | break; 281 | case Command.MOV_S: 282 | if (!Tools.IsMOVDS(Buffer, Pos)) 283 | return false; 284 | break; 285 | } 286 | Pos += GetLen(Step); 287 | } 288 | return true; 289 | } 290 | 291 | public class Key { 292 | public byte[] KEY { get; private set; } 293 | 294 | internal Key(byte[] KEY) { 295 | this.KEY = KEY; 296 | } 297 | 298 | public string KeyStr { 299 | get { 300 | string Hex = string.Empty; 301 | for (int i = 0; i < KEY.Length; i++) { 302 | string H = KEY[i].ToString("X"); 303 | Hex += (H.Length == 1 ? "0x0" : "0x") + H + ", "; 304 | } 305 | return Hex.Substring(0, Hex.Length - 2); 306 | } 307 | } 308 | } 309 | 310 | 311 | private struct Result { 312 | public byte[] Buffer; 313 | public Algorithm Type; 314 | } 315 | private enum Algorithm { 316 | Type1, Type2 317 | } 318 | } 319 | 320 | 321 | internal static class Tools { 322 | internal static bool isMOVZX(byte[] Buff, int Pos) { 323 | byte b = Buff[Pos], b2 = Buff[Pos + 1], b3 = Buff[Pos + 2]; 324 | return b == 0x0F && b2 == 0xB6 && (b3 == 0x5 || b3 == 0xD || b3 == 0x15); 325 | } 326 | internal static bool isLongMOV(byte[] Buffer, int Pos) { 327 | byte b = Buffer[Pos + 1]; 328 | int h = b >> 4; 329 | int l = b & 0xF; 330 | return ((h >= 8 && h <= 0xB) && (l == 0x4 || l == 0xC)) && Buffer[Pos] == 0x88; 331 | } 332 | internal static int int8(byte b) { 333 | return sbyte.Parse(b.ToString("x"), System.Globalization.NumberStyles.HexNumber); 334 | } 335 | internal static int int32(byte[] arr) { 336 | if (!BitConverter.IsLittleEndian) 337 | Array.Reverse(arr, 0, arr.Length); 338 | int p = BitConverter.ToInt32(arr, 0); 339 | return p; 340 | } 341 | 342 | internal static bool IsMOVAL(byte[] Buffer, int pos) { 343 | return Buffer[pos] == 0xA0; 344 | } 345 | internal static bool IsMOVDS(byte[] Buffer, int pos) { 346 | return Buffer[pos] == 0x88 && !Tools.isLongMOV(Buffer, pos); 347 | } 348 | internal static bool IsMOVESI(byte[] Buffer, int pos) { 349 | return Buffer[pos] == 0x8B; 350 | } 351 | } 352 | internal class RegisterEmu { 353 | int EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI, EXTRA; 354 | internal int this[Register Reg] { 355 | get { 356 | switch (Reg) { 357 | case Register.EAX: 358 | return EAX; 359 | case Register.EBP: 360 | return EBP; 361 | case Register.EBX: 362 | return EBX; 363 | case Register.ECX: 364 | return ECX; 365 | case Register.EDI: 366 | return EDI; 367 | case Register.EDX: 368 | return EDX; 369 | case Register.ESI: 370 | return ESI; 371 | case Register.ESP: 372 | return ESP; 373 | case Register.Unk: 374 | return EXTRA; 375 | case Register.AL: 376 | return EAX & 0x000000FF; 377 | case Register.BL: 378 | return EBX & 0x000000FF; 379 | case Register.CL: 380 | return ECX & 0x000000FF; 381 | case Register.DL: 382 | return EDX & 0x000000FF; 383 | default: 384 | throw new Exception("Unsupported Register"); 385 | } 386 | } 387 | set { 388 | switch (Reg) { 389 | case Register.EAX: 390 | EAX = value; 391 | break; 392 | case Register.EBP: 393 | EBP = value; 394 | break; 395 | case Register.EBX: 396 | EBX = value; 397 | break; 398 | case Register.ECX: 399 | ECX = value; 400 | break; 401 | case Register.EDI: 402 | EDI = value; 403 | break; 404 | case Register.EDX: 405 | EDX = value; 406 | break; 407 | case Register.ESI: 408 | ESI = value; 409 | break; 410 | case Register.ESP: 411 | ESP = value; 412 | break; 413 | case Register.AL: 414 | EAX = value & 0x000000FF; 415 | break; 416 | case Register.BL: 417 | EBX = value & 0x000000FF; 418 | break; 419 | case Register.CL: 420 | ECX = value & 0x000000FF; 421 | break; 422 | case Register.DL: 423 | EDX = value & 0x000000FF; 424 | break; 425 | case Register.Unk: 426 | EXTRA = value; 427 | break; 428 | default: 429 | throw new Exception("Unsupported Register"); 430 | } 431 | } 432 | } 433 | } 434 | internal enum Register { 435 | //MovZX 436 | EAX = 0x05, ECX = 0x0D, 437 | EDX = 0x15, EBX = 0x1D, 438 | ESP = 0x25, EBP = 0x2D, 439 | ESI = 0x35, EDI = 0x3D, 440 | //Mov Long 441 | AL = 0x84, BL = 0x9C, 442 | CL = 0x8C, DL = 0x94, 443 | //Unknowk 444 | Unk = -1 445 | } 446 | } 447 | -------------------------------------------------------------------------------- /ExternelLib/include/libogg/ogg/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.13.4 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | 17 | VPATH = @srcdir@ 18 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' 19 | am__make_running_with_option = \ 20 | case $${target_option-} in \ 21 | ?) ;; \ 22 | *) echo "am__make_running_with_option: internal error: invalid" \ 23 | "target option '$${target_option-}' specified" >&2; \ 24 | exit 1;; \ 25 | esac; \ 26 | has_opt=no; \ 27 | sane_makeflags=$$MAKEFLAGS; \ 28 | if $(am__is_gnu_make); then \ 29 | sane_makeflags=$$MFLAGS; \ 30 | else \ 31 | case $$MAKEFLAGS in \ 32 | *\\[\ \ ]*) \ 33 | bs=\\; \ 34 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 35 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 36 | esac; \ 37 | fi; \ 38 | skip_next=no; \ 39 | strip_trailopt () \ 40 | { \ 41 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 42 | }; \ 43 | for flg in $$sane_makeflags; do \ 44 | test $$skip_next = yes && { skip_next=no; continue; }; \ 45 | case $$flg in \ 46 | *=*|--*) continue;; \ 47 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 48 | -*I?*) strip_trailopt 'I';; \ 49 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 50 | -*O?*) strip_trailopt 'O';; \ 51 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 52 | -*l?*) strip_trailopt 'l';; \ 53 | -[dEDm]) skip_next=yes;; \ 54 | -[JT]) skip_next=yes;; \ 55 | esac; \ 56 | case $$flg in \ 57 | *$$target_option*) has_opt=yes; break;; \ 58 | esac; \ 59 | done; \ 60 | test $$has_opt = yes 61 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 62 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 63 | pkgdatadir = $(datadir)/@PACKAGE@ 64 | pkgincludedir = $(includedir)/@PACKAGE@ 65 | pkglibdir = $(libdir)/@PACKAGE@ 66 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 67 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 68 | install_sh_DATA = $(install_sh) -c -m 644 69 | install_sh_PROGRAM = $(install_sh) -c 70 | install_sh_SCRIPT = $(install_sh) -c 71 | INSTALL_HEADER = $(INSTALL_DATA) 72 | transform = $(program_transform_name) 73 | NORMAL_INSTALL = : 74 | PRE_INSTALL = : 75 | POST_INSTALL = : 76 | NORMAL_UNINSTALL = : 77 | PRE_UNINSTALL = : 78 | POST_UNINSTALL = : 79 | build_triplet = @build@ 80 | host_triplet = @host@ 81 | subdir = include/ogg 82 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ 83 | $(srcdir)/config_types.h.in $(ogginclude_HEADERS) 84 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 85 | am__aclocal_m4_deps = $(top_srcdir)/configure.in 86 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 87 | $(ACLOCAL_M4) 88 | mkinstalldirs = $(install_sh) -d 89 | CONFIG_HEADER = $(top_builddir)/config.h 90 | CONFIG_CLEAN_FILES = config_types.h 91 | CONFIG_CLEAN_VPATH_FILES = 92 | AM_V_P = $(am__v_P_@AM_V@) 93 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 94 | am__v_P_0 = false 95 | am__v_P_1 = : 96 | AM_V_GEN = $(am__v_GEN_@AM_V@) 97 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 98 | am__v_GEN_0 = @echo " GEN " $@; 99 | am__v_GEN_1 = 100 | AM_V_at = $(am__v_at_@AM_V@) 101 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 102 | am__v_at_0 = @ 103 | am__v_at_1 = 104 | SOURCES = 105 | DIST_SOURCES = 106 | am__can_run_installinfo = \ 107 | case $$AM_UPDATE_INFO_DIR in \ 108 | n|no|NO) false;; \ 109 | *) (install-info --version) >/dev/null 2>&1;; \ 110 | esac 111 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 112 | am__vpath_adj = case $$p in \ 113 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 114 | *) f=$$p;; \ 115 | esac; 116 | am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; 117 | am__install_max = 40 118 | am__nobase_strip_setup = \ 119 | srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` 120 | am__nobase_strip = \ 121 | for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" 122 | am__nobase_list = $(am__nobase_strip_setup); \ 123 | for p in $$list; do echo "$$p $$p"; done | \ 124 | sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ 125 | $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ 126 | if (++n[$$2] == $(am__install_max)) \ 127 | { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ 128 | END { for (dir in files) print dir, files[dir] }' 129 | am__base_list = \ 130 | sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ 131 | sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' 132 | am__uninstall_files_from_dir = { \ 133 | test -z "$$files" \ 134 | || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ 135 | || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ 136 | $(am__cd) "$$dir" && rm -f $$files; }; \ 137 | } 138 | am__installdirs = "$(DESTDIR)$(oggincludedir)" \ 139 | "$(DESTDIR)$(oggincludedir)" 140 | HEADERS = $(nodist_ogginclude_HEADERS) $(ogginclude_HEADERS) 141 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 142 | # Read a list of newline-separated strings from the standard input, 143 | # and print each of them once, without duplicates. Input order is 144 | # *not* preserved. 145 | am__uniquify_input = $(AWK) '\ 146 | BEGIN { nonempty = 0; } \ 147 | { items[$$0] = 1; nonempty = 1; } \ 148 | END { if (nonempty) { for (i in items) print i; }; } \ 149 | ' 150 | # Make sure the list of sources is unique. This is necessary because, 151 | # e.g., the same source file might be shared among _SOURCES variables 152 | # for different programs/libraries. 153 | am__define_uniq_tagged_files = \ 154 | list='$(am__tagged_files)'; \ 155 | unique=`for i in $$list; do \ 156 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 157 | done | $(am__uniquify_input)` 158 | ETAGS = etags 159 | CTAGS = ctags 160 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 161 | ACLOCAL = @ACLOCAL@ 162 | AMTAR = @AMTAR@ 163 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 164 | AR = @AR@ 165 | AUTOCONF = @AUTOCONF@ 166 | AUTOHEADER = @AUTOHEADER@ 167 | AUTOMAKE = @AUTOMAKE@ 168 | AWK = @AWK@ 169 | CC = @CC@ 170 | CCDEPMODE = @CCDEPMODE@ 171 | CFLAGS = @CFLAGS@ 172 | CPP = @CPP@ 173 | CPPFLAGS = @CPPFLAGS@ 174 | CYGPATH_W = @CYGPATH_W@ 175 | DEBUG = @DEBUG@ 176 | DEFS = @DEFS@ 177 | DEPDIR = @DEPDIR@ 178 | DLLTOOL = @DLLTOOL@ 179 | DSYMUTIL = @DSYMUTIL@ 180 | DUMPBIN = @DUMPBIN@ 181 | ECHO_C = @ECHO_C@ 182 | ECHO_N = @ECHO_N@ 183 | ECHO_T = @ECHO_T@ 184 | EGREP = @EGREP@ 185 | EXEEXT = @EXEEXT@ 186 | FGREP = @FGREP@ 187 | GREP = @GREP@ 188 | INCLUDE_INTTYPES_H = @INCLUDE_INTTYPES_H@ 189 | INCLUDE_STDINT_H = @INCLUDE_STDINT_H@ 190 | INCLUDE_SYS_TYPES_H = @INCLUDE_SYS_TYPES_H@ 191 | INSTALL = @INSTALL@ 192 | INSTALL_DATA = @INSTALL_DATA@ 193 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 194 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 195 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 196 | LD = @LD@ 197 | LDFLAGS = @LDFLAGS@ 198 | LIBOBJS = @LIBOBJS@ 199 | LIBS = @LIBS@ 200 | LIBTOOL = @LIBTOOL@ 201 | LIBTOOL_DEPS = @LIBTOOL_DEPS@ 202 | LIB_AGE = @LIB_AGE@ 203 | LIB_CURRENT = @LIB_CURRENT@ 204 | LIB_REVISION = @LIB_REVISION@ 205 | LIPO = @LIPO@ 206 | LN_S = @LN_S@ 207 | LTLIBOBJS = @LTLIBOBJS@ 208 | MAINT = @MAINT@ 209 | MAKEINFO = @MAKEINFO@ 210 | MANIFEST_TOOL = @MANIFEST_TOOL@ 211 | MKDIR_P = @MKDIR_P@ 212 | NM = @NM@ 213 | NMEDIT = @NMEDIT@ 214 | OBJDUMP = @OBJDUMP@ 215 | OBJEXT = @OBJEXT@ 216 | OPT = @OPT@ 217 | OTOOL = @OTOOL@ 218 | OTOOL64 = @OTOOL64@ 219 | PACKAGE = @PACKAGE@ 220 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 221 | PACKAGE_NAME = @PACKAGE_NAME@ 222 | PACKAGE_STRING = @PACKAGE_STRING@ 223 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 224 | PACKAGE_URL = @PACKAGE_URL@ 225 | PACKAGE_VERSION = @PACKAGE_VERSION@ 226 | PATH_SEPARATOR = @PATH_SEPARATOR@ 227 | PROFILE = @PROFILE@ 228 | RANLIB = @RANLIB@ 229 | SED = @SED@ 230 | SET_MAKE = @SET_MAKE@ 231 | SHELL = @SHELL@ 232 | SIZE16 = @SIZE16@ 233 | SIZE32 = @SIZE32@ 234 | SIZE64 = @SIZE64@ 235 | STRIP = @STRIP@ 236 | USIZE16 = @USIZE16@ 237 | USIZE32 = @USIZE32@ 238 | VERSION = @VERSION@ 239 | abs_builddir = @abs_builddir@ 240 | abs_srcdir = @abs_srcdir@ 241 | abs_top_builddir = @abs_top_builddir@ 242 | abs_top_srcdir = @abs_top_srcdir@ 243 | ac_ct_AR = @ac_ct_AR@ 244 | ac_ct_CC = @ac_ct_CC@ 245 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 246 | am__include = @am__include@ 247 | am__leading_dot = @am__leading_dot@ 248 | am__quote = @am__quote@ 249 | am__tar = @am__tar@ 250 | am__untar = @am__untar@ 251 | bindir = @bindir@ 252 | build = @build@ 253 | build_alias = @build_alias@ 254 | build_cpu = @build_cpu@ 255 | build_os = @build_os@ 256 | build_vendor = @build_vendor@ 257 | builddir = @builddir@ 258 | datadir = @datadir@ 259 | datarootdir = @datarootdir@ 260 | docdir = @docdir@ 261 | dvidir = @dvidir@ 262 | exec_prefix = @exec_prefix@ 263 | host = @host@ 264 | host_alias = @host_alias@ 265 | host_cpu = @host_cpu@ 266 | host_os = @host_os@ 267 | host_vendor = @host_vendor@ 268 | htmldir = @htmldir@ 269 | includedir = @includedir@ 270 | infodir = @infodir@ 271 | install_sh = @install_sh@ 272 | libdir = @libdir@ 273 | libexecdir = @libexecdir@ 274 | localedir = @localedir@ 275 | localstatedir = @localstatedir@ 276 | mandir = @mandir@ 277 | mkdir_p = @mkdir_p@ 278 | oldincludedir = @oldincludedir@ 279 | pdfdir = @pdfdir@ 280 | prefix = @prefix@ 281 | program_transform_name = @program_transform_name@ 282 | psdir = @psdir@ 283 | sbindir = @sbindir@ 284 | sharedstatedir = @sharedstatedir@ 285 | srcdir = @srcdir@ 286 | sysconfdir = @sysconfdir@ 287 | target_alias = @target_alias@ 288 | top_build_prefix = @top_build_prefix@ 289 | top_builddir = @top_builddir@ 290 | top_srcdir = @top_srcdir@ 291 | oggincludedir = $(includedir)/ogg 292 | ogginclude_HEADERS = ogg.h os_types.h 293 | nodist_ogginclude_HEADERS = config_types.h 294 | all: all-am 295 | 296 | .SUFFIXES: 297 | $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) 298 | @for dep in $?; do \ 299 | case '$(am__configure_deps)' in \ 300 | *$$dep*) \ 301 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 302 | && { if test -f $@; then exit 0; else break; fi; }; \ 303 | exit 1;; \ 304 | esac; \ 305 | done; \ 306 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/ogg/Makefile'; \ 307 | $(am__cd) $(top_srcdir) && \ 308 | $(AUTOMAKE) --gnu include/ogg/Makefile 309 | .PRECIOUS: Makefile 310 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 311 | @case '$?' in \ 312 | *config.status*) \ 313 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 314 | *) \ 315 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 316 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 317 | esac; 318 | 319 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 320 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 321 | 322 | $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 323 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 324 | $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) 325 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 326 | $(am__aclocal_m4_deps): 327 | config_types.h: $(top_builddir)/config.status $(srcdir)/config_types.h.in 328 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 329 | 330 | mostlyclean-libtool: 331 | -rm -f *.lo 332 | 333 | clean-libtool: 334 | -rm -rf .libs _libs 335 | install-nodist_oggincludeHEADERS: $(nodist_ogginclude_HEADERS) 336 | @$(NORMAL_INSTALL) 337 | @list='$(nodist_ogginclude_HEADERS)'; test -n "$(oggincludedir)" || list=; \ 338 | if test -n "$$list"; then \ 339 | echo " $(MKDIR_P) '$(DESTDIR)$(oggincludedir)'"; \ 340 | $(MKDIR_P) "$(DESTDIR)$(oggincludedir)" || exit 1; \ 341 | fi; \ 342 | for p in $$list; do \ 343 | if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 344 | echo "$$d$$p"; \ 345 | done | $(am__base_list) | \ 346 | while read files; do \ 347 | echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(oggincludedir)'"; \ 348 | $(INSTALL_HEADER) $$files "$(DESTDIR)$(oggincludedir)" || exit $$?; \ 349 | done 350 | 351 | uninstall-nodist_oggincludeHEADERS: 352 | @$(NORMAL_UNINSTALL) 353 | @list='$(nodist_ogginclude_HEADERS)'; test -n "$(oggincludedir)" || list=; \ 354 | files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ 355 | dir='$(DESTDIR)$(oggincludedir)'; $(am__uninstall_files_from_dir) 356 | install-oggincludeHEADERS: $(ogginclude_HEADERS) 357 | @$(NORMAL_INSTALL) 358 | @list='$(ogginclude_HEADERS)'; test -n "$(oggincludedir)" || list=; \ 359 | if test -n "$$list"; then \ 360 | echo " $(MKDIR_P) '$(DESTDIR)$(oggincludedir)'"; \ 361 | $(MKDIR_P) "$(DESTDIR)$(oggincludedir)" || exit 1; \ 362 | fi; \ 363 | for p in $$list; do \ 364 | if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 365 | echo "$$d$$p"; \ 366 | done | $(am__base_list) | \ 367 | while read files; do \ 368 | echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(oggincludedir)'"; \ 369 | $(INSTALL_HEADER) $$files "$(DESTDIR)$(oggincludedir)" || exit $$?; \ 370 | done 371 | 372 | uninstall-oggincludeHEADERS: 373 | @$(NORMAL_UNINSTALL) 374 | @list='$(ogginclude_HEADERS)'; test -n "$(oggincludedir)" || list=; \ 375 | files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ 376 | dir='$(DESTDIR)$(oggincludedir)'; $(am__uninstall_files_from_dir) 377 | 378 | ID: $(am__tagged_files) 379 | $(am__define_uniq_tagged_files); mkid -fID $$unique 380 | tags: tags-am 381 | TAGS: tags 382 | 383 | tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 384 | set x; \ 385 | here=`pwd`; \ 386 | $(am__define_uniq_tagged_files); \ 387 | shift; \ 388 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 389 | test -n "$$unique" || unique=$$empty_fix; \ 390 | if test $$# -gt 0; then \ 391 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 392 | "$$@" $$unique; \ 393 | else \ 394 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 395 | $$unique; \ 396 | fi; \ 397 | fi 398 | ctags: ctags-am 399 | 400 | CTAGS: ctags 401 | ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 402 | $(am__define_uniq_tagged_files); \ 403 | test -z "$(CTAGS_ARGS)$$unique" \ 404 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 405 | $$unique 406 | 407 | GTAGS: 408 | here=`$(am__cd) $(top_builddir) && pwd` \ 409 | && $(am__cd) $(top_srcdir) \ 410 | && gtags -i $(GTAGS_ARGS) "$$here" 411 | cscopelist: cscopelist-am 412 | 413 | cscopelist-am: $(am__tagged_files) 414 | list='$(am__tagged_files)'; \ 415 | case "$(srcdir)" in \ 416 | [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 417 | *) sdir=$(subdir)/$(srcdir) ;; \ 418 | esac; \ 419 | for i in $$list; do \ 420 | if test -f "$$i"; then \ 421 | echo "$(subdir)/$$i"; \ 422 | else \ 423 | echo "$$sdir/$$i"; \ 424 | fi; \ 425 | done >> $(top_builddir)/cscope.files 426 | 427 | distclean-tags: 428 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 429 | 430 | distdir: $(DISTFILES) 431 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 432 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 433 | list='$(DISTFILES)'; \ 434 | dist_files=`for file in $$list; do echo $$file; done | \ 435 | sed -e "s|^$$srcdirstrip/||;t" \ 436 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 437 | case $$dist_files in \ 438 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 439 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 440 | sort -u` ;; \ 441 | esac; \ 442 | for file in $$dist_files; do \ 443 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 444 | if test -d $$d/$$file; then \ 445 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 446 | if test -d "$(distdir)/$$file"; then \ 447 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 448 | fi; \ 449 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 450 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 451 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 452 | fi; \ 453 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 454 | else \ 455 | test -f "$(distdir)/$$file" \ 456 | || cp -p $$d/$$file "$(distdir)/$$file" \ 457 | || exit 1; \ 458 | fi; \ 459 | done 460 | check-am: all-am 461 | check: check-am 462 | all-am: Makefile $(HEADERS) 463 | installdirs: 464 | for dir in "$(DESTDIR)$(oggincludedir)" "$(DESTDIR)$(oggincludedir)"; do \ 465 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 466 | done 467 | install: install-am 468 | install-exec: install-exec-am 469 | install-data: install-data-am 470 | uninstall: uninstall-am 471 | 472 | install-am: all-am 473 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 474 | 475 | installcheck: installcheck-am 476 | install-strip: 477 | if test -z '$(STRIP)'; then \ 478 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 479 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 480 | install; \ 481 | else \ 482 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 483 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 484 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 485 | fi 486 | mostlyclean-generic: 487 | 488 | clean-generic: 489 | 490 | distclean-generic: 491 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 492 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 493 | 494 | maintainer-clean-generic: 495 | @echo "This command is intended for maintainers to use" 496 | @echo "it deletes files that may require special tools to rebuild." 497 | clean: clean-am 498 | 499 | clean-am: clean-generic clean-libtool mostlyclean-am 500 | 501 | distclean: distclean-am 502 | -rm -f Makefile 503 | distclean-am: clean-am distclean-generic distclean-tags 504 | 505 | dvi: dvi-am 506 | 507 | dvi-am: 508 | 509 | html: html-am 510 | 511 | html-am: 512 | 513 | info: info-am 514 | 515 | info-am: 516 | 517 | install-data-am: install-nodist_oggincludeHEADERS \ 518 | install-oggincludeHEADERS 519 | 520 | install-dvi: install-dvi-am 521 | 522 | install-dvi-am: 523 | 524 | install-exec-am: 525 | 526 | install-html: install-html-am 527 | 528 | install-html-am: 529 | 530 | install-info: install-info-am 531 | 532 | install-info-am: 533 | 534 | install-man: 535 | 536 | install-pdf: install-pdf-am 537 | 538 | install-pdf-am: 539 | 540 | install-ps: install-ps-am 541 | 542 | install-ps-am: 543 | 544 | installcheck-am: 545 | 546 | maintainer-clean: maintainer-clean-am 547 | -rm -f Makefile 548 | maintainer-clean-am: distclean-am maintainer-clean-generic 549 | 550 | mostlyclean: mostlyclean-am 551 | 552 | mostlyclean-am: mostlyclean-generic mostlyclean-libtool 553 | 554 | pdf: pdf-am 555 | 556 | pdf-am: 557 | 558 | ps: ps-am 559 | 560 | ps-am: 561 | 562 | uninstall-am: uninstall-nodist_oggincludeHEADERS \ 563 | uninstall-oggincludeHEADERS 564 | 565 | .MAKE: install-am install-strip 566 | 567 | .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ 568 | clean-libtool cscopelist-am ctags ctags-am distclean \ 569 | distclean-generic distclean-libtool distclean-tags distdir dvi \ 570 | dvi-am html html-am info info-am install install-am \ 571 | install-data install-data-am install-dvi install-dvi-am \ 572 | install-exec install-exec-am install-html install-html-am \ 573 | install-info install-info-am install-man \ 574 | install-nodist_oggincludeHEADERS install-oggincludeHEADERS \ 575 | install-pdf install-pdf-am install-ps install-ps-am \ 576 | install-strip installcheck installcheck-am installdirs \ 577 | maintainer-clean maintainer-clean-generic mostlyclean \ 578 | mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ 579 | tags tags-am uninstall uninstall-am \ 580 | uninstall-nodist_oggincludeHEADERS uninstall-oggincludeHEADERS 581 | 582 | 583 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 584 | # Otherwise a system limit (for SysV at least) may be exceeded. 585 | .NOEXPORT: 586 | -------------------------------------------------------------------------------- /SiglusTranslationToolkit/stt/pckt.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #ifdef INCLUDE_PCKT 4 | #define _X86_ 5 | #include "pckt.h" 6 | #include "datt.h" 7 | #include "decryption.h" 8 | #include 9 | #include 10 | #include 11 | #include "util.h" 12 | #include "error.h" 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace stt 19 | { 20 | struct PCKHeader 21 | { 22 | unsigned int indexOffset; 23 | unsigned int type; 24 | unsigned int fileCount; 25 | unsigned int dataOffset; 26 | unsigned int sizeOffset; 27 | unsigned int nameOffset; 28 | 29 | PCKHeader() {} 30 | 31 | PCKHeader(std::vector& raw) 32 | { 33 | std::vector headerList(8); 34 | std::copy(raw.begin(), raw.begin() + sizeof(unsigned int) * 8, reinterpret_cast(&headerList[0])); 35 | indexOffset = 32; 36 | type = headerList[0]; 37 | fileCount = headerList[1]; 38 | dataOffset = headerList[2] + indexOffset; 39 | sizeOffset = headerList[3] + indexOffset; 40 | nameOffset = indexOffset + fileCount * 4; 41 | } 42 | }; 43 | 44 | struct SceneHeader 45 | { 46 | unsigned int length; 47 | unsigned int varInfoOffset; unsigned int varInfoCount; 48 | unsigned int varNameIndexOffset; unsigned int varNameIndexCount; 49 | unsigned int varNameOffset; unsigned int varNameCount; 50 | unsigned int cmdInfoOffset; unsigned int cmdInfoCount; 51 | unsigned int cmdNameIndexOffset; unsigned int cmdNameIndexCount; 52 | unsigned int cmdNameOffset; unsigned int cmdNameCount; 53 | unsigned int SceneNameIndexOffset; unsigned int SceneNameIndexCount; 54 | unsigned int SceneNameOffset; unsigned int SceneNameCount; 55 | unsigned int SceneInfoOffset; unsigned int SceneInfoCount; 56 | unsigned int SceneDataOffset; unsigned int SceneDataCount; 57 | unsigned int ExtraKeyUse; unsigned int SourceHeaderLength; 58 | 59 | SceneHeader() {} 60 | 61 | SceneHeader(std::vector& raw) 62 | { 63 | std::copy(raw.begin(), raw.begin() + sizeof(SceneHeader), reinterpret_cast(this)); 64 | } 65 | }; 66 | 67 | struct SSHeader 68 | { 69 | unsigned int length; 70 | unsigned int index; 71 | unsigned int count; 72 | unsigned int offset; 73 | unsigned int dataCount; 74 | 75 | SSHeader() {} 76 | 77 | SSHeader(std::vector& raw) 78 | { 79 | std::copy(raw.begin(), raw.begin() + sizeof(unsigned int), reinterpret_cast(&length)); 80 | std::vector headerList(32); 81 | std::copy(raw.begin() + sizeof(unsigned int), raw.begin() + sizeof(unsigned int) * 33, reinterpret_cast(&headerList[0])); 82 | index = headerList[2]; 83 | count = headerList[3]; 84 | offset = headerList[4]; 85 | dataCount = headerList[5]; 86 | } 87 | }; 88 | 89 | void RepackPCK(std::wstring inFile, std::wstring outPath, int compressionLevel, bool koreanForceSpacing) 90 | { 91 | std::wstring outFilePCK = outPath + getPartialFileName(inFile) + L".pck"; 92 | 93 | std::wstring repackSignitureString = L"This file has already been repacked by the Siglus Translation Toolkit more than once."; 94 | std::vector repackSigniture(reinterpret_cast(&repackSignitureString[0]), reinterpret_cast(&repackSignitureString[0]) + repackSignitureString.length() * sizeof(wchar_t)); 95 | 96 | bool alreadyRepacked = false; 97 | 98 | std::ifstream ifStream; 99 | checkAvailablePath(inFile); 100 | ifStream.open(inFile, std::ios::binary); 101 | 102 | ifStream.seekg(0, std::ifstream::end); 103 | int size = static_cast(ifStream.tellg()); 104 | ifStream.seekg(0); 105 | 106 | std::vector buf(size); 107 | ifStream.read(reinterpret_cast(&buf[0]), size); 108 | size = static_cast(ifStream.tellg()); 109 | ifStream.close(); 110 | 111 | SceneHeader sceneHeader(buf); 112 | 113 | std::vector keyArray; 114 | 115 | if (sceneHeader.ExtraKeyUse) 116 | { 117 | if (size - sceneHeader.SceneInfoOffset != 16) 118 | { 119 | ifStream.close(); 120 | throw(ERR_INVALID_KEY2); 121 | } 122 | else 123 | { 124 | keyArray.resize(16); 125 | std::copy(buf.begin() + sceneHeader.SceneInfoOffset, buf.end(), reinterpret_cast(&keyArray[0])); 126 | } 127 | } 128 | 129 | std::vector SceneNameOffset; 130 | std::vector SceneNameLength; 131 | for (unsigned int i = 0; i < sceneHeader.SceneNameIndexCount; ++i) 132 | { 133 | unsigned int dataInfo[2]; //dataInfo[0] : nameOffset, dataInfo[1] : nameLength 134 | std::copy(buf.begin() + sceneHeader.SceneNameIndexOffset + sizeof(dataInfo) * i, buf.begin() + sceneHeader.SceneNameIndexOffset + sizeof(dataInfo) * (i + 1), reinterpret_cast(&dataInfo[0])); 135 | 136 | SceneNameOffset.push_back(dataInfo[0]); 137 | SceneNameLength.push_back(dataInfo[1]); 138 | } 139 | 140 | std::vector> SceneNameString; 141 | int sceneOffset = 0; 142 | for (unsigned int i = 0; i < sceneHeader.SceneNameCount; ++i) 143 | { 144 | std::vector tempNameString(SceneNameLength[i] * 2); 145 | std::copy(buf.begin() + sceneHeader.SceneNameOffset + sceneOffset, buf.begin() + sceneHeader.SceneNameOffset + sceneOffset + SceneNameLength[i] * 2, reinterpret_cast(&tempNameString[0])); 146 | 147 | SceneNameString.push_back(tempNameString); 148 | 149 | sceneOffset += SceneNameLength[i] * 2; 150 | } 151 | 152 | std::vector SceneDataOffset; 153 | std::vector SceneDataLength; 154 | 155 | std::vector> SceneData; 156 | 157 | sceneOffset = 0; 158 | std::locale prevLocale = std::wcout.imbue(std::locale(".932")); 159 | for (unsigned int i = 0; i < sceneHeader.SceneDataCount; ++i) 160 | { 161 | std::wstring ssFileName; 162 | ssFileName.resize(SceneNameString[i].size() / 2); 163 | 164 | std::copy(SceneNameString[i].begin(), SceneNameString[i].end(), reinterpret_cast(&ssFileName[0])); 165 | 166 | std::wstring inFileSS = getDirectory(inFile) + ssFileName + L".ss"; 167 | 168 | checkAvailablePath(inFileSS); 169 | ifStream.open(inFileSS, std::ios::binary); 170 | 171 | ifStream.seekg(0, std::ifstream::end); 172 | int ssSize = static_cast(ifStream.tellg()); 173 | ifStream.seekg(0); 174 | 175 | std::vector decomp(ssSize); 176 | ifStream.read(reinterpret_cast(&decomp[0]), ssSize); 177 | 178 | ifStream.close(); 179 | 180 | std::vector endPadding; 181 | endPadding.resize(repackSigniture.size()); 182 | 183 | std::copy(decomp.end()-repackSigniture.size(), decomp.end(), reinterpret_cast(&endPadding[0])); 184 | 185 | if (endPadding == repackSigniture) 186 | alreadyRepacked = true; 187 | 188 | SSHeader ssHeader(decomp); 189 | 190 | std::vector ssLineOffset; 191 | std::vector ssLineLength; 192 | for (unsigned int j = 0; j < ssHeader.count; ++j) 193 | { 194 | unsigned int dataInfo[2]; //dataInfo[0] : offset, dataInfo[1] : length 195 | std::copy(decomp.begin() + ssHeader.index + sizeof(dataInfo) * j, decomp.begin() + ssHeader.index + sizeof(dataInfo) * (j + 1), reinterpret_cast(&dataInfo[0])); 196 | 197 | ssLineOffset.push_back(dataInfo[0]); 198 | ssLineLength.push_back(dataInfo[1]); 199 | } 200 | 201 | std::vector> ssString; 202 | for (unsigned int j = 0; j < ssHeader.count; ++j) 203 | { 204 | if (ssLineLength[j] == 0) 205 | { 206 | ssString.emplace_back(); 207 | continue; 208 | } 209 | std::vector rawStringData(ssLineLength[j] * 2); 210 | std::copy(decomp.begin() + ssHeader.offset + ssLineOffset[j] * 2, decomp.begin() + ssHeader.offset + (ssLineOffset[j] + ssLineLength[j]) * 2, reinterpret_cast(&rawStringData[0])); 211 | 212 | ssString.push_back(rawStringData); 213 | } 214 | 215 | std::wstring inFileSXT = getDirectory(inFile) + ssFileName + L".sxt"; 216 | 217 | std::wcout << ssFileName << L".sxt packing.." << std::endl; 218 | 219 | std::wifstream wifStream; 220 | checkAvailablePath(inFileSXT); 221 | wifStream.open(inFileSXT, std::ios::binary); 222 | 223 | wifStream.imbue(std::locale(wifStream.getloc(), new std::codecvt_utf16)); 224 | 225 | while (!wifStream.eof()) 226 | { 227 | std::wstring line; 228 | std::getline(wifStream, line); 229 | 230 | if (!line.empty() && line.back() == L'\r') 231 | line.pop_back(); 232 | 233 | if (line.empty()) 234 | continue; 235 | else if (line[0] == L'●') 236 | { 237 | int closeBracketPos = line.find(L'●', 1); 238 | if (closeBracketPos == std::wstring::npos) 239 | { 240 | continue; 241 | } 242 | 243 | int index = stoi(std::wstring(line.begin() + 1, line.begin() + closeBracketPos)); 244 | 245 | if (koreanForceSpacing) 246 | { 247 | std::wstring line2; 248 | for (wchar_t ch : line) 249 | { 250 | line2.push_back(ch); 251 | if (ch >= L'가' && ch <= L'힣') 252 | { 253 | line2 += L' '; 254 | } 255 | } 256 | line = line2; 257 | } 258 | 259 | std::wstring lineString(line.begin() + line.find(L'●', 1) + 1, line.end()); 260 | 261 | std::vector sxtRawStringData(reinterpret_cast(&lineString[0]), 262 | reinterpret_cast(&lineString[0]) 263 | + lineString.length() * sizeof(wchar_t)); 264 | 265 | decrypt0(reinterpret_cast(&sxtRawStringData[0]), sxtRawStringData.size() / 2, static_cast(index)); 266 | 267 | ssLineLength[index] = sxtRawStringData.size()/2; 268 | ssString[index] = sxtRawStringData; 269 | } 270 | } 271 | 272 | wifStream.close(); 273 | 274 | int lineOffset = 0; 275 | for (unsigned int j = 0; j < ssHeader.count; ++j) 276 | { 277 | ssLineOffset[j] = lineOffset; 278 | lineOffset += ssLineLength[j]; 279 | } 280 | 281 | if (alreadyRepacked) 282 | { 283 | decomp.erase(decomp.begin() + ssHeader.offset, decomp.end()); 284 | ssSize = decomp.size(); 285 | } 286 | 287 | std::copy(reinterpret_cast(&ssSize), reinterpret_cast(&ssSize) + sizeof(ssSize), reinterpret_cast(&decomp[20])); 288 | 289 | for (unsigned int j = 0; j < ssHeader.count; ++j) 290 | { 291 | std::copy(reinterpret_cast(&ssLineOffset[j]), reinterpret_cast(&ssLineOffset[j]) + sizeof(ssLineOffset[j]), reinterpret_cast(&decomp[ssHeader.index + sizeof(ssLineOffset[j]) * 2 * j])); 292 | std::copy(reinterpret_cast(&ssLineLength[j]), reinterpret_cast(&ssLineLength[j]) + sizeof(ssLineLength[j]), reinterpret_cast(&decomp[ssHeader.index + sizeof(ssLineLength[j]) * (2 * j + 1)])); 293 | 294 | decomp.insert(decomp.end(), ssString[j].begin(), ssString[j].end()); 295 | } 296 | decomp.insert(decomp.end(), repackSigniture.begin(), repackSigniture.end()); 297 | #ifdef _DEBUG // Validation Code 298 | SSHeader ssNewHeader(decomp); 299 | 300 | std::vector ssNewLineOffset; 301 | std::vector ssNewLineLength; 302 | for (unsigned int j = 0; j < ssNewHeader.count; ++j) 303 | { 304 | unsigned int dataInfo[2]; //dataInfo[0] : offset, dataInfo[1] : length 305 | std::copy(decomp.begin() + ssNewHeader.index + sizeof(dataInfo) * j, decomp.begin() + ssNewHeader.index + sizeof(dataInfo) * (j + 1), reinterpret_cast(&dataInfo[0])); 306 | 307 | ssNewLineOffset.push_back(dataInfo[0]); 308 | ssNewLineLength.push_back(dataInfo[1]); 309 | } 310 | 311 | std::vector ssNewString; 312 | for (unsigned int j = 0; j < ssNewHeader.count; ++j) 313 | { 314 | if (ssNewLineLength[j] == 0) 315 | { 316 | ssNewString.emplace_back(); 317 | continue; 318 | } 319 | std::vector rawStringData(ssNewLineLength[j] * 2); 320 | std::copy(decomp.begin() + ssNewHeader.offset + ssNewLineOffset[j] * 2, decomp.begin() + ssNewHeader.offset + (ssNewLineOffset[j] + ssNewLineLength[j]) * 2, reinterpret_cast(&rawStringData[0])); 321 | 322 | decrypt0(reinterpret_cast(&rawStringData[0]), rawStringData.size() / 2, static_cast(j)); 323 | 324 | std::wstring stringData; 325 | stringData.resize(rawStringData.size() / 2); 326 | 327 | std::copy(rawStringData.begin(), rawStringData.end(), reinterpret_cast(&stringData[0])); 328 | ssNewString.push_back(stringData); 329 | } 330 | #endif //_DEBUG 331 | 332 | std::wcout << ssFileName << L".ss packing.." << std::endl; 333 | std::vector comp; 334 | if (compressionLevel > 0) 335 | { 336 | int newSize = 0; 337 | unsigned char* compDataPtr = compress(&decomp[0], decomp.size(), &newSize, compressionLevel); 338 | comp.assign(compDataPtr, compDataPtr + newSize); 339 | } 340 | else 341 | { 342 | /* This block has not been tested!! */ 343 | 344 | int prevSize = decomp.size(); 345 | int newSize = prevSize + int(prevSize / 8) + 8; 346 | if (prevSize % 8 != 0) 347 | newSize += 1; 348 | comp.resize(newSize - 8, 0); 349 | comp.insert(comp.begin(), reinterpret_cast(&newSize), reinterpret_cast(&newSize) + sizeof(int)); 350 | comp.insert(comp.begin() + sizeof(int), reinterpret_cast(&prevSize), reinterpret_cast(&prevSize) + sizeof(int)); 351 | fakeCompress(&decomp[0], &comp[0], prevSize); 352 | } 353 | 354 | if (sceneHeader.ExtraKeyUse > 0) 355 | { 356 | decrypt1(&comp[0], comp.size(), &keyArray[0]); 357 | } 358 | 359 | decrypt2(&comp[0], comp.size(), 0); 360 | 361 | 362 | SceneData.push_back(comp); 363 | SceneDataLength.push_back(comp.size()); 364 | SceneDataOffset.push_back(sceneOffset); 365 | 366 | sceneOffset += comp.size(); 367 | } 368 | std::wcout.imbue(prevLocale); 369 | 370 | std::ofstream ofStream; 371 | checkAvailablePath(outFilePCK, true); 372 | ofStream.open(outFilePCK, std::ios::binary); 373 | ofStream.write(reinterpret_cast(&buf[0]), sceneHeader.SceneInfoOffset); 374 | 375 | for (unsigned int i = 0; i < sceneHeader.SceneInfoCount; ++i) 376 | { 377 | ofStream.write(reinterpret_cast(&SceneDataOffset[i]), sizeof(unsigned int)); 378 | ofStream.write(reinterpret_cast(&SceneDataLength[i]), sizeof(unsigned int)); 379 | } 380 | 381 | for (unsigned int i = 0; i < sceneHeader.SceneDataCount; ++i) 382 | { 383 | ofStream.write(reinterpret_cast(&SceneData[i][0]), SceneData[i].size()); 384 | } 385 | 386 | ofStream.close(); 387 | 388 | } 389 | 390 | void UnpackPCK(std::wstring inFile, std::wstring outPath, bool useComment, std::vector keyArray, bool koreanForceSpacing) 391 | { 392 | std::wstring outFilePKX = outPath + getPartialFileName(inFile) + L".pkx"; 393 | 394 | std::ifstream ifStream; 395 | checkAvailablePath(inFile); 396 | ifStream.open(inFile, std::ios::binary); 397 | 398 | ifStream.seekg(0, std::ifstream::end); 399 | int size = static_cast(ifStream.tellg()); 400 | ifStream.seekg(0); 401 | 402 | std::vector buf(size); 403 | ifStream.read(reinterpret_cast(&buf[0]), size); 404 | 405 | ifStream.close(); 406 | 407 | PCKHeader pckHeader(buf); 408 | 409 | if (pckHeader.type == 1) 410 | { 411 | std::wcout << "Currently only unpacking Scene.pck is supported." << std::endl; 412 | throw(ERR_NO_SUPPORT); 413 | } 414 | 415 | SceneHeader sceneHeader(buf); 416 | 417 | if (sceneHeader.ExtraKeyUse > 0 && keyArray.size() != 16) 418 | { 419 | throw(ERR_INVALID_KEY); 420 | } 421 | 422 | std::vector SceneNameOffset; 423 | std::vector SceneNameLength; 424 | for (unsigned int i = 0; i < sceneHeader.SceneNameIndexCount; ++i) 425 | { 426 | unsigned int dataInfo[2]; //dataInfo[0] : nameOffset, dataInfo[1] : nameLength 427 | std::copy(buf.begin() + sceneHeader.SceneNameIndexOffset + sizeof(dataInfo) * i , buf.begin() + sceneHeader.SceneNameIndexOffset + sizeof(dataInfo) * (i + 1), reinterpret_cast(&dataInfo[0])); 428 | 429 | SceneNameOffset.push_back(dataInfo[0]); 430 | SceneNameLength.push_back(dataInfo[1]); 431 | } 432 | 433 | std::vector> SceneNameString; 434 | int offset = 0; 435 | for (unsigned int i = 0; i < sceneHeader.SceneNameCount; ++i) 436 | { 437 | std::vector tempNameString(SceneNameLength[i]*2); 438 | std::copy(buf.begin() + sceneHeader.SceneNameOffset + offset, buf.begin() + sceneHeader.SceneNameOffset + offset + SceneNameLength[i] * 2, reinterpret_cast(&tempNameString[0])); 439 | 440 | SceneNameString.push_back(tempNameString); 441 | 442 | offset += SceneNameLength[i] * 2; 443 | } 444 | 445 | std::ofstream ofStream; 446 | checkAvailablePath(outFilePKX, true); 447 | ofStream.open(outFilePKX, std::ios::binary); 448 | 449 | ofStream.write(reinterpret_cast(&buf[0]), sceneHeader.SceneInfoOffset); 450 | if (sceneHeader.ExtraKeyUse > 0) 451 | { 452 | ofStream.write(reinterpret_cast(&keyArray[0]), 16); 453 | } 454 | 455 | ofStream.close(); 456 | 457 | std::vector SceneDataOffset; 458 | std::vector SceneDataLength; 459 | for (unsigned int i = 0; i < sceneHeader.SceneInfoCount; ++i) 460 | { 461 | unsigned int dataInfo[2]; //dataInfo[0] : dataOffset, dataInfo[1] : dataLength 462 | std::copy(buf.begin() + sceneHeader.SceneInfoOffset + sizeof(dataInfo) * i, buf.begin() + sceneHeader.SceneInfoOffset + sizeof(dataInfo) * (i + 1), reinterpret_cast(&dataInfo[0])); 463 | 464 | SceneDataOffset.push_back(dataInfo[0]); 465 | SceneDataLength.push_back(dataInfo[1]); 466 | } 467 | 468 | std::vector> SceneData; 469 | for (unsigned int i = 0; i < sceneHeader.SceneDataCount; ++i) 470 | { 471 | std::vector tempData(SceneDataLength[i]); 472 | std::copy(buf.begin() + sceneHeader.SceneDataOffset + SceneDataOffset[i], buf.begin() + sceneHeader.SceneDataOffset + SceneDataOffset[i] + SceneDataLength[i], reinterpret_cast(&tempData[0])); 473 | 474 | SceneData.push_back(tempData); 475 | } 476 | 477 | std::locale prevLocale = std::wcout.imbue(std::locale(".932")); 478 | for (unsigned int i = 0; i < sceneHeader.SceneDataCount; ++i) 479 | { 480 | std::wstring ssFileName; 481 | ssFileName.resize(SceneNameString[i].size() / 2); 482 | 483 | std::copy(SceneNameString[i].begin(), SceneNameString[i].end(), reinterpret_cast(&ssFileName[0])); 484 | 485 | if (sceneHeader.ExtraKeyUse > 0) 486 | { 487 | decrypt1(&SceneData[i][0], SceneData[i].size(), &keyArray[0]); 488 | } 489 | 490 | decrypt2(&SceneData[i][0], SceneData[i].size(), 0); 491 | 492 | int compSize; 493 | std::copy(SceneData[i].begin(), SceneData[i].begin() + sizeof(int), reinterpret_cast(&compSize)); 494 | 495 | int decompSize; 496 | std::copy(SceneData[i].begin() + sizeof(int), SceneData[i].begin() + sizeof(int) * 2, reinterpret_cast(&decompSize)); 497 | 498 | SceneData[i] = std::vector(SceneData[i].begin() + 8, SceneData[i].end()); 499 | 500 | std::vector decomp(decompSize+DECOMP_SIZE_PADDING); 501 | 502 | decompress(&SceneData[i][0], &decomp[0], decompSize); 503 | 504 | std::wstring outFileSS = outPath + ssFileName + L".ss"; 505 | 506 | std::wcout << ssFileName << L".ss extracting.." << std::endl; 507 | 508 | 509 | checkAvailablePath(outFileSS, true); 510 | ofStream.open(outFileSS, std::ios::binary); 511 | 512 | ofStream.write(reinterpret_cast(&decomp[0]), decompSize); 513 | 514 | ofStream.close(); 515 | 516 | SSHeader ssHeader(decomp); 517 | 518 | std::vector offset; 519 | std::vector length; 520 | for (unsigned int j = 0; j < ssHeader.count; ++j) 521 | { 522 | unsigned int dataInfo[2]; //dataInfo[0] : offset, dataInfo[1] : length 523 | std::copy(decomp.begin() + ssHeader.index + sizeof(dataInfo) * j, decomp.begin() + ssHeader.index + sizeof(dataInfo) * (j + 1), reinterpret_cast(&dataInfo[0])); 524 | 525 | offset.push_back(dataInfo[0]); 526 | length.push_back(dataInfo[1]); 527 | } 528 | 529 | 530 | std::wstring outFileSXT = outPath + ssFileName + L".sxt"; 531 | 532 | std::wcout << ssFileName << L".sxt extracting.." << std::endl; 533 | 534 | std::wofstream wofStream; 535 | checkAvailablePath(outFileSXT, true); 536 | wofStream.open(outFileSXT, std::ios::binary); 537 | 538 | wofStream.imbue(std::locale(wofStream.getloc(), new std::codecvt_utf16)); 539 | 540 | for (unsigned int j = 0; j < ssHeader.count; ++j) 541 | { 542 | if (length[j]==0) 543 | continue; 544 | 545 | std::vector rawStringData(length[j] * 2); 546 | std::copy(decomp.begin() + ssHeader.offset + offset[j] * 2, decomp.begin() + ssHeader.offset + (offset[j] + length[j]) * 2, reinterpret_cast(&rawStringData[0])); 547 | 548 | decrypt0(reinterpret_cast(&rawStringData[0]), rawStringData.size()/2, static_cast(j)); 549 | 550 | std::wstring stringData; 551 | stringData.resize(rawStringData.size() / 2); 552 | 553 | std::copy(rawStringData.begin(), rawStringData.end(), reinterpret_cast(&stringData[0])); 554 | 555 | if (koreanForceSpacing) 556 | { 557 | bool kor = false; 558 | 559 | std::wstring line2; 560 | for (wchar_t ch : stringData) 561 | { 562 | if (!kor || ch != L' ') 563 | { 564 | line2.push_back(ch); 565 | } 566 | 567 | kor = false; 568 | 569 | if (ch >= L'가' && ch <= L'힣') 570 | { 571 | kor = true; 572 | } 573 | } 574 | stringData = line2; 575 | } 576 | 577 | if (useComment) 578 | wofStream << L"○" << std::setw(6) << std::setfill(L'0') << j << L"○" << stringData << L"\r\n●" << std::setw(6) << std::setfill(L'0') << j << L"●" << stringData << L"\r\n\r\n"; 579 | else 580 | wofStream << L"●" << std::setw(6) << std::setfill(L'0') << j << L"●" << stringData << L"\r\n"; 581 | } 582 | 583 | wofStream.close(); 584 | } 585 | 586 | std::wcout.imbue(prevLocale); 587 | } 588 | } 589 | #endif //INCLUDE_PCKT -------------------------------------------------------------------------------- /ExternelLib/include/theora/theoraenc.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: 14 | last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $ 15 | 16 | ********************************************************************/ 17 | 18 | /**\file 19 | * The libtheoraenc C encoding API.*/ 20 | 21 | #if !defined(_O_THEORA_THEORAENC_H_) 22 | # define _O_THEORA_THEORAENC_H_ (1) 23 | # include 24 | # include 25 | # include "codec.h" 26 | 27 | #if defined(__cplusplus) 28 | extern "C" { 29 | #endif 30 | 31 | 32 | 33 | /**\name th_encode_ctl() codes 34 | * \anchor encctlcodes 35 | * These are the available request codes for th_encode_ctl(). 36 | * By convention, these are even, to distinguish them from the 37 | * \ref decctlcodes "decoder control codes". 38 | * Keep any experimental or vendor-specific values above \c 0x8000.*/ 39 | /*@{*/ 40 | /**Sets the Huffman tables to use. 41 | * The tables are copied, not stored by reference, so they can be freed after 42 | * this call. 43 | * NULL may be specified to revert to the default tables. 44 | * 45 | * \param[in] _buf #th_huff_code[#TH_NHUFFMAN_TABLES][#TH_NDCT_TOKENS] 46 | * \retval TH_EFAULT \a _enc_ctx is NULL. 47 | * \retval TH_EINVAL Encoding has already begun or one or more of the given 48 | * tables is not full or prefix-free, \a _buf is 49 | * NULL and \a _buf_sz is not zero, or \a _buf is 50 | * non-NULL and \a _buf_sz is not 51 | * sizeof(#th_huff_code)*#TH_NHUFFMAN_TABLES*#TH_NDCT_TOKENS. 52 | * \retval TH_EIMPL Not supported by this implementation.*/ 53 | #define TH_ENCCTL_SET_HUFFMAN_CODES (0) 54 | /**Sets the quantization parameters to use. 55 | * The parameters are copied, not stored by reference, so they can be freed 56 | * after this call. 57 | * NULL may be specified to revert to the default parameters. 58 | * 59 | * \param[in] _buf #th_quant_info 60 | * \retval TH_EFAULT \a _enc_ctx is NULL. 61 | * \retval TH_EINVAL Encoding has already begun, \a _buf is 62 | * NULL and \a _buf_sz is not zero, 63 | * or \a _buf is non-NULL and 64 | * \a _buf_sz is not sizeof(#th_quant_info). 65 | * \retval TH_EIMPL Not supported by this implementation.*/ 66 | #define TH_ENCCTL_SET_QUANT_PARAMS (2) 67 | /**Sets the maximum distance between key frames. 68 | * This can be changed during an encode, but will be bounded by 69 | * 1<. 70 | * If it is set before encoding begins, th_info#keyframe_granule_shift will 71 | * be enlarged appropriately. 72 | * 73 | * \param[in] _buf ogg_uint32_t: The maximum distance between key 74 | * frames. 75 | * \param[out] _buf ogg_uint32_t: The actual maximum distance set. 76 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 77 | * \retval TH_EINVAL \a _buf_sz is not sizeof(ogg_uint32_t). 78 | * \retval TH_EIMPL Not supported by this implementation.*/ 79 | #define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4) 80 | /**Disables any encoder features that would prevent lossless transcoding back 81 | * to VP3. 82 | * This primarily means disabling block-adaptive quantization and always coding 83 | * all four luma blocks in a macro block when 4MV is used. 84 | * It also includes using the VP3 quantization tables and Huffman codes; if you 85 | * set them explicitly after calling this function, the resulting stream will 86 | * not be VP3-compatible. 87 | * If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source 88 | * material, or when using a picture region smaller than the full frame (e.g. 89 | * a non-multiple-of-16 width or height), then non-VP3 bitstream features will 90 | * still be disabled, but the stream will still not be VP3-compatible, as VP3 91 | * was not capable of encoding such formats. 92 | * If you call this after encoding has already begun, then the quantization 93 | * tables and codebooks cannot be changed, but the frame-level features will 94 | * be enabled or disabled as requested. 95 | * 96 | * \param[in] _buf int: a non-zero value to enable VP3 compatibility, 97 | * or 0 to disable it (the default). 98 | * \param[out] _buf int: 1 if all bitstream features required for 99 | * VP3-compatibility could be set, and 0 otherwise. 100 | * The latter will be returned if the pixel format is not 101 | * 4:2:0, the picture region is smaller than the full frame, 102 | * or if encoding has begun, preventing the quantization 103 | * tables and codebooks from being set. 104 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 105 | * \retval TH_EINVAL \a _buf_sz is not sizeof(int). 106 | * \retval TH_EIMPL Not supported by this implementation.*/ 107 | #define TH_ENCCTL_SET_VP3_COMPATIBLE (10) 108 | /**Gets the maximum speed level. 109 | * Higher speed levels favor quicker encoding over better quality per bit. 110 | * Depending on the encoding mode, and the internal algorithms used, quality 111 | * may actually improve, but in this case bitrate will also likely increase. 112 | * In any case, overall rate/distortion performance will probably decrease. 113 | * The maximum value, and the meaning of each value, may change depending on 114 | * the current encoding mode (VBR vs. constant quality, etc.). 115 | * 116 | * \param[out] _buf int: The maximum encoding speed level. 117 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 118 | * \retval TH_EINVAL \a _buf_sz is not sizeof(int). 119 | * \retval TH_EIMPL Not supported by this implementation in the current 120 | * encoding mode.*/ 121 | #define TH_ENCCTL_GET_SPLEVEL_MAX (12) 122 | /**Sets the speed level. 123 | * The current speed level may be retrieved using #TH_ENCCTL_GET_SPLEVEL. 124 | * 125 | * \param[in] _buf int: The new encoding speed level. 126 | * 0 is slowest, larger values use less CPU. 127 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 128 | * \retval TH_EINVAL \a _buf_sz is not sizeof(int), or the 129 | * encoding speed level is out of bounds. 130 | * The maximum encoding speed level may be 131 | * implementation- and encoding mode-specific, and can be 132 | * obtained via #TH_ENCCTL_GET_SPLEVEL_MAX. 133 | * \retval TH_EIMPL Not supported by this implementation in the current 134 | * encoding mode.*/ 135 | #define TH_ENCCTL_SET_SPLEVEL (14) 136 | /**Gets the current speed level. 137 | * The default speed level may vary according to encoder implementation, but if 138 | * this control code is not supported (it returns #TH_EIMPL), the default may 139 | * be assumed to be the slowest available speed (0). 140 | * The maximum encoding speed level may be implementation- and encoding 141 | * mode-specific, and can be obtained via #TH_ENCCTL_GET_SPLEVEL_MAX. 142 | * 143 | * \param[out] _buf int: The current encoding speed level. 144 | * 0 is slowest, larger values use less CPU. 145 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 146 | * \retval TH_EINVAL \a _buf_sz is not sizeof(int). 147 | * \retval TH_EIMPL Not supported by this implementation in the current 148 | * encoding mode.*/ 149 | #define TH_ENCCTL_GET_SPLEVEL (16) 150 | /**Sets the number of duplicates of the next frame to produce. 151 | * Although libtheora can encode duplicate frames very cheaply, it costs some 152 | * amount of CPU to detect them, and a run of duplicates cannot span a 153 | * keyframe boundary. 154 | * This control code tells the encoder to produce the specified number of extra 155 | * duplicates of the next frame. 156 | * This allows the encoder to make smarter keyframe placement decisions and 157 | * rate control decisions, and reduces CPU usage as well, when compared to 158 | * just submitting the same frame for encoding multiple times. 159 | * This setting only applies to the next frame submitted for encoding. 160 | * You MUST call th_encode_packetout() repeatedly until it returns 0, or the 161 | * extra duplicate frames will be lost. 162 | * 163 | * \param[in] _buf int: The number of duplicates to produce. 164 | * If this is negative or zero, no duplicates will be produced. 165 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 166 | * \retval TH_EINVAL \a _buf_sz is not sizeof(int), or the 167 | * number of duplicates is greater than or equal to the 168 | * maximum keyframe interval. 169 | * In the latter case, NO duplicate frames will be produced. 170 | * You must ensure that the maximum keyframe interval is set 171 | * larger than the maximum number of duplicates you will 172 | * ever wish to insert prior to encoding. 173 | * \retval TH_EIMPL Not supported by this implementation in the current 174 | * encoding mode.*/ 175 | #define TH_ENCCTL_SET_DUP_COUNT (18) 176 | /**Modifies the default bitrate management behavior. 177 | * Use to allow or disallow frame dropping, and to enable or disable capping 178 | * bit reservoir overflows and underflows. 179 | * See \ref encctlcodes "the list of available flags". 180 | * The flags are set by default to 181 | * #TH_RATECTL_DROP_FRAMES|#TH_RATECTL_CAP_OVERFLOW. 182 | * 183 | * \param[in] _buf int: Any combination of 184 | * \ref ratectlflags "the available flags": 185 | * - #TH_RATECTL_DROP_FRAMES: Enable frame dropping. 186 | * - #TH_RATECTL_CAP_OVERFLOW: Don't bank excess bits for later 187 | * use. 188 | * - #TH_RATECTL_CAP_UNDERFLOW: Don't try to make up shortfalls 189 | * later. 190 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 191 | * \retval TH_EINVAL \a _buf_sz is not sizeof(int) or rate control 192 | * is not enabled. 193 | * \retval TH_EIMPL Not supported by this implementation in the current 194 | * encoding mode.*/ 195 | #define TH_ENCCTL_SET_RATE_FLAGS (20) 196 | /**Sets the size of the bitrate management bit reservoir as a function 197 | * of number of frames. 198 | * The reservoir size affects how quickly bitrate management reacts to 199 | * instantaneous changes in the video complexity. 200 | * Larger reservoirs react more slowly, and provide better overall quality, but 201 | * require more buffering by a client, adding more latency to live streams. 202 | * By default, libtheora sets the reservoir to the maximum distance between 203 | * keyframes, subject to a minimum and maximum limit. 204 | * This call may be used to increase or decrease the reservoir, increasing or 205 | * decreasing the allowed temporary variance in bitrate. 206 | * An implementation may impose some limits on the size of a reservoir it can 207 | * handle, in which case the actual reservoir size may not be exactly what was 208 | * requested. 209 | * The actual value set will be returned. 210 | * 211 | * \param[in] _buf int: Requested size of the reservoir measured in 212 | * frames. 213 | * \param[out] _buf int: The actual size of the reservoir set. 214 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 215 | * \retval TH_EINVAL \a _buf_sz is not sizeof(int), or rate control 216 | * is not enabled. The buffer has an implementation 217 | * defined minimum and maximum size and the value in _buf 218 | * will be adjusted to match the actual value set. 219 | * \retval TH_EIMPL Not supported by this implementation in the current 220 | * encoding mode.*/ 221 | #define TH_ENCCTL_SET_RATE_BUFFER (22) 222 | /**Enable pass 1 of two-pass encoding mode and retrieve the first pass metrics. 223 | * Pass 1 mode must be enabled before the first frame is encoded, and a target 224 | * bitrate must have already been specified to the encoder. 225 | * Although this does not have to be the exact rate that will be used in the 226 | * second pass, closer values may produce better results. 227 | * The first call returns the size of the two-pass header data, along with some 228 | * placeholder content, and sets the encoder into pass 1 mode implicitly. 229 | * This call sets the encoder to pass 1 mode implicitly. 230 | * Then, a subsequent call must be made after each call to 231 | * th_encode_ycbcr_in() to retrieve the metrics for that frame. 232 | * An additional, final call must be made to retrieve the summary data, 233 | * containing such information as the total number of frames, etc. 234 | * This must be stored in place of the placeholder data that was returned 235 | * in the first call, before the frame metrics data. 236 | * All of this data must be presented back to the encoder during pass 2 using 237 | * #TH_ENCCTL_2PASS_IN. 238 | * 239 | * \param[out] char *_buf: Returns a pointer to internal storage 240 | * containing the two pass metrics data. 241 | * This storage is only valid until the next call, or until the 242 | * encoder context is freed, and must be copied by the 243 | * application. 244 | * \retval >=0 The number of bytes of metric data available in the 245 | * returned buffer. 246 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 247 | * \retval TH_EINVAL \a _buf_sz is not sizeof(char *), no target 248 | * bitrate has been set, or the first call was made after 249 | * the first frame was submitted for encoding. 250 | * \retval TH_EIMPL Not supported by this implementation.*/ 251 | #define TH_ENCCTL_2PASS_OUT (24) 252 | /**Submits two-pass encoding metric data collected the first encoding pass to 253 | * the second pass. 254 | * The first call must be made before the first frame is encoded, and a target 255 | * bitrate must have already been specified to the encoder. 256 | * It sets the encoder to pass 2 mode implicitly; this cannot be disabled. 257 | * The encoder may require reading data from some or all of the frames in 258 | * advance, depending on, e.g., the reservoir size used in the second pass. 259 | * You must call this function repeatedly before each frame to provide data 260 | * until either a) it fails to consume all of the data presented or b) all of 261 | * the pass 1 data has been consumed. 262 | * In the first case, you must save the remaining data to be presented after 263 | * the next frame. 264 | * You can call this function with a NULL argument to get an upper bound on 265 | * the number of bytes that will be required before the next frame. 266 | * 267 | * When pass 2 is first enabled, the default bit reservoir is set to the entire 268 | * file; this gives maximum flexibility but can lead to very high peak rates. 269 | * You can subsequently set it to another value with #TH_ENCCTL_SET_RATE_BUFFER 270 | * (e.g., to set it to the keyframe interval for non-live streaming), however, 271 | * you may then need to provide more data before the next frame. 272 | * 273 | * \param[in] _buf char[]: A buffer containing the data returned by 274 | * #TH_ENCCTL_2PASS_OUT in pass 1. 275 | * You may pass NULL for \a _buf to return an upper 276 | * bound on the number of additional bytes needed before the 277 | * next frame. 278 | * The summary data returned at the end of pass 1 must be at 279 | * the head of the buffer on the first call with a 280 | * non-NULL \a _buf, and the placeholder data 281 | * returned at the start of pass 1 should be omitted. 282 | * After each call you should advance this buffer by the number 283 | * of bytes consumed. 284 | * \retval >0 The number of bytes of metric data required/consumed. 285 | * \retval 0 No more data is required before the next frame. 286 | * \retval TH_EFAULT \a _enc_ctx is NULL. 287 | * \retval TH_EINVAL No target bitrate has been set, or the first call was 288 | * made after the first frame was submitted for 289 | * encoding. 290 | * \retval TH_ENOTFORMAT The data did not appear to be pass 1 from a compatible 291 | * implementation of this library. 292 | * \retval TH_EBADHEADER The data was invalid; this may be returned when 293 | * attempting to read an aborted pass 1 file that still 294 | * has the placeholder data in place of the summary 295 | * data. 296 | * \retval TH_EIMPL Not supported by this implementation.*/ 297 | #define TH_ENCCTL_2PASS_IN (26) 298 | /**Sets the current encoding quality. 299 | * This is only valid so long as no bitrate has been specified, either through 300 | * the #th_info struct used to initialize the encoder or through 301 | * #TH_ENCCTL_SET_BITRATE (this restriction may be relaxed in a future 302 | * version). 303 | * If it is set before the headers are emitted, the target quality encoded in 304 | * them will be updated. 305 | * 306 | * \param[in] _buf int: The new target quality, in the range 0...63, 307 | * inclusive. 308 | * \retval 0 Success. 309 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 310 | * \retval TH_EINVAL A target bitrate has already been specified, or the 311 | * quality index was not in the range 0...63. 312 | * \retval TH_EIMPL Not supported by this implementation.*/ 313 | #define TH_ENCCTL_SET_QUALITY (28) 314 | /**Sets the current encoding bitrate. 315 | * Once a bitrate is set, the encoder must use a rate-controlled mode for all 316 | * future frames (this restriction may be relaxed in a future version). 317 | * If it is set before the headers are emitted, the target bitrate encoded in 318 | * them will be updated. 319 | * Due to the buffer delay, the exact bitrate of each section of the encode is 320 | * not guaranteed. 321 | * The encoder may have already used more bits than allowed for the frames it 322 | * has encoded, expecting to make them up in future frames, or it may have 323 | * used fewer, holding the excess in reserve. 324 | * The exact transition between the two bitrates is not well-defined by this 325 | * API, but may be affected by flags set with #TH_ENCCTL_SET_RATE_FLAGS. 326 | * After a number of frames equal to the buffer delay, one may expect further 327 | * output to average at the target bitrate. 328 | * 329 | * \param[in] _buf long: The new target bitrate, in bits per second. 330 | * \retval 0 Success. 331 | * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. 332 | * \retval TH_EINVAL The target bitrate was not positive. 333 | * \retval TH_EIMPL Not supported by this implementation.*/ 334 | #define TH_ENCCTL_SET_BITRATE (30) 335 | 336 | /*@}*/ 337 | 338 | 339 | /**\name TH_ENCCTL_SET_RATE_FLAGS flags 340 | * \anchor ratectlflags 341 | * These are the flags available for use with #TH_ENCCTL_SET_RATE_FLAGS.*/ 342 | /*@{*/ 343 | /**Drop frames to keep within bitrate buffer constraints. 344 | * This can have a severe impact on quality, but is the only way to ensure that 345 | * bitrate targets are met at low rates during sudden bursts of activity.*/ 346 | #define TH_RATECTL_DROP_FRAMES (0x1) 347 | /**Ignore bitrate buffer overflows. 348 | * If the encoder uses so few bits that the reservoir of available bits 349 | * overflows, ignore the excess. 350 | * The encoder will not try to use these extra bits in future frames. 351 | * At high rates this may cause the result to be undersized, but allows a 352 | * client to play the stream using a finite buffer; it should normally be 353 | * enabled.*/ 354 | #define TH_RATECTL_CAP_OVERFLOW (0x2) 355 | /**Ignore bitrate buffer underflows. 356 | * If the encoder uses so many bits that the reservoir of available bits 357 | * underflows, ignore the deficit. 358 | * The encoder will not try to make up these extra bits in future frames. 359 | * At low rates this may cause the result to be oversized; it should normally 360 | * be disabled.*/ 361 | #define TH_RATECTL_CAP_UNDERFLOW (0x4) 362 | /*@}*/ 363 | 364 | 365 | 366 | /**The quantization parameters used by VP3.*/ 367 | extern const th_quant_info TH_VP31_QUANT_INFO; 368 | 369 | /**The Huffman tables used by VP3.*/ 370 | extern const th_huff_code 371 | TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]; 372 | 373 | 374 | 375 | /**\name Encoder state 376 | The following data structure is opaque, and its contents are not publicly 377 | defined by this API. 378 | Referring to its internals directly is unsupported, and may break without 379 | warning.*/ 380 | /*@{*/ 381 | /**The encoder context.*/ 382 | typedef struct th_enc_ctx th_enc_ctx; 383 | /*@}*/ 384 | 385 | 386 | 387 | /**\defgroup encfuncs Functions for Encoding*/ 388 | /*@{*/ 389 | /**\name Functions for encoding 390 | * You must link to libtheoraenc and libtheoradec 391 | * if you use any of the functions in this section. 392 | * 393 | * The functions are listed in the order they are used in a typical encode. 394 | * The basic steps are: 395 | * - Fill in a #th_info structure with details on the format of the video you 396 | * wish to encode. 397 | * - Allocate a #th_enc_ctx handle with th_encode_alloc(). 398 | * - Perform any additional encoder configuration required with 399 | * th_encode_ctl(). 400 | * - Repeatedly call th_encode_flushheader() to retrieve all the header 401 | * packets. 402 | * - For each uncompressed frame: 403 | * - Submit the uncompressed frame via th_encode_ycbcr_in() 404 | * - Repeatedly call th_encode_packetout() to retrieve any video data packets 405 | * that are ready. 406 | * - Call th_encode_free() to release all encoder memory.*/ 407 | /*@{*/ 408 | /**Allocates an encoder instance. 409 | * \param _info A #th_info struct filled with the desired encoding parameters. 410 | * \return The initialized #th_enc_ctx handle. 411 | * \retval NULL If the encoding parameters were invalid.*/ 412 | extern th_enc_ctx *th_encode_alloc(const th_info *_info); 413 | /**Encoder control function. 414 | * This is used to provide advanced control the encoding process. 415 | * \param _enc A #th_enc_ctx handle. 416 | * \param _req The control code to process. 417 | * See \ref encctlcodes "the list of available control codes" 418 | * for details. 419 | * \param _buf The parameters for this control code. 420 | * \param _buf_sz The size of the parameter buffer.*/ 421 | extern int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz); 422 | /**Outputs the next header packet. 423 | * This should be called repeatedly after encoder initialization until it 424 | * returns 0 in order to get all of the header packets, in order, before 425 | * encoding actual video data. 426 | * \param _enc A #th_enc_ctx handle. 427 | * \param _comments The metadata to place in the comment header, when it is 428 | * encoded. 429 | * \param _op An ogg_packet structure to fill. 430 | * All of the elements of this structure will be set, 431 | * including a pointer to the header data. 432 | * The memory for the header data is owned by 433 | * libtheoraenc, and may be invalidated when the 434 | * next encoder function is called. 435 | * \return A positive value indicates that a header packet was successfully 436 | * produced. 437 | * \retval 0 No packet was produced, and no more header packets remain. 438 | * \retval TH_EFAULT \a _enc, \a _comments, or \a _op was NULL.*/ 439 | extern int th_encode_flushheader(th_enc_ctx *_enc, 440 | th_comment *_comments,ogg_packet *_op); 441 | /**Submits an uncompressed frame to the encoder. 442 | * \param _enc A #th_enc_ctx handle. 443 | * \param _ycbcr A buffer of Y'CbCr data to encode. 444 | * \retval 0 Success. 445 | * \retval TH_EFAULT \a _enc or \a _ycbcr is NULL. 446 | * \retval TH_EINVAL The buffer size does not match the frame size the encoder 447 | * was initialized with, or encoding has already 448 | * completed.*/ 449 | extern int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _ycbcr); 450 | /**Retrieves encoded video data packets. 451 | * This should be called repeatedly after each frame is submitted to flush any 452 | * encoded packets, until it returns 0. 453 | * The encoder will not buffer these packets as subsequent frames are 454 | * compressed, so a failure to do so will result in lost video data. 455 | * \note Currently the encoder operates in a one-frame-in, one-packet-out 456 | * manner. 457 | * However, this may be changed in the future. 458 | * \param _enc A #th_enc_ctx handle. 459 | * \param _last Set this flag to a non-zero value if no more uncompressed 460 | * frames will be submitted. 461 | * This ensures that a proper EOS flag is set on the last packet. 462 | * \param _op An ogg_packet structure to fill. 463 | * All of the elements of this structure will be set, including a 464 | * pointer to the video data. 465 | * The memory for the video data is owned by 466 | * libtheoraenc, and may be invalidated when the next 467 | * encoder function is called. 468 | * \return A positive value indicates that a video data packet was successfully 469 | * produced. 470 | * \retval 0 No packet was produced, and no more encoded video data 471 | * remains. 472 | * \retval TH_EFAULT \a _enc or \a _op was NULL.*/ 473 | extern int th_encode_packetout(th_enc_ctx *_enc,int _last,ogg_packet *_op); 474 | /**Frees an allocated encoder instance. 475 | * \param _enc A #th_enc_ctx handle.*/ 476 | extern void th_encode_free(th_enc_ctx *_enc); 477 | /*@}*/ 478 | /*@}*/ 479 | 480 | 481 | 482 | #if defined(__cplusplus) 483 | } 484 | #endif 485 | 486 | #endif 487 | --------------------------------------------------------------------------------