├── .gitignore ├── DGMPGDec_Build_Debug_msvc10.bat ├── DGMPGDec_Build_Debug_msvc12.bat ├── DGMPGDec_Build_Debug_msvc14.bat ├── DGMPGDec_Build_Debug_msvc15.bat ├── DGMPGDec_Build_Debug_msvc16.bat ├── DGMPGDec_Build_Debug_msvc17.bat ├── DGMPGDec_Build_Release_msvc10.bat ├── DGMPGDec_Build_Release_msvc12.bat ├── DGMPGDec_Build_Release_msvc14.bat ├── DGMPGDec_Build_Release_msvc15.bat ├── DGMPGDec_Build_Release_msvc16.bat ├── DGMPGDec_Build_Release_msvc17.bat ├── bin ├── .gitkeep ├── DGIndex.lang.ini ├── DGIndex.lang_chi.ini └── DGIndex.lang_jpn.ini ├── config.sh ├── doc ├── DGDecodeManual.html ├── DGIndexManual.html └── dev │ └── CodeNote1.txt ├── msvc ├── DGDecode │ ├── DGDecode.vcxproj │ └── DGDecode.vcxproj.filters ├── DGIndex │ ├── DGIndex.vcxproj │ └── DGIndex.vcxproj.filters ├── DGMPGDec.sln ├── DGVfapi │ ├── DGVfapi.vcxproj │ └── DGVfapi.vcxproj.filters ├── msvcX.props └── nasm │ ├── CPOL.htm │ ├── _info.txt │ ├── nasm.props │ ├── nasm.targets │ └── nasm.xml ├── nmake_build_msvc10.bat ├── nmake_build_msvc12.bat ├── nmake_build_msvc14.bat ├── nmake_build_msvc15.bat ├── nmake_build_msvc16.bat ├── nmake_build_msvc17.bat ├── nmake_build_wsdk71.bat └── src ├── COPYING.txt ├── config.h ├── dgdecode ├── AVISynthAPI.cpp ├── AvisynthAPI.h ├── History.txt ├── PostProcess.cpp ├── PostProcess.h ├── Utilities.cpp ├── Utilities.h ├── alloc.cpp ├── avisynth.h ├── avs │ ├── capi.h │ ├── config.h │ ├── cpuid.h │ ├── posix.h │ └── types.h ├── getbit.cpp ├── gethdr.cpp ├── getpic.cpp ├── global.cpp ├── global.h ├── gui.rc ├── idctfpu.cpp ├── idctmmx.asm ├── idctref.cpp ├── lumayv12.cpp ├── mc.cpp ├── mc.h ├── mc3dnow.cpp ├── mcmmx.cpp ├── mcsse.asm ├── misc.cpp ├── misc.h ├── motion.cpp ├── mpeg2dec.cpp ├── resource.h ├── simple_idct_mmx.asm ├── skl_dct_sse.asm ├── skl_nasm.h ├── store.cpp ├── text-overlay.cpp ├── text-overlay.h └── vfapidec.cpp ├── dgdecode64 ├── AVISynthAPI.cpp ├── AVISynthAPI.h ├── COPYING.txt ├── DGDecode.rc ├── DGDecode.sln ├── DGDecode.vcxproj ├── DGDecode.vcxproj.filters ├── History.txt ├── MPEG2Decoder.cpp ├── MPEG2Decoder.h ├── Readme64.txt ├── VSHelper.h ├── VapourSynth.h ├── Vapoursynth Notes.txt ├── avisynth.h ├── avs │ ├── capi.h │ ├── config.h │ ├── cpuid.h │ ├── posix.h │ └── types.h ├── chars.h ├── color_convert.cpp ├── color_convert.h ├── getbit.cpp ├── gethdr.cpp ├── getpic.cpp ├── global.cpp ├── global.h ├── idct.h ├── idct_ap922_sse2.cpp ├── idct_llm_float_avx2.cpp ├── idct_llm_float_sse2.cpp ├── idct_ref_sse3.cpp ├── mc.cpp ├── mc.h ├── misc.cpp ├── misc.h ├── store.cpp ├── vapoursource.cpp ├── vapoursource.h ├── win_import_min.h ├── yv12pict.cpp └── yv12pict.h ├── dgindex ├── AC3Dec │ ├── ac3.h │ ├── bit_allocate.cpp │ ├── bitstream.cpp │ ├── bitstream.h │ ├── coeff.cpp │ ├── crc.cpp │ ├── decode.cpp │ ├── downmix.cpp │ ├── exponent.cpp │ ├── imdct.cpp │ ├── parse.cpp │ ├── rematrix.cpp │ └── sanity_check.cpp ├── d2vparse.cpp ├── filter.h ├── getbit.cpp ├── getbit.h ├── gethdr.cpp ├── getpic.cpp ├── global.h ├── gui.cpp ├── gui.rc ├── idctfpu.cpp ├── idctmmx.asm ├── idctref.cpp ├── initial_parse.cpp ├── makefile ├── makefile.dep ├── misc.cpp ├── misc.h ├── motion.cpp ├── movie.ico ├── mpeg2dec.cpp ├── norm.cpp ├── parse_cli.cpp ├── pat.cpp ├── pat.h ├── resource.h ├── simple_idct_mmx.asm ├── skl_dct_sse.asm ├── skl_nasm.h ├── store.cpp ├── strverscmp.cpp └── wavefs44.cpp └── dgvfapi ├── avisynth.h ├── dgvfapi.def ├── gui.rc ├── resource.h ├── vfapi.cpp └── vfapi.h /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.exe 3 | *.dll 4 | *.lib 5 | *.log 6 | *.diff 7 | *.patch 8 | *.old 9 | *.bak 10 | *.orig 11 | *.rej 12 | *.aps 13 | *.ncb 14 | *.opensdf 15 | *.sdf 16 | *.VC.db 17 | *.VC.opendb 18 | *.suo 19 | *.user 20 | *.obj 21 | *.res 22 | *.exp 23 | *.ilk 24 | *.pdb 25 | msvc/.vs/ 26 | msvc/*/ipch/ 27 | msvc/*/Debug/ 28 | msvc/*/Release/ 29 | bin/msvc*/ 30 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Debug_msvc10.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=10.0 10 | set TOOLS_VER=4.0 11 | set MSVC_VER=msvc10 12 | 13 | rem Set up for MSBuild 14 | set MSBUILD_PATH=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319 15 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 16 | 17 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 18 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 19 | set FLOG_VERBOSITY=normal 20 | 21 | rem List up the target project 22 | set TGT_PROJECT=DGMPGDec 23 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 24 | set TGT_PLATFORM=Win32 25 | set TGT_CONFIG=Debug 26 | 27 | rem Set up NASMPATH (Path termination must be a separator character.) 28 | rem set NASMPATH=\ 29 | 30 | rem Build 31 | for %%c in (%TGT_CONFIG% ) do ( 32 | for %%p in (%TGT_PLATFORM%) do ( 33 | echo -Build- %%c^|%%p 34 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 35 | )) 36 | 37 | echo ----------------------------------------------------- 38 | echo F I N I S H 39 | echo ----------------------------------------------------- 40 | 41 | endlocal 42 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Debug_msvc12.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=12.0 10 | set TOOLS_VER=%VisualStudioVersion% 11 | set MSVC_VER=msvc12 12 | 13 | rem Set up for MSBuild 14 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 15 | set MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 16 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 17 | 18 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 19 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 20 | set FLOG_VERBOSITY=normal 21 | 22 | rem List up the target project 23 | set TGT_PROJECT=DGMPGDec 24 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 25 | set TGT_PLATFORM=Win32 26 | set TGT_CONFIG=Debug 27 | 28 | rem Set up NASMPATH (Path termination must be a separator character.) 29 | rem set NASMPATH=\ 30 | 31 | rem Windows XP support 32 | rem set WINXPISDEAD=1 33 | 34 | rem Build 35 | for %%c in (%TGT_CONFIG% ) do ( 36 | for %%p in (%TGT_PLATFORM%) do ( 37 | echo -Build- %%c^|%%p 38 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 39 | )) 40 | 41 | echo ----------------------------------------------------- 42 | echo F I N I S H 43 | echo ----------------------------------------------------- 44 | 45 | endlocal 46 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Debug_msvc14.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=14.0 10 | set TOOLS_VER=%VisualStudioVersion% 11 | set MSVC_VER=msvc14 12 | 13 | rem Set up for MSBuild 14 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 15 | set MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 16 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 17 | 18 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 19 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 20 | set FLOG_VERBOSITY=normal 21 | 22 | rem List up the target project 23 | set TGT_PROJECT=DGMPGDec 24 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 25 | set TGT_PLATFORM=Win32 26 | set TGT_CONFIG=Debug 27 | 28 | rem Set up NASMPATH (Path termination must be a separator character.) 29 | rem set NASMPATH=\ 30 | 31 | rem Windows XP support 32 | rem set WINXPISDEAD=1 33 | 34 | rem Build 35 | for %%c in (%TGT_CONFIG% ) do ( 36 | for %%p in (%TGT_PLATFORM%) do ( 37 | echo -Build- %%c^|%%p 38 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 39 | )) 40 | 41 | echo ----------------------------------------------------- 42 | echo F I N I S H 43 | echo ----------------------------------------------------- 44 | 45 | endlocal 46 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Debug_msvc15.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=15.0 10 | set TOOLS_VER=%VisualStudioVersion% 11 | set MSVC_VER=msvc15 12 | set VS_NUMBER=2017 13 | set VS_EDITION=Community 14 | 15 | set VSINSTPATH=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_NUMBER%\%VS_EDITION% 16 | 17 | rem Check installed version of Visual Studio (15.2 or later) 18 | set VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 19 | if exist "%VSWHERE%" ( 20 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set VisualStudioVersion=%%a.0 21 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set TOOLS_VER=%%a.0 22 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set MSVC_VER=msvc%%a 23 | for /f "delims=" %%a in ('"%VSWHERE%" -products * -property installationPath' ) do set VSINSTPATH=%%a 24 | ) 25 | 26 | rem Set up for MSBuild 27 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 28 | rem 12.0-14.0: %ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 29 | set MSBUILD_PATH=%VSINSTPATH%\MSBuild\%TOOLS_VER%\Bin 30 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 31 | 32 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 33 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 34 | set FLOG_VERBOSITY=normal 35 | 36 | rem List up the target project 37 | set TGT_PROJECT=DGMPGDec 38 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 39 | set TGT_PLATFORM=Win32 40 | set TGT_CONFIG=Debug 41 | 42 | rem Set up NASMPATH (Path termination must be a separator character.) 43 | rem set NASMPATH=\ 44 | 45 | rem Windows XP support 46 | rem set WINXPISDEAD=1 47 | 48 | rem Build 49 | for %%c in (%TGT_CONFIG% ) do ( 50 | for %%p in (%TGT_PLATFORM%) do ( 51 | echo -Build- %%c^|%%p 52 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 53 | )) 54 | 55 | echo ----------------------------------------------------- 56 | echo F I N I S H 57 | echo ----------------------------------------------------- 58 | 59 | endlocal 60 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Debug_msvc16.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=16.0 10 | set TOOLS_VER=Current 11 | set MSVC_VER=msvc16 12 | set VS_NUMBER=2019 13 | set VS_EDITION=Community 14 | 15 | set VSINSTPATH=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_NUMBER%\%VS_EDITION% 16 | 17 | rem Check installed version of Visual Studio (15.2 or later) 18 | set VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 19 | if exist "%VSWHERE%" ( 20 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set VisualStudioVersion=%%a.0 21 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set MSVC_VER=msvc%%a 22 | for /f "delims=" %%a in ('"%VSWHERE%" -products * -property installationPath' ) do set VSINSTPATH=%%a 23 | ) 24 | 25 | rem Set up for MSBuild 26 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 27 | rem 12.0-14.0: %ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 28 | set MSBUILD_PATH=%VSINSTPATH%\MSBuild\%TOOLS_VER%\Bin 29 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 30 | 31 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 32 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 33 | set FLOG_VERBOSITY=normal 34 | 35 | rem List up the target project 36 | set TGT_PROJECT=DGMPGDec 37 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 38 | set TGT_PLATFORM=Win32 39 | set TGT_CONFIG=Debug 40 | 41 | rem Set up NASMPATH (Path termination must be a separator character.) 42 | rem set NASMPATH=\ 43 | 44 | rem Windows XP support 45 | rem set WINXPISDEAD=1 46 | 47 | rem Build 48 | for %%c in (%TGT_CONFIG% ) do ( 49 | for %%p in (%TGT_PLATFORM%) do ( 50 | echo -Build- %%c^|%%p 51 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 52 | )) 53 | 54 | echo ----------------------------------------------------- 55 | echo F I N I S H 56 | echo ----------------------------------------------------- 57 | 58 | endlocal 59 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Debug_msvc17.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=17.0 10 | set TOOLS_VER=Current 11 | set MSVC_VER=msvc17 12 | set VS_NUMBER=2022 13 | set VS_EDITION=Community 14 | 15 | set VSINSTPATH=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_NUMBER%\%VS_EDITION% 16 | 17 | rem Check installed version of Visual Studio (15.2 or later) 18 | set VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 19 | if exist "%VSWHERE%" ( 20 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set VisualStudioVersion=%%a.0 21 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set MSVC_VER=msvc%%a 22 | for /f "delims=" %%a in ('"%VSWHERE%" -products * -property installationPath' ) do set VSINSTPATH=%%a 23 | ) 24 | 25 | rem Set up for MSBuild 26 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 27 | rem 12.0-14.0: %ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 28 | set MSBUILD_PATH=%VSINSTPATH%\MSBuild\%TOOLS_VER%\Bin 29 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 30 | 31 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 32 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 33 | set FLOG_VERBOSITY=normal 34 | 35 | rem List up the target project 36 | set TGT_PROJECT=DGMPGDec 37 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 38 | set TGT_PLATFORM=Win32 39 | set TGT_CONFIG=Debug 40 | 41 | rem Set up NASMPATH (Path termination must be a separator character.) 42 | rem set NASMPATH=\ 43 | 44 | rem Windows XP support 45 | rem set WINXPISDEAD=1 46 | 47 | rem Build 48 | for %%c in (%TGT_CONFIG% ) do ( 49 | for %%p in (%TGT_PLATFORM%) do ( 50 | echo -Build- %%c^|%%p 51 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 52 | )) 53 | 54 | echo ----------------------------------------------------- 55 | echo F I N I S H 56 | echo ----------------------------------------------------- 57 | 58 | endlocal 59 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Release_msvc10.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=10.0 10 | set TOOLS_VER=4.0 11 | set MSVC_VER=msvc10 12 | 13 | rem Set up for MSBuild 14 | set MSBUILD_PATH=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319 15 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 16 | 17 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 18 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 19 | set FLOG_VERBOSITY=normal 20 | 21 | rem List up the target project 22 | set TGT_PROJECT=DGMPGDec 23 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 24 | set TGT_PLATFORM=Win32 25 | set TGT_CONFIG=Release 26 | 27 | rem Set up NASMPATH (Path termination must be a separator character.) 28 | rem set NASMPATH=\ 29 | 30 | rem Build 31 | for %%c in (%TGT_CONFIG% ) do ( 32 | for %%p in (%TGT_PLATFORM%) do ( 33 | echo -Build- %%c^|%%p 34 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 35 | )) 36 | 37 | echo ----------------------------------------------------- 38 | echo F I N I S H 39 | echo ----------------------------------------------------- 40 | 41 | endlocal 42 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Release_msvc12.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=12.0 10 | set TOOLS_VER=%VisualStudioVersion% 11 | set MSVC_VER=msvc12 12 | 13 | rem Set up for MSBuild 14 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 15 | set MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 16 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 17 | 18 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 19 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 20 | set FLOG_VERBOSITY=normal 21 | 22 | rem List up the target project 23 | set TGT_PROJECT=DGMPGDec 24 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 25 | set TGT_PLATFORM=Win32 26 | set TGT_CONFIG=Release 27 | 28 | rem Set up NASMPATH (Path termination must be a separator character.) 29 | rem set NASMPATH=\ 30 | 31 | rem Windows XP support 32 | rem set WINXPISDEAD=1 33 | 34 | rem Build 35 | for %%c in (%TGT_CONFIG% ) do ( 36 | for %%p in (%TGT_PLATFORM%) do ( 37 | echo -Build- %%c^|%%p 38 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 39 | )) 40 | 41 | echo ----------------------------------------------------- 42 | echo F I N I S H 43 | echo ----------------------------------------------------- 44 | 45 | endlocal 46 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Release_msvc14.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=14.0 10 | set TOOLS_VER=%VisualStudioVersion% 11 | set MSVC_VER=msvc14 12 | 13 | rem Set up for MSBuild 14 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 15 | set MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 16 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 17 | 18 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 19 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 20 | set FLOG_VERBOSITY=normal 21 | 22 | rem List up the target project 23 | set TGT_PROJECT=DGMPGDec 24 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 25 | set TGT_PLATFORM=Win32 26 | set TGT_CONFIG=Release 27 | 28 | rem Set up NASMPATH (Path termination must be a separator character.) 29 | rem set NASMPATH=\ 30 | 31 | rem Windows XP support 32 | rem set WINXPISDEAD=1 33 | 34 | rem Build 35 | for %%c in (%TGT_CONFIG% ) do ( 36 | for %%p in (%TGT_PLATFORM%) do ( 37 | echo -Build- %%c^|%%p 38 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 39 | )) 40 | 41 | echo ----------------------------------------------------- 42 | echo F I N I S H 43 | echo ----------------------------------------------------- 44 | 45 | endlocal 46 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Release_msvc15.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=15.0 10 | set TOOLS_VER=%VisualStudioVersion% 11 | set MSVC_VER=msvc15 12 | set VS_NUMBER=2017 13 | set VS_EDITION=Community 14 | 15 | set VSINSTPATH=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_NUMBER%\%VS_EDITION% 16 | 17 | rem Check installed version of Visual Studio (15.2 or later) 18 | set VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 19 | if exist "%VSWHERE%" ( 20 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set VisualStudioVersion=%%a.0 21 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set TOOLS_VER=%%a.0 22 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set MSVC_VER=msvc%%a 23 | for /f "delims=" %%a in ('"%VSWHERE%" -products * -property installationPath' ) do set VSINSTPATH=%%a 24 | ) 25 | 26 | rem Set up for MSBuild 27 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 28 | rem 12.0-14.0: %ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 29 | set MSBUILD_PATH=%VSINSTPATH%\MSBuild\%TOOLS_VER%\Bin 30 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 31 | 32 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 33 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 34 | set FLOG_VERBOSITY=normal 35 | 36 | rem List up the target project 37 | set TGT_PROJECT=DGMPGDec 38 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 39 | set TGT_PLATFORM=Win32 40 | set TGT_CONFIG=Release 41 | 42 | rem Set up NASMPATH (Path termination must be a separator character.) 43 | rem set NASMPATH=\ 44 | 45 | rem Windows XP support 46 | rem set WINXPISDEAD=1 47 | 48 | rem Build 49 | for %%c in (%TGT_CONFIG% ) do ( 50 | for %%p in (%TGT_PLATFORM%) do ( 51 | echo -Build- %%c^|%%p 52 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 53 | )) 54 | 55 | echo ----------------------------------------------------- 56 | echo F I N I S H 57 | echo ----------------------------------------------------- 58 | 59 | endlocal 60 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Release_msvc16.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=16.0 10 | set TOOLS_VER=Current 11 | set MSVC_VER=msvc16 12 | set VS_NUMBER=2019 13 | set VS_EDITION=Community 14 | 15 | set VSINSTPATH=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_NUMBER%\%VS_EDITION% 16 | 17 | rem Check installed version of Visual Studio (15.2 or later) 18 | set VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 19 | if exist "%VSWHERE%" ( 20 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set VisualStudioVersion=%%a.0 21 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set MSVC_VER=msvc%%a 22 | for /f "delims=" %%a in ('"%VSWHERE%" -products * -property installationPath' ) do set VSINSTPATH=%%a 23 | ) 24 | 25 | rem Set up for MSBuild 26 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 27 | rem 12.0-14.0: %ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 28 | set MSBUILD_PATH=%VSINSTPATH%\MSBuild\%TOOLS_VER%\Bin 29 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 30 | 31 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 32 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 33 | set FLOG_VERBOSITY=normal 34 | 35 | rem List up the target project 36 | set TGT_PROJECT=DGMPGDec 37 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 38 | set TGT_PLATFORM=Win32 39 | set TGT_CONFIG=Release 40 | 41 | rem Set up NASMPATH (Path termination must be a separator character.) 42 | rem set NASMPATH=\ 43 | 44 | rem Windows XP support 45 | rem set WINXPISDEAD=1 46 | 47 | rem Build 48 | for %%c in (%TGT_CONFIG% ) do ( 49 | for %%p in (%TGT_PLATFORM%) do ( 50 | echo -Build- %%c^|%%p 51 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 52 | )) 53 | 54 | echo ----------------------------------------------------- 55 | echo F I N I S H 56 | echo ----------------------------------------------------- 57 | 58 | endlocal 59 | -------------------------------------------------------------------------------- /DGMPGDec_Build_Release_msvc17.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | echo ----------------------------------------------------- 6 | echo S T A R T 7 | echo ----------------------------------------------------- 8 | 9 | set VisualStudioVersion=17.0 10 | set TOOLS_VER=Current 11 | set MSVC_VER=msvc17 12 | set VS_NUMBER=2022 13 | set VS_EDITION=Community 14 | 15 | set VSINSTPATH=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_NUMBER%\%VS_EDITION% 16 | 17 | rem Check installed version of Visual Studio (15.2 or later) 18 | set VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 19 | if exist "%VSWHERE%" ( 20 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set VisualStudioVersion=%%a.0 21 | for /f "delims=. tokens=1" %%a in ('"%VSWHERE%" -products * -property installationVersion') do set MSVC_VER=msvc%%a 22 | for /f "delims=" %%a in ('"%VSWHERE%" -products * -property installationPath' ) do set VSINSTPATH=%%a 23 | ) 24 | 25 | rem Set up for MSBuild 26 | rem [memo] 4.0: %SystemRoot%\Microsoft.NET\Framework\v4.0.30319 27 | rem 12.0-14.0: %ProgramFiles(x86)%\MSBuild\%TOOLS_VER%\Bin 28 | set MSBUILD_PATH=%VSINSTPATH%\MSBuild\%TOOLS_VER%\Bin 29 | set MSBUILD_EXEC=%MSBUILD_PATH%\MSBuild.exe 30 | 31 | rem [memo] verbosity-level: q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic] 32 | set BUILD_OPT=/nologo /maxcpucount:1 /toolsversion:%TOOLS_VER% /verbosity:normal /fl 33 | set FLOG_VERBOSITY=normal 34 | 35 | rem List up the target project 36 | set TGT_PROJECT=DGMPGDec 37 | set TGT_SLN=.\msvc\%TGT_PROJECT%.sln 38 | set TGT_PLATFORM=Win32 39 | set TGT_CONFIG=Release 40 | 41 | rem Set up NASMPATH (Path termination must be a separator character.) 42 | rem set NASMPATH=\ 43 | 44 | rem Windows XP support 45 | rem set WINXPISDEAD=1 46 | 47 | rem Build 48 | for %%c in (%TGT_CONFIG% ) do ( 49 | for %%p in (%TGT_PLATFORM%) do ( 50 | echo -Build- %%c^|%%p 51 | "%MSBUILD_EXEC%" %TGT_SLN% /p:Configuration=%%c;Platform=%%p %BUILD_OPT% /flp:logfile=_build_%TGT_PROJECT%_%%c_%%p_%MSVC_VER%.log;verbosity=%FLOG_VERBOSITY% 52 | )) 53 | 54 | echo ----------------------------------------------------- 55 | echo F I N I S H 56 | echo ----------------------------------------------------- 57 | 58 | endlocal 59 | -------------------------------------------------------------------------------- /bin/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maki-rxrz/DGMPGDec/382e557d9379c49b4c22aa40c6eab9564f4db9a1/bin/.gitkeep -------------------------------------------------------------------------------- /bin/DGIndex.lang.ini: -------------------------------------------------------------------------------- 1 | ; DGIndex language settings 2 | 3 | [MainMenu] 4 | 00=&File 5 | 01=&Stream 6 | 02=&Video 7 | 03=&Audio 8 | 04=&Options 9 | 05=&Tools 10 | 06=&Help 11 | 12 | [SubMenu0] 13 | 00=&Open [F2] 14 | 01=Load Project 15 | 02=&Close [F3] 16 | 03= 17 | 04=&Save Project [F4] 18 | 05=Save Project and Demux Video 19 | 06=Save BMP [F7] 20 | 07=Demux Audio-Only Stream 21 | 08= 22 | 09=Preview [F5] 23 | 10=Play [F6] 24 | 11=Stop [Esc] 25 | 12=Pause/Resume [Space] 26 | 13= 27 | 14= 28 | 15=Exit 29 | 30 | [SubMenu1] 31 | 00=Detect PIDs: PAT/PMT 32 | 01=Detect PIDs: PSIP 33 | 02=Detect PIDs: Raw 34 | 03=Set PIDs 35 | 04=Set Margin 36 | 37 | [SubMenu2] 38 | 00=iDCT Algorithm 39 | 01=Field Operation 40 | 02=YUV -> RGB 41 | 03=HD Display 42 | 04= 43 | 05=Luminance Filter 44 | 06=Cropping Filter 45 | 07= 46 | 08=Copy frame to clipboard [F8] 47 | 48 | [SubMenu2-0] 49 | 00=32-bit MMX 50 | 01=32-bit SSE MMX 51 | 02=32-bit SSE2 MMX 52 | 03=64-bit Floating Point 53 | 04=IEEE-1180 Reference 54 | 05=Skal SSE MMX 55 | 06=Simple MMX 56 | 57 | [SubMenu2-1] 58 | 00=Honor Pulldown Flags 59 | 01=Ignore Pulldown Flags 60 | 02=Forced Film 61 | 62 | [SubMenu2-2] 63 | 00=PC Scale 64 | 01=TV Scale 65 | 66 | [SubMenu2-3] 67 | 00=Full Sized 68 | 01=Shrink by Half 69 | 02=Top Left 70 | 03=Top Right 71 | 04=Bottom Left 72 | 05=Bottom Right 73 | 74 | [SubMenu3] 75 | 00=Output Method 76 | 01=Select Track(s) 77 | 02= 78 | 03=Dolby Digital Decode 79 | 04=48 -> 44.1KHz 80 | 05=Normalization 81 | 82 | [SubMenu3-0] 83 | 00=Disable 84 | 01=Demux Tracks 85 | 02=Demux All Tracks 86 | 03=Decode AC3 Track to WAV 87 | 88 | [SubMenu3-3] 89 | 00=Dynamic Range Control 90 | 01=Dolby Surround Downmix 91 | 02=Pre-Scale Decision [F9] 92 | 93 | [SubMenu3-3-0] 94 | 00=Off 95 | 01= 96 | 02=Light 97 | 03=Normal 98 | 04=Heavy 99 | 100 | [SubMenu3-4] 101 | 00=Off 102 | 01= 103 | 02=Low 104 | 03=Mid 105 | 04=High 106 | 05=UltraHigh 107 | 108 | [SubMenu4] 109 | 00=Loop Playback 110 | 01=Playback Speed 111 | 02=Process Priority 112 | 03=Use Full Paths 113 | 04=Force Fusion-Style Audio 114 | 05=Force Open GOPs in D2V File 115 | 06=Log Quant Matrices 116 | 07=Log Timestamps 117 | 08=Template 118 | 09=BMP Save Path 119 | 10=Enable Info Log 120 | 11=Correct D2V 121 | 122 | [SubMenu4-1] 123 | 00=Single Step 124 | 01=Super Slow 125 | 02=Slow 126 | 03=Normal 127 | 04=Fast 128 | 05=Maximum 129 | 130 | [SubMenu4-2] 131 | 00=High 132 | 01=Normal 133 | 02=Low 134 | 135 | [SubMenu4-11] 136 | 00=Disable 137 | 01=Enable 138 | 139 | [SubMenu5] 140 | 00=Analyze Sync 141 | 01=Fix D2V 142 | 02=Parse D2V 143 | 144 | [SubMenu6] 145 | 00=Detected SIMD 146 | 01=VFAPI Plug-In 147 | 02= 148 | 03=About DGIndex 149 | 04=DGMPGDec Quick Start Guide 150 | 05=DGIndex User Manual 151 | 06=DGDecode User Manual 152 | 07= 153 | 08=DG's Web Site 154 | 155 | [SubMenu6-0] 156 | 00=MMX 157 | 01=SSE MMX 158 | 02=SSE2 159 | 03=SSE FPU 160 | 04=3D Now! 161 | 162 | [Dialog0] 163 | ;caption=Information 164 | ;font_size=8 165 | ;font_name=Tahoma 166 | 167 | [Dialog1] 168 | caption=Version 169 | font_size=10 170 | font_name=Tahoma 171 | 00=OK 172 | 01=DGIndex is an evolution of jackei's original work called DVD2AVI. The name was changed to prevent versioning nightmares and to reflect the significant divergence of functionality. 173 | 02=I am using this About box to permanently record the origins of DGIndex and to acknowledge the original work of jackei, as well as my personal gratitude for his wonderful contribution to our community!" 174 | 175 | [Dialog2] 176 | caption=File List 177 | font_size=10 178 | font_name=Tahoma 179 | 00=ADD 180 | 01=UP 181 | 02=DOWN 182 | 03=DEL 183 | 04=DEL ALL 184 | 05=OK 185 | 186 | [Dialog3] 187 | caption=Luminance Filter 188 | font_size=10 189 | font_name=Tahoma 190 | 00=Enable Luminance Filter 191 | 01=Offset: 192 | 02=Gammna: 193 | 194 | [Dialog4] 195 | caption=Normalization 196 | font_size=10 197 | font_name=Tahoma 198 | 00=Enable Normalization 199 | 01=Volume 200 | 201 | [Dialog5] 202 | caption=Set PIDs 203 | font_size=10 204 | font_name=Tahoma 205 | 00=OK 206 | 01=Cancel 207 | 02=Video PID 208 | 03=Audio PID 209 | 04=PCR PID 210 | 05=[Please use hexadecimal values with no leading 0x.] 211 | 212 | [Dialog6] 213 | caption=Template 214 | font_size=10 215 | font_name=Tahoma 216 | 00=Don't Use Template 217 | 01=Change Template File 218 | 02=Keep Current Template File 219 | 03=Your current template file is: 220 | 221 | [Dialog7] 222 | caption=BMP Save Path 223 | font_size=10 224 | font_name=Tahoma 225 | 00=OK 226 | 01=Cancel 227 | 02=Your current BMP save path is: 228 | 229 | [Dialog8] 230 | caption=Cropping 231 | font_size=10 232 | font_name=Tahoma 233 | 00=Enable Cropping Filter 234 | 01=Left 235 | 02=Right 236 | 03=Top 237 | 04=Bottom 238 | 05=Width 239 | 06=Height 240 | 241 | [Dialog9] 242 | caption=Detect PIDs 243 | font_size=10 244 | font_name=Tahoma 245 | 00=Set Video 246 | 01=Set Audio 247 | 02=Set PCR 248 | 03=Done 249 | 04=Select a line and use these buttons to set that PID as the audio or video PID. 250 | 251 | [Dialog10] 252 | caption=Select Track(s) 253 | font_size=10 254 | font_name=Tahoma 255 | 00=OK 256 | 01=Cancel 257 | 02=List desired audio id's separated by commas 258 | 259 | [Dialog11] 260 | caption=Select Track to Analyze 261 | font_size=10 262 | font_name=Tahoma 263 | 00=OK 264 | 01=Cancel 265 | 02=Enter audio id to analyze in hex without the leading 0x 266 | 267 | [Dialog12] 268 | caption=Set Margin 269 | font_size=10 270 | font_name=Tahoma 271 | 00=OK 272 | 01=Cancel 273 | 02=Margin: 274 | 03=msec 275 | -------------------------------------------------------------------------------- /bin/DGIndex.lang_chi.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maki-rxrz/DGMPGDec/382e557d9379c49b4c22aa40c6eab9564f4db9a1/bin/DGIndex.lang_chi.ini -------------------------------------------------------------------------------- /bin/DGIndex.lang_jpn.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maki-rxrz/DGMPGDec/382e557d9379c49b4c22aa40c6eab9564f4db9a1/bin/DGIndex.lang_jpn.ini -------------------------------------------------------------------------------- /config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ERR_EXIT () { 3 | echo $1; exit 1 4 | } 5 | 6 | cwd="$(cd $(dirname $0); pwd)" 7 | 8 | version='' 9 | clean='no' 10 | 11 | config_h="$cwd/src/config.h" 12 | 13 | # Parse options 14 | for opt do 15 | optarg="${opt#*=}" 16 | case "$opt" in 17 | --clean) 18 | clean='yes' 19 | ;; 20 | *) 21 | ERR_EXIT "Unknown option ... $opt" 22 | ;; 23 | esac 24 | done 25 | 26 | # Output config.h 27 | if [ "$clean" = 'yes' -o ! -d "$cwd/.git" ]; then 28 | cat > "$config_h" << EOF 29 | #undef DGMPGDEC_GIT_VERSION 30 | EOF 31 | else 32 | cd "$cwd" 33 | if [ -n "`git tag`" ]; then 34 | version="`git describe --tags`" 35 | echo "$version" 36 | echo "#define DGMPGDEC_GIT_VERSION \"$version\"" > "$config_h" 37 | else 38 | echo "#undef DGMPGDEC_GIT_VERSION" > "$config_h" 39 | fi 40 | fi 41 | -------------------------------------------------------------------------------- /doc/DGDecodeManual.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maki-rxrz/DGMPGDec/382e557d9379c49b4c22aa40c6eab9564f4db9a1/doc/DGDecodeManual.html -------------------------------------------------------------------------------- /doc/dev/CodeNote1.txt: -------------------------------------------------------------------------------- 1 | This fix was added to address a submitted VOB that caused DGDecode to hang. 2 | 3 | This is a field structure clip so we have: 4 | 5 | top field picture 6 | bottom field picture 7 | top field picture <--- 8 | bottom field picture 9 | top field picture 10 | bottom field picture 11 | ... 12 | 13 | Now, suppose I want to index the arrowed picture above. For program streams (of which VOB is one), I index the previous pack start code. But we have this in this clip: 14 | 15 | pack start 16 | bottom field picture (P) 17 | top field picture (I) <--- 18 | bottom field picture (P) 19 | ... 20 | 21 | So the code loop looking for the I picture sees a bottom field P picture first and thus fails the test to set HadI. Then it decodes another picture because it is field structure and encounters the top field I picture, but that decode had no test to set HadI. That causes the hang. 22 | 23 | Normally this would never happen because pictures are usually bigger than one pack. But in this case it was at a static scene. And of course field pictures are smaller than frame pictures. And the bottom field was a P and not an I. A really bad congruence of factors! 24 | 25 | We can't just add the HadI test for the second picture decode in the loop because we would exit the loop out of sync by one field, i.e., we should exit with a top and bottom field decoded and expecting a top next, but we'd have done a bottom and then a top, so instead of having a top coming next as we should, we'd have a bottom. 26 | 27 | Unfortunately MPEG2 syntax doesn't give you a direct way to determine if a field is the first one of a frame pair for field structure. They should have used the top_field_first flag, IMHO. 28 | 29 | I made a fix by using the Second_Field variable. I reset it to 0 whenever a sequence header or gop header is encountered. Then I test it and decide whether an extra field picture needs to be decoded. So, in this case, after the spurious bottom field picture is decoded, the Second_Field variable gets reset to 0, allowing me to know that I am out of sync by a field. (We could get really unlucky and not have an intervening SH or GH. In that case I don't know what to do, other than just ensure that it doesn't hang, even though we'd still be out by a field.) 30 | 31 | The fix works fine for the submitted VOB. 32 | 33 | Another idea is to record the field order as seen at the most recent SH and assume that is still valid. That would handle the cases where there is no intervening SH or GH. That may be worth trying. -------------------------------------------------------------------------------- /msvc/DGMPGDec.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29001.49 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DGIndex", "DGIndex\DGIndex.vcxproj", "{7BED3DC2-9B7C-446A-997F-9AD4560B1709}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DGDecode", "DGDecode\DGDecode.vcxproj", "{13BF3FBA-7CD9-4374-83D5-E001E722E3DE}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DGVfapi", "DGVfapi\DGVfapi.vcxproj", "{A2C7C35A-7346-4200-8C18-03EF6CDB7178}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Win32 = Debug|Win32 15 | Release|Win32 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Debug|Win32.Build.0 = Debug|Win32 20 | {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Release|Win32.ActiveCfg = Release|Win32 21 | {13BF3FBA-7CD9-4374-83D5-E001E722E3DE}.Release|Win32.Build.0 = Release|Win32 22 | {A2C7C35A-7346-4200-8C18-03EF6CDB7178}.Debug|Win32.ActiveCfg = Debug|Win32 23 | {A2C7C35A-7346-4200-8C18-03EF6CDB7178}.Debug|Win32.Build.0 = Debug|Win32 24 | {A2C7C35A-7346-4200-8C18-03EF6CDB7178}.Release|Win32.ActiveCfg = Release|Win32 25 | {A2C7C35A-7346-4200-8C18-03EF6CDB7178}.Release|Win32.Build.0 = Release|Win32 26 | {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Debug|Win32.Build.0 = Debug|Win32 28 | {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Release|Win32.ActiveCfg = Release|Win32 29 | {7BED3DC2-9B7C-446A-997F-9AD4560B1709}.Release|Win32.Build.0 = Release|Win32 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /msvc/DGVfapi/DGVfapi.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {A2C7C35A-7346-4200-8C18-03EF6CDB7178} 15 | Win32Proj 16 | DGVfapi 17 | DGVfapi 18 | 19 | 20 | 21 | 22 | DynamicLibrary 23 | true 24 | MultiByte 25 | 26 | 27 | DynamicLibrary 28 | false 29 | true 30 | MultiByte 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | ..\..\bin\msvc$(VisualStudioVersion)\$(Configuration)\ 45 | $(Configuration)\msvc$(VisualStudioVersion)\ 46 | 47 | 48 | false 49 | ..\..\bin\msvc$(VisualStudioVersion)\$(Configuration)\ 50 | $(Configuration)\msvc$(VisualStudioVersion)\ 51 | 52 | 53 | 54 | 55 | 56 | Level3 57 | Disabled 58 | _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;DGVFAPI_EXPORTS;%(PreprocessorDefinitions) 59 | ..\..\src\dgvfapi 60 | 61 | 62 | Windows 63 | true 64 | ..\..\src\dgvfapi\dgvfapi.def 65 | 66 | 67 | 68 | 69 | Level3 70 | 71 | 72 | MaxSpeed 73 | true 74 | true 75 | _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;DGVFAPI_EXPORTS;%(PreprocessorDefinitions) 76 | ..\..\src\dgvfapi 77 | 78 | 79 | Windows 80 | true 81 | true 82 | true 83 | false 84 | ..\..\src\dgvfapi\dgvfapi.def 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /msvc/DGVfapi/DGVfapi.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;hpp;hxx;hm;inl;inc;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 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | Resource Files 36 | 37 | 38 | 39 | 40 | Resource Files 41 | 42 | 43 | -------------------------------------------------------------------------------- /msvc/msvcX.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | v110_xp 5 | v120_xp 6 | v140_xp 7 | v141_xp 8 | v141_xp 9 | v141_xp 10 | 11 | 12 | v110 13 | v120 14 | v140 15 | v141 16 | v142 17 | v143 18 | 19 | 20 | 10.0.17763.0 21 | 10.0 22 | 23 | 24 | -------------------------------------------------------------------------------- /msvc/nasm/CPOL.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maki-rxrz/DGMPGDec/382e557d9379c49b4c22aa40c6eab9564f4db9a1/msvc/nasm/CPOL.htm -------------------------------------------------------------------------------- /msvc/nasm/_info.txt: -------------------------------------------------------------------------------- 1 | 2 | There files were created by 'perilbrain'. 3 | - nasm.props 4 | - nasm.targets 5 | - nasm.xml 6 | 7 | See the following site for details. 8 | http://www.codeproject.com/Articles/410776/Integrating-a-compiler-assembler-in-VS-Using-NASM 9 | 10 | -------------------------------------------------------------------------------- /msvc/nasm/nasm.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | Midl 6 | CustomBuild 7 | 8 | 9 | nasm 10 | "$(NASMPATH)nasm" 11 | 12 | 13 | 14 | $(IntDir)%(FileName).obj 15 | 0 16 | 4 17 | 1 18 | 0 19 | $(NasmExec) [AllOptions] [AdditionalOptions] [Inputs] 20 | $(NasmExec) [AllOptions] [AdditionalOptions] [Inputs] 21 | echo NASM not supported on this platform 22 | Assembling %(Identity)... 23 | 24 | 25 | -------------------------------------------------------------------------------- /msvc/nasm/nasm.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | _NASM 8 | 9 | 10 | 11 | 12 | $(ComputeLinkInputsTargets); 13 | ComputeNASMOutput; 14 | 15 | 16 | $(ComputeLibInputsTargets); 17 | ComputeNASMOutput; 18 | 19 | 20 | 24 | $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml 25 | 26 | 34 | 35 | 36 | 37 | 38 | 39 | @(NASM, '|') 40 | 41 | 42 | 45 | 49 | 74 | 75 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /nmake_build_msvc10.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | rem Set up NASMPATH (Path termination must be a separator character.) 6 | rem set NASMPATH=\ 7 | 8 | cd .\src\dgindex 9 | 10 | call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" x86 11 | 12 | jom /version >NUL 2>&1 13 | 14 | if "%ERRORLEVEL%" == "0" ( 15 | jom 16 | ) else ( 17 | nmake /nologo 18 | ) 19 | 20 | echo. 21 | 22 | endlocal 23 | 24 | pause 25 | -------------------------------------------------------------------------------- /nmake_build_msvc12.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | rem Set up NASMPATH (Path termination must be a separator character.) 6 | rem set NASMPATH=\ 7 | 8 | rem Windows XP support 9 | rem set WINXPISDEAD=1 10 | 11 | set EXTRA_CPPFLAGS=/FS 12 | 13 | cd .\src\dgindex 14 | 15 | call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x86 16 | 17 | jom /version >NUL 2>&1 18 | 19 | if "%ERRORLEVEL%" == "0" ( 20 | jom 21 | ) else ( 22 | nmake /nologo 23 | ) 24 | 25 | echo. 26 | 27 | endlocal 28 | 29 | pause 30 | -------------------------------------------------------------------------------- /nmake_build_msvc14.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | rem Set up NASMPATH (Path termination must be a separator character.) 6 | rem set NASMPATH=\ 7 | 8 | rem Windows XP support 9 | rem set WINXPISDEAD=1 10 | 11 | set EXTRA_CPPFLAGS=/FS 12 | 13 | cd .\src\dgindex 14 | 15 | call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86 16 | 17 | jom /version >NUL 2>&1 18 | 19 | if "%ERRORLEVEL%" == "0" ( 20 | jom 21 | ) else ( 22 | nmake /nologo 23 | ) 24 | 25 | echo. 26 | 27 | endlocal 28 | 29 | pause 30 | -------------------------------------------------------------------------------- /nmake_build_msvc15.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | set VS_NUMBER=2017 6 | set VS_EDITION=Community 7 | 8 | set VSINSTPATH=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_NUMBER%\%VS_EDITION% 9 | 10 | rem Check installed version of Visual Studio (15.2 or later) 11 | set VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 12 | if exist "%VSWHERE%" ( 13 | for /f "delims=" %%a in ('"%VSWHERE%" -products * -property installationPath') do set VSINSTPATH=%%a 14 | ) 15 | 16 | rem Set up NASMPATH (Path termination must be a separator character.) 17 | rem set NASMPATH=\ 18 | 19 | rem Windows XP support 20 | rem set WINXPISDEAD=1 21 | 22 | set EXTRA_CPPFLAGS=/FS 23 | 24 | cd .\src\dgindex 25 | 26 | call "%VSINSTPATH%\VC\Auxiliary\Build\vcvarsall.bat" x86 27 | 28 | jom /version >NUL 2>&1 29 | 30 | if "%ERRORLEVEL%" == "0" ( 31 | jom 32 | ) else ( 33 | nmake /nologo 34 | ) 35 | 36 | echo. 37 | 38 | endlocal 39 | 40 | pause 41 | -------------------------------------------------------------------------------- /nmake_build_msvc16.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | set VS_NUMBER=2019 6 | set VS_EDITION=Community 7 | 8 | set VSINSTPATH=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_NUMBER%\%VS_EDITION% 9 | 10 | rem Check installed version of Visual Studio (15.2 or later) 11 | set VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 12 | if exist "%VSWHERE%" ( 13 | for /f "delims=" %%a in ('"%VSWHERE%" -products * -property installationPath') do set VSINSTPATH=%%a 14 | ) 15 | 16 | rem Set up NASMPATH (Path termination must be a separator character.) 17 | rem set NASMPATH=\ 18 | 19 | rem Windows XP support 20 | rem set WINXPISDEAD=1 21 | 22 | set EXTRA_CPPFLAGS=/FS 23 | 24 | cd .\src\dgindex 25 | 26 | call "%VSINSTPATH%\VC\Auxiliary\Build\vcvarsall.bat" x86 27 | 28 | jom /version >NUL 2>&1 29 | 30 | if "%ERRORLEVEL%" == "0" ( 31 | jom 32 | ) else ( 33 | nmake /nologo 34 | ) 35 | 36 | echo. 37 | 38 | endlocal 39 | 40 | pause 41 | -------------------------------------------------------------------------------- /nmake_build_msvc17.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | set VS_NUMBER=2022 6 | set VS_EDITION=Community 7 | 8 | set VSINSTPATH=%ProgramFiles(x86)%\Microsoft Visual Studio\%VS_NUMBER%\%VS_EDITION% 9 | 10 | rem Check installed version of Visual Studio (15.2 or later) 11 | set VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 12 | if exist "%VSWHERE%" ( 13 | for /f "delims=" %%a in ('"%VSWHERE%" -products * -property installationPath') do set VSINSTPATH=%%a 14 | ) 15 | 16 | rem Set up NASMPATH (Path termination must be a separator character.) 17 | rem set NASMPATH=\ 18 | 19 | rem Windows XP support 20 | rem set WINXPISDEAD=1 21 | 22 | set EXTRA_CPPFLAGS=/FS 23 | 24 | cd .\src\dgindex 25 | 26 | call "%VSINSTPATH%\VC\Auxiliary\Build\vcvarsall.bat" x86 27 | 28 | jom /version >NUL 2>&1 29 | 30 | if "%ERRORLEVEL%" == "0" ( 31 | jom 32 | ) else ( 33 | nmake /nologo 34 | ) 35 | 36 | echo. 37 | 38 | endlocal 39 | 40 | pause 41 | -------------------------------------------------------------------------------- /nmake_build_wsdk71.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | rem Set up NASMPATH (Path termination must be a separator character.) 6 | rem set NASMPATH=\ 7 | 8 | cd .\src\dgindex 9 | 10 | call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x86 /xp /Release 11 | 12 | jom /version >NUL 2>&1 13 | 14 | if "%ERRORLEVEL%" == "0" ( 15 | jom 16 | ) else ( 17 | nmake /nologo 18 | ) 19 | 20 | echo. 21 | 22 | endlocal 23 | 24 | pause 25 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | #undef DGMPGDEC_GIT_VERSION 2 | -------------------------------------------------------------------------------- /src/dgdecode/AvisynthAPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Avisynth 2.5 API for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * based of the intial MPEG2Dec Avisytnh API Copyright (C) Mathias Born - May 2001 7 | * 8 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 9 | * 10 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * MPEG2Dec3 is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with GNU Make; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #include "global.h" 27 | #include "avisynth.h" 28 | #include "text-overlay.h" 29 | 30 | #define uc unsigned char 31 | 32 | class MPEG2Source: public IClip { 33 | protected: 34 | VideoInfo vi; 35 | int ovr_idct; 36 | int _PP_MODE; 37 | YV12PICT *out; 38 | unsigned char *bufY, *bufU, *bufV; // for 4:2:2 input support 39 | unsigned char *u444, *v444; // for RGB24 output 40 | 41 | public: 42 | MPEG2Source(const char* d2v, int _upConv); 43 | 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); 44 | ~MPEG2Source(); 45 | int MPEG2Source::getMatrix(int n); 46 | 47 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); 48 | void GetFrame(int n, unsigned char *buffer, int pitch); 49 | 50 | bool __stdcall GetParity(int n); 51 | void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env) {}; 52 | const VideoInfo& __stdcall GetVideoInfo() { return vi; } 53 | int __stdcall SetCacheHints(int cachehints, int frame_range) { return 0; }; // We do not pass cache requests upwards, only to the next filter. 54 | void override(int ovr_idct); 55 | void conv422toYUV422(const unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, 56 | int pitch1Y, int pitch1UV, int pitch2, int width, int height); 57 | 58 | CMPEG2Decoder m_decoder; 59 | }; 60 | 61 | class BlindPP : public GenericVideoFilter { 62 | int* QP; 63 | bool iPP; 64 | int PP_MODE; 65 | int moderate_h, moderate_v; 66 | YV12PICT *out; 67 | public: 68 | BlindPP(AVSValue args, IScriptEnvironment* env); 69 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); 70 | ~BlindPP(); 71 | void BlindPP::convYUV422to422(const unsigned char *src, unsigned char *py, unsigned char *pu, unsigned char *pv, 72 | int pitch1, int pitch2y, int pitch2uv, int width, int height); 73 | }; 74 | 75 | void conv420to422(const unsigned char *src, unsigned char *dst, int frame_type, int src_pitch, 76 | int dst_pitch, int width, int height); 77 | void conv420to422P_iSSE(const unsigned char *src, unsigned char *dst, int src_pitch, int dst_pitch, 78 | int width, int height); 79 | void conv422to444(const unsigned char *src, unsigned char *dst, int src_pitch, int dst_pitch, 80 | int width, int height); 81 | void conv422to444_iSSE(const unsigned char *src, unsigned char *dst, int src_pitch, int dst_pitch, 82 | int width, int height); 83 | void conv444toRGB24(const unsigned char *py, const unsigned char *pu, const unsigned char *pv, 84 | unsigned char *dst, int src_pitchY, int src_pitchUV, int dst_pitch, int width, 85 | int height, int matrix, int pc_scale); 86 | 87 | /* Macros for accessing easily frame pointers and pitch */ 88 | #define YRPLAN(a) (a)->GetReadPtr(PLANAR_Y) 89 | #define YWPLAN(a) (a)->GetWritePtr(PLANAR_Y) 90 | #define URPLAN(a) (a)->GetReadPtr(PLANAR_U) 91 | #define UWPLAN(a) (a)->GetWritePtr(PLANAR_U) 92 | #define VRPLAN(a) (a)->GetReadPtr(PLANAR_V) 93 | #define VWPLAN(a) (a)->GetWritePtr(PLANAR_V) 94 | #define YPITCH(a) (a)->GetPitch(PLANAR_Y) 95 | #define UPITCH(a) (a)->GetPitch(PLANAR_U) 96 | #define VPITCH(a) (a)->GetPitch(PLANAR_V) 97 | 98 | class Deblock : public GenericVideoFilter { 99 | private: 100 | bool mmx, isse; 101 | int nQuant; 102 | int nAOffset, nBOffset; 103 | int nWidth, nHeight; 104 | 105 | static inline int sat(int x, int min, int max) 106 | { return (x < min) ? min : ((x > max) ? max : x); } 107 | 108 | static inline int abs(int x) 109 | { return ( x < 0 ) ? -x : x; } 110 | 111 | static void DeblockHorEdge(unsigned char *srcp, int srcPitch, int ia, int ib); 112 | 113 | static void DeblockVerEdge(unsigned char *srcp, int srcPitch, int ia, int ib); 114 | public: 115 | static void DeblockPicture(unsigned char *srcp, int srcPitch, int w, int h, 116 | int q, int aOff, int bOff); 117 | 118 | Deblock(PClip _child, int q, int aOff, int bOff, bool _mmx, bool _isse, 119 | IScriptEnvironment* env); 120 | ~Deblock(); 121 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); 122 | }; 123 | 124 | class LumaYV12 : public GenericVideoFilter 125 | { 126 | double lumgain; 127 | int lumoff; 128 | 129 | public: 130 | LumaYV12(PClip _child, int _Lumaoffset, double _Lumagain, IScriptEnvironment* env); 131 | ~LumaYV12(); 132 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); 133 | 134 | private: 135 | bool use_SSE2; 136 | bool use_ISSE; 137 | bool SepFields; 138 | int lumGain; 139 | }; 140 | -------------------------------------------------------------------------------- /src/dgdecode/PostProcess.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSTPROCESS_H 2 | #define _POSTPROCESS_H 3 | 4 | #ifndef INLINE 5 | #ifdef WIN32 6 | #define INLINE __inline 7 | #endif 8 | #endif 9 | 10 | #define DEC_MBC 45+300 11 | #define DEC_MBR 36+300 12 | 13 | /**** mode flags to control postprocessing actions ****/ 14 | #define PP_DEBLOCK_Y_H 0x00000001 /* Luma horizontal deblocking */ 15 | #define PP_DEBLOCK_Y_V 0x00000002 /* Luma vertical deblocking */ 16 | #define PP_DEBLOCK_C_H 0x00000004 /* Chroma horizontal deblocking */ 17 | #define PP_DEBLOCK_C_V 0x00000008 /* Chroma vertical deblocking */ 18 | #define PP_DERING_Y 0x00000010 /* Luma deringing */ 19 | #define PP_DERING_C 0x00000020 /* Chroma deringing */ 20 | #define PP_DONT_COPY 0x10000000 /* Postprocessor will not copy src -> dst */ 21 | /* instead, it will operate on dst only */ 22 | 23 | /******************* general, useful macros ****************/ 24 | #define ABS(a) ( (a)>0 ? (a) : -(a) ) 25 | #define SIGN(a) ( (a)<0 ? -1 : 1 ) 26 | #define MIN(a, b) ( (a)<(b) ? (a) : (b) ) 27 | #define MAX(a, b) ( (a)>(b) ? (a) : (b) ) 28 | 29 | #if _MSC_VER >= 1600 30 | #include 31 | 32 | #else 33 | #define int8_t char 34 | #define uint8_t unsigned char 35 | #define int16_t short 36 | #define uint16_t unsigned short 37 | #define int32_t int 38 | #define uint32_t unsigned int 39 | #define int64_t __int64 40 | #define uint64_t unsigned __int64 41 | #endif 42 | #define QP_STORE_T int 43 | 44 | /******************** component function prototypes **************/ 45 | int deblock_horiz_useDC(uint8_t *v, int stride, int moderate_h); 46 | int deblock_horiz_DC_on(uint8_t *v, int stride, int QP); 47 | void deblock_horiz_lpf9(uint8_t *v, int stride, int QP); 48 | void deblock_horiz_default_filter(uint8_t *v, int stride, int QP); 49 | void deblock_horiz(uint8_t *image, int width, int stride, QP_STORE_T *QP_store, int QP_stride, int chromaFlag, int moderate_h); 50 | int deblock_vert_useDC(uint8_t *v, int stride, int moderate_v); 51 | int deblock_vert_DC_on(uint8_t *v, int stride, int QP); 52 | void deblock_vert_copy_and_unpack(int stride, uint8_t *source, uint64_t *dest, int n); 53 | void deblock_vert_choose_p1p2(uint8_t *v, int stride, uint64_t *p1p2, int QP); 54 | void deblock_vert_lpf9(uint64_t *v_local, uint64_t *p1p2, uint8_t *v, int stride); 55 | void deblock_vert_default_filter(uint8_t *v, int stride, int QP); 56 | void deblock_vert( uint8_t *image, int width, int stride, QP_STORE_T *QP_store, int QP_stride, int chromaFlag, int moderate_v); 57 | void fast_copy(unsigned char *src, int src_stride, 58 | unsigned char *dst, int dst_stride, 59 | int horizontal_size, int vertical_size); 60 | void dering( uint8_t *image, int width, int height, int stride, int *QP_store, int QP_stride, int chroma); 61 | 62 | void postprocess(unsigned char * src[], int src_stride, int UVsrc_stride, 63 | unsigned char * dst[], int dst_stride, int UVdst_stride, 64 | 65 | int horizontal_size, int vertical_size, 66 | QP_STORE_T *QP_store, int QP_stride, 67 | int mode, int moderate_h, int moderate_v, bool is422, bool iPP); 68 | int __cdecl dprintf(char* fmt, ...); 69 | void do_emms(); 70 | 71 | // New Deringing Algo: 72 | struct DERING_INFO 73 | { 74 | uint8_t *rangearray; 75 | uint8_t *thrarray; 76 | }; 77 | 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src/dgdecode/Utilities.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define MAGIC_NUMBER (0xdeadbeef) 4 | 5 | bool PutHintingData(unsigned char *video, unsigned int hint) 6 | { 7 | unsigned char *p; 8 | unsigned int i, magic_number = MAGIC_NUMBER; 9 | bool error = false; 10 | 11 | p = video; 12 | for (i = 0; i < 32; i++) 13 | { 14 | *p &= ~1; 15 | *p++ |= ((magic_number & (1 << i)) >> i); 16 | } 17 | for (i = 0; i < 32; i++) 18 | { 19 | *p &= ~1; 20 | *p++ |= ((hint & (1 << i)) >> i); 21 | } 22 | return error; 23 | } 24 | 25 | bool GetHintingData(unsigned char *video, unsigned int *hint) 26 | { 27 | unsigned char *p; 28 | unsigned int i, magic_number = 0; 29 | bool error = false; 30 | 31 | p = video; 32 | for (i = 0; i < 32; i++) 33 | { 34 | magic_number |= ((*p++ & 1) << i); 35 | } 36 | if (magic_number != MAGIC_NUMBER) 37 | { 38 | error = true; 39 | } 40 | else 41 | { 42 | *hint = 0; 43 | for (i = 0; i < 32; i++) 44 | { 45 | *hint |= ((*p++ & 1) << i); 46 | } 47 | } 48 | return error; 49 | } 50 | -------------------------------------------------------------------------------- /src/dgdecode/Utilities.h: -------------------------------------------------------------------------------- 1 | bool PutHintingData(unsigned char *video, unsigned int hint); 2 | bool GetHintingData(unsigned char *video, unsigned int *hint); 3 | 4 | #define HINT_INVALID 0x80000000 5 | #define PROGRESSIVE 0x00000001 6 | #define IN_PATTERN 0x00000002 7 | #define COLORIMETRY 0x0000001C 8 | #define COLORIMETRY_SHIFT 2 9 | -------------------------------------------------------------------------------- /src/dgdecode/alloc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Chia-chen Kuo - April 2001 3 | * 4 | * This file is part of DVD2AVI, a free MPEG-2 decoder 5 | * 6 | * DVD2AVI is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * DVD2AVI is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Make; see the file COPYING. If not, write to 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | // replace with one that doesn't need fixed size table - trbarry 3-22-2002 23 | 24 | #include 25 | #include "global.h" 26 | 27 | #define ptr_t unsigned int 28 | 29 | extern "C" void *aligned_malloc(size_t size, size_t alignment) 30 | { 31 | BYTE *mem_ptr; 32 | 33 | if (!alignment) 34 | { 35 | 36 | /* We have not to satisfy any alignment */ 37 | if ((mem_ptr = (BYTE *) malloc(size + 1)) != NULL) { 38 | 39 | /* Store (mem_ptr - "real allocated memory") in *(mem_ptr-1) */ 40 | *mem_ptr = 1; 41 | 42 | /* Return the mem_ptr pointer */ 43 | return (void *) (mem_ptr+1); 44 | 45 | } 46 | 47 | } else { 48 | BYTE *tmp; 49 | 50 | /* 51 | * Allocate the required size memory + alignment so we 52 | * can realign the data if necessary 53 | */ 54 | 55 | if ((tmp = (BYTE *) malloc(size + alignment)) != NULL) { 56 | 57 | /* Align the tmp pointer */ 58 | mem_ptr = 59 | (BYTE *) ((ptr_t) (tmp + alignment - 1) & 60 | (~(ptr_t) (alignment - 1))); 61 | 62 | /* 63 | * Special case where malloc have already satisfied the alignment 64 | * We must add alignment to mem_ptr because we must store 65 | * (mem_ptr - tmp) in *(mem_ptr-1) 66 | * If we do not add alignment to mem_ptr then *(mem_ptr-1) points 67 | * to a forbidden memory space 68 | */ 69 | if (mem_ptr == tmp) 70 | mem_ptr += alignment; 71 | 72 | /* 73 | * (mem_ptr - tmp) is stored in *(mem_ptr-1) so we are able to retrieve 74 | * the real malloc block allocated and free it in xvid_free 75 | */ 76 | *(mem_ptr - 1) = (BYTE) (mem_ptr - tmp); 77 | 78 | /* Return the aligned pointer */ 79 | return (void *) mem_ptr; 80 | 81 | } 82 | } 83 | 84 | return NULL; 85 | 86 | } 87 | 88 | extern "C" void aligned_free(void *mem_ptr) 89 | { 90 | /* *(mem_ptr - 1) give us the offset to the real malloc block */ 91 | if (mem_ptr) 92 | free((BYTE *) mem_ptr - *((BYTE *) mem_ptr - 1)); 93 | 94 | } 95 | 96 | 97 | // memory allocation for MPEG2Dec3. 98 | // 99 | // Changed this to handle/track both width/pitch for when 100 | // width != pitch and it simply makes things easier to have all 101 | // information in this struct. It now uses 32y/16uv byte alignment 102 | // by default, which makes internal bugs easier to catch. This can 103 | // easily be changed if needed. 104 | // 105 | // The definition of YV12PICT is in global.h 106 | // 107 | // tritical - May 16, 2005 108 | YV12PICT* create_YV12PICT(int height, int width, int chroma_format) 109 | { 110 | YV12PICT* pict; 111 | pict = (YV12PICT*)malloc(sizeof(YV12PICT)); 112 | int uvwidth, uvheight; 113 | if (chroma_format == 1) // 4:2:0 114 | { 115 | uvwidth = width>>1; 116 | uvheight = height>>1; 117 | } 118 | else if (chroma_format == 2) // 4:2:2 119 | { 120 | uvwidth = width>>1; 121 | uvheight = height; 122 | } 123 | else // 4:4:4 124 | { 125 | uvwidth = width; 126 | uvheight = height; 127 | } 128 | int uvpitch = (((uvwidth+15)>>4)<<4); 129 | int ypitch = uvpitch*2; 130 | pict->y = (unsigned char*)aligned_malloc(height*ypitch,32); 131 | pict->u = (unsigned char*)aligned_malloc(uvheight*uvpitch,16); 132 | pict->v = (unsigned char*)aligned_malloc(uvheight*uvpitch,16); 133 | pict->ypitch = ypitch; 134 | pict->uvpitch = uvpitch; 135 | pict->ywidth = width; 136 | pict->uvwidth = uvwidth; 137 | pict->yheight = height; 138 | pict->uvheight = uvheight; 139 | return pict; 140 | } 141 | 142 | void destroy_YV12PICT(YV12PICT * pict) 143 | { 144 | aligned_free(pict->y); 145 | aligned_free(pict->u); 146 | aligned_free(pict->v); 147 | free(pict); 148 | } 149 | -------------------------------------------------------------------------------- /src/dgdecode/avs/capi.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_CAPI_H 34 | #define AVS_CAPI_H 35 | 36 | #include "config.h" 37 | 38 | #ifdef AVS_POSIX 39 | // this is also defined in avs/posix.h 40 | #define __declspec(x) 41 | #endif 42 | 43 | #ifdef __cplusplus 44 | # define EXTERN_C extern "C" 45 | #else 46 | # define EXTERN_C 47 | #endif 48 | 49 | #ifdef AVS_WINDOWS 50 | #ifdef BUILDING_AVSCORE 51 | # if defined(GCC) && defined(X86_32) 52 | # define AVSC_CC 53 | # else // MSVC builds and 64-bit GCC 54 | # ifndef AVSC_USE_STDCALL 55 | # define AVSC_CC __cdecl 56 | # else 57 | # define AVSC_CC __stdcall 58 | # endif 59 | # endif 60 | #else // needed for programs that talk to AviSynth+ 61 | # ifndef AVSC_WIN32_GCC32 // see comment below 62 | # ifndef AVSC_USE_STDCALL 63 | # define AVSC_CC __cdecl 64 | # else 65 | # define AVSC_CC __stdcall 66 | # endif 67 | # else 68 | # define AVSC_CC 69 | # endif 70 | #endif 71 | # else 72 | # define AVSC_CC 73 | #endif 74 | 75 | // On 64-bit Windows, there's only one calling convention, 76 | // so there is no difference between MSVC and GCC. On 32-bit, 77 | // this isn't true. The convention that GCC needs to use to 78 | // even build AviSynth+ as 32-bit makes anything that uses 79 | // it incompatible with 32-bit MSVC builds of AviSynth+. 80 | // The AVSC_WIN32_GCC32 define is meant to provide a user 81 | // switchable way to make builds of FFmpeg to test 32-bit 82 | // GCC builds of AviSynth+ without having to screw around 83 | // with alternate headers, while still default to the usual 84 | // situation of using 32-bit MSVC builds of AviSynth+. 85 | 86 | // Hopefully, this situation will eventually be resolved 87 | // and a broadly compatible solution will arise so the 88 | // same 32-bit FFmpeg build can handle either MSVC or GCC 89 | // builds of AviSynth+. 90 | 91 | #define AVSC_INLINE static __inline 92 | 93 | #ifdef BUILDING_AVSCORE 94 | #ifdef AVS_WINDOWS 95 | # define AVSC_EXPORT __declspec(dllexport) 96 | # define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name 97 | #else 98 | # define AVSC_EXPORT EXTERN_C 99 | # define AVSC_API(ret, name) EXTERN_C ret AVSC_CC name 100 | #endif 101 | #else 102 | # define AVSC_EXPORT EXTERN_C __declspec(dllexport) 103 | # ifndef AVSC_NO_DECLSPEC 104 | # define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name 105 | # else 106 | # define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func) 107 | # endif 108 | #endif 109 | 110 | #endif //AVS_CAPI_H 111 | -------------------------------------------------------------------------------- /src/dgdecode/avs/config.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_CONFIG_H 34 | #define AVS_CONFIG_H 35 | 36 | // Undefine this to get cdecl calling convention 37 | #define AVSC_USE_STDCALL 1 38 | 39 | // NOTE TO PLUGIN AUTHORS: 40 | // Because FRAME_ALIGN can be substantially higher than the alignment 41 | // a plugin actually needs, plugins should not use FRAME_ALIGN to check for 42 | // alignment. They should always request the exact alignment value they need. 43 | // This is to make sure that plugins work over the widest range of AviSynth 44 | // builds possible. 45 | #define FRAME_ALIGN 64 46 | 47 | #if defined(_M_AMD64) || defined(__x86_64) 48 | # define X86_64 49 | #elif defined(_M_IX86) || defined(__i386__) 50 | # define X86_32 51 | // VS2017 introduced _M_ARM64 52 | #elif defined(_M_ARM64) || defined(__aarch64__) 53 | # define ARM64 54 | #elif defined(_M_ARM) || defined(__arm__) 55 | # define ARM32 56 | #else 57 | # error Unsupported CPU architecture. 58 | #endif 59 | 60 | // VC++ LLVM-Clang-cl MinGW-Gnu 61 | // MSVC x x 62 | // MSVC_PURE x 63 | // CLANG x 64 | // GCC x 65 | 66 | #if defined(__clang__) 67 | // Check clang first. clang-cl also defines __MSC_VER 68 | // We set MSVC because they are mostly compatible 69 | # define CLANG 70 | #if defined(_MSC_VER) 71 | # define MSVC 72 | # define AVS_FORCEINLINE __attribute__((always_inline)) 73 | #else 74 | # define AVS_FORCEINLINE __attribute__((always_inline)) inline 75 | #endif 76 | #elif defined(_MSC_VER) 77 | # define MSVC 78 | # define MSVC_PURE 79 | # define AVS_FORCEINLINE __forceinline 80 | #elif defined(__GNUC__) 81 | # define GCC 82 | # define AVS_FORCEINLINE __attribute__((always_inline)) inline 83 | #else 84 | # error Unsupported compiler. 85 | # define AVS_FORCEINLINE inline 86 | # undef __forceinline 87 | # define __forceinline inline 88 | #endif 89 | 90 | #if defined(_WIN32) 91 | # define AVS_WINDOWS 92 | #elif defined(__linux__) 93 | # define AVS_LINUX 94 | # define AVS_POSIX 95 | #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) 96 | # define AVS_BSD 97 | # define AVS_POSIX 98 | #elif defined(__APPLE__) 99 | # define AVS_MACOS 100 | # define AVS_POSIX 101 | #else 102 | # error Operating system unsupported. 103 | #endif 104 | 105 | // useful warnings disabler macros for supported compilers 106 | 107 | #if defined(_MSC_VER) 108 | #define DISABLE_WARNING_PUSH __pragma(warning( push )) 109 | #define DISABLE_WARNING_POP __pragma(warning( pop )) 110 | #define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber )) 111 | 112 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(4101) 113 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(4505) 114 | // other warnings you want to deactivate... 115 | 116 | #elif defined(__GNUC__) || defined(__clang__) 117 | #define DO_PRAGMA(X) _Pragma(#X) 118 | #define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push) 119 | #define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop) 120 | #define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName) 121 | 122 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(-Wunused-variable) 123 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(-Wunused-function) 124 | // other warnings you want to deactivate... 125 | 126 | #else 127 | #define DISABLE_WARNING_PUSH 128 | #define DISABLE_WARNING_POP 129 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE 130 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION 131 | // other warnings you want to deactivate... 132 | 133 | #endif 134 | 135 | #if defined(AVS_POSIX) 136 | #define NEW_AVSVALUE 137 | #else 138 | #define NEW_AVSVALUE 139 | #endif 140 | 141 | #if defined(AVS_WINDOWS) 142 | // Windows XP does not have proper initialization for 143 | // thread local variables. 144 | // Use workaround instead __declspec(thread) 145 | #define XP_TLS 146 | #endif 147 | 148 | #endif //AVS_CONFIG_H 149 | -------------------------------------------------------------------------------- /src/dgdecode/avs/cpuid.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifndef AVSCORE_CPUID_H 33 | #define AVSCORE_CPUID_H 34 | 35 | // For GetCPUFlags. These are backwards-compatible with those in VirtualDub. 36 | // ending with SSE4_2 37 | // For emulation see https://software.intel.com/en-us/articles/intel-software-development-emulator 38 | enum { 39 | /* oldest CPU to support extension */ 40 | CPUF_FORCE = 0x01, // N/A 41 | CPUF_FPU = 0x02, // 386/486DX 42 | CPUF_MMX = 0x04, // P55C, K6, PII 43 | CPUF_INTEGER_SSE = 0x08, // PIII, Athlon 44 | CPUF_SSE = 0x10, // PIII, Athlon XP/MP 45 | CPUF_SSE2 = 0x20, // PIV, K8 46 | CPUF_3DNOW = 0x40, // K6-2 47 | CPUF_3DNOW_EXT = 0x80, // Athlon 48 | CPUF_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2, which 49 | // only Hammer will have anyway) 50 | CPUF_SSE3 = 0x100, // PIV+, K8 Venice 51 | CPUF_SSSE3 = 0x200, // Core 2 52 | CPUF_SSE4 = 0x400, 53 | CPUF_SSE4_1 = 0x400, // Penryn, Wolfdale, Yorkfield 54 | CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer 55 | CPUF_SSE4_2 = 0x1000, // Nehalem 56 | // AVS+ 57 | CPUF_AVX2 = 0x2000, // Haswell 58 | CPUF_FMA3 = 0x4000, 59 | CPUF_F16C = 0x8000, 60 | CPUF_MOVBE = 0x10000, // Big Endian move 61 | CPUF_POPCNT = 0x20000, 62 | CPUF_AES = 0x40000, 63 | CPUF_FMA4 = 0x80000, 64 | 65 | CPUF_AVX512F = 0x100000, // AVX-512 Foundation. 66 | CPUF_AVX512DQ = 0x200000, // AVX-512 DQ (Double/Quad granular) Instructions 67 | CPUF_AVX512PF = 0x400000, // AVX-512 Prefetch 68 | CPUF_AVX512ER = 0x800000, // AVX-512 Exponential and Reciprocal 69 | CPUF_AVX512CD = 0x1000000, // AVX-512 Conflict Detection 70 | CPUF_AVX512BW = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions 71 | CPUF_AVX512VL = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions 72 | CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit 73 | CPUF_AVX512VBMI = 0x10000000,// AVX-512 VBMI 74 | }; 75 | 76 | #ifdef BUILDING_AVSCORE 77 | int GetCPUFlags(); 78 | void SetMaxCPU(int new_flags); 79 | #endif 80 | 81 | #endif // AVSCORE_CPUID_H 82 | -------------------------------------------------------------------------------- /src/dgdecode/avs/posix.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifdef AVS_POSIX 33 | #ifndef AVSCORE_POSIX_H 34 | #define AVSCORE_POSIX_H 35 | 36 | #ifdef __cplusplus 37 | #include 38 | #endif 39 | #include 40 | #include 41 | 42 | // Define these MSVC-extension used in Avisynth 43 | #define __single_inheritance 44 | 45 | // These things don't exist in Linux 46 | #define __declspec(x) 47 | #define lstrlen strlen 48 | #define lstrcmp strcmp 49 | #define lstrcmpi strcasecmp 50 | #define _stricmp strcasecmp 51 | #define _strnicmp strncasecmp 52 | #define _strdup strdup 53 | #define SetCurrentDirectory(x) chdir(x) 54 | #define SetCurrentDirectoryW(x) chdir(x) 55 | #define GetCurrentDirectoryW(x) getcwd(x) 56 | #define _putenv putenv 57 | #define _alloca alloca 58 | 59 | // Borrowing some compatibility macros from AvxSynth, slightly modified 60 | #define UInt32x32To64(a, b) ((uint64_t)(((uint64_t)((uint32_t)(a))) * ((uint32_t)(b)))) 61 | #define Int64ShrlMod32(a, b) ((uint64_t)((uint64_t)(a) >> (b))) 62 | #define Int32x32To64(a, b) ((int64_t)(((int64_t)((long)(a))) * ((long)(b)))) 63 | 64 | #define InterlockedIncrement(x) __sync_add_and_fetch((x), 1) 65 | #define InterlockedDecrement(x) __sync_sub_and_fetch((x), 1) 66 | #define MulDiv(nNumber, nNumerator, nDenominator) (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator)) 67 | 68 | #ifndef TRUE 69 | #define TRUE true 70 | #endif 71 | 72 | #ifndef FALSE 73 | #define FALSE false 74 | #endif 75 | 76 | #define S_FALSE (0x00000001) 77 | #define E_FAIL (0x80004005) 78 | #define FAILED(hr) ((hr) & 0x80000000) 79 | #define SUCCEEDED(hr) (!FAILED(hr)) 80 | 81 | // Statuses copied from comments in exception.cpp 82 | #define STATUS_GUARD_PAGE_VIOLATION 0x80000001 83 | #define STATUS_DATATYPE_MISALIGNMENT 0x80000002 84 | #define STATUS_BREAKPOINT 0x80000003 85 | #define STATUS_SINGLE_STEP 0x80000004 86 | #define STATUS_ACCESS_VIOLATION 0xc0000005 87 | #define STATUS_IN_PAGE_ERROR 0xc0000006 88 | #define STATUS_INVALID_HANDLE 0xc0000008 89 | #define STATUS_NO_MEMORY 0xc0000017 90 | #define STATUS_ILLEGAL_INSTRUCTION 0xc000001d 91 | #define STATUS_NONCONTINUABLE_EXCEPTION 0xc0000025 92 | #define STATUS_INVALID_DISPOSITION 0xc0000026 93 | #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xc000008c 94 | #define STATUS_FLOAT_DENORMAL_OPERAND 0xc000008d 95 | #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xc000008e 96 | #define STATUS_FLOAT_INEXACT_RESULT 0xc000008f 97 | #define STATUS_FLOAT_INVALID_OPERATION 0xc0000090 98 | #define STATUS_FLOAT_OVERFLOW 0xc0000091 99 | #define STATUS_FLOAT_STACK_CHECK 0xc0000092 100 | #define STATUS_FLOAT_UNDERFLOW 0xc0000093 101 | #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xc0000094 102 | #define STATUS_INTEGER_OVERFLOW 0xc0000095 103 | #define STATUS_PRIVILEGED_INSTRUCTION 0xc0000096 104 | #define STATUS_STACK_OVERFLOW 0xc00000fd 105 | 106 | // Calling convension 107 | #define __stdcall 108 | #define __cdecl 109 | 110 | #endif // AVSCORE_POSIX_H 111 | #endif // AVS_POSIX 112 | -------------------------------------------------------------------------------- /src/dgdecode/avs/types.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_TYPES_H 34 | #define AVS_TYPES_H 35 | 36 | // Define all types necessary for interfacing with avisynth.dll 37 | #include 38 | #include 39 | #ifdef __cplusplus 40 | #include 41 | #include 42 | #else 43 | #include 44 | #include 45 | #endif 46 | 47 | // Raster types used by VirtualDub & Avisynth 48 | typedef uint32_t Pixel32; 49 | typedef uint8_t BYTE; 50 | 51 | // Audio Sample information 52 | typedef float SFLOAT; 53 | 54 | #endif //AVS_TYPES_H 55 | -------------------------------------------------------------------------------- /src/dgdecode/global.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Chia-chen Kuo - April 2001 3 | * 4 | * This file is part of DVD2AVI, a free MPEG-2 decoder 5 | * Ported to C++ by Mathias Born - May 2001 6 | * 7 | * DVD2AVI is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * DVD2AVI is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Make; see the file COPYING. If not, write to 19 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 20 | * 21 | */ 22 | 23 | //#include "stdafx.h" 24 | #define GLOBAL 25 | #include "global.h" 26 | 27 | int testint; 28 | 29 | void CheckCPU() 30 | { 31 | __asm 32 | { 33 | mov eax, 1 34 | cpuid 35 | test edx, 0x00800000 // STD MMX 36 | jz TEST_SSE 37 | mov [cpu.mmx], 1 38 | TEST_SSE: 39 | test edx, 0x02000000 // STD SSE 40 | jz TEST_3DNOW 41 | mov [cpu.ssemmx], 1 42 | mov [cpu.ssefpu], 1 43 | 44 | test edx, 0x04000000 // STD SSE2 TRB 12/30/2001 45 | jz TEST_3DNOW 46 | mov [cpu.sse2mmx], 1 47 | 48 | TEST_3DNOW: 49 | mov eax, 0x80000001 50 | cpuid 51 | test edx, 0x80000000 // 3D NOW 52 | jz TEST_SSEMMX 53 | mov [cpu._3dnow], 1 54 | 55 | TEST_SSEMMX: 56 | test edx, 0x00400000 // SSE MMX 57 | jz TEST_END 58 | mov [cpu.ssemmx], 1 59 | TEST_END: 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/dgdecode/gui.rc: -------------------------------------------------------------------------------- 1 | //Microsoft Developer Studio generated resource script. 2 | // 3 | #include "resource.h" 4 | #include "..\config.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #define APSTUDIO_HIDDEN_SYMBOLS 12 | #include "windows.h" 13 | #undef APSTUDIO_HIDDEN_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | #undef APSTUDIO_READONLY_SYMBOLS 17 | 18 | ///////////////////////////////////////////////////////////////////////////// 19 | // English (U.S.) resources 20 | 21 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 22 | #ifdef _WIN32 23 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 24 | #pragma code_page(1252) 25 | #endif //_WIN32 26 | 27 | #ifndef _MAC 28 | ///////////////////////////////////////////////////////////////////////////// 29 | // 30 | // Version 31 | // 32 | 33 | VS_VERSION_INFO VERSIONINFO 34 | FILEVERSION 2,0,0,5 35 | FILEFLAGSMASK 0x3fL 36 | #ifdef _DEBUG 37 | FILEFLAGS 0x29L 38 | #else 39 | FILEFLAGS 0x28L 40 | #endif 41 | FILEOS 0x4L 42 | FILETYPE 0x2L 43 | FILESUBTYPE 0x0L 44 | BEGIN 45 | BLOCK "StringFileInfo" 46 | BEGIN 47 | BLOCK "040904b0" 48 | BEGIN 49 | VALUE "Comments", "DGDecode is the decoding component of DGMPGDec, an MPEG decoding and frame serving utility.\0" 50 | VALUE "CompanyName", "Freeware licensed under GPL\0" 51 | VALUE "LegalCopyright", "Copyright (C) 2001-2021 Donald A. Graft\0" 52 | #ifdef DGMPGDEC_GIT_VERSION 53 | VALUE "FileVersion", DGMPGDEC_GIT_VERSION "\0" 54 | #else 55 | VALUE "FileVersion", "2.0.0.5\0" 56 | #endif 57 | END 58 | END 59 | BLOCK "VarFileInfo" 60 | BEGIN 61 | VALUE "Translation", 0x409, 1200 62 | END 63 | END 64 | 65 | 66 | #endif // !_MAC 67 | 68 | 69 | #endif // English (U.S.) resources 70 | ///////////////////////////////////////////////////////////////////////////// 71 | 72 | 73 | 74 | #ifndef APSTUDIO_INVOKED 75 | ///////////////////////////////////////////////////////////////////////////// 76 | // 77 | // Generated from the TEXTINCLUDE 3 resource. 78 | // 79 | 80 | 81 | ///////////////////////////////////////////////////////////////////////////// 82 | #endif // not APSTUDIO_INVOKED 83 | 84 | -------------------------------------------------------------------------------- /src/dgdecode/mc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Motion Compensation for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 7 | * 8 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * MPEG2Dec3 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | #include "mc.h" 25 | #include "global.h" 26 | 27 | MCFuncPtr ppppf_motion[2][2][4]; 28 | 29 | void Choose_Prediction(bool fastMC) 30 | { 31 | // if (cpu.mmx) => MMX is needed anyway 32 | 33 | ppppf_motion[0][0][0] = MC_put_8_mmx; 34 | ppppf_motion[0][0][1] = MC_put_y8_mmx; 35 | ppppf_motion[0][0][2] = MC_put_x8_mmx; 36 | ppppf_motion[0][0][3] = MC_put_xy8_mmx; 37 | 38 | ppppf_motion[0][1][0] = MC_put_16_mmx; 39 | ppppf_motion[0][1][1] = MC_put_y16_mmx; 40 | ppppf_motion[0][1][2] = MC_put_x16_mmx; 41 | ppppf_motion[0][1][3] = MC_put_xy16_mmx; 42 | 43 | ppppf_motion[1][0][0] = MC_avg_8_mmx; 44 | ppppf_motion[1][0][1] = MC_avg_y8_mmx; 45 | ppppf_motion[1][0][2] = MC_avg_x8_mmx; 46 | ppppf_motion[1][0][3] = MC_avg_xy8_mmx; 47 | 48 | ppppf_motion[1][1][0] = MC_avg_16_mmx; 49 | ppppf_motion[1][1][1] = MC_avg_y16_mmx; 50 | ppppf_motion[1][1][2] = MC_avg_x16_mmx; 51 | ppppf_motion[1][1][3] = MC_avg_xy16_mmx; 52 | 53 | 54 | if (cpu._3dnow) 55 | { 56 | ppppf_motion[0][0][0] = MC_put_8_3dnow; 57 | ppppf_motion[0][0][1] = MC_put_y8_3dnow; 58 | ppppf_motion[0][0][2] = MC_put_x8_3dnow; 59 | 60 | ppppf_motion[0][1][0] = MC_put_16_3dnow; 61 | ppppf_motion[0][1][1] = MC_put_y16_3dnow; 62 | ppppf_motion[0][1][2] = MC_put_x16_3dnow; 63 | 64 | ppppf_motion[1][0][0] = MC_avg_8_3dnow; 65 | ppppf_motion[1][0][1] = MC_avg_y8_3dnow; 66 | ppppf_motion[1][0][2] = MC_avg_x8_3dnow; 67 | 68 | ppppf_motion[1][1][0] = MC_avg_16_3dnow; 69 | ppppf_motion[1][1][1] = MC_avg_y16_3dnow; 70 | ppppf_motion[1][1][2] = MC_avg_x16_3dnow; 71 | 72 | if (fastMC) 73 | { 74 | ppppf_motion[0][0][3] = MC_put_xy8_3dnow_FAST; 75 | ppppf_motion[0][1][3] = MC_put_xy16_3dnow_FAST; 76 | ppppf_motion[1][0][3] = MC_avg_xy8_3dnow_FAST; 77 | ppppf_motion[1][1][3] = MC_avg_xy16_3dnow_FAST; 78 | } 79 | else 80 | { 81 | ppppf_motion[0][0][3] = MC_put_xy8_3dnow_AC; 82 | ppppf_motion[0][1][3] = MC_put_xy16_3dnow_AC; 83 | ppppf_motion[1][0][3] = MC_avg_xy8_3dnow_AC; 84 | ppppf_motion[1][1][3] = MC_avg_xy16_3dnow_AC; 85 | } 86 | } 87 | 88 | if (cpu.ssemmx) 89 | { 90 | ppppf_motion[0][0][0] = MC_put_8_mmxext; 91 | ppppf_motion[0][0][1] = MC_put_y8_mmxext; 92 | ppppf_motion[0][0][2] = MC_put_x8_mmxext; 93 | 94 | ppppf_motion[0][1][0] = MC_put_16_mmxext; 95 | ppppf_motion[0][1][1] = MC_put_y16_mmxext; 96 | ppppf_motion[0][1][2] = MC_put_x16_mmxext; 97 | 98 | ppppf_motion[1][0][0] = MC_avg_8_mmxext; 99 | ppppf_motion[1][0][1] = MC_avg_y8_mmxext; 100 | ppppf_motion[1][0][2] = MC_avg_x8_mmxext; 101 | 102 | 103 | ppppf_motion[1][1][0] = MC_avg_16_mmxext; 104 | ppppf_motion[1][1][1] = MC_avg_y16_mmxext; 105 | ppppf_motion[1][1][2] = MC_avg_x16_mmxext; 106 | 107 | if (fastMC) { 108 | ppppf_motion[0][0][3] = MC_put_xy8_mmxext_FAST; 109 | ppppf_motion[0][1][3] = MC_put_xy16_mmxext_FAST; 110 | ppppf_motion[1][0][3] = MC_avg_xy8_mmxext_FAST; 111 | ppppf_motion[1][1][3] = MC_avg_xy16_mmxext_FAST; 112 | } else { 113 | ppppf_motion[0][0][3] = MC_put_xy8_mmxext_AC; 114 | ppppf_motion[0][1][3] = MC_put_xy16_mmxext_AC; 115 | ppppf_motion[1][0][3] = MC_avg_xy8_mmxext_AC; 116 | ppppf_motion[1][1][3] = MC_avg_xy16_mmxext_AC; 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/dgdecode/mc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Motion Compensation for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 7 | * 8 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * MPEG2Dec3 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | typedef void (MCFunc) (unsigned char * dest, unsigned char * ref, int stride, int offs, int height); 25 | typedef MCFunc* MCFuncPtr; 26 | 27 | MCFunc MC_put_8_mmx; 28 | MCFunc MC_put_x8_mmx; 29 | MCFunc MC_put_y8_mmx; 30 | MCFunc MC_put_xy8_mmx; 31 | 32 | MCFunc MC_put_16_mmx; 33 | MCFunc MC_put_x16_mmx; 34 | MCFunc MC_put_y16_mmx; 35 | MCFunc MC_put_xy16_mmx; 36 | 37 | MCFunc MC_avg_8_mmx; 38 | MCFunc MC_avg_x8_mmx; 39 | MCFunc MC_avg_y8_mmx; 40 | MCFunc MC_avg_xy8_mmx; 41 | 42 | MCFunc MC_avg_16_mmx; 43 | MCFunc MC_avg_x16_mmx; 44 | MCFunc MC_avg_y16_mmx; 45 | MCFunc MC_avg_xy16_mmx; 46 | 47 | MCFunc MC_put_8_3dnow; 48 | MCFunc MC_put_x8_3dnow; 49 | MCFunc MC_put_y8_3dnow; 50 | MCFunc MC_put_xy8_3dnow_AC; 51 | MCFunc MC_put_xy8_3dnow_FAST; 52 | 53 | MCFunc MC_put_16_3dnow; 54 | MCFunc MC_put_x16_3dnow; 55 | MCFunc MC_put_y16_3dnow; 56 | MCFunc MC_put_xy16_3dnow_AC; 57 | MCFunc MC_put_xy16_3dnow_FAST; 58 | 59 | MCFunc MC_avg_8_3dnow; 60 | MCFunc MC_avg_x8_3dnow; 61 | MCFunc MC_avg_y8_3dnow; 62 | MCFunc MC_avg_xy8_3dnow_AC; 63 | MCFunc MC_avg_xy8_3dnow_FAST; 64 | 65 | MCFunc MC_avg_16_3dnow; 66 | MCFunc MC_avg_x16_3dnow; 67 | MCFunc MC_avg_y16_3dnow; 68 | MCFunc MC_avg_xy16_3dnow_AC; 69 | MCFunc MC_avg_xy16_3dnow_FAST; 70 | 71 | extern "C" { 72 | 73 | MCFunc MC_put_8_mmxext; 74 | MCFunc MC_put_x8_mmxext; 75 | MCFunc MC_put_y8_mmxext; 76 | MCFunc MC_put_xy8_mmxext_AC; 77 | MCFunc MC_put_xy8_mmxext_FAST; 78 | 79 | MCFunc MC_put_16_mmxext; 80 | MCFunc MC_put_x16_mmxext; 81 | MCFunc MC_put_y16_mmxext; 82 | MCFunc MC_put_xy16_mmxext_AC; 83 | MCFunc MC_put_xy16_mmxext_FAST; 84 | 85 | MCFunc MC_avg_8_mmxext; 86 | MCFunc MC_avg_x8_mmxext; 87 | MCFunc MC_avg_y8_mmxext; 88 | MCFunc MC_avg_xy8_mmxext_AC; 89 | MCFunc MC_avg_xy8_mmxext_FAST; 90 | 91 | MCFunc MC_avg_16_mmxext; 92 | MCFunc MC_avg_x16_mmxext; 93 | MCFunc MC_avg_y16_mmxext; 94 | MCFunc MC_avg_xy16_mmxext_AC; 95 | MCFunc MC_avg_xy16_mmxext_FAST; 96 | 97 | } 98 | 99 | // Form prediction (motion compensation) function pointer array (GetPic.c) - Vlad59 04-20-2002 100 | extern MCFuncPtr ppppf_motion[2][2][4]; 101 | void Choose_Prediction(bool fastMC); 102 | -------------------------------------------------------------------------------- /src/dgdecode/misc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Misc Stuff (profiling) for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 7 | * 8 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * MPEG2Dec3 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | #include "misc.h" 25 | #include 26 | #include 27 | #include 28 | 29 | #ifdef PROFILING 30 | 31 | static ui64 local; 32 | static char buffer[256]; 33 | 34 | unsigned __int64 read_counter(void) 35 | { 36 | unsigned __int64 ts; 37 | unsigned __int32 ts1, ts2; 38 | __asm { 39 | rdtsc 40 | mov ts1, eax 41 | mov ts2, edx 42 | } 43 | ts = ((unsigned __int64) ts2 << 32) | ((unsigned __int64) ts1); 44 | return ts; 45 | } 46 | 47 | // get CPU frequency in Hz (1 Mz precision) 48 | ui64 get_freq(void) 49 | { 50 | unsigned __int64 x = 0; 51 | time_t i; 52 | i = time(NULL); 53 | while (i == time(NULL)); 54 | x -= read_counter(); 55 | i++; 56 | while (i == time(NULL)); 57 | x += read_counter(); 58 | return x; 59 | } 60 | 61 | void init_first(ts* timers) 62 | { 63 | memset(timers,0,sizeof(ts)); 64 | timers->div = 0; timers->sum = 0; 65 | // timers->freq = get_freq()/1000; 66 | timers->freq = 1412*1000000; // shortcut for my athlon xp 1600+ (1.4 Gz) 67 | } 68 | 69 | void init_timers(ts* timers) 70 | { 71 | timers->idct = 0; 72 | timers->conv = 0; 73 | timers->mcpy = 0; 74 | timers->post = 0; 75 | timers->dec = 0; 76 | timers->bit = 0; 77 | timers->decMB = 0; 78 | timers->mcmp = 0; 79 | timers->addb = 0; 80 | timers->overall = 0; 81 | if (timers->div > 25) { timers->div = 0; timers->sum = 0; } 82 | } 83 | 84 | void start_timer() 85 | { 86 | local = read_counter(); 87 | } 88 | 89 | void start_timer2(ui64* timer) 90 | { 91 | *timer -= read_counter(); 92 | } 93 | 94 | void stop_timer(ui64* timer) 95 | { 96 | *timer += (read_counter() - local); 97 | } 98 | 99 | void stop_timer2(ui64* timer) 100 | { 101 | *timer += read_counter(); 102 | } 103 | 104 | void timer_debug(ts* timers) 105 | { 106 | ts tim = *timers; 107 | //tim.freq = ; 108 | // sprintf(buffer,"conv = %I64d ",tim.conv); 109 | // sprintf(buffer,"idct = %I64d overall=%I64d idct%% = %f",tim.idct,tim.overall,(double)tim.idct*100/tim.overall); 110 | sprintf(buffer,"| dec%% = %f > mcmp%% = %f addb%% = %f idct%% = %f decMB%% = %f bit%% = %f | conv%% = %f | post%% = %f | mcpy%% = %f | msec = %f fps = %f mean = %f", 111 | (double)tim.dec*100/tim.overall, 112 | (double)tim.idct*100/tim.overall, 113 | (double)tim.addb*100/tim.overall, 114 | (double)tim.mcmp*100/tim.overall, 115 | (double)tim.decMB*100/tim.overall, 116 | (double)tim.bit*100/tim.overall, 117 | (double)tim.conv*100/tim.overall, 118 | (double)tim.post*100/tim.overall, 119 | (double)tim.mcpy*100/tim.overall, 120 | (double)tim.overall*1000/tim.freq, 121 | tim.freq/(double)tim.overall, 122 | (tim.freq)/((double)tim.sum/tim.div) 123 | ); 124 | OutputDebugString(buffer); 125 | } 126 | #endif 127 | -------------------------------------------------------------------------------- /src/dgdecode/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Misc Stuff (profiling) for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 7 | * 8 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * MPEG2Dec3 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #define ui64 unsigned __int64 29 | 30 | struct ts 31 | { 32 | ui64 idct; 33 | ui64 conv; 34 | ui64 mcpy; 35 | ui64 post; 36 | ui64 dec; 37 | ui64 bit; 38 | ui64 decMB; 39 | ui64 mcmp; 40 | ui64 addb; 41 | ui64 overall; 42 | ui64 sum; 43 | int div; 44 | ui64 freq; 45 | }; 46 | 47 | ui64 read_counter(void); 48 | ui64 get_freq(void); 49 | 50 | void init_first(ts* timers); 51 | void init_timers(ts* timers); 52 | void start_timer(); 53 | void start_timer2(ui64* timer); 54 | void stop_timer(ui64* timer); 55 | void stop_timer2(ui64* timer); 56 | void timer_debug(ts* tim); 57 | -------------------------------------------------------------------------------- /src/dgdecode/mpeg2dec.cpp: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | 3 | BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) 4 | { 5 | switch (ul_reason_for_call) 6 | { 7 | case DLL_PROCESS_ATTACH: 8 | CheckCPU(); 9 | case DLL_THREAD_ATTACH: 10 | case DLL_THREAD_DETACH: 11 | case DLL_PROCESS_DETACH: 12 | break; 13 | } 14 | return TRUE; 15 | } 16 | -------------------------------------------------------------------------------- /src/dgdecode/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by gui.rc 4 | // 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NEXT_RESOURCE_VALUE 101 11 | #define _APS_NEXT_COMMAND_VALUE 40001 12 | #define _APS_NEXT_CONTROL_VALUE 1000 13 | #define _APS_NEXT_SYMED_VALUE 101 14 | #endif 15 | #endif 16 | -------------------------------------------------------------------------------- /src/dgdecode/skl_nasm.h: -------------------------------------------------------------------------------- 1 | ;/******************************************************** 2 | ; * Some code. Copyright (C) 2003 by Pascal Massimino. * 3 | ; * All Rights Reserved. (http://skal.planet-d.net) * 4 | ; * For Educational/Academic use ONLY. See 'LICENSE.TXT'.* 5 | ; ********************************************************/ 6 | ;////////////////////////////////////////////////////////// 7 | ;// NASM macros 8 | ;////////////////////////////////////////////////////////// 9 | 10 | %ifdef LINUX 11 | 12 | ;////////////////////////////////////////////////////////// 13 | ; LINUX / egcs / macros 14 | ;////////////////////////////////////////////////////////// 15 | 16 | %macro extrn 1 17 | extern %1 18 | %define %1 %1 19 | %endmacro 20 | %macro globl 1 21 | global %1 22 | %define %1 %1 23 | %endmacro 24 | 25 | %macro DATA 0 26 | [section data align=16 write alloc USE32] 27 | %endmacro 28 | %macro TEXT 0 29 | [section text align=16 nowrite alloc exec USE32] 30 | %endmacro 31 | 32 | %endif ; LINUX 33 | 34 | ;////////////////////////////////////////////////////////// 35 | 36 | %ifdef WIN32 37 | 38 | %macro extrn 1 39 | extern _%1 40 | %define %1 _%1 41 | %endmacro 42 | 43 | %macro globl 1 44 | global _%1 45 | %define %1 _%1 46 | %endmacro 47 | 48 | %macro DATA 0 49 | [section .data align=16 write alloc USE32] 50 | %endmacro 51 | %macro TEXT 0 52 | [section .text align=16 nowrite alloc exec USE32] 53 | %endmacro 54 | 55 | %endif ; WIN32 56 | 57 | ;////////////////////////////////////////////////////////// 58 | ; 59 | ; MACRO for timing. NASM. 60 | ; Total additional code size is 0xb0. 61 | ; this keep code alignment right. 62 | 63 | ;extrn Skl_Cur_Count_ 64 | ;extrn Skl_Print_Tics 65 | 66 | %macro SKL_USE_RDSTC 0 67 | extrn SKL_RDTSC_0_ASM 68 | extrn SKL_RDTSC_1_ASM 69 | extrn SKL_RDTSC_2_ASM 70 | %endmacro 71 | %define SKL_RDTSC_OFFSET 15 ; check value with skl_rdtsc.h... 72 | 73 | %macro SKL_RDTSC_IN 0 74 | SKL_USE_RDSTC 75 | call SKL_RDTSC_0_ASM 76 | .Skl_RDTSC_Loop_: 77 | call SKL_RDTSC_1_ASM 78 | %endmacro 79 | 80 | ;%macro SKL_RDTSC_OUT 0 81 | ; call SKL_RDTSC_2_ASM 82 | ; dec dword [Skl_Cur_Count_] 83 | ; jge near .Skl_RDTSC_Loop_ 84 | ; push dword 53 85 | ; call Skl_Print_Tics 86 | ;%endmacro 87 | 88 | ;////////////////////////////////////////////////////////// 89 | -------------------------------------------------------------------------------- /src/dgdecode64/AVISynthAPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Avisynth 2.5 API for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * based of the intial MPEG2Dec Avisytnh API Copyright (C) Mathias Born - May 2001 7 | * 8 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 9 | * 10 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * MPEG2Dec3 is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with GNU Make; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #ifndef MPEG2DECPLUS_AVS_API_H 27 | #define MPEG2DECPLUS_AVS_API_H 28 | 29 | #include 30 | #include "avisynth.h" 31 | #ifdef _WIN32 32 | //#include "avs/win.h" 33 | #else 34 | #include "win_import_min.h" 35 | #endif 36 | #include "MPEG2Decoder.h" 37 | 38 | 39 | class MPEG2Source: public IClip { 40 | VideoInfo vi; 41 | //int _PP_MODE; 42 | uint8_t *bufY, *bufU, *bufV; // for 4:2:2 input support 43 | CMPEG2Decoder* decoder; 44 | bool luminanceFlag; 45 | uint8_t luminanceTable[256]; 46 | bool has_at_least_v8; 47 | 48 | public: 49 | MPEG2Source(const char* d2v, int idct, bool showQ, int _info, IScriptEnvironment* env); 50 | ~MPEG2Source() {} 51 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); 52 | bool __stdcall GetParity(int n); 53 | void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env) {}; 54 | const VideoInfo& __stdcall GetVideoInfo() { return vi; } 55 | int __stdcall SetCacheHints(int hints, int) { return hints == CACHE_GET_MTMODE ? MT_SERIALIZED : 0; }; 56 | static AVSValue __cdecl create(AVSValue args, void*, IScriptEnvironment* env); 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/dgdecode64/DGDecode.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION 2,0,0,5 6 | PRODUCTVERSION 2,0,0,5 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0x0L 9 | FILEOS VOS__WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE VFT2_UNKNOWN 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | BEGIN 17 | VALUE "FileDescription", "DGDecode for AviSynth 2.6/AviSynth+/Vapoursynth" 18 | VALUE "FileVersion", "2.0.0.5" 19 | VALUE "InternalName", "DGDecode" 20 | VALUE "OriginalFilename", "DGDecode.dll" 21 | VALUE "ProductName", "DGDecode" 22 | VALUE "ProductVersion", "2.0.0.5" 23 | END 24 | END 25 | BLOCK "VarFileInfo" 26 | BEGIN 27 | VALUE "Translation", 0x409, 1252 28 | END 29 | END 30 | -------------------------------------------------------------------------------- /src/dgdecode64/DGDecode.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30204.135 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DGDecode", "DGDecode.vcxproj", "{BE45DDEC-9C54-4E57-BE8C-3CDE734BEAA6}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {BE45DDEC-9C54-4E57-BE8C-3CDE734BEAA6}.Debug|x64.ActiveCfg = Debug|x64 17 | {BE45DDEC-9C54-4E57-BE8C-3CDE734BEAA6}.Debug|x64.Build.0 = Debug|x64 18 | {BE45DDEC-9C54-4E57-BE8C-3CDE734BEAA6}.Debug|x86.ActiveCfg = Debug|Win32 19 | {BE45DDEC-9C54-4E57-BE8C-3CDE734BEAA6}.Debug|x86.Build.0 = Debug|Win32 20 | {BE45DDEC-9C54-4E57-BE8C-3CDE734BEAA6}.Release|x64.ActiveCfg = Release|x64 21 | {BE45DDEC-9C54-4E57-BE8C-3CDE734BEAA6}.Release|x64.Build.0 = Release|x64 22 | {BE45DDEC-9C54-4E57-BE8C-3CDE734BEAA6}.Release|x86.ActiveCfg = Release|Win32 23 | {BE45DDEC-9C54-4E57-BE8C-3CDE734BEAA6}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | VisualSVNWorkingCopyRoot = . 30 | SolutionGuid = {80DFC486-AC15-406C-BBDA-6D722A495010} 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /src/dgdecode64/DGDecode.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;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 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files 121 | 122 | 123 | Header Files 124 | 125 | 126 | 127 | 128 | Resource Files 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /src/dgdecode64/Readme64.txt: -------------------------------------------------------------------------------- 1 | DGDecode 2 | -------- 3 | 4 | This is DGDecode.dll for Vapoursynth/AviSynth+ and 64-bit operation. 5 | The single DLL supports both Vapoursynth and Avisynth operation. 6 | 7 | Usage 8 | ----- 9 | 10 | DGDecode(string "d2v", int "idct", bool "showQ", int "info") 11 | 12 | Vapoursynth script 13 | ------------------ 14 | 15 | import vapoursynth as vs 16 | core = vs.get_core() 17 | core.std.LoadPlugin(".../DGDecode.dll") 18 | video = core.dgdecode.MPEG2Source(r"cut.d2v") 19 | video.set_output() 20 | 21 | Parameters 22 | ---------- 23 | 24 | - d2v 25 | The path of the dv2 file. 26 | 27 | - idct 28 | The iDCT algorithm to use. 29 | 0: Follow the d2v specification. 30 | 1,2,3,6,7: AP922 integer (same as SSE2/MMX). 31 | 4: SSE2/AVX2 LLM (single precision floating point, SSE2/AVX2 determination is automatic). 32 | 5: IEEE 1180 reference (double precision floating point). 33 | Default: -1. 34 | 35 | - showQ 36 | It displays macroblock quantizers. 37 | Default: False. 38 | 39 | - info 40 | It prints debug information. 41 | 0: Do not display. 42 | 1: Overlay on video frame. 43 | 2: Output with OutputDebugString(). (The contents are confirmed by DebugView.exe). 44 | 3: Embed hints in 64 bytes of the frame upper left corner. 45 | Default: 0. 46 | 47 | -------------------------------------------------------------------------------- /src/dgdecode64/Vapoursynth Notes.txt: -------------------------------------------------------------------------------- 1 | Vapoursynth Usage Notes 2 | ----------------------- 3 | 4 | DGDecodeNV is usable in Vapoursynth either as a native Vapoursynth 5 | filter, or as a native Avisynth filter. Currently, the utility 6 | filters DGDenoise(), DGBob(), etc., are available only when DGDecodeNV 7 | is used in native Avisynth mode. 8 | 9 | Note that in Vapoursynth the defines true/false are required to be 10 | True/False, i.e., the first letters are capitalized. Here are 11 | sample scripts delivering full bit depth for both modes: 12 | 13 | Vapoursynth native mode: 14 | 15 | ----- 16 | import vapoursynth as vs 17 | core = vs.get_core() 18 | core.std.LoadPlugin(".../DGDecodeNV.dll") 19 | video = core.dgdecodenv.DGSource(".../beach.dgi",fulldepth=True) 20 | video.set_output() 21 | ----- 22 | 23 | Avisynth native mode: 24 | 25 | ----- 26 | import vapoursynth as vs 27 | core = vs.get_core() 28 | core.avs.LoadPlugin(".../DGDecodeNV.dll") 29 | video = core.avs.DGSource(".../beach.dgi",fulldepth=True) 30 | video.set_output() 31 | ----- 32 | 33 | Copyright (c) 2018 Donald A. Graft, All rights reserved 34 | -------------------------------------------------------------------------------- /src/dgdecode64/avs/capi.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_CAPI_H 34 | #define AVS_CAPI_H 35 | 36 | #include "config.h" 37 | 38 | #ifdef AVS_POSIX 39 | // this is also defined in avs/posix.h 40 | #define __declspec(x) 41 | #endif 42 | 43 | #ifdef __cplusplus 44 | # define EXTERN_C extern "C" 45 | #else 46 | # define EXTERN_C 47 | #endif 48 | 49 | #ifdef AVS_WINDOWS 50 | #ifdef BUILDING_AVSCORE 51 | # if defined(GCC) && defined(X86_32) 52 | # define AVSC_CC 53 | # else // MSVC builds and 64-bit GCC 54 | # ifndef AVSC_USE_STDCALL 55 | # define AVSC_CC __cdecl 56 | # else 57 | # define AVSC_CC __stdcall 58 | # endif 59 | # endif 60 | #else // needed for programs that talk to AviSynth+ 61 | # ifndef AVSC_WIN32_GCC32 // see comment below 62 | # ifndef AVSC_USE_STDCALL 63 | # define AVSC_CC __cdecl 64 | # else 65 | # define AVSC_CC __stdcall 66 | # endif 67 | # else 68 | # define AVSC_CC 69 | # endif 70 | #endif 71 | # else 72 | # define AVSC_CC 73 | #endif 74 | 75 | // On 64-bit Windows, there's only one calling convention, 76 | // so there is no difference between MSVC and GCC. On 32-bit, 77 | // this isn't true. The convention that GCC needs to use to 78 | // even build AviSynth+ as 32-bit makes anything that uses 79 | // it incompatible with 32-bit MSVC builds of AviSynth+. 80 | // The AVSC_WIN32_GCC32 define is meant to provide a user 81 | // switchable way to make builds of FFmpeg to test 32-bit 82 | // GCC builds of AviSynth+ without having to screw around 83 | // with alternate headers, while still default to the usual 84 | // situation of using 32-bit MSVC builds of AviSynth+. 85 | 86 | // Hopefully, this situation will eventually be resolved 87 | // and a broadly compatible solution will arise so the 88 | // same 32-bit FFmpeg build can handle either MSVC or GCC 89 | // builds of AviSynth+. 90 | 91 | #define AVSC_INLINE static __inline 92 | 93 | #ifdef BUILDING_AVSCORE 94 | #ifdef AVS_WINDOWS 95 | # define AVSC_EXPORT __declspec(dllexport) 96 | # define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name 97 | #else 98 | # define AVSC_EXPORT EXTERN_C 99 | # define AVSC_API(ret, name) EXTERN_C ret AVSC_CC name 100 | #endif 101 | #else 102 | # define AVSC_EXPORT EXTERN_C __declspec(dllexport) 103 | # ifndef AVSC_NO_DECLSPEC 104 | # define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name 105 | # else 106 | # define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func) 107 | # endif 108 | #endif 109 | 110 | #endif //AVS_CAPI_H 111 | -------------------------------------------------------------------------------- /src/dgdecode64/avs/config.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_CONFIG_H 34 | #define AVS_CONFIG_H 35 | 36 | // Undefine this to get cdecl calling convention 37 | #define AVSC_USE_STDCALL 1 38 | 39 | // NOTE TO PLUGIN AUTHORS: 40 | // Because FRAME_ALIGN can be substantially higher than the alignment 41 | // a plugin actually needs, plugins should not use FRAME_ALIGN to check for 42 | // alignment. They should always request the exact alignment value they need. 43 | // This is to make sure that plugins work over the widest range of AviSynth 44 | // builds possible. 45 | #define FRAME_ALIGN 64 46 | 47 | #if defined(_M_AMD64) || defined(__x86_64) 48 | # define X86_64 49 | #elif defined(_M_IX86) || defined(__i386__) 50 | # define X86_32 51 | // VS2017 introduced _M_ARM64 52 | #elif defined(_M_ARM64) || defined(__aarch64__) 53 | # define ARM64 54 | #elif defined(_M_ARM) || defined(__arm__) 55 | # define ARM32 56 | #else 57 | # error Unsupported CPU architecture. 58 | #endif 59 | 60 | // VC++ LLVM-Clang-cl MinGW-Gnu 61 | // MSVC x x 62 | // MSVC_PURE x 63 | // CLANG x 64 | // GCC x 65 | 66 | #if defined(__clang__) 67 | // Check clang first. clang-cl also defines __MSC_VER 68 | // We set MSVC because they are mostly compatible 69 | # define CLANG 70 | #if defined(_MSC_VER) 71 | # define MSVC 72 | # define AVS_FORCEINLINE __attribute__((always_inline)) 73 | #else 74 | # define AVS_FORCEINLINE __attribute__((always_inline)) inline 75 | #endif 76 | #elif defined(_MSC_VER) 77 | # define MSVC 78 | # define MSVC_PURE 79 | # define AVS_FORCEINLINE __forceinline 80 | #elif defined(__GNUC__) 81 | # define GCC 82 | # define AVS_FORCEINLINE __attribute__((always_inline)) inline 83 | #else 84 | # error Unsupported compiler. 85 | # define AVS_FORCEINLINE inline 86 | # undef __forceinline 87 | # define __forceinline inline 88 | #endif 89 | 90 | #if defined(_WIN32) 91 | # define AVS_WINDOWS 92 | #elif defined(__linux__) 93 | # define AVS_LINUX 94 | # define AVS_POSIX 95 | #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) 96 | # define AVS_BSD 97 | # define AVS_POSIX 98 | #elif defined(__APPLE__) 99 | # define AVS_MACOS 100 | # define AVS_POSIX 101 | #else 102 | # error Operating system unsupported. 103 | #endif 104 | 105 | // useful warnings disabler macros for supported compilers 106 | 107 | #if defined(_MSC_VER) 108 | #define DISABLE_WARNING_PUSH __pragma(warning( push )) 109 | #define DISABLE_WARNING_POP __pragma(warning( pop )) 110 | #define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber )) 111 | 112 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(4101) 113 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(4505) 114 | // other warnings you want to deactivate... 115 | 116 | #elif defined(__GNUC__) || defined(__clang__) 117 | #define DO_PRAGMA(X) _Pragma(#X) 118 | #define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push) 119 | #define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop) 120 | #define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName) 121 | 122 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(-Wunused-variable) 123 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(-Wunused-function) 124 | // other warnings you want to deactivate... 125 | 126 | #else 127 | #define DISABLE_WARNING_PUSH 128 | #define DISABLE_WARNING_POP 129 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE 130 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION 131 | // other warnings you want to deactivate... 132 | 133 | #endif 134 | 135 | #if defined(AVS_POSIX) 136 | #define NEW_AVSVALUE 137 | #else 138 | #define NEW_AVSVALUE 139 | #endif 140 | 141 | #if defined(AVS_WINDOWS) 142 | // Windows XP does not have proper initialization for 143 | // thread local variables. 144 | // Use workaround instead __declspec(thread) 145 | #define XP_TLS 146 | #endif 147 | 148 | #endif //AVS_CONFIG_H 149 | -------------------------------------------------------------------------------- /src/dgdecode64/avs/cpuid.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifndef AVSCORE_CPUID_H 33 | #define AVSCORE_CPUID_H 34 | 35 | // For GetCPUFlags. These are backwards-compatible with those in VirtualDub. 36 | // ending with SSE4_2 37 | // For emulation see https://software.intel.com/en-us/articles/intel-software-development-emulator 38 | enum { 39 | /* oldest CPU to support extension */ 40 | CPUF_FORCE = 0x01, // N/A 41 | CPUF_FPU = 0x02, // 386/486DX 42 | CPUF_MMX = 0x04, // P55C, K6, PII 43 | CPUF_INTEGER_SSE = 0x08, // PIII, Athlon 44 | CPUF_SSE = 0x10, // PIII, Athlon XP/MP 45 | CPUF_SSE2 = 0x20, // PIV, K8 46 | CPUF_3DNOW = 0x40, // K6-2 47 | CPUF_3DNOW_EXT = 0x80, // Athlon 48 | CPUF_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2, which 49 | // only Hammer will have anyway) 50 | CPUF_SSE3 = 0x100, // PIV+, K8 Venice 51 | CPUF_SSSE3 = 0x200, // Core 2 52 | CPUF_SSE4 = 0x400, 53 | CPUF_SSE4_1 = 0x400, // Penryn, Wolfdale, Yorkfield 54 | CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer 55 | CPUF_SSE4_2 = 0x1000, // Nehalem 56 | // AVS+ 57 | CPUF_AVX2 = 0x2000, // Haswell 58 | CPUF_FMA3 = 0x4000, 59 | CPUF_F16C = 0x8000, 60 | CPUF_MOVBE = 0x10000, // Big Endian move 61 | CPUF_POPCNT = 0x20000, 62 | CPUF_AES = 0x40000, 63 | CPUF_FMA4 = 0x80000, 64 | 65 | CPUF_AVX512F = 0x100000, // AVX-512 Foundation. 66 | CPUF_AVX512DQ = 0x200000, // AVX-512 DQ (Double/Quad granular) Instructions 67 | CPUF_AVX512PF = 0x400000, // AVX-512 Prefetch 68 | CPUF_AVX512ER = 0x800000, // AVX-512 Exponential and Reciprocal 69 | CPUF_AVX512CD = 0x1000000, // AVX-512 Conflict Detection 70 | CPUF_AVX512BW = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions 71 | CPUF_AVX512VL = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions 72 | CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit 73 | CPUF_AVX512VBMI = 0x10000000,// AVX-512 VBMI 74 | }; 75 | 76 | #ifdef BUILDING_AVSCORE 77 | int GetCPUFlags(); 78 | void SetMaxCPU(int new_flags); 79 | #endif 80 | 81 | #endif // AVSCORE_CPUID_H 82 | -------------------------------------------------------------------------------- /src/dgdecode64/avs/posix.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifdef AVS_POSIX 33 | #ifndef AVSCORE_POSIX_H 34 | #define AVSCORE_POSIX_H 35 | 36 | #ifdef __cplusplus 37 | #include 38 | #endif 39 | #include 40 | #include 41 | 42 | // Define these MSVC-extension used in Avisynth 43 | #define __single_inheritance 44 | 45 | // These things don't exist in Linux 46 | #define __declspec(x) 47 | #define lstrlen strlen 48 | #define lstrcmp strcmp 49 | #define lstrcmpi strcasecmp 50 | #define _stricmp strcasecmp 51 | #define _strnicmp strncasecmp 52 | #define _strdup strdup 53 | #define SetCurrentDirectory(x) chdir(x) 54 | #define SetCurrentDirectoryW(x) chdir(x) 55 | #define GetCurrentDirectoryW(x) getcwd(x) 56 | #define _putenv putenv 57 | #define _alloca alloca 58 | 59 | // Borrowing some compatibility macros from AvxSynth, slightly modified 60 | #define UInt32x32To64(a, b) ((uint64_t)(((uint64_t)((uint32_t)(a))) * ((uint32_t)(b)))) 61 | #define Int64ShrlMod32(a, b) ((uint64_t)((uint64_t)(a) >> (b))) 62 | #define Int32x32To64(a, b) ((int64_t)(((int64_t)((long)(a))) * ((long)(b)))) 63 | 64 | #define InterlockedIncrement(x) __sync_add_and_fetch((x), 1) 65 | #define InterlockedDecrement(x) __sync_sub_and_fetch((x), 1) 66 | #define MulDiv(nNumber, nNumerator, nDenominator) (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator)) 67 | 68 | #ifndef TRUE 69 | #define TRUE true 70 | #endif 71 | 72 | #ifndef FALSE 73 | #define FALSE false 74 | #endif 75 | 76 | #define S_FALSE (0x00000001) 77 | #define E_FAIL (0x80004005) 78 | #define FAILED(hr) ((hr) & 0x80000000) 79 | #define SUCCEEDED(hr) (!FAILED(hr)) 80 | 81 | // Statuses copied from comments in exception.cpp 82 | #define STATUS_GUARD_PAGE_VIOLATION 0x80000001 83 | #define STATUS_DATATYPE_MISALIGNMENT 0x80000002 84 | #define STATUS_BREAKPOINT 0x80000003 85 | #define STATUS_SINGLE_STEP 0x80000004 86 | #define STATUS_ACCESS_VIOLATION 0xc0000005 87 | #define STATUS_IN_PAGE_ERROR 0xc0000006 88 | #define STATUS_INVALID_HANDLE 0xc0000008 89 | #define STATUS_NO_MEMORY 0xc0000017 90 | #define STATUS_ILLEGAL_INSTRUCTION 0xc000001d 91 | #define STATUS_NONCONTINUABLE_EXCEPTION 0xc0000025 92 | #define STATUS_INVALID_DISPOSITION 0xc0000026 93 | #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xc000008c 94 | #define STATUS_FLOAT_DENORMAL_OPERAND 0xc000008d 95 | #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xc000008e 96 | #define STATUS_FLOAT_INEXACT_RESULT 0xc000008f 97 | #define STATUS_FLOAT_INVALID_OPERATION 0xc0000090 98 | #define STATUS_FLOAT_OVERFLOW 0xc0000091 99 | #define STATUS_FLOAT_STACK_CHECK 0xc0000092 100 | #define STATUS_FLOAT_UNDERFLOW 0xc0000093 101 | #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xc0000094 102 | #define STATUS_INTEGER_OVERFLOW 0xc0000095 103 | #define STATUS_PRIVILEGED_INSTRUCTION 0xc0000096 104 | #define STATUS_STACK_OVERFLOW 0xc00000fd 105 | 106 | // Calling convension 107 | #define __stdcall 108 | #define __cdecl 109 | 110 | #endif // AVSCORE_POSIX_H 111 | #endif // AVS_POSIX 112 | -------------------------------------------------------------------------------- /src/dgdecode64/avs/types.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_TYPES_H 34 | #define AVS_TYPES_H 35 | 36 | // Define all types necessary for interfacing with avisynth.dll 37 | #include 38 | #include 39 | #ifdef __cplusplus 40 | #include 41 | #include 42 | #else 43 | #include 44 | #include 45 | #endif 46 | 47 | // Raster types used by VirtualDub & Avisynth 48 | typedef uint32_t Pixel32; 49 | typedef uint8_t BYTE; 50 | 51 | // Audio Sample information 52 | typedef float SFLOAT; 53 | 54 | #endif //AVS_TYPES_H 55 | -------------------------------------------------------------------------------- /src/dgdecode64/color_convert.h: -------------------------------------------------------------------------------- 1 | #ifndef MPEG2DECPLUS_COLOR_CONVERT_H 2 | #define MPEG2DECPLUS_COLOR_CONVERT_H 3 | 4 | #include 5 | 6 | void conv420to422P(const uint8_t *src, uint8_t *dst, int src_pitch, int dst_pitch, 7 | int width, int height); 8 | 9 | void conv420to422I(const uint8_t *src, uint8_t *dst, int src_pitch, int dst_pitch, 10 | int width, int height); 11 | 12 | void conv422to444(const uint8_t *src, uint8_t *dst, int src_pitch, int dst_pitch, 13 | int width, int height); 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/dgdecode64/global.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Chia-chen Kuo - April 2001 3 | * 4 | * This file is part of DVD2AVI, a free MPEG-2 decoder 5 | * Ported to C++ by Mathias Born - May 2001 6 | * 7 | * DVD2AVI is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * DVD2AVI is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Make; see the file COPYING. If not, write to 19 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 20 | * 21 | */ 22 | 23 | 24 | #define GLOBAL 25 | #include "global.h" 26 | 27 | int testint; 28 | -------------------------------------------------------------------------------- /src/dgdecode64/idct.h: -------------------------------------------------------------------------------- 1 | #ifndef MPEG2DECPLUS_IDCT_H 2 | #define MPEG2DECPLUS_IDCT_H 3 | 4 | #include 5 | 6 | void __fastcall idct_ref_sse3(int16_t* block) noexcept; 7 | 8 | void __fastcall prefetch_ref() noexcept; 9 | 10 | void __fastcall idct_ap922_sse2(int16_t* block) noexcept; 11 | 12 | void __fastcall prefetch_ap922() noexcept; 13 | 14 | void __fastcall idct_llm_float_sse2(int16_t* block) noexcept; 15 | 16 | void __fastcall idct_llm_float_avx2(int16_t* block) noexcept; 17 | 18 | void __fastcall prefetch_llm_float_sse2() noexcept; 19 | 20 | void __fastcall prefetch_llm_float_avx2() noexcept; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/dgdecode64/idct_llm_float_sse2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #ifndef _WIN32 3 | #include "win_import_min.h" 4 | #endif 5 | #include "idct.h" 6 | 7 | 8 | alignas(64) static const float llm_coefs[] = { 9 | 1.175876f, 1.175876f, 1.175876f, 1.175876f, 10 | -1.961571f, -1.961571f, -1.961571f, -1.961571f, 11 | -0.390181f, -0.390181f, -0.390181f, -0.390181f, 12 | -0.899976f, -0.899976f, -0.899976f, -0.899976f, 13 | -2.562915f, -2.562915f, -2.562915f, -2.562915f, 14 | 0.298631f, 0.298631f, 0.298631f, 0.298631f, 15 | 2.053120f, 2.053120f, 2.053120f, 2.053120f, 16 | 3.072711f, 3.072711f, 3.072711f, 3.072711f, 17 | 1.501321f, 1.501321f, 1.501321f, 1.501321f, 18 | 0.541196f, 0.541196f, 0.541196f, 0.541196f, 19 | -1.847759f, -1.847759f, -1.847759f, -1.847759f, 20 | 0.765367f, 0.765367f, 0.765367f, 0.765367f, 21 | }; 22 | 23 | 24 | static inline void short_to_float(const short* srcp, float*dstp) noexcept 25 | { 26 | const __m128i zero = _mm_setzero_si128(); 27 | 28 | for (int i = 0; i < 64; i += 8) { 29 | __m128i s = _mm_load_si128(reinterpret_cast(srcp + i)); 30 | __m128i mask = _mm_cmpgt_epi16(zero, s); 31 | __m128 d0 = _mm_cvtepi32_ps(_mm_unpacklo_epi16(s, mask)); 32 | __m128 d1 = _mm_cvtepi32_ps(_mm_unpackhi_epi16(s, mask)); 33 | _mm_store_ps(dstp + i, d0); 34 | _mm_store_ps(dstp + i + 4, d1); 35 | } 36 | } 37 | 38 | 39 | static inline void idct_8x4_with_transpose(const float* srcp, float* dstp) noexcept 40 | { 41 | __m128 s0 = _mm_load_ps(srcp); 42 | __m128 s1 = _mm_load_ps(srcp + 8); 43 | __m128 s2 = _mm_load_ps(srcp + 16); 44 | __m128 s3 = _mm_load_ps(srcp + 24); 45 | _MM_TRANSPOSE4_PS(s0, s1, s2, s3); 46 | __m128 s4 = _mm_load_ps(srcp + 4); 47 | __m128 s5 = _mm_load_ps(srcp + 12); 48 | __m128 s6 = _mm_load_ps(srcp + 20); 49 | __m128 s7 = _mm_load_ps(srcp + 28); 50 | _MM_TRANSPOSE4_PS(s4, s5, s6, s7); 51 | 52 | __m128 z0 = _mm_add_ps(s1, s7); 53 | __m128 z1 = _mm_add_ps(s3, s5); 54 | __m128 z2 = _mm_add_ps(s3, s7); 55 | __m128 z3 = _mm_add_ps(s1, s5); 56 | __m128 z4 = _mm_mul_ps(_mm_add_ps(z0, z1), _mm_load_ps(llm_coefs)); 57 | 58 | z2 =_mm_add_ps(_mm_mul_ps(z2, _mm_load_ps(llm_coefs + 4)), z4); 59 | z3 =_mm_add_ps(_mm_mul_ps(z3, _mm_load_ps(llm_coefs + 8)), z4); 60 | z0 =_mm_mul_ps(z0, _mm_load_ps(llm_coefs + 12)); 61 | z1 =_mm_mul_ps(z1, _mm_load_ps(llm_coefs + 16)); 62 | 63 | __m128 b3 =_mm_add_ps(_mm_add_ps(_mm_mul_ps(s7, _mm_load_ps(llm_coefs + 20)), z0), z2); 64 | __m128 b2 =_mm_add_ps(_mm_add_ps(_mm_mul_ps(s5, _mm_load_ps(llm_coefs + 24)), z1), z3); 65 | __m128 b1 =_mm_add_ps(_mm_add_ps(_mm_mul_ps(s3, _mm_load_ps(llm_coefs + 28)), z1), z2); 66 | __m128 b0 =_mm_add_ps(_mm_add_ps(_mm_mul_ps(s1, _mm_load_ps(llm_coefs + 32)), z0), z3); 67 | 68 | z4 = _mm_mul_ps(_mm_add_ps(s2, s6), _mm_load_ps(llm_coefs + 36)); 69 | z0=_mm_add_ps(s0, s4); 70 | z1=_mm_sub_ps(s0, s4); 71 | 72 | z2=_mm_add_ps(z4, _mm_mul_ps(s6, _mm_load_ps(llm_coefs + 40))); 73 | z3=_mm_add_ps(z4, _mm_mul_ps(s2, _mm_load_ps(llm_coefs + 44))); 74 | 75 | s0 = _mm_add_ps(z0, z3); 76 | s3 = _mm_sub_ps(z0, z3); 77 | s1 = _mm_add_ps(z1, z2); 78 | s2 = _mm_sub_ps(z1, z2); 79 | 80 | _mm_store_ps(dstp , _mm_add_ps(s0, b0)); 81 | _mm_store_ps(dstp + 56, _mm_sub_ps(s0, b0)); 82 | _mm_store_ps(dstp + 8, _mm_add_ps(s1, b1)); 83 | _mm_store_ps(dstp + 48, _mm_sub_ps(s1, b1)); 84 | _mm_store_ps(dstp + 16, _mm_add_ps(s2, b2)); 85 | _mm_store_ps(dstp + 40, _mm_sub_ps(s2, b2)); 86 | _mm_store_ps(dstp + 24, _mm_add_ps(s3, b3)); 87 | _mm_store_ps(dstp + 32, _mm_sub_ps(s3, b3)); 88 | } 89 | 90 | 91 | static inline void float_to_dst_llm(const float* srcp, int16_t* dstp) noexcept 92 | { 93 | static const __m128 one_eighth = _mm_set1_ps(0.1250f); 94 | static const __m128i minimum = _mm_set1_epi16(-256); 95 | static const __m128i maximum = _mm_set1_epi16(255); 96 | 97 | for (int i = 0; i < 64; i += 8) { 98 | __m128 s0 = _mm_load_ps(srcp + i); 99 | __m128 s1 = _mm_load_ps(srcp + i + 4); 100 | s0 = _mm_mul_ps(s0, one_eighth); 101 | s1 = _mm_mul_ps(s1, one_eighth); 102 | __m128i d = _mm_packs_epi32(_mm_cvtps_epi32(s0), _mm_cvtps_epi32(s1)); 103 | d = _mm_min_epi16(_mm_max_epi16(d, minimum), maximum); 104 | _mm_store_si128(reinterpret_cast<__m128i*>(dstp + i), d); 105 | } 106 | } 107 | 108 | 109 | void __fastcall idct_llm_float_sse2(int16_t* block) noexcept 110 | { 111 | alignas(64) float blockf[64]; 112 | alignas(64) float tmp[64]; 113 | 114 | short_to_float(block, blockf); 115 | 116 | idct_8x4_with_transpose(blockf, tmp); 117 | idct_8x4_with_transpose(blockf + 32, tmp + 4); 118 | 119 | idct_8x4_with_transpose(tmp, blockf); 120 | idct_8x4_with_transpose(tmp + 32, blockf + 4); 121 | 122 | float_to_dst_llm(blockf, block); 123 | } 124 | 125 | 126 | void __fastcall prefetch_llm_float_sse2() noexcept 127 | { 128 | _mm_prefetch(reinterpret_cast(llm_coefs), _MM_HINT_NTA); 129 | _mm_prefetch(reinterpret_cast(llm_coefs + 16), _MM_HINT_NTA); 130 | _mm_prefetch(reinterpret_cast(llm_coefs + 32), _MM_HINT_NTA); 131 | } 132 | 133 | -------------------------------------------------------------------------------- /src/dgdecode64/mc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Motion Compensation for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 7 | * 8 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * MPEG2Dec3 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | #ifndef MPEG2DEC_MC_H 25 | #define MPEG2DEC_MC_H 26 | 27 | #include 28 | 29 | typedef void (MCFunc) (uint8_t* dest, const uint8_t* ref, int stride, int offs, int height); 30 | typedef MCFunc* MCFuncPtr; 31 | 32 | // Form prediction (motion compensation) function pointer array (GetPic.c) - Vlad59 04-20-2002 33 | extern MCFuncPtr ppppf_motion[2][2][4]; 34 | void Choose_Prediction(void); 35 | 36 | #endif // MPEG2DEC_MC_H 37 | -------------------------------------------------------------------------------- /src/dgdecode64/misc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Misc Stuff for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 7 | * 8 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * MPEG2Dec3 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | 25 | #include 26 | #ifdef _WIN32 27 | #include 28 | #define WIN32_LEAN_AND_MEAN 29 | #define NOMINMAX 30 | #include 31 | #else 32 | #include 33 | #include "win_import_min.h" 34 | #endif 35 | #include "misc.h" 36 | 37 | 38 | size_t __cdecl dprintf(char* fmt, ...) 39 | { 40 | char printString[1024]; 41 | 42 | va_list argp; 43 | 44 | va_start(argp, fmt); 45 | vsprintf_s(printString, 1024, fmt, argp); 46 | va_end(argp); 47 | OutputDebugString(printString); 48 | return strlen(printString); 49 | } 50 | 51 | 52 | void __stdcall 53 | fast_copy(const uint8_t* src, const int src_stride, uint8_t* dst, 54 | const int dst_stride, const int horizontal_size, int vertical_size) noexcept 55 | { 56 | if (vertical_size == 0) { 57 | return; 58 | } else if (horizontal_size == src_stride && src_stride == dst_stride) { 59 | memcpy(dst, src, static_cast(horizontal_size) * vertical_size); 60 | } else { 61 | do { 62 | memcpy(dst, src, horizontal_size); 63 | dst += dst_stride; 64 | src += src_stride; 65 | } while (--vertical_size != 0); 66 | } 67 | } 68 | 69 | 70 | #ifdef _WIN32 71 | enum { 72 | CPU_NO_X86_SIMD = 0x000000, 73 | CPU_SSE2_SUPPORT = 0x000001, 74 | CPU_SSE3_SUPPORT = 0x000002, 75 | CPU_SSSE3_SUPPORT = 0x000004, 76 | CPU_SSE4_1_SUPPORT = 0x000008, 77 | CPU_SSE4_2_SUPPORT = 0x000010, 78 | CPU_SSE4_A_SUPPORT = 0x000020, 79 | CPU_FMA4_SUPPORT = 0x000040, 80 | CPU_FMA3_SUPPORT = 0x000080, 81 | CPU_AVX_SUPPORT = 0x000100, 82 | CPU_AVX2_SUPPORT = 0x000200, 83 | CPU_AVX512F_SUPPORT = 0x000400, 84 | CPU_AVX512DQ_SUPPORT = 0x000800, 85 | CPU_AVX512IFMA52_SUPPORT = 0x001000, 86 | CPU_AVX512PF_SUPPORT = 0x002000, 87 | CPU_AVX512ER_SUPPORT = 0x004000, 88 | CPU_AVX512CD_SUPPORT = 0x008000, 89 | CPU_AVX512BW_SUPPORT = 0x010000, 90 | CPU_AVX512VL_SUPPORT = 0x020000, 91 | CPU_AVX512VBMI_SUPPORT = 0x040000, 92 | }; 93 | 94 | 95 | static __forceinline bool is_bit_set(int bitfield, int bit) noexcept 96 | { 97 | return (bitfield & (1 << bit)) != 0; 98 | } 99 | 100 | static uint32_t get_simd_support_info(void) noexcept 101 | { 102 | uint32_t ret = 0; 103 | int regs[4] = {0}; 104 | 105 | __cpuid(regs, 0x00000001); 106 | if (is_bit_set(regs[3], 26)) { 107 | ret |= CPU_SSE2_SUPPORT; 108 | } 109 | if (is_bit_set(regs[2], 0)) { 110 | ret |= CPU_SSE3_SUPPORT; 111 | } 112 | if (is_bit_set(regs[2], 9)) { 113 | ret |= CPU_SSSE3_SUPPORT; 114 | } 115 | if (is_bit_set(regs[2], 19)) { 116 | ret |= CPU_SSE4_1_SUPPORT; 117 | } 118 | if (is_bit_set(regs[2], 26)) { 119 | ret |= CPU_SSE4_2_SUPPORT; 120 | } 121 | if (is_bit_set(regs[2], 27)) { 122 | if (is_bit_set(regs[2], 28)) { 123 | ret |= CPU_AVX_SUPPORT; 124 | } 125 | if (is_bit_set(regs[2], 12)) { 126 | ret |= CPU_FMA3_SUPPORT; 127 | } 128 | } 129 | 130 | regs[3] = 0; 131 | __cpuid(regs, 0x80000001); 132 | if (is_bit_set(regs[3], 6)) { 133 | ret |= CPU_SSE4_A_SUPPORT; 134 | } 135 | if (is_bit_set(regs[3], 16)) { 136 | ret |= CPU_FMA4_SUPPORT; 137 | } 138 | 139 | __cpuid(regs, 0x00000000); 140 | if (regs[0] < 7) { 141 | return ret; 142 | } 143 | 144 | __cpuidex(regs, 0x00000007, 0); 145 | if (is_bit_set(regs[1], 5)) { 146 | ret |= CPU_AVX2_SUPPORT; 147 | } 148 | if (!is_bit_set(regs[1], 16)) { 149 | return ret; 150 | } 151 | 152 | ret |= CPU_AVX512F_SUPPORT; 153 | if (is_bit_set(regs[1], 17)) { 154 | ret |= CPU_AVX512DQ_SUPPORT; 155 | } 156 | if (is_bit_set(regs[1], 21)) { 157 | ret |= CPU_AVX512IFMA52_SUPPORT; 158 | } 159 | if (is_bit_set(regs[1], 26)) { 160 | ret |= CPU_AVX512PF_SUPPORT; 161 | } 162 | if (is_bit_set(regs[1], 27)) { 163 | ret |= CPU_AVX512ER_SUPPORT; 164 | } 165 | if (is_bit_set(regs[1], 28)) { 166 | ret |= CPU_AVX512CD_SUPPORT; 167 | } 168 | if (is_bit_set(regs[1], 30)) { 169 | ret |= CPU_AVX512BW_SUPPORT; 170 | } 171 | if (is_bit_set(regs[1], 31)) { 172 | ret |= CPU_AVX512VL_SUPPORT; 173 | } 174 | if (is_bit_set(regs[2], 1)) { 175 | ret |= CPU_AVX512VBMI_SUPPORT; 176 | } 177 | 178 | return ret; 179 | } 180 | 181 | bool has_sse2() noexcept 182 | { 183 | return (get_simd_support_info() & CPU_SSE2_SUPPORT) != 0; 184 | } 185 | 186 | bool has_sse3() noexcept 187 | { 188 | return (get_simd_support_info() & CPU_SSE4_1_SUPPORT) != 0; 189 | } 190 | 191 | bool has_avx2() noexcept 192 | { 193 | uint32_t flags = CPU_AVX2_SUPPORT | CPU_FMA3_SUPPORT; 194 | return (get_simd_support_info() & flags) == flags; 195 | } 196 | #endif 197 | 198 | -------------------------------------------------------------------------------- /src/dgdecode64/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Misc Stuff (profiling) for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 7 | * 8 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * MPEG2Dec3 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | #ifndef MPEG2DECPLUS_MISC_H 25 | #define MPEG2DECPLUS_MISC_H 26 | 27 | #define VERSION "DGDecode 2.0.0.5" 28 | 29 | #include 30 | #include 31 | 32 | void __stdcall 33 | fast_copy(const uint8_t *src, const int src_stride, uint8_t *dst, 34 | const int dst_stride, const int horizontal_size, 35 | const int vertical_size) noexcept; 36 | 37 | size_t __cdecl dprintf(char* fmt, ...); 38 | 39 | bool has_sse2() noexcept; 40 | 41 | bool has_sse3() noexcept; 42 | 43 | bool has_avx2() noexcept; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/dgdecode64/store.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MPEG2Dec3 : YV12 & PostProcessing 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * based of the intial MPEG2Dec Copyright (C) Chia-chen Kuo - April 2001 7 | * 8 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 9 | * 10 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * MPEG2Dec3 is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with GNU Make; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | 27 | #include "MPEG2Decoder.h" 28 | //#include "postprocess.h" 29 | #include "color_convert.h" 30 | #include "misc.h" 31 | 32 | 33 | // Write 2-digits numbers in a 16x16 zone. 34 | static void write_quants(uint8_t* dst, int stride, int mb_width, int mb_height, 35 | const int* qp) 36 | { 37 | const uint8_t rien[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 38 | const uint8_t nums[10][8] = { 39 | { 1, 4, 4, 4, 4, 4, 1, 0 }, 40 | { 3, 3, 3, 3, 3, 3, 3, 0 }, 41 | { 1, 3, 3, 1, 2, 2, 1, 0 }, 42 | { 1, 3, 3, 1, 3, 3, 1, 0 }, 43 | { 4, 4, 4, 1, 3, 3, 3, 0 }, 44 | { 1, 2, 2, 1, 3, 3, 1, 0 }, 45 | { 1, 2, 2, 1, 4, 4, 1, 0 }, 46 | { 1, 3, 3, 3, 3, 3, 3, 0 }, 47 | { 1, 4, 4, 1, 4, 4, 1, 0 }, 48 | { 1, 4, 4, 1, 3, 3, 1, 0 }, 49 | }; 50 | 51 | auto write = [](const uint8_t* num, uint8_t* dst, const int stride) { 52 | for (int y = 0; y < 7; ++y) { 53 | if (num[y] == 1) { 54 | dst[1 + y * stride] = 0xFF; 55 | dst[2 + y * stride] = 0xFF; 56 | dst[3 + y * stride] = 0xFF; 57 | dst[4 + y * stride] = 0xFF; 58 | } 59 | if (num[y] == 2) { 60 | dst[1 + y * stride] = 0xFF; 61 | } 62 | if (num[y] == 3) { 63 | dst[4 + y * stride] = 0xFF; 64 | } 65 | if (num[y] == 4) { 66 | dst[1 + y * stride] = 0xFF; 67 | dst[4 + y * stride] = 0xFF; 68 | } 69 | } 70 | }; 71 | 72 | for (int y = 0; y < mb_height; ++y) { 73 | for (int x = 0; x < mb_width; ++x) { 74 | int number = qp[x + y * mb_width]; 75 | uint8_t* dstp = dst + static_cast(x) * 16 + static_cast(3) * stride; 76 | 77 | int c = (number / 100) % 10; 78 | const uint8_t* num = nums[c]; // x00 79 | if (c == 0) num = rien; 80 | write(num, dstp, stride); 81 | 82 | dstp += 5; 83 | int d = (number / 10) % 10; 84 | num = nums[d]; // 0x0 85 | if (c==0 && d==0) num = rien; 86 | write(num, dstp, stride); 87 | 88 | dstp += 5; 89 | num = nums[number % 10]; // 00x 90 | write(num, dstp, stride); 91 | } 92 | dst += static_cast(16) * stride; 93 | } 94 | } 95 | 96 | 97 | static void set_qparams(const int* qp, size_t mb_size, int& minquant, 98 | int& maxquant, int& avgquant) 99 | { 100 | int minq = qp[0], maxq = qp[0], sum = qp[0]; 101 | for (size_t i = 1; i < mb_size; ++i) { 102 | int q = qp[i]; 103 | if (q < minq) minq = q; 104 | if (q > maxq) maxq = q; 105 | sum += q; 106 | } 107 | minquant = minq; 108 | maxquant = maxq; 109 | avgquant = static_cast(static_cast(sum) / mb_size + 0.5f); 110 | } 111 | 112 | 113 | void CMPEG2Decoder::assembleFrame(uint8_t* src[], int pf, YV12PICT& dst) 114 | { 115 | dst.pf = pf; 116 | fast_copy(src[0], Coded_Picture_Width, dst.y, dst.ypitch, Coded_Picture_Width, Coded_Picture_Height); 117 | fast_copy(src[1], Chroma_Width, dst.u, dst.uvpitch, Chroma_Width, Chroma_Height); 118 | fast_copy(src[2], Chroma_Width, dst.v, dst.uvpitch, Chroma_Width, Chroma_Height); 119 | 120 | if (info == 1 || info == 2 || showQ) { 121 | // Re-order quant data for display order. 122 | const int* qp = (picture_coding_type == B_TYPE) ? auxQP : backwardQP; 123 | if (info == 1 || info == 2) { 124 | set_qparams(qp, static_cast(mb_width) * mb_height, minquant, maxquant, avgquant); 125 | } 126 | if (showQ) { 127 | write_quants(dst.y, dst.ypitch, mb_width, mb_height, qp); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/dgdecode64/vapoursource.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "VapourSynth.h" 3 | #include 4 | #include "MPEG2Decoder.h" 5 | 6 | class VSVideoSource 7 | { 8 | private: 9 | VSVideoInfo VI[1]; 10 | uint8_t* bufY, * bufU, * bufV; // for 4:2:2 input support 11 | bool luminanceFlag; 12 | uint8_t luminanceTable[256]; 13 | friend class CMPEG2Decoder; 14 | public: 15 | VSVideoSource(const char *d2v, int64_t idct, int64_t showQ, int64_t info, const VSAPI* vsapi, VSCore* core); 16 | ~VSVideoSource(); 17 | 18 | static void VS_CC Init(VSMap *in, VSMap *out, void **instanceData, VSNode *node, VSCore *core, const VSAPI *vsapi); 19 | static const VSFrameRef *VS_CC GetFrame(int n, int activationReason, void **instanceData, void **frameData, VSFrameContext *frameCtx, VSCore *core, const VSAPI *vsapi); 20 | static void VS_CC Free(void *instanceData, VSCore *core, const VSAPI *vsapi); 21 | CMPEG2Decoder *m_decoder; 22 | DWORD threadId; 23 | static const unsigned short vsfont[500][20]; 24 | static void VSDrawDigit(VSFrameRef *Dst, const VSAPI *vsapi, int x, int y, int offsetX, int offsetY, int num, bool full); 25 | static void VSDrawString(VSFrameRef *Dst, const VSAPI *vsapi, int x, int y, int offsetX, int offsetY, const char *s, bool full); 26 | }; 27 | -------------------------------------------------------------------------------- /src/dgdecode64/win_import_min.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef WIN_IMPORT_MIN_H 3 | #define WIN_IMPORT_MIN_H 4 | 5 | #define __int64 int64_t 6 | 7 | #define __fastcall __attribute__((fastcall)) 8 | 9 | /* support from recent _mingw.h */ 10 | 11 | #include 12 | 13 | #define MAX_PATH PATH_MAX 14 | #define _MAX_PATH PATH_MAX 15 | 16 | #ifdef __cplusplus 17 | #define __forceinline inline __attribute__((__always_inline__)) 18 | #else 19 | #define __forceinline extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) 20 | #endif /* __cplusplus */ 21 | 22 | #ifdef __GNUC__ 23 | #define _byteswap_ulong(x) __builtin_bswap32(x) 24 | #endif 25 | 26 | #define _read read 27 | #define _lseeki64 lseek 28 | #define _close close 29 | #define OutputDebugString(x) fprintf(stderr,x) 30 | 31 | /* gnu libc offers the equivalent 'aligned_alloc' BUT requested 'size' 32 | has to be a multiple of 'alignment' - in case it isn't, I'll set 33 | a different size, rounding up the value */ 34 | #define _aligned_malloc(s,a) ( \ 35 | aligned_alloc(a,((s-1)/a+1)*a) \ 36 | ) 37 | 38 | #define _aligned_free(x) free(x) 39 | 40 | #define _atoi64(x) strtoll(x,NULL,10) 41 | #define sprintf_s(buf,...) snprintf((buf),sizeof(buf),__VA_ARGS__) 42 | #define strncpy_s(d,n,s,c) strncpy(d,s,c) 43 | #define vsprintf_s(d,n,t,v) vsprintf(d,t,v) 44 | #define sscanf_s(buf,...) sscanf((buf),__VA_ARGS__) 45 | #define fscanf_s(f,t,...) fscanf(f,t,__VA_ARGS__) 46 | 47 | #endif // WIN_IMPORT_MIN_H 48 | 49 | -------------------------------------------------------------------------------- /src/dgdecode64/yv12pict.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Chia-chen Kuo - April 2001 3 | * 4 | * This file is part of DVD2AVI, a free MPEG-2 decoder 5 | * 6 | * DVD2AVI is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * DVD2AVI is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Make; see the file COPYING. If not, write to 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | // replace with one that doesn't need fixed size table - trbarry 3-22-2002 23 | 24 | #include 25 | #include 26 | #ifndef _WIN32 27 | #include "win_import_min.h" 28 | #endif 29 | #include "yv12pict.h" 30 | #include "VapourSynth.h" 31 | 32 | //#define ptr_t unsigned int 33 | 34 | 35 | 36 | // memory allocation for MPEG2Dec3. 37 | // 38 | // Changed this to handle/track both width/pitch for when 39 | // width != pitch and it simply makes things easier to have all 40 | // information in this struct. It now uses 32y/16uv byte alignment 41 | // by default, which makes internal bugs easier to catch. This can 42 | // easily be changed if needed. 43 | // 44 | // The definition of YV12PICT is in global.h 45 | // 46 | // tritical - May 16, 2005 47 | 48 | // Change to use constructor/destructor 49 | // chikuzen - Sep 6, 2016 50 | 51 | 52 | YV12PICT::YV12PICT(int height, int width, int chroma_format) : 53 | allocated(true), 54 | ywidth(width), uvwidth(width), 55 | yheight(height), uvheight(height) 56 | { 57 | if (chroma_format < 3) { 58 | uvwidth /= 2; 59 | } 60 | if (chroma_format < 2) { 61 | uvheight /= 2; 62 | } 63 | 64 | uvpitch = (uvwidth + 15) & ~15; 65 | ypitch = (ywidth + 31) & ~31; 66 | 67 | y = reinterpret_cast(_aligned_malloc(static_cast(height) * ypitch, 32)); 68 | u = reinterpret_cast(_aligned_malloc(static_cast(uvheight) * uvpitch, 16)); 69 | v = reinterpret_cast(_aligned_malloc(static_cast(uvheight) * uvpitch, 16)); 70 | if (!y || !u || !v) { 71 | _aligned_free(y); 72 | _aligned_free(u); 73 | throw std::runtime_error("failed to new YV12PICT"); 74 | } 75 | } 76 | 77 | 78 | YV12PICT::YV12PICT(PVideoFrame& frame) : 79 | allocated(false), 80 | y(frame->GetWritePtr(PLANAR_Y)), 81 | u(frame->GetWritePtr(PLANAR_U)), 82 | v(frame->GetWritePtr(PLANAR_V)), 83 | ypitch(frame->GetPitch(PLANAR_Y)), uvpitch(frame->GetPitch(PLANAR_U)), 84 | ywidth(frame->GetRowSize(PLANAR_Y)), uvwidth(frame->GetRowSize(PLANAR_U)), 85 | yheight(frame->GetHeight(PLANAR_Y)), uvheight(frame->GetHeight(PLANAR_U)) 86 | {} 87 | 88 | YV12PICT::YV12PICT(const VSAPI* vsapi, VSFrameRef* Dst) : 89 | allocated(false), 90 | y(vsapi->getWritePtr(Dst, 0)), 91 | u(vsapi->getWritePtr(Dst, 1)), 92 | v(vsapi->getWritePtr(Dst, 2)), 93 | ypitch(vsapi->getStride(Dst, 0)), 94 | uvpitch(vsapi->getStride(Dst, 1)), 95 | ywidth(vsapi->getFrameWidth(Dst, 0)), 96 | uvwidth(vsapi->getFrameWidth(Dst, 1)), 97 | yheight(vsapi->getFrameHeight(Dst, 0)), 98 | uvheight(vsapi->getFrameHeight(Dst, 1)) 99 | {} 100 | 101 | YV12PICT::YV12PICT(uint8_t* py, uint8_t* pu, uint8_t*pv, int yw, int cw, int h) : 102 | allocated(false), 103 | y(py), u(pu), v(pv), 104 | ypitch((yw + 31) & ~31), uvpitch((cw + 15) & ~15), 105 | ywidth(yw), uvwidth(cw), yheight(h), uvheight(h) 106 | {} 107 | 108 | 109 | YV12PICT::~YV12PICT() 110 | { 111 | if (allocated) { 112 | _aligned_free(y); 113 | _aligned_free(u); 114 | _aligned_free(v); 115 | y = u = v = nullptr; 116 | } 117 | } 118 | 119 | -------------------------------------------------------------------------------- /src/dgdecode64/yv12pict.h: -------------------------------------------------------------------------------- 1 | #ifndef YV12PICT_H 2 | #define YV12PICT_H 3 | 4 | #include 5 | #include "avisynth.h" 6 | #include "VapourSynth.h" 7 | 8 | 9 | class YV12PICT { 10 | bool allocated; 11 | public: 12 | uint8_t *y, *u, *v; 13 | int ypitch, uvpitch; 14 | int ywidth, uvwidth; 15 | int yheight, uvheight; 16 | int pf; 17 | 18 | YV12PICT(PVideoFrame& frame); 19 | YV12PICT(uint8_t* py, uint8_t* pu, uint8_t*pv, int yw, int cw, int h); 20 | YV12PICT(int height, int width, int chroma_format); 21 | YV12PICT::YV12PICT(const VSAPI* vsapi, VSFrameRef* Dst); 22 | ~YV12PICT(); 23 | }; 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /src/dgindex/AC3Dec/bitstream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Aaron Holtzman - May 1999 3 | * 4 | * This file is part of ac3dec, a free Dolby AC-3 stream decoder. 5 | * 6 | * ac3dec is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * ac3dec is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Make; see the file COPYING. If not, write to 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #include "ac3.h" 23 | #include "bitstream.h" 24 | 25 | uint_32 bitstream_get_bh(uint_32 num_bits) 26 | { 27 | uint_32 result; 28 | 29 | num_bits -= bits_left; 30 | result = (current_word << (32 - bits_left)) >> (32 - bits_left); 31 | 32 | current_word = (*buffer_start << 24) + (*(buffer_start+1) << 16) + (*(buffer_start+2) << 8) + *(buffer_start+3); 33 | buffer_start +=4; 34 | 35 | if(num_bits != 0) 36 | result = (result << num_bits) + (current_word >> (32 - num_bits)); 37 | 38 | bits_left = 32 - num_bits; 39 | 40 | return result; 41 | } 42 | 43 | void bitstream_init(uint_8 *start) 44 | { 45 | // initialize the start of the buffer 46 | buffer_start = start; 47 | bits_left = 0; 48 | } 49 | -------------------------------------------------------------------------------- /src/dgindex/AC3Dec/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Aaron Holtzman - May 1999 3 | * 4 | * This file is part of ac3dec, a free Dolby AC-3 stream decoder. 5 | * 6 | * ac3dec is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * ac3dec is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Make; see the file COPYING. If not, write to 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | void bitstream_init(uint_8 *start); 23 | uint_32 bitstream_get_bh(uint_32 num_bits); 24 | 25 | __forceinline static uint_32 bitstream_get(uint_32 num_bits) 26 | { 27 | uint_32 result; 28 | 29 | if (num_bits < bits_left) 30 | { 31 | result = (current_word << (32 - bits_left)) >> (32 - num_bits); 32 | bits_left -= num_bits; 33 | return result; 34 | } 35 | 36 | return bitstream_get_bh(num_bits); 37 | } 38 | -------------------------------------------------------------------------------- /src/dgindex/AC3Dec/crc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Aaron Holtzman - May 1999 3 | * 4 | * This file is part of ac3dec, a free Dolby AC-3 stream decoder. 5 | * 6 | * ac3dec is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * ac3dec is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Make; see the file COPYING. If not, write to 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #include "ac3.h" 23 | 24 | static const uint_16 crc_lut[256] = 25 | { 26 | 0x0000,0x8005,0x800f,0x000a,0x801b,0x001e,0x0014,0x8011, 27 | 0x8033,0x0036,0x003c,0x8039,0x0028,0x802d,0x8027,0x0022, 28 | 0x8063,0x0066,0x006c,0x8069,0x0078,0x807d,0x8077,0x0072, 29 | 0x0050,0x8055,0x805f,0x005a,0x804b,0x004e,0x0044,0x8041, 30 | 0x80c3,0x00c6,0x00cc,0x80c9,0x00d8,0x80dd,0x80d7,0x00d2, 31 | 0x00f0,0x80f5,0x80ff,0x00fa,0x80eb,0x00ee,0x00e4,0x80e1, 32 | 0x00a0,0x80a5,0x80af,0x00aa,0x80bb,0x00be,0x00b4,0x80b1, 33 | 0x8093,0x0096,0x009c,0x8099,0x0088,0x808d,0x8087,0x0082, 34 | 0x8183,0x0186,0x018c,0x8189,0x0198,0x819d,0x8197,0x0192, 35 | 0x01b0,0x81b5,0x81bf,0x01ba,0x81ab,0x01ae,0x01a4,0x81a1, 36 | 0x01e0,0x81e5,0x81ef,0x01ea,0x81fb,0x01fe,0x01f4,0x81f1, 37 | 0x81d3,0x01d6,0x01dc,0x81d9,0x01c8,0x81cd,0x81c7,0x01c2, 38 | 0x0140,0x8145,0x814f,0x014a,0x815b,0x015e,0x0154,0x8151, 39 | 0x8173,0x0176,0x017c,0x8179,0x0168,0x816d,0x8167,0x0162, 40 | 0x8123,0x0126,0x012c,0x8129,0x0138,0x813d,0x8137,0x0132, 41 | 0x0110,0x8115,0x811f,0x011a,0x810b,0x010e,0x0104,0x8101, 42 | 0x8303,0x0306,0x030c,0x8309,0x0318,0x831d,0x8317,0x0312, 43 | 0x0330,0x8335,0x833f,0x033a,0x832b,0x032e,0x0324,0x8321, 44 | 0x0360,0x8365,0x836f,0x036a,0x837b,0x037e,0x0374,0x8371, 45 | 0x8353,0x0356,0x035c,0x8359,0x0348,0x834d,0x8347,0x0342, 46 | 0x03c0,0x83c5,0x83cf,0x03ca,0x83db,0x03de,0x03d4,0x83d1, 47 | 0x83f3,0x03f6,0x03fc,0x83f9,0x03e8,0x83ed,0x83e7,0x03e2, 48 | 0x83a3,0x03a6,0x03ac,0x83a9,0x03b8,0x83bd,0x83b7,0x03b2, 49 | 0x0390,0x8395,0x839f,0x039a,0x838b,0x038e,0x0384,0x8381, 50 | 0x0280,0x8285,0x828f,0x028a,0x829b,0x029e,0x0294,0x8291, 51 | 0x82b3,0x02b6,0x02bc,0x82b9,0x02a8,0x82ad,0x82a7,0x02a2, 52 | 0x82e3,0x02e6,0x02ec,0x82e9,0x02f8,0x82fd,0x82f7,0x02f2, 53 | 0x02d0,0x82d5,0x82df,0x02da,0x82cb,0x02ce,0x02c4,0x82c1, 54 | 0x8243,0x0246,0x024c,0x8249,0x0258,0x825d,0x8257,0x0252, 55 | 0x0270,0x8275,0x827f,0x027a,0x826b,0x026e,0x0264,0x8261, 56 | 0x0220,0x8225,0x822f,0x022a,0x823b,0x023e,0x0234,0x8231, 57 | 0x8213,0x0216,0x021c,0x8219,0x0208,0x820d,0x8207,0x0202 58 | }; 59 | 60 | int crc_process_frame(uint_8 *data, uint_32 num_bytes) 61 | { 62 | uint_16 state = 0; 63 | uint_32 i; 64 | 65 | for(i=0; i>8)] ^ (state<<8); 67 | 68 | return state; 69 | } 70 | -------------------------------------------------------------------------------- /src/dgindex/AC3Dec/exponent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Aaron Holtzman - May 1999 3 | * 4 | * This file is part of ac3dec, a free Dolby AC-3 stream decoder. 5 | * 6 | * ac3dec is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * ac3dec is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Make; see the file COPYING. If not, write to 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #include "ac3.h" 23 | 24 | static sint_16 EXPT[125][3]; 25 | 26 | static void exp_unpack_ch(uint_16 type,uint_16 expstr,uint_16 ngrps,uint_16 initial_exp, uint_16 exps[], uint_16 *dest); 27 | 28 | void exponent_init() 29 | { 30 | int i; 31 | 32 | for (i=0; i<125; i++) 33 | { 34 | EXPT[i][0] = i / 25; 35 | EXPT[i][1] = (i - EXPT[i][0] * 25) / 5; 36 | EXPT[i][2] = i - EXPT[i][0] * 25 - EXPT[i][1] * 5; 37 | EXPT[i][0] -= 2; 38 | EXPT[i][1] -= 2; 39 | EXPT[i][2] -= 2; 40 | } 41 | } 42 | 43 | void exponent_unpack( bsi_t *bsi, audblk_t *audblk) 44 | { 45 | uint_16 i; 46 | 47 | for(i=0; i< bsi->nfchans; i++) 48 | exp_unpack_ch(UNPACK_FBW, audblk->chexpstr[i], audblk->nchgrps[i], audblk->exps[i][0], 49 | &audblk->exps[i][1], audblk->fbw_exp[i]); 50 | 51 | if(audblk->cplinu) 52 | exp_unpack_ch(UNPACK_CPL, audblk->cplexpstr, audblk->ncplgrps, audblk->cplabsexp << 1, 53 | audblk->cplexps, &audblk->cpl_exp[audblk->cplstrtmant]); 54 | 55 | if(bsi->lfeon) 56 | exp_unpack_ch(UNPACK_LFE, audblk->lfeexpstr, 2, audblk->lfeexps[0], 57 | &audblk->lfeexps[1], audblk->lfe_exp); 58 | } 59 | 60 | 61 | static void exp_unpack_ch(uint_16 type,uint_16 expstr,uint_16 ngrps,uint_16 initial_exp, 62 | uint_16 exps[], uint_16 *dest) 63 | { 64 | uint_16 i,j; 65 | sint_16 exp_acc; 66 | 67 | if(expstr == EXP_REUSE) 68 | return; 69 | 70 | /* Handle the initial absolute exponent */ 71 | exp_acc = initial_exp; 72 | j = 0; 73 | 74 | /* In the case of a fbw channel then the initial absolute values is 75 | * also an exponent */ 76 | if(type != UNPACK_CPL) 77 | dest[j++] = exp_acc; 78 | 79 | /* Loop through the groups and fill the dest array appropriately */ 80 | for(i=0; i 124) 83 | { 84 | error_flag = 1; 85 | return; 86 | } 87 | 88 | exp_acc += EXPT[exps[i]][0]; 89 | 90 | switch (expstr) 91 | { 92 | case EXP_D45: 93 | dest[j++] = exp_acc; 94 | dest[j++] = exp_acc; 95 | case EXP_D25: 96 | dest[j++] = exp_acc; 97 | case EXP_D15: 98 | dest[j++] = exp_acc; 99 | } 100 | 101 | exp_acc += EXPT[exps[i]][1]; 102 | 103 | switch (expstr) 104 | { 105 | case EXP_D45: 106 | dest[j++] = exp_acc; 107 | dest[j++] = exp_acc; 108 | case EXP_D25: 109 | dest[j++] = exp_acc; 110 | case EXP_D15: 111 | dest[j++] = exp_acc; 112 | } 113 | 114 | exp_acc += EXPT[exps[i]][2]; 115 | 116 | switch (expstr) 117 | { 118 | case EXP_D45: 119 | dest[j++] = exp_acc; 120 | dest[j++] = exp_acc; 121 | case EXP_D25: 122 | dest[j++] = exp_acc; 123 | case EXP_D15: 124 | dest[j++] = exp_acc; 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/dgindex/AC3Dec/rematrix.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Aaron Holtzman - May 1999 3 | * 4 | * This file is part of ac3dec, a free Dolby AC-3 stream decoder. 5 | * 6 | * ac3dec is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * ac3dec is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Make; see the file COPYING. If not, write to 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #include "ac3.h" 23 | 24 | struct rematrix_band_s 25 | { 26 | uint_32 start; 27 | uint_32 end; 28 | }; 29 | 30 | static struct rematrix_band_s rematrix_band[] = {{13,24}, {25,36}, {37,60}, {61,252}}; 31 | 32 | /* This routine simply does stereo rematixing for the 2 channel stereo mode */ 33 | void rematrix(audblk_t *audblk, stream_samples_t samples) 34 | { 35 | uint_32 num_bands; 36 | uint_32 start; 37 | uint_32 end; 38 | uint_32 i, j; 39 | double left, right; 40 | 41 | if(!audblk->cplinu || audblk->cplbegf > 2) 42 | num_bands = 4; 43 | else if (audblk->cplbegf > 0) 44 | num_bands = 3; 45 | else 46 | num_bands = 2; 47 | 48 | for(i=0; irematflg[i]) 51 | continue; 52 | 53 | start = rematrix_band[i].start; 54 | 55 | if (i==num_bands-1 && audblk->cplinu) 56 | end = 12 * audblk->cplbegf + 36; 57 | else 58 | end = rematrix_band[i].end; 59 | 60 | for (j=start; j<=end; j++) 61 | { 62 | left = samples[0][j] + samples[1][j]; 63 | right = samples[0][j] - samples[1][j]; 64 | samples[0][j] = left; 65 | samples[1][j] = right; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/dgindex/AC3Dec/sanity_check.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Aaron Holtzman - May 1999 3 | * 4 | * This file is part of ac3dec, a free Dolby AC-3 stream decoder. 5 | * 6 | * ac3dec is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * ac3dec is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Make; see the file COPYING. If not, write to 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #include "ac3.h" 23 | 24 | void sanity_check(bsi_t *bsi, audblk_t *audblk) 25 | { 26 | int i; 27 | 28 | for(i=0; i<5 ; i++) 29 | { 30 | if (audblk->fbw_exp[i][255] !=0 || audblk->fbw_exp[i][254] !=0 || audblk->fbw_exp[i][253] !=0) 31 | error_flag = 1; 32 | 33 | if (audblk->fbw_bap[i][255] !=0 || audblk->fbw_bap[i][254] !=0 || audblk->fbw_bap[i][253] !=0) 34 | error_flag = 1; 35 | } 36 | 37 | if (audblk->cpl_exp[255] !=0 || audblk->cpl_exp[254] !=0 || audblk->cpl_exp[253] !=0) 38 | error_flag = 1; 39 | 40 | if (audblk->cpl_bap[255] !=0 || audblk->cpl_bap[254] !=0 || audblk->cpl_bap[253] !=0) 41 | error_flag = 1; 42 | 43 | if (audblk->cplmant[255] !=0 || audblk->cplmant[254] !=0 || audblk->cplmant[253] !=0) 44 | error_flag = 1; 45 | 46 | for(i=0; i < bsi->nfchans; i++) 47 | if(audblk->chincpl[i]==0 && audblk->chbwcod[i]>60) 48 | error_flag = 1; 49 | } 50 | -------------------------------------------------------------------------------- /src/dgindex/makefile: -------------------------------------------------------------------------------- 1 | #----------------------------- 2 | # makefile for DGIndex 3 | #----------------------------- 4 | 5 | ### Target ### 6 | 7 | OUTDIR=.\Release_nmake 8 | INTDIR=$(OUTDIR)\obj 9 | 10 | TARGET=DGIndex 11 | TARGETEXE=$(OUTDIR)\$(TARGET).exe 12 | 13 | 14 | ### build utils ### 15 | 16 | MASM = ml.exe 17 | NASM = "$(NASMPATH)"nasm.exe 18 | CC = cl.exe 19 | CPP = cl.exe 20 | LD = link.exe 21 | RC = rc.exe 22 | 23 | 24 | ### build flags ### 25 | 26 | MASM_FLAGS = /c /coff /Cx /nologo 27 | 28 | NASM_FLAGS = -f win32 -DPREFIX -DWIN32 29 | 30 | CPPFLAGS = \ 31 | /c /Zi /nologo /W3 /WX- /O2 /Ob1 /Oi /Ot /Oy- \ 32 | /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_CRT_SECURE_NO_WARNINGS" /D "_MBCS" \ 33 | /GF /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t /Zc:forScope \ 34 | /Fp"$(OUTDIR)/$(TARGET).pch" /Fd"$(OUTDIR)/" \ 35 | /Gd /analyze- /errorReport:none $(EXTRA_CPPFLAGS) 36 | 37 | LDFLAGS = \ 38 | /OUT:"$(TARGETEXE)" \ 39 | /INCREMENTAL:NO \ 40 | /NOLOGO \ 41 | /MANIFEST \ 42 | /ManifestFile:"$(TARGETEXE).intermediate.manifest" \ 43 | /ALLOWISOLATION \ 44 | /MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ 45 | /SUBSYSTEM:WINDOWS,5.01 \ 46 | /STACK:"4096000" \ 47 | /TLBID:1 \ 48 | /DYNAMICBASE \ 49 | /NXCOMPAT \ 50 | /MACHINE:X86 \ 51 | /ERRORREPORT:NONE $(EXTRA_LDFLAGS) 52 | 53 | LDFLAGS_DEBUG = \ 54 | /DEBUG \ 55 | /PDB:"$(OUTDIR)\$(TARGET).pdb" 56 | 57 | RFLAGS = /D "NDEBUG" /l 0x0409 /nologo 58 | 59 | 60 | ### link targets ### 61 | 62 | LIBS = vfw32.lib winmm.lib odbc32.lib odbccp32.lib shlwapi.lib kernel32.lib \ 63 | user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib \ 64 | ole32.lib oleaut32.lib uuid.lib 65 | 66 | OBJS = \ 67 | "$(INTDIR)\gui.res" \ 68 | "$(INTDIR)\masm\idctmmx.obj" \ 69 | "$(INTDIR)\nasm\simple_idct_mmx.obj" \ 70 | "$(INTDIR)\nasm\skl_dct_sse.obj" \ 71 | "$(INTDIR)\d2vparse.obj" \ 72 | "$(INTDIR)\getbit.obj" \ 73 | "$(INTDIR)\gethdr.obj" \ 74 | "$(INTDIR)\getpic.obj" \ 75 | "$(INTDIR)\gui.obj" \ 76 | "$(INTDIR)\idctfpu.obj" \ 77 | "$(INTDIR)\idctref.obj" \ 78 | "$(INTDIR)\initial_parse.obj" \ 79 | "$(INTDIR)\misc.obj" \ 80 | "$(INTDIR)\motion.obj" \ 81 | "$(INTDIR)\mpeg2dec.obj" \ 82 | "$(INTDIR)\norm.obj" \ 83 | "$(INTDIR)\parse_cli.obj" \ 84 | "$(INTDIR)\pat.obj" \ 85 | "$(INTDIR)\store.obj" \ 86 | "$(INTDIR)\strverscmp.obj" \ 87 | "$(INTDIR)\wavefs44.obj" \ 88 | "$(INTDIR)\AC3Dec\bit_allocate.obj" \ 89 | "$(INTDIR)\AC3Dec\bitstream.obj" \ 90 | "$(INTDIR)\AC3Dec\coeff.obj" \ 91 | "$(INTDIR)\AC3Dec\crc.obj" \ 92 | "$(INTDIR)\AC3Dec\decode.obj" \ 93 | "$(INTDIR)\AC3Dec\downmix.obj" \ 94 | "$(INTDIR)\AC3Dec\exponent.obj" \ 95 | "$(INTDIR)\AC3Dec\imdct.obj" \ 96 | "$(INTDIR)\AC3Dec\parse.obj" \ 97 | "$(INTDIR)\AC3Dec\rematrix.obj" \ 98 | "$(INTDIR)\AC3Dec\sanity_check.obj" 99 | 100 | 101 | ### build ### 102 | 103 | .SUFFIXES : .exe .obj .asm .cpp .res .rc 104 | 105 | 106 | ALL: "$(TARGETEXE)" 107 | 108 | "$(TARGETEXE)": "$(OUTDIR)" $(OBJS) 109 | @echo LD $(TARGET).exe 110 | @$(LD) $(LDFLAGS) $(OBJS) $(LIBS) >NUL 111 | 112 | .asm{$(INTDIR)\masm}.obj: 113 | @echo MASM $< 114 | @$(MASM) $(MASM_FLAGS) /Fo"$@" $< >NUL 115 | 116 | .asm{$(INTDIR)\nasm}.obj: 117 | @echo NASM $< 118 | @$(NASM) $(NASM_FLAGS) $< -o $@ >NUL 119 | 120 | {AC3Dec}.cpp{$(INTDIR)\AC3Dec}.obj: 121 | @echo CXX $< 122 | @$(CPP) $(CPPFLAGS) $< /Fo"$@" >NUL 123 | 124 | .cpp{$(INTDIR)}.obj: 125 | @echo CXX $< 126 | @$(CPP) $(CPPFLAGS) $< /Fo"$@" >NUL 127 | 128 | .rc{$(INTDIR)}.res: 129 | @echo RC $< 130 | @$(RC) $(RFLAGS) /fo"$@" $< >NUL 131 | 132 | clean: 133 | @echo delete "*.obj *.res *.pdb *.manifest" 134 | @if exist "$(INTDIR)" @rmdir /S /Q "$(INTDIR)" >NUL 135 | @if exist "$(OUTDIR)" @del /Q "$(OUTDIR)\*.obj" "$(OUTDIR)\*.pdb" "$(OUTDIR)\*.manifest" 2>NUL 1>NUL 136 | 137 | "$(OUTDIR)": "$(INTDIR)" "$(INTDIR)\AC3Dec" "$(INTDIR)\masm" "$(INTDIR)\nasm" 138 | @if not exist "$(OUTDIR)" @mkdir "$(OUTDIR)" 139 | 140 | "$(INTDIR)": 141 | @if not exist "$(INTDIR)" @mkdir "$(INTDIR)" 142 | 143 | "$(INTDIR)\AC3Dec": 144 | @if not exist "$(INTDIR)\AC3Dec" @mkdir "$(INTDIR)\AC3Dec" 145 | 146 | "$(INTDIR)\masm": 147 | @if not exist "$(INTDIR)\masm" @mkdir "$(INTDIR)\masm" 148 | 149 | "$(INTDIR)\nasm": 150 | @if not exist "$(INTDIR)\nasm" @mkdir "$(INTDIR)\nasm" 151 | 152 | 153 | ### depend #### 154 | 155 | !include "makefile.dep" 156 | -------------------------------------------------------------------------------- /src/dgindex/makefile.dep: -------------------------------------------------------------------------------- 1 | $(INTDIR)\masm\idctmmx.obj: idctmmx.asm 2 | $(INTDIR)\nasm\simple_idct_mmx.obj: simple_idct_mmx.asm 3 | $(INTDIR)\nasm\skl_dct_sse.obj: skl_dct_sse.asm skl_nasm.h 4 | $(INTDIR)\d2vparse.obj : d2vparse.cpp global.h misc.h resource.h pat.h 5 | $(INTDIR)\getbit.obj : getbit.cpp global.h misc.h resource.h pat.h getbit.h AC3Dec\ac3.h 6 | $(INTDIR)\gethdr.obj : gethdr.cpp global.h misc.h resource.h pat.h getbit.h 7 | $(INTDIR)\getpic.obj : getpic.cpp global.h misc.h resource.h pat.h getbit.h 8 | $(INTDIR)\gui.obj : gui.cpp resource.h global.h misc.h pat.h ..\config.h 9 | $(INTDIR)\idctfpu.obj : idctfpu.cpp 10 | $(INTDIR)\idctref.obj : idctref.cpp 11 | $(INTDIR)\initial_parse.obj : initial_parse.cpp resource.h global.h misc.h pat.h 12 | $(INTDIR)\misc.obj : misc.cpp global.h misc.h resource.h pat.h 13 | $(INTDIR)\motion.obj : motion.cpp global.h misc.h resource.h pat.h getbit.h 14 | $(INTDIR)\mpeg2dec.obj : mpeg2dec.cpp global.h misc.h resource.h pat.h getbit.h 15 | $(INTDIR)\norm.obj : norm.cpp global.h misc.h resource.h pat.h 16 | $(INTDIR)\parse_cli.obj : parse_cli.cpp resource.h global.h misc.h pat.h 17 | $(INTDIR)\pat.obj : pat.cpp resource.h global.h misc.h pat.h 18 | $(INTDIR)\store.obj : store.cpp global.h misc.h resource.h pat.h filter.h 19 | $(INTDIR)\strverscmp.obj : strverscmp.cpp 20 | $(INTDIR)\wavefs44.obj : wavefs44.cpp global.h misc.h resource.h pat.h 21 | $(INTDIR)\AC3Dec\bit_allocate.obj : AC3Dec\bit_allocate.cpp AC3Dec\ac3.h 22 | $(INTDIR)\AC3Dec\bitstream.obj : AC3Dec\bitstream.cpp AC3Dec\ac3.h AC3Dec\bitstream.h 23 | $(INTDIR)\AC3Dec\coeff.obj : AC3Dec\coeff.cpp AC3Dec\ac3.h AC3Dec\bitstream.h 24 | $(INTDIR)\AC3Dec\crc.obj : AC3Dec\crc.cpp AC3Dec\ac3.h 25 | $(INTDIR)\AC3Dec\decode.obj : AC3Dec\decode.cpp global.h AC3Dec\ac3.h AC3Dec\bitstream.h 26 | $(INTDIR)\AC3Dec\downmix.obj : AC3Dec\downmix.cpp global.h AC3Dec\ac3.h 27 | $(INTDIR)\AC3Dec\exponent.obj : AC3Dec\exponent.cpp AC3Dec\ac3.h 28 | $(INTDIR)\AC3Dec\imdct.obj : AC3Dec\imdct.cpp AC3Dec\ac3.h 29 | $(INTDIR)\AC3Dec\parse.obj : AC3Dec\parse.cpp AC3Dec\ac3.h AC3Dec\bitstream.h 30 | $(INTDIR)\AC3Dec\rematrix.obj : AC3Dec\rematrix.cpp AC3Dec\ac3.h 31 | $(INTDIR)\AC3Dec\sanity_check.obj : AC3Dec\sanity_check.cpp AC3Dec\ac3.h 32 | $(INTDIR)\gui.res : gui.rc resource.h ..\config.h 33 | -------------------------------------------------------------------------------- /src/dgindex/misc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Misc Stuff (profiling) for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 7 | * 8 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * MPEG2Dec3 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | #include "global.h" 25 | 26 | static ui64 local; 27 | static char buffer[256]; 28 | 29 | unsigned __int64 read_counter(void) 30 | { 31 | unsigned __int64 ts; 32 | unsigned __int32 ts1, ts2; 33 | __asm { 34 | rdtsc 35 | mov ts1, eax 36 | mov ts2, edx 37 | } 38 | ts = ((unsigned __int64) ts2 << 32) | ((unsigned __int64) ts1); 39 | return ts; 40 | } 41 | 42 | // get CPU frequency in Hz (1MHz precision) 43 | ui64 get_freq(void) 44 | { 45 | unsigned __int64 x = 0; 46 | time_t i; 47 | i = time(NULL); 48 | while (i == time(NULL)); 49 | x -= read_counter(); 50 | i++; 51 | while (i == time(NULL)); 52 | x += read_counter(); 53 | return x; 54 | } 55 | 56 | void init_first(ts* timers) { 57 | memset(timers,0,sizeof(ts)); 58 | timers->div = 0; timers->sum = 0; 59 | timers->freq = get_freq()/1000; 60 | // timers->freq = 1412*1000000; // shortcut for my athlon xp 1600+ (1.4 Gz) 61 | } 62 | 63 | void init_timers(ts* timers) { 64 | timers->idct = 0; 65 | timers->conv = 0; 66 | timers->mcpy = 0; 67 | timers->post = 0; 68 | timers->dec = 0; 69 | timers->bit = 0; 70 | timers->decMB = 0; 71 | timers->mcmp = 0; 72 | timers->addb = 0; 73 | timers->overall = 0; 74 | if (timers->div > 25) { timers->div = 0; timers->sum = 0; } 75 | } 76 | 77 | void start_timer() { 78 | local = read_counter(); 79 | } 80 | 81 | ui64 read_timer() 82 | { 83 | ui64 tmp; 84 | 85 | tmp = local; 86 | local = read_counter(); 87 | return (local - tmp); 88 | } 89 | 90 | void start_timer2(ui64* timer) { 91 | *timer -= read_counter(); 92 | } 93 | 94 | void stop_timer(ui64* timer) { 95 | *timer += (read_counter() - local); 96 | } 97 | 98 | void stop_timer2(ui64* timer) { 99 | *timer += read_counter(); 100 | } 101 | 102 | void timer_debug(ts* timers) { 103 | ts tim = *timers; 104 | //tim.freq = ; 105 | // sprintf(buffer,"conv = %I64d ",tim.conv); 106 | // sprintf(buffer,"idct = %I64d overall=%I64d idct% = %f",tim.idct,tim.overall,(double)tim.idct*100/tim.overall); 107 | sprintf(buffer,"| dec%% = %f > mcmp%% = %f addb%% = %f idct%% = %f decMB%% = %f bit%% = %f | conv%% = %f | post%% = %f | mcpy%% = %f | msec = %f fps = %f mean = %f", 108 | (double)tim.dec*100/tim.overall, 109 | (double)tim.idct*100/tim.overall, 110 | (double)tim.addb*100/tim.overall, 111 | (double)tim.mcmp*100/tim.overall, 112 | (double)tim.decMB*100/tim.overall, 113 | (double)tim.bit*100/tim.overall, 114 | (double)tim.conv*100/tim.overall, 115 | (double)tim.post*100/tim.overall, 116 | (double)tim.mcpy*100/tim.overall, 117 | (double)tim.overall*1000/tim.freq, 118 | tim.freq/(double)tim.overall, 119 | (tim.freq)/((double)tim.sum/tim.div) 120 | ); 121 | OutputDebugString(buffer); 122 | } 123 | 124 | int dprintf(char* fmt, ...) 125 | { 126 | char printString[1000]; 127 | va_list argp; 128 | va_start(argp, fmt); 129 | vsprintf(printString, fmt, argp); 130 | va_end(argp); 131 | OutputDebugString(printString); 132 | return strlen(printString); 133 | } 134 | -------------------------------------------------------------------------------- /src/dgindex/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Misc Stuff (profiling) for MPEG2Dec3 3 | * 4 | * Copyright (C) 2002-2003 Marc Fauconneau 5 | * 6 | * This file is part of MPEG2Dec3, a free MPEG-2 decoder 7 | * 8 | * MPEG2Dec3 is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * MPEG2Dec3 is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | #define ui64 unsigned __int64 25 | 26 | struct ts_t 27 | { 28 | ui64 idct; 29 | ui64 conv; 30 | ui64 mcpy; 31 | ui64 post; 32 | ui64 dec; 33 | ui64 bit; 34 | ui64 decMB; 35 | ui64 mcmp; 36 | ui64 addb; 37 | ui64 overall; 38 | ui64 sum; 39 | int div; 40 | ui64 freq; 41 | }; 42 | 43 | typedef struct ts_t ts; 44 | 45 | ui64 read_counter(void); 46 | ui64 get_freq(void); 47 | int dprintf(char* fmt, ...); 48 | 49 | void init_first(ts* timers); 50 | void init_timers(ts* timers); 51 | void start_timer(); 52 | ui64 read_timer(); 53 | void start_timer2(ui64* timer); 54 | void stop_timer(ui64* timer); 55 | void stop_timer2(ui64* timer); 56 | void timer_debug(ts* tim); 57 | -------------------------------------------------------------------------------- /src/dgindex/movie.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maki-rxrz/DGMPGDec/382e557d9379c49b4c22aa40c6eab9564f4db9a1/src/dgindex/movie.ico -------------------------------------------------------------------------------- /src/dgindex/norm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Mutated into DGIndex. Modifications Copyright (C) 2004, Donald Graft 3 | * 4 | * Copyright (C) Chia-chen Kuo - April 2001 5 | * 6 | * This file is part of DVD2AVI, a free MPEG-2 decoder 7 | * 8 | * DVD2AVI is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * DVD2AVI is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with GNU Make; see the file COPYING. If not, write to 20 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | #include "global.h" 25 | #include 26 | 27 | #define NORM_SIZE 1048576 28 | 29 | static short Norm_Table[65536]; // -32768 ~ 32767 30 | static short Norm_Buffer[NORM_SIZE]; 31 | 32 | static void TwoPass(FILE *WaveIn, int WaveInPos, FILE *WaveOut, int WaveOutPos, int size, int pass); 33 | 34 | void Normalize(FILE *WaveIn, int WaveInPos, char *filename, FILE *WaveOut, int WaveOutPos, int size) 35 | { 36 | int i, norm; 37 | bool trigger = false; 38 | double ratio = 1.0; 39 | 40 | if (Norm_Flag) 41 | { 42 | if (WaveIn==NULL) // In = Out 43 | WaveIn = fopen(filename, "rb"); 44 | else 45 | TwoPass(WaveIn, WaveInPos, NULL, 0, size, 0); 46 | 47 | ratio = 327.68 * Norm_Ratio / Sound_Max; 48 | 49 | if (ratio >= 1.01 || ratio < 1.0) 50 | trigger = true; 51 | } 52 | else if (WaveIn!=NULL) 53 | trigger = true; 54 | 55 | for (i=-32768; i<0; i++) 56 | { 57 | norm = (int)(ratio * i - 0.5); 58 | 59 | if (norm < -32768) 60 | Norm_Table[i+32768] = -32768; 61 | else 62 | Norm_Table[i+32768] = norm; 63 | } 64 | 65 | Norm_Table[32768] = 0; 66 | 67 | for (i=1; i<32768; i++) 68 | { 69 | if (Norm_Table[i] > -32767) 70 | Norm_Table[65536-i] = -Norm_Table[i]; 71 | else 72 | Norm_Table[65536-i] = 32767; 73 | } 74 | 75 | sprintf(szBuffer, "%.2f", ratio); 76 | SetDlgItemText(hDlg, IDC_INFO, szBuffer); 77 | 78 | if (trigger) 79 | TwoPass(WaveIn, WaveInPos, WaveOut, WaveOutPos, size, 1); 80 | } 81 | 82 | static void TwoPass(FILE *WaveIn, int WaveInPos, FILE *WaveOut, int WaveOutPos, int size, int pass) 83 | { 84 | int i, rsize, maxsize = size; 85 | 86 | fseek(WaveIn, WaveInPos, SEEK_SET); 87 | 88 | if (pass) 89 | fseek(WaveOut, WaveOutPos, SEEK_SET); 90 | 91 | timing.op = timeGetTime(); 92 | 93 | while (size > 0) 94 | { 95 | float percent; 96 | 97 | rsize = (size >= NORM_SIZE ? NORM_SIZE : size); 98 | 99 | fread(Norm_Buffer, rsize, 1, WaveIn); 100 | 101 | if (pass) 102 | { 103 | for (i=0; i<(rsize>>1); i++) 104 | Norm_Buffer[i] = Norm_Table[Norm_Buffer[i]+32768]; 105 | 106 | fwrite(Norm_Buffer, rsize, 1, WaveOut); 107 | } 108 | else 109 | for (i=0; i<(rsize>>1); i++) 110 | if (Sound_Max < abs(Norm_Buffer[i])) 111 | Sound_Max = abs(Norm_Buffer[i]); 112 | 113 | size -= rsize; 114 | 115 | timing.ed = timeGetTime(); 116 | elapsed = (timing.ed-timing.op)/1000; 117 | percent = (float)(100.0*(maxsize-size)/maxsize); 118 | remain = (int)((timing.ed-timing.op)*(100.0-percent)/percent)/1000; 119 | 120 | if (Info_Flag) 121 | { 122 | sprintf(szBuffer, "%d:%02d:%02d", elapsed/3600, (elapsed%3600)/60, elapsed%60); 123 | SetDlgItemText(hDlg, IDC_ELAPSED, szBuffer); 124 | 125 | sprintf(szBuffer, "%d:%02d:%02d", remain/3600, (remain%3600)/60, remain%60); 126 | SetDlgItemText(hDlg, IDC_REMAIN, szBuffer); 127 | } 128 | 129 | InvalidateRect(hwndSelect, NULL, TRUE); 130 | SendMessage(hTrack, TBM_SETPOS, (WPARAM)true, (int)(percent*TRACK_PITCH/100)); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/dgindex/pat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004-2006, Donald A Graft, All Rights Reserved 3 | * 4 | * PAT/PMT table parser for PID detection. 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this code; see the file COPYING. If not, write to 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #include 23 | 24 | #define TS_SYNC_BYTE 0x47 25 | #define PAT_PID 0 26 | #define PSIP_PID 0x1ffb 27 | #define LIMIT 10000000 28 | #define MAX_PROGRAMS 500 29 | #define MAX_SECTION 4096 30 | #define MAX_PIDS 500 31 | #define MAX_PACKETS 100000 32 | #define PCR_STREAM 1 33 | 34 | class PATParser 35 | { 36 | private: 37 | enum operation {Dump=1, AudioType, InitialPids} op; 38 | HWND hDialog; 39 | char *filename; 40 | unsigned int audio_pid; 41 | unsigned int audio_type; 42 | FILE *fin; 43 | unsigned int num_pmt_pids, num_programs; 44 | bool first_pat, first_pmt; 45 | unsigned int pmt_pids[MAX_PIDS]; 46 | unsigned int programs[MAX_PROGRAMS]; 47 | unsigned char section[MAX_SECTION]; 48 | unsigned char *section_ptr; 49 | unsigned char buffer[204]; 50 | private: 51 | int SyncTransport(void); 52 | void PATParser::GetTable(unsigned int table_pid); 53 | int AnalyzePAT(void); 54 | int AnalyzePSIP(void); 55 | int AnalyzeRaw(void); 56 | int ProcessPATSection(void); 57 | int ProcessPMTSection(void); 58 | int ProcessPSIPSection(void); 59 | __int64 GetPCRValue( void ); 60 | public: 61 | PATParser(void); 62 | int DumpPAT(HWND hDialog, char *filename); 63 | int DumpPSIP(HWND hDialog, char *filename); 64 | int DumpRaw(HWND hDialog, char *filename); 65 | int GetAudioType(char *filename, unsigned int audio_pid); 66 | int DoInitialPids(char *filename); 67 | private: 68 | int check_pmt_selction_length; 69 | unsigned char *check_section_ptr; 70 | public: 71 | unsigned int GetNumPMTpids( void ); 72 | void InitializePMTCheckItems(void); 73 | int CheckPMTPid( int pkt_pid, int check_pmt_idx ); 74 | int CheckPMTSection( int pkt_pid, unsigned char *pkt_ptr, unsigned int pkt_length, int check_pmt_idx ); 75 | private: 76 | int ParsePMTSection( void ); 77 | }; 78 | -------------------------------------------------------------------------------- /src/dgindex/skl_nasm.h: -------------------------------------------------------------------------------- 1 | ;/******************************************************** 2 | ; * Some code. Copyright (C) 2003 by Pascal Massimino. * 3 | ; * All Rights Reserved. (http://skal.planet-d.net) * 4 | ; * For Educational/Academic use ONLY. See 'LICENSE.TXT'.* 5 | ; ********************************************************/ 6 | ;////////////////////////////////////////////////////////// 7 | ;// NASM macros 8 | ;////////////////////////////////////////////////////////// 9 | 10 | %ifdef LINUX 11 | 12 | ;////////////////////////////////////////////////////////// 13 | ; LINUX / egcs / macros 14 | ;////////////////////////////////////////////////////////// 15 | 16 | %macro extrn 1 17 | extern %1 18 | %define %1 %1 19 | %endmacro 20 | %macro globl 1 21 | global %1 22 | %define %1 %1 23 | %endmacro 24 | 25 | %macro DATA 0 26 | [section data align=16 write alloc USE32] 27 | %endmacro 28 | %macro TEXT 0 29 | [section text align=16 nowrite alloc exec USE32] 30 | %endmacro 31 | 32 | %endif ; LINUX 33 | 34 | ;////////////////////////////////////////////////////////// 35 | 36 | %ifdef WIN32 37 | 38 | %macro extrn 1 39 | extern _%1 40 | %define %1 _%1 41 | %endmacro 42 | 43 | %macro globl 1 44 | global _%1 45 | %define %1 _%1 46 | %endmacro 47 | 48 | %macro DATA 0 49 | [section .data align=16 write alloc USE32] 50 | %endmacro 51 | %macro TEXT 0 52 | [section .text align=16 nowrite alloc exec USE32] 53 | %endmacro 54 | 55 | %endif ; WIN32 56 | 57 | ;////////////////////////////////////////////////////////// 58 | ; 59 | ; MACRO for timing. NASM. 60 | ; Total additional code size is 0xb0. 61 | ; this keep code alignment right. 62 | 63 | ;extrn Skl_Cur_Count_ 64 | ;extrn Skl_Print_Tics 65 | 66 | %macro SKL_USE_RDSTC 0 67 | extrn SKL_RDTSC_0_ASM 68 | extrn SKL_RDTSC_1_ASM 69 | extrn SKL_RDTSC_2_ASM 70 | %endmacro 71 | %define SKL_RDTSC_OFFSET 15 ; check value with skl_rdtsc.h... 72 | 73 | %macro SKL_RDTSC_IN 0 74 | SKL_USE_RDSTC 75 | call SKL_RDTSC_0_ASM 76 | .Skl_RDTSC_Loop_: 77 | call SKL_RDTSC_1_ASM 78 | %endmacro 79 | 80 | ;%macro SKL_RDTSC_OUT 0 81 | ; call SKL_RDTSC_2_ASM 82 | ; dec dword [Skl_Cur_Count_] 83 | ; jge near .Skl_RDTSC_Loop_ 84 | ; push dword 53 85 | ; call Skl_Print_Tics 86 | ;%endmacro 87 | 88 | ;////////////////////////////////////////////////////////// 89 | -------------------------------------------------------------------------------- /src/dgindex/strverscmp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maki-rxrz/DGMPGDec/382e557d9379c49b4c22aa40c6eab9564f4db9a1/src/dgindex/strverscmp.cpp -------------------------------------------------------------------------------- /src/dgvfapi/dgvfapi.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | vfGetPluginInfo 3 | vfGetPluginFunc 4 | -------------------------------------------------------------------------------- /src/dgvfapi/gui.rc: -------------------------------------------------------------------------------- 1 | //Microsoft Developer Studio generated resource script. 2 | // 3 | #include "resource.h" 4 | #include "..\config.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #define APSTUDIO_HIDDEN_SYMBOLS 12 | #include "windows.h" 13 | #undef APSTUDIO_HIDDEN_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | #undef APSTUDIO_READONLY_SYMBOLS 17 | 18 | ///////////////////////////////////////////////////////////////////////////// 19 | // English (U.S.) resources 20 | 21 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 22 | #ifdef _WIN32 23 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 24 | #pragma code_page(1252) 25 | #endif //_WIN32 26 | 27 | #ifndef _MAC 28 | ///////////////////////////////////////////////////////////////////////////// 29 | // 30 | // Version 31 | // 32 | 33 | VS_VERSION_INFO VERSIONINFO 34 | FILEVERSION 1,5,8,0 35 | FILEFLAGSMASK 0x3fL 36 | #ifdef _DEBUG 37 | FILEFLAGS 0x29L 38 | #else 39 | FILEFLAGS 0x28L 40 | #endif 41 | FILEOS 0x4L 42 | FILETYPE 0x2L 43 | FILESUBTYPE 0x0L 44 | BEGIN 45 | BLOCK "StringFileInfo" 46 | BEGIN 47 | BLOCK "040904b0" 48 | BEGIN 49 | VALUE "Comments", "DGVfapi is the VFAPI component of DGMPGDec, an MPEG decoding and frame serving utility.\0" 50 | VALUE "CompanyName", "Freeware licensed under GPL\0" 51 | VALUE "LegalCopyright", "Copyright (C) 2001-2010 Donald A. Graft\0" 52 | #ifdef DGMPGDEC_GIT_VERSION 53 | VALUE "FileVersion", DGMPGDEC_GIT_VERSION "\0" 54 | #else 55 | VALUE "FileVersion", "1.5.8\0" 56 | #endif 57 | END 58 | END 59 | BLOCK "VarFileInfo" 60 | BEGIN 61 | VALUE "Translation", 0x409, 1200 62 | END 63 | END 64 | 65 | 66 | #endif // !_MAC 67 | 68 | 69 | #endif // English (U.S.) resources 70 | ///////////////////////////////////////////////////////////////////////////// 71 | 72 | 73 | 74 | #ifndef APSTUDIO_INVOKED 75 | ///////////////////////////////////////////////////////////////////////////// 76 | // 77 | // Generated from the TEXTINCLUDE 3 resource. 78 | // 79 | 80 | 81 | ///////////////////////////////////////////////////////////////////////////// 82 | #endif // not APSTUDIO_INVOKED 83 | 84 | -------------------------------------------------------------------------------- /src/dgvfapi/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by gui.rc 4 | // 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NEXT_RESOURCE_VALUE 101 11 | #define _APS_NEXT_COMMAND_VALUE 40001 12 | #define _APS_NEXT_CONTROL_VALUE 1000 13 | #define _APS_NEXT_SYMED_VALUE 101 14 | #endif 15 | #endif 16 | -------------------------------------------------------------------------------- /src/dgvfapi/vfapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Chia-chen Kuo - April 2001 3 | * Modifications (C) Donald A. Graft - October 2003 4 | * 5 | * This file is part of DVD2AVI, a free MPEG-2 decoder 6 | * 7 | * DVD2AVI is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * DVD2AVI is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Make; see the file COPYING. If not, write to 19 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | #include "avisynth.h" 26 | 27 | #define VF_STREAM_VIDEO 0x00000001 28 | #define VF_STREAM_AUDIO 0x00000002 29 | #define VF_OK 0x00000000 30 | #define VF_ERROR 0x80004005 31 | 32 | typedef DWORD VF_FileHandle, *LPVF_FileHandle; 33 | 34 | typedef struct { 35 | DWORD dwSize; 36 | DWORD dwAPIVersion; 37 | DWORD dwVersion; 38 | DWORD dwSupportStreamType; 39 | char cPluginInfo[256]; 40 | char cFileType[256]; 41 | } VF_PluginInfo, *LPVF_PluginInfo; 42 | 43 | typedef struct { 44 | DWORD dwSize; 45 | DWORD dwHasStreams; 46 | } VF_FileInfo, *LPVF_FileInfo; 47 | 48 | typedef struct { 49 | DWORD dwSize; 50 | DWORD dwLengthL; 51 | DWORD dwLengthH; 52 | DWORD dwRate; 53 | DWORD dwScale; 54 | DWORD dwWidth; 55 | DWORD dwHeight; 56 | DWORD dwBitCount; 57 | } VF_StreamInfo_Video, *LPVF_StreamInfo_Video; 58 | 59 | typedef struct { 60 | DWORD dwSize; 61 | DWORD dwLengthL; 62 | DWORD dwLengthH; 63 | DWORD dwRate; 64 | DWORD dwScale; 65 | DWORD dwChannels; 66 | DWORD dwBitsPerSample; 67 | DWORD dwBlockAlign; 68 | } VF_StreamInfo_Audio, *LPVF_StreamInfo_Audio; 69 | 70 | typedef struct { 71 | DWORD dwSize; 72 | DWORD dwFrameNumberL; 73 | DWORD dwFrameNumberH; 74 | void *lpData; 75 | int lPitch; 76 | } VF_ReadData_Video, *LPVF_ReadData_Video; 77 | 78 | typedef struct { 79 | DWORD dwSize; 80 | DWORD dwSamplePosL; 81 | DWORD dwSamplePosH; 82 | DWORD dwSampleCount; 83 | DWORD dwReadedSampleCount; 84 | DWORD dwBufSize; 85 | void *lpBuf; 86 | } VF_ReadData_Audio, *LPVF_ReadData_Audio; 87 | 88 | typedef struct { 89 | DWORD dwSize; 90 | HRESULT (__stdcall *OpenFile)(char *lpFileName, LPVF_FileHandle lpFileHandle); 91 | HRESULT (__stdcall *CloseFile)(VF_FileHandle hFileHandle); 92 | HRESULT (__stdcall *GetFileInfo)(VF_FileHandle hFileHandle,LPVF_FileInfo lpFileInfo); 93 | HRESULT (__stdcall *GetStreamInfo)(VF_FileHandle hFileHandle,DWORD dwStream, void *lpStreamInfo); 94 | HRESULT (__stdcall *ReadData)(VF_FileHandle hFileHandle, DWORD dwStream, void *lpData); 95 | } VF_PluginFunc, *LPVF_PluginFunc; 96 | 97 | class vfMI 98 | { 99 | public: 100 | VideoInfo * (__cdecl *openMPEG2SourceMI)(char*, int); 101 | unsigned char* (__cdecl *getRGBFrameMI)(int,int); 102 | void (__cdecl *closeVideoMI)(int); 103 | IScriptEnvironment* (__stdcall *CreateScriptEnvironment)(int); 104 | IScriptEnvironment *avsEnv; 105 | VideoInfo *vi; 106 | HMODULE hDLL; 107 | PClip *clip; 108 | int type, ident; 109 | static int instance; 110 | vfMI *prv, *nxt; 111 | vfMI::vfMI() : vi(NULL), avsEnv(NULL), clip(NULL), hDLL(NULL), type(-1) 112 | { 113 | openMPEG2SourceMI = NULL; 114 | getRGBFrameMI = NULL; 115 | closeVideoMI = NULL; 116 | CreateScriptEnvironment = NULL; 117 | ident = instance; 118 | ++instance; 119 | prv = nxt = NULL; 120 | } 121 | vfMI::~vfMI() 122 | { 123 | if (vi && closeVideoMI) closeVideoMI(ident); 124 | if (hDLL) FreeLibrary(hDLL); 125 | } 126 | }; 127 | 128 | class vfMILinkedList 129 | { 130 | public: 131 | vfMI *LLB, *LLE; 132 | vfMILinkedList::vfMILinkedList() : LLB(NULL), LLE(NULL) {}; 133 | vfMILinkedList::~vfMILinkedList() 134 | { 135 | for (vfMI *i=LLB; i;) 136 | { 137 | vfMI *j = i->nxt; 138 | if (i->avsEnv) 139 | { 140 | if (i->clip) delete i->clip; 141 | for (vfMI* k = i->nxt; k; k = k->nxt) 142 | { 143 | if (k != i && k->avsEnv == i->avsEnv) 144 | goto noavsdelete; 145 | } 146 | delete i->avsEnv; 147 | } 148 | noavsdelete: 149 | delete i; 150 | i = j; 151 | } 152 | LLE = LLB = NULL; 153 | } 154 | void vfMILinkedList::Add(vfMI *i) 155 | { 156 | if (!i) return; 157 | if (!LLB) { LLB = LLE = i; return; } 158 | i->prv = LLE; 159 | LLE->nxt = i; 160 | LLE = i; 161 | } 162 | void vfMILinkedList::Remove(vfMI *i) 163 | { 164 | if (!i) return; 165 | if (i->prv) 166 | { 167 | if (i->nxt) i->prv->nxt = i->nxt; 168 | else i->prv->nxt = NULL; 169 | } 170 | else if (i == LLB) LLB = i->nxt; 171 | if (i->nxt) 172 | { 173 | if (i->prv) i->nxt->prv = i->prv; 174 | else i->nxt->prv = NULL; 175 | } 176 | else if (i == LLE) LLE = i->prv; 177 | } 178 | }; 179 | --------------------------------------------------------------------------------