diff --git a/README.md b/README.md index 4863c13..7128bc7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,76 @@ # MPEG2DecPlus これはDGDecode.dllをAvisynth+用に改造するプロジェクトです。 -やりたいこと: - - 改築を重ねた温泉旅館のようなコードをきれいにする。 - - VFAPI用コード、YUY2用コード等、現在では必要ないコードの排除。 - - アセンブラの排除による64bitへの対応、及びSSE2/AVX2でのintrinsicによる最適化。 - 等 +###やりたいこと: + - 改築を重ねた温泉旅館のようなコードをきれいにする。 + - VFAPI用コード、YUY2用コード等、現在では必要ないコードの排除。 + - アセンブラの排除による64bitへの対応、及びSSE2/AVX2でのintrinsicによる最適化。等 + +###必要なもの: + - Windows Vista SP2 以降の Windows OS + - SSE3が使えるCPU(Intel Pentium4(prescott) または AMD Athlon64x2 以降) + - Avisynth+ r2172以降 + - Microsoft VisualC++ Redistributable Package 2015. + + ###使い方: + ``` + MPEG2Source(string "d2v", int "cpu", int "idct", bool "iPP", int "moderate_h", int "moderate_v", + bool "showQ", bool "fastMC", string "cpu2", int "info", int "upConv", bool "i420", bool "iCC") + ``` + d2v: dv2ファイルのパス + + cpu: 現在使用不可。設定しても何も起こらない。iPP, moderate_h, moderate_v, fastMC, cpu2も同様。 + + idct: 1,2,3,4,6,7 はすべてSSE2MMX(AP922互換)、5はIEEE 1180 reference(単精度小数点)。 + + showQ: マクロブロックの量子化器を表示する。 + + info: デバッグ情報を出力する。 + 0: 表示しない。(デフォルト) + 1: 動画フレームにオーバーレイで表示。 + 2: OutputDebugString()で出力。(内容はDebugView.exeで確認) + 3: hintsをフレーム左上隅の64バイトに埋め込む。 + + upConv: フレームを出力するフォーマット。 + 0: YUV420なソースはYV12で出力、YUV422なソースはYV16で出力。 + 1: YV16で出力。 + 2: YV24で出力。 + + i420: trueであればYUV420をi420として出力する。現在ではどちらでもほぼ変わりはない。 + + iCC: upConvにおけるYUV420の取扱いの設定。 + 未設定: フレームフラグに従ってinterlaced/progressiveを切り替える。 + true: 全フレームをinterlacedとして処理する。 + false: 全フレームをprogressiveとして処理する。 + +``` +Deblock(clip c, int "quant", int "aOffset", int "bOffset") +``` +H.264式でブロックフィルタ。manao氏のフィルタを取り込んだもの。 + + clip: Y8, YV12, YV16, YV411, YV24をサポート。 + + quant: 0~51(デフォルト25) + デブロックの強さ。 + + aOffset: 0 ~ 51-quant(デフォルト0) + ブロック検出の閾値。高いほどブロックと判定されやすくなる。 + + bOffset: 0 ~ 51-quant(デフォルト0) + デブロックの強さ及び検出率の補正値。 + 高いほどデブロックが強くかかり、ブロックと判定されやすくなる。 + +``` +LumaYUV(clip c, int "lumoff", int "lumgain") +``` +入力クリップの輝度をlumoffとlumgainの値によって変更する。出力Y = (入力y * lumgain) + lumoff + + clip: Y8, YV12, YV16, YV411, YV24をサポート。 + + lumoff: -255 ~ 255 (デフォルト0) + + lumgain: 0.0 ~ 2.0 (デフォルト1.0) + + + + diff --git a/build/msvcX/DGDecode/DGDecode.vcxproj.filters b/build/msvcX/DGDecode/DGDecode.vcxproj.filters index d7b3b52..c1c56b9 100644 --- a/build/msvcX/DGDecode/DGDecode.vcxproj.filters +++ b/build/msvcX/DGDecode/DGDecode.vcxproj.filters @@ -13,7 +13,7 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - + {b92ffe8f-65a1-47d7-b2eb-8eafdef68fd7} @@ -40,16 +40,16 @@ Source Files - DGDecode + MPEG2DecPlus - DGDecode + MPEG2DecPlus - DGDecode + MPEG2DecPlus - DGDecode + MPEG2DecPlus Source Files @@ -72,10 +72,10 @@ Header Files - DGDecode + MPEG2DecPlus - DGDecode + MPEG2DecPlus Header Files diff --git a/build/msvcX/DGIndex/DGIndex.vcxproj b/build/msvcX/DGIndex/DGIndex.vcxproj index a2b893b..2181632 100644 --- a/build/msvcX/DGIndex/DGIndex.vcxproj +++ b/build/msvcX/DGIndex/DGIndex.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {7BED3DC2-9B7C-446A-997F-9AD4560B1709} @@ -22,32 +30,55 @@ true MultiByte + + Application + true + MultiByte + Application false true MultiByte + + Application + false + true + MultiByte + + + + + + + true $(SolutionDir)..\..\bin\msvc$(VisualStudioVersion)\$(Configuration)\ $(Configuration)\msvc$(VisualStudioVersion)\ + + true + false $(SolutionDir)..\..\bin\msvc$(VisualStudioVersion)\$(Configuration)\ $(Configuration)\msvc$(VisualStudioVersion)\ + + false + @@ -64,6 +95,22 @@ 4096000 + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + ..\..\..\src\dgindex + + + Windows + true + shlwapi.lib;winmm.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) + 4096000 + + Level3 @@ -85,6 +132,27 @@ false + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + ..\..\..\src\dgindex + + + Windows + true + true + true + shlwapi.lib;winmm.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) + 4096000 + false + + @@ -133,31 +201,53 @@ ml /c /coff /Cx /nologo /Fo $(IntDir)%(Filename).obj %(FullPath) + + ml /c /coff /Cx /nologo /Fo $(IntDir)%(Filename).obj %(FullPath) $(IntDir)%(Filename).obj;%(Outputs) + $(IntDir)%(Filename).obj;%(Outputs) ml /c /coff /Cx /nologo /Fo $(IntDir)%(Filename).obj %(FullPath) + + ml /c /coff /Cx /nologo /Fo $(IntDir)%(Filename).obj %(FullPath) $(IntDir)%(Filename).obj;%(Outputs) + $(IntDir)%(Filename).obj;%(Outputs) nasm -f win32 -DPREFIX -DWIN32 -o $(IntDir)%(Filename).obj %(FullPath) + + nasm -f win32 -DPREFIX -DWIN32 -o $(IntDir)%(Filename).obj %(FullPath) $(IntDir)%(Filename).obj;%(Outputs) + $(IntDir)%(Filename).obj;%(Outputs) nasm -f win32 -DPREFIX -DWIN32 -o $(IntDir)%(Filename).obj %(FullPath) + + nasm -f win32 -DPREFIX -DWIN32 -o $(IntDir)%(Filename).obj %(FullPath) $(IntDir)%(Filename).obj;%(Outputs) + $(IntDir)%(Filename).obj;%(Outputs) %40copy /Y ..\..\..\src\dgdecode\skl_nasm.h .\ >NUL nasm -f win32 -DPREFIX -DWIN32 -o $(IntDir)%(Filename).obj %(FullPath) %40del /Q .\*.h + + %40copy /Y ..\..\..\src\dgdecode\skl_nasm.h .\ >NUL +nasm -f win32 -DPREFIX -DWIN32 -o $(IntDir)%(Filename).obj %(FullPath) +%40del /Q .\*.h $(IntDir)%(Filename).obj;%(Outputs) + $(IntDir)%(Filename).obj;%(Outputs) %40copy /Y ..\..\..\src\dgdecode\skl_nasm.h .\ >NUL nasm -f win32 -DPREFIX -DWIN32 -o $(IntDir)%(Filename).obj %(FullPath) %40del /Q .\*.h + + %40copy /Y ..\..\..\src\dgdecode\skl_nasm.h .\ >NUL +nasm -f win32 -DPREFIX -DWIN32 -o $(IntDir)%(Filename).obj %(FullPath) +%40del /Q .\*.h $(IntDir)%(Filename).obj;%(Outputs) + $(IntDir)%(Filename).obj;%(Outputs) diff --git a/build/msvcX/DGMPGDec.sln b/build/msvcX/DGMPGDec.sln index ab38fde..92db205 100644 --- a/build/msvcX/DGMPGDec.sln +++ b/build/msvcX/DGMPGDec.sln @@ -5,22 +5,32 @@ VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DGIndex", "DGIndex\DGIndex.vcxproj", "{7BED3DC2-9B7C-446A-997F-9AD4560B1709}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DGDecode", "DGDecode\DGDecode.vcxproj", "{13BF3FBA-7CD9-4374-83D5-E001E722E3DE}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MPEG2DecPlus", "DGDecode\DGDecode.vcxproj", "{13BF3FBA-7CD9-4374-83D5-E001E722E3DE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Debug|Win32.ActiveCfg = Debug|Win32 {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Debug|Win32.Build.0 = Debug|Win32 + {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Debug|x64.ActiveCfg = Debug|x64 + {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Debug|x64.Build.0 = Debug|x64 {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Release|Win32.ActiveCfg = Release|Win32 {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Release|Win32.Build.0 = Release|Win32 + {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Release|x64.ActiveCfg = Release|x64 + {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Release|x64.Build.0 = Release|x64 {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Debug|Win32.ActiveCfg = Debug|Win32 {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Debug|Win32.Build.0 = Debug|Win32 + {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Debug|x64.ActiveCfg = Debug|x64 + {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Debug|x64.Build.0 = Debug|x64 {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Release|Win32.ActiveCfg = Release|Win32 {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Release|Win32.Build.0 = Release|Win32 + {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Release|x64.ActiveCfg = Release|x64 + {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/dgdecode/AVISynthAPI.cpp b/src/dgdecode/AVISynthAPI.cpp index 4360b54..9caf665 100644 --- a/src/dgdecode/AVISynthAPI.cpp +++ b/src/dgdecode/AVISynthAPI.cpp @@ -37,7 +37,7 @@ #include "idct.h" -#define VERSION "DGDecode 1.5.8" +#define VERSION "MPEG2DecPlus 0.0.0" MPEG2Source::MPEG2Source(const char* d2v, int cpu, int idct, int iPP, int moderate_h, int moderate_v, bool showQ, bool fastMC, const char* _cpu2, int _info, int _upConv, bool _i420, int iCC, IScriptEnvironment* env) @@ -49,8 +49,8 @@ MPEG2Source::MPEG2Source(const char* d2v, int cpu, int idct, int iPP, int modera m_decoder.fpuinit = false; m_decoder.luminit = false; - if (iPP != -1 && iPP != 0 && iPP != 1) - env->ThrowError("MPEG2Source: iPP must be set to -1, 0, or 1!"); + //if (iPP != -1 && iPP != 0 && iPP != 1) + // env->ThrowError("MPEG2Source: iPP must be set to -1, 0, or 1!"); if (iCC != -1 && iCC != 0 && iCC != 1) env->ThrowError("MPEG2Source: iCC must be set to -1, 0, or 1!"); @@ -92,10 +92,10 @@ MPEG2Source::MPEG2Source(const char* d2v, int cpu, int idct, int iPP, int modera if (status == 1) env->ThrowError("MPEG2Source: Invalid D2V file, it's empty!"); else if (status == 2) - env->ThrowError("MPEG2Source: DGIndex/DGDecode mismatch. You are picking up\n" - "a version of DGDecode, possibly from your plugins directory,\n" + env->ThrowError("MPEG2Source: DGIndex/MPEG2DecPlus mismatch. You are picking up\n" + "a version of MPEG2DecPlus, possibly from your plugins directory,\n" "that does not match the version of DGIndex used to make the D2V\n" - "file. Search your hard disk for all copies of DGDecode.dll\n" + "file. Search your hard disk for all copies of MPEG2DecPlus.dll\n" "and delete or rename all of them except for the one that\n" "has the same version number as the DGIndex.exe that was used\n" "to make the D2V file."); @@ -372,21 +372,21 @@ PVideoFrame __stdcall MPEG2Source::GetFrame(int n, IScriptEnvironment* env) if (m_decoder.info == 1) { char msg1[1024]; - sprintf(msg1,"%s (c) 2007 Donald A. Graft (et al)\n" \ - "---------------------------------------\n" \ - "Source: %s\n" \ - "Frame Rate: %3.6f fps (%u/%u) %s\n" \ - "Field Order: %s\n" \ - "Picture Size: %d x %d\n" \ - "Aspect Ratio: %s\n" \ - "Progr Seq: %s\n" \ - "GOP Number: %d (%d) GOP Pos = %I64d\n" \ - "Closed GOP: %s\n" \ - "Display Frame: %d\n" \ - "Encoded Frame: %d (top) %d (bottom)\n" \ - "Frame Type: %c (%d)\n" \ - "Progr Frame: %s\n" \ - "Colorimetry: %s (%d)\n" \ + sprintf(msg1,"%s\n" + "---------------------------------------\n" + "Source: %s\n" + "Frame Rate: %3.6f fps (%u/%u) %s\n" + "Field Order: %s\n" + "Picture Size: %d x %d\n" + "Aspect Ratio: %s\n" + "Progr Seq: %s\n" + "GOP Number: %d (%d) GOP Pos = %I64d\n" + "Closed GOP: %s\n" + "Display Frame: %d\n" + "Encoded Frame: %d (top) %d (bottom)\n" + "Frame Type: %c (%d)\n" + "Progr Frame: %s\n" + "Colorimetry: %s (%d)\n" "Quants: %d/%d/%d (avg/min/max)\n", VERSION, m_decoder.Infilename[m_decoder.GOPList[gop]->file], @@ -411,24 +411,24 @@ PVideoFrame __stdcall MPEG2Source::GetFrame(int n, IScriptEnvironment* env) } else if (m_decoder.info == 2) { - dprintf("DGDecode: DGDecode %s (c) 2005 Donald A. Graft\n", VERSION); - dprintf("DGDecode: Source: %s\n", m_decoder.Infilename[m_decoder.GOPList[gop]->file]); - dprintf("DGDecode: Frame Rate: %3.6f fps (%u/%u) %s\n", + dprintf("MPEG2DecPlus: %s\n", VERSION); + dprintf("MPEG2DecPlus: Source: %s\n", m_decoder.Infilename[m_decoder.GOPList[gop]->file]); + dprintf("MPEG2DecPlus: Frame Rate: %3.6f fps (%u/%u) %s\n", double(m_decoder.VF_FrameRate_Num) / double(m_decoder.VF_FrameRate_Den), m_decoder.VF_FrameRate_Num, m_decoder.VF_FrameRate_Den, (m_decoder.VF_FrameRate == 25000 || m_decoder.VF_FrameRate == 50000) ? "(PAL)" : m_decoder.VF_FrameRate == 29970 ? "(NTSC)" : ""); - dprintf("DGDecode: Field Order: %s\n", m_decoder.Field_Order == 1 ? "Top Field First" : "Bottom Field First"); - dprintf("DGDecode: Picture Size: %d x %d\n", m_decoder.Coded_Picture_Width, m_decoder.Coded_Picture_Height); - dprintf("DGDecode: Aspect Ratio: %s\n", m_decoder.Aspect_Ratio); - dprintf("DGDecode: Progressive Seq: %s\n", m_decoder.GOPList[gop]->progressive ? "True" : "False"); - dprintf("DGDecode: GOP Number: %d (%d) GOP Pos = %I64d\n", gop, m_decoder.GOPList[gop]->number, m_decoder.GOPList[gop]->position); - dprintf("DGDecode: Closed GOP: %s\n", m_decoder.GOPList[gop]->closed ? "True" : "False"); - dprintf("DGDecode: Display Frame: %d\n", n); - dprintf("DGDecode: Encoded Frame: %d (top) %d (bottom)\n", m_decoder.FrameList[n].top, m_decoder.FrameList[n].bottom); - dprintf("DGDecode: Frame Type: %c (%d)\n", pct, raw); - dprintf("DGDecode: Progressive Frame: %s\n", m_decoder.FrameList[raw].pf ? "True" : "False"); - dprintf("DGDecode: Colorimetry: %s (%d)\n", Matrix_s, m_decoder.GOPList[gop]->matrix); - dprintf("DGDecode: Quants: %d/%d/%d (avg/min/max)\n", m_decoder.avgquant, m_decoder.minquant, m_decoder.maxquant); + dprintf("MPEG2DecPlus: Field Order: %s\n", m_decoder.Field_Order == 1 ? "Top Field First" : "Bottom Field First"); + dprintf("MPEG2DecPlus: Picture Size: %d x %d\n", m_decoder.Coded_Picture_Width, m_decoder.Coded_Picture_Height); + dprintf("MPEG2DecPlus: Aspect Ratio: %s\n", m_decoder.Aspect_Ratio); + dprintf("MPEG2DecPlus: Progressive Seq: %s\n", m_decoder.GOPList[gop]->progressive ? "True" : "False"); + dprintf("MPEG2DecPlus: GOP Number: %d (%d) GOP Pos = %I64d\n", gop, m_decoder.GOPList[gop]->number, m_decoder.GOPList[gop]->position); + dprintf("MPEG2DecPlus: Closed GOP: %s\n", m_decoder.GOPList[gop]->closed ? "True" : "False"); + dprintf("MPEG2DecPlus: Display Frame: %d\n", n); + dprintf("MPEG2DecPlus: Encoded Frame: %d (top) %d (bottom)\n", m_decoder.FrameList[n].top, m_decoder.FrameList[n].bottom); + dprintf("MPEG2DecPlus: Frame Type: %c (%d)\n", pct, raw); + dprintf("MPEG2DecPlus: Progressive Frame: %s\n", m_decoder.FrameList[raw].pf ? "True" : "False"); + dprintf("MPEG2DecPlus: Colorimetry: %s (%d)\n", Matrix_s, m_decoder.GOPList[gop]->matrix); + dprintf("MPEG2DecPlus: Quants: %d/%d/%d (avg/min/max)\n", m_decoder.avgquant, m_decoder.minquant, m_decoder.maxquant); } else if (m_decoder.info == 3) { @@ -500,7 +500,7 @@ if (strncmp(buf, name, len) == 0) \ { FILE *f; - if ((f = fopen("DGDecode.def", "r")) != NULL) + if ((f = fopen("MPEG2DecPlus.def", "r")) != NULL) { while(fgets(buf, 80, f) != 0) { @@ -589,7 +589,7 @@ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScri env->AddFunction("MPEG2Source", "[d2v]s[cpu]i[idct]i[iPP]b[moderate_h]i[moderate_v]i[showQ]b[fastMC]b[cpu2]s[info]i[upConv]i[i420]b[iCC]b", MPEG2Source::create, nullptr); env->AddFunction("LumaYUV","c[lumoff]i[lumgain]f", LumaYUV::create, nullptr); // env->AddFunction("BlindPP", "c[quant]i[cpu]i[cpu2]s[iPP]b[moderate_h]i[moderate_v]i", BlindPP::create, nullptr); - env->AddFunction("Deblock", "c[quant]i[aOffset]i[bOffset]i[mmx]b[isse]b", Deblock::create, nullptr); + env->AddFunction("Deblock", "c[quant]i[aOffset]i[bOffset]i", Deblock::create, nullptr); return 0; } diff --git a/src/dgdecode/deblock.cpp b/src/dgdecode/deblock.cpp index bfffc1d..47a570a 100644 --- a/src/dgdecode/deblock.cpp +++ b/src/dgdecode/deblock.cpp @@ -1,3 +1,8 @@ +/* +A rewite of Deblock filter for support all planar 8bit YUV. +Almost same as tp7's version. +*/ + #include "AvisynthAPI.h" diff --git a/src/dgdecode/vfapidec.cpp b/src/dgdecode/vfapidec.cpp index 0d11969..3fceb48 100644 --- a/src/dgdecode/vfapidec.cpp +++ b/src/dgdecode/vfapidec.cpp @@ -26,7 +26,6 @@ #include #include -//#include "global.h" #include "MPEG2Decoder.h" #include "mc.h" #include "misc.h"