Skip to content

Commit

Permalink
Add building instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
Asd-g committed Jan 17, 2021
1 parent c93c218 commit af0b296
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 32 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
##### 1.2.1:
Added support for path with forward slash (Windows).

##### 1.2.0:
Added variables (ffms2 like) - FFSAR_NUM, FFSAR_DEN, FFSAR.

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.8)

set(ProjectName "D2VSource")

Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,28 @@ This is a project (previously named as MPEG2DecPlus) to modify DGDecode.dll for
## Exported variables:

FFSAR_NUM, FFSAR_DEN, FFSAR.

# Building

## Windows

Use solution files.

## Linux

### Requirements

- Git
- C++17 compiler
- CMake >= 3.8

```
git clone https://github.com/Asd-g/MPEG2DecPlus && \
cd MPEG2DecPlus && \
mkdir build && \
cd build && \
cmake ..
make -j$(nproc)
sudo make install
```
8 changes: 3 additions & 5 deletions msvc/D2VSource.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>llvm</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -105,14 +105,14 @@
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<FloatingPointModel>Precise</FloatingPointModel>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand Down Expand Up @@ -156,9 +156,7 @@
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
<ClCompile Include="..\src\idct_llm_float_sse2.cpp" />
<ClCompile Include="..\src\idct_ref_sse3.cpp">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">-mssse3 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<ClCompile Include="..\src\idct_ref_sse3.cpp" />
<ClCompile Include="..\src\mc.cpp" />
<ClCompile Include="..\src\misc.cpp" />
<ClCompile Include="..\src\MPEG2Decoder.cpp" />
Expand Down
4 changes: 4 additions & 0 deletions src/AVISynthAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ static void show_info(int n, CMPEG2Decoder& d, PVideoFrame& frame,
d.getLumaWidth(), d.getLumaHeight(),
d.Aspect_Ratio,
rgop.progressive ? "True" : "False",
#ifdef _WIN32
gop, rgop.number, rgop.position,
#else
gop, rgop.number, static_cast<int>(rgop.position),
#endif
rgop.closed ? "True" : "False",
n,
fn.top, fn.bottom,
Expand Down
4 changes: 2 additions & 2 deletions src/MPEG2Decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ class CMPEG2Decoder
int Fault_Flag;
int File_Flag;
int FO_Flag;
void(__fastcall *idctFunction)(int16_t* block);
void(__fastcall *prefetchTables)();
void(*idctFunction)(int16_t* block);
void(*prefetchTables)();
int SystemStream_Flag; // 0 = none, 1=program, 2=Transport 3=PVA

int TransportPacketSize;
Expand Down
16 changes: 8 additions & 8 deletions src/idct.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
#include "win_import_min.h"
#endif

void __fastcall idct_ref_sse3(int16_t* block) noexcept;
void idct_ref_sse3(int16_t* block);

void __fastcall prefetch_ref() noexcept;
void prefetch_ref();

void __fastcall idct_ap922_sse2(int16_t* block) noexcept;
void idct_ap922_sse2(int16_t* block);

void __fastcall prefetch_ap922() noexcept;
void prefetch_ap922();

void __fastcall idct_llm_float_sse2(int16_t* block) noexcept;
void idct_llm_float_sse2(int16_t* block);

void __fastcall idct_llm_float_avx2(int16_t* block) noexcept;
void idct_llm_float_avx2(int16_t* block);

void __fastcall prefetch_llm_float_sse2() noexcept;
void prefetch_llm_float_sse2();

void __fastcall prefetch_llm_float_avx2() noexcept;
void prefetch_llm_float_avx2();

#endif
16 changes: 8 additions & 8 deletions src/idct_ap922_sse2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,35 @@ These examples contain code fragments for first stage iDCT 8x8
#endif


alignas(64) static const int16_t table04[] = {
alignas(64) static constexpr int16_t table04[] = {
16384, 21407, 16384, 8867, 16384, -8867, 16384, -21407, // w0, w1, w4, w5, w8, w9,w12,w13
16384, 8867, -16384, -21407, -16384, 21407, 16384, -8867, // w2, w3, w6, w7,w10,w11,w14,w15
22725, 19266, 19266, -4520, 12873, -22725, 4520, -12873, //w16,w17,w20,w21,w24,w25,w28,w29
12873, 4520, -22725, -12873, 4520, 19266, 19266, -22725, //w18,w19,w22,w23,w26,w27,w30,w31
};

alignas(64) static const int16_t table17[] = {
alignas(64) static constexpr int16_t table17[] = {
22725, 29692, 22725, 12299, 22725, -12299, 22725, -29692, // w0, w1, w4, w5, w8, w9,w12,w13
22725, 12299, -22725, -29692, -22725, 29692, 22725, -12299, // w2, w3, w6, w7,w10,w11,w14,w15
31521, 26722, 26722, -6270, 17855, -31521, 6270, -17855, //w16,w17,w20,w21,w24,w25,w28,w29
17855, 6270, -31521, -17855, 6270, 26722, 26722, -31521, //w18,w19,w22,w23,w26,w27,w30,w31
};

alignas(64) static const int16_t table26[] = {
alignas(64) static constexpr int16_t table26[] = {
21407, 27969, 21407, 11585, 21407, -11585, 21407, -27969, // w0, w1, w4, w5, w8, w9,w12,w13
21407, 11585, -21407, -27969, -21407, 27969, 21407, -11585, // w2, w3, w6, w7,w10,w11,w14,w15
29692, 25172, 25172, -5906, 16819, -29692, 5906, -16819, //w16,w17,w20,w21,w24,w25,w28,w29
16819, 5906, -29692, -16819, 5906, 25172, 25172, -29692, //w18,w19,w22,w23,w26,w27,w30,w31
};

alignas(64) static const int16_t table35[] = {
alignas(64) static constexpr int16_t table35[] = {
19266, 25172, 19266, 10426, 19266, -10426, 19266, -25172, // w0, w1, w4, w5, w8, w9,w12,w13
19266, 10426, -19266, -25172, -19266, 25172, 19266, -10426, // w2, w3, w6, w7,w10,w11,w14,w15
26722, 22654, 22654, -5315, 15137, -26722, 5315, -15137, //w16,w17,w20,w21,w24,w25,w28,w29
15137, 5315, -26722, -15137, 5315, 22654, 22654, -26722, //w18,w19,w22,w23,w26,w27,w30,w31
};

alignas(64) static const int32_t rounders[8][4] = {
alignas(64) static constexpr int32_t rounders[8][4] = {
{ 65536, 65536, 65536, 65536 },
{ 3597, 3597, 3597, 3597 },
{ 2260, 2260, 2260, 2260 },
Expand All @@ -127,7 +127,7 @@ alignas(64) static const int32_t rounders[8][4] = {
{ 512, 512, 512, 512 },
};

alignas(64) static const int16_t tg[4][8] = {
alignas(64) static constexpr int16_t tg[4][8] = {
{ 13036, 13036, 13036, 13036, 13036, 13036, 13036, 13036 },
{ 27146, 27146, 27146, 27146, 27146, 27146, 27146, 27146},
{-21746, -21746, -21746, -21746, -21746, -21746, -21746, -21746},
Expand Down Expand Up @@ -248,7 +248,7 @@ idct_colx8_sse2(int16_t* block) noexcept
}


void __fastcall idct_ap922_sse2(int16_t* block) noexcept
void idct_ap922_sse2(int16_t* block)
{
idct_row_sse2(block + 0, table04, rounders[0]);
idct_row_sse2(block + 8, table17, rounders[1]);
Expand All @@ -263,7 +263,7 @@ void __fastcall idct_ap922_sse2(int16_t* block) noexcept
}


void __fastcall prefetch_ap922() noexcept
void prefetch_ap922()
{
_mm_prefetch(reinterpret_cast<const char*>(table04), _MM_HINT_NTA);
_mm_prefetch(reinterpret_cast<const char*>(table17), _MM_HINT_NTA);
Expand Down
4 changes: 2 additions & 2 deletions src/idct_llm_float_avx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ float_to_dst_avx2(const __m256& s0, const __m256& s1, int16_t* dst) noexcept
}


void __fastcall idct_llm_float_avx2(int16_t* block) noexcept
void idct_llm_float_avx2(int16_t* block)
{
__m256 s0 = load_and_convert_to_float_x8_avx2(block);
__m256 s1 = load_and_convert_to_float_x8_avx2(block + 8);
Expand All @@ -145,7 +145,7 @@ void __fastcall idct_llm_float_avx2(int16_t* block) noexcept
}


void __fastcall prefetch_llm_float_avx2() noexcept
void prefetch_llm_float_avx2()
{
_mm_prefetch(reinterpret_cast<const char*>(llm_coefs), _MM_HINT_NTA);
_mm_prefetch(reinterpret_cast<const char*>(llm_coefs + 16), _MM_HINT_NTA);
Expand Down
4 changes: 2 additions & 2 deletions src/idct_llm_float_sse2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static inline void float_to_dst_llm(const float* srcp, int16_t* dstp) noexcept
}


void __fastcall idct_llm_float_sse2(int16_t* block) noexcept
void idct_llm_float_sse2(int16_t* block)
{
alignas(64) float blockf[64];
alignas(64) float tmp[64];
Expand All @@ -120,7 +120,7 @@ void __fastcall idct_llm_float_sse2(int16_t* block) noexcept
}


void __fastcall prefetch_llm_float_sse2() noexcept
void prefetch_llm_float_sse2()
{
_mm_prefetch(reinterpret_cast<const char*>(llm_coefs), _MM_HINT_NTA);
_mm_prefetch(reinterpret_cast<const char*>(llm_coefs + 16), _MM_HINT_NTA);
Expand Down
4 changes: 2 additions & 2 deletions src/idct_ref_sse3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static inline void double_to_dst_sse2(const double* srcp, int16_t* dst) noexcept
}


void __fastcall idct_ref_sse3(int16_t* block) noexcept
void idct_ref_sse3(int16_t* block)
{
alignas(64) double blockf[64];
alignas(64) double tmp[64];
Expand All @@ -182,7 +182,7 @@ void __fastcall idct_ref_sse3(int16_t* block) noexcept
}


void __fastcall prefetch_ref() noexcept
void prefetch_ref()
{
_mm_prefetch(reinterpret_cast<const char*>(ref_dct_matrix_t + 0), _MM_HINT_NTA);
_mm_prefetch(reinterpret_cast<const char*>(ref_dct_matrix_t + 8), _MM_HINT_NTA);
Expand Down
2 changes: 0 additions & 2 deletions src/win_import_min.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#ifndef WIN_IMPORT_MIN_H
#define WIN_IMPORT_MIN_H

#define __fastcall __attribute__((fastcall))

/* support from recent _mingw.h */

#ifdef __cplusplus
Expand Down

0 comments on commit af0b296

Please sign in to comment.