diff --git a/.gitignore b/.gitignore
index 38c8b7ef1af..9e396e9b454 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,10 +16,10 @@
/build.user.bat
/contrib/[Aa][Ss]tyle.exe
/contrib/cov-int
-/contrib/MPC-HC.lzma
+/contrib/cov_upload.log
+/contrib/MPC-HC.tar.xz
/contrib/MPC-HC.tar
/contrib/MPC-HC.tgz
-/contrib/warn-about-64-bit-msbuild.txt
/distrib/*.exe
/include/version_rev.h
/signinfo.txt
@@ -28,5 +28,6 @@
/src/mpc-hc/mpcresources/tx.exe
/src/mpc-hc/res/mpc-hc.exe.manifest
/src/MPCTestAPI/bin
+/src/thirdparty/DoctorDump/obj
/src/thirdparty/LAVFilters/obj
ipch
diff --git a/Readme.md b/Readme.md
index fd2534390ba..8389f418d8d 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,7 +1,7 @@
# Media Player Classic - Home Cinema
-[](http://badge.fury.io/gh/mpc-hc%2Fmpc-hc)
-[](https://scan.coverity.com/projects/259)
+[](https://github.com/mpc-hc/mpc-hc)
+[](https://scan.coverity.com/projects/259)
Media Player Classic - Home Cinema (MPC-HC) is a free and open source (OSS) video
@@ -12,26 +12,26 @@ We are in dire need of new developers of any kind. If you can code a little, or
logos for the player and images for the file associations, or you can create/maintain the main
website, please join our IRC channel and talk to us. Any help is always appreciated.
-Find some easy ticket on our trac page, fix the problem, send a [pull request](https://github.com/mpc-hc/mpc-hc/pulls),
-or post the patch on [trac](https://trac.mpc-hc.org) or come on IRC and we'll review it for you.
+Find some easy ticket on our Trac, fix the problem, send a [pull request](https://github.com/mpc-hc/mpc-hc/pulls),
+or post the patch on [Trac](https://trac.mpc-hc.org/) or come on IRC and we'll review it for you.
See [CONTRIBUTING.md](/CONTRIBUTING.md) for more info.
*We care about keeping an open project open and free for contributions wherever they may come from.*
## Main Features:
-* Option to remove [tearing](http://en.wikipedia.org/wiki/Screen_tearing)
+* Option to remove [tearing](https://en.wikipedia.org/wiki/Screen_tearing)
* Support for Windows Vista/7/8, including a 64-bit build
-* Support for [EVR/EVR CP](http://en.wikipedia.org/wiki/Media_Foundation#Enhanced_Video_Renderer) (Enhanced Video Renderer)
-* Supports most types of [subtitles](http://en.wikipedia.org/wiki/Subtitle_%28captioning%29#Subtitle_formats)
- including [BluRay](http://en.wikipedia.org/wiki/Blu-ray_Disc) .sup files
+* Support for [EVR/EVR CP](https://en.wikipedia.org/wiki/Media_Foundation#Enhanced_Video_Renderer) (Enhanced Video Renderer)
+* Supports most types of [subtitles](https://en.wikipedia.org/wiki/Subtitle_%28captioning%29#Subtitle_formats)
+ including [BluRay](https://en.wikipedia.org/wiki/Blu-ray_Disc) .sup files
* Playback and recording of television programs, if a supported
- [TV tuner card](http://en.wikipedia.org/wiki/TV_tuner_card) is installed
-* [OSD info (On Screen Display)](http://en.wikipedia.org/wiki/On-screen_display)
+ [TV tuner card](https://en.wikipedia.org/wiki/TV_tuner_card) is installed
+* [OSD info (On Screen Display)](https://en.wikipedia.org/wiki/On-screen_display)
* Multi-Monitor support
-* Various [pixel shaders](http://en.wikipedia.org/wiki/Shader#Pixel_shaders)
-* [Color management](http://en.wikipedia.org/wiki/Color_management)
-* 37 translations available
+* Various [pixel shaders](https://en.wikipedia.org/wiki/Shader#Pixel_shaders)
+* [Color management](https://en.wikipedia.org/wiki/Color_management)
+* 38 translations available
## System Requirements:
@@ -40,12 +40,12 @@ See [CONTRIBUTING.md](/CONTRIBUTING.md) for more info.
## Links:
-* [Website](http://mpc-hc.org)
+* [Website](https://mpc-hc.org/)
* [Source code](https://github.com/mpc-hc)
-* [Support Trac](https://trac.mpc-hc.org)
-* IRC Channel: [#mpc-hc](http://webchat.freenode.net/?randomnick=1&channels=mpc-hc&prompt=1&uio=d4)
- / [#mpc-hc-dev](http://webchat.freenode.net/?randomnick=1&channels=mpc-hc-dev&prompt=1&uio=d4) at [Freenode](http://freenode.net/)
-* [Donations](http://mpc-hc.org/donate/)
+* [Support Trac](https://trac.mpc-hc.org/)
+* IRC Channel: [#mpc-hc](https://webchat.freenode.net/?randomnick=1&channels=mpc-hc&prompt=1&uio=d4)
+ / [#mpc-hc-dev](https://webchat.freenode.net/?randomnick=1&channels=mpc-hc-dev&prompt=1&uio=d4) at [Freenode](https://freenode.net/)
+* [Donations](https://mpc-hc.org/donate/)
For the people involved in the development, see
@@ -64,21 +64,21 @@ MPC-HC makes use of the following third-party code:
| Project | License | Website |
| ----------------- | ------------------------- | ----------------- |
| CSizingControlBar | - | http://www.datamekanix.com/sizecbar/ |
-| LAV Filters | GPLv2+ | http://code.google.com/p/lavfilters/ |
+| LAV Filters | GPLv2+ | https://code.google.com/p/lavfilters/ |
| libdivide | zlib License | http://libdivide.com/ |
| Little CMS | MIT License | http://www.littlecms.com/ |
| Logitech SDK | - | - |
-| MediaInfoLib | Simplified BSD License | http://mediaarea.net/MediaInfo |
+| MediaInfoLib | Simplified BSD License | https://mediaarea.net/MediaInfo |
| Mhook | MIT License | https://github.com/martona/mhook |
| MultiMon | CPOL | http://www.codeproject.com/Articles/3690/ |
-| QuickTime SDK | - | http://developer.apple.com/quicktime/ |
+| QuickTime SDK | - | https://developer.apple.com/quicktime/ |
| RARFileSource | GPLv2+ | http://www.v12pwr.com/RARFileSource/ |
| RealMedia SDK | - | - |
-| ResizableLib | Artistic License | http://sourceforge.net/projects/resizablelib/ |
+| ResizableLib | Artistic License | https://sourceforge.net/projects/resizablelib/ |
| Silk Icons | CC Attribution 2.5 | http://www.famfamfam.com/lab/icons/silk/ |
| SoundTouch | LGPLv2.1 | http://www.surina.net/soundtouch/ |
| TreePropSheet | - | http://www.codeproject.com/Articles/3709/ |
| UnRAR | freeware | http://www.rarlab.com/rar_add.htm |
| VirtualDub | GPLv2+ | http://www.virtualdub.org/ |
-| ZenLib | zlib License | http://sourceforge.net/projects/zenlib/ |
+| ZenLib | zlib License | https://sourceforge.net/projects/zenlib/ |
| zlib | zlib License | http://zlib.net/ |
diff --git a/build.bat b/build.bat
index 125aa6e3d96..21cea0e84d1 100755
--- a/build.bat
+++ b/build.bat
@@ -18,20 +18,6 @@ REM along with this program. If not, see .
SETLOCAL
-CD /D %~dp0
-
-REM pre-build checks
-IF EXIST "build.user.bat" (
- CALL "build.user.bat"
-) ELSE (
- IF DEFINED MINGW32 (SET MPCHC_MINGW32=%MINGW32%) ELSE (GOTO MissingVar)
- IF DEFINED MINGW64 (SET MPCHC_MINGW64=%MINGW64%) ELSE (GOTO MissingVar)
- IF DEFINED MSYS (SET MPCHC_MSYS=%MSYS%) ELSE (GOTO MissingVar)
-)
-
-IF NOT EXIST "%MPCHC_MINGW32%" GOTO MissingVar
-IF NOT EXIST "%MPCHC_MINGW64%" GOTO MissingVar
-IF NOT EXIST "%MPCHC_MSYS%" GOTO MissingVar
SET ARG=/%*
SET ARG=%ARG:/=%
@@ -48,9 +34,7 @@ IF /I "%ARG%" == "?" GOTO ShowHelp
FOR %%G IN (%ARG%) DO (
IF /I "%%G" == "help" GOTO ShowHelp
- IF /I "%%G" == "GetVersion" ENDLOCAL & SET "FORCE_VER_UPDATE=True" & CALL :SubGetVersion & EXIT /B
- IF /I "%%G" == "CopyDXDll" ENDLOCAL & CALL :SubCopyDXDll x86 & CALL :SubCopyDXDll x64 & EXIT /B
- IF /I "%%G" == "CopyDX" ENDLOCAL & CALL :SubCopyDXDll x86 & CALL :SubCopyDXDll x64 & EXIT /B
+ IF /I "%%G" == "GetVersion" ENDLOCAL & SET "FORCE_VER_UPDATE=True" & CALL "%~dp0common.bat" :SubGetVersion & EXIT /B
IF /I "%%G" == "Build" SET "BUILDTYPE=Build" & SET /A ARGB+=1
IF /I "%%G" == "Clean" SET "BUILDTYPE=Clean" & SET /A ARGB+=1 & SET "NO_INST=True" & SET /A "NO_ZIP=True" & SET "NO_LAV=True"
IF /I "%%G" == "Rebuild" SET "BUILDTYPE=Rebuild" & SET /A ARGB+=1 & SET "NO_LAV=True"
@@ -82,6 +66,14 @@ FOR %%G IN (%ARG%) DO (
IF /I "%%G" == "Analyze" SET "ANALYZE=True" & SET /A VALID+=1
)
+SET "FILE_DIR=%~dp0"
+PUSHD "%FILE_DIR%"
+
+SET "COMMON=%FILE_DIR%\common.bat"
+
+CALL "%COMMON%" :SubPreBuild
+IF %ERRORLEVEL% NEQ 0 GOTO MissingVar
+
FOR %%G IN (%*) DO SET /A INPUT+=1
SET /A VALID+=%ARGB%+%ARGPL%+%ARGC%+%ARGBC%+%ARGCOMP%
IF %VALID% NEQ %INPUT% GOTO UnsupportedSwitch
@@ -103,7 +95,7 @@ IF NOT DEFINED VS120COMNTOOLS GOTO MissingVar
SET "TOOLSET=%VS120COMNTOOLS%..\..\VC\vcvarsall.bat"
SET "BIN_DIR=bin"
-IF EXIST "%~dp0signinfo.txt" (
+IF EXIST "%FILE_DIR%signinfo.txt" (
IF /I "%INSTALLER%" == "True" SET "SIGN=True"
IF /I "%ZIP%" == "True" SET "SIGN=True"
)
@@ -185,8 +177,8 @@ EXIT /B
IF %ERRORLEVEL% NEQ 0 EXIT /B
TITLE Compiling MPC-HC %COMPILER% [FINISHED]
SET END_TIME=%TIME%
-CALL :SubGetDuration
-CALL :SubMsg "INFO" "Compilation started on %START_DATE%-%START_TIME% and completed on %DATE%-%END_TIME% [%DURATION%]"
+CALL "%COMMON%" :SubGetDuration
+CALL "%COMMON%" :SubMsg "INFO" "Compilation started on %START_DATE%-%START_TIME% and completed on %DATE%-%END_TIME% [%DURATION%]"
ENDLOCAL
EXIT /B
@@ -203,10 +195,10 @@ MSBuild.exe mpc-hc.sln %MSBUILD_SWITCHES%^
/flp1:LogFile=%LOG_DIR%\filters_errors_%BUILDCFG%_%1.log;errorsonly;Verbosity=diagnostic^
/flp2:LogFile=%LOG_DIR%\filters_warnings_%BUILDCFG%_%1.log;warningsonly;Verbosity=diagnostic
IF %ERRORLEVEL% NEQ 0 (
- CALL :SubMsg "ERROR" "mpc-hc.sln %BUILDCFG% Filter %1 - Compilation failed!"
+ CALL "%COMMON%" :SubMsg "ERROR" "mpc-hc.sln %BUILDCFG% Filter %1 - Compilation failed!"
EXIT /B
) ELSE (
- CALL :SubMsg "INFO" "mpc-hc.sln %BUILDCFG% Filter %1 compiled successfully"
+ CALL "%COMMON%" :SubMsg "INFO" "mpc-hc.sln %BUILDCFG% Filter %1 compiled successfully"
)
IF /I "%SIGN%" == "True" CALL :SubSign Filters *.ax
IF /I "%SIGN%" == "True" CALL :SubSign Filters VSFilter.dll
@@ -222,10 +214,10 @@ MSBuild.exe mpc-hc.sln %MSBUILD_SWITCHES%^
/flp1:LogFile="%LOG_DIR%\mpc-hc_errors_%BUILDCFG%_%1.log";errorsonly;Verbosity=diagnostic^
/flp2:LogFile="%LOG_DIR%\mpc-hc_warnings_%BUILDCFG%_%1.log";warningsonly;Verbosity=diagnostic
IF %ERRORLEVEL% NEQ 0 (
- CALL :SubMsg "ERROR" "mpc-hc.sln %BUILDCFG% %1 - Compilation failed!"
+ CALL "%COMMON%" :SubMsg "ERROR" "mpc-hc.sln %BUILDCFG% %1 - Compilation failed!"
EXIT /B
) ELSE (
- CALL :SubMsg "INFO" "mpc-hc.sln %BUILDCFG% %1 compiled successfully"
+ CALL "%COMMON%" :SubMsg "INFO" "mpc-hc.sln %BUILDCFG% %1 compiled successfully"
)
IF /I "%SIGN%" == "True" CALL :SubSign MPC-HC mpc-hc*.exe
IF /I "%SIGN%" == "True" CALL :SubSign MPC-HC *.dll %LAVFILTERSDIR%
@@ -238,14 +230,14 @@ EXIT /B
IF %ERRORLEVEL% NEQ 0 EXIT /B
IF /I "%BUILDCFG%" == "Debug" (
- CALL :SubMsg "WARNING" "/debug was used, resources will not be built"
+ CALL "%COMMON%" :SubMsg "WARNING" "/debug was used, resources will not be built"
EXIT /B
)
CALL :SubMPCIconLib %1
IF DEFINED MPCHC_LITE (
- CALL :SubMsg "WARNING" "/lite was used, translations will not be built"
+ CALL "%COMMON%" :SubMsg "WARNING" "/lite was used, translations will not be built"
EXIT /B
)
@@ -260,10 +252,10 @@ TITLE Compiling mpciconlib %COMPILER% - Release^|%1...
MSBuild.exe mpciconlib.sln %MSBUILD_SWITCHES%^
/target:%BUILDTYPE% /property:Configuration=Release;Platform=%1
IF %ERRORLEVEL% NEQ 0 (
- CALL :SubMsg "ERROR" "mpciconlib.sln %1 - Compilation failed!"
+ CALL "%COMMON%" :SubMsg "ERROR" "mpciconlib.sln %1 - Compilation failed!"
EXIT /B
) ELSE (
- CALL :SubMsg "INFO" "mpciconlib.sln %1 compiled successfully"
+ CALL "%COMMON%" :SubMsg "INFO" "mpciconlib.sln %1 compiled successfully"
)
IF /I "%SIGN%" == "True" CALL :SubSign MPC-HC mpciconlib.dll
@@ -282,16 +274,16 @@ IF %ERRORLEVEL% NEQ 0 EXIT /B
FOR %%G IN (
"Arabic" "Armenian" "Basque" "Belarusian" "Bengali" "Catalan" "Chinese Simplified"
- "Chinese Traditional" "Croatian" "Czech" "Dutch" "English (British)" "Finnish"
- "French" "Galician" "German" "Greek" "Hebrew" "Hungarian" "Italian" "Japanese"
- "Korean" "Malay" "Polish" "Portuguese (Brazil)" "Romanian" "Russian" "Serbian"
- "Slovak" "Slovenian" "Spanish" "Swedish" "Tatar" "Thai" "Turkish" "Ukrainian"
- "Vietnamese"
+ "Chinese Traditional" "Croatian" "Czech" "Danish" "Dutch" "English (British)"
+ "Finnish" "French" "Galician" "German" "Greek" "Hebrew" "Hungarian" "Italian"
+ "Japanese" "Korean" "Malay" "Polish" "Portuguese (Brazil)" "Romanian" "Russian"
+ "Serbian" "Slovak" "Slovenian" "Spanish" "Swedish" "Tatar" "Thai" "Turkish"
+ "Ukrainian" "Vietnamese"
) DO (
TITLE Compiling mpcresources %COMPILER% - %%~G^|%1...
MSBuild.exe mpcresources.sln %MSBUILD_SWITCHES%^
/target:%BUILDTYPE% /property:Configuration="Release %%~G";Platform=%1
- IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Compilation failed!" & EXIT /B
+ IF %ERRORLEVEL% NEQ 0 CALL "%COMMON%" :SubMsg "ERROR" "Compilation failed!" & EXIT /B
)
IF /I "%SIGN%" == "True" CALL :SubSign MPC-HC mpcresources.??.dll Lang
IF /I "%SIGN%" == "True" CALL :SubSign MPC-HC mpcresources.??_??.dll Lang
@@ -306,10 +298,10 @@ TITLE Compiling MPCTestAPI %COMPILER% - %BUILDCFG%^|%1...
MSBuild.exe MPCTestAPI.sln %MSBUILD_SWITCHES%^
/target:%BUILDTYPE% /property:Configuration=%BUILDCFG%;Platform=%1
IF %ERRORLEVEL% NEQ 0 (
- CALL :SubMsg "ERROR" "MPCTestAPI.sln %1 - Compilation failed!"
+ CALL "%COMMON%" :SubMsg "ERROR" "MPCTestAPI.sln %1 - Compilation failed!"
EXIT /B
) ELSE (
- CALL :SubMsg "INFO" "MPCTestAPI.sln %1 compiled successfully"
+ CALL "%COMMON%" :SubMsg "INFO" "MPCTestAPI.sln %1 compiled successfully"
)
POPD
EXIT /B
@@ -325,9 +317,9 @@ IF /I "%PPLATFORM%" == "Win32" PUSHD "%BIN_DIR%\%~1_x86\%3"
IF /I "%PPLATFORM%" == "x64" PUSHD "%BIN_DIR%\%~1_x64\%3"
FOR /F "delims=" %%A IN ('DIR "%2" /b') DO (
- CALL "%~dp0contrib\sign.bat" "%%A" || (CALL :SubMsg "ERROR" "Problem signing %%A" & GOTO Break)
+ CALL "%FILE_DIR%contrib\sign.bat" "%%A" || (CALL "%COMMON%" :SubMsg "ERROR" "Problem signing %%A" & GOTO Break)
)
-CALL :SubMsg "INFO" "%2 signed successfully."
+CALL "%COMMON%" :SubMsg "INFO" "%2 signed successfully."
:Break
POPD
@@ -338,9 +330,9 @@ EXIT /B
IF /I "%BUILDCFG%" == "Debug" EXIT /B
PUSHD "%BIN_DIR%"
EXPAND "%DXSDK_DIR%\Redist\Jun2010_D3DCompiler_43_%~1.cab" -F:D3DCompiler_43.dll "mpc-hc_%~1%~2"
-IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Problem when extracting %DXSDK_DIR%\Redist\Jun2010_D3DCompiler_43_%~1.cab" & EXIT /B
+IF %ERRORLEVEL% NEQ 0 CALL "%COMMON%" :SubMsg "ERROR" "Problem when extracting %DXSDK_DIR%\Redist\Jun2010_D3DCompiler_43_%~1.cab" & EXIT /B
EXPAND "%DXSDK_DIR%\Redist\Jun2010_d3dx9_43_%~1.cab" -F:d3dx9_43.dll "mpc-hc_%~1%~2"
-IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Problem when extracting Jun2010_d3dx9_43_%~1.cab" & EXIT /B
+IF %ERRORLEVEL% NEQ 0 CALL "%COMMON%" :SubMsg "ERROR" "Problem when extracting Jun2010_d3dx9_43_%~1.cab" & EXIT /B
POPD
EXIT /B
@@ -361,18 +353,18 @@ IF DEFINED MPCHC_LITE (
CALL :SubCopyDXDll %MPCHC_COPY_DX_DLL_ARGS%
-CALL :SubDetectInnoSetup
+CALL "%COMMON%" :SubDetectInnoSetup
IF NOT DEFINED InnoSetupPath (
- CALL :SubMsg "WARNING" "Inno Setup wasn't found, the %1 installer wasn't built"
+ CALL "%COMMON%" :SubMsg "WARNING" "Inno Setup wasn't found, the %1 installer wasn't built"
EXIT /B
)
TITLE Compiling %1 %COMPILER% installer...
-"%InnoSetupPath%" /SMySignTool="cmd /c "%~dp0contrib\sign.bat" $f" /Q /O"%BIN_DIR%"^
+"%InnoSetupPath%" /SMySignTool="cmd /c "%FILE_DIR%contrib\sign.bat" $f" /Q /O"%BIN_DIR%"^
"distrib\mpc-hc_setup.iss" %MPCHC_INNO_DEF%
-IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Compilation failed!" & EXIT /B
-CALL :SubMsg "INFO" "%1 installer successfully built"
+IF %ERRORLEVEL% NEQ 0 CALL "%COMMON%" :SubMsg "ERROR" "Compilation failed!" & EXIT /B
+CALL "%COMMON%" :SubMsg "INFO" "%1 installer successfully built"
EXIT /B
@@ -380,11 +372,11 @@ EXIT /B
:SubCreatePackages
IF %ERRORLEVEL% NEQ 0 EXIT /B
-CALL :SubDetectSevenzipPath
-CALL :SubGetVersion
+CALL "%COMMON%" :SubDetectSevenzipPath
+CALL "%COMMON%" :SubGetVersion
IF NOT DEFINED SEVENZIP (
- CALL :SubMsg "WARNING" "7-Zip wasn't found, the %1 %2 package wasn't built"
+ CALL "%COMMON%" :SubMsg "WARNING" "7-Zip wasn't found, the %1 %2 package wasn't built"
EXIT /B
)
@@ -427,8 +419,8 @@ IF /I "%NAME%" == "MPC-HC" (
TITLE Creating archive %PCKG_NAME%.pdb.7z...
START "7z" /B /WAIT "%SEVENZIP%" a -t7z "%PCKG_NAME%.pdb.7z" %PDB_FILES% -m0=LZMA2^
-mmt=%NUMBER_OF_PROCESSORS% -mx9 -ms=on
- IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Unable to create %PCKG_NAME%.pdb.7z!" & EXIT /B
- CALL :SubMsg "INFO" "%PCKG_NAME%.pdb.7z successfully created"
+ IF %ERRORLEVEL% NEQ 0 CALL "%COMMON%" :SubMsg "ERROR" "Unable to create %PCKG_NAME%.pdb.7z!" & EXIT /B
+ CALL "%COMMON%" :SubMsg "INFO" "%PCKG_NAME%.pdb.7z successfully created"
IF EXIST "%PCKG_NAME%.pdb.7z" MOVE /Y "%PCKG_NAME%.pdb.7z" ".." >NUL
POPD
)
@@ -460,6 +452,12 @@ IF /I "%NAME%" == "MPC-HC" (
COPY /Y /V "%VS_OUT_DIR%\d3dx9_43.dll" "%PCKG_NAME%\d3dx9_43.dll" >NUL
IF NOT EXIST "%PCKG_NAME%\Shaders" MD "%PCKG_NAME%\Shaders"
COPY /Y /V "..\src\mpc-hc\res\shaders\external\*.hlsl" "%PCKG_NAME%\Shaders" >NUL
+ IF /I "%BUILDCFG%" NEQ "Debug" IF /I "%BUILDCFG%" NEQ "Debug Lite" IF EXIST "%VS_OUT_DIR%\CrashReporter" (
+ IF NOT EXIST "%PCKG_NAME%\CrashReporter" MD "%PCKG_NAME%\CrashReporter"
+ COPY /Y /V "%VS_OUT_DIR%\CrashReporter\crashrpt.dll" "%PCKG_NAME%\CrashReporter"
+ COPY /Y /V "%VS_OUT_DIR%\CrashReporter\dbghelp.dll" "%PCKG_NAME%\CrashReporter"
+ COPY /Y /V "%VS_OUT_DIR%\CrashReporter\sendrpt.exe" "%PCKG_NAME%\CrashReporter"
+ )
) ELSE (
COPY /Y /V "%VS_OUT_DIR%\*.ax" "%PCKG_NAME%\*.ax" >NUL
COPY /Y /V "%VS_OUT_DIR%\VSFilter.dll" "%PCKG_NAME%\VSFilter.dll" >NUL
@@ -473,8 +471,8 @@ COPY /Y /V "..\docs\Readme.txt" "%PCKG_NAME%" >NUL
TITLE Creating archive %PCKG_NAME%.7z...
START "7z" /B /WAIT "%SEVENZIP%" a -t7z "%PCKG_NAME%.7z" "%PCKG_NAME%" -m0=LZMA2^
-mmt=%NUMBER_OF_PROCESSORS% -mx9 -ms=on
-IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "Unable to create %PCKG_NAME%.7z!" & EXIT /B
-CALL :SubMsg "INFO" "%PCKG_NAME%.7z successfully created"
+IF %ERRORLEVEL% NEQ 0 CALL "%COMMON%" :SubMsg "ERROR" "Unable to create %PCKG_NAME%.7z!" & EXIT /B
+CALL "%COMMON%" :SubMsg "INFO" "%PCKG_NAME%.7z successfully created"
IF EXIST "%PCKG_NAME%" RD /Q /S "%PCKG_NAME%"
@@ -482,56 +480,6 @@ POPD
EXIT /B
-:SubGetVersion
-PUSHD %~dp0
-REM Get the version
-IF NOT EXIST "include\version_rev.h" SET "FORCE_VER_UPDATE=True"
-IF /I "%FORCE_VER_UPDATE%" == "True" CALL "update_version.bat" && SET "FORCE_VER_UPDATE=False"
-
-FOR /F "tokens=2,3" %%A IN ('FINDSTR /R /C:"define MPC_VERSION_[M,P]" "include\version.h"') DO (
- SET "%%A=%%B"
-)
-
-FOR /F "tokens=2,3" %%A IN ('FINDSTR /R /C:"define MPC" "include\version_rev.h"') DO (
- SET "%%A=%%B"
-)
-
-IF "%MPC_VERSION_REV%" NEQ "0" (SET "MPCHC_NIGHTLY=1") ELSE (SET "MPCHC_NIGHTLY=0")
-
-SET "MPCHC_HASH=%MPCHC_HASH:~4,-2%"
-IF DEFINED MPCHC_BRANCH (
- SET "MPCHC_BRANCH=%MPCHC_BRANCH:~4,-2%"
-)
-
-IF "%MPCHC_NIGHTLY%" NEQ "0" (
- SET "MPCHC_VER=%MPC_VERSION_MAJOR%.%MPC_VERSION_MINOR%.%MPC_VERSION_PATCH%.%MPC_VERSION_REV%"
-) ELSE (
- SET "MPCHC_VER=%MPC_VERSION_MAJOR%.%MPC_VERSION_MINOR%.%MPC_VERSION_PATCH%"
-)
-POPD
-EXIT /B
-
-
-:SubDetectInnoSetup
-FOR /F "tokens=5*" %%A IN (
- 'REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path" 2^>NUL ^| FIND "REG_SZ" ^|^|
- REG QUERY "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "InnoSetupPath=%%B\ISCC.exe"
-EXIT /B
-
-
-:SubDetectSevenzipPath
-FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
-IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
-
-FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
-IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
-
-FOR /F "tokens=2*" %%A IN (
- 'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ" ^|^|
- REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "SEVENZIP=%%B\7z.exe"
-EXIT /B
-
-
:ShowHelp
TITLE %~nx0 Help
ECHO.
@@ -565,7 +513,7 @@ TITLE Compiling MPC-HC %COMPILER% [ERROR]
ECHO Not all build dependencies were found.
ECHO.
ECHO See "docs\Compilation.txt" for more information.
-CALL :SubMsg "ERROR" "Compilation failed!" & EXIT /B
+CALL "%COMMON%" :SubMsg "ERROR" "Compilation failed!" & EXIT /B
:UnsupportedSwitch
@@ -575,68 +523,4 @@ ECHO.
ECHO "%~nx0 %*"
ECHO.
ECHO Run "%~nx0 help" for details about the commandline switches.
-CALL :SubMsg "ERROR" "Compilation failed!" & EXIT /B
-
-
-:SubMsg
-ECHO. & ECHO ------------------------------
-IF /I "%~1" == "ERROR" (
- CALL :SubColorText "0C" "[%~1]" "%~2"
-) ELSE IF /I "%~1" == "INFO" (
- CALL :SubColorText "0A" "[%~1]" "%~2"
-) ELSE IF /I "%~1" == "WARNING" (
- CALL :SubColorText "0E" "[%~1]" "%~2"
-)
-ECHO ------------------------------ & ECHO.
-IF /I "%~1" == "ERROR" (
- IF NOT DEFINED SILENT (
- ECHO Press any key to exit...
- PAUSE >NUL
- )
- ENDLOCAL
- EXIT /B 1
-) ELSE (
- EXIT /B
-)
-
-
-:SubColorText
-IF DEFINED NOCOLORS ECHO %~2 %~3 & EXIT /B
-FOR /F "tokens=1,2 delims=#" %%G IN (
- '"PROMPT #$H#$E# & ECHO ON & FOR %%H IN (1) DO REM"') DO (
- SET "DEL=%%G")
- "%~2"
-FINDSTR /v /a:%1 /R ".18" "%~2" NUL
-DEL "%~2" > NUL 2>&1
-REM The space in the following ECHO is intentional
-ECHO %~3
-EXIT /B
-
-
-:SubGetDuration
-SET START_TIME=%START_TIME: =%
-SET END_TIME=%END_TIME: =%
-
-FOR /F "tokens=1-4 delims=:.," %%G IN ("%START_TIME%") DO (
- SET /A "STARTTIME=(100%%G %% 100) * 360000 + (100%%H %% 100) * 6000 + (100%%I %% 100) * 100 + (100%%J %% 100)"
-)
-
-FOR /F "tokens=1-4 delims=:.," %%G IN ("%END_TIME%") DO (
- SET /A "ENDTIME=(100%%G %% 100) * 360000 + (100%%H %% 100) * 6000 + (100%%I %% 100) * 100 + (100%%J %% 100)"
-)
-
-SET /A DURATION=%ENDTIME%-%STARTTIME%
-IF %ENDTIME% LSS %STARTTIME% SET /A "DURATION+=24 * 360000"
-
-SET /A DURATIONH=%DURATION% / 360000
-SET /A DURATIONM=(%DURATION% - %DURATIONH%*360000) / 6000
-SET /A DURATIONS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000) / 100
-SET /A DURATIONHS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000 - %DURATIONS%*100)*10
-
-IF %DURATIONH% EQU 0 (SET DURATIONH=) ELSE (SET DURATIONH=%DURATIONH%h )
-IF %DURATIONM% EQU 0 (SET DURATIONM=) ELSE (SET DURATIONM=%DURATIONM%m )
-IF %DURATIONS% EQU 0 (SET DURATIONS=) ELSE (SET DURATIONS=%DURATIONS%s )
-IF %DURATIONHS% EQU 0 (SET DURATIONHS=) ELSE (SET DURATIONHS=%DURATIONHS%ms)
-
-SET "DURATION=%DURATIONH%%DURATIONM%%DURATIONS%%DURATIONHS%"
-EXIT /B
+CALL "%COMMON%" :SubMsg "ERROR" "Compilation failed!" & EXIT /B
diff --git a/common.bat b/common.bat
new file mode 100644
index 00000000000..cc3a5c75fa8
--- /dev/null
+++ b/common.bat
@@ -0,0 +1,168 @@
+@ECHO OFF
+REM (C) 2015 see Authors.txt
+REM
+REM This file is part of MPC-HC.
+REM
+REM MPC-HC is free software; you can redistribute it and/or modify
+REM it under the terms of the GNU General Public License as published by
+REM the Free Software Foundation; either version 3 of the License, or
+REM (at your option) any later version.
+REM
+REM MPC-HC is distributed in the hope that it will be useful,
+REM but WITHOUT ANY WARRANTY; without even the implied warranty of
+REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+REM GNU General Public License for more details.
+REM
+REM You should have received a copy of the GNU General Public License
+REM along with this program. If not, see .
+
+
+IF "%1" == "" CALL :SubMsg "ERROR" "%~nx0, No argument was provided." & EXIT /B
+PUSHD %~dp0
+CALL %*
+POPD
+EXIT /B
+
+:SubPreBuild
+IF EXIST "build.user.bat" CALL "build.user.bat"
+
+IF NOT DEFINED MPCHC_MINGW32 IF DEFINED MINGW32 (SET "MPCHC_MINGW32=%MINGW32%") ELSE (EXIT /B 1)
+IF NOT DEFINED MPCHC_MINGW64 IF DEFINED MINGW64 (SET "MPCHC_MINGW64=%MINGW64%") ELSE (EXIT /B 1)
+IF NOT DEFINED MPCHC_MSYS IF DEFINED MSYS (SET "MPCHC_MSYS=%MSYS%") ELSE (EXIT /B 1)
+
+IF NOT EXIST "%MPCHC_MINGW32%" EXIT /B 1
+IF NOT EXIST "%MPCHC_MINGW64%" EXIT /B 1
+IF NOT EXIST "%MPCHC_MSYS%" EXIT /B 1
+EXIT /B
+
+:SubSetPath
+CALL :SubPreBuild
+IF %ERRORLEVEL% NEQ 0 EXIT /B 1
+SET "PATH=%MPCHC_MSYS%\usr\bin;%MPCHC_MSYS%\bin;%MPCHC_MINGW32%\bin;%PATH%"
+EXIT /B
+
+:SubDoesExist
+FOR %%G IN (%~1) DO (SET FOUND=%%~$PATH:G)
+IF NOT DEFINED FOUND EXIT /B 1
+EXIT /B
+
+:SubGetVersion
+REM Get the version
+IF NOT EXIST "include\version_rev.h" SET "FORCE_VER_UPDATE=True"
+IF /I "%FORCE_VER_UPDATE%" == "True" CALL "update_version.bat" && SET "FORCE_VER_UPDATE=False"
+
+FOR /F "tokens=2,3" %%A IN ('FINDSTR /R /C:"define MPC_VERSION_[M,P]" "include\version.h"') DO (
+ SET "%%A=%%B"
+)
+
+FOR /F "tokens=2,3" %%A IN ('FINDSTR /R /C:"define MPC" "include\version_rev.h"') DO (
+ SET "%%A=%%B"
+)
+
+IF "%MPC_VERSION_REV%" NEQ "0" (SET "MPCHC_NIGHTLY=1") ELSE (SET "MPCHC_NIGHTLY=0")
+
+SET "MPCHC_HASH=%MPCHC_HASH:~4,-2%"
+IF DEFINED MPCHC_BRANCH (
+ SET "MPCHC_BRANCH=%MPCHC_BRANCH:~4,-2%"
+)
+
+IF "%MPCHC_NIGHTLY%" NEQ "0" (
+ SET "MPCHC_VER=%MPC_VERSION_MAJOR%.%MPC_VERSION_MINOR%.%MPC_VERSION_PATCH%.%MPC_VERSION_REV%"
+) ELSE (
+ SET "MPCHC_VER=%MPC_VERSION_MAJOR%.%MPC_VERSION_MINOR%.%MPC_VERSION_PATCH%"
+)
+EXIT /B
+
+:SubDetectCurl
+IF EXIST curl.exe (SET "CURL=curl.exe" & EXIT /B)
+IF EXIST "%CURL_PATH%\curl.exe" (SET "CURL=%CURL_PATH%\curl.exe" & EXIT /B)
+IF EXIST "%CURL_PATH%\bin\curl.exe" (SET "CURL=%CURL_PATH%\bin\curl.exe" & EXIT /B)
+FOR %%G IN (curl.exe) DO (SET "CURL_PATH=%%~$PATH:G")
+IF EXIST "%CURL_PATH%" (SET "CURL=%CURL_PATH%" & EXIT /B)
+EXIT /B
+
+:SubDetectTar
+IF EXIST tar.exe (SET "TAR=tar.exe" & EXIT /B)
+IF EXIST "%TAR_PATH%\tar.exe" (SET "TAR=%TAR_PATH%\tar.exe" & EXIT /B)
+FOR %%G IN (tar.exe) DO (SET "TAR_PATH=%%~$PATH:G")
+IF EXIST "%TAR_PATH%" (SET "TAR=%TAR_PATH%" & EXIT /B)
+EXIT /B
+
+:SubDetectInnoSetup
+FOR /F "tokens=5*" %%A IN (
+ 'REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path" 2^>NUL ^| FIND "REG_SZ" ^|^|
+ REG QUERY "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "InnoSetupPath=%%B\ISCC.exe"
+EXIT /B
+
+:SubDetectSevenzipPath
+FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
+IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
+
+FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
+IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
+
+FOR /F "tokens=2*" %%A IN (
+ 'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ" ^|^|
+ REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "SEVENZIP=%%B\7z.exe"
+EXIT /B
+
+:SubMsg
+ECHO. & ECHO ------------------------------
+IF /I "%~1" == "ERROR" (
+ CALL :SubColorText "0C" "[%~1]" "%~2"
+) ELSE IF /I "%~1" == "INFO" (
+ CALL :SubColorText "0A" "[%~1]" "%~2"
+) ELSE IF /I "%~1" == "WARNING" (
+ CALL :SubColorText "0E" "[%~1]" "%~2"
+)
+ECHO ------------------------------ & ECHO.
+IF /I "%~1" == "ERROR" (
+ IF NOT DEFINED SILENT (
+ ECHO Press any key to exit...
+ PAUSE >NUL
+ )
+ ENDLOCAL
+ EXIT /B 1
+) ELSE (
+ EXIT /B
+)
+
+:SubColorText
+IF DEFINED NOCOLORS ECHO %~2 %~3 & EXIT /B
+FOR /F "tokens=1,2 delims=#" %%G IN (
+ '"PROMPT #$H#$E# & ECHO ON & FOR %%H IN (1) DO REM"') DO (
+ SET "DEL=%%G")
+ "%~2"
+FINDSTR /v /a:%1 /R ".18" "%~2" NUL
+DEL "%~2" > NUL 2>&1
+REM The space in the following ECHO is intentional
+ECHO %~3
+EXIT /B
+
+:SubGetDuration
+SET START_TIME=%START_TIME: =%
+SET END_TIME=%END_TIME: =%
+
+FOR /F "tokens=1-4 delims=:.," %%G IN ("%START_TIME%") DO (
+ SET /A "STARTTIME=(100%%G %% 100) * 360000 + (100%%H %% 100) * 6000 + (100%%I %% 100) * 100 + (100%%J %% 100)"
+)
+
+FOR /F "tokens=1-4 delims=:.," %%G IN ("%END_TIME%") DO (
+ SET /A "ENDTIME=(100%%G %% 100) * 360000 + (100%%H %% 100) * 6000 + (100%%I %% 100) * 100 + (100%%J %% 100)"
+)
+
+SET /A DURATION=%ENDTIME%-%STARTTIME%
+IF %ENDTIME% LSS %STARTTIME% SET /A "DURATION+=24 * 360000"
+
+SET /A DURATIONH=%DURATION% / 360000
+SET /A DURATIONM=(%DURATION% - %DURATIONH%*360000) / 6000
+SET /A DURATIONS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000) / 100
+SET /A DURATIONHS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000 - %DURATIONS%*100)*10
+
+IF %DURATIONH% EQU 0 (SET DURATIONH=) ELSE (SET DURATIONH=%DURATIONH%h )
+IF %DURATIONM% EQU 0 (SET DURATIONM=) ELSE (SET DURATIONM=%DURATIONM%m )
+IF %DURATIONS% EQU 0 (SET DURATIONS=) ELSE (SET DURATIONS=%DURATIONS%s )
+IF %DURATIONHS% EQU 0 (SET DURATIONHS=) ELSE (SET DURATIONHS=%DURATIONHS%ms)
+
+SET "DURATION=%DURATIONH%%DURATIONM%%DURATIONS%%DURATIONHS%"
+EXIT /B
diff --git a/contrib/astyle.ini b/contrib/astyle.ini
index 95e19ae95ca..5d95a5cf983 100644
--- a/contrib/astyle.ini
+++ b/contrib/astyle.ini
@@ -35,17 +35,17 @@
# directories
--exclude=bin
+--exclude=cov-int
--exclude=thirdparty
# common files
--exclude=resource.h
# include dir
---exclude=atl --exclude=avisynth --exclude=dx --exclude=lglcd
---exclude=qt --exclude=realmedia --exclude=vd2 --exclude=winddk
---exclude=inttypes.h --exclude=libdivide.h --exclude=MediaInfoDLL.h
---exclude=mvrInterfaces.h --exclude=SubRenderIntf.h --exclude=unrar.h
---exclude=Utf8.h --exclude=version_rev.h
+--exclude=avisynth --exclude=dx --exclude=lglcd --exclude=qt
+--exclude=realmedia --exclude=vd2 --exclude=winddk --exclude=libdivide.h
+--exclude=MediaInfoDLL.h --exclude=mvrInterfaces.h --exclude=SubRenderIntf.h
+--exclude=unrar.h --exclude=Utf8.h --exclude=version_rev.h
# src/DeCSS
--exclude=CSSauth.cpp --exclude=CSSauth.h --exclude=CSSscramble.cpp --exclude=CSSscramble.h
@@ -55,7 +55,7 @@
--exclude=deinterlace.cpp --exclude=vd_asm.cpp --exclude=vd_asm.h --exclude=vd.cpp --exclude=vd.h
# src/mpc-hc
---exclude=LineNumberEdit.cpp --exclude=LineNumberEdit.h --exclude=Struct.h
+--exclude=Struct.h
# src/MPCTestAPI
--exclude=HScrollListBox.cpp --exclude=HScrollListBox.h
diff --git a/contrib/coverity.bat b/contrib/coverity.bat
index 9d274189b37..3dcd21c61a4 100755
--- a/contrib/coverity.bat
+++ b/contrib/coverity.bat
@@ -18,31 +18,22 @@ REM along with this program. If not, see .
SETLOCAL
+SET "FILE_DIR=%~dp0"
+PUSHD "%FILE_DIR%"
-PUSHD %~dp0
+SET "COMMON=%FILE_DIR%..\common.bat"
IF EXIST "..\build.user.bat" CALL "..\build.user.bat"
-IF NOT DEFINED COV_PATH SET "COV_PATH=H:\progs\thirdparty\cov-analysis-win64"
-IF DEFINED COV_PATH IF NOT EXIST "%COV_PATH%" (
- ECHO.
- ECHO ERROR: Coverity not found in "%COV_PATH%"
- GOTO End
-)
-
-
-CALL "%VS120COMNTOOLS%\vsvars32.bat"
-IF %ERRORLEVEL% NEQ 0 (
- ECHO vsvars32.bat call failed.
- GOTO End
-)
+IF NOT EXIST "%COV_PATH%" (CALL "%COMMON%" :SubMsg "ERROR" "Coverity not found in '%COV_PATH%'" & EXIT /B)
:Cleanup
IF EXIST "cov-int" RD /q /s "cov-int"
-IF EXIST "MPC-HC.lzma" DEL "MPC-HC.lzma"
-IF EXIST "MPC-HC.tar" DEL "MPC-HC.tar"
-IF EXIST "MPC-HC.tgz" DEL "MPC-HC.tgz"
+IF EXIST "MPC-HC.tar.xz" DEL "MPC-HC.tar.xz"
+IF EXIST "MPC-HC.tar" DEL "MPC-HC.tar"
+IF EXIST "MPC-HC.tgz" DEL "MPC-HC.tgz"
+IF EXIST "cov_upload.log" DEL "cov_upload.log"
:Main
@@ -54,58 +45,58 @@ CALL "..\build.bat" clean Api Both Release silent
"%COV_PATH%\bin\cov-build.exe" --dir cov-int "..\build.bat" Build Filters Both Release silent
"%COV_PATH%\bin\cov-build.exe" --dir cov-int "..\build.bat" Build IconLib Both Release silent
"%COV_PATH%\bin\cov-build.exe" --dir cov-int "..\build.bat" Build Api Both Release silent
+IF %ERRORLEVEL% NEQ 0 (CALL "%COMMON%" :SubMsg "ERROR" "Build failed." & EXIT /B)
:tar
-tar --version 1>&2 2>NUL || (ECHO. & ECHO ERROR: tar not found & GOTO SevenZip)
-tar caf "MPC-HC.lzma" "cov-int"
+CALL "%COMMON%" :SubDetectTar
+IF NOT EXIST "%TAR%" (CALL "%COMMON%" :SubMsg "WARNING" "tar not found. Trying 7-zip..." & GOTO SevenZip)
+
+SET "FILE_NAME=MPC-HC.tar.xz"
+SET "XZ_OPT=-9e"
+REM You can add -T{N} where {N} stands for count of threads to use. 0 will use all available threads.
+REM Pay attention to memory usage, -9eT4 uses over 5GB of RAM, but -9eT1 uses 700MB in my test.
+REM Lowering compression preset will also decrease memory usage significantly.
+
+%TAR% cJf %FILE_NAME% cov-int
+IF %ERRORLEVEL% NEQ 0 (
+ REM Fallback for 32-bit version of xz.
+ CALL "%COMMON%" :SubMsg "WARNING" "Fallback for 32-bit xz. Trying again with 'XZ_OPT=-7e'..."
+ SET "XZ_OPT=-7e"
+ %TAR% cJf %FILE_NAME% cov-int
+)
+
+IF %ERRORLEVEL% NEQ 0 (CALL "%COMMON%" :SubMsg "WARNING" "tar failed. Trying 7-zip..." & GOTO SevenZip)
GOTO Upload
:SevenZip
-CALL :SubDetectSevenzipPath
-
-rem Coverity is totally bogus with lzma...
-rem And since I cannot replicate the arguments with 7-Zip, just use tar/gzip.
-IF EXIST "%SEVENZIP%" (
- "%SEVENZIP%" a -ttar "MPC-HC.tar" "cov-int"
- "%SEVENZIP%" a -tgzip "MPC-HC.tgz" "MPC-HC.tar"
- IF EXIST "MPC-HC.tar" DEL "MPC-HC.tar"
- GOTO Upload
-)
+CALL "%COMMON%" :SubDetectSevenzipPath
+IF NOT EXIST "%SEVENZIP%" (CALL "%COMMON%" :SubMsg "ERROR" "7-zip not found." & EXIT /B)
+
+SET "FILE_NAME=MPC-HC.tgz"
+REM 7-Zip doesn't support tarball compliant LZMA2 archives, just use tar/gzip.
+"%SEVENZIP%" a -ttar "MPC-HC.tar" "cov-int"
+IF %ERRORLEVEL% NEQ 0 (CALL "%COMMON%" :SubMsg "ERROR" "7-zip failed." & EXIT /B)
+"%SEVENZIP%" a -tgzip "%FILE_NAME%" "MPC-HC.tar"
+IF %ERRORLEVEL% NEQ 0 (CALL "%COMMON%" :SubMsg "ERROR" "7-zip failed." & EXIT /B)
+IF EXIST "MPC-HC.tar" DEL "MPC-HC.tar"
+GOTO Upload
:Upload
CALL "..\build.bat" GetVersion
-CALL :SubDetectCurl
-%CURL% --form project=MPC-HC --form token=%COV_TOKEN% --form email=%COV_EMAIL% --form file=@MPC-HC.lzma --form version=%MPCHC_HASH% http://scan5.coverity.com/cgi-bin/upload.py
+CALL "%COMMON%" :SubDetectCurl
+IF NOT EXIST "%CURL%" (CALL "%COMMON%" :SubMsg "WARNING" "curl not found. Upload aborted." & GOTO End)
+IF NOT DEFINED COV_TOKEN (CALL "%COMMON%" :SubMsg "WARNING" "COV_TOKEN not defined. Upload aborted." & GOTO End)
+IF NOT DEFINED COV_EMAIL (CALL "%COMMON%" :SubMsg "WARNING" "COV_EMAIL not defined. Upload aborted." & GOTO End)
+%CURL% --form token=%COV_TOKEN% --form email=%COV_EMAIL% --form file=@%FILE_NAME% --form version=%MPCHC_HASH% https://scan.coverity.com/builds?project=MPC-HC -o cov_upload.log
GOTO End
-:SubDetectSevenzipPath
-FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
-IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
-
-FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
-IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
-
-FOR /F "tokens=2*" %%A IN (
- 'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ" ^|^|
- REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "SEVENZIP=%%B\7z.exe"
-EXIT /B
-
-
-:SubDetectCurl
-IF EXIST curl.exe (SET "CURL=curl.exe" & EXIT /B)
-IF EXIST "%CURL_PATH%\curl.exe" (SET "CURL=%CURL_PATH%\curl.exe" & EXIT /B)
-FOR %%G IN (curl.exe) DO (SET "CURL_PATH=%%~$PATH:G")
-IF EXIST "%CURL_PATH%" (SET "CURL=%CURL_PATH%" & EXIT /B)
-EXIT /B
-
-
:End
POPD
-ECHO. & ECHO Press any key to close this window...
+CALL "%COMMON%" :SubMsg "INFO" "Done. Press any key to exit..."
PAUSE >NUL
ENDLOCAL
EXIT /B
diff --git a/contrib/run_astyle.bat b/contrib/run_astyle.bat
index 7e75e8b8362..e90f69bfb8a 100755
--- a/contrib/run_astyle.bat
+++ b/contrib/run_astyle.bat
@@ -1,5 +1,5 @@
@ECHO OFF
-REM (C) 2012-2014 see Authors.txt
+REM (C) 2012-2015 see Authors.txt
REM
REM This file is part of MPC-HC.
REM
@@ -18,8 +18,8 @@ REM along with this program. If not, see .
SETLOCAL
-
-PUSHD %~dp0
+SET "FILE_DIR=%~dp0"
+PUSHD "%FILE_DIR%"
SET "AStyleVerReq=2.05.1"
astyle --version 2>NUL || (ECHO. & ECHO ERROR: AStyle not found & GOTO End)
@@ -27,7 +27,7 @@ CALL :SubCheckVer || GOTO End
:Start
-TITLE Running astyle using %~dp0astyle.ini
+TITLE Running astyle using %FILE_DIR%astyle.ini
IF "%~1" == "" (
astyle -r --options=astyle.ini ..\*.h ..\*.cpp
diff --git a/contrib/sign.bat b/contrib/sign.bat
index d5711b41f86..a232875daac 100755
--- a/contrib/sign.bat
+++ b/contrib/sign.bat
@@ -1,5 +1,5 @@
@ECHO OFF
-REM (C) 2013 see Authors.txt
+REM (C) 2013, 2015 see Authors.txt
REM
REM This file is part of MPC-HC.
REM
@@ -18,6 +18,7 @@ REM along with this program. If not, see .
SETLOCAL
+SET "FILE_DIR=%~dp0"
IF "%~1" == "" (
ECHO %~nx0: No input specified!
@@ -31,14 +32,14 @@ IF NOT DEFINED VS120COMNTOOLS (
GOTO END
)
-IF NOT EXIST "%~dp0..\signinfo.txt" (
- ECHO %~nx0: %~dp0..\signinfo.txt is not present!
+IF NOT EXIST "%FILE_DIR%..\signinfo.txt" (
+ ECHO %~nx0: %FILE_DIR%..\signinfo.txt is not present!
SET SIGN_ERROR=True
GOTO END
)
SET SIGN_CMD=
-SET /P SIGN_CMD=<%~dp0..\signinfo.txt
+SET /P SIGN_CMD=<"%FILE_DIR%..\signinfo.txt"
TITLE Signing "%~1"...
ECHO. & ECHO Signing "%~1"...
@@ -50,7 +51,7 @@ IF %ERRORLEVEL% NEQ 0 (
)
REM Repeat n times when signing fails
-SET REPEAT=3
+SET REPEAT=5
SET TRY=0
:SIGN
diff --git a/distrib/Languages/Bengali.islu b/distrib/Languages/Bengali.islu
index 58f84daf5f7..082a84dd22c 100644
--- a/distrib/Languages/Bengali.islu
+++ b/distrib/Languages/Bengali.islu
@@ -1,5 +1,5 @@
-; *** Inno Setup version 5.5.3+ Bangla messages ***
-;; Translated by Mehedi Shanto [ mehediDshanto@gmail.com ]
+; *** Inno Setup version 5.5.3+ Bengali messages ***
+; Translated by Mehedi Shanto [ mehediDshanto@gmail.com ]
; To download user-contributed translations of this file, go to:
; http://www.jrsoftware.org/files/istrans/
;
@@ -74,7 +74,7 @@ AboutSetupMenuItem=সেটআপ বিষয়ক...(&A)
AboutSetupTitle=সেটআপ বিষয়ক
AboutSetupMessage=%1এর সংস্করণ %2%n%3%n%n%1 হোম পেইজ:%n%4
AboutSetupNote=
-TranslatorNote=বাংলা অনুবাদ সম্পাদিত করেছে মেহেদী শান্ত
+TranslatorNote=বাংলা অনুবাদটি সম্পাদনা করেছে মেহেদী শান্ত
; *** Buttons
ButtonBack=< পূর্ববর্তী(&B)
@@ -149,7 +149,7 @@ InvalidDrive=আপনি যে ড্রাইভ বা UNC shareটি ন
DiskSpaceWarningTitle=নির্ধারিত ড্রাইভে পর্যাপ্ত জায়গা নেই
DiskSpaceWarning=ইনস্টল করতে সেটআপের কমপক্ষে %1 KB খালি জায়গা থাকতে হবে, কিন্তু নির্ধারিত ড্রাইভে রয়েছে মাত্র %2 KB।%n%nআপনি কি যাই হোক প্রক্রিয়াটি চলমান রাখতে চান?
DirNameTooLong=নির্ধারিত ফোল্ডারটির নাম অথবা অবস্থান অত্যন্ত দীর্ঘ।
-InvalidDirName=নির্ধারিত ফোল্ডারের নামটি সঠিক নয়।
+InvalidDirName=নির্ধারিত ফোল্ডারের নামটি অগ্রহণযোগ্য।
BadDirName32=ফোল্ডারের নামে নিম্নোক্ত ক্যারেক্টারসমূহ ব্যবহার করা যাবে না:%n%n%1
DirExistsTitle=ফোল্ডারটি বিদ্যমান রয়েছে
DirExists=নিম্নোক্ত ফোল্ডার:%n%n%1%n%nইতিমধ্যে বিদ্যমান রয়েছে। আপনি কি যাই হোক এই ফোল্ডারটিতেই ইনস্টল করতে চান?
@@ -163,7 +163,7 @@ SelectComponentsLabel2=যে সকল উপাদানসমূহ আপন
FullInstallation=সম্পূর্ণ ইনস্টল প্রক্রিয়া
; if possible don't translate 'Compact' as 'Minimal' (I mean 'Minimal' in your language)
CompactInstallation=ঘনবিন্যস্ত ইনস্টল প্রক্রিয়া
-CustomInstallation=নির্ধারণযোগ্য ইনস্টল প্রক্রিয়া
+CustomInstallation=ব্যক্তি-নির্ধারিত ইনস্টল প্রক্রিয়া
NoUninstallWarningTitle=উপাদানসমূহ বিদ্যমান রয়েছে
NoUninstallWarning=সেটআপ সনাক্ত করেছে যে নিম্নোক্ত উপাদানসমূহ ইতিমধ্যে আপনার কম্পিউটারে ইনস্টল করা রয়েছে:%n%n%1%n%nএই উপাদানসমূহ অনির্ধারণ করে দিলে তা আনইনস্টল হবে না।%n%nআপনি কি যাই হোক প্রক্রিয়াটি চলমান রাখতে চান?
ComponentSize1=%1 KB
@@ -182,7 +182,7 @@ SelectStartMenuFolderLabel3=সেটআপ প্রোগ্রামটির
SelectStartMenuFolderBrowseLabel=প্রক্রিয়াটি চলমান রাখতে, "পরবর্তী" ক্লিক করুন। ভিন্ন ফোল্ডার নির্ধারণ করতে চাইলে "ব্রাউজ করি" ক্লিক করুন।
MustEnterGroupName=আপনাকে অবশ্যই একটি ফোল্ডারের নাম প্রবেশ করতে হবে।
GroupNameTooLong=নির্ধারিত ফোল্ডারটির নাম অথবা অবস্থান অত্যন্ত দীর্ঘ।
-InvalidGroupName=নির্ধারিত ফোল্ডারের নামটি সঠিক নয়।
+InvalidGroupName=নির্ধারিত ফোল্ডারের নামটি অগ্রহণযোগ্য।
BadGroupName=ফোল্ডারের নামে নিম্নোক্ত ক্যারেক্টারসমূহ ব্যবহার করা যাবে না:%n%n%1
NoProgramGroupCheck2=স্টার্ট মেন্যুতে ফোল্ডার তৈরি করা হবে না(&D)
diff --git a/distrib/custom_messages_translated.iss b/distrib/custom_messages_translated.iss
index 49c036d58af..3d17fd2b532 100644
--- a/distrib/custom_messages_translated.iss
+++ b/distrib/custom_messages_translated.iss
@@ -35,16 +35,20 @@ be.WinVersionTooLowError=[name] патрабуецца Windows XP Service Pack 3
; Bengali
bn.WelcomeLabel2=এর মাধ্যমে আপনার কম্পিউটারে [name] ইনস্টল করা হবে। %n%nপ্রক্রিয়াটি চালিয়ে যাওয়ার পূর্বে অন্যান্য সকল অ্যাপ্লিকেশন বন্ধ করার পরামর্শ দেয়া যাচ্ছে।
-bn.WinVersionTooLowError=[name] চালানোর জন্য Windows XP Service Pack 3 অথবা ঊর্ধ্বতন সংস্করণ প্রয়োজন।
+bn.WinVersionTooLowError=[NAME] চালানোর জন্য Windows XP Service Pack 3 অথবা ঊর্ধ্বতন সংস্করণ প্রয়োজন।
; Catalan
ca.WelcomeLabel2=Aquest auxiliar instal·larà el [name] al vostre ordinador%n%nEs recomana tancar totes les aplicacions abans de continuar.
-ca.WinVersionTooLowError=[name] requereix Windows XP Service Pack 3 o superior per funcionar.
+ca.WinVersionTooLowError=[name] cal Windows XP Service Pack 3 o superior per que funcioni.
; Czech
cs.WelcomeLabel2=Produkt [name] bude nainstalován na Váš počítač.%n%nDříve než budete pokračovat, doporučuje se ukončit veškeré spuštěné aplikace.
cs.WinVersionTooLowError=[name] vyžaduje Windows XP Service Pack 3 nebo novější.
+; Danish
+da.WelcomeLabel2=Dette vil installere [name] på din computer.%n%nDet anbefales, at du lukker alle andre programmer, inden du fortsætter.
+da.WinVersionTooLowError=[name] kræver Windows XP Service Pack 3 eller nyere for at køre.
+
; German (Neutral)
de.WelcomeLabel2=Dieses Programm installiert [name] auf Ihrem Computer.%n%nEs wird empfohlen, alle laufenden Programme zu beenden, bevor Sie mit der Installation fortfahren.
de.WinVersionTooLowError=[name] benötigt Windows XP Service Pack 3 oder höher.
@@ -74,7 +78,7 @@ fr.WelcomeLabel2=Vous allez installer [name] sur votre ordinateur.%n%nIl est rec
fr.WinVersionTooLowError=[name] nécessite Windows XP Service Pack 3 ou plus récent pour fonctionner.
; Galician
-gl.WelcomeLabel2=Isto intalará [name] no teu ordenador.%n%nRecomendase que peches todas as aplicacións antes de seguir.
+gl.WelcomeLabel2=Isto instalará [name] no teu ordenador.%n%nRecoméndase que peches todas as aplicacións antes de seguir.
gl.WinVersionTooLowError=[name] require Windows XP Service Pack 3 ou posterior.
; Hebrew (Israel)
@@ -99,7 +103,7 @@ it.WinVersionTooLowError=[name] richiede Windows XP Service Pack 3 o successivo
; Japanese
ja.WelcomeLabel2=このプログラムはあなたのコンピュータ上に [name] をインストールします。%n%nセットアップを続行する前に他のすべてのアプリケーションを閉じることが推奨されます。
-ja.WinVersionTooLowError=[name] を実行する為には Windows XP Service Pack 3 以降が必要です。
+ja.WinVersionTooLowError=[name] を実行するためには Windows XP Service Pack 3 以降が必要です。
; Korean
ko.WelcomeLabel2=이것은 [name] 를(을) 당신의 컴퓨터에 설치합니다.%n%n설치를 계속하기 전에 다른 모든 프로그램을 종료하는 것을 권장합니다.
@@ -122,7 +126,7 @@ pt_BR.WelcomeLabel2=Isto instalará o [name] no seu computador.%n%nÉ recomendá
pt_BR.WinVersionTooLowError=[name] requer o Windows XP Service Pack 3 ou superior para ser executado.
; Romanian
-ro.WelcomeLabel2=Se va instala [name] pe calculatorul dumneavoastră.%n%nEste recomandat să închideţi toate celelalte aplicaţii înainte de a continua.
+ro.WelcomeLabel2=Se va instala [name] pe calculatorul dumneavoastră.%n%nEste recomandat să închideţi toate celelalte aplicații înainte de a continua.
ro.WinVersionTooLowError=[name] necesită Windows XP Service Pack 3 sau mai nou pentru a rula.
; Russian
@@ -220,7 +224,7 @@ bn.langid=00001093
bn.comp_mpciconlib=আইকন লাইব্রেরি
bn.comp_mpcresources=অনুবাদসমূহ
bn.msg_DeleteSettings=আপনি কি MPC-HCএর সেটিংসমূহও মুছে ফেলতে চান?%n%nআপনার যদি পুনরায় MPC-HC ইনস্টল করার পরিকল্পনা থাকে, তাহলে এসব মুছে ফেলতে হবে না।
-bn.msg_SetupIsRunningWarning=MPC-HCএর সেটআপ ইতিমধ্যে চলমান রয়েছে!
+bn.msg_SetupIsRunningWarning=MPC-HCএর সেটআপ প্রক্রিয়া ইতিমধ্যে চলমান রয়েছে!
#if defined(sse_required)
bn.msg_simd_sse=MPC-HCএর এই নির্মাণটির জন্য SSE এক্সটেনশন সমর্থন করে এমন একটি CPUর প্রয়োজন।%n%nআপনার CPUর সেই কর্মক্ষমতা নেই।
#elif defined(sse2_required)
@@ -231,8 +235,8 @@ bn.tsk_AllUsers=সকল ব্যবহারকারীর জন্য
bn.tsk_CurrentUser=শুধুমাত্র বর্তমান ব্যবহারকারীর জন্য
bn.tsk_Other=অন্যান্য কাজসমূহ:
bn.tsk_ResetSettings=সেটিংসমূহ পুনর্বিন্যাস
-bn.types_DefaultInstallation=নির্ধারিত ইনস্টল প্রক্রিয়া
-bn.types_CustomInstallation=নির্ধারণযোগ্য ইনস্টল প্রক্রিয়া
+bn.types_DefaultInstallation=ডিফল্ট ইনস্টল প্রক্রিয়া
+bn.types_CustomInstallation=ব্যক্তি-নির্ধারিত ইনস্টল প্রক্রিয়া
bn.ViewChangelog=পরিবর্তনতালিকা দেখুন
; Catalan
@@ -242,15 +246,15 @@ ca.comp_mpcresources=Traduccions
ca.msg_DeleteSettings=Voleu suprimir les preferències del MPC-HC?%n%nSi planegeu instal·lar-ho un altre cop no cal eliminar-les.
ca.msg_SetupIsRunningWarning=La instal·lació del MPC-HC ja s’està executant.
#if defined(sse_required)
-ca.msg_simd_sse=Aquesta versió de MPC-HC requereix una CPU amb suport d'extensions SSE.%n%nLa teva CPU no cumpleix aquestes característiques.
+ca.msg_simd_sse=Aquesta versió de MPC-HC necessita una CPU amb suport d'extensions SSE.%n%nLa teva CPU no cumpleix aquestes característiques.
#elif defined(sse2_required)
ca.msg_simd_sse2=Aquesta versió de MPC-HC requereix una CPU amb suport d'extensions SSE2.%n%nLa teva CPU no cumpleix aquestes característiques.
#endif
-ca.run_DownloadToolbarImages=Visita la nostra pàgina de Wiki per descarregar imatges per la barra d'eines
-ca.tsk_AllUsers=Per tots els usuaris
+ca.run_DownloadToolbarImages=Visita la nostra pàgina del Wiki per descarregar imatges per a la barra d'eines
+ca.tsk_AllUsers=Per a tots els usuaris
ca.tsk_CurrentUser=Només per l'usuari actual
ca.tsk_Other=Altres tasques:
-ca.tsk_ResetSettings=Reiniciar preferències
+ca.tsk_ResetSettings=Reiniciar les preferències
ca.types_DefaultInstallation=Instal·lació per defecte
ca.types_CustomInstallation=Instal·lació personalitzada
ca.ViewChangelog=Veure registre de canvis
@@ -275,6 +279,26 @@ cs.types_DefaultInstallation=Standardní instalace
cs.types_CustomInstallation=Volitelná instalace
cs.ViewChangelog=Zobrazit seznam změn
+; Danish
+da.langid=00001030
+da.comp_mpciconlib=Ikon-bibliotek
+da.comp_mpcresources=Oversættelser
+da.msg_DeleteSettings=Vil du også slette MPC-HC indstillinger?%n%nHvis du har tænkt dig at installere MPC-HC igen, så behøves du ikke slette dem.
+da.msg_SetupIsRunningWarning=MPC-HC installation kører allerede!
+#if defined(sse_required)
+da.msg_simd_sse=Denne version af MPC-HC kræver en CPU der understøtter SSE-udvidelsen.%n%nDin CPU understøtter det ikke.
+#elif defined(sse2_required)
+da.msg_simd_sse2=Denne version af MPC-HC kræver en CPU der understøtter SSE2-udvidelsen.%n%nDin CPU understøtter det ikke.
+#endif
+da.run_DownloadToolbarImages=Besøg vores wiki-side for at hente værktøjslinjebilleder
+da.tsk_AllUsers=For alle brugere
+da.tsk_CurrentUser=Kun for denne bruger
+da.tsk_Other=Andre opgaver:
+da.tsk_ResetSettings=Nulstil indstillinger
+da.types_DefaultInstallation=Standardinstallation
+da.types_CustomInstallation=Brugerdefineret installation
+da.ViewChangelog=Vis ændringslog
+
; German (Neutral)
de.langid=00001031
de.comp_mpciconlib=Dateisymbole für verknüpfte Mediendateien
@@ -419,12 +443,12 @@ fr.ViewChangelog=Voir la liste des changements
gl.langid=00001110
gl.comp_mpciconlib=Biblioteca de iconas
gl.comp_mpcresources=Traducións
-gl.msg_DeleteSettings=Tamén queres eliminar os axustes de MPC-HC?%n%nSe te plantexas instalar MPC-HC outra vez entón non o tes que eliminar.
-gl.msg_SetupIsRunningWarning=O instalador de MPC-HC xa está correndo!
+gl.msg_DeleteSettings=Ques eliminar tamén os axustes de MPC-HC?%n%nSe pensas instalar MPC-HC de novo entón non o tes que eliminalos.
+gl.msg_SetupIsRunningWarning=O instalador de MPC-HC xa está a ser executado!
#if defined(sse_required)
-gl.msg_simd_sse=Esta versión de MPC-HC require unha CPU con soporte para a extensión SSE .%n%nO seu CPU non ten estas capacidades.
+gl.msg_simd_sse=Esta versión de MPC-HC require unha CPU con soporte para a extensión SSE .%n%nA súa CPU non ten estas capacidades.
#elif defined(sse2_required)
-gl.msg_simd_sse2=Esta versión de MPC-HC require unha CPU con soporte para a extensión SSE2 .%n%nO seu CPU non ten estas capacidades.
+gl.msg_simd_sse2=Esta versión de MPC-HC require unha CPU con soporte para a extensión SSE2 .%n%nA súa CPU non ten estas capacidades.
#endif
gl.run_DownloadToolbarImages=Visite a nosa Wiki para descargar imaxes da barra de ferramentas
gl.tsk_AllUsers=Para todos os usuarios
@@ -471,7 +495,7 @@ hr.tsk_AllUsers=Za sve korisnike
hr.tsk_CurrentUser=Samo za trenutnog korisnika
hr.tsk_Other=Ostali zadaci:
hr.tsk_ResetSettings=Vrati na početne postavke programa
-hr.types_DefaultInstallation=Standarnda instalacija
+hr.types_DefaultInstallation=Standardna instalacija
hr.types_CustomInstallation=Prilagođena instalacija
hr.ViewChangelog=Pogledaj popis promjena
diff --git a/distrib/mpc-hc_setup.iss b/distrib/mpc-hc_setup.iss
index e222d124362..4dbecc41ad0 100644
--- a/distrib/mpc-hc_setup.iss
+++ b/distrib/mpc-hc_setup.iss
@@ -80,6 +80,8 @@
#define bindir = bindir + " Lite"
#endif
+#define crashreporter_dir = AddBackslash(bindir) + "CrashReporter"
+
#ifnexist AddBackslash(bindir) + mpchc_exe
#error Compile MPC-HC first
#endif
@@ -163,6 +165,7 @@ Name: be; MessagesFile: Languages\Belarusian.isl
Name: bn; MessagesFile: Languages\Bengali.islu
Name: ca; MessagesFile: compiler:Languages\Catalan.isl
Name: cs; MessagesFile: compiler:Languages\Czech.isl
+Name: da; MessagesFile: compiler:Languages\Danish.isl
Name: de; MessagesFile: compiler:Languages\German.isl
Name: el; MessagesFile: compiler:Languages\Greek.isl
Name: en_GB; MessagesFile: Languages\EnglishBritish.isl
@@ -245,6 +248,11 @@ Source: ..\docs\Authors.txt; DestDir: {app}; Components: main
Source: ..\docs\Changelog.txt; DestDir: {app}; Components: main; Flags: ignoreversion
Source: ..\docs\Readme.txt; DestDir: {app}; Components: main; Flags: ignoreversion
Source: ..\src\mpc-hc\res\shaders\external\*.hlsl; DestDir: {app}\Shaders; Components: main; Flags: ignoreversion
+#if DirExists(crashreporter_dir)
+Source: {#bindir}\CrashReporter\crashrpt.dll; DestDir: {app}\CrashReporter; Components: main; Flags: ignoreversion
+Source: {#bindir}\CrashReporter\dbghelp.dll; DestDir: {app}\CrashReporter; Components: main; Flags: ignoreversion
+Source: {#bindir}\CrashReporter\sendrpt.exe; DestDir: {app}\CrashReporter; Components: main; Flags: ignoreversion
+#endif
[Icons]
@@ -447,6 +455,12 @@ begin
end;
+procedure InitializeWizard();
+begin
+ WizardForm.LicenseAcceptedRadio.Checked := True;
+end;
+
+
procedure CurStepChanged(CurStep: TSetupStep);
var
iLanguage: Integer;
diff --git a/docs/Changelog.txt b/docs/Changelog.txt
index d80e2a05697..1164d81aaba 100644
--- a/docs/Changelog.txt
+++ b/docs/Changelog.txt
@@ -8,85 +8,82 @@ Legend:
! Fixed
-1.7.8 - 25 January 2015
-=======================
-+ DVB: Show current event time in the status bar
-+ DVB: Add context menu to the navigation dialog
-+ Add Finnish and Serbian translations
-+ Ticket #907, Enable "Properties" dialog for DVD and DVB playback modes
-+ Ticket #1091, Support MediaInfo analyse for DVD
-+ Ticket #1494, Add tooltip in the "Organize Favorites" dialog with path of the item
-+ Ticket #2438, Keep history of recently opened DVD directories
-+ Ticket #3647, Internal LAV Video Decoder: Support Cinepack and QPEG in low-merit mode
-+ Ticket #4941, Support embedded cover-art
-* DVB: Improve channel switching speed
-* The "Properties" dialog should open faster being that the MediaInfo analysis is now done asynchronously
-* Make double-click tolerance consistent with system settings
-* Ticket #4978, Execute "once" after playback event when playlist ends, regardless of the loop count
-* Ticket #4991, Text subtitles: "opaque box" outlines will now always be drawn even if the border width is set to 0.
- The size of the text is independent of the border width so there is no reason not to draw that part
-* Ticket #5056, Position the text subtitles relative to the video frame by default
-* Updated MediaInfoLib to v0.7.71
-* Updated ZenLib to v0.4.29 r498
-* Updated SoundTouch to v1.8.0 r201
-* Updated Little CMS to v2.7 (git 8174681)
-* Updated Unrar to v5.2.3
-* Updated LAV Filters to v0.63.0.52:
- - LAV Video Decoder: Fix a crash when the video height is not a multiple of 2
- - Ticket #3144, LAV Splitter: Support librtmp parameters for RTMP streams
- - Ticket #4407, LAV Video Decoder: Fix a rare crash when checking the compatibility with hardware decoding
- - Ticket #5030, LAV Video Decoder: The video timestamps could be wrong in some cases when using H264 DXVA decoding.
- This could lead to synchronization issue with the audio
- - Ticket #5047, LAV Splitter: Fix missing tracks in (m2)ts files
- - Ticket #5116, LAV Video Decoder: Fix aspect ratio for some MPEG2 streams
-* Updated Arabic, Armenian, Basque, Belarusian, Bengali, British English, Catalan, Chinese (Simplified and Traditional),
- Croatian, Czech, Dutch, French, Galician, German, Greek, Hebrew, Hungarian, Italian, Japanese, Korean, Malay,
- Polish, Portuguese (Brazil), Romanian, Russian, Slovak, Slovenian, Spanish, Swedish, Tatar, Thai, Turkish,
- Ukrainian and Vietnamese translations
-! XySubFilter: Always preserve subtitle frame aspect ratio
-! Properties dialog: The creation time did not account for the local timezone
-! Properties dialog: More consistent UI for the "Resources" tab
-! PGSSub: Subtitles could have opaque background instead of transparent one
-! Audio CDROMs with extra content could not be played
-! Ticket #2420, Improve the reliability of the DirectShow hooks
-! Ticket #2626, Fix some rare crashes when another application prevents MPC-HC from rendering the video
-! Ticket #2953, DVB: Fix crash when closing window right after switching channel
-! Ticket #3324, Some applications could interfere with Skype API and prevent MPC-HC from running
- when "Display "Now Playing" information in Skype's mood message" was enabled
-! Ticket #3666, DVB: Don't clear the channel list on saving new scan result
-! Ticket #3742, Sync Renderer: Fix rare crashes when using Sync Renderer with "synchronize video to display" option enabled
-! Ticket #3864, Video renderers: Fix a possible crash caused by a race condition
-! Ticket #3991, Video renderers: Fix a possible crash when the D3D device cannot be created
-! Ticket #4029, Fix a rare crash when right-clicking on the playlist panel
-! Ticket #4436, DVB: Improve compatibility with certain tuners
-! Ticket #4551, Fix a possible crash when saving the current frame
-! Ticket #4721, Audio CD playback could hang and stutter with some drives
-! Ticket #4933, ASS/SSA subtitles: Fix a crash for elements with no horizontal border but a vertical one
-! Ticket #4937, Prevent showing black bars when window size after scale exceed current work area
-! Ticket #4938, Fix resetting the settings from the "Options" dialog: some settings were (randomly) not
- restored to their default value
-! Ticket #4954, Open dialog: Support quoted paths
-! Ticket #4956, Improve Play/Pause mouse click responsiveness
-! Ticket #4957/#4982, Do not adjust window width in audio mode if no cover-art/logo is loaded or its size
- is limited to zero
-! Ticket #4969, DVD playback could fail with an error related to copy protection on some systems
-! Ticket #4971, Bring back "Play next file in the folder" event in single time events menu
-! Ticket #4975, Unrelated images could be loaded as cover-art when no author information was available
- in the audio file
-! Ticket #4991, Text subtitles: "opaque box" outlines were scaled twice
-! Ticket #4992, DVB: Enabling the "Information" panel using the "Info" button on the "Navigation" dialog
- would reduce the size of the main window when hiding the panel from the "View" menu
-! Ticket #4993, DVB: The content of the "Information" panel was lost when changing the UI language
-! Ticket #4994, The "Channels" sub-menu was not translated
-! Ticket #4995, Some context menus weren't properly positioned when opened by App key
-! Ticket #5010, Text subtitles: Fix a crash in case of memory allocation failure
-! Ticket #5055, True/False strings were not translated in value column on advanced page
-! Ticket #5067/#5203, Fix RealText subtitle parsing: the parser did not work at all and could even crash
-! Ticket #5127, Improve the behavior of MPC-HC when doing the MediaInfo analysis when playing from
- an optical drive. Playback will now be paused during the analysis to avoid concurrent accesses to
- the disk that might hang playback
-! Ticket #5130, Lock the player when the scan dialog is opened. Double-clicking on a media file will
- always open a new instance of MPC-HC in this case. This avoids interrupting the scan accidentally
- and fixes the issues which used to arise when doing that
-! Ticket #5130, Remove the information corresponding to the previously playing channel during the DVB scan
-! Ticket #5131, DVD playback could stutter on some systems
+1.7.9 - 1 June 2015
+===================
++ Internal Subtitle Renderer: Convert colorspace of subtitles to match video.
++ Append files to the playlist on drag&drop while holding "Control" key
++ Enable Press and Hold gesture to make easier access to context menu on touch devices
++ Add Danish translation
++ Add ability to disable every time after playback event for current session by selecting
+ "Do nothing" event in context menu.
++ Ticket #3051, Support DTS Music Disc
++ Ticket #5147, Add /randomize command-line switch for playlist randomization
++ Ticket #5334, Allow to enable high precision timer also when Subresync bar is hidden.
+ Right click on timer shows menu with options.
++ Ticket #5356, DVB: Support HEVC broadcasts
++ Ticket #5386, OSD: Add the ability to display the file name using a menu item and a hotkey ('N' by default)
+* Subtitle renderer: Better compatibility with ASS/SSA subtitle files that are slightly violating the specs
+* Rename "Display Stats" and "Reset Display Stats" features to "OSD: Display Renderer Statistics" and
+ "OSD: Reset Renderer Statistics" so that their meaning is clearer in the "Keys" option panel. Also
+ rename "Display Stats" to "Display Statistics" in the "Renderer Settings" menu
+* Ticket #5294, Use internal LAV Splitter for demuxing WTV files
+* Ticket #5336/#5380, Replace the minidump creation by Doctor Dump, a more advanced crash reporter.
+ The new crash reporter is able to send the report automatically after the user's approval and can
+ warn the user if the problem has already been fixed in a newer version. It should also be generally
+ more reliable than the old method
+* Ticket #5416, Rename "Remaining Time" feature to "Display Current Time" in the "Renderer Settings" menu
+ and to "OSD: Display Current Time" in the "Keys" option panel so that it describes the feature accurately
+* Updated Little CMS to v2.7 (git 6e33faa)
+* Updated Unrar to v5.2.7
+* Updated MediaInfoLib to v0.7.73
+* Updated ZenLib to v0.4.31
+* Updated SoundTouch to v1.9.0
+* Updated LAV Filters to v0.65.0.9:
+ - LAV Video Decoder: Faster DXVA decoding in copy-back mode (direct output mode)
+ - LAV Video Decoder: Support for HEVC Main10 DXVA2 decoding in copy-back mode
+ - LAV Audio Decoder: Support for native DTS-HD decoding using libdcadec
+ - Ticket #5299, LAV Video Decoder: Fix corrupted decoding of some HEVC files
+ - Ticket #5330, LAV Video Decoder: Improve DVD subtitles timeout in some cases
+ - Ticket #5333, LAV Splitter: Fix handling of some Blu-Ray playlist
+* Updated Basque, British English, Catalan, Chinese (Simplified), Croatian, Czech, Dutch, Finnish, French,
+ Galician, German, Greek, Hungarian, Italian, Japanese, Korean, Malay, Polish, Portuguese (Brazil), Romanian,
+ Russian, Serbian, Slovak, Slovenian, Spanish, Swedish, Thai, Turkish, Ukrainian and Vietnamese translations
+! EVR-CP/Sync renderers could produce wrong colors
+! Do not mirror the status bar and the time indicator when using an RTL layout
+! DVBSub: Fix a possible infinite loop when rendering corrupted subtitles
+! Subfolders were sometimes parsed multiple times when drag-and-dropping a folder
+! Haali Renderer: Fix XySubFilter support
+! Cover image were sometimes incorrectly displayed
+! Logitech LCD: MPC-HC crashed when the media duration was unknown
+! PGS subtitles: MPC-HC could crash when rendering broken subtitles
+! Playlist: Fix and improve the shuffle mode:
+ - Ticket #80, Playback stopped after playing the last playlist item even if not all tracks had been played
+ - Ticket #3028, If the playlist was cleared and then the items readded, pressing next caused a crash
+ - Ticket #3128, The first item to play was always the first one in the playlist
+ - Ticket #4442, Going to the previous file used the playlist order instead of the shuffled order
+ - Ticket #4616, No tracks will be repeated unless all tracks have been played at least once
+! Ticket #2167, Prevent the task bar buttons from being RTLed when Windows is configured to use RTL layout
+! Ticket #2516, VSFilter: Fix PGS/DVB subtitles with different size than video frame
+! Ticket #5028, Display OSD message for every time after playback event if once event is disabled
+! Ticket #5183, Fix a rare crash when processing after playback event
+! Ticket #5239, Fix a crash when specifying a non-existent monitor in the command line (/monitor)
+! Ticket #5241, Improve the handling of RTL layout for dockable bars (Playlist, Subresync, etc.)
+! Ticket #5247, "Information" panel was not showing new lines until window resize
+! Ticket #5259, The auto fit factor could not be modified unless auto fit was used as auto-zoom
+! Ticket #5262, The "Go to next/previous subtitle" feature did not work for some subtitles
+! Ticket #5274, Dockable bars: Improve reloading of saved state
+! Ticket #5280, The /nofocus command line option did nothing when starting MPC-HC
+! Ticket #5314, If an explicit start time was set (for example from the command line or a favorite),
+ the saved position wrongly overwrote the position of the previously opened file
+! Ticket #5324, Use more common "kb/s" instead of "Kb/s" as bitrate unit
+! Ticket #5326, Prevent the main window from stealing the mouse focus from the D3D fullscreen window
+ when using always on top. It could cause unintentional mouse clicks in the hidden main
+ window and prevented the mouse pointer from being correctly hidden
+! Ticket #5345, Fix opening of shortcuts pointing on directories
+! Ticket #5348, VobSub: The latest subtitle entry was sometimes not rendered
+! Ticket #5360, Fix: The "Turn off monitor" after playback event did not work
+! Ticket #5378, Fix the "DVD Menu Activate" hotkey
+! Ticket #5392, the Internal Subtitle Renderer did not work properly when the maximum texture resolution
+ was set to "Video" and the renderer was madVR
+! Ticket #5401, Remote commands (WinLIRC, uICE) were incorrectly bounded to actions
+! Ticket #5418, Fast seek (to key-frame) did not work when an external audio track was loaded
diff --git a/docs/Changelog_old.txt b/docs/Changelog_old.txt
index e40240e8528..6f870c25903 100644
--- a/docs/Changelog_old.txt
+++ b/docs/Changelog_old.txt
@@ -4,6 +4,90 @@ Legend:
! Fixed
+1.7.8 - 25 January 2015
+=======================
++ DVB: Show current event time in the status bar
++ DVB: Add context menu to the navigation dialog
++ Add Finnish and Serbian translations
++ Ticket #907, Enable "Properties" dialog for DVD and DVB playback modes
++ Ticket #1091, Support MediaInfo analyse for DVD
++ Ticket #1494, Add tooltip in the "Organize Favorites" dialog with path of the item
++ Ticket #2438, Keep history of recently opened DVD directories
++ Ticket #3647, Internal LAV Video Decoder: Support Cinepack and QPEG in low-merit mode
++ Ticket #4941, Support embedded cover-art
+* DVB: Improve channel switching speed
+* The "Properties" dialog should open faster being that the MediaInfo analysis is now done asynchronously
+* Make double-click tolerance consistent with system settings
+* Ticket #4978, Execute "once" after playback event when playlist ends, regardless of the loop count
+* Ticket #4991, Text subtitles: "opaque box" outlines will now always be drawn even if the border width is set to 0.
+ The size of the text is independent of the border width so there is no reason not to draw that part
+* Ticket #5056, Position the text subtitles relative to the video frame by default
+* Updated MediaInfoLib to v0.7.71
+* Updated ZenLib to v0.4.29 r498
+* Updated SoundTouch to v1.8.0 r201
+* Updated Little CMS to v2.7 (git 8174681)
+* Updated Unrar to v5.2.3
+* Updated LAV Filters to v0.63.0.52:
+ - LAV Video Decoder: Fix a crash when the video height is not a multiple of 2
+ - Ticket #3144, LAV Splitter: Support librtmp parameters for RTMP streams
+ - Ticket #4407, LAV Video Decoder: Fix a rare crash when checking the compatibility with hardware decoding
+ - Ticket #5030, LAV Video Decoder: The video timestamps could be wrong in some cases when using H264 DXVA decoding.
+ This could lead to synchronization issue with the audio
+ - Ticket #5047, LAV Splitter: Fix missing tracks in (m2)ts files
+ - Ticket #5116, LAV Video Decoder: Fix aspect ratio for some MPEG2 streams
+* Updated Arabic, Armenian, Basque, Belarusian, Bengali, British English, Catalan, Chinese (Simplified and Traditional),
+ Croatian, Czech, Dutch, French, Galician, German, Greek, Hebrew, Hungarian, Italian, Japanese, Korean, Malay,
+ Polish, Portuguese (Brazil), Romanian, Russian, Slovak, Slovenian, Spanish, Swedish, Tatar, Thai, Turkish,
+ Ukrainian and Vietnamese translations
+! XySubFilter: Always preserve subtitle frame aspect ratio
+! Properties dialog: The creation time did not account for the local timezone
+! Properties dialog: More consistent UI for the "Resources" tab
+! PGSSub: Subtitles could have opaque background instead of transparent one
+! Audio CDROMs with extra content could not be played
+! Ticket #2420, Improve the reliability of the DirectShow hooks
+! Ticket #2626, Fix some rare crashes when another application prevents MPC-HC from rendering the video
+! Ticket #2953, DVB: Fix crash when closing window right after switching channel
+! Ticket #3324, Some applications could interfere with Skype API and prevent MPC-HC from running
+ when "Display "Now Playing" information in Skype's mood message" was enabled
+! Ticket #3666, DVB: Don't clear the channel list on saving new scan result
+! Ticket #3742, Sync Renderer: Fix rare crashes when using Sync Renderer with "synchronize video to display" option enabled
+! Ticket #3864, Video renderers: Fix a possible crash caused by a race condition
+! Ticket #3991, Video renderers: Fix a possible crash when the D3D device cannot be created
+! Ticket #4029, Fix a rare crash when right-clicking on the playlist panel
+! Ticket #4436, DVB: Improve compatibility with certain tuners
+! Ticket #4551, Fix a possible crash when saving the current frame
+! Ticket #4721, Audio CD playback could hang and stutter with some drives
+! Ticket #4933, ASS/SSA subtitles: Fix a crash for elements with no horizontal border but a vertical one
+! Ticket #4937, Prevent showing black bars when window size after scale exceed current work area
+! Ticket #4938, Fix resetting the settings from the "Options" dialog: some settings were (randomly) not
+ restored to their default value
+! Ticket #4954, Open dialog: Support quoted paths
+! Ticket #4956, Improve Play/Pause mouse click responsiveness
+! Ticket #4957/#4982, Do not adjust window width in audio mode if no cover-art/logo is loaded or its size
+ is limited to zero
+! Ticket #4969, DVD playback could fail with an error related to copy protection on some systems
+! Ticket #4971, Bring back "Play next file in the folder" event in single time events menu
+! Ticket #4975, Unrelated images could be loaded as cover-art when no author information was available
+ in the audio file
+! Ticket #4991, Text subtitles: "opaque box" outlines were scaled twice
+! Ticket #4992, DVB: Enabling the "Information" panel using the "Info" button on the "Navigation" dialog
+ would reduce the size of the main window when hiding the panel from the "View" menu
+! Ticket #4993, DVB: The content of the "Information" panel was lost when changing the UI language
+! Ticket #4994, The "Channels" sub-menu was not translated
+! Ticket #4995, Some context menus weren't properly positioned when opened by App key
+! Ticket #5010, Text subtitles: Fix a crash in case of memory allocation failure
+! Ticket #5055, True/False strings were not translated in value column on advanced page
+! Ticket #5067/#5203, Fix RealText subtitle parsing: the parser did not work at all and could even crash
+! Ticket #5127, Improve the behavior of MPC-HC when doing the MediaInfo analysis when playing from
+ an optical drive. Playback will now be paused during the analysis to avoid concurrent accesses to
+ the disk that might hang playback
+! Ticket #5130, Lock the player when the scan dialog is opened. Double-clicking on a media file will
+ always open a new instance of MPC-HC in this case. This avoids interrupting the scan accidentally
+ and fixes the issues which used to arise when doing that
+! Ticket #5130, Remove the information corresponding to the previously playing channel during the DVB scan
+! Ticket #5131, DVD playback could stutter on some systems
+
+
1.7.7 - 05 October 2014
=======================
+ Allow loading more than one subtitle file at a time using the "Load subtitle" dialog or drag-and-drop
diff --git a/docs/Readme.txt b/docs/Readme.txt
index 87f8a788778..d00901ca1a1 100644
--- a/docs/Readme.txt
+++ b/docs/Readme.txt
@@ -5,8 +5,8 @@ and contains many additional features and bug fixes.
We are in dire need of new developers of any kind. If you can code a little,
or you can create logos for the player and images for the file associations,
or you can create/maintain the main website, please join our IRC channel
-and talk to us. Find some easy ticket on our trac page, fix the problem,
-post the patch on trac or come on IRC and we'll review it for you.
+and talk to us. Find some easy ticket on our Trac, fix the problem,
+post the patch on Trac or come on IRC and we'll review it for you.
Any help is always appreciated.
We care about keeping an open project open and free for contributions
@@ -24,7 +24,7 @@ Main Features:
* Multi-Monitor support
* Various pixel shaders
* Color management
-* 37 translations available
+* 38 translations available
System Requirements:
@@ -35,11 +35,11 @@ System Requirements:
Links:
------
-Website: http://mpc-hc.org
+Website: https://mpc-hc.org/
Source code: https://github.com/mpc-hc
-Support Trac: https://trac.mpc-hc.org
+Support Trac: https://trac.mpc-hc.org/
IRC Channel: #mpc-hc / #mpc-hc-dev at Freenode (http://webchat.freenode.net/)
-Donations: http://mpc-hc.org/donate/
+Donations: https://mpc-hc.org/donate/
For the people involved in the development, see Authors.txt.
@@ -53,21 +53,21 @@ MPC-HC makes use of the following third-party code:
Project License Website
--------------------------------------------------------------------
CSizingControlBar - http://www.datamekanix.com/sizecbar/
-LAV Filters GPLv2+ http://code.google.com/p/lavfilters/
+LAV Filters GPLv2+ https://code.google.com/p/lavfilters/
libdivide zlib License http://libdivide.com/
Little CMS MIT License http://www.littlecms.com/
Logitech SDK - -
-MediaInfoLib Simplified BSD License http://mediaarea.net/MediaInfo
+MediaInfoLib Simplified BSD License https://mediaarea.net/MediaInfo
Mhook MIT License https://github.com/martona/mhook
MultiMon CPOL http://www.codeproject.com/Articles/3690/
QuickTime SDK - http://developer.apple.com/quicktime/
RARFileSource GPLv2+ http://www.v12pwr.com/RARFileSource/
RealMedia SDK - -
-ResizableLib Artistic License http://sourceforge.net/projects/resizablelib/
+ResizableLib Artistic License https://sourceforge.net/projects/resizablelib/
Silk Icons CC Attribution 2.5 http://www.famfamfam.com/lab/icons/silk/
SoundTouch LGPLv2.1 http://www.surina.net/soundtouch/
TreePropSheet - http://www.codeproject.com/Articles/3709/
UnRAR freeware http://www.rarlab.com/rar_add.htm
VirtualDub GPLv2+ http://www.virtualdub.org/
-ZenLib zlib License http://sourceforge.net/projects/zenlib/
+ZenLib zlib License https://sourceforge.net/projects/zenlib/
zlib zlib License http://zlib.net/
diff --git a/include/inttypes.h b/include/inttypes.h
deleted file mode 100644
index dfbe45508fd..00000000000
--- a/include/inttypes.h
+++ /dev/null
@@ -1,306 +0,0 @@
-// ISO C9x compliant inttypes.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
-//
-// Copyright (c) 2006-2013 Alexander Chemeris
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// 3. Neither the name of the product nor the names of its contributors may
-// be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _MSC_VER // [
-#error "Use this header only with Microsoft Visual C++ compilers!"
-#endif // _MSC_VER ]
-
-#ifndef _MSC_INTTYPES_H_ // [
-#define _MSC_INTTYPES_H_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#include
-
-// 7.8 Format conversion of integer types
-
-typedef struct {
- intmax_t quot;
- intmax_t rem;
-} imaxdiv_t;
-
-// 7.8.1 Macros for format specifiers
-
-#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
-
-// The fprintf macros for signed integers are:
-#define PRId8 "d"
-#define PRIi8 "i"
-#define PRIdLEAST8 "d"
-#define PRIiLEAST8 "i"
-#define PRIdFAST8 "d"
-#define PRIiFAST8 "i"
-
-#define PRId16 "hd"
-#define PRIi16 "hi"
-#define PRIdLEAST16 "hd"
-#define PRIiLEAST16 "hi"
-#define PRIdFAST16 "hd"
-#define PRIiFAST16 "hi"
-
-#define PRId32 "I32d"
-#define PRIi32 "I32i"
-#define PRIdLEAST32 "I32d"
-#define PRIiLEAST32 "I32i"
-#define PRIdFAST32 "I32d"
-#define PRIiFAST32 "I32i"
-
-#define PRId64 "I64d"
-#define PRIi64 "I64i"
-#define PRIdLEAST64 "I64d"
-#define PRIiLEAST64 "I64i"
-#define PRIdFAST64 "I64d"
-#define PRIiFAST64 "I64i"
-
-#define PRIdMAX "I64d"
-#define PRIiMAX "I64i"
-
-#define PRIdPTR "Id"
-#define PRIiPTR "Ii"
-
-// The fprintf macros for unsigned integers are:
-#define PRIo8 "o"
-#define PRIu8 "u"
-#define PRIx8 "x"
-#define PRIX8 "X"
-#define PRIoLEAST8 "o"
-#define PRIuLEAST8 "u"
-#define PRIxLEAST8 "x"
-#define PRIXLEAST8 "X"
-#define PRIoFAST8 "o"
-#define PRIuFAST8 "u"
-#define PRIxFAST8 "x"
-#define PRIXFAST8 "X"
-
-#define PRIo16 "ho"
-#define PRIu16 "hu"
-#define PRIx16 "hx"
-#define PRIX16 "hX"
-#define PRIoLEAST16 "ho"
-#define PRIuLEAST16 "hu"
-#define PRIxLEAST16 "hx"
-#define PRIXLEAST16 "hX"
-#define PRIoFAST16 "ho"
-#define PRIuFAST16 "hu"
-#define PRIxFAST16 "hx"
-#define PRIXFAST16 "hX"
-
-#define PRIo32 "I32o"
-#define PRIu32 "I32u"
-#define PRIx32 "I32x"
-#define PRIX32 "I32X"
-#define PRIoLEAST32 "I32o"
-#define PRIuLEAST32 "I32u"
-#define PRIxLEAST32 "I32x"
-#define PRIXLEAST32 "I32X"
-#define PRIoFAST32 "I32o"
-#define PRIuFAST32 "I32u"
-#define PRIxFAST32 "I32x"
-#define PRIXFAST32 "I32X"
-
-#define PRIo64 "I64o"
-#define PRIu64 "I64u"
-#define PRIx64 "I64x"
-#define PRIX64 "I64X"
-#define PRIoLEAST64 "I64o"
-#define PRIuLEAST64 "I64u"
-#define PRIxLEAST64 "I64x"
-#define PRIXLEAST64 "I64X"
-#define PRIoFAST64 "I64o"
-#define PRIuFAST64 "I64u"
-#define PRIxFAST64 "I64x"
-#define PRIXFAST64 "I64X"
-
-#define PRIoMAX "I64o"
-#define PRIuMAX "I64u"
-#define PRIxMAX "I64x"
-#define PRIXMAX "I64X"
-
-#define PRIoPTR "Io"
-#define PRIuPTR "Iu"
-#define PRIxPTR "Ix"
-#define PRIXPTR "IX"
-
-// The fscanf macros for signed integers are:
-#define SCNd8 "d"
-#define SCNi8 "i"
-#define SCNdLEAST8 "d"
-#define SCNiLEAST8 "i"
-#define SCNdFAST8 "d"
-#define SCNiFAST8 "i"
-
-#define SCNd16 "hd"
-#define SCNi16 "hi"
-#define SCNdLEAST16 "hd"
-#define SCNiLEAST16 "hi"
-#define SCNdFAST16 "hd"
-#define SCNiFAST16 "hi"
-
-#define SCNd32 "ld"
-#define SCNi32 "li"
-#define SCNdLEAST32 "ld"
-#define SCNiLEAST32 "li"
-#define SCNdFAST32 "ld"
-#define SCNiFAST32 "li"
-
-#define SCNd64 "I64d"
-#define SCNi64 "I64i"
-#define SCNdLEAST64 "I64d"
-#define SCNiLEAST64 "I64i"
-#define SCNdFAST64 "I64d"
-#define SCNiFAST64 "I64i"
-
-#define SCNdMAX "I64d"
-#define SCNiMAX "I64i"
-
-#ifdef _WIN64 // [
-# define SCNdPTR "I64d"
-# define SCNiPTR "I64i"
-#else // _WIN64 ][
-# define SCNdPTR "ld"
-# define SCNiPTR "li"
-#endif // _WIN64 ]
-
-// The fscanf macros for unsigned integers are:
-#define SCNo8 "o"
-#define SCNu8 "u"
-#define SCNx8 "x"
-#define SCNX8 "X"
-#define SCNoLEAST8 "o"
-#define SCNuLEAST8 "u"
-#define SCNxLEAST8 "x"
-#define SCNXLEAST8 "X"
-#define SCNoFAST8 "o"
-#define SCNuFAST8 "u"
-#define SCNxFAST8 "x"
-#define SCNXFAST8 "X"
-
-#define SCNo16 "ho"
-#define SCNu16 "hu"
-#define SCNx16 "hx"
-#define SCNX16 "hX"
-#define SCNoLEAST16 "ho"
-#define SCNuLEAST16 "hu"
-#define SCNxLEAST16 "hx"
-#define SCNXLEAST16 "hX"
-#define SCNoFAST16 "ho"
-#define SCNuFAST16 "hu"
-#define SCNxFAST16 "hx"
-#define SCNXFAST16 "hX"
-
-#define SCNo32 "lo"
-#define SCNu32 "lu"
-#define SCNx32 "lx"
-#define SCNX32 "lX"
-#define SCNoLEAST32 "lo"
-#define SCNuLEAST32 "lu"
-#define SCNxLEAST32 "lx"
-#define SCNXLEAST32 "lX"
-#define SCNoFAST32 "lo"
-#define SCNuFAST32 "lu"
-#define SCNxFAST32 "lx"
-#define SCNXFAST32 "lX"
-
-#define SCNo64 "I64o"
-#define SCNu64 "I64u"
-#define SCNx64 "I64x"
-#define SCNX64 "I64X"
-#define SCNoLEAST64 "I64o"
-#define SCNuLEAST64 "I64u"
-#define SCNxLEAST64 "I64x"
-#define SCNXLEAST64 "I64X"
-#define SCNoFAST64 "I64o"
-#define SCNuFAST64 "I64u"
-#define SCNxFAST64 "I64x"
-#define SCNXFAST64 "I64X"
-
-#define SCNoMAX "I64o"
-#define SCNuMAX "I64u"
-#define SCNxMAX "I64x"
-#define SCNXMAX "I64X"
-
-#ifdef _WIN64 // [
-# define SCNoPTR "I64o"
-# define SCNuPTR "I64u"
-# define SCNxPTR "I64x"
-# define SCNXPTR "I64X"
-#else // _WIN64 ][
-# define SCNoPTR "lo"
-# define SCNuPTR "lu"
-# define SCNxPTR "lx"
-# define SCNXPTR "lX"
-#endif // _WIN64 ]
-
-#endif // __STDC_FORMAT_MACROS ]
-
-// 7.8.2 Functions for greatest-width integer types
-
-// 7.8.2.1 The imaxabs function
-#define imaxabs _abs64
-
-// 7.8.2.2 The imaxdiv function
-
-// This is modified version of div() function from Microsoft's div.c found
-// in %MSVC.NET%\crt\src\div.c
-#ifdef STATIC_IMAXDIV // [
-static
-#else // STATIC_IMAXDIV ][
-_inline
-#endif // STATIC_IMAXDIV ]
-imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
-{
- imaxdiv_t result;
-
- result.quot = numer / denom;
- result.rem = numer % denom;
-
- if (numer < 0 && result.rem > 0) {
- // did division wrong; must fix up
- ++result.quot;
- result.rem -= denom;
- }
-
- return result;
-}
-
-// 7.8.2.3 The strtoimax and strtoumax functions
-#define strtoimax _strtoi64
-#define strtoumax _strtoui64
-
-// 7.8.2.4 The wcstoimax and wcstoumax functions
-#define wcstoimax _wcstoi64
-#define wcstoumax _wcstoui64
-
-
-#endif // _MSC_INTTYPES_H_ ]
diff --git a/include/moreuuids.h b/include/moreuuids.h
index 311d2c1c0f2..6ee7f94b0ad 100644
--- a/include/moreuuids.h
+++ b/include/moreuuids.h
@@ -396,9 +396,6 @@ DEFINE_GUID(MEDIASUBTYPE_PS2_SUB,
DEFINE_GUID(CLSID_DXR,
0x760a8f35, 0x97e7, 0x479d, 0xaa, 0xf5, 0xda, 0x9e, 0xff, 0x95, 0xd7, 0x51);
-DEFINE_GUID(CLSID_madVR,
- 0xe1a8b82a, 0x32ce, 0x4b0d, 0xbe, 0x0d, 0xaa, 0x68, 0xc7, 0x72, 0xe4, 0x23);
-
//
// Ogg
//
diff --git a/include/mpc-hc_config.h b/include/mpc-hc_config.h
index d8a2b0f5330..03317b768db 100644
--- a/include/mpc-hc_config.h
+++ b/include/mpc-hc_config.h
@@ -1,6 +1,6 @@
#ifndef ISPP_INVOKED
/*
- * (C) 2013-2014 see Authors.txt
+ * (C) 2013-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -31,9 +31,9 @@
#endif
#endif
-#define WEBSITE_URL _T("http://mpc-hc.org/")
-#define DOWNLOAD_URL _T("http://mpc-hc.org/downloads/")
-#define UPDATE_URL _T("http://mpc-hc.org/version.txt")
+#define WEBSITE_URL _T("https://mpc-hc.org/")
+#define DOWNLOAD_URL _T("https://mpc-hc.org/downloads/")
+#define UPDATE_URL _T("https://mpc-hc.org/version.txt")
#define TRAC_URL _T("https://trac.mpc-hc.org/")
#define BUGS_URL _T("https://trac.mpc-hc.org/wiki/How_to_Report_Issues")
#define TOOLBARS_URL _T("https://trac.mpc-hc.org/wiki/Toolbar_images")
diff --git a/include/mvrInterfaces.h b/include/mvrInterfaces.h
index 24f63d0ac72..fccbef67dba 100644
--- a/include/mvrInterfaces.h
+++ b/include/mvrInterfaces.h
@@ -1,11 +1,12 @@
// ***************************************************************
-// mvrInterfaces.h version: 1.0.6 date: 2013-06-04
+// mvrInterfaces.h version: 1.0.7 date: 2014-01-18
// -------------------------------------------------------------
// various interfaces exported by madVR
// -------------------------------------------------------------
-// Copyright (C) 2011 - 2013 www.madshi.net, BSD license
+// Copyright (C) 2011 - 2014 www.madshi.net, BSD license
// ***************************************************************
+// 2014-01-18 1.0.7 added IMadVRSettings2
// 2013-06-04 1.0.6 added IMadVRInfo
// 2013-01-23 1.0.5 added IMadVRSubclassReplacement
// 2012-11-18 1.0.4 added IMadVRExternalPixelShaders
@@ -23,7 +24,7 @@
// use this CLSID to create a madVR instance
-// DEFINE_GUID(CLSID_madVR, 0xe1a8b82a, 0x32ce, 0x4b0d, 0xbe, 0x0d, 0xaa, 0x68, 0xc7, 0x72, 0xe4, 0x23);
+DEFINE_GUID(CLSID_madVR, 0xe1a8b82a, 0x32ce, 0x4b0d, 0xbe, 0x0d, 0xaa, 0x68, 0xc7, 0x72, 0xe4, 0x23);
// ---------------------------------------------------------------------------
// IMadVROsdServices
@@ -72,6 +73,8 @@ interface IOsdRenderCallback : public IUnknown
// fullOutputRect = (0, 0, outputSurfaceWidth, outputSurfaceHeight)
// activeVideoRect = active video rendering rect inside of fullOutputRect
// background area = the part of fullOutputRect which isn't covered by activeVideoRect
+ // you can return ERROR_EMPTY to indicate that you didn't actually do anything
+ // in that case madVR will skip some Direct3D state changes to save performance
STDMETHOD(ClearBackground)(LPCSTR name, REFERENCE_TIME frameStart, RECT *fullOutputRect, RECT *activeVideoRect) = 0;
STDMETHOD(RenderOsd )(LPCSTR name, REFERENCE_TIME frameStart, RECT *fullOutputRect, RECT *activeVideoRect) = 0;
};
@@ -91,7 +94,7 @@ interface IMadVROsdServices : public IUnknown
bool posRelativeToVideoRect = false, // draw relative to TRUE: the active video rect; FALSE: the full output rect
int zOrder = 0, // high zOrder OSD elements are drawn on top of those with smaller zOrder values
DWORD duration = 0, // how many milliseconds shall the OSD element be shown (0 = infinite)?
- DWORD flags = 0, // undefined - set to 0
+ DWORD flags = 0, // 0x00000001 = stretch OSD bitmap to video/output rect
OSDMOUSECALLBACK callback = NULL, // optional callback for mouse events
LPVOID callbackContext = NULL, // this context is passed to the callback
LPVOID reserved = NULL // undefined - set to NULL
@@ -313,8 +316,8 @@ interface IMadVRInfo : public IUnknown
// setting value. E.g. the following calls will all return the same value:
// (1) GetBoolean(L"dontDither", &boolVal);
// (2) GetBoolean(L"don't use dithering", &boolVal);
-// (3) GetBoolean(L"tradeQuality\dontDither", &boolVal);
-// (4) GetBoolean(L"performanceTweaks\trade quality for performance\dontDither", &boolVal);
+// (3) GetBoolean(L"dithering\dontDither", &boolVal);
+// (4) GetBoolean(L"rendering\dithering\dontDither", &boolVal);
// Using the full path can make sense if you want to access a specific profile.
// If you don't specify a path, you automatically access the currently active
@@ -351,6 +354,55 @@ interface IMadVRSettings : public IUnknown
STDMETHOD_(BOOL, SettingsGetBinary )(LPCWSTR path, LPVOID* value, int* bufLenInBytes) = 0;
};
+[uuid("1C3E03D6-F422-4D31-9424-75936F663BF7")]
+interface IMadVRSettings2 : public IMadVRSettings
+{
+ // Enumerate the available settings stuff in the specified path.
+ // Simply loop from enumIndex 0 to infinite, until the enumeration returns FALSE.
+ // When enumeration is completed GetLastError returns ERROR_NO_MORE_ITEMS.
+ // The buffers must be provided by the caller and ...LenInChars set to the
+ // buffer's length (please note: 1 char -> 2 bytes). If the buffer is too small,
+ // the API fails and GetLastError returns ERROR_MORE_DATA. On return,
+ // ...LenInChars is set to the required buffer size.
+ STDMETHOD_(BOOL, SettingsEnumFolders )(LPCWSTR path, int enumIndex, LPCWSTR id, LPCWSTR name, LPCWSTR type, int* idLenInChars, int* nameLenInChars, int* typeLenInChars) = 0;
+ STDMETHOD_(BOOL, SettingsEnumValues )(LPCWSTR path, int enumIndex, LPCWSTR id, LPCWSTR name, LPCWSTR type, int* idLenInChars, int* nameLenInChars, int* typeLenInChars) = 0;
+ STDMETHOD_(BOOL, SettingsEnumProfileGroups)(LPCWSTR path, int enumIndex, LPCWSTR name, int* nameLenInChars ) = 0;
+ STDMETHOD_(BOOL, SettingsEnumProfiles )(LPCWSTR path, int enumIndex, LPCWSTR name, int* nameLenInChars ) = 0;
+
+ // Creates/deletes a profile group in the specified path.
+ // Deleting a profile group works only if there's only one profile left in the group.
+ // Example:
+ // SettingsCreateProfileGroup('scalingParent', 'imageDoubling|lumaUp', 'upscaling profiles', 'SD 24fps');
+ // SettingsDeleteProfileGroup('scalingParent\upscaling profiles');
+ STDMETHOD_(BOOL, SettingsCreateProfileGroup)(LPCWSTR path, LPCWSTR settingsPageList, LPCWSTR profileGroupName, LPCWSTR firstProfileName) = 0;
+ STDMETHOD_(BOOL, SettingsDeleteProfileGroup)(LPCWSTR path) = 0;
+
+ // SettingsAddProfile adds a new profile, using default parameters for all values.
+ // SettingsDuplicateProfile duplicates/copies a profile with all parameters.
+ // Deleting a profile works only if it isn't the only profile left in the group.
+ // Example:
+ // SettingsAddProfile('scalingParent\upscaling profiles', 'SD 60fps');
+ // SettingsDuplicateProfile('scalingParent\upscaling profiles', 'SD 60fps', 'HD 24fps');
+ // SettingsDeleteProfile('scalingParent\upscaling profiles', 'SD 60fps');
+ STDMETHOD_(BOOL, SettingsAddProfile )(LPCWSTR path, LPCWSTR newProfileName) = 0;
+ STDMETHOD_(BOOL, SettingsDuplicateProfile)(LPCWSTR path, LPCWSTR originalProfileName, LPCWSTR newProfileName) = 0;
+ STDMETHOD_(BOOL, SettingsDeleteProfile )(LPCWSTR path, LPCWSTR profileName ) = 0;
+
+ // SettingsActivateProfile activates the specified profile.
+ // It also disables automatic (rule based) profile selection.
+ // SettingsAutoselectProfile allows you to reactivate it.
+ // Example:
+ // if SettingsIsProfileActive('scalingParent\upscaling profiles', 'SD 24fps') then
+ // begin
+ // SettingsActivateProfile('scalingParent\upscaling profiles', 'SD 60fps');
+ // [...]
+ // SettingsAutoselectProfile('scalingParent\upscaling profiles');
+ STDMETHOD_(BOOL, SettingsIsProfileActive)(LPCWSTR path, LPCWSTR profileName) = 0;
+ STDMETHOD_(BOOL, SettingsActivateProfile)(LPCWSTR path, LPCWSTR profileName) = 0;
+ STDMETHOD_(BOOL, SettingsIsProfileAutoselected)(LPCWSTR path) = 0;
+ STDMETHOD_(BOOL, SettingsAutoselectProfile)(LPCWSTR path) = 0;
+};
+
// available settings: id, name, type, valid values
// ------------------------------------------------
// devices, devices
@@ -364,11 +416,15 @@ interface IMadVRSettings : public IUnknown
// levels, levels, string, TV Levels|PC Levels|Custom
// black, black, integer, 0..48
// white, white, integer, 200..255
-// displayBitdepth, native display bitdepth, integer, 6..10
+// displayBitdepth, native display bitdepth, integer, 3..10
// calibration, calibration
// calibrate, calibrate display, string, disable calibration controls for this display|this display is already calibrated|calibrate this display by using yCMS|calibrate this display by using an external 3dlut file
// disableGpuGammaRamps, disable GPU gamma ramps, boolean
-// external3dlutFile, external 3dlut file, string
+// external3dlutFile709, external 3dlut file (BT.709), string
+// external3dlutFileNtsc, external 3dlut file (SMPTE C), string
+// external3dlutFilePal, external 3dlut file (EBU/PAL), string
+// external3dlutFile2020, external 3dlut file (BT.2020), string
+// external3dlutFileDci, external 3dlut file (DCI-P3), string
// gamutMeasurements, gamut measurements, string
// gammaMeasurements, gamma measurements, string
// displayPrimaries, display primaries, string, BT.709 (HD)|BT.601 (SD)|PAL|something else
@@ -390,20 +446,34 @@ interface IMadVRSettings : public IUnknown
// currentGammaCurve, current gamma curve, string, pure power curve|BT.709/601 curve
// currentGammaValue, current gamma value, string, 1.80|1.85|1.90|1.95|2.00|2.05|2.10|2.15|2.20|2.25|2.30|2.35|2.40|2.45|2.50|2.55|2.60|2.65|2.70|2.75|2.80
// processing, processing
-// decoding, processing
-// decodeH264, decode h264, string, disable|libav|intel|hardware
-// decodeVc1, decode VC-1, string, disable|libav|intel|hardware
-// decodeMpeg2, decode MPEG2, string, disable|libav|intel|hardware
// deinterlacing, deinterlacing
// autoActivateDeinterlacing, automatically activate deinterlacing when needed, boolean
// ifInDoubtDeinterlace, if in doubt, activate deinterlacing, boolean
// contentType, source type, string, auto|film|video
// scanPartialFrame, only look at pixels in the frame center, boolean
// deinterlaceThread, perform deinterlacing in separate thread, boolean
+// artifactRemoval, artifact removal
+// debandActive, reduce banding artifacts, boolean
+// debandLevel, default debanding strength, integer, 0..2
+// debandFadeLevel, strength during fade in/out, integer, 0..2
// scalingParent, scaling algorithms
// chromaUp, chroma upscaling
-// chromaUp, chroma upsampling, string, Nearest Neighbor|Bilinear|Mitchell-Netravali|Catmull-Rom|Bicubic50|Bicubic60|Bicubic75|Bicubic100|SoftCubic50|SoftCubic60|SoftCubic70|SoftCubic80|SoftCubic100|Lanczos3|Lanczos4|Lanczos8|Spline36|Spline64|Jinc3|Jinc4|Jinc8
+// chromaUp, chroma upsampling, string, Nearest Neighbor|Bilinear|Mitchell-Netravali|Catmull-Rom|Bicubic50|Bicubic60|Bicubic75|Bicubic100|SoftCubic50|SoftCubic60|SoftCubic70|SoftCubic80|SoftCubic100|Lanczos3|Lanczos4|Lanczos8|Spline36|Spline64|Jinc3|Jinc4|Jinc8|Nnedi16|Nnedi32|Nnedi64|Nnedi128|Nnedi256
// chromaAntiRinging, activate anti-ringing filter for chroma upsampling, boolean
+// imageDoubling, image doubling
+// nnediDLEnable, use NNEDI3 to double Luma resolution, boolean
+// nnediDCEnable, use NNEDI3 to double Chroma resolution, boolean
+// nnediQLEnable, use NNEDI3 to quadruple Luma resolution, boolean
+// nnediQCEnable, use NNEDI3 to quadruple Chroma resolution, boolean
+// nnediDLScalingFactor, when to use NNEDI3 to double Luma resolution, string, 1.2x|1.5x|2.0x|always
+// nnediDCScalingFactor, when to use NNEDI3 to double Chroma resolution, string, 1.2x|1.5x|2.0x|always
+// nnediQLScalingFactor, when to use NNEDI3 to quadruple Luma resolution, string, 1.2x|1.5x|2.0x|always
+// nnediQCScalingFactor, when to use NNEDI3 to quadruple Chroma resolution, string, 1.2x|1.5x|2.0x|always
+// nnediDLQuality, NNEDI3 double Luma quality, integer, 0..4
+// nnediDLQuality, NNEDI3 double Chroma quality, integer, 0..4
+// nnediDLQuality, NNEDI3 quadruple Luma quality, integer, 0..4
+// nnediDLQuality, NNEDI3 quadruple Chroma quality, integer, 0..4
+// amdInteropHack, use alternative interop hack (not recommended, AMD only), boolean
// lumaUp, image upscaling
// lumaUp, image upscaling, string, Nearest Neighbor|Bilinear|Dxva|Mitchell-Netravali|Catmull-Rom|Bicubic50|Bicubic60|Bicubic75|Bicubic100|SoftCubic50|SoftCubic60|SoftCubic70|SoftCubic80|SoftCubic100|Lanczos3|Lanczos4|Lanczos8|Spline36|Spline64|Jinc3|Jinc4|Jinc8
// lumaUpAntiRinging, activate anti-ringing filter for luma upsampling, boolean
@@ -414,7 +484,6 @@ interface IMadVRSettings : public IUnknown
// lumaDownLinear, downscale luma in linear light, boolean
// rendering, rendering
// basicRendering, general settings
-// managedUpload, use managed upload textures (XP only), boolean
// uploadInRenderThread, upload frames in render thread, boolean
// delayPlaybackStart2, delay playback start until render queue is full, boolean
// delaySeek, delay playback start after seeking, too, boolean
@@ -433,13 +502,13 @@ interface IMadVRSettings : public IUnknown
// flushAfterLastStep, after last step, string, don''t flush|flush|flush & wait (sleep)|flush & wait (loop)
// flushAfterBackbuffer, after backbuffer, string, don''t flush|flush|flush & wait (sleep)|flush & wait (loop)
// flushAfterPresent, after present, string, don''t flush|flush|flush & wait (sleep)|flush & wait (loop)
+// oldWindowedPath, use old windowed rendering path, boolean
+// preRenderFramesWindowed, no of pre-presented frames, integer, 1..16
// exclusiveSettings, exclusive mode settings
// enableSeekbar, show seek bar, boolean
// exclusiveDelay, delay switch to exclusive mode by 3 seconds, boolean
-// oldExclusivePath, use old rendering path, boolean
+// oldExclusivePath, use old fse rendering path, boolean
// presentThread, run presentation in a separate thread, boolean
-// avoidGlitches, limit rendering times to avoid glitches, boolean
-// overshootMaxLatency, overshoot max frame latency (Vista and newer), boolean
// preRenderFrames, no of pre-presented frames, integer, 1..16
// backbufferCountExcl, no of backbuffers, integer, 1..8
// flushAfterRenderStepsExcl, after render steps, string, don''t flush|flush|flush & wait (sleep)|flush & wait (loop)
@@ -449,18 +518,27 @@ interface IMadVRSettings : public IUnknown
// smoothMotion, smooth motion
// smoothMotionEnabled, enable smooth motion frame rate conversion, boolean
// smoothMotionMode, smooth motion mode, string, avoidJudder|almostAlways|always
+// dithering, dithering
+// ditheringAlgo, dithering algorithm, string, random|ordered|errorDifLowNoise|errorDifMedNoise
+// dontDither, don't use dithering, boolean
+// coloredDither, use colored noise, boolean
+// dynamicDither, change dither for every frame, boolean
// tradeQuality, trade quality for performance
+// fastSubtitles, optimize subtitles for performance instead of quality, boolean
+// dxvaChromaWhenDecode, use DXVA chroma upscaling when doing native DXVA decoding boolean
+// dxvaChromaWhenDeint, use DXVA chroma upscaling when doing DXVA deinterlacing boolean
+// mayLoseBtb, lose BTB and WTW if it improves performance boolean
+// customShaders16f, store custom pixel shader results in 16bit buffer instead of 32bit, boolean
+// gammaDithering, don't use linear light for dithering, boolean
+// noGradientAngles, don't analyze gradient angles for debanding, boolean
+// dontRerenderFades, don't rerender frames when fade in/out is detected, boolean
// gammaBlending, don't use linear light for smooth motion frame blending, boolean
-// dontDither, don't use dithering, boolean
-// halfDxvaDeintFramerate, use half frame rate for DXVA deinterlacing, boolean
// 10bitChroma, use 10bit chroma buffer instead of 16bit, boolean
// 10bitLuma, use 10bit image buffer instead of 16bit, boolean
-// customShaders16f, store custom pixel shader results in 16bit buffer instead of 32bit, boolean
// customShadersTv, run custom pixel shaders in video levels instead of PC levels, boolean
-// noDeintCopyback, don't use "copyback" for DXVA deinterlacing, boolean
-// noDecodeCopyback, don't use "copyback" for DXVA decoding, boolean
// 3dlutLowerBitdepth, use lower bitdepth for yCMS 3dlut calibration, boolean
// 3dlutBitdepth, 3dlut bitdepth, integer, 6..7
+// halfDxvaDeintFramerate, use half frame rate for DXVA deinterlacing, boolean
// ui, user interface
// keys, keyboard shortcuts
// keysOnlyIfFocused, use only if media player has keyboard focus, boolean
@@ -495,6 +573,8 @@ interface IMadVRSettings : public IUnknown
// keyDeintContentTypeFilm, deinterlacing content type - set to "film", string
// keyDeintContentTypeVideo, deinterlacing content type - set to "video", string
// keyDeintContentTypeAuto, deinterlacing content type - set to "auto detect", string
+// keyDeband, debanding - toggle, string
+// keyDebandCustom, debanding custom settings - toggle, string
// keyDesiredGammaCurve, desired display gamma curve - toggle, string
// keyDesiredGammaValueInc, desired display gamma value - increase, string
// keyDesiredGammaValueDec, desired display gamma value - decrease, string
@@ -548,6 +628,17 @@ interface IMadVRSettings : public IUnknown
// keyDisplayModeChanger, display mode switcher - toggle on/off, string
// keyDisplayBitdepth, display bitdepth - toggle, string
// keyDithering, dithering - toggle on/off, string
+// key3dlutSplitScreen, 3dlut split screen - toggle on, string
+
+// profile settings: id, name, type, valid values
+// ----------------------------------------------
+// Profile Group 1
+// keyToggleProfiles, keyboard shortcut to toggle profiles, string
+// autoselectRules, profile auto select rules, string
+// Profile 1
+// keyActivateProfile, keyboard shortcut to activate this profile, string
+// activateCmdline, command line to execute when this profile is activated, string
+// deactivateCmdline, command line to execute when this profile is deactivated, string
// ---------------------------------------------------------------------------
// ISubRender
@@ -557,27 +648,29 @@ interface IMadVRSettings : public IUnknown
// engine in MPC-HC and PotPlayer for communication with madVR and with the
// Haali Video Renderer
-// interface ISubRenderCallback; // forward
+/*
+interface ISubRenderCallback; // forward
// interface exported by madVR
-// [uuid("9CC7F9F7-3ED1-493c-AF65-527EA1D9947F")]
-// interface ISubRender : public IUnknown
-// {
-// STDMETHOD(SetCallback)(ISubRenderCallback *callback) = 0;
-// };
+[uuid("9CC7F9F7-3ED1-493c-AF65-527EA1D9947F")]
+interface ISubRender : public IUnknown
+{
+ STDMETHOD(SetCallback)(ISubRenderCallback *callback) = 0;
+};
// callback interfaces can provide madVR with
-// [uuid("CD6D2AA5-20D3-4ebe-A8A9-34D3B00CC253")]
-// interface ISubRenderCallback : public IUnknown
-// {
-// STDMETHOD(SetDevice)(IDirect3DDevice9 *device) = 0;
-// STDMETHOD(Render)(REFERENCE_TIME frameStart, int left, int top, int right, int bottom, int width, int height) = 0;
-// };
-// [uuid("E602585E-C05A-4828-AC69-AF92997F2E0C")]
-// interface ISubRenderCallback2 : public ISubRenderCallback
-// {
-// STDMETHOD(RenderEx)(REFERENCE_TIME frameStart, REFERENCE_TIME frameStop, REFERENCE_TIME avgTimePerFrame, int left, int top, int right, int bottom, int width, int height) = 0;
-// };
+[uuid("CD6D2AA5-20D3-4ebe-A8A9-34D3B00CC253")]
+interface ISubRenderCallback : public IUnknown
+{
+ STDMETHOD(SetDevice)(IDirect3DDevice9 *device) = 0;
+ STDMETHOD(Render)(REFERENCE_TIME frameStart, int left, int top, int right, int bottom, int width, int height) = 0;
+};
+[uuid("E602585E-C05A-4828-AC69-AF92997F2E0C")]
+interface ISubRenderCallback2 : public ISubRenderCallback
+{
+ STDMETHOD(RenderEx)(REFERENCE_TIME frameStart, REFERENCE_TIME frameStop, REFERENCE_TIME avgTimePerFrame, int left, int top, int right, int bottom, int width, int height) = 0;
+};
+*/
// ---------------------------------------------------------------------------
// IMadVRExclusiveModeInfo (obsolete)
diff --git a/include/version.h b/include/version.h
index 4c8f655661e..ec42aaced32 100644
--- a/include/version.h
+++ b/include/version.h
@@ -53,7 +53,7 @@
#define MPC_VERSION_MAJOR 1
#define MPC_VERSION_MINOR 7
-#define MPC_VERSION_PATCH 8
+#define MPC_VERSION_PATCH 9
#ifndef NO_VERSION_REV_NEEDED
diff --git a/mpc-hc.sln b/mpc-hc.sln
index 357e0f53f31..45e159ed8ac 100644
--- a/mpc-hc.sln
+++ b/mpc-hc.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
-VisualStudioVersion = 12.0.30723.0
+VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{A21F07E6-A891-479C-98EA-EDB58CE4EFAB}"
EndProject
@@ -25,6 +25,9 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Transform", "Transform", "{F9F42BF2-3F13-4654-82C5-E27B8879EC4E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpc-hc", "src\mpc-hc\mpc-hc.vcxproj", "{8CE7E5D0-C821-47AC-A247-28EC95B34670}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6} = {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeCSS", "src\DeCSS\DeCSS.vcxproj", "{1A2DFD1A-3C6C-44D1-909D-294AF646B575}"
EndProject
@@ -116,6 +119,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mhook", "src\thirdparty\mho
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathLibFix", "src\MathLibFix\MathLibFix.vcxproj", "{FC9FC17F-70BF-4ACA-8285-C24D1889BACB}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DoctorDump", "src\thirdparty\DoctorDump\DoctorDump.vcxproj", "{BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Filter|Win32 = Debug Filter|Win32
@@ -1118,6 +1123,22 @@ Global
{FC9FC17F-70BF-4ACA-8285-C24D1889BACB}.Release|Win32.Build.0 = Release|Win32
{FC9FC17F-70BF-4ACA-8285-C24D1889BACB}.Release|x64.ActiveCfg = Release|x64
{FC9FC17F-70BF-4ACA-8285-C24D1889BACB}.Release|x64.Build.0 = Release|x64
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Debug Filter|Win32.ActiveCfg = Release|Win32
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Debug Filter|x64.ActiveCfg = Release|x64
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Debug Lite|Win32.ActiveCfg = Release Lite|Win32
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Debug Lite|x64.ActiveCfg = Release Lite|x64
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Debug|Win32.ActiveCfg = Release|Win32
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Debug|x64.ActiveCfg = Release|x64
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release Filter|Win32.ActiveCfg = Release|Win32
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release Filter|x64.ActiveCfg = Release|x64
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release Lite|Win32.ActiveCfg = Release Lite|Win32
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release Lite|Win32.Build.0 = Release Lite|Win32
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release Lite|x64.ActiveCfg = Release Lite|x64
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release Lite|x64.Build.0 = Release Lite|x64
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release|Win32.ActiveCfg = Release|Win32
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release|Win32.Build.0 = Release|Win32
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release|x64.ActiveCfg = Release|x64
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1177,5 +1198,6 @@ Global
{ED257874-E12E-4143-AF0A-0676DA3BB18C} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{F841363C-A630-4716-8941-CDDC1F32CFC3} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{FC9FC17F-70BF-4ACA-8285-C24D1889BACB} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
+ {BECEAFF9-CDCA-45EC-A1CF-658FA51818E6} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
EndGlobalSection
EndGlobal
diff --git a/mpcresources.sln b/mpcresources.sln
index 8f43566846e..f8782487f8f 100644
--- a/mpcresources.sln
+++ b/mpcresources.sln
@@ -26,6 +26,8 @@ Global
Release Croatian|x64 = Release Croatian|x64
Release Czech|Win32 = Release Czech|Win32
Release Czech|x64 = Release Czech|x64
+ Release Danish|Win32 = Release Danish|Win32
+ Release Danish|x64 = Release Danish|x64
Release Dutch|Win32 = Release Dutch|Win32
Release Dutch|x64 = Release Dutch|x64
Release English (British)|Win32 = Release English (British)|Win32
@@ -122,6 +124,10 @@ Global
{A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Czech|Win32.Build.0 = Release Czech|Win32
{A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Czech|x64.ActiveCfg = Release Czech|x64
{A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Czech|x64.Build.0 = Release Czech|x64
+ {A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Danish|Win32.ActiveCfg = Release Danish|Win32
+ {A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Danish|Win32.Build.0 = Release Danish|Win32
+ {A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Danish|x64.ActiveCfg = Release Danish|x64
+ {A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Danish|x64.Build.0 = Release Danish|x64
{A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Dutch|Win32.ActiveCfg = Release Dutch|Win32
{A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Dutch|Win32.Build.0 = Release Dutch|Win32
{A57CBE1A-3703-4237-950A-FC5F594FDB43}.Release Dutch|x64.ActiveCfg = Release Dutch|x64
diff --git a/src/DSUtil/ArrayUtils.h b/src/DSUtil/ArrayUtils.h
new file mode 100644
index 00000000000..1187bc93081
--- /dev/null
+++ b/src/DSUtil/ArrayUtils.h
@@ -0,0 +1,27 @@
+/*
+* (C) 2015 see Authors.txt
+*
+* This file is part of MPC-HC.
+*
+* MPC-HC is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* MPC-HC is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+*/
+
+#pragma once
+
+template
+inline std::array::type, sizeof...(T)> make_array(T... values)
+{
+ return { values... };
+}
diff --git a/src/DSUtil/DSUtil.cpp b/src/DSUtil/DSUtil.cpp
index 406f5f63c91..c9227635432 100644
--- a/src/DSUtil/DSUtil.cpp
+++ b/src/DSUtil/DSUtil.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -346,7 +346,7 @@ IPin* AppendFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
}
CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, nullptr))) {
+ if (FAILED(pPB->Read(_T("FriendlyName"), &var, nullptr))) {
break;
}
@@ -440,7 +440,7 @@ IPin* InsertFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
}
CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, nullptr))) {
+ if (FAILED(pPB->Read(_T("FriendlyName"), &var, nullptr))) {
break;
}
@@ -629,10 +629,9 @@ bool IsCLSIDRegistered(const CLSID& clsid)
{
bool fRet = false;
- LPOLESTR pStr = nullptr;
+ CComHeapPtr pStr;
if (S_OK == StringFromCLSID(clsid, &pStr) && pStr) {
fRet = IsCLSIDRegistered(CString(pStr));
- CoTaskMemFree(pStr);
}
return fRet;
@@ -660,10 +659,9 @@ CString GetFilterPath(const CLSID& clsid)
{
CString path;
- LPOLESTR pStr = nullptr;
+ CComHeapPtr pStr;
if (S_OK == StringFromCLSID(clsid, &pStr) && pStr) {
path = GetFilterPath(CString(pStr));
- CoTaskMemFree(pStr);
}
return path;
@@ -1117,7 +1115,7 @@ bool CreateFilter(CStringW DisplayName, IBaseFilter** ppBF, CStringW& FriendlyNa
CComPtr pPB;
CComVariant var;
if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_PPV_ARGS(&pPB)))
- && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, nullptr))) {
+ && SUCCEEDED(pPB->Read(_T("FriendlyName"), &var, nullptr))) {
FriendlyName = var.bstrVal;
}
@@ -1146,7 +1144,7 @@ IBaseFilter* AppendFilter(IPin* pPin, IMoniker* pMoniker, IGraphBuilder* pGB)
}
CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, nullptr))) {
+ if (FAILED(pPB->Read(_T("FriendlyName"), &var, nullptr))) {
break;
}
@@ -1190,7 +1188,7 @@ CStringW GetFriendlyName(CStringW displayName)
CComPtr pPB;
CComVariant var;
if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_PPV_ARGS(&pPB)))
- && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, nullptr))) {
+ && SUCCEEDED(pPB->Read(_T("FriendlyName"), &var, nullptr))) {
friendlyName = var.bstrVal;
}
}
@@ -2424,87 +2422,6 @@ REFERENCE_TIME StringToReftime(LPCTSTR strVal)
return rt;
}
-const double Rec601_Kr = 0.299;
-const double Rec601_Kb = 0.114;
-const double Rec601_Kg = 0.587;
-
-COLORREF YCrCbToRGB_Rec601(BYTE Y, BYTE Cr, BYTE Cb, double sourceBlackLevel, double sourceWhiteLevel, double targetBlackLevel, double targetWhiteLevel)
-{
- double targetRange = targetWhiteLevel - targetBlackLevel;
- double chromaChannelRange = (sourceWhiteLevel == 235.0 ? 224.0 /* 4:2:0 */ : sourceBlackLevel == 0.0 ? 255.0 /* 4:4:4 */ : 239.0 /* 4:2:2 */) / 2.0;
- double chromaScaleFactor = targetRange / chromaChannelRange;
- double scaledY = (Y - (sourceBlackLevel - targetBlackLevel)) * (targetRange / (sourceWhiteLevel - sourceBlackLevel));
-
- double rp = scaledY + chromaScaleFactor * (Cr - 128) * (1.0 - Rec601_Kr);
- double gp = scaledY - chromaScaleFactor * (Cb - 128) * (1.0 - Rec601_Kb) * Rec601_Kb / Rec601_Kg - chromaScaleFactor * (Cr - 128) * (1.0 - Rec601_Kr) * Rec601_Kr / Rec601_Kg;
- double bp = scaledY + chromaScaleFactor * (Cb - 128) * (1.0 - Rec601_Kb);
-
- auto R = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(rp)), targetWhiteLevel));
- auto G = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(gp)), targetWhiteLevel));
- auto B = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(bp)), targetWhiteLevel));
-
- return RGB(R, G, B);
-}
-
-DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb, double sourceBlackLevel, double sourceWhiteLevel, double targetBlackLevel, double targetWhiteLevel)
-{
- double targetRange = targetWhiteLevel - targetBlackLevel;
- double chromaChannelRange = (sourceWhiteLevel == 235.0 ? 224.0 /* 4:2:0 */ : sourceBlackLevel == 0.0 ? 255.0 /* 4:4:4 */ : 239.0 /* 4:2:2 */) / 2.0;
- double chromaScaleFactor = targetRange / chromaChannelRange;
- double scaledY = (Y - (sourceBlackLevel - targetBlackLevel)) * (targetRange / (sourceWhiteLevel - sourceBlackLevel));
-
- double rp = scaledY + chromaScaleFactor * (Cr - 128) * (1.0 - Rec601_Kr);
- double gp = scaledY - chromaScaleFactor * (Cb - 128) * (1.0 - Rec601_Kb) * Rec601_Kb / Rec601_Kg - chromaScaleFactor * (Cr - 128) * (1.0 - Rec601_Kr) * Rec601_Kr / Rec601_Kg;
- double bp = scaledY + chromaScaleFactor * (Cb - 128) * (1.0 - Rec601_Kb);
-
- auto R = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(rp)), targetWhiteLevel));
- auto G = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(gp)), targetWhiteLevel));
- auto B = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(bp)), targetWhiteLevel));
-
- return D3DCOLOR_ARGB(A, R, G, B);
-}
-
-
-const double Rec709_Kr = 0.2126;
-const double Rec709_Kb = 0.0722;
-const double Rec709_Kg = 0.7152;
-
-COLORREF YCrCbToRGB_Rec709(BYTE Y, BYTE Cr, BYTE Cb, double sourceBlackLevel, double sourceWhiteLevel, double targetBlackLevel, double targetWhiteLevel)
-{
- double targetRange = targetWhiteLevel - targetBlackLevel;
- double chromaChannelRange = (sourceWhiteLevel == 235.0 ? 224.0 /* 4:2:0 */ : sourceBlackLevel == 0.0 ? 255.0 /* 4:4:4 */ : 239.0 /* 4:2:2 */) / 2.0;
- double chromaScaleFactor = targetRange / chromaChannelRange;
- double scaledY = (Y - (sourceBlackLevel - targetBlackLevel)) * (targetRange / (sourceWhiteLevel - sourceBlackLevel));
-
- double rp = scaledY + chromaScaleFactor * (Cr - 128) * (1.0 - Rec709_Kr);
- double gp = scaledY - chromaScaleFactor * (Cb - 128) * (1.0 - Rec709_Kb) * Rec709_Kb / Rec709_Kg - chromaScaleFactor * (Cr - 128) * (1.0 - Rec709_Kr) * Rec709_Kr / Rec709_Kg;
- double bp = scaledY + chromaScaleFactor * (Cb - 128) * (1.0 - Rec709_Kb);
-
- auto R = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(rp)), targetWhiteLevel));
- auto G = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(gp)), targetWhiteLevel));
- auto B = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(bp)), targetWhiteLevel));
-
- return RGB(R, G, B);
-}
-
-DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb, double sourceBlackLevel, double sourceWhiteLevel, double targetBlackLevel, double targetWhiteLevel)
-{
- double targetRange = targetWhiteLevel - targetBlackLevel;
- double chromaChannelRange = (sourceWhiteLevel == 235.0 ? 224.0 /* 4:2:0 */ : sourceBlackLevel == 0.0 ? 255.0 /* 4:4:4 */ : 239.0 /* 4:2:2 */) / 2.0;
- double chromaScaleFactor = targetRange / chromaChannelRange;
- double scaledY = (Y - (sourceBlackLevel - targetBlackLevel)) * (targetRange / (sourceWhiteLevel - sourceBlackLevel));
-
- double rp = scaledY + chromaScaleFactor * (Cr - 128) * (1.0 - Rec709_Kr);
- double gp = scaledY - chromaScaleFactor * (Cb - 128) * (1.0 - Rec709_Kb) * Rec709_Kb / Rec709_Kg - chromaScaleFactor * (Cr - 128) * (1.0 - Rec709_Kr) * Rec709_Kr / Rec709_Kg;
- double bp = scaledY + chromaScaleFactor * (Cb - 128) * (1.0 - Rec709_Kb);
-
- auto R = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(rp)), targetWhiteLevel));
- auto G = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(gp)), targetWhiteLevel));
- auto B = (BYTE)std::max(targetBlackLevel, std::min(std::abs(std::round(bp)), targetWhiteLevel));
-
- return D3DCOLOR_ARGB(A, R, G, B);
-}
-
const wchar_t* StreamTypeToName(PES_STREAM_TYPE _Type)
{
switch (_Type) {
@@ -2518,6 +2435,8 @@ const wchar_t* StreamTypeToName(PES_STREAM_TYPE _Type)
return L"MPEG-2";
case VIDEO_STREAM_H264:
return L"H264";
+ case VIDEO_STREAM_HEVC:
+ return L"HEVC";
case AUDIO_STREAM_LPCM:
return L"LPCM";
case AUDIO_STREAM_AC3:
diff --git a/src/DSUtil/DSUtil.h b/src/DSUtil/DSUtil.h
index f70859fe41f..64a78a856bb 100644
--- a/src/DSUtil/DSUtil.h
+++ b/src/DSUtil/DSUtil.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -125,10 +125,6 @@ extern CString ReftimeToString(const REFERENCE_TIME& rtVal);
extern CString ReftimeToString2(const REFERENCE_TIME& rtVal);
extern CString DVDtimeToString(const DVD_HMSF_TIMECODE& rtVal, bool bAlwaysShowHours = false);
extern REFERENCE_TIME StringToReftime(LPCTSTR strVal);
-extern COLORREF YCrCbToRGB_Rec601(BYTE Y, BYTE Cr, BYTE Cb, double sourceBlackLevel, double sourceWhiteLevel, double targetBlackLevel, double targetWhiteLevel);
-extern COLORREF YCrCbToRGB_Rec709(BYTE Y, BYTE Cr, BYTE Cb, double sourceBlackLevel, double sourceWhiteLevel, double targetBlackLevel, double targetWhiteLevel);
-extern DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb, double sourceBlackLevel, double sourceWhiteLevel, double targetBlackLevel, double targetWhiteLevel);
-extern DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb, double sourceBlackLevel, double sourceWhiteLevel, double targetBlackLevel, double targetWhiteLevel);
extern void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName);
extern void CorrectComboListWidth(CComboBox& m_pComboBox);
extern void CorrectComboBoxHeaderWidth(CWnd* pComboBox);
@@ -291,7 +287,7 @@ typename std::enable_if::value, T>::type GCD(T a, T b)
template
typename std::enable_if::value, T>::type GCD(T a, T b)
{
- typedef std::make_unsigned::type uT;
+ using uT = typename std::make_unsigned::type;
return T(GCD(uT(std::abs(a)), uT(std::abs(b))));
}
diff --git a/src/DSUtil/DSUtil.vcxproj b/src/DSUtil/DSUtil.vcxproj
index 9d22e901d7a..c145ebfd318 100644
--- a/src/DSUtil/DSUtil.vcxproj
+++ b/src/DSUtil/DSUtil.vcxproj
@@ -132,6 +132,7 @@
+
diff --git a/src/DSUtil/DSUtil.vcxproj.filters b/src/DSUtil/DSUtil.vcxproj.filters
index 5079d7b6ffc..56b6610c18d 100644
--- a/src/DSUtil/DSUtil.vcxproj.filters
+++ b/src/DSUtil/DSUtil.vcxproj.filters
@@ -133,5 +133,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/src/DSUtil/MediaTypeEx.cpp b/src/DSUtil/MediaTypeEx.cpp
index d9cde419db6..6fa348df752 100644
--- a/src/DSUtil/MediaTypeEx.cpp
+++ b/src/DSUtil/MediaTypeEx.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -262,7 +262,7 @@ CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression
for (ptrdiff_t i = 0; i < 4; i++) {
if (b[i] >= 'a' && b[i] <= 'z') {
- b[i] = toupper(b[i]);
+ b[i] = (BYTE)toupper(b[i]);
}
}
diff --git a/src/DSUtil/Mpeg2Def.h b/src/DSUtil/Mpeg2Def.h
index edd0fd1e84c..ca6baf39fef 100644
--- a/src/DSUtil/Mpeg2Def.h
+++ b/src/DSUtil/Mpeg2Def.h
@@ -1,5 +1,5 @@
/*
- * (C) 2009-2014 see Authors.txt
+ * (C) 2009-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -54,6 +54,12 @@ enum PES_STREAM_TYPE {
AUXILIARY_VIDEO_STREAM = 0x1E, // Auxiliary video stream as defined in ISO/IEC 23002-3
SVC_H264 = 0x1F, // SVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex G of ITU-T Rec. H.264 | ISO/IEC 14496-10
MVC_H264 = 0x20, // MVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex H of ITU-T Rec. H.264 | ISO/IEC 14496-10
+ VIDEO_STREAM_JPEG2000 = 0x21, // ITU - T Rec.T.800 | ISO / IEC 15444 - 1
+ ADDITIONAL_VIEW_MPEG2 = 0x22, // ITU - T Rec.H.262 | ISO / IEC 13818 - 2 Additional view for compatible 3D
+ ADDITIONAL_VIEW_H264 = 0x23, // ITU - T Rec.H.264 | ISO / IEC 14496 - 10 Additional view for compatible 3D
+ VIDEO_STREAM_HEVC = 0x24, // ITU - T Rec.H.265 | ISO / IEC 23008 - 2 video stream
+ VIDEO_SUBSET_HEVC = 0x25, // ITU - T Rec.H.265 | ISO / IEC 23008 - 2 Annex A temporal video subset
+ MVCD_H264 = 0x26, // ITU - T Rec.H.264 | ISO / IEC 14496 - 10 Annex I MVCD video sub - bitstream
AUDIO_STREAM_LPCM = 0x80,
AUDIO_STREAM_AC3 = 0x81,
AUDIO_STREAM_DTS = 0x82,
@@ -166,7 +172,8 @@ enum SERVICE_TYPE {
AVC_DIGITAL_RADIO = 0x0A,
MPEG2_HD_DIGITAL_TV = 0x11,
AVC_SD_TV = 0x16,
- AVC_HD_TV = 0x19
+ AVC_HD_TV = 0x19,
+ HEVC_TV = 0x1F
};
extern const wchar_t* StreamTypeToName(PES_STREAM_TYPE _Type);
diff --git a/src/DSUtil/PathUtils.cpp b/src/DSUtil/PathUtils.cpp
index e382083f06f..b46341a87d5 100644
--- a/src/DSUtil/PathUtils.cpp
+++ b/src/DSUtil/PathUtils.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2013-2014 see Authors.txt
+ * (C) 2013-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -179,6 +179,11 @@ namespace PathUtils
return (attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY);
}
+ bool IsLinkFile(LPCTSTR path)
+ {
+ return !FileExt(path).CompareNoCase(_T(".lnk"));
+ }
+
bool CreateDirRecursive(LPCTSTR path)
{
bool ret = IsDir(path) || CreateDirectory(path, nullptr);
@@ -187,4 +192,60 @@ namespace PathUtils
}
return ret;
}
+
+ CString ResolveLinkFile(LPCTSTR path)
+ {
+ TCHAR buff[MAX_PATH];
+ CComPtr pSL;
+ pSL.CoCreateInstance(CLSID_ShellLink);
+ CComQIPtr pPF = pSL;
+
+ if (pSL && pPF
+ && SUCCEEDED(pPF->Load(path, STGM_READ))
+ && SUCCEEDED(pSL->Resolve(nullptr, SLR_ANY_MATCH | SLR_NO_UI))
+ && SUCCEEDED(pSL->GetPath(buff, _countof(buff), nullptr, 0))) {
+ return buff;
+ }
+
+ return _T("");
+ }
+
+ void RecurseAddDir(LPCTSTR path, CAtlList& paths)
+ {
+ CFileFind finder;
+
+ BOOL bFound = finder.FindFile(PathUtils::CombinePaths(path, _T("*.*")));
+ while (bFound) {
+ bFound = finder.FindNextFile();
+
+ if (!finder.IsDots() && finder.IsDirectory()) {
+ CString folderPath = finder.GetFilePath();
+ paths.AddTail(folderPath);
+ RecurseAddDir(folderPath, paths);
+ }
+ }
+ }
+
+ void ParseDirs(CAtlList& paths)
+ {
+ POSITION pos = paths.GetHeadPosition();
+ while (pos) {
+ POSITION prevPos = pos;
+ CString fn = paths.GetNext(pos);
+ // Try to follow link files that point to a directory
+ if (IsLinkFile(fn)) {
+ fn = ResolveLinkFile(fn);
+ }
+
+ if (IsDir(fn)) {
+ CAtlList subDirs;
+ RecurseAddDir(fn, subDirs);
+ // Add the subdirectories just after their parent
+ // so that the tree is not parsed multiple times
+ while (!subDirs.IsEmpty()) {
+ paths.InsertAfter(prevPos, subDirs.RemoveTail());
+ }
+ }
+ }
+ }
}
diff --git a/src/DSUtil/PathUtils.h b/src/DSUtil/PathUtils.h
index bec04b99fa1..f90826fc7f5 100644
--- a/src/DSUtil/PathUtils.h
+++ b/src/DSUtil/PathUtils.h
@@ -1,5 +1,5 @@
/*
- * (C) 2013-2014 see Authors.txt
+ * (C) 2013-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -39,5 +39,9 @@ namespace PathUtils
bool Exists(LPCTSTR path);
bool IsFile(LPCTSTR path);
bool IsDir(LPCTSTR path);
+ bool IsLinkFile(LPCTSTR path);
bool CreateDirRecursive(LPCTSTR path);
+ CString ResolveLinkFile(LPCTSTR path);
+ void RecurseAddDir(LPCTSTR path, CAtlList& sl);
+ void ParseDirs(CAtlList& pathsList);
}
diff --git a/src/DSUtil/deinterlace.cpp b/src/DSUtil/deinterlace.cpp
index 0ec3850511b..7ef0dce756c 100644
--- a/src/DSUtil/deinterlace.cpp
+++ b/src/DSUtil/deinterlace.cpp
@@ -1346,7 +1346,7 @@ namespace {
}
topbuf[wr+16] = topbuf[wr+17] = topbuf[wr+18] = topbuf[wr+15];
- topbuf[wr+16] = topbuf[wr+17] = botbuf[wr+18] = botbuf[wr+15];
+ botbuf[wr+16] = botbuf[wr+17] = botbuf[wr+18] = botbuf[wr+15];
ela_L8_scalar(elabuf, topbuf, botbuf, w16);
nela_L8_scalar((uint8 *)dst, elabuf, w16);
diff --git a/src/DSUtil/text.h b/src/DSUtil/text.h
index 08657095d4c..22863a6ddae 100644
--- a/src/DSUtil/text.h
+++ b/src/DSUtil/text.h
@@ -179,3 +179,10 @@ int FindOneOf(const T& str, typename T::PCXSTR pszCharSet, int iStart) throw()
T::PCXSTR psz = T::StrTraits::StringScanSet(str.GetString() + iStart, pszCharSet);
return ((psz == NULL) ? -1 : int(psz - str.GetString()));
}
+
+template
+CString NumToCString(T num)
+{
+ static_assert(std::numeric_limits::is_specialized, "NumToCString can be used only for numeric types.");
+ return std::to_string(num).c_str();
+}
diff --git a/src/DSUtil/vd.cpp b/src/DSUtil/vd.cpp
index 18647dfb05f..ac15cf11dbd 100644
--- a/src/DSUtil/vd.cpp
+++ b/src/DSUtil/vd.cpp
@@ -262,6 +262,62 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s
return VDPixmapBlt(dstpxm, srcbm);
}
+bool BitBltFromRGBToRGBStretch(int dstw, int dsth, BYTE* dst, int dstpitch, int dbpp, int srcw, int srch, BYTE* src, int srcpitch, int sbpp)
+{
+ VDPixmap srcbm = {
+ src + srcpitch * (srch - 1),
+ nullptr,
+ srcw,
+ srch,
+ -srcpitch
+ };
+
+ switch (sbpp) {
+ case 8:
+ srcbm.format = nsVDPixmap::kPixFormat_Pal8;
+ break;
+ case 16:
+ srcbm.format = nsVDPixmap::kPixFormat_RGB565;
+ break;
+ case 24:
+ srcbm.format = nsVDPixmap::kPixFormat_RGB888;
+ break;
+ case 32:
+ srcbm.format = nsVDPixmap::kPixFormat_XRGB8888;
+ break;
+ default:
+ VDASSERT(false);
+ }
+
+ VDPixmap dstpxm = {
+ dst + dstpitch * (dsth - 1),
+ nullptr,
+ dstw,
+ dsth,
+ -dstpitch
+ };
+
+ switch (dbpp) {
+ case 8:
+ dstpxm.format = nsVDPixmap::kPixFormat_Pal8;
+ break;
+ case 16:
+ dstpxm.format = nsVDPixmap::kPixFormat_RGB565;
+ break;
+ case 24:
+ dstpxm.format = nsVDPixmap::kPixFormat_RGB888;
+ break;
+ case 32:
+ dstpxm.format = nsVDPixmap::kPixFormat_XRGB8888;
+ break;
+ default:
+ VDASSERT(false);
+ }
+
+ return VDPixmapStretchBltBilinear(dstpxm, srcbm);
+}
+
+
bool BitBltFromYUY2ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* src, int srcpitch)
{
if (srcpitch == 0) srcpitch = w;
diff --git a/src/DSUtil/vd.h b/src/DSUtil/vd.h
index f0407dcc111..9ba810b0b5f 100644
--- a/src/DSUtil/vd.h
+++ b/src/DSUtil/vd.h
@@ -37,6 +37,7 @@ extern bool BitBltFromI420ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp,
extern bool BitBltFromYUY2ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* src, int srcpitch);
extern bool BitBltFromYUY2ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* src, int srcpitch);
extern bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* src, int srcpitch, int sbpp);
+extern bool BitBltFromRGBToRGBStretch(int dstw, int dsth, BYTE* dst, int dstpitch, int dbpp, int srcw, int srch, BYTE* src, int srcpitch, int sbpp);
extern void DeinterlaceBlend(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD dstpitch, DWORD srcpitch);
extern void DeinterlaceBob(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD dstpitch, DWORD srcpitch, bool topfield);
diff --git a/src/DeCSS/DeCSSInputPin.cpp b/src/DeCSS/DeCSSInputPin.cpp
index c76ef19a120..41f78df1647 100644
--- a/src/DeCSS/DeCSSInputPin.cpp
+++ b/src/DeCSS/DeCSSInputPin.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
+ * (C) 2006-2013, 2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -289,7 +289,7 @@ STDMETHODIMP CDeCSSInputPin::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData
switch (Id) {
case AM_PROPERTY_DVDCOPY_CHLG_KEY: { // 1. auth: send our nonce word
AM_DVDCOPY_CHLGKEY* pChlgKey = (AM_DVDCOPY_CHLGKEY*)pPropertyData;
- for (int i = 0; i < 10; i++) {
+ for (BYTE i = 0; i < 10; i++) {
pChlgKey->ChlgKey[i] = 9 - (m_Challenge[i] = i);
}
*pBytesReturned = sizeof(AM_DVDCOPY_CHLGKEY);
diff --git a/src/DeCSS/VobFile.cpp b/src/DeCSS/VobFile.cpp
index af8b8c64d0d..8a8ef473e1f 100644
--- a/src/DeCSS/VobFile.cpp
+++ b/src/DeCSS/VobFile.cpp
@@ -97,7 +97,7 @@ bool CDVDSession::Authenticate()
BYTE Challenge[10], Key[10];
- for (int i = 0; i < 10; i++) {
+ for (BYTE i = 0; i < 10; i++) {
Challenge[i] = i;
}
@@ -205,74 +205,94 @@ static void Reverse(BYTE* d, BYTE* s, int len)
bool CDVDSession::SendKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData)
{
- CAutoPtr key;
+ CAutoVectorPtr key;
+ DVD_COPY_PROTECT_KEY* pKey = nullptr;
+
+ auto allocateKey = [&](ULONG len) {
+ bool bSuccess = key.Allocate(len);
+ if (bSuccess) {
+ pKey = (DVD_COPY_PROTECT_KEY*)(BYTE*)key;
+ pKey->KeyLength = len;
+ }
+ return bSuccess;
+ };
switch (KeyType) {
case DvdChallengeKey:
- key.Attach((DVD_COPY_PROTECT_KEY*)DEBUG_NEW BYTE[DVD_CHALLENGE_KEY_LENGTH]);
- key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
- Reverse(key->KeyData, pKeyData, 10);
+ if (allocateKey(DVD_CHALLENGE_KEY_LENGTH)) {
+ Reverse(pKey->KeyData, pKeyData, 10);
+ }
break;
case DvdBusKey2:
- key.Attach((DVD_COPY_PROTECT_KEY*)DEBUG_NEW BYTE[DVD_BUS_KEY_LENGTH]);
- key->KeyLength = DVD_BUS_KEY_LENGTH;
- Reverse(key->KeyData, pKeyData, 5);
+ if (allocateKey(DVD_BUS_KEY_LENGTH)) {
+ Reverse(pKey->KeyData, pKeyData, 5);
+ }
break;
default:
break;
}
- if (!key) {
+ if (!pKey) {
return false;
}
- key->SessionId = m_session;
- key->KeyType = KeyType;
- key->KeyFlags = 0;
+ pKey->SessionId = m_session;
+ pKey->KeyType = KeyType;
+ pKey->KeyFlags = 0;
- DWORD BytesReturned;
- return !!DeviceIoControl(m_hDrive, IOCTL_DVD_SEND_KEY, key, key->KeyLength, nullptr, 0, &BytesReturned, nullptr);
+ DWORD dwBytesReturned;
+ return !!DeviceIoControl(m_hDrive, IOCTL_DVD_SEND_KEY, pKey, pKey->KeyLength, nullptr, 0, &dwBytesReturned, nullptr);
}
bool CDVDSession::ReadKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData, int lba)
{
- CAutoPtr key;
+ CAutoVectorPtr key;
+ DVD_COPY_PROTECT_KEY* pKey = nullptr;
+
+ auto allocateKey = [&](ULONG len) {
+ bool bSuccess = key.Allocate(len);
+ if (bSuccess) {
+ pKey = (DVD_COPY_PROTECT_KEY*)(BYTE*)key;
+ pKey->KeyLength = len;
+ }
+ return bSuccess;
+ };
switch (KeyType) {
case DvdChallengeKey:
- key.Attach((DVD_COPY_PROTECT_KEY*)DEBUG_NEW BYTE[DVD_CHALLENGE_KEY_LENGTH]);
- key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
- key->Parameters.TitleOffset.QuadPart = 0;
+ if (allocateKey(DVD_CHALLENGE_KEY_LENGTH)) {
+ pKey->Parameters.TitleOffset.QuadPart = 0;
+ }
break;
case DvdBusKey1:
- key.Attach((DVD_COPY_PROTECT_KEY*)DEBUG_NEW BYTE[DVD_BUS_KEY_LENGTH]);
- key->KeyLength = DVD_BUS_KEY_LENGTH;
- key->Parameters.TitleOffset.QuadPart = 0;
+ if (allocateKey(DVD_BUS_KEY_LENGTH)) {
+ pKey->Parameters.TitleOffset.QuadPart = 0;
+ }
break;
case DvdDiskKey:
- key.Attach((DVD_COPY_PROTECT_KEY*)DEBUG_NEW BYTE[DVD_DISK_KEY_LENGTH]);
- key->KeyLength = DVD_DISK_KEY_LENGTH;
- key->Parameters.TitleOffset.QuadPart = 0;
+ if (allocateKey(DVD_DISK_KEY_LENGTH)) {
+ pKey->Parameters.TitleOffset.QuadPart = 0;
+ }
break;
case DvdTitleKey:
- key.Attach((DVD_COPY_PROTECT_KEY*)DEBUG_NEW BYTE[DVD_TITLE_KEY_LENGTH]);
- key->KeyLength = DVD_TITLE_KEY_LENGTH;
- key->Parameters.TitleOffset.QuadPart = 2048i64 * lba;
+ if (allocateKey(DVD_TITLE_KEY_LENGTH)) {
+ pKey->Parameters.TitleOffset.QuadPart = 2048i64 * lba;
+ }
break;
default:
break;
}
- if (!key) {
+ if (!pKey) {
return false;
}
- key->SessionId = m_session;
- key->KeyType = KeyType;
- key->KeyFlags = 0;
+ pKey->SessionId = m_session;
+ pKey->KeyType = KeyType;
+ pKey->KeyFlags = 0;
- DWORD BytesReturned;
- if (!DeviceIoControl(m_hDrive, IOCTL_DVD_READ_KEY, key, key->KeyLength, key, key->KeyLength, &BytesReturned, nullptr)) {
+ DWORD dwBytesReturned;
+ if (!DeviceIoControl(m_hDrive, IOCTL_DVD_READ_KEY, pKey, pKey->KeyLength, pKey, pKey->KeyLength, &dwBytesReturned, nullptr)) {
DWORD err = GetLastError();
UNREFERENCED_PARAMETER(err);
return false;
@@ -280,19 +300,19 @@ bool CDVDSession::ReadKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData, int lba)
switch (KeyType) {
case DvdChallengeKey:
- Reverse(pKeyData, key->KeyData, 10);
+ Reverse(pKeyData, pKey->KeyData, 10);
break;
case DvdBusKey1:
- Reverse(pKeyData, key->KeyData, 5);
+ Reverse(pKeyData, pKey->KeyData, 5);
break;
case DvdDiskKey:
- memcpy(pKeyData, key->KeyData, 2048);
+ memcpy(pKeyData, pKey->KeyData, 2048);
for (int i = 0; i < 2048 / 5; i++) {
pKeyData[i] ^= m_SessionKey[4 - (i % 5)];
}
break;
case DvdTitleKey:
- memcpy(pKeyData, key->KeyData, 5);
+ memcpy(pKeyData, pKey->KeyData, 5);
for (int i = 0; i < 5; i++) {
pKeyData[i] ^= m_SessionKey[4 - (i % 5)];
}
@@ -533,7 +553,7 @@ bool CVobFile::Open(CString fn, CAtlList& vobs, ULONG nProgNum /*= 1*/,
int cellTableOffset = ReadShort();
REFERENCE_TIME rtDuration = 0;
m_pChapters[0] = 0;
- for (int currentProgram = 0; currentProgram < programChainPrograms; currentProgram++) {
+ for (BYTE currentProgram = 0; currentProgram < programChainPrograms; currentProgram++) {
m_ifoFile.Seek(pcgITPosition + chainOffset + programMapOffset + currentProgram, CFile::begin);
byte entryCell = ReadByte();
byte exitCell = entryCell;
@@ -834,6 +854,7 @@ BSTR CVobFile::GetTrackName(UINT aTrackIdx) const
REFERENCE_TIME CVobFile::GetChapterOffset(UINT ChapterNumber) const
{
REFERENCE_TIME rtChapterOffset = 0;
- m_pChapters.Lookup(ChapterNumber, rtChapterOffset);
+ ASSERT(ChapterNumber < BYTE_MAX);
+ m_pChapters.Lookup((BYTE)ChapterNumber, rtChapterOffset);
return rtChapterOffset;
}
diff --git a/src/DeCSS/udf.cpp b/src/DeCSS/udf.cpp
index fcf6c79978b..ac1e08786a5 100644
--- a/src/DeCSS/udf.cpp
+++ b/src/DeCSS/udf.cpp
@@ -126,7 +126,7 @@ tp_udf_file udf_get_root(const HANDLE hDrive, const WORD partition_number)
if (vol_valid) {
// extract vol->FileSetDescriptorSequence
FileDescriptorSequence_lba = vol->FileSetDescriptorSequence.Location.Location;
- DWORD FileDescriptorSequence_lba_end = FileDescriptorSequence_lba + ((vol->FileSetDescriptorSequence.Length & udf_LengthMask) - 1) / sec_size;
+ // DWORD FileDescriptorSequence_lba_end = FileDescriptorSequence_lba + ((vol->FileSetDescriptorSequence.Length & udf_LengthMask) - 1) / sec_size;
}
}
} else {
diff --git a/src/SubPic/ISubPic.h b/src/SubPic/ISubPic.h
index fa89052c77c..11766d37f65 100644
--- a/src/SubPic/ISubPic.h
+++ b/src/SubPic/ISubPic.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -219,6 +219,7 @@ public IPersist {
STDMETHOD_(int, GetStream)() PURE;
STDMETHOD(SetStream)(int iStream) PURE;
STDMETHOD(Reload)() PURE;
+ STDMETHOD(SetSourceTargetInfo)(CString yuvMatrix, int targetBlackLevel, int targetWhiteLevel) PURE;
// TODO: get rid of IPersist to identify type and use only
// interface functions to modify the settings of the substream
diff --git a/src/SubPic/MemSubPic.cpp b/src/SubPic/MemSubPic.cpp
index 1505f4cb063..defab054de1 100644
--- a/src/SubPic/MemSubPic.cpp
+++ b/src/SubPic/MemSubPic.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -62,7 +62,7 @@ void ColorConvInit()
for (int i = 0; i < 256; i++) {
clipBase[i] = 0;
- clipBase[i + 256] = i;
+ clipBase[i + 256] = BYTE(i);
clipBase[i + 512] = 255;
}
@@ -84,8 +84,9 @@ void ColorConvInit()
// CMemSubPic
//
-CMemSubPic::CMemSubPic(const SubPicDesc& spd)
- : m_spd(spd)
+CMemSubPic::CMemSubPic(const SubPicDesc& spd, CMemSubPicAllocator* pAllocator)
+ : m_pAllocator(pAllocator)
+ , m_spd(spd)
{
m_maxsize.SetSize(spd.w, spd.h);
m_rcDirty.SetRect(0, 0, spd.w, spd.h);
@@ -93,7 +94,10 @@ CMemSubPic::CMemSubPic(const SubPicDesc& spd)
CMemSubPic::~CMemSubPic()
{
- delete [] m_spd.bits;
+ m_pAllocator->FreeSpdBits(m_spd);
+ if (m_resizedSpd) {
+ m_pAllocator->FreeSpdBits(*m_resizedSpd);
+ }
}
// ISubPic
@@ -106,8 +110,8 @@ STDMETHODIMP_(void*) CMemSubPic::GetObject()
STDMETHODIMP CMemSubPic::GetDesc(SubPicDesc& spd)
{
spd.type = m_spd.type;
- spd.w = m_size.cx;
- spd.h = m_size.cy;
+ spd.w = m_spd.w;
+ spd.h = m_spd.h;
spd.bpp = m_spd.bpp;
spd.pitch = m_spd.pitch;
spd.bits = m_spd.bits;
@@ -130,6 +134,13 @@ STDMETHODIMP CMemSubPic::CopyTo(ISubPic* pSubPic)
return E_FAIL;
}
+ if (auto subPic = dynamic_cast(pSubPic)) {
+ ASSERT(subPic->m_pAllocator == m_pAllocator);
+ ASSERT(subPic->m_resizedSpd == nullptr);
+ // Move because we are not going to reuse it.
+ subPic->m_resizedSpd = std::move(m_resizedSpd);
+ }
+
int w = m_rcDirty.Width(), h = m_rcDirty.Height();
BYTE* s = src.bits + src.pitch * m_rcDirty.top + m_rcDirty.left * 4;
BYTE* d = dst.bits + dst.pitch * m_rcDirty.top + m_rcDirty.left * 4;
@@ -181,26 +192,61 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
return S_OK;
}
- if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV || m_spd.type == MSP_AYUV) {
+ CRect r = m_spd.vidrect;
+ CRect rcDirty = m_rcDirty;
+ if (m_spd.h != r.Height() || m_spd.w != r.Width()) {
+ if (!m_resizedSpd) {
+ m_resizedSpd = std::unique_ptr(DEBUG_NEW SubPicDesc);
+ }
+
+ m_resizedSpd->type = m_spd.type;
+ m_resizedSpd->w = r.Width();
+ m_resizedSpd->h = r.Height();
+ m_resizedSpd->pitch = r.Width() * 4;
+ m_resizedSpd->bpp = m_spd.bpp;
+
+ if (!m_resizedSpd->bits) {
+ m_pAllocator->AllocSpdBits(*m_resizedSpd);
+ }
+
+ BitBltFromRGBToRGBStretch(m_resizedSpd->w, m_resizedSpd->h, m_resizedSpd->bits, m_resizedSpd->pitch, m_resizedSpd->bpp
+ , m_spd.w, m_spd.h, m_spd.bits, m_spd.pitch, m_spd.bpp);
+ TRACE("CMemSubPic: Resized SubPic %dx%d -> %dx%d\n", m_spd.w, m_spd.h, r.Width(), r.Height());
+
+ // Set whole resized spd as dirty, we are not going to reuse it.
+ rcDirty.SetRect(0, 0, m_resizedSpd->w, m_resizedSpd->h);
+ } else if (m_resizedSpd) {
+ // Resize is not needed so release m_resizedSpd.
+ m_pAllocator->FreeSpdBits(*m_resizedSpd);
+ m_resizedSpd = nullptr;
+ }
+
+ const SubPicDesc& subPic = m_resizedSpd ? *m_resizedSpd : m_spd;
+
+ if (subPic.type == MSP_YUY2 || subPic.type == MSP_YV12 || subPic.type == MSP_IYUV || subPic.type == MSP_AYUV) {
ColorConvInit();
- if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
- m_rcDirty.left &= ~1;
- m_rcDirty.right = (m_rcDirty.right + 1) & ~1;
+ if (subPic.type == MSP_YUY2 || subPic.type == MSP_YV12 || subPic.type == MSP_IYUV) {
+ rcDirty.left &= ~1;
+ rcDirty.right = (rcDirty.right + 1) & ~1;
- if (m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
- m_rcDirty.top &= ~1;
- m_rcDirty.bottom = (m_rcDirty.bottom + 1) & ~1;
+ if (subPic.type == MSP_YV12 || subPic.type == MSP_IYUV) {
+ rcDirty.top &= ~1;
+ rcDirty.bottom = (rcDirty.bottom + 1) & ~1;
}
}
}
- int w = m_rcDirty.Width(), h = m_rcDirty.Height();
- BYTE* top = m_spd.bits + m_spd.pitch * m_rcDirty.top + m_rcDirty.left * 4;
- BYTE* bottom = top + m_spd.pitch * h;
+ if (!m_resizedSpd) {
+ m_rcDirty = rcDirty;
+ }
+
+ int w = rcDirty.Width(), h = rcDirty.Height();
+ BYTE* top = subPic.bits + subPic.pitch * rcDirty.top + rcDirty.left * 4;
+ BYTE* bottom = top + subPic.pitch * h;
- if (m_spd.type == MSP_RGB16) {
- for (; top < bottom ; top += m_spd.pitch) {
+ if (subPic.type == MSP_RGB16) {
+ for (; top < bottom ; top += subPic.pitch) {
DWORD* s = (DWORD*)top;
DWORD* e = s + w;
for (; s < e; s++) {
@@ -208,8 +254,8 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
//*s = (*s&0xff000000)|((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x001f);
}
}
- } else if (m_spd.type == MSP_RGB15) {
- for (; top < bottom; top += m_spd.pitch) {
+ } else if (subPic.type == MSP_RGB15) {
+ for (; top < bottom; top += subPic.pitch) {
DWORD* s = (DWORD*)top;
DWORD* e = s + w;
for (; s < e; s++) {
@@ -217,14 +263,14 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
//*s = (*s&0xff000000)|((*s>>9)&0x7c00)|((*s>>6)&0x03e0)|((*s>>3)&0x001f);
}
}
- } else if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
- for (; top < bottom ; top += m_spd.pitch) {
+ } else if (subPic.type == MSP_YUY2 || subPic.type == MSP_YV12 || subPic.type == MSP_IYUV) {
+ for (; top < bottom ; top += subPic.pitch) {
BYTE* s = top;
BYTE* e = s + w * 4;
for (; s < e; s += 8) { // ARGB ARGB -> AxYU AxYV
if ((s[3] + s[7]) < 0x1fe) {
- s[1] = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
- s[5] = (c2y_yb[s[4]] + c2y_yg[s[5]] + c2y_yr[s[6]] + 0x108000) >> 16;
+ s[1] = BYTE((c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16);
+ s[5] = BYTE((c2y_yb[s[4]] + c2y_yg[s[5]] + c2y_yr[s[6]] + 0x108000) >> 16);
int scaled_y = (s[1] + s[5] - 32) * cy_cy2;
@@ -236,14 +282,14 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
}
}
}
- } else if (m_spd.type == MSP_AYUV) {
- for (; top < bottom ; top += m_spd.pitch) {
+ } else if (subPic.type == MSP_AYUV) {
+ for (; top < bottom ; top += subPic.pitch) {
BYTE* s = top;
BYTE* e = s + w * 4;
for (; s < e; s += 4) { // ARGB -> AYUV
if (s[3] < 0xff) {
- int y = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
+ auto y = BYTE((c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16);
int scaled_y = (y - 32) * cy_cy;
s[1] = clip[((((s[0] << 16) - scaled_y) >> 10) * c2y_cu + 0x800000 + 0x8000) >> 16];
s[0] = clip[((((s[2] << 16) - scaled_y) >> 10) * c2y_cv + 0x800000 + 0x8000) >> 16];
@@ -373,7 +419,7 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
return E_POINTER;
}
- const SubPicDesc& src = m_spd;
+ const SubPicDesc& src = m_resizedSpd ? *m_resizedSpd : m_spd;
SubPicDesc dst = *pTarget; // copy, because we might modify it
if (src.type != dst.type) {
@@ -382,6 +428,10 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
CRect rs(*pSrc), rd(*pDst);
+ if (m_resizedSpd) {
+ rs = rd = CRect(0, 0, m_resizedSpd->w, m_resizedSpd->h);
+ }
+
if (dst.h < 0) {
dst.h = -dst.h;
rd.bottom = dst.h - rd.bottom;
@@ -565,7 +615,7 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
for (; s2 < s2end; s2 += 8, d2++, is2 += 8) {
unsigned int ia = (s2[3] + s2[3 + src.pitch] + is2[3] + is2[3 + src.pitch]) >> 2;
if (ia < 0xff) {
- *d2 = (((*d2 - 0x80) * ia) >> 8) + ((s2[0] + s2[src.pitch]) >> 1);
+ *d2 = BYTE((((*d2 - 0x80) * ia) >> 8) + ((s2[0] + s2[src.pitch]) >> 1));
}
}
}
@@ -586,11 +636,20 @@ CMemSubPicAllocator::CMemSubPicAllocator(int type, SIZE maxsize)
{
}
+CMemSubPicAllocator::~CMemSubPicAllocator()
+{
+ CAutoLock cAutoLock(this);
+
+ for (const auto& p : m_freeMemoryChunks) {
+ delete[] std::get<1>(p);
+ }
+}
+
// ISubPicAllocatorImpl
bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if (!ppSubPic) {
+ if (!ppSubPic || m_maxsize.cx <= 0 || m_maxsize.cy <= 0) {
return false;
}
@@ -600,15 +659,14 @@ bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
spd.bpp = 32;
spd.pitch = (spd.w * spd.bpp) >> 3;
spd.type = m_type;
- try {
- spd.bits = DEBUG_NEW BYTE[spd.pitch * spd.h];
- } catch (CMemoryException* e) {
- e->Delete();
+ spd.vidrect = m_curvidrect;
+
+ if (!AllocSpdBits(spd)) {
return false;
}
try {
- *ppSubPic = DEBUG_NEW CMemSubPic(spd);
+ *ppSubPic = DEBUG_NEW CMemSubPic(spd, this);
} catch (CMemoryException* e) {
e->Delete();
delete [] spd.bits;
@@ -619,3 +677,57 @@ bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
return true;
}
+
+bool CMemSubPicAllocator::AllocSpdBits(SubPicDesc& spd)
+{
+ CAutoLock cAutoLock(this);
+
+ ASSERT(!spd.bits);
+ ASSERT(spd.pitch * spd.h > 0);
+
+ auto it = std::find_if(m_freeMemoryChunks.cbegin(), m_freeMemoryChunks.cend(), [&](const std::pair& p) {
+ return std::get<0>(p) == size_t(spd.pitch) * spd.h;
+ });
+
+ if (it != m_freeMemoryChunks.cend()) {
+ spd.bits = std::get<1>(*it);
+ m_freeMemoryChunks.erase(it);
+ } else {
+ try {
+ spd.bits = DEBUG_NEW BYTE[spd.pitch * spd.h];
+ } catch (CMemoryException* e) {
+ ASSERT(FALSE);
+ e->Delete();
+ return false;
+ }
+ }
+ return true;
+}
+
+void CMemSubPicAllocator::FreeSpdBits(SubPicDesc& spd)
+{
+ CAutoLock cAutoLock(this);
+
+ ASSERT(spd.bits);
+ m_freeMemoryChunks.emplace_back(spd.pitch * spd.h, spd.bits);
+ spd.bits = nullptr;
+}
+
+STDMETHODIMP CMemSubPicAllocator::SetMaxTextureSize(SIZE maxTextureSize)
+{
+ if (m_maxsize != maxTextureSize) {
+ m_maxsize = maxTextureSize;
+ CAutoLock cAutoLock(this);
+ for (const auto& p : m_freeMemoryChunks) {
+ delete[] std::get<1>(p);
+ }
+ m_freeMemoryChunks.clear();
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CMemSubPicAllocator::SetCurVidRect(RECT curvidrect)
+{
+ m_curvidrect = curvidrect;
+ return __super::SetCurVidRect(curvidrect);
+}
diff --git a/src/SubPic/MemSubPic.h b/src/SubPic/MemSubPic.h
index 091a6237166..903639c0253 100644
--- a/src/SubPic/MemSubPic.h
+++ b/src/SubPic/MemSubPic.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -22,6 +22,8 @@
#pragma once
#include "SubPicImpl.h"
+#include
+#include
enum {
MSP_RGB32,
@@ -36,16 +38,19 @@ enum {
};
// CMemSubPic
-
+class CMemSubPicAllocator;
class CMemSubPic : public CSubPicImpl
{
+ CComPtr m_pAllocator;
+
SubPicDesc m_spd;
+ std::unique_ptr m_resizedSpd;
protected:
STDMETHODIMP_(void*) GetObject(); // returns SubPicDesc*
public:
- CMemSubPic(const SubPicDesc& spd);
+ CMemSubPic(const SubPicDesc& spd, CMemSubPicAllocator* pAllocator);
virtual ~CMemSubPic();
// ISubPic
@@ -59,13 +64,23 @@ class CMemSubPic : public CSubPicImpl
// CMemSubPicAllocator
-class CMemSubPicAllocator : public CSubPicAllocatorImpl
+class CMemSubPicAllocator : public CSubPicAllocatorImpl, public CCritSec
{
int m_type;
CSize m_maxsize;
+ CRect m_curvidrect;
+
+ std::vector> m_freeMemoryChunks;
bool Alloc(bool fStatic, ISubPic** ppSubPic);
public:
CMemSubPicAllocator(int type, SIZE maxsize);
+ virtual ~CMemSubPicAllocator();
+
+ bool AllocSpdBits(SubPicDesc& spd);
+ void FreeSpdBits(SubPicDesc& spd);
+
+ STDMETHODIMP SetMaxTextureSize(SIZE maxTextureSize) override;
+ STDMETHODIMP SetCurVidRect(RECT curvidrect) override;
};
diff --git a/src/SubPic/SubPicAllocatorPresenterImpl.cpp b/src/SubPic/SubPicAllocatorPresenterImpl.cpp
index 61d96739831..80cd05170e7 100644
--- a/src/SubPic/SubPicAllocatorPresenterImpl.cpp
+++ b/src/SubPic/SubPicAllocatorPresenterImpl.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -70,6 +70,7 @@ STDMETHODIMP CSubPicAllocatorPresenterImpl::NonDelegatingQueryInterface(REFIID r
QI(ISubPicAllocatorPresenter2)
QI(ISubRenderOptions)
QI(ISubRenderConsumer)
+ QI(ISubRenderConsumer2)
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -483,10 +484,21 @@ STDMETHODIMP CSubPicAllocatorPresenterImpl::Connect(ISubRenderProvider* subtitle
: (ISubPicQueue*)DEBUG_NEW CXySubPicQueueNoThread(m_pAllocator, &hr);
*/
+ // Lock and wait for m_pAllocator to be ready.
+ CAutoLock cAutoLock(this);
+ if (!m_pAllocator) {
+ std::mutex mutexAllocator;
+ std::unique_lock lock(mutexAllocator);
+ if (!m_condAllocatorReady.wait_for(lock, std::chrono::seconds(1), [&]() {return !!m_pAllocator;})) {
+ // Return early, CXySubPicQueueNoThread ctor would fail anyway.
+ ASSERT(FALSE);
+ return E_FAIL;
+ }
+ }
+
CComPtr pSubPicQueue = (ISubPicQueue*)DEBUG_NEW CXySubPicQueueNoThread(m_pAllocator, &hr);
if (SUCCEEDED(hr)) {
- CAutoLock cAutoLock(this);
pSubPicQueue->SetSubPicProvider(pSubPicProvider);
m_pSubPicProvider = pSubPicProvider;
m_pSubPicQueue = pSubPicQueue;
diff --git a/src/SubPic/SubPicAllocatorPresenterImpl.h b/src/SubPic/SubPicAllocatorPresenterImpl.h
index 40ce613cfb4..5b2e5a2d432 100644
--- a/src/SubPic/SubPicAllocatorPresenterImpl.h
+++ b/src/SubPic/SubPicAllocatorPresenterImpl.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -23,6 +23,7 @@
#include
#include
+#include
#include "ISubPic.h"
#include "CoordGeom.h"
#include "SubRenderIntf.h"
@@ -54,6 +55,8 @@ class CSubPicAllocatorPresenterImpl
CComPtr m_pAllocator;
CComPtr m_pSubPicQueue;
+ std::condition_variable m_condAllocatorReady;
+
bool m_bDeviceResetRequested;
bool m_bPendingResetDevice;
diff --git a/src/SubPic/SubPicImpl.h b/src/SubPic/SubPicImpl.h
index febb1d08e98..18c388c1ed4 100644
--- a/src/SubPic/SubPicImpl.h
+++ b/src/SubPic/SubPicImpl.h
@@ -135,6 +135,6 @@ class CSubPicAllocatorImpl : public CUnknown, public ISubPicAllocator
STDMETHODIMP AllocDynamic(ISubPic** ppSubPic);
STDMETHODIMP_(bool) IsDynamicWriteOnly() const;
STDMETHODIMP ChangeDevice(IUnknown* pDev);
- STDMETHODIMP SetMaxTextureSize(SIZE maxTextureSize) { return E_NOTIMPL; };
+ STDMETHODIMP SetMaxTextureSize(SIZE maxTextureSize) PURE;
STDMETHODIMP FreeStatic();
};
diff --git a/src/SubPic/SubPicQueueImpl.cpp b/src/SubPic/SubPicQueueImpl.cpp
index ffbbc9fe3d5..f5d7abc22cf 100644
--- a/src/SubPic/SubPicQueueImpl.cpp
+++ b/src/SubPic/SubPicQueueImpl.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -180,6 +180,9 @@ CSubPicQueue::~CSubPicQueue()
m_bExitThread = true;
SetSubPicProvider(nullptr);
CAMThread::Close();
+ if (m_pAllocator) {
+ m_pAllocator->FreeStatic();
+ }
}
// ISubPicQueue
@@ -688,6 +691,9 @@ CSubPicQueueNoThread::CSubPicQueueNoThread(SubPicQueueSettings settings, ISubPic
CSubPicQueueNoThread::~CSubPicQueueNoThread()
{
+ if (m_pAllocator) {
+ m_pAllocator->FreeStatic();
+ }
}
// ISubPicQueue
diff --git a/src/Subtitles/ColorConvTable.cpp b/src/Subtitles/ColorConvTable.cpp
new file mode 100644
index 00000000000..092d91e179a
--- /dev/null
+++ b/src/Subtitles/ColorConvTable.cpp
@@ -0,0 +1,885 @@
+/*
+* (C) 2015 see Authors.txt
+*
+* This file is part of MPC-HC.
+*
+* MPC-HC is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* MPC-HC is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+*/
+
+#include "stdafx.h"
+#include "ColorConvTable.h"
+
+/************************************
+Formula:
+Ey => [0,1]
+Eu => [-0.5,0.5]
+Ev => [-0.5,0.5]
+Er => [0,1]
+Eg => [0,1]
+Eb => [0,1]
+
+1 = Kr + Kg + Kb
+Ey = Kr * Er + Kg * Eg + Kb * Eb;
+Eu = (Eb - Ey) / (1 - Kb) / 2;
+Ev = (Er - Ey) / (1 - Kr) / 2;
+
+Quantization:
+ANY = ANY * RANGE_SIZE + BASE
+
+Range:
+TV Level
+Y => [16, 235]
+U => [16, 240]
+V => [16, 240]
+
+R => [16, 235]
+G => [16, 235]
+B => [16, 235]
+PC Level
+Y => [0,255]
+U => [0,255]
+V => [0,255]
+
+R => [0,255]
+G => [0,255]
+B => [0,255]
+************************************/
+
+//RGB to YUV
+#define DEFINE_YUV_MATRIX(Kr,Kg,Kb) { \
+ { Kr , Kg , Kb , 0},\
+ { -Kr /((1-Kb)*2), -Kg/((1-Kb)*2),(1-Kb)/((1-Kb)*2), 0},\
+ {(1-Kr)/((1-Kr)*2), -Kg/((1-Kr)*2), -Kb /((1-Kr)*2), 0} \
+}
+
+//YUV to RGB: INV stand for inverse
+#define DEFINE_YUV_MATRIX_INV(Kr,Kg,Kb) { \
+ { 1, 0 , 2*(1-Kr) , 0},\
+ { 1, -2*(1-Kb)*Kb/Kg, -2*(1-Kr)*Kr/Kg, 0},\
+ { 1, 2*(1-Kb) , 0 , 0} \
+}
+
+const float MATRIX_BT_601[3][4] = DEFINE_YUV_MATRIX(0.299f, 0.587f, 0.114f);
+const float MATRIX_BT_601_INV[3][4] = DEFINE_YUV_MATRIX_INV(0.299f, 0.587f, 0.114f);
+const float MATRIX_BT_709[3][4] = DEFINE_YUV_MATRIX(0.2126f, 0.7152f, 0.0722f);
+const float MATRIX_BT_709_INV[3][4] = DEFINE_YUV_MATRIX_INV(0.2126f, 0.7152f, 0.0722f);
+const float YUV_PC[3][4] = {
+ { 255, 0, 0, 0 },
+ { 0, 255, 0, 128 },
+ { 0, 0, 255, 128 }
+};
+const float YUV_PC_INV[3][4] = {
+ { 1 / 255.0f, 0, 0, 0 },
+ { 0, 1 / 255.0f, 0, -128 / 255.0f },
+ { 0, 0, 1 / 255.0f, -128 / 255.0f }
+};
+const float YUV_TV[3][4] = {
+ { 219, 0, 0, 16 },
+ { 0, 224, 0, 128 },
+ { 0, 0, 224, 128 }
+};
+const float YUV_TV_INV[3][4] = {
+ { 1 / 219.0f, 0, 0, -16 / 219.0f },
+ { 0, 1 / 224.0f, 0, -128 / 224.0f },
+ { 0, 0, 1 / 224.0f, -128 / 224.0f }
+};
+const float RGB_PC[3][4] = {
+ { 255, 0, 0, 0 },
+ { 0, 255, 0, 0 },
+ { 0, 0, 255, 0 }
+};
+const float RGB_PC_INV[3][4] = {
+ { 1 / 255.0f, 0, 0, 0 },
+ { 0, 1 / 255.0f, 0, 0 },
+ { 0, 0, 1 / 255.0f, 0 }
+};
+const float RGB_TV[3][4] = {
+ { 219, 0, 0, 16 },
+ { 0, 219, 0, 16 },
+ { 0, 0, 219, 16 }
+};
+const float RGB_TV_INV[3][4] = {
+ { 1 / 219.0f, 0, 0, -16 / 219.0f },
+ { 0, 1 / 219.0f, 0, -16 / 219.0f },
+ { 0, 0, 1 / 219.0f, -16 / 219.0f }
+};
+const float IDENTITY[3][4] = {
+ { 1, 0, 0, 0 },
+ { 0, 1, 0, 0 },
+ { 0, 0, 1, 0 }
+};
+
+inline int clip(int value, int upper_bound)
+{
+ value &= ~(value >> 31); //value = value > 0 ? value : 0
+ return value ^ ((value ^ upper_bound) & ((upper_bound - value) >> 31)); //value = value < upper_bound ? value : upper_bound
+}
+
+#define E(M,i,j) M[i*4+j]
+
+void MultiplyMatrix(float* lhs_in_out, const float* rhs)
+{
+ float tmp1;
+ float tmp2;
+ float tmp3;
+
+ tmp1 = E(lhs_in_out, 0, 0);
+ tmp2 = E(lhs_in_out, 0, 1);
+ tmp3 = E(lhs_in_out, 0, 2);
+
+ E(lhs_in_out, 0, 0) = tmp1 * E(rhs, 0, 0) + tmp2 * E(rhs, 1, 0) + tmp3 * E(rhs, 2, 0);
+ E(lhs_in_out, 0, 1) = tmp1 * E(rhs, 0, 1) + tmp2 * E(rhs, 1, 1) + tmp3 * E(rhs, 2, 1);
+ E(lhs_in_out, 0, 2) = tmp1 * E(rhs, 0, 2) + tmp2 * E(rhs, 1, 2) + tmp3 * E(rhs, 2, 2);
+ E(lhs_in_out, 0, 3) = tmp1 * E(rhs, 0, 3) + tmp2 * E(rhs, 1, 3) + tmp3 * E(rhs, 2, 3) + E(lhs_in_out, 0, 3);
+
+ tmp1 = E(lhs_in_out, 1, 0);
+ tmp2 = E(lhs_in_out, 1, 1);
+ tmp3 = E(lhs_in_out, 1, 2);
+
+ E(lhs_in_out, 1, 0) = tmp1 * E(rhs, 0, 0) + tmp2 * E(rhs, 1, 0) + tmp3 * E(rhs, 2, 0);
+ E(lhs_in_out, 1, 1) = tmp1 * E(rhs, 0, 1) + tmp2 * E(rhs, 1, 1) + tmp3 * E(rhs, 2, 1);
+ E(lhs_in_out, 1, 2) = tmp1 * E(rhs, 0, 2) + tmp2 * E(rhs, 1, 2) + tmp3 * E(rhs, 2, 2);
+ E(lhs_in_out, 1, 3) = tmp1 * E(rhs, 0, 3) + tmp2 * E(rhs, 1, 3) + tmp3 * E(rhs, 2, 3) + E(lhs_in_out, 1, 3);
+
+ tmp1 = E(lhs_in_out, 2, 0);
+ tmp2 = E(lhs_in_out, 2, 1);
+ tmp3 = E(lhs_in_out, 2, 2);
+
+ E(lhs_in_out, 2, 0) = tmp1 * E(rhs, 0, 0) + tmp2 * E(rhs, 1, 0) + tmp3 * E(rhs, 2, 0);
+ E(lhs_in_out, 2, 1) = tmp1 * E(rhs, 0, 1) + tmp2 * E(rhs, 1, 1) + tmp3 * E(rhs, 2, 1);
+ E(lhs_in_out, 2, 2) = tmp1 * E(rhs, 0, 2) + tmp2 * E(rhs, 1, 2) + tmp3 * E(rhs, 2, 2);
+ E(lhs_in_out, 2, 3) = tmp1 * E(rhs, 0, 3) + tmp2 * E(rhs, 1, 3) + tmp3 * E(rhs, 2, 3) + E(lhs_in_out, 2, 3);
+}
+
+class ConvMatrix
+{
+public:
+ enum LevelType {
+ LEVEL_TV,
+ LEVEL_PC,
+ LEVEL_COUNT
+ };
+ enum ColorType {
+ COLOR_YUV_601,
+ COLOR_YUV_709,
+ COLOR_RGB,
+ COLOR_COUNT
+ };
+public:
+ ConvMatrix();
+ virtual ~ConvMatrix();
+
+ bool Init();
+ DWORD Convert(int x1, int x2, int x3, int in_level, int in_type, int out_level, int out_type);
+ static DWORD DoConvert(int x1, int x2, int x3, const int* matrix);
+
+ DWORD ColorCorrection(int r8, int g8, int b8, int output_rgb_level);
+ void InitMatrix(int in_level, int in_type, int out_level, int out_type);
+ void InitColorCorrectionMatrix();
+private:
+ const float* MATRIX_DE_QUAN[LEVEL_COUNT][COLOR_COUNT];
+ const float* MATRIX_INV_TRANS[COLOR_COUNT];
+ const float* MATRIX_TRANS[COLOR_COUNT];
+ const float* MATRIX_QUAN[LEVEL_COUNT][COLOR_COUNT];
+
+ //m_matrix[in_level][in_type][out_level][out_type]
+ int* m_matrix[LEVEL_COUNT][COLOR_COUNT][LEVEL_COUNT][COLOR_COUNT];
+
+ int m_matrix_vsfilter_compact_corretion[LEVEL_COUNT][3][4];
+};
+
+ConvMatrix::ConvMatrix()
+{
+ ZeroMemory(m_matrix, LEVEL_COUNT * COLOR_COUNT * LEVEL_COUNT * COLOR_COUNT * sizeof(float*));
+ Init();
+}
+
+ConvMatrix::~ConvMatrix()
+{
+ int** p_matrix = (int**)m_matrix;
+ for (int i = 0; i < LEVEL_COUNT * COLOR_COUNT * LEVEL_COUNT * COLOR_COUNT; i++) {
+ SAFE_DELETE(p_matrix[i]);
+ }
+}
+
+bool ConvMatrix::Init()
+{
+ MATRIX_DE_QUAN[LEVEL_TV][COLOR_YUV_601] = &YUV_TV_INV[0][0];
+ MATRIX_DE_QUAN[LEVEL_TV][COLOR_YUV_709] = &YUV_TV_INV[0][0];
+ MATRIX_DE_QUAN[LEVEL_TV][COLOR_RGB] = &RGB_TV_INV[0][0];
+
+ MATRIX_DE_QUAN[LEVEL_PC][COLOR_YUV_601] = &YUV_PC_INV[0][0];
+ MATRIX_DE_QUAN[LEVEL_PC][COLOR_YUV_709] = &YUV_PC_INV[0][0];
+ MATRIX_DE_QUAN[LEVEL_PC][COLOR_RGB] = &RGB_PC_INV[0][0];
+
+ MATRIX_INV_TRANS[COLOR_YUV_601] = &MATRIX_BT_601_INV[0][0];
+ MATRIX_INV_TRANS[COLOR_YUV_709] = &MATRIX_BT_709_INV[0][0];
+ MATRIX_INV_TRANS[COLOR_RGB] = &IDENTITY[0][0];
+
+ MATRIX_TRANS[COLOR_YUV_601] = &MATRIX_BT_601[0][0];
+ MATRIX_TRANS[COLOR_YUV_709] = &MATRIX_BT_709[0][0];
+ MATRIX_TRANS[COLOR_RGB] = &IDENTITY[0][0];
+
+ MATRIX_QUAN[LEVEL_TV][COLOR_YUV_601] = &YUV_TV[0][0];
+ MATRIX_QUAN[LEVEL_TV][COLOR_YUV_709] = &YUV_TV[0][0];
+ MATRIX_QUAN[LEVEL_TV][COLOR_RGB] = &RGB_TV[0][0];
+
+ MATRIX_QUAN[LEVEL_PC][COLOR_YUV_601] = &YUV_PC[0][0];
+ MATRIX_QUAN[LEVEL_PC][COLOR_YUV_709] = &YUV_PC[0][0];
+ MATRIX_QUAN[LEVEL_PC][COLOR_RGB] = &RGB_PC[0][0];
+
+ InitColorCorrectionMatrix();
+ //InitMatrix(LEVEL_PC, COLOR_RGB, LEVEL_TV, COLOR_YUV_601);
+ //InitMatrix(LEVEL_PC, COLOR_RGB, LEVEL_TV, COLOR_YUV_709);
+ //InitMatrix(LEVEL_TV, COLOR_YUV_601, LEVEL_PC, COLOR_RGB);
+ //InitMatrix(LEVEL_TV, COLOR_YUV_709, LEVEL_PC, COLOR_RGB);
+
+ //InitMatrix(LEVEL_TV, COLOR_RGB, LEVEL_TV, COLOR_YUV_601);
+ //InitMatrix(LEVEL_TV, COLOR_RGB, LEVEL_TV, COLOR_YUV_709);
+ //InitMatrix(LEVEL_TV, COLOR_YUV_601, LEVEL_TV, COLOR_RGB);
+ //InitMatrix(LEVEL_TV, COLOR_YUV_709, LEVEL_TV, COLOR_RGB);
+ return true;
+};
+
+void ConvMatrix::InitMatrix(int in_level, int in_type, int out_level, int out_type)
+{
+ int*& out_matrix = m_matrix[in_level][in_type][out_level][out_type];
+ if (out_matrix) {
+ return;
+ }
+ out_matrix = DEBUG_NEW int[3 * 4];
+ ASSERT(out_matrix);
+
+ float matrix[3][4];
+ float* p_matrix = &matrix[0][0];
+ memcpy(p_matrix, MATRIX_QUAN[out_level][out_type], 3 * 4 * sizeof(float));
+ MultiplyMatrix(p_matrix, MATRIX_TRANS[out_type]);
+ MultiplyMatrix(p_matrix, MATRIX_INV_TRANS[in_type]);
+ MultiplyMatrix(p_matrix, MATRIX_DE_QUAN[in_level][in_type]);
+ for (int i = 0; i < 3 * 4; i++) {
+ out_matrix[i] = std::lround(p_matrix[i] * (1 << 16));
+ ASSERT(out_matrix[i] < (1 << 24));
+ }
+}
+
+void ConvMatrix::InitColorCorrectionMatrix()
+{
+ int* out_matrix = &m_matrix_vsfilter_compact_corretion[LEVEL_PC][0][0];
+
+ float matrix[3][4];
+ float* p_matrix = &matrix[0][0];
+ memcpy(p_matrix, MATRIX_INV_TRANS[COLOR_YUV_709], 3 * 4 * sizeof(float));
+ MultiplyMatrix(p_matrix, MATRIX_TRANS[COLOR_YUV_601]);
+ for (int i = 0; i < 3 * 4; i++) {
+ out_matrix[i] = std::lround(p_matrix[i] * (1 << 16));
+ ASSERT(out_matrix[i] < (1 << 24));
+ }
+
+ out_matrix = &m_matrix_vsfilter_compact_corretion[LEVEL_TV][0][0];
+ memcpy(p_matrix, MATRIX_QUAN[LEVEL_TV][COLOR_RGB], 3 * 4 * sizeof(float));
+ MultiplyMatrix(p_matrix, MATRIX_INV_TRANS[COLOR_YUV_709]);
+ MultiplyMatrix(p_matrix, MATRIX_TRANS[COLOR_YUV_601]);
+ MultiplyMatrix(p_matrix, MATRIX_DE_QUAN[LEVEL_PC][COLOR_RGB]);
+ for (int i = 0; i < 3 * 4; i++) {
+ out_matrix[i] = std::lround(p_matrix[i] * (1 << 16));
+ ASSERT(out_matrix[i] < (1 << 24));
+ }
+}
+
+DWORD ConvMatrix::Convert(int x1, int x2, int x3, int in_level, int in_type, int out_level, int out_type)
+{
+ int*& matrix_int = m_matrix[in_level][in_type][out_level][out_type];
+ if (!matrix_int) {
+ InitMatrix(in_level, in_type, out_level, out_type);
+ if (!matrix_int) {
+ ASSERT(FALSE);
+ return 0;
+ }
+ }
+ return DoConvert(x1, x2, x3, matrix_int);
+}
+
+DWORD ConvMatrix::DoConvert(int x1, int x2, int x3, const int* matrix)
+{
+ ASSERT(matrix);
+ int tmp1 = (E(matrix, 0, 0) * x1 + E(matrix, 0, 1) * x2 + E(matrix, 0, 2) * x3 + E(matrix, 0, 3) + (1 << 15)) >> 16;
+ int tmp2 = (E(matrix, 1, 0) * x1 + E(matrix, 1, 1) * x2 + E(matrix, 1, 2) * x3 + E(matrix, 1, 3) + (1 << 15)) >> 16;
+ int tmp3 = (E(matrix, 2, 0) * x1 + E(matrix, 2, 1) * x2 + E(matrix, 2, 2) * x3 + E(matrix, 2, 3) + (1 << 15)) >> 16;
+ tmp1 = clip(tmp1, 255);
+ tmp2 = clip(tmp2, 255);
+ tmp3 = clip(tmp3, 255);
+ return (tmp1 << 16) | (tmp2 << 8) | tmp3;
+}
+
+DWORD ConvMatrix::ColorCorrection(int r8, int g8, int b8, int output_rgb_level)
+{
+ ASSERT(output_rgb_level == LEVEL_PC || output_rgb_level == LEVEL_TV);
+ return DoConvert(r8, g8, b8, &m_matrix_vsfilter_compact_corretion[output_rgb_level][0][0]);
+}
+
+const int FRACTION_BITS = 16;
+const int FRACTION_SCALE = 1 << 16;
+
+struct RGBLevelInfo {
+ int low, size;
+};
+const RGBLevelInfo RGB_LVL_PC = { 0, 255 };
+const RGBLevelInfo RGB_LVL_TV = { 16, 219 };
+
+struct YUVLevelInfo {
+ int y_low, y_size;
+ int u_mid, u_size;
+};
+const YUVLevelInfo YUV_LVL_PC = { 0, 255, 128, 255 };
+const YUVLevelInfo YUV_LVL_TV = { 16, 219, 128, 224 };
+
+#define DEFINE_RGB2YUV_FUNC(func, RGB_LEVEL, YUV_LEVEL, Kr, Kg, Kb, YUV_POS) \
+DWORD func(int r8, int g8, int b8) \
+{ \
+ r8 -= RGB_LEVEL.low; \
+ g8 -= RGB_LEVEL.low; \
+ b8 -= RGB_LEVEL.low; \
+ const int INT_Kr = int(Kr*FRACTION_SCALE+0.5); \
+ const int INT_Kg = int(Kg*FRACTION_SCALE+0.5); \
+ const int INT_Kb = int(Kb*FRACTION_SCALE+0.5); \
+ const int Y_CU = int(0.5/(1-Kb)*4096+0.5); \
+ const int Y_CV = int(0.5/(1-Kr)*4096+0.5); \
+ const int Y_SCALE= int(1.0*YUV_LEVEL.y_size/RGB_LEVEL.size*4096+0.5); \
+ const int U_SCALE= int(1.0*YUV_LEVEL.u_size/RGB_LEVEL.size*4096+0.5); \
+ \
+ int y = INT_Kr*r8 + INT_Kg*g8 + INT_Kb*b8; \
+ int u = (((b8<> 12) * Y_CU; \
+ int v = (((r8<> 12) * Y_CV; \
+ y = Y_SCALE == 4096 ? y : (y>>12)*Y_SCALE; \
+ u = U_SCALE == 4096 ? u : (u>>12)*U_SCALE; \
+ v = U_SCALE == 4096 ? v : (v>>12)*U_SCALE; \
+ y = (y + (YUV_LEVEL.y_low*FRACTION_SCALE + FRACTION_SCALE/2))>>FRACTION_BITS; \
+ u = (u + (YUV_LEVEL.u_mid*FRACTION_SCALE + FRACTION_SCALE/2))>>FRACTION_BITS; \
+ v = (v + (YUV_LEVEL.u_mid*FRACTION_SCALE + FRACTION_SCALE/2))>>FRACTION_BITS; \
+ y = clip(y, 255); \
+ u = clip(u, 255); \
+ v = clip(v, 255); \
+ return (y<>FRACTION_BITS; \
+ int g = (y8 + INT_GU*u8 + INT_GV*v8 + FRACTION_SCALE/2)>>FRACTION_BITS; \
+ int b = (y8 + INT_BU*u8 + 0 + FRACTION_SCALE/2)>>FRACTION_BITS; \
+ r = clip(r, RGB_LEVEL.size); \
+ g = clip(g, RGB_LEVEL.size); \
+ b = clip(b, RGB_LEVEL.size); \
+ r += RGB_LEVEL.low; \
+ g += RGB_LEVEL.low; \
+ b += RGB_LEVEL.low; \
+ return (r<<16) | (g<<8) | b; \
+}
+
+#define DEFINE_PREMUL_ARGB2AYUV_FUNC(func, RGB_LEVEL, YUV_LEVEL, Kr, Kg, Kb, YUV_POS) \
+DWORD func(int a8, int r8, int g8, int b8) \
+{ \
+ r8 -= RGB_LEVEL.low; \
+ g8 -= RGB_LEVEL.low; \
+ b8 -= RGB_LEVEL.low; \
+ const int INT_Kr = int(Kr*FRACTION_SCALE+0.5); \
+ const int INT_Kg = int(Kg*FRACTION_SCALE+0.5); \
+ const int INT_Kb = int(Kb*FRACTION_SCALE+0.5); \
+ const int Y_CU = int(0.5/(1-Kb)*4096+0.5); \
+ const int Y_CV = int(0.5/(1-Kr)*4096+0.5); \
+ const int Y_SCALE= int(1.0*YUV_LEVEL.y_size/RGB_LEVEL.size*4096+0.5); \
+ const int U_SCALE= int(1.0*YUV_LEVEL.u_size/RGB_LEVEL.size*4096+0.5); \
+ \
+ int a = (256-a8)<<(FRACTION_BITS-8); \
+ int y = INT_Kr*r8 + INT_Kg*g8 + INT_Kb*b8; \
+ int u = (((b8<> 12) * Y_CU; \
+ int v = (((r8<> 12) * Y_CV; \
+ y = Y_SCALE == 4096 ? y : (y>>12)*Y_SCALE; \
+ u = U_SCALE == 4096 ? u : (u>>12)*U_SCALE; \
+ v = U_SCALE == 4096 ? v : (v>>12)*U_SCALE; \
+ y = (y + YUV_LEVEL.y_low*a + FRACTION_SCALE/2)>>FRACTION_BITS; \
+ u = (u + YUV_LEVEL.u_mid*a + FRACTION_SCALE/2)>>FRACTION_BITS; \
+ v = (v + YUV_LEVEL.u_mid*a + FRACTION_SCALE/2)>>FRACTION_BITS; \
+ y = clip(y, 255); \
+ u = clip(u, 255); \
+ v = clip(v, 255); \
+ return (y<>12)*Y_SCALE; \
+ y = (y + (YUV_LEVEL.y_low*FRACTION_SCALE + FRACTION_SCALE/2))>>FRACTION_BITS; \
+ y = clip(y, 255); \
+ return y; \
+}
+
+DWORD RGB_PC_TO_YUV_TV_601(int r8, int g8, int b8);
+DWORD RGB_PC_TO_YUV_PC_601(int r8, int g8, int b8);
+DWORD RGB_PC_TO_YUV_TV_709(int r8, int g8, int b8);
+DWORD RGB_PC_TO_YUV_PC_709(int r8, int g8, int b8);
+
+DWORD RGB_TV_TO_YUV_TV_601(int r8, int g8, int b8);
+DWORD RGB_TV_TO_YUV_PC_601(int r8, int g8, int b8);
+DWORD RGB_TV_TO_YUV_TV_709(int r8, int g8, int b8);
+DWORD RGB_TV_TO_YUV_PC_709(int r8, int g8, int b8);
+
+DWORD RGB_PC_TO_UYV_TV_601(int r8, int g8, int b8);
+DWORD RGB_PC_TO_UYV_PC_601(int r8, int g8, int b8);
+DWORD RGB_PC_TO_UYV_TV_709(int r8, int g8, int b8);
+DWORD RGB_PC_TO_UYV_PC_709(int r8, int g8, int b8);
+
+DWORD RGB_TV_TO_UYV_TV_601(int r8, int g8, int b8);
+DWORD RGB_TV_TO_UYV_PC_601(int r8, int g8, int b8);
+DWORD RGB_TV_TO_UYV_TV_709(int r8, int g8, int b8);
+DWORD RGB_TV_TO_UYV_PC_709(int r8, int g8, int b8);
+
+DWORD PREMUL_ARGB_PC_TO_AYUV_TV_601(int a8, int r8, int g8, int b8);
+DWORD PREMUL_ARGB_PC_TO_AYUV_PC_601(int a8, int r8, int g8, int b8);
+DWORD PREMUL_ARGB_PC_TO_AYUV_TV_709(int a8, int r8, int g8, int b8);
+DWORD PREMUL_ARGB_PC_TO_AYUV_PC_709(int a8, int r8, int g8, int b8);
+
+DWORD PREMUL_ARGB_TV_TO_AYUV_TV_601(int a8, int r8, int g8, int b8);
+DWORD PREMUL_ARGB_TV_TO_AYUV_PC_601(int a8, int r8, int g8, int b8);
+DWORD PREMUL_ARGB_TV_TO_AYUV_TV_709(int a8, int r8, int g8, int b8);
+DWORD PREMUL_ARGB_TV_TO_AYUV_PC_709(int a8, int r8, int g8, int b8);
+
+DWORD RGB_PC_TO_Y_TV_601(int r8, int g8, int b8);
+DWORD RGB_PC_TO_Y_PC_601(int r8, int g8, int b8);
+DWORD RGB_PC_TO_Y_TV_709(int r8, int g8, int b8);
+DWORD RGB_PC_TO_Y_PC_709(int r8, int g8, int b8);
+
+DWORD RGB_TV_TO_Y_TV_601(int r8, int g8, int b8);
+DWORD RGB_TV_TO_Y_PC_601(int r8, int g8, int b8);
+DWORD RGB_TV_TO_Y_TV_709(int r8, int g8, int b8);
+DWORD RGB_TV_TO_Y_PC_709(int r8, int g8, int b8);
+
+DWORD YUV_TV_TO_RGB_PC_601(int y, int u, int v);
+DWORD YUV_PC_TO_RGB_PC_601(int y, int u, int v);
+DWORD YUV_TV_TO_RGB_PC_709(int y, int u, int v);
+DWORD YUV_PC_TO_RGB_PC_709(int y, int u, int v);
+
+DWORD YUV_TV_TO_RGB_TV_601(int y, int u, int v);
+DWORD YUV_PC_TO_RGB_TV_601(int y, int u, int v);
+DWORD YUV_TV_TO_RGB_TV_709(int y, int u, int v);
+DWORD YUV_PC_TO_RGB_TV_709(int y, int u, int v);
+
+typedef ColorConvTable::YuvMatrixType YuvMatrixType;
+typedef ColorConvTable::YuvRangeType YuvRangeType;
+
+class ConvFunc
+{
+public:
+ ConvFunc(YuvMatrixType yuv_type, YuvRangeType range, bool bOutputTVRange, bool bVSFilterCorrection);
+ bool InitConvFunc(YuvMatrixType yuv_type, YuvRangeType range);
+
+ typedef DWORD(*R8G8B8ToYuvFunc)(int r8, int g8, int b8);
+ typedef DWORD(*PreMulArgbToAyuvFunc)(int a8, int r8, int g8, int b8);
+ typedef R8G8B8ToYuvFunc R8G8B8ToY;
+ typedef R8G8B8ToYuvFunc Y8U8V8ToRGBFunc;
+
+ R8G8B8ToYuvFunc r8g8b8_to_yuv_func;
+ R8G8B8ToYuvFunc r8g8b8_to_uyv_func;
+ PreMulArgbToAyuvFunc pre_mul_argb_to_ayuv_func;
+ R8G8B8ToY r8g8b8_to_y_func;
+ Y8U8V8ToRGBFunc y8u8v8_to_rgb_func;
+
+ YuvMatrixType m_eYuvType;
+ YuvRangeType m_eRangeType;
+ bool m_bOutputTVRange;
+ bool m_bVSFilterCorrection;
+
+ ConvMatrix m_convMatrix; //for YUV to YUV or other complicated conversions
+};
+
+static ConvFunc& ConvFuncInst()
+{
+ static ConvFunc s(ColorConvTable::BT601, ColorConvTable::RANGE_TV, false, false);
+ return s;
+}
+
+bool ConvFunc::InitConvFunc(YuvMatrixType yuv_type, YuvRangeType range)
+{
+ bool result = true;
+
+ if (yuv_type == ColorConvTable::BT601 && range == ColorConvTable::RANGE_TV) {
+ r8g8b8_to_yuv_func = RGB_PC_TO_YUV_TV_601;
+ r8g8b8_to_uyv_func = RGB_PC_TO_UYV_TV_601;
+ pre_mul_argb_to_ayuv_func = PREMUL_ARGB_PC_TO_AYUV_TV_601;
+ r8g8b8_to_y_func = RGB_PC_TO_Y_TV_601;
+ y8u8v8_to_rgb_func = YUV_TV_TO_RGB_PC_601;
+
+ m_eYuvType = yuv_type;
+ m_eRangeType = range;
+ } else if (yuv_type == ColorConvTable::BT709 && range == ColorConvTable::RANGE_TV) {
+ r8g8b8_to_yuv_func = RGB_PC_TO_YUV_TV_709;
+ r8g8b8_to_uyv_func = RGB_PC_TO_UYV_TV_709;
+ pre_mul_argb_to_ayuv_func = PREMUL_ARGB_PC_TO_AYUV_TV_709;
+ r8g8b8_to_y_func = RGB_PC_TO_Y_TV_709;
+ y8u8v8_to_rgb_func = YUV_TV_TO_RGB_PC_709;
+
+ m_eYuvType = yuv_type;
+ m_eRangeType = range;
+ } else if (yuv_type == ColorConvTable::BT601 && range == ColorConvTable::RANGE_PC) {
+ r8g8b8_to_yuv_func = RGB_PC_TO_YUV_PC_601;
+ r8g8b8_to_uyv_func = RGB_PC_TO_UYV_PC_601;
+ pre_mul_argb_to_ayuv_func = PREMUL_ARGB_PC_TO_AYUV_PC_601;
+ r8g8b8_to_y_func = RGB_PC_TO_Y_PC_601;
+ y8u8v8_to_rgb_func = YUV_PC_TO_RGB_PC_601;
+
+ m_eYuvType = yuv_type;
+ m_eRangeType = range;
+ } else if (yuv_type == ColorConvTable::BT709 && range == ColorConvTable::RANGE_PC) {
+ r8g8b8_to_yuv_func = RGB_PC_TO_YUV_PC_709;
+ r8g8b8_to_uyv_func = RGB_PC_TO_UYV_PC_709;
+ pre_mul_argb_to_ayuv_func = PREMUL_ARGB_PC_TO_AYUV_PC_709;
+ r8g8b8_to_y_func = RGB_PC_TO_Y_PC_709;
+ y8u8v8_to_rgb_func = YUV_PC_TO_RGB_PC_709;
+
+ m_eYuvType = yuv_type;
+ m_eRangeType = range;
+ } else {
+ r8g8b8_to_yuv_func = RGB_PC_TO_YUV_TV_601;
+ r8g8b8_to_uyv_func = RGB_PC_TO_UYV_TV_601;
+ pre_mul_argb_to_ayuv_func = PREMUL_ARGB_PC_TO_AYUV_TV_601;
+ r8g8b8_to_y_func = RGB_PC_TO_Y_TV_601;
+ y8u8v8_to_rgb_func = YUV_TV_TO_RGB_PC_601;
+
+ m_eYuvType = ColorConvTable::BT601;
+ m_eRangeType = ColorConvTable::RANGE_TV;
+ }
+
+ return result;
+}
+
+ConvFunc::ConvFunc(YuvMatrixType yuv_type, YuvRangeType range, bool bOutputTVRange, bool bVSFilterCorrection)
+ : m_bOutputTVRange(bOutputTVRange)
+ , m_bVSFilterCorrection(bVSFilterCorrection)
+{
+ m_convMatrix.InitMatrix(
+ ConvMatrix::LEVEL_TV, ConvMatrix::COLOR_YUV_601,
+ ConvMatrix::LEVEL_TV, ConvMatrix::COLOR_YUV_709);
+ m_convMatrix.InitMatrix(
+ ConvMatrix::LEVEL_TV, ConvMatrix::COLOR_YUV_601,
+ ConvMatrix::LEVEL_PC, ConvMatrix::COLOR_YUV_709);
+ m_convMatrix.InitMatrix(
+ ConvMatrix::LEVEL_PC, ConvMatrix::COLOR_YUV_601,
+ ConvMatrix::LEVEL_TV, ConvMatrix::COLOR_YUV_709);
+ m_convMatrix.InitMatrix(
+ ConvMatrix::LEVEL_PC, ConvMatrix::COLOR_YUV_601,
+ ConvMatrix::LEVEL_PC, ConvMatrix::COLOR_YUV_709);
+
+ m_convMatrix.InitMatrix(
+ ConvMatrix::LEVEL_TV, ConvMatrix::COLOR_YUV_709,
+ ConvMatrix::LEVEL_TV, ConvMatrix::COLOR_YUV_601);
+ m_convMatrix.InitMatrix(
+ ConvMatrix::LEVEL_TV, ConvMatrix::COLOR_YUV_709,
+ ConvMatrix::LEVEL_PC, ConvMatrix::COLOR_YUV_601);
+ m_convMatrix.InitMatrix(
+ ConvMatrix::LEVEL_PC, ConvMatrix::COLOR_YUV_709,
+ ConvMatrix::LEVEL_TV, ConvMatrix::COLOR_YUV_601);
+ m_convMatrix.InitMatrix(
+ ConvMatrix::LEVEL_PC, ConvMatrix::COLOR_YUV_709,
+ ConvMatrix::LEVEL_PC, ConvMatrix::COLOR_YUV_601);
+ InitConvFunc(yuv_type, range);
+}
+
+//
+// ColorConvTable
+//
+ColorConvTable::YuvMatrixType ColorConvTable::GetDefaultYUVType()
+{
+ return ConvFuncInst().m_eYuvType;
+}
+
+ColorConvTable::YuvRangeType ColorConvTable::GetDefaultRangeType()
+{
+ return ConvFuncInst().m_eRangeType;
+}
+
+void ColorConvTable::SetDefaultConvType(YuvMatrixType yuv_type, YuvRangeType range, bool bOutputTVRange, bool bVSFilterCorrection)
+{
+ if (ConvFuncInst().m_eYuvType != yuv_type || ConvFuncInst().m_eRangeType != range) {
+ ConvFuncInst().InitConvFunc(yuv_type, range);
+ }
+ ConvFuncInst().m_bOutputTVRange = bOutputTVRange;
+ ConvFuncInst().m_bVSFilterCorrection = bVSFilterCorrection;
+}
+
+DWORD ColorConvTable::Argb2Auyv(DWORD argb)
+{
+ int r = (argb & 0x00ff0000) >> 16;
+ int g = (argb & 0x0000ff00) >> 8;
+ int b = (argb & 0x000000ff);
+ return (argb & 0xff000000) | ConvFuncInst().r8g8b8_to_uyv_func(r, g, b);
+}
+
+DWORD ColorConvTable::Argb2Ayuv(DWORD argb)
+{
+ int r = (argb & 0x00ff0000) >> 16;
+ int g = (argb & 0x0000ff00) >> 8;
+ int b = (argb & 0x000000ff);
+ return (argb & 0xff000000) | ConvFuncInst().r8g8b8_to_yuv_func(r, g, b);
+}
+
+DWORD ColorConvTable::Argb2Ayuv_TV_BT601(DWORD argb)
+{
+ int r = (argb & 0x00ff0000) >> 16;
+ int g = (argb & 0x0000ff00) >> 8;
+ int b = (argb & 0x000000ff);
+ return (argb & 0xff000000) | RGB_PC_TO_YUV_TV_601(r, g, b);
+}
+
+DWORD ColorConvTable::Ayuv2Auyv(DWORD ayuv)
+{
+ int y = (ayuv & 0x00ff0000) >> 8;
+ int u = (ayuv & 0x0000ff00) << 8;
+ return (ayuv & 0xff0000ff) | u | y;
+}
+
+DWORD ColorConvTable::PreMulArgb2Ayuv(int a8, int r8, int g8, int b8)
+{
+ return ConvFuncInst().pre_mul_argb_to_ayuv_func(a8, r8, g8, b8);
+}
+
+DWORD ColorConvTable::Rgb2Y(int r8, int g8, int b8)
+{
+ return ConvFuncInst().r8g8b8_to_y_func(r8, g8, b8);
+}
+
+DWORD ColorConvTable::Ayuv2Argb_TV_BT601(DWORD ayuv)
+{
+ int y = (ayuv & 0x00ff0000) >> 16;
+ int u = (ayuv & 0x0000ff00) >> 8;
+ int v = (ayuv & 0x000000ff);
+ return (ayuv & 0xff000000) | YUV_TV_TO_RGB_PC_601(y, u, v);
+}
+
+DWORD ColorConvTable::Ayuv2Argb_TV_BT709(DWORD ayuv)
+{
+ int y = (ayuv & 0x00ff0000) >> 16;
+ int u = (ayuv & 0x0000ff00) >> 8;
+ int v = (ayuv & 0x000000ff);
+ return (ayuv & 0xff000000) | YUV_TV_TO_RGB_PC_709(y, u, v);
+}
+
+DWORD ColorConvTable::Ayuv2Argb(DWORD ayuv)
+{
+ int y = (ayuv & 0x00ff0000) >> 16;
+ int u = (ayuv & 0x0000ff00) >> 8;
+ int v = (ayuv & 0x000000ff);
+ return (ayuv & 0xff000000) | ConvFuncInst().y8u8v8_to_rgb_func(y, u, v);
+}
+
+DWORD ColorConvTable::A8Y8U8V8_To_ARGB_TV_BT601(int a8, int y8, int u8, int v8)
+{
+ return (a8 << 24) | YUV_TV_TO_RGB_PC_601(y8, u8, v8);
+}
+
+DWORD ColorConvTable::A8Y8U8V8_To_ARGB_PC_BT601(int a8, int y8, int u8, int v8)
+{
+ return (a8 << 24) | YUV_PC_TO_RGB_PC_601(y8, u8, v8);
+}
+
+DWORD ColorConvTable::A8Y8U8V8_To_ARGB_TV_BT709(int a8, int y8, int u8, int v8)
+{
+ return (a8 << 24) | YUV_TV_TO_RGB_PC_709(y8, u8, v8);
+}
+
+DWORD ColorConvTable::A8Y8U8V8_To_ARGB_PC_BT709(int a8, int y8, int u8, int v8)
+{
+ return (a8 << 24) | YUV_PC_TO_RGB_PC_709(y8, u8, v8);
+}
+
+DWORD ColorConvTable::A8Y8U8V8_PC_To_TV(int a8, int y8, int u8, int v8)
+{
+ const int FRACTION_SCALE = 1 << 16;
+ const int YUV_MIN = 16;
+ const int cy = int(219.0 / 255 * FRACTION_SCALE + 0.5);
+ const int cuv = int(224.0 / 255 * FRACTION_SCALE + 0.5);
+ y8 = ((y8 * cy) >> 16) + YUV_MIN;
+ u8 = ((u8 * cuv) >> 16) + YUV_MIN;
+ v8 = ((v8 * cuv) >> 16) + YUV_MIN;
+ return (a8 << 24) | (y8 << 16) | (u8 << 8) | v8;
+}
+
+DWORD ColorConvTable::A8Y8U8V8_TV_To_PC(int a8, int y8, int u8, int v8)
+{
+ const int FRACTION_SCALE = 1 << 16;
+ const int YUV_MIN = 16;
+ const int cy = int(255 / 219.0 * FRACTION_SCALE + 0.5);
+ const int cuv = int(255 / 224.0 * FRACTION_SCALE + 0.5);
+ y8 = ((y8 - YUV_MIN) * cy) >> 16;
+ u8 = ((u8 - YUV_MIN) * cuv) >> 16;
+ v8 = ((v8 - YUV_MIN) * cuv) >> 16;
+ return (a8 << 24) | (y8 << 16) | (u8 << 8) | v8;
+}
+
+DWORD ColorConvTable::RGB_PC_TO_TV(DWORD argb)
+{
+ const int MIN = 16;
+ const int SCALE = int(219.0 / 255 * FRACTION_SCALE + 0.5);
+ DWORD r = (argb & 0x00ff0000) >> 16;
+ DWORD g = (argb & 0x0000ff00) >> 8;
+ DWORD b = (argb & 0x000000ff);
+ r = ((r * SCALE) >> 16) + MIN;
+ g = ((g * SCALE) >> 16) + MIN;
+ b = ((b * SCALE) >> 16) + MIN;
+ return (argb & 0xff000000) | (r << 16) | (g << 8) | b;
+}
+
+DWORD ColorConvTable::A8Y8U8V8_TO_AYUV(int a8, int y8, int u8, int v8,
+ YuvRangeType in_range, YuvMatrixType in_type, YuvRangeType out_range, YuvMatrixType out_type)
+{
+ const int level_map[3] = {
+ ConvMatrix::LEVEL_TV,
+ ConvMatrix::LEVEL_TV,
+ ConvMatrix::LEVEL_PC
+ };
+ const int type_map[3] = {
+ ConvMatrix::COLOR_YUV_601,
+ ConvMatrix::COLOR_YUV_601,
+ ConvMatrix::COLOR_YUV_709
+
+ };
+ //level_map[ColorConvTable::RANGE_NONE] = ConvMatrix::LEVEL_TV;
+ //level_map[ColorConvTable::RANGE_TV] = ConvMatrix::LEVEL_TV;
+ //level_map[ColorConvTable::RANGE_PC] = ConvMatrix::LEVEL_PC;
+ //type_map[ColorConvTable::NONE] = ConvMatrix::COLOR_YUV_601;
+ //type_map[ColorConvTable::BT601] = ConvMatrix::COLOR_YUV_601;
+ //type_map[ColorConvTable::BT709] = ConvMatrix::COLOR_YUV_709;
+ if (in_type == out_type) {
+ if (in_range == RANGE_PC && out_range == RANGE_TV) {
+ return A8Y8U8V8_PC_To_TV(a8, y8, u8, v8);
+ } else if (in_range == RANGE_TV && out_range == RANGE_PC) {
+ return A8Y8U8V8_TV_To_PC(a8, y8, u8, v8);
+ } else {
+ return (a8 << 24) | (y8 << 16) | (u8 << 8) | v8;
+ }
+ }
+ return (a8 << 24) | ConvFuncInst().m_convMatrix.Convert(y8, u8, v8,
+ level_map[in_range], type_map[in_type], level_map[out_range], type_map[out_type]);
+}
+
+DWORD ColorConvTable::A8Y8U8V8_TO_CUR_AYUV(int a8, int y8, int u8, int v8, YuvRangeType in_range, YuvMatrixType in_type)
+{
+ return A8Y8U8V8_TO_AYUV(a8, y8, u8, v8, in_range, in_type,
+ ConvFuncInst().m_eRangeType, ConvFuncInst().m_eYuvType);
+}
+
+DWORD ColorConvTable::A8Y8U8V8_TO_ARGB(int a8, int y8, int u8, int v8, YuvMatrixType in_type)
+{
+ const ConvFunc::Y8U8V8ToRGBFunc funcs[2][2][2] = {
+ {
+ { YUV_TV_TO_RGB_TV_601, YUV_TV_TO_RGB_PC_601 },
+ { YUV_TV_TO_RGB_TV_709, YUV_TV_TO_RGB_PC_709 }
+ },
+ {
+ { YUV_PC_TO_RGB_TV_601, YUV_PC_TO_RGB_PC_601 },
+ { YUV_PC_TO_RGB_TV_709, YUV_PC_TO_RGB_PC_709 }
+ }
+ };
+ return (a8 << 24) | funcs[ConvFuncInst().m_eRangeType == RANGE_PC ? 1 : 0][in_type == BT709 ? 1 : 0][ConvFuncInst().m_bOutputTVRange ? 0 : 1](y8, u8, v8);
+}
+
+DWORD ColorConvTable::ColorCorrection(DWORD argb)
+{
+ if (ConvFuncInst().m_bVSFilterCorrection) {
+ int r = (argb & 0x00ff0000) >> 16;
+ int g = (argb & 0x0000ff00) >> 8;
+ int b = (argb & 0x000000ff);
+ return (argb & 0xff000000) |
+ ConvFuncInst().m_convMatrix.ColorCorrection(r, g, b,
+ ConvFuncInst().m_bOutputTVRange ? ConvMatrix::LEVEL_TV : ConvMatrix::LEVEL_PC);
+ }
+ return argb;
+}
+
+struct YuvPos {
+ int y;
+ int u;
+ int v;
+};
+const YuvPos POS_YUV = { 16, 8, 0 };
+const YuvPos POS_UYV = { 8, 16, 0 };
+
+
+DEFINE_RGB2YUV_FUNC(RGB_PC_TO_YUV_TV_601, RGB_LVL_PC, YUV_LVL_TV, 0.299, 0.587, 0.114, POS_YUV)
+DEFINE_RGB2YUV_FUNC(RGB_PC_TO_YUV_PC_601, RGB_LVL_PC, YUV_LVL_PC, 0.299, 0.587, 0.114, POS_YUV)
+DEFINE_RGB2YUV_FUNC(RGB_PC_TO_YUV_TV_709, RGB_LVL_PC, YUV_LVL_TV, 0.2126, 0.7152, 0.0722, POS_YUV)
+DEFINE_RGB2YUV_FUNC(RGB_PC_TO_YUV_PC_709, RGB_LVL_PC, YUV_LVL_PC, 0.2126, 0.7152, 0.0722, POS_YUV)
+
+DEFINE_RGB2YUV_FUNC(RGB_TV_TO_YUV_TV_601, RGB_LVL_TV, YUV_LVL_TV, 0.299, 0.587, 0.114, POS_YUV)
+DEFINE_RGB2YUV_FUNC(RGB_TV_TO_YUV_PC_601, RGB_LVL_TV, YUV_LVL_PC, 0.299, 0.587, 0.114, POS_YUV)
+DEFINE_RGB2YUV_FUNC(RGB_TV_TO_YUV_TV_709, RGB_LVL_TV, YUV_LVL_TV, 0.2126, 0.7152, 0.0722, POS_YUV)
+DEFINE_RGB2YUV_FUNC(RGB_TV_TO_YUV_PC_709, RGB_LVL_TV, YUV_LVL_PC, 0.2126, 0.7152, 0.0722, POS_YUV)
+
+DEFINE_RGB2YUV_FUNC(RGB_PC_TO_UYV_TV_601, RGB_LVL_PC, YUV_LVL_TV, 0.299, 0.587, 0.114, POS_UYV)
+DEFINE_RGB2YUV_FUNC(RGB_PC_TO_UYV_PC_601, RGB_LVL_PC, YUV_LVL_PC, 0.299, 0.587, 0.114, POS_UYV)
+DEFINE_RGB2YUV_FUNC(RGB_PC_TO_UYV_TV_709, RGB_LVL_PC, YUV_LVL_TV, 0.2126, 0.7152, 0.0722, POS_UYV)
+DEFINE_RGB2YUV_FUNC(RGB_PC_TO_UYV_PC_709, RGB_LVL_PC, YUV_LVL_PC, 0.2126, 0.7152, 0.0722, POS_UYV)
+
+DEFINE_RGB2YUV_FUNC(RGB_TV_TO_UYV_TV_601, RGB_LVL_TV, YUV_LVL_TV, 0.299, 0.587, 0.114, POS_UYV)
+DEFINE_RGB2YUV_FUNC(RGB_TV_TO_UYV_PC_601, RGB_LVL_TV, YUV_LVL_PC, 0.299, 0.587, 0.114, POS_UYV)
+DEFINE_RGB2YUV_FUNC(RGB_TV_TO_UYV_TV_709, RGB_LVL_TV, YUV_LVL_TV, 0.2126, 0.7152, 0.0722, POS_UYV)
+DEFINE_RGB2YUV_FUNC(RGB_TV_TO_UYV_PC_709, RGB_LVL_TV, YUV_LVL_PC, 0.2126, 0.7152, 0.0722, POS_UYV)
+
+DEFINE_YUV2RGB_FUNC(YUV_TV_TO_RGB_PC_601, RGB_LVL_PC, YUV_LVL_TV, 0.299, 0.587, 0.114)
+DEFINE_YUV2RGB_FUNC(YUV_PC_TO_RGB_PC_601, RGB_LVL_PC, YUV_LVL_PC, 0.299, 0.587, 0.114)
+DEFINE_YUV2RGB_FUNC(YUV_TV_TO_RGB_PC_709, RGB_LVL_PC, YUV_LVL_TV, 0.2126, 0.7152, 0.0722)
+DEFINE_YUV2RGB_FUNC(YUV_PC_TO_RGB_PC_709, RGB_LVL_PC, YUV_LVL_PC, 0.2126, 0.7152, 0.0722)
+
+DEFINE_YUV2RGB_FUNC(YUV_TV_TO_RGB_TV_601, RGB_LVL_TV, YUV_LVL_TV, 0.299, 0.587, 0.114)
+DEFINE_YUV2RGB_FUNC(YUV_PC_TO_RGB_TV_601, RGB_LVL_TV, YUV_LVL_PC, 0.299, 0.587, 0.114)
+DEFINE_YUV2RGB_FUNC(YUV_TV_TO_RGB_TV_709, RGB_LVL_TV, YUV_LVL_TV, 0.2126, 0.7152, 0.0722)
+DEFINE_YUV2RGB_FUNC(YUV_PC_TO_RGB_TV_709, RGB_LVL_TV, YUV_LVL_PC, 0.2126, 0.7152, 0.0722)
+
+DEFINE_PREMUL_ARGB2AYUV_FUNC(PREMUL_ARGB_PC_TO_AYUV_TV_601, RGB_LVL_PC, YUV_LVL_TV, 0.299, 0.587, 0.114, POS_YUV)
+DEFINE_PREMUL_ARGB2AYUV_FUNC(PREMUL_ARGB_PC_TO_AYUV_PC_601, RGB_LVL_PC, YUV_LVL_PC, 0.299, 0.587, 0.114, POS_YUV)
+DEFINE_PREMUL_ARGB2AYUV_FUNC(PREMUL_ARGB_PC_TO_AYUV_TV_709, RGB_LVL_PC, YUV_LVL_TV, 0.2126, 0.7152, 0.0722, POS_YUV)
+DEFINE_PREMUL_ARGB2AYUV_FUNC(PREMUL_ARGB_PC_TO_AYUV_PC_709, RGB_LVL_PC, YUV_LVL_PC, 0.2126, 0.7152, 0.0722, POS_YUV)
+
+DEFINE_PREMUL_ARGB2AYUV_FUNC(PREMUL_ARGB_TV_TO_AYUV_TV_601, RGB_LVL_TV, YUV_LVL_TV, 0.299, 0.587, 0.114, POS_YUV)
+DEFINE_PREMUL_ARGB2AYUV_FUNC(PREMUL_ARGB_TV_TO_AYUV_PC_601, RGB_LVL_TV, YUV_LVL_PC, 0.299, 0.587, 0.114, POS_YUV)
+DEFINE_PREMUL_ARGB2AYUV_FUNC(PREMUL_ARGB_TV_TO_AYUV_TV_709, RGB_LVL_TV, YUV_LVL_TV, 0.2126, 0.7152, 0.0722, POS_YUV)
+DEFINE_PREMUL_ARGB2AYUV_FUNC(PREMUL_ARGB_TV_TO_AYUV_PC_709, RGB_LVL_TV, YUV_LVL_PC, 0.2126, 0.7152, 0.0722, POS_YUV)
+
+DEFINE_RGB2Y_FUNC(RGB_PC_TO_Y_TV_601, RGB_LVL_PC, YUV_LVL_TV, 0.299, 0.587, 0.114)
+DEFINE_RGB2Y_FUNC(RGB_PC_TO_Y_PC_601, RGB_LVL_PC, YUV_LVL_PC, 0.299, 0.587, 0.114)
+DEFINE_RGB2Y_FUNC(RGB_PC_TO_Y_TV_709, RGB_LVL_PC, YUV_LVL_TV, 0.2126, 0.7152, 0.0722)
+DEFINE_RGB2Y_FUNC(RGB_PC_TO_Y_PC_709, RGB_LVL_PC, YUV_LVL_PC, 0.2126, 0.7152, 0.0722)
+
+DEFINE_RGB2Y_FUNC(RGB_TV_TO_Y_TV_601, RGB_LVL_TV, YUV_LVL_TV, 0.299, 0.587, 0.114)
+DEFINE_RGB2Y_FUNC(RGB_TV_TO_Y_PC_601, RGB_LVL_TV, YUV_LVL_PC, 0.299, 0.587, 0.114)
+DEFINE_RGB2Y_FUNC(RGB_TV_TO_Y_TV_709, RGB_LVL_TV, YUV_LVL_TV, 0.2126, 0.7152, 0.0722)
+DEFINE_RGB2Y_FUNC(RGB_TV_TO_Y_PC_709, RGB_LVL_TV, YUV_LVL_PC, 0.2126, 0.7152, 0.0722)
diff --git a/src/Subtitles/ColorConvTable.h b/src/Subtitles/ColorConvTable.h
new file mode 100644
index 00000000000..36d2178261e
--- /dev/null
+++ b/src/Subtitles/ColorConvTable.h
@@ -0,0 +1,69 @@
+/*
+* (C) 2015 see Authors.txt
+*
+* This file is part of MPC-HC.
+*
+* MPC-HC is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* MPC-HC is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+*/
+
+#pragma once
+
+struct ColorConvTable {
+ enum YuvMatrixType {
+ NONE,
+ BT601,
+ BT709
+ };
+
+ enum YuvRangeType {
+ RANGE_NONE,
+ RANGE_TV,
+ RANGE_PC
+ };
+
+ static void SetDefaultConvType(YuvMatrixType yuv_type, YuvRangeType range, bool bOutputTVRange, bool bVSFilterCorrection);
+
+ static YuvMatrixType GetDefaultYUVType();
+ static YuvRangeType GetDefaultRangeType();
+
+ static DWORD Argb2Ayuv(DWORD argb);
+ static DWORD Argb2Ayuv_TV_BT601(DWORD argb);
+ static DWORD Argb2Auyv(DWORD argb);
+ static DWORD Ayuv2Auyv(DWORD ayuv);
+ static DWORD Rgb2Y(int r8, int g8, int b8);
+ static DWORD PreMulArgb2Ayuv(int a8, int r8, int g8, int b8);
+
+ static DWORD Ayuv2Argb(DWORD ayuv);
+ static DWORD Ayuv2Argb_TV_BT601(DWORD ayuv);
+ static DWORD A8Y8U8V8_To_ARGB_TV_BT601(int a8, int y8, int u8, int v8);
+ static DWORD A8Y8U8V8_To_ARGB_PC_BT601(int a8, int y8, int u8, int v8);
+ static DWORD Ayuv2Argb_TV_BT709(DWORD ayuv);
+ static DWORD A8Y8U8V8_To_ARGB_TV_BT709(int a8, int y8, int u8, int v8);
+ static DWORD A8Y8U8V8_To_ARGB_PC_BT709(int a8, int y8, int u8, int v8);
+
+ static DWORD A8Y8U8V8_PC_To_TV(int a8, int y8, int u8, int v8);
+ static DWORD A8Y8U8V8_TV_To_PC(int a8, int y8, int u8, int v8);
+
+ //should not past NONE into it
+ static DWORD A8Y8U8V8_TO_AYUV(int a8, int y8, int u8, int v8, YuvRangeType in_range, YuvMatrixType in_type, YuvRangeType out_range, YuvMatrixType out_type);
+ static DWORD A8Y8U8V8_TO_CUR_AYUV(int a8, int y8, int u8, int v8, YuvRangeType in_range, YuvMatrixType in_type);
+ static DWORD A8Y8U8V8_TO_ARGB(int a8, int y8, int u8, int v8, YuvMatrixType in_type);
+
+ static DWORD RGB_PC_TO_TV(DWORD argb);
+
+ static DWORD ColorCorrection(DWORD argb);
+
+ ColorConvTable() = delete;
+};
diff --git a/src/Subtitles/CompositionObject.cpp b/src/Subtitles/CompositionObject.cpp
index 2f4094d2221..4993a790e03 100644
--- a/src/Subtitles/CompositionObject.cpp
+++ b/src/Subtitles/CompositionObject.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2009-2014 see Authors.txt
+ * (C) 2009-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -20,6 +20,7 @@
#include "stdafx.h"
#include "CompositionObject.h"
+#include "ColorConvTable.h"
#include "../DSUtil/GolombBuffer.h"
@@ -82,15 +83,11 @@ void CompositionObject::Reset()
Init();
}
-void CompositionObject::SetPalette(int nNbEntry, const HDMV_PALETTE* pPalette, bool BT709, int sourceBlackLevel, int sourceWhiteLevel, int targetBlackLevel, int targetWhiteLevel)
+void CompositionObject::SetPalette(int nNbEntry, const HDMV_PALETTE* pPalette, ColorConvTable::YuvMatrixType currentMatrix)
{
m_nColorNumber = nNbEntry;
for (int i = 0; i < nNbEntry; i++) {
- if (BT709) {
- m_colors[pPalette[i].entry_id] = YCrCbToRGB_Rec709(pPalette[i].T, pPalette[i].Y, pPalette[i].Cr, pPalette[i].Cb, sourceBlackLevel, sourceWhiteLevel, targetBlackLevel, targetWhiteLevel);
- } else {
- m_colors[pPalette[i].entry_id] = YCrCbToRGB_Rec601(pPalette[i].T, pPalette[i].Y, pPalette[i].Cr, pPalette[i].Cb, sourceBlackLevel, sourceWhiteLevel, targetBlackLevel, targetWhiteLevel);
- }
+ m_colors[pPalette[i].entry_id] = ColorConvTable::A8Y8U8V8_TO_ARGB(pPalette[i].T, pPalette[i].Y, pPalette[i].Cb, pPalette[i].Cr, currentMatrix);
}
}
@@ -200,6 +197,12 @@ void CompositionObject::DvbRenderField(SubPicDesc& spd, CGolombBuffer& gb, short
short nX = nXStart;
short nY = nYStart;
size_t nEnd = gb.GetPos() + nLength;
+ if (nEnd > gb.GetSize()) {
+ // Unexpected end of data, the file is probably corrupted
+ // but try to render the subtitles anyway
+ ASSERT(FALSE);
+ nEnd = gb.GetSize();
+ }
while (gb.GetPos() < nEnd) {
BYTE bType = gb.ReadByte();
@@ -272,11 +275,6 @@ void CompositionObject::Dvb2PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb,
}
}
- if (nX + nCount > m_width) {
- ASSERT(FALSE);
- break;
- }
-
if (nCount > 0) {
FillSolidRect(spd, nX, nY, nCount, 1, m_colors[nPaletteIndex]);
nX += nCount;
@@ -330,13 +328,6 @@ void CompositionObject::Dvb4PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb,
}
}
-#if 0
- if (nX + nCount > m_width) {
- ASSERT(FALSE);
- break;
- }
-#endif
-
if (nCount > 0) {
FillSolidRect(spd, nX, nY, nCount, 1, m_colors[nPaletteIndex]);
nX += nCount;
@@ -369,11 +360,6 @@ void CompositionObject::Dvb8PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb,
}
}
- if (nX + nCount > m_width) {
- ASSERT(FALSE);
- break;
- }
-
if (nCount > 0) {
FillSolidRect(spd, nX, nY, nCount, 1, m_colors[nPaletteIndex]);
nX += nCount;
diff --git a/src/Subtitles/CompositionObject.h b/src/Subtitles/CompositionObject.h
index 1d2bf1a1b04..767ef4630ed 100644
--- a/src/Subtitles/CompositionObject.h
+++ b/src/Subtitles/CompositionObject.h
@@ -1,5 +1,5 @@
/*
- * (C) 2009-2014 see Authors.txt
+ * (C) 2009-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -21,6 +21,7 @@
#pragma once
#include "Rasterizer.h"
+#include "ColorConvTable.h"
struct HDMV_PALETTE {
@@ -68,7 +69,7 @@ class CompositionObject : Rasterizer
void RenderHdmv(SubPicDesc& spd);
void RenderDvb(SubPicDesc& spd, short nX, short nY);
void WriteSeg(SubPicDesc& spd, short nX, short nY, short nCount, short nPaletteIndex);
- void SetPalette(int nNbEntry, const HDMV_PALETTE* pPalette, bool BT709, int sourceBlackLevel, int sourceWhiteLevel, int targetBlackLevel, int targetWhiteLevel);
+ void SetPalette(int nNbEntry, const HDMV_PALETTE* pPalette, ColorConvTable::YuvMatrixType currentMatrix);
bool HavePalette() const { return m_nColorNumber > 0; };
// Forbid the use of direct affectation for now, it would be dangerous because
diff --git a/src/Subtitles/DVBSub.cpp b/src/Subtitles/DVBSub.cpp
index 3c2315647e2..c5d453a0a43 100644
--- a/src/Subtitles/DVBSub.cpp
+++ b/src/Subtitles/DVBSub.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2009-2014 see Authors.txt
+ * (C) 2009-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -101,40 +101,44 @@ STDMETHODIMP CDVBSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, REC
if (POSITION posPage = FindPage(rt)) {
const auto& pPage = m_pages.GetAt(posPage);
- bool BT709 = m_infoSourceTarget.sourceMatrix == BT_709 ? true : m_infoSourceTarget.sourceMatrix == NONE ? (m_displayInfo.width > 720) : false;
+ m_eSourceMatrix = ColorConvTable::NONE ? (m_displayInfo.width > 720) ? ColorConvTable::BT709 : ColorConvTable::BT601 : m_eSourceMatrix;
pPage->rendered = true;
TRACE_DVB(_T("DVB - Renderer - %s - %s\n"), ReftimeToString(pPage->rtStart), ReftimeToString(pPage->rtStop));
- int nRegion = 1, nObject = 1;
- for (POSITION pos = pPage->regionsPos.GetHeadPosition(); pos; nRegion++) {
- DVB_REGION_POS regionPos = pPage->regionsPos.GetNext(pos);
+ size_t nRegion = 1;
+ for (const auto& regionPos : pPage->regionsPos) {
+ auto itRegion = FindRegion(pPage, regionPos.id);
+ if (itRegion != pPage->regions.cend()) {
+ const auto& pRegion = *itRegion;
+ auto itCLUT = FindClut(pPage, pRegion->CLUT_id);
- if (POSITION posRegion = FindRegion(pPage, regionPos.id)) {
- const auto& pRegion = pPage->regions.GetAt(posRegion);
+ if (itCLUT != pPage->CLUTs.cend()) {
+ const auto& pCLUT = *itCLUT;
- if (POSITION posCLUT = FindClut(pPage, pRegion->CLUT_id)) {
- const auto& pCLUT = pPage->CLUTs.GetAt(posCLUT);
+ size_t nObject = 1;
+ for (const auto& objectPos : pRegion->objects) {
+ auto itObject = FindObject(pPage, objectPos.object_id);
- for (POSITION posO = pRegion->objects.GetHeadPosition(); posO; nObject++) {
- DVB_OBJECT objectPos = pRegion->objects.GetNext(posO);
-
- if (POSITION posObject = FindObject(pPage, objectPos.object_id)) {
- const auto& pObject = pPage->objects.GetAt(posObject);
+ if (itObject != pPage->objects.cend()) {
+ const auto& pObject = *itObject;
short nX = regionPos.horizAddr + objectPos.object_horizontal_position;
short nY = regionPos.vertAddr + objectPos.object_vertical_position;
pObject->m_width = pRegion->width;
pObject->m_height = pRegion->height;
- pObject->SetPalette(pCLUT->size, pCLUT->palette, BT709,
- m_infoSourceTarget.sourceBlackLevel, m_infoSourceTarget.sourceWhiteLevel, m_infoSourceTarget.targetBlackLevel, m_infoSourceTarget.targetWhiteLevel);
+ pObject->SetPalette(pCLUT->size, pCLUT->palette.data(), m_eSourceMatrix);
pObject->RenderDvb(spd, nX, nY);
- TRACE_DVB(_T(" --> %d/%d - %d/%d\n"), nRegion, pPage->regionsPos.GetCount(), nObject, pRegion->objects.GetCount());
+ TRACE_DVB(_T(" --> %Iu/%Iu - %Iu/%Iu\n"), nRegion, pPage->regionsPos.size(), nObject, pRegion->objects.size());
}
+
+ nObject++;
}
}
}
+
+ nRegion++;
}
bbox.left = 0;
@@ -285,16 +289,16 @@ HRESULT CDVBSub::ParseSample(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BYTE
// Copy data from the previous page
const auto& pPrevPage = m_pages.GetTail();
- for (POSITION pos = pPrevPage->regions.GetHeadPosition(); pos;) {
- m_pCurrentPage->regions.AddTail(CAutoPtr(DEBUG_NEW DVB_REGION(*pPrevPage->regions.GetNext(pos))));
+ for (const auto& region : pPrevPage->regions) {
+ m_pCurrentPage->regions.emplace_back(DEBUG_NEW DVB_REGION(*region));
}
- for (POSITION pos = pPrevPage->objects.GetHeadPosition(); pos;) {
- m_pCurrentPage->objects.AddTail(CAutoPtr(DEBUG_NEW CompositionObject(*pPrevPage->objects.GetNext(pos))));
+ for (const auto& object : pPrevPage->objects) {
+ m_pCurrentPage->objects.emplace_back(DEBUG_NEW CompositionObject(*object));
}
- for (POSITION pos = pPrevPage->CLUTs.GetHeadPosition(); pos;) {
- m_pCurrentPage->CLUTs.AddTail(CAutoPtr(DEBUG_NEW DVB_CLUT(*pPrevPage->CLUTs.GetNext(pos))));
+ for (const auto& CLUT : pPrevPage->CLUTs) {
+ m_pCurrentPage->CLUTs.emplace_back(DEBUG_NEW DVB_CLUT(*CLUT));
}
TRACE_DVB(_T("DVB - Page started [update] %s, TimeOut = %ds\n"),
@@ -421,55 +425,28 @@ POSITION CDVBSub::FindPage(REFERENCE_TIME rt) const
return nullptr;
}
-POSITION CDVBSub::FindRegion(const CAutoPtr& pPage, BYTE bRegionId) const
+CDVBSub::RegionList::const_iterator CDVBSub::FindRegion(const CAutoPtr& pPage, BYTE bRegionId) const
{
- if (pPage != nullptr) {
- POSITION pos = pPage->regions.GetHeadPosition();
+ ENSURE(pPage);
- while (pos) {
- POSITION currentPos = pos;
- const auto& pRegion = pPage->regions.GetNext(pos);
-
- if (pRegion->id == bRegionId) {
- return currentPos;
- }
- }
- }
- return nullptr;
+ return std::find_if(pPage->regions.cbegin(), pPage->regions.cend(),
+ [bRegionId](const std::unique_ptr& pRegion) { return pRegion->id == bRegionId; });
}
-POSITION CDVBSub::FindClut(const CAutoPtr& pPage, BYTE bClutId) const
+CDVBSub::ClutList::const_iterator CDVBSub::FindClut(const CAutoPtr& pPage, BYTE bClutId) const
{
- if (pPage != nullptr) {
- POSITION pos = pPage->CLUTs.GetHeadPosition();
+ ENSURE(pPage);
- while (pos) {
- POSITION currentPos = pos;
- const auto& pCLUT = pPage->CLUTs.GetNext(pos);
-
- if (pCLUT->id == bClutId) {
- return currentPos;
- }
- }
- }
- return nullptr;
+ return std::find_if(pPage->CLUTs.cbegin(), pPage->CLUTs.cend(),
+ [bClutId](const std::unique_ptr& pCLUT) { return pCLUT->id == bClutId; });
}
-POSITION CDVBSub::FindObject(const CAutoPtr& pPage, short sObjectId) const
+CDVBSub::CompositionObjectList::const_iterator CDVBSub::FindObject(const CAutoPtr& pPage, short sObjectId) const
{
- if (pPage != nullptr) {
- POSITION pos = pPage->objects.GetHeadPosition();
+ ENSURE(pPage);
- while (pos) {
- POSITION currentPos = pos;
- const auto& pObject = pPage->objects.GetNext(pos);
-
- if (pObject->m_object_id_ref == sObjectId) {
- return currentPos;
- }
- }
- }
- return nullptr;
+ return std::find_if(pPage->objects.cbegin(), pPage->objects.cend(),
+ [sObjectId](const std::unique_ptr& pObject) { return pObject->m_object_id_ref == sObjectId; });
}
HRESULT CDVBSub::ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr& pPage)
@@ -477,7 +454,7 @@ HRESULT CDVBSub::ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr(DEBUG_NEW DVB_PAGE());
+ pPage.Attach(DEBUG_NEW DVB_PAGE());
pPage->pageTimeOut = gb.ReadByte();
pPage->pageVersionNumber = (BYTE)gb.BitRead(4);
@@ -490,7 +467,7 @@ HRESULT CDVBSub::ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtrregionsPos.AddTail(regionPos);
+ pPage->regionsPos.emplace_back(std::move(regionPos));
}
return (wSegLength == nExpectedSize) ? S_OK : E_UNEXPECTED;
@@ -525,11 +502,12 @@ HRESULT CDVBSub::ParseRegion(CGolombBuffer& gb, WORD wSegLength)
size_t nEnd = gb.GetPos() + wSegLength;
BYTE id = gb.ReadByte();
- POSITION posRegion = FindRegion(m_pCurrentPage, id);
- if (!posRegion) {
- posRegion = m_pCurrentPage->regions.AddTail(CAutoPtr(DEBUG_NEW DVB_REGION()));
+ auto itRegion = FindRegion(m_pCurrentPage, id);
+ if (itRegion == m_pCurrentPage->regions.cend()) {
+ m_pCurrentPage->regions.emplace_back(DEBUG_NEW DVB_REGION());
+ itRegion = std::prev(m_pCurrentPage->regions.cend());
}
- const auto& pRegion = m_pCurrentPage->regions.GetAt(posRegion);
+ const auto& pRegion = *itRegion;
pRegion->id = id;
pRegion->version_number = (BYTE)gb.BitRead(4);
@@ -560,7 +538,7 @@ HRESULT CDVBSub::ParseRegion(CGolombBuffer& gb, WORD wSegLength)
object.foreground_pixel_code = gb.ReadByte();
object.background_pixel_code = gb.ReadByte();
}
- pRegion->objects.AddTail(object);
+ pRegion->objects.emplace_back(std::move(object));
}
hr = (wSegLength == nExpectedSize) ? S_OK : E_UNEXPECTED;
@@ -578,11 +556,12 @@ HRESULT CDVBSub::ParseClut(CGolombBuffer& gb, WORD wSegLength)
size_t nEnd = gb.GetPos() + wSegLength;
BYTE id = gb.ReadByte();
- POSITION posClut = FindClut(m_pCurrentPage, id);
- if (!posClut) {
- posClut = m_pCurrentPage->CLUTs.AddTail(CAutoPtr(DEBUG_NEW DVB_CLUT()));
+ auto itClut = FindClut(m_pCurrentPage, id);
+ if (itClut == m_pCurrentPage->CLUTs.cend()) {
+ m_pCurrentPage->CLUTs.emplace_back(DEBUG_NEW DVB_CLUT());
+ itClut = std::prev(m_pCurrentPage->CLUTs.cend());
}
- const auto& pClut = m_pCurrentPage->CLUTs.GetAt(posClut);
+ const auto& pClut = *itClut;
pClut->id = id;
pClut->version_number = (BYTE)gb.BitRead(4);
@@ -635,14 +614,15 @@ HRESULT CDVBSub::ParseObject(CGolombBuffer& gb, WORD wSegLength)
if (m_pCurrentPage) {
size_t nExpectedSize = 3;
- size_t nEnd = gb.GetPos() + wSegLength;
+ // size_t nEnd = gb.GetPos() + wSegLength;
short id = gb.ReadShort();
- POSITION posObject = FindObject(m_pCurrentPage, id);
- if (!posObject) {
- posObject = m_pCurrentPage->objects.AddTail(CAutoPtr(DEBUG_NEW CompositionObject()));
+ auto itObject = FindObject(m_pCurrentPage, id);
+ if (itObject == m_pCurrentPage->objects.cend()) {
+ m_pCurrentPage->objects.emplace_back(DEBUG_NEW CompositionObject());
+ itObject = std::prev(m_pCurrentPage->objects.cend());
}
- const auto& pObject = m_pCurrentPage->objects.GetAt(posObject);
+ const auto& pObject = *itObject;
pObject->m_object_id_ref = id;
pObject->m_version_number = (BYTE)gb.BitRead(4);
@@ -658,7 +638,7 @@ HRESULT CDVBSub::ParseObject(CGolombBuffer& gb, WORD wSegLength)
hr = (wSegLength >= nExpectedSize) ? S_OK : E_UNEXPECTED;
} else {
TRACE_DVB(_T("DVB - Text subtitles are currently not supported\n"));
- m_pCurrentPage->objects.RemoveTail();
+ m_pCurrentPage->objects.pop_back();
hr = E_NOTIMPL;
}
}
@@ -704,10 +684,11 @@ void CDVBSub::RemoveOldPages(REFERENCE_TIME rt)
{
// Cleanup the old pages. We keep a 2 min buffer to play nice with the queue.
while (!m_pages.IsEmpty() && m_pages.GetHead()->rtStop + 120 * 10000000i64 < rt) {
- auto pPage = m_pages.RemoveHead();
+ const auto& pPage = m_pages.GetHead();
if (!pPage->rendered) {
TRACE_DVB(_T("DVB - remove unrendered object, %s - %s\n"),
ReftimeToString(pPage->rtStart), ReftimeToString(pPage->rtStop));
}
+ m_pages.RemoveHeadNoReturn();
}
}
diff --git a/src/Subtitles/DVBSub.h b/src/Subtitles/DVBSub.h
index bbfba28d9cc..e2be340502a 100644
--- a/src/Subtitles/DVBSub.h
+++ b/src/Subtitles/DVBSub.h
@@ -1,5 +1,5 @@
/*
- * (C) 2009-2014 see Authors.txt
+ * (C) 2009-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -22,6 +22,8 @@
#include "RLECodedSubtitle.h"
#include "CompositionObject.h"
+#include
+#include
class CGolombBuffer;
@@ -71,141 +73,77 @@ class CDVBSub : public CRLECodedSubtitle
};
struct DVB_CLUT {
- BYTE id;
- BYTE version_number;
- BYTE size;
+ BYTE id = 0;
+ BYTE version_number = 0;
+ BYTE size = 0;
- HDMV_PALETTE palette[256];
+ std::array palette;
DVB_CLUT()
- : id(0)
- , version_number(0)
- , size(0) {
- ZeroMemory(palette, sizeof(palette));
+ : palette() {
}
};
struct DVB_DISPLAY {
- BYTE version_number;
- BYTE display_window_flag;
- short width;
- short height;
- short horizontal_position_minimun;
- short horizontal_position_maximum;
- short vertical_position_minimun;
- short vertical_position_maximum;
-
- DVB_DISPLAY()
// Default value (section 5.1.3)
- : version_number(0)
- , display_window_flag(0)
- , width(720)
- , height(576)
- , horizontal_position_minimun(0)
- , horizontal_position_maximum(0)
- , vertical_position_minimun(0)
- , vertical_position_maximum(0) {
- }
+ BYTE version_number = 0;
+ BYTE display_window_flag = 0;
+ short width = 720;
+ short height = 576;
+ short horizontal_position_minimun = 0;
+ short horizontal_position_maximum = 0;
+ short vertical_position_minimun = 0;
+ short vertical_position_maximum = 0;
};
struct DVB_OBJECT {
- short object_id;
- BYTE object_type;
- BYTE object_provider_flag;
- short object_horizontal_position;
- short object_vertical_position;
- BYTE foreground_pixel_code;
- BYTE background_pixel_code;
-
- DVB_OBJECT()
- : object_id(0xFF)
- , object_type(0)
- , object_provider_flag(0)
- , object_horizontal_position(0)
- , object_vertical_position(0)
- , foreground_pixel_code(0)
- , background_pixel_code(0) {
- }
+ short object_id = 0;
+ BYTE object_type = 0;
+ BYTE object_provider_flag = 0;
+ short object_horizontal_position = 0;
+ short object_vertical_position = 0;
+ BYTE foreground_pixel_code = 0;
+ BYTE background_pixel_code = 0;
};
struct DVB_REGION_POS {
- BYTE id;
- WORD horizAddr;
- WORD vertAddr;
-
- DVB_REGION_POS()
- : id(0)
- , horizAddr(0)
- , vertAddr(0) {
- }
+ BYTE id = 0;
+ WORD horizAddr = 0;
+ WORD vertAddr = 0;
};
struct DVB_REGION {
- BYTE id;
- BYTE version_number;
- BYTE fill_flag;
- WORD width;
- WORD height;
- BYTE level_of_compatibility;
- BYTE depth;
- BYTE CLUT_id;
- BYTE _8_bit_pixel_code;
- BYTE _4_bit_pixel_code;
- BYTE _2_bit_pixel_code;
- CAtlList objects;
-
- DVB_REGION()
- : id(0)
- , version_number(0)
- , fill_flag(0)
- , width(0)
- , height(0)
- , level_of_compatibility(0)
- , depth(0)
- , CLUT_id(0)
- , _8_bit_pixel_code(0)
- , _4_bit_pixel_code(0)
- , _2_bit_pixel_code(0) {
- }
-
- DVB_REGION(const CDVBSub::DVB_REGION& region)
- : id(region.id)
- , version_number(region.version_number)
- , fill_flag(region.fill_flag)
- , width(region.width)
- , height(region.height)
- , level_of_compatibility(region.level_of_compatibility)
- , depth(region.depth)
- , CLUT_id(region.CLUT_id)
- , _8_bit_pixel_code(region._8_bit_pixel_code)
- , _4_bit_pixel_code(region._4_bit_pixel_code)
- , _2_bit_pixel_code(region._2_bit_pixel_code) {
- objects.AddHeadList(®ion.objects);
- }
+ BYTE id = 0;
+ BYTE version_number = 0;
+ BYTE fill_flag = 0;
+ WORD width = 0;
+ WORD height = 0;
+ BYTE level_of_compatibility = 0;
+ BYTE depth = 0;
+ BYTE CLUT_id = 0;
+ BYTE _8_bit_pixel_code = 0;
+ BYTE _4_bit_pixel_code = 0;
+ BYTE _2_bit_pixel_code = 0;
+ std::list objects;
};
+ using RegionList = std::list>;
+ using CompositionObjectList = std::list>;
+ using ClutList = std::list>;
+
class DVB_PAGE
{
public:
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
- BYTE pageTimeOut;
- BYTE pageVersionNumber;
- BYTE pageState;
- CAtlList regionsPos;
- CAutoPtrList regions;
- CAutoPtrList objects;
- CAutoPtrList CLUTs;
- bool rendered;
-
- DVB_PAGE()
- : rtStart(0)
- , rtStop(0)
- , pageTimeOut(0)
- , pageVersionNumber(0)
- , pageState(0)
- , rendered(false) {
- }
+ REFERENCE_TIME rtStart = 0;
+ REFERENCE_TIME rtStop = 0;
+ BYTE pageTimeOut = 0;
+ BYTE pageVersionNumber = 0;
+ BYTE pageState = 0;
+ std::list regionsPos;
+ RegionList regions;
+ CompositionObjectList objects;
+ ClutList CLUTs;
+ bool rendered = false;
};
size_t m_nBufferSize;
@@ -219,9 +157,9 @@ class CDVBSub : public CRLECodedSubtitle
HRESULT AddToBuffer(BYTE* pData, size_t nSize);
POSITION FindPage(REFERENCE_TIME rt) const;
- POSITION FindRegion(const CAutoPtr& pPage, BYTE bRegionId) const;
- POSITION FindClut(const CAutoPtr& pPage, BYTE bClutId) const;
- POSITION FindObject(const CAutoPtr& pPage, short sObjectId) const;
+ RegionList::const_iterator FindRegion(const CAutoPtr& pPage, BYTE bRegionId) const;
+ ClutList::const_iterator FindClut(const CAutoPtr& pPage, BYTE bClutId) const;
+ CompositionObjectList::const_iterator FindObject(const CAutoPtr& pPage, short sObjectId) const;
HRESULT ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr& pPage);
HRESULT ParseDisplay(CGolombBuffer& gb, WORD wSegLength);
diff --git a/src/Subtitles/PGSSub.cpp b/src/Subtitles/PGSSub.cpp
index 748c2058ec3..3a13e0fee50 100644
--- a/src/Subtitles/PGSSub.cpp
+++ b/src/Subtitles/PGSSub.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -216,8 +216,8 @@ void CPGSSub::Reset()
m_nCurSegment = NO_SEGMENT;
m_pCurrentPresentationSegment.Free();
m_pPresentationSegments.RemoveAll();
- for (int i = 0; i < _countof(m_compositionObjects); i++) {
- m_compositionObjects[i].Reset();
+ for (auto& compositionObject : m_compositionObjects) {
+ compositionObject.Reset();
}
}
@@ -247,7 +247,7 @@ HRESULT CPGSSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox, bool bRe
if (posPresentationSegment) {
const auto& pPresentationSegment = m_pPresentationSegments.GetAt(posPresentationSegment);
- bool BT709 = m_infoSourceTarget.sourceMatrix == BT_709 ? true : m_infoSourceTarget.sourceMatrix == NONE ? (pPresentationSegment->video_descriptor.nVideoWidth > 720) : false;
+ m_eSourceMatrix = ColorConvTable::NONE ? (pPresentationSegment->video_descriptor.nVideoWidth > 720) ? ColorConvTable::BT709 : ColorConvTable::BT601 : m_eSourceMatrix;
TRACE_PGSSUB(_T("CPGSSub:Render Presentation segment %d --> %s - %s\n"), pPresentationSegment->composition_descriptor.nNumber,
ReftimeToString(pPresentationSegment->rtStart),
@@ -256,14 +256,10 @@ HRESULT CPGSSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox, bool bRe
bbox.left = bbox.top = LONG_MAX;
bbox.right = bbox.bottom = 0;
- POSITION pos = pPresentationSegment->objects.GetHeadPosition();
- while (pos) {
- const auto& pObject = pPresentationSegment->objects.GetNext(pos);
-
+ for (const auto& pObject : pPresentationSegment->objects) {
if (pObject->GetRLEDataSize() && pObject->m_width > 0 && pObject->m_height > 0
&& spd.w >= (pObject->m_horizontal_position + pObject->m_width) && spd.h >= (pObject->m_vertical_position + pObject->m_height)) {
- pObject->SetPalette(pPresentationSegment->CLUT.size, pPresentationSegment->CLUT.palette, BT709,
- m_infoSourceTarget.sourceBlackLevel, m_infoSourceTarget.sourceWhiteLevel, m_infoSourceTarget.targetBlackLevel, m_infoSourceTarget.targetWhiteLevel);
+ pObject->SetPalette(pPresentationSegment->CLUT.size, pPresentationSegment->CLUT.palette.data(), m_eSourceMatrix);
bbox.left = std::min(pObject->m_horizontal_position, bbox.left);
bbox.top = std::min(pObject->m_vertical_position, bbox.top);
bbox.right = std::max(pObject->m_horizontal_position + pObject->m_width, bbox.right);
@@ -289,7 +285,8 @@ HRESULT CPGSSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox, bool bRe
int CPGSSub::ParsePresentationSegment(REFERENCE_TIME rt, CGolombBuffer* pGBuffer)
{
- m_pCurrentPresentationSegment = CAutoPtr(DEBUG_NEW HDMV_PRESENTATION_SEGMENT());
+ m_pCurrentPresentationSegment.Free();
+ m_pCurrentPresentationSegment.Attach(DEBUG_NEW HDMV_PRESENTATION_SEGMENT());
m_pCurrentPresentationSegment->rtStart = rt;
m_pCurrentPresentationSegment->rtStop = UNKNOWN_TIME; // Unknown for now
@@ -304,9 +301,10 @@ int CPGSSub::ParsePresentationSegment(REFERENCE_TIME rt, CGolombBuffer* pGBuffer
m_pCurrentPresentationSegment->composition_descriptor.bState, m_pCurrentPresentationSegment->objectCount);
for (int i = 0; i < m_pCurrentPresentationSegment->objectCount; i++) {
- CAutoPtr pCompositionObject(DEBUG_NEW CompositionObject());
- ParseCompositionObject(pGBuffer, pCompositionObject);
- m_pCurrentPresentationSegment->objects.AddTail(pCompositionObject);
+ std::unique_ptr pCompositionObject(DEBUG_NEW CompositionObject());
+ if (ParseCompositionObject(pGBuffer, pCompositionObject)) {
+ m_pCurrentPresentationSegment->objects.emplace_back(std::move(pCompositionObject));
+ }
}
return m_pCurrentPresentationSegment->objectCount;
@@ -319,10 +317,7 @@ void CPGSSub::EnqueuePresentationSegment()
m_pCurrentPresentationSegment->CLUT = m_CLUTs[m_pCurrentPresentationSegment->CLUT.id];
// Get the objects' data
- POSITION pos = m_pCurrentPresentationSegment->objects.GetHeadPosition();
- while (pos) {
- const auto& pObject = m_pCurrentPresentationSegment->objects.GetNext(pos);
-
+ for (auto& pObject : m_pCurrentPresentationSegment->objects) {
const CompositionObject& pObjectData = m_compositionObjects[pObject->m_object_id_ref];
pObject->m_width = pObjectData.m_width;
@@ -384,7 +379,10 @@ void CPGSSub::ParsePalette(CGolombBuffer* pGBuffer, size_t nSize) // #497
void CPGSSub::ParseObject(CGolombBuffer* pGBuffer, size_t nUnitSize) // #498
{
short object_id = pGBuffer->ReadShort();
- ASSERT(object_id < _countof(m_compositionObjects));
+ if (object_id < 0 || size_t(object_id) >= m_compositionObjects.size()) {
+ ASSERT(FALSE); // This is not supposed to happen
+ return;
+ }
CompositionObject& pObject = m_compositionObjects[object_id];
@@ -405,12 +403,17 @@ void CPGSSub::ParseObject(CGolombBuffer* pGBuffer, size_t nUnitSize) // #498
}
}
-void CPGSSub::ParseCompositionObject(CGolombBuffer* pGBuffer, const CAutoPtr& pCompositionObject)
+bool CPGSSub::ParseCompositionObject(CGolombBuffer* pGBuffer, const std::unique_ptr& pCompositionObject)
{
- BYTE bTemp;
- pCompositionObject->m_object_id_ref = pGBuffer->ReadShort();
+ short object_id_ref = pGBuffer->ReadShort();
+ if (object_id_ref < 0 || size_t(object_id_ref) >= m_compositionObjects.size()) {
+ ASSERT(FALSE); // This is not supposed to happen
+ return false;
+ }
+
+ pCompositionObject->m_object_id_ref = object_id_ref;
pCompositionObject->m_window_id_ref = pGBuffer->ReadByte();
- bTemp = pGBuffer->ReadByte();
+ BYTE bTemp = pGBuffer->ReadByte();
pCompositionObject->m_object_cropped_flag = !!(bTemp & 0x80);
pCompositionObject->m_forced_on_flag = !!(bTemp & 0x40);
pCompositionObject->m_horizontal_position = pGBuffer->ReadShort();
@@ -422,6 +425,8 @@ void CPGSSub::ParseCompositionObject(CGolombBuffer* pGBuffer, const CAutoPtrm_cropping_width = pGBuffer->ReadShort();
pCompositionObject->m_cropping_height = pGBuffer->ReadShort();
}
+
+ return true;
}
void CPGSSub::ParseVideoDescriptor(CGolombBuffer* pGBuffer, VIDEO_DESCRIPTOR* pVideoDescriptor)
@@ -459,12 +464,12 @@ void CPGSSub::RemoveOldSegments(REFERENCE_TIME rt)
while (!m_pPresentationSegments.IsEmpty()
&& m_pPresentationSegments.GetHead()->rtStop != UNKNOWN_TIME
&& m_pPresentationSegments.GetHead()->rtStop + 120 * 10000000i64 < rt) {
- auto pPresentationSegment = m_pPresentationSegments.RemoveHead();
TRACE_PGSSUB(_T("CPGSSub::RemoveOldSegments Remove presentation segment %d %s => %s (rt=%s)\n"),
- pPresentationSegment->composition_descriptor.nNumber,
- ReftimeToString(pPresentationSegment->rtStart),
- ReftimeToString(pPresentationSegment->rtStop),
+ m_pPresentationSegments.GetHead()->composition_descriptor.nNumber,
+ ReftimeToString(m_pPresentationSegments.GetHead()->rtStart),
+ ReftimeToString(m_pPresentationSegments.GetHead()->rtStop),
ReftimeToString(rt));
+ m_pPresentationSegments.RemoveHeadNoReturn();
}
}
@@ -536,7 +541,7 @@ void CPGSSubFile::ParseFile(CString fn)
headerBuffer.ReadByte(); // segment type
WORD wLenSegment = (WORD)headerBuffer.ReadShort();
- // Let some round to add the segment type and size
+ // Leave some room to add the segment type and size
int nLenData = nExtraSize + wLenSegment;
segBuff.resize(nLenData);
memcpy(segBuff.data(), &header[header.size() - nExtraSize], nExtraSize);
diff --git a/src/Subtitles/PGSSub.h b/src/Subtitles/PGSSub.h
index 09cf4adfafe..ad651caadcc 100644
--- a/src/Subtitles/PGSSub.h
+++ b/src/Subtitles/PGSSub.h
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -23,6 +23,8 @@
#include "RLECodedSubtitle.h"
#include "CompositionObject.h"
#include
+#include
+#include
class CGolombBuffer;
@@ -80,17 +82,14 @@ class CPGSSub : public CRLECodedSubtitle
};
struct HDMV_CLUT {
- BYTE id;
- BYTE version_number;
- BYTE size;
+ BYTE id = 0;
+ BYTE version_number = 0;
+ BYTE size = 0;
- HDMV_PALETTE palette[256];
+ std::array palette;
HDMV_CLUT()
- : id(0)
- , version_number(0)
- , size(0) {
- ZeroMemory(palette, sizeof(palette));
+ : palette() {
}
};
@@ -106,7 +105,7 @@ class CPGSSub : public CRLECodedSubtitle
int objectCount;
- CAutoPtrList objects;
+ std::list> objects;
};
HDMV_SEGMENT_TYPE m_nCurSegment;
@@ -118,8 +117,8 @@ class CPGSSub : public CRLECodedSubtitle
CAutoPtr m_pCurrentPresentationSegment;
CAutoPtrList m_pPresentationSegments;
- HDMV_CLUT m_CLUTs[256];
- CompositionObject m_compositionObjects[64];
+ std::array m_CLUTs;
+ std::array m_compositionObjects;
void AllocSegment(size_t nSize);
int ParsePresentationSegment(REFERENCE_TIME rt, CGolombBuffer* pGBuffer);
@@ -130,7 +129,7 @@ class CPGSSub : public CRLECodedSubtitle
void ParseObject(CGolombBuffer* pGBuffer, size_t nUnitSize);
void ParseVideoDescriptor(CGolombBuffer* pGBuffer, VIDEO_DESCRIPTOR* pVideoDescriptor);
void ParseCompositionDescriptor(CGolombBuffer* pGBuffer, COMPOSITION_DESCRIPTOR* pCompositionDescriptor);
- void ParseCompositionObject(CGolombBuffer* pGBuffer, const CAutoPtr& pCompositionObject);
+ bool ParseCompositionObject(CGolombBuffer* pGBuffer, const std::unique_ptr& pCompositionObject);
POSITION FindPresentationSegment(REFERENCE_TIME rt) const;
diff --git a/src/Subtitles/RLECodedSubtitle.cpp b/src/Subtitles/RLECodedSubtitle.cpp
index 88c8bc71e1d..328f07b3234 100644
--- a/src/Subtitles/RLECodedSubtitle.cpp
+++ b/src/Subtitles/RLECodedSubtitle.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2008-2014 see Authors.txt
+ * (C) 2008-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -101,40 +101,38 @@ STDMETHODIMP CRLECodedSubtitle::Reload()
return S_OK;
}
-HRESULT CRLECodedSubtitle::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CAutoLock cAutoLock(&m_csCritSec);
-
- Reset();
-
- return S_OK;
-}
-
STDMETHODIMP CRLECodedSubtitle::SetSourceTargetInfo(CString yuvMatrix, int targetBlackLevel, int targetWhiteLevel)
{
+ yuvMatrix.Replace(_T(".VSFilter"), _T(""));
int nPos = 0;
CString range = yuvMatrix.Tokenize(_T("."), nPos);
CString matrix = yuvMatrix.Mid(nPos);
- m_infoSourceTarget.sourceBlackLevel = 16;
- m_infoSourceTarget.sourceWhiteLevel = 235;
+ ColorConvTable::YuvRangeType sourceRange = ColorConvTable::RANGE_TV;
if (range == _T("PC")) {
- m_infoSourceTarget.sourceBlackLevel = 0;
- m_infoSourceTarget.sourceWhiteLevel = 255;
+ sourceRange = ColorConvTable::RANGE_PC;
}
if (matrix == _T("709")) {
- m_infoSourceTarget.sourceMatrix = BT_709;
+ m_eSourceMatrix = ColorConvTable::BT709;
} else if (matrix == _T("240M")) {
- m_infoSourceTarget.sourceMatrix = BT_709;
+ m_eSourceMatrix = ColorConvTable::BT709;
} else if (matrix == _T("601")) {
- m_infoSourceTarget.sourceMatrix = BT_601;
+ m_eSourceMatrix = ColorConvTable::BT601;
} else {
- m_infoSourceTarget.sourceMatrix = NONE;
+ m_eSourceMatrix = ColorConvTable::NONE;
}
- m_infoSourceTarget.targetBlackLevel = targetBlackLevel;
- m_infoSourceTarget.targetWhiteLevel = targetWhiteLevel;
+ ColorConvTable::SetDefaultConvType(ColorConvTable::BT601, sourceRange, (targetWhiteLevel < 245), false); // Matrix isn't relevant here.
+
+ return S_OK;
+}
+
+HRESULT CRLECodedSubtitle::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
+{
+ CAutoLock cAutoLock(&m_csCritSec);
+
+ Reset();
return S_OK;
}
diff --git a/src/Subtitles/RLECodedSubtitle.h b/src/Subtitles/RLECodedSubtitle.h
index ac407e54b55..7f5d31e6a6d 100644
--- a/src/Subtitles/RLECodedSubtitle.h
+++ b/src/Subtitles/RLECodedSubtitle.h
@@ -1,5 +1,5 @@
/*
- * (C) 2008-2014 see Authors.txt
+ * (C) 2008-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -21,6 +21,7 @@
#pragma once
#include "../SubPic/SubPicProviderImpl.h"
+#include "ColorConvTable.h"
class __declspec(uuid("FCA68599-C83E-4ea5-94A3-C2E1B0E326B9"))
@@ -47,12 +48,12 @@ class __declspec(uuid("FCA68599-C83E-4ea5-94A3-C2E1B0E326B9"))
STDMETHODIMP_(int) GetStream();
STDMETHODIMP SetStream(int iStream);
STDMETHODIMP Reload();
+ STDMETHODIMP SetSourceTargetInfo(CString yuvMatrix, int targetBlackLevel, int targetWhiteLevel);
virtual HRESULT ParseSample(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BYTE* pData, size_t nLen) PURE;
HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
virtual void EndOfStream() PURE;
virtual void Reset() PURE;
- STDMETHODIMP SetSourceTargetInfo(CString yuvMatrix, int targetBlackLevel, int targetWhiteLevel);
protected:
CCritSec m_csCritSec;
@@ -60,18 +61,5 @@ class __declspec(uuid("FCA68599-C83E-4ea5-94A3-C2E1B0E326B9"))
CString m_name;
LCID m_lcid;
- enum SOURCE_MATRIX {
- NONE,
- BT_709,
- BT_601
- };
-
- struct SourceTarget {
- int sourceBlackLevel = 16;
- int sourceWhiteLevel = 235;
- int targetBlackLevel = 0;
- int targetWhiteLevel = 255;
-
- SOURCE_MATRIX sourceMatrix = NONE;
- } m_infoSourceTarget;
+ ColorConvTable::YuvMatrixType m_eSourceMatrix = ColorConvTable::NONE;
};
diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp
index 778c9c34f1f..934c89b2ed9 100644
--- a/src/Subtitles/RTS.cpp
+++ b/src/Subtitles/RTS.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -23,6 +23,7 @@
#include
#include
#include
+#include "ColorConvTable.h"
#include "RTS.h"
#include "../DSUtil/PathUtils.h"
@@ -605,14 +606,16 @@ bool CPolygon::ParseStr()
};
for (LPCWSTR str = m_str; *str;) {
- // Trim left whitespace
- while (CStringW::StrTraits::IsSpace(*str)) {
+ // Trim any leading invalid characters and whitespace
+ while (*str && !isValidAction(*str)) {
str++;
}
const WCHAR c = *str;
- do {
- str++;
- } while (isValidAction(*str));
+ if (*str) {
+ do {
+ str++;
+ } while (isValidAction(*str));
+ }
switch (c) {
case L'm':
if (!bFoundMove) {
@@ -961,6 +964,7 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo
}
COLORREF shadow = revcolor(w->m_style.colors[3]) | (a << 24);
DWORD sw[6] = {shadow, DWORD_MAX};
+ sw[0] = ColorConvTable::ColorCorrection(sw[0]);
w->Paint(CPoint(x, y), org);
@@ -1000,6 +1004,7 @@ CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CP
}
COLORREF outline = revcolor(w->m_style.colors[2]) | ((0xff - aoutline) << 24);
DWORD sw[6] = {outline, DWORD_MAX};
+ sw[0] = ColorConvTable::ColorCorrection(sw[0]);
w->Paint(CPoint(x, y), org);
@@ -1079,14 +1084,14 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin
if (w->m_style.fBlur) {
bluradjust += 8;
}
- double tx = w->m_style.fontAngleZ;
- UNREFERENCED_PARAMETER(tx);
- sw[4] = sw[2];
- sw[5] = 0x00ffffff;
w->Paint(CPoint(x, y), org);
+ sw[0] = ColorConvTable::ColorCorrection(sw[0]);
+ sw[2] = ColorConvTable::ColorCorrection(sw[2]);
sw[3] = (int)(w->m_style.outlineWidthX + t * w->getOverlayWidth() + t * bluradjust) >> 3;
+ sw[4] = sw[2];
+ sw[5] = 0x00ffffff;
bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
p.x += w->m_width;
@@ -1330,7 +1335,7 @@ void CSubtitle::CreateClippers(CSize size)
int k = std::min(width, w);
for (ptrdiff_t i = 0; i < k; i++, a += da) {
- am[i] = (am[i] * a) >> 14;
+ am[i] = BYTE((am[i] * a) >> 14);
}
a = 0x40 << 8;
@@ -1342,7 +1347,7 @@ void CSubtitle::CreateClippers(CSize size)
}
for (ptrdiff_t i = k; i < w; i++, a -= da) {
- am[i] = (am[i] * a) >> 14;
+ am[i] = BYTE((am[i] * a) >> 14);
}
}
} else if (m_effects[EF_SCROLL] && m_effects[EF_SCROLL]->param[4]) {
@@ -1371,7 +1376,7 @@ void CSubtitle::CreateClippers(CSize size)
for (ptrdiff_t j = k; j < l; j++, a += da) {
for (ptrdiff_t i = 0; i < w; i++, am++) {
- *am = ((*am) * a) >> 14;
+ *am = BYTE(((*am) * a) >> 14);
}
}
}
@@ -1394,7 +1399,7 @@ void CSubtitle::CreateClippers(CSize size)
int j = k;
for (; j < l; j++, a += da) {
for (ptrdiff_t i = 0; i < w; i++, am++) {
- *am = ((*am) * a) >> 14;
+ *am = BYTE(((*am) * a) >> 14);
}
}
@@ -3249,3 +3254,42 @@ STDMETHODIMP CRenderedTextSubtitle::Reload()
}
return !m_path.IsEmpty() && Open(m_path, DEFAULT_CHARSET, m_name) ? S_OK : E_FAIL;
}
+
+STDMETHODIMP CRenderedTextSubtitle::SetSourceTargetInfo(CString yuvVideoMatrix, int targetBlackLevel, int targetWhiteLevel)
+{
+ bool bIsVSFilter = !!yuvVideoMatrix.Replace(_T(".VSFilter"), _T(""));
+ ColorConvTable::YuvMatrixType yuvMatrix = ColorConvTable::BT601;
+ ColorConvTable::YuvRangeType yuvRange = ColorConvTable::RANGE_TV;
+
+ auto parseMatrixString = [&](const CString & sYuvMatrix) {
+ int nPos = 0;
+ CString range = sYuvMatrix.Tokenize(_T("."), nPos);
+ CString matrix = sYuvMatrix.Mid(nPos);
+
+ yuvRange = ColorConvTable::RANGE_TV;
+ if (range == _T("PC")) {
+ yuvRange = ColorConvTable::RANGE_PC;
+ }
+
+ if (matrix == _T("709")) {
+ yuvMatrix = ColorConvTable::BT709;
+ } else if (matrix == _T("240M")) {
+ yuvMatrix = ColorConvTable::BT709;
+ } else if (matrix == _T("601")) {
+ yuvMatrix = ColorConvTable::BT601;
+ } else {
+ yuvMatrix = ColorConvTable::NONE;
+ }
+ };
+
+ if (!m_sYCbCrMatrix.IsEmpty()) {
+ parseMatrixString(m_sYCbCrMatrix);
+ } else {
+ parseMatrixString(yuvVideoMatrix);
+ }
+
+ bool bTransformColors = !bIsVSFilter && !m_sYCbCrMatrix.IsEmpty();
+ ColorConvTable::SetDefaultConvType(yuvMatrix, yuvRange, (targetWhiteLevel < 245), bTransformColors);
+
+ return S_OK;
+}
diff --git a/src/Subtitles/RTS.h b/src/Subtitles/RTS.h
index cd350b72519..b2660d45862 100644
--- a/src/Subtitles/RTS.h
+++ b/src/Subtitles/RTS.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -423,4 +423,5 @@ class __declspec(uuid("537DCACA-2812-4a4f-B2C6-1A34C17ADEB0"))
STDMETHODIMP_(int) GetStream();
STDMETHODIMP SetStream(int iStream);
STDMETHODIMP Reload();
+ STDMETHODIMP SetSourceTargetInfo(CString yuvMatrix, int targetBlackLevel, int targetWhiteLevel);
};
diff --git a/src/Subtitles/Rasterizer.cpp b/src/Subtitles/Rasterizer.cpp
index 4f68ceba511..e61eb61b1fe 100644
--- a/src/Subtitles/Rasterizer.cpp
+++ b/src/Subtitles/Rasterizer.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -865,9 +865,9 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)
byte* dst = buffer + m_pOverlayData->mOverlayPitch * (y >> 3) + first;
if (first == last) {
- *dst += x2 - x1;
+ *dst += byte(x2 - x1);
} else {
- *dst += ((first + 1) << 3) - x1;
+ *dst += byte(((first + 1) << 3) - x1);
++dst;
while (++first < last) {
@@ -875,7 +875,7 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)
++dst;
}
- *dst += x2 - (last << 3);
+ *dst += byte(x2 - (last << 3));
}
}
}
@@ -1674,6 +1674,8 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x
void Rasterizer::FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nHeight, DWORD lColor)
{
+ ASSERT(spd.w >= x + nWidth && spd.h >= y + nHeight);
+
for (int wy = y; wy < y + nHeight; wy++) {
DWORD* dst = (DWORD*)((BYTE*)spd.bits + spd.pitch * wy) + x;
for (int wt = 0; wt < nWidth; ++wt) {
diff --git a/src/Subtitles/STS.cpp b/src/Subtitles/STS.cpp
index b428458896a..8ec94753120 100644
--- a/src/Subtitles/STS.cpp
+++ b/src/Subtitles/STS.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -242,14 +242,6 @@ int CharSetLen = _countof(CharSetList);
//
-static DWORD CharSetToCodePage(DWORD dwCharSet)
-{
- CHARSETINFO cs;
- ZeroMemory(&cs, sizeof(CHARSETINFO));
- ::TranslateCharsetInfo((DWORD*)dwCharSet, &cs, TCI_SRCCHARSET);
- return cs.ciACP;
-}
-
static int FindChar(CStringW str, WCHAR c, int pos, bool fUnicode, int CharSet)
{
if (fUnicode) {
@@ -1269,7 +1261,7 @@ static bool LoadFont(const CString& font)
const TCHAR* s = font;
const TCHAR* e = s + len;
for (BYTE* p = pData; s < e; s++, p++) {
- *p = *s - 33;
+ *p = BYTE(*s - 33);
}
for (ptrdiff_t i = 0, j = 0, k = len & ~3; i < k; i += 4, j += 3) {
@@ -1485,7 +1477,7 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C
style->colors[2] = style->colors[3]; // style->colors[2] is used for drawing the outline
alpha = std::max(std::min(alpha, 0xff), 0);
for (size_t i = 0; i < 3; i++) {
- style->alpha[i] = alpha;
+ style->alpha[i] = (BYTE)alpha;
}
style->alpha[3] = 0x80;
}
@@ -1580,6 +1572,8 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C
fRet = true;
} else if (entry == L"fontname") {
LoadUUEFont(file);
+ } else if (entry == L"ycbcr matrix") {
+ ret.m_sYCbCrMatrix = GetStrW(pszBuff, nBuffLength);
}
}
@@ -1645,7 +1639,7 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
style->colors[i] = (COLORREF)GetInt(pszBuff, nBuffLength);
}
for (size_t i = 0; i < 4; i++) {
- style->alpha[i] = GetInt(pszBuff, nBuffLength);
+ style->alpha[i] = (BYTE)GetInt(pszBuff, nBuffLength);
}
style->fontWeight = GetInt(pszBuff, nBuffLength) ? FW_BOLD : FW_NORMAL;
style->fItalic = GetInt(pszBuff, nBuffLength);
@@ -2615,7 +2609,7 @@ bool CSimpleTextSubtitle::Open(CString fn, int CharSet, CString name, CString vi
return Open(&f, CharSet, name);
}
-static size_t CountLines(CTextFile* f, ULONGLONG from, ULONGLONG to, CString& s = CString())
+static size_t CountLines(CTextFile* f, ULONGLONG from, ULONGLONG to, CString s = _T(""))
{
size_t n = 0;
f->Seek(from, CFile::begin);
@@ -3038,7 +3032,7 @@ STSStyle& STSStyle::operator = (LOGFONT& lf)
LOGFONTA& operator <<= (LOGFONTA& lfa, STSStyle& s)
{
- lfa.lfCharSet = s.charSet;
+ lfa.lfCharSet = (BYTE)s.charSet;
strncpy_s(lfa.lfFaceName, LF_FACESIZE, CStringA(s.fontName), _TRUNCATE);
HDC hDC = GetDC(nullptr);
lfa.lfHeight = -MulDiv((int)(s.fontSize + 0.5), GetDeviceCaps(hDC, LOGPIXELSY), 72);
@@ -3052,7 +3046,7 @@ LOGFONTA& operator <<= (LOGFONTA& lfa, STSStyle& s)
LOGFONTW& operator <<= (LOGFONTW& lfw, STSStyle& s)
{
- lfw.lfCharSet = s.charSet;
+ lfw.lfCharSet = (BYTE)s.charSet;
wcsncpy_s(lfw.lfFaceName, LF_FACESIZE, CStringW(s.fontName), _TRUNCATE);
HDC hDC = GetDC(nullptr);
lfw.lfHeight = -MulDiv((int)(s.fontSize + 0.5), GetDeviceCaps(hDC, LOGPIXELSY), 72);
@@ -3106,7 +3100,7 @@ STSStyle& operator <<= (STSStyle& s, const CString& style)
s.colors[i] = (COLORREF)GetInt(pszBuff, nBuffLength, L';');
}
for (size_t i = 0; i < 4; i++) {
- s.alpha[i] = GetInt(pszBuff, nBuffLength, L';');
+ s.alpha[i] = (BYTE)GetInt(pszBuff, nBuffLength, L';');
}
s.charSet = GetInt(pszBuff, nBuffLength, L';');
s.fontName = WToT(GetStrW(pszBuff, nBuffLength, L';'));
diff --git a/src/Subtitles/STS.h b/src/Subtitles/STS.h
index cd9bdf63573..5803f9d88fa 100644
--- a/src/Subtitles/STS.h
+++ b/src/Subtitles/STS.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -143,6 +143,7 @@ class CSimpleTextSubtitle : public CAtlArray
int m_defaultWrapStyle;
int m_collisions;
bool m_fScaledBAS;
+ CString m_sYCbCrMatrix;
bool m_fUsingAutoGeneratedDefaultStyle;
diff --git a/src/Subtitles/SeparableFilter.h b/src/Subtitles/SeparableFilter.h
index 3334a56b468..4b272026b59 100644
--- a/src/Subtitles/SeparableFilter.h
+++ b/src/Subtitles/SeparableFilter.h
@@ -1,6 +1,6 @@
/*
* (C) 2007 Niels Martin Hansen
-* (C) 2013-2014 see Authors.txt
+* (C) 2013-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -24,7 +24,10 @@
#include
#define LIBDIVIDE_USE_SSE2 1
+#pragma warning(push)
+#pragma warning(disable: 4244 4702)
#include "libdivide.h"
+#pragma warning(pop)
// Filter an image in horizontal direction with a one-dimensional filter
// PixelWidth is the distance in bytes between pixels
diff --git a/src/Subtitles/SubtitleInputPin.cpp b/src/Subtitles/SubtitleInputPin.cpp
index 9cdcc559547..a7cf216ec80 100644
--- a/src/Subtitles/SubtitleInputPin.cpp
+++ b/src/Subtitles/SubtitleInputPin.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -275,7 +275,7 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample)
{
std::unique_lock lock(m_mutexQueue);
- m_sampleQueue.AddTail(CAutoPtr(DEBUG_NEW SubtitleSample(tStart, tStop, pData, size_t(len))));
+ m_sampleQueue.emplace_back(DEBUG_NEW SubtitleSample(tStart, tStop, pData, size_t(len)));
lock.unlock();
m_condQueueReady.notify_one();
}
@@ -290,7 +290,7 @@ STDMETHODIMP CSubtitleInputPin::EndOfStream(void)
if (SUCCEEDED(hr)) {
std::unique_lock lock(m_mutexQueue);
- m_sampleQueue.AddTail(CAutoPtr(nullptr)); // nullptr means end of stream
+ m_sampleQueue.emplace_back(nullptr); // nullptr means end of stream
lock.unlock();
m_condQueueReady.notify_one();
}
@@ -318,7 +318,7 @@ void CSubtitleInputPin::DecodeSamples()
};
auto isQueueReady = [&]() {
- return !m_sampleQueue.IsEmpty() || needStopProcessing();
+ return !m_sampleQueue.empty() || needStopProcessing();
};
m_condQueueReady.wait(lock, isQueueReady);
@@ -330,8 +330,8 @@ void CSubtitleInputPin::DecodeSamples()
CAutoLock cAutoLock(m_pSubLock);
lock.lock(); // Reacquire the lock
- while (!m_sampleQueue.IsEmpty() && !needStopProcessing()) {
- auto pSample = m_sampleQueue.RemoveHead();
+ while (!m_sampleQueue.empty() && !needStopProcessing()) {
+ const auto& pSample = m_sampleQueue.front();
if (pSample) {
REFERENCE_TIME rtSampleInvalidate = DecodeSample(pSample);
@@ -344,6 +344,8 @@ void CSubtitleInputPin::DecodeSamples()
pRLECodedSubtitle->EndOfStream();
}
}
+
+ m_sampleQueue.pop_front();
}
}
@@ -355,7 +357,7 @@ void CSubtitleInputPin::DecodeSamples()
}
}
-REFERENCE_TIME CSubtitleInputPin::DecodeSample(const CAutoPtr& pSample)
+REFERENCE_TIME CSubtitleInputPin::DecodeSample(const std::unique_ptr& pSample)
{
bool bInvalidate = false;
@@ -476,7 +478,7 @@ void CSubtitleInputPin::InvalidateSamples()
m_bStopDecoding = true;
{
std::lock_guard lock(m_mutexQueue);
- m_sampleQueue.RemoveAll();
+ m_sampleQueue.clear();
m_bStopDecoding = false;
}
}
diff --git a/src/Subtitles/SubtitleInputPin.h b/src/Subtitles/SubtitleInputPin.h
index 55549ad9465..c94635d3e15 100644
--- a/src/Subtitles/SubtitleInputPin.h
+++ b/src/Subtitles/SubtitleInputPin.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -22,6 +22,7 @@
#pragma once
#include
+#include
#include
#include
#include
@@ -51,7 +52,7 @@ class CSubtitleInputPin : public CBaseInputPin
, data(pData, pData + len) {}
};
- CAutoPtrList m_sampleQueue;
+ std::list> m_sampleQueue;
bool m_bExitDecodingThread, m_bStopDecoding;
std::thread m_decodeThread;
@@ -59,7 +60,7 @@ class CSubtitleInputPin : public CBaseInputPin
std::condition_variable m_condQueueReady;
void DecodeSamples();
- REFERENCE_TIME DecodeSample(const CAutoPtr& pSample);
+ REFERENCE_TIME DecodeSample(const std::unique_ptr& pSample);
void InvalidateSamples();
protected:
diff --git a/src/Subtitles/Subtitles.vcxproj b/src/Subtitles/Subtitles.vcxproj
index 2bf9badf43d..4d64358d61f 100644
--- a/src/Subtitles/Subtitles.vcxproj
+++ b/src/Subtitles/Subtitles.vcxproj
@@ -96,6 +96,7 @@
+
@@ -117,6 +118,7 @@
+
diff --git a/src/Subtitles/Subtitles.vcxproj.filters b/src/Subtitles/Subtitles.vcxproj.filters
index 7587cff1c1d..706743683d2 100644
--- a/src/Subtitles/Subtitles.vcxproj.filters
+++ b/src/Subtitles/Subtitles.vcxproj.filters
@@ -71,6 +71,9 @@
Source Files
+
+ Source Files
+
@@ -139,5 +142,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/src/Subtitles/USFSubtitles.cpp b/src/Subtitles/USFSubtitles.cpp
index 7e50225ac3a..737dad5e029 100644
--- a/src/Subtitles/USFSubtitles.cpp
+++ b/src/Subtitles/USFSubtitles.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -315,7 +315,7 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts)
if (!s->name.CompareNoCase(L"Default") && !s->fontstyle.wrap.IsEmpty()) {
sts.m_defaultWrapStyle =
!s->fontstyle.wrap.CompareNoCase(L"no") ? 2 :
- !s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :
+ /*!s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :*/
1;
}
@@ -348,12 +348,12 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts)
for (size_t i = 0; i < 4; i++) {
DWORD color = ColorToDWORD(s->fontstyle.color[i]);
- int alpha = (BYTE)wcstol(s->fontstyle.alpha, nullptr, 10);
+ auto alpha = (BYTE)wcstol(s->fontstyle.alpha, nullptr, 10);
stss->colors[i] = color & 0xffffff;
stss->alpha[i] = (BYTE)(color >> 24);
- stss->alpha[i] = stss->alpha[i] + (255 - stss->alpha[i]) * std::min(std::max(alpha, 0), 100) / 100;
+ stss->alpha[i] = BYTE(stss->alpha[i] + (255 - stss->alpha[i]) * std::min(std::max(alpha, 0ui8), 100ui8) / 100);
}
if (!s->fontstyle.face.IsEmpty()) {
@@ -428,7 +428,7 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts)
if (s->name == t->style && !s->fontstyle.wrap.IsEmpty()) {
int WrapStyle =
!s->fontstyle.wrap.CompareNoCase(L"no") ? 2 :
- !s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :
+ /*!s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :*/
1;
if (WrapStyle != sts.m_defaultWrapStyle) {
diff --git a/src/Subtitles/VobSubFile.cpp b/src/Subtitles/VobSubFile.cpp
index abc82c2218d..1c0983ced90 100644
--- a/src/Subtitles/VobSubFile.cpp
+++ b/src/Subtitles/VobSubFile.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -259,8 +259,8 @@ bool CVobSubFile::Copy(CVobSubFile& vsf)
sp.filepos = m_sub.GetPosition();
BYTE buff[2048];
- vsf.m_sub.Read(buff, 2048);
- m_sub.Write(buff, 2048);
+ UINT uRead = vsf.m_sub.Read(buff, 2048);
+ m_sub.Write(buff, uRead);
WORD packetsize = (buff[buff[0x16] + 0x18] << 8) | buff[buff[0x16] + 0x19];
@@ -271,13 +271,13 @@ bool CVobSubFile::Copy(CVobSubFile& vsf)
size = std::min(sizeleft, 2048 - hsize);
if (size != sizeleft) {
- while (vsf.m_sub.Read(buff, 2048)) {
+ while ((uRead = vsf.m_sub.Read(buff, 2048)) > 0) {
if (!(buff[0x15] & 0x80) && buff[buff[0x16] + 0x17] == (i | 0x20)) {
break;
}
}
- m_sub.Write(buff, 2048);
+ m_sub.Write(buff, uRead);
}
}
@@ -648,7 +648,7 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
} else if (entry == _T("id")) {
str.MakeLower();
- int langid = ((str[0] & 0xff) << 8) | (str[1] & 0xff);
+ WORD langid = ((str[0] & 0xff) << 8) | (str[1] & 0xff);
i = str.Find(_T("index:"));
if (i < 0) {
@@ -690,8 +690,8 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
} else if (id >= 0 && entry == _T("timestamp")) {
SubPos sb;
- sb.vobid = vobid;
- sb.cellid = cellid;
+ sb.vobid = (char)vobid;
+ sb.cellid = (char)cellid;
sb.celltimestamp = celltimestamp;
sb.bValid = true;
@@ -1143,13 +1143,15 @@ BYTE* CVobSubFile::GetPacket(size_t idx, size_t& packetSize, size_t& dataSize, s
break;
}
+ ASSERT(nLang < BYTE_MAX);
+
// let's check a few things to make sure...
if (*(DWORD*)&buff[0x00] != 0xba010000
|| *(DWORD*)&buff[0x0e] != 0xbd010000
|| !(buff[0x15] & 0x80)
|| (buff[0x17] & 0xf0) != 0x20
|| (buff[buff[0x16] + 0x17] & 0xe0) != 0x20
- || (buff[buff[0x16] + 0x17] & 0x1f) != nLang) {
+ || (buff[buff[0x16] + 0x17] & 0x1f) != (BYTE)nLang) {
break;
}
@@ -1225,14 +1227,11 @@ bool CVobSubFile::GetFrame(size_t idx, size_t nLang /*= SIZE_T_ERROR*/, REFERENC
}
m_img.start = sp[idx].start;
- m_img.delay = idx + 1 < sp.GetCount() ? sp[idx + 1].start - sp[idx].start : 3000;
bool ret = m_img.Decode(buff, packetSize, dataSize, rt >= 0 ? int(rt - sp[idx].start) : INT_MAX,
m_bCustomPal, m_tridx, m_orgpal, m_cuspal, true);
- if (idx + 1 < sp.GetCount()) {
- m_img.delay = std::min(m_img.delay, sp[idx + 1].start - m_img.start);
- }
+ m_img.delay = sp[idx].stop - sp[idx].start;
if (!ret) {
return false;
@@ -1360,7 +1359,7 @@ STDMETHODIMP CVobSubFile::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps,
rt /= 10000;
- if (!GetFrame(GetFrameIdxByTimeStamp(rt), -1, rt)) {
+ if (!GetFrame(GetFrameIdxByTimeStamp(rt), SIZE_T_ERROR, rt)) {
return E_FAIL;
}
@@ -1496,8 +1495,8 @@ static void PixelAtBiLinear(RGBQUAD& c, int x, int y, CVobSubImage& src)
+ c21.rgbGreen * v2u1 + c22.rgbGreen * v2u2) >> 24;
c.rgbBlue = (c11.rgbBlue * v1u1 + c12.rgbBlue * v1u2
+ c21.rgbBlue * v2u1 + c22.rgbBlue * v2u2) >> 24;
- c.rgbReserved = (v1u1 + v1u2
- + v2u1 + v2u2) >> 16;
+ c.rgbReserved = BYTE((v1u1 + v1u2
+ + v2u1 + v2u2) >> 16);
}
static void StretchBlt(SubPicDesc& spd, CRect dstrect, CVobSubImage& src)
@@ -1960,7 +1959,8 @@ bool CVobSubFile::SaveScenarist(CString fn, int delay)
BYTE colormap[16];
for (size_t i = 0; i < 16; i++) {
- int idx = 0, maxdif = 255 * 255 * 3 + 1;
+ BYTE idx = 0;
+ int maxdif = 255 * 255 * 3 + 1;
for (size_t j = 0; j < 16 && maxdif; j++) {
int rdif = pal[j].rgbRed - m_orgpal[i].rgbRed;
@@ -1970,7 +1970,7 @@ bool CVobSubFile::SaveScenarist(CString fn, int delay)
int dif = rdif * rdif + gdif * gdif + bdif * bdif;
if (dif < maxdif) {
maxdif = dif;
- idx = (int)j;
+ idx = (BYTE)j;
}
}
@@ -2397,7 +2397,7 @@ void CVobSubStream::Open(CString name, BYTE* pData, int len)
m_bAlign = sl.RemoveHead() == _T("ON");
CString hor = sl.GetHead(), ver = sl.GetTail();
m_alignhor = hor == _T("LEFT") ? 0 : hor == _T("CENTER") ? 1 : hor == _T("RIGHT") ? 2 : 1;
- m_alignver = ver == _T("TOP") ? 0 : ver == _T("CENTER") ? 1 : ver == _T("BOTTOM") ? 2 : 2;
+ m_alignver = ver == _T("TOP") ? 0 : ver == _T("CENTER") ? 1 : /*ver == _T("BOTTOM") ? 2 :*/ 2;
}
} else if (key == _T("fade in/out")) {
_stscanf_s(value, _T("%d%, %d%"), &m_fadein, &m_fadeout);
diff --git a/src/Subtitles/VobSubFile.h b/src/Subtitles/VobSubFile.h
index b3fe01a454d..b1aea10e194 100644
--- a/src/Subtitles/VobSubFile.h
+++ b/src/Subtitles/VobSubFile.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -94,7 +94,7 @@ class __declspec(uuid("998D4C9A-460F-4de6-BDCD-35AB24F94ADF"))
};
struct SubLang {
- int id = 0;
+ WORD id = 0;
CString name, alt;
CAtlArray subpos;
};
@@ -163,6 +163,7 @@ class __declspec(uuid("998D4C9A-460F-4de6-BDCD-35AB24F94ADF"))
STDMETHODIMP_(int) GetStream();
STDMETHODIMP SetStream(int iStream);
STDMETHODIMP Reload();
+ STDMETHODIMP SetSourceTargetInfo(CString yuvMatrix, int targetBlackLevel, int targetWhiteLevel) { return E_NOTIMPL; };
};
class __declspec(uuid("D7FBFB45-2D13-494F-9B3D-FFC9557D5C45"))
@@ -208,4 +209,5 @@ class __declspec(uuid("D7FBFB45-2D13-494F-9B3D-FFC9557D5C45"))
STDMETHODIMP_(int) GetStream();
STDMETHODIMP SetStream(int iStream);
STDMETHODIMP Reload() { return E_NOTIMPL; }
+ STDMETHODIMP SetSourceTargetInfo(CString yuvMatrix, int targetBlackLevel, int targetWhiteLevel) { return E_NOTIMPL; }
};
diff --git a/src/Subtitles/VobSubFileRipper.cpp b/src/Subtitles/VobSubFileRipper.cpp
index 031671dd46f..00bd1763810 100644
--- a/src/Subtitles/VobSubFileRipper.cpp
+++ b/src/Subtitles/VobSubFileRipper.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -1024,16 +1024,14 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn)
line.TrimLeft();
n = 0;
-
- int langnum;
-
if (_istdigit(lang[0])) {
+ int langnum;
n = _stscanf_s(lang, _T("%d"), &langnum);
if (n != 1) {
break;
}
- m_rd.selids[langnum] = true;
+ m_rd.selids[(BYTE)langnum] = true;
} else if (_istalpha(lang[0])) {
n = _stscanf_s(lang, _T("%s"), langid, _countof(langid));
if (n != 1) {
@@ -1045,7 +1043,8 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn)
if (id == 'cc') {
m_rd.bClosedCaption = true;
} else {
- m_rd.selids[id] = true;
+ ASSERT(id <= BYTE_MAX);
+ m_rd.selids[(BYTE)id] = true;
}
} else {
break;
diff --git a/src/Subtitles/VobSubImage.cpp b/src/Subtitles/VobSubImage.cpp
index f00fb2b4e30..c797f40e574 100644
--- a/src/Subtitles/VobSubImage.cpp
+++ b/src/Subtitles/VobSubImage.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -990,8 +990,8 @@ void CVobSubImage::SplitOutline(const COutline& o, COutline& o1, COutline& o2)
}
}
- size_t maxlen = 0, maxidx = -1;
- size_t maxlen2 = 0, maxidx2 = -1;
+ size_t maxlen = 0, maxidx = SIZE_T_ERROR;
+ size_t maxlen2 = 0, maxidx2 = SIZE_T_ERROR;
for (i = 0; i < la.GetCount(); i++) {
if (maxlen < la[i]) {
@@ -1005,6 +1005,8 @@ void CVobSubImage::SplitOutline(const COutline& o, COutline& o1, COutline& o2)
}
}
+ ASSERT(maxidx != SIZE_T_ERROR && maxidx2 != SIZE_T_ERROR);
+
if (maxlen == maxlen2) {
maxidx = maxidx2; // if equal choose the inner section
}
diff --git a/src/Subtitles/stdafx.h b/src/Subtitles/stdafx.h
index b6cb795fcd1..a2cc7e7521a 100644
--- a/src/Subtitles/stdafx.h
+++ b/src/Subtitles/stdafx.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -35,4 +35,8 @@
#include "../DSUtil/DSUtil.h"
#include
+#include
#include
+#include
+#include
+#include
diff --git a/src/YASM.bat b/src/YASM.bat
index dde5bc0a164..451fe036d8c 100755
--- a/src/YASM.bat
+++ b/src/YASM.bat
@@ -1,5 +1,5 @@
@ECHO OFF
-REM (C) 2012-2013 see Authors.txt
+REM (C) 2012-2013, 2015 see Authors.txt
REM
REM This file is part of MPC-HC.
REM
@@ -17,12 +17,9 @@ REM You should have received a copy of the GNU General Public License
REM along with this program. If not, see .
-IF EXIST "%~dp0..\build.user.bat" (
- CALL "%~dp0..\build.user.bat"
-) ELSE (
- IF DEFINED MSYS SET MPCHC_MSYS=%MSYS%
-)
-
-SET PATH=%PATH%;%MPCHC_MSYS%\bin
+CALL "%~dp0..\common.bat" :SubSetPath
+IF %ERRORLEVEL% NEQ 0 EXIT /B 1
+CALL "%~dp0..\common.bat" :SubDoesExist yasm.exe
+IF %ERRORLEVEL% NEQ 0 EXIT /B 1
yasm.exe %*
diff --git a/src/common-3rd-party.props b/src/common-3rd-party.props
index a13bbd2bdcc..03f400dbbb7 100644
--- a/src/common-3rd-party.props
+++ b/src/common-3rd-party.props
@@ -6,4 +6,4 @@
TurnOffAllWarnings
-
\ No newline at end of file
+
diff --git a/src/common.props b/src/common.props
index 9c92797f0df..5b7686e7753 100644
--- a/src/common.props
+++ b/src/common.props
@@ -12,7 +12,7 @@
- /w34701 /w34706 /d2Zi+ /Zc:rvalueCast %(AdditionalOptions)
+ /w34701 /w34706 /Zo /Zc:rvalueCast %(AdditionalOptions)
/wd4005 /wd6031 /wd6246 /wd6309 /wd6387 /wd28204 %(AdditionalOptions)
true
true
@@ -26,7 +26,7 @@
STANDALONE_FILTER;_USRDLL;_AFX_NO_MFC_CONTROLS_IN_DIALOGS;%(PreprocessorDefinitions)
WIN32;%(PreprocessorDefinitions)
_WIN64;WIN64;%(PreprocessorDefinitions)
- Level3
+ Level4
MachineX86
@@ -92,4 +92,4 @@
NDEBUG;%(PreprocessorDefinitions)
-
\ No newline at end of file
+
diff --git a/src/filters/PinInfoWnd.cpp b/src/filters/PinInfoWnd.cpp
index 8717e2ffa6c..2ba4264722f 100644
--- a/src/filters/PinInfoWnd.cpp
+++ b/src/filters/PinInfoWnd.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -116,7 +116,7 @@ bool CPinInfoWnd::OnActivate()
IDC_PP_EDIT1);
m_info_edit.SetLimitText(60000);
- OnCbnSelchangeCombo1();
+ OnSelectedPinChange();
for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
@@ -151,7 +151,7 @@ BOOL CPinInfoWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT*
}
BEGIN_MESSAGE_MAP(CPinInfoWnd, CInternalPropertyPageWnd)
- ON_CBN_SELCHANGE(IDC_PP_COMBO1, OnCbnSelchangeCombo1)
+ ON_CBN_SELCHANGE(IDC_PP_COMBO1, OnSelectedPinChange)
END_MESSAGE_MAP()
void CPinInfoWnd::AddLine(CString str)
@@ -162,7 +162,7 @@ void CPinInfoWnd::AddLine(CString str)
m_info_edit.ReplaceSel(str);
}
-void CPinInfoWnd::OnCbnSelchangeCombo1()
+void CPinInfoWnd::OnSelectedPinChange()
{
m_info_edit.SetWindowText(_T(""));
@@ -177,29 +177,27 @@ void CPinInfoWnd::OnCbnSelchangeCombo1()
}
CString str;
- PIN_INFO PinInfo;
+ CPinInfo pinInfo;
- if (SUCCEEDED(pPin->QueryPinInfo(&PinInfo))) {
+ if (SUCCEEDED(pPin->QueryPinInfo(&pinInfo))) {
CString strName;
- CLSID FilterClsid;
- FILTER_INFO FilterInfo;
+ CLSID filterClsid;
+ CFilterInfo filterInfo;
- if (SUCCEEDED(PinInfo.pFilter->QueryFilterInfo(&FilterInfo))) {
+ if (SUCCEEDED(pinInfo.pFilter->QueryFilterInfo(&filterInfo))) {
CRegKey key;
- PinInfo.pFilter->GetClassID(&FilterClsid);
+ pinInfo.pFilter->GetClassID(&filterClsid);
TCHAR buff[128];
ULONG len = _countof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11D0-BD40-00A0C911CE86}\\Instance\\") + CStringFromGUID(FilterClsid), KEY_READ)
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11D0-BD40-00A0C911CE86}\\Instance\\") + CStringFromGUID(filterClsid), KEY_READ)
&& ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), buff, &len)) {
strName = CString(buff);
} else {
- strName = FilterInfo.achName;
+ strName = filterInfo.achName;
}
- str.Format(_T("Filter : %s - CLSID : %s\n\n"), strName, CStringFromGUID(FilterClsid));
+ str.Format(_T("Filter : %s - CLSID : %s\n\n"), strName, CStringFromGUID(filterClsid));
AddLine(str);
- FilterInfo.pGraph->Release();
}
- PinInfo.pFilter->Release();
}
CMediaTypeEx cmt;
diff --git a/src/filters/PinInfoWnd.h b/src/filters/PinInfoWnd.h
index a92b50d303b..441d1764fd1 100644
--- a/src/filters/PinInfoWnd.h
+++ b/src/filters/PinInfoWnd.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
+ * (C) 2006-2012, 2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -54,7 +54,7 @@ class __declspec(uuid("A1EB391C-6089-4A87-9988-BE50872317D4"))
DECLARE_MESSAGE_MAP()
- void OnCbnSelchangeCombo1();
+ void OnSelectedPinChange();
protected:
virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp
index 6b38dd9e1f8..e4408028c57 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
+ * (C) 2006-2013, 2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -244,8 +244,8 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
int len = (DataSize + 7) & 0x1fff;
BYTE hdr[7] = {0xff, 0xf9};
- hdr[2] = (profile << 6) | (srate_idx << 2) | ((channels & 4) >> 2);
- hdr[3] = ((channels & 3) << 6) | (len >> 11);
+ hdr[2] = BYTE((profile << 6) | (srate_idx << 2) | ((channels & 4) >> 2));
+ hdr[3] = BYTE(((channels & 3) << 6) | (len >> 11));
hdr[4] = (len >> 3) & 0xff;
hdr[5] = ((len & 7) << 5) | 0x1f;
hdr[6] = 0xfc;
diff --git a/src/filters/muxer/DSMMuxer/DSMMuxer.cpp b/src/filters/muxer/DSMMuxer/DSMMuxer.cpp
index 8c3584967db..192c8484cdc 100644
--- a/src/filters/muxer/DSMMuxer/DSMMuxer.cpp
+++ b/src/filters/muxer/DSMMuxer/DSMMuxer.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
+ * (C) 2006-2013, 2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -417,7 +417,7 @@ void CDSMMuxerFilter::IndexSyncPoint(const MuxerPacket* p, __int64 fp)
m_rtPrevSyncPoint = p->rtStart;
SyncPoint sp;
- sp.id = p->pPin->GetID();
+ sp.id = (BYTE)p->pPin->GetID();
sp.rtStart = p->rtStart;
sp.rtStop = p->pPin->IsSubtitleStream() ? p->rtStop : _I64_MAX;
sp.fp = fp;
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp
index 61a3b011a51..f2c1e0d8278 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -255,7 +255,7 @@ QWORD CLength::Size(bool fWithHeader)
QWORD len = 0;
for (int i = 1; i <= 8; i++) {
- if (!(m_len & (~((1i64 << (7 * i)) - 1))) && (m_len & ((1i64 << (7 * i)) - 1)) != ((1i64 << (7 * i)) - 1)) {
+ if (!(m_len & (~((QWORD(1) << (7 * i)) - 1))) && (m_len & ((QWORD(1) << (7 * i)) - 1)) != ((QWORD(1) << (7 * i)) - 1)) {
len += i;
break;
}
@@ -924,8 +924,14 @@ HRESULT Void::Write(IStream* pStream)
HeaderWrite(pStream);
BYTE buff[64];
memset(buff, 0x80, sizeof(buff));
- for (int len = (int)m_len; len > 0; len -= sizeof(buff)) {
- pStream->Write(buff, std::min(sizeof(buff), (ULONG)len), nullptr);
+ QWORD len = m_len;
+ for (; len >= sizeof(buff); len -= sizeof(buff)) {
+ pStream->Write(buff, sizeof(buff), nullptr);
}
+
+ if (len > 0) {
+ pStream->Write(buff, (ULONG)len, nullptr);
+ }
+
return S_OK;
}
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp
index de5e64c6829..c5be29d3196 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -156,7 +156,7 @@ CBasePin* CMatroskaMuxerFilter::GetPin(int n)
}
}
- if (n == m_pInputs.GetCount() && m_pOutput) {
+ if (n == (int)m_pInputs.GetCount() && m_pOutput) {
return m_pOutput;
}
@@ -396,9 +396,9 @@ DWORD CMatroskaMuxerFilter::ThreadProc()
// TODO
QWORD voidlen = 100;
if (rtDur > 0) {
- voidlen += int(1.0 * rtDur / MAXCLUSTERTIME / 10000 + 0.5) * 20;
+ voidlen += QWORD(1.0 * rtDur / MAXCLUSTERTIME / 10000 + 0.5) * 20;
} else {
- voidlen += int(1.0 * 1000 * 60 * 60 * 24 / MAXCLUSTERTIME + 0.5) * 20; // when no duration is known, allocate for 24 hours (~340k)
+ voidlen += QWORD(1.0 * 1000 * 60 * 60 * 24 / MAXCLUSTERTIME + 0.5) * 20; // when no duration is known, allocate for 24 hours (~340k)
}
ULONGLONG voidpos = GetStreamPosition(pStream);
{
@@ -675,15 +675,15 @@ DWORD CMatroskaMuxerFilter::ThreadProc()
}
SetStreamPosition(pStream, voidpos);
- int len = (int)(voidlen - seek.Size());
+ QWORD len = voidlen - seek.Size();
ASSERT(len >= 0 && len != 1);
seek.Write(pStream);
if (len == 0) {
// nothing to do
} else if (len >= 2) {
- for (int i = 0; i < 8; i++) {
- if (len >= (1 << i * 7) - 2 && len <= (1 << (i + 1) * 7) - 2) {
+ for (QWORD i = 0; i < 8; i++) {
+ if (len >= (QWORD(1) << i * 7) - 2 && len <= (QWORD(1) << (i + 1) * 7) - 2) {
Void(len - 2 - i).Write(pStream);
break;
}
@@ -1105,7 +1105,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
*dst++ = 2;
for (int i = 0; i < 2; i++) {
for (int len2 = pvf2->HeaderSize[i]; len2 >= 0; len2 -= 255) {
- *dst++ = std::min(len2, 255);
+ *dst++ = (BYTE)std::min(len2, BYTE_MAX);
}
}
diff --git a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
index f44f808d2a2..efd02df97e8 100644
--- a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
+++ b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
+ * (C) 2006-2013, 2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -144,10 +144,9 @@ DWORD CStreamDriveThruFilter::ThreadProc()
if (CComQIPtr pFSF = GetFilterFromPin(m_pOutput->GetConnected())) {
pFSF->SetMode(AM_FILE_OVERWRITE);
- LPOLESTR pfn;
+ CComHeapPtr pfn;
if (SUCCEEDED(pFSF->GetCurFile(&pfn, nullptr))) {
pFSF->SetFileName(pfn, nullptr);
- CoTaskMemFree(pfn);
}
}
diff --git a/src/filters/reader/CDDAReader/CDDAReader.cpp b/src/filters/reader/CDDAReader/CDDAReader.cpp
index bf7182e8557..8a3cd1f35a9 100644
--- a/src/filters/reader/CDDAReader/CDDAReader.cpp
+++ b/src/filters/reader/CDDAReader/CDDAReader.cpp
@@ -21,6 +21,7 @@
#include "stdafx.h"
#include
+#include
#ifdef STANDALONE_FILTER
#include
#endif
@@ -133,7 +134,7 @@ STDMETHODIMP CCDDAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
CMediaType mt;
mt.majortype = MEDIATYPE_Stream;
- mt.subtype = MEDIASUBTYPE_WAVE;
+ mt.subtype = m_stream.IsDTS() ? MEDIASUBTYPE_DTS : MEDIASUBTYPE_WAVE;
m_mt = mt;
return S_OK;
@@ -275,6 +276,8 @@ CCDDAStream::CCDDAStream()
m_header.frm.pcm.wf.nBlockAlign = m_header.frm.pcm.wf.nChannels * m_header.frm.pcm.wBitsPerSample / 8;
m_header.frm.pcm.wf.nAvgBytesPerSec = m_header.frm.pcm.wf.nSamplesPerSec * m_header.frm.pcm.wf.nBlockAlign;
m_header.data.hdr.chunkID = DataID;
+
+ m_bDTS = false;
}
CCDDAStream::~CCDDAStream()
@@ -342,6 +345,39 @@ bool CCDDAStream::Load(const WCHAR* fnw)
m_header.riff.hdr.chunkSize = (long)(m_llLength + sizeof(m_header) - 8);
m_header.data.hdr.chunkSize = (long)(m_llLength);
+ // Detect DTS Music Disk
+ m_bDTS = false;
+
+ // DCA syncwords
+ const DWORD DCA_MARKER_RAW_BE = 0x7FFE8001;
+ const DWORD DCA_MARKER_RAW_LE = 0xFE7F0180;
+ const DWORD DCA_MARKER_14B_BE = 0x1FFFE800;
+ const DWORD DCA_MARKER_14B_LE = 0xFF1F00E8;
+ UINT nMarkerFound = 0, nAttempt = 0;
+ DWORD marker = DWORD_MAX;
+
+ std::vector data(16384);
+ DWORD dwSizeRead = 0;
+ while (SUCCEEDED(Read(data.data(), (DWORD)data.size(), TRUE, &dwSizeRead)) && dwSizeRead && nAttempt < (4 + nMarkerFound)) {
+ nAttempt++;
+
+ for (DWORD i = 0; i < dwSizeRead; i++) {
+ marker = (marker << 8) | data[i];
+ if ((marker == DCA_MARKER_14B_LE && (i < dwSizeRead - 2) && (data[i + 1] & 0xF0) == 0xF0 && data[i + 2] == 0x07)
+ || (marker == DCA_MARKER_14B_BE && (i < dwSizeRead - 2) && data[i + 1] == 0x07 && (data[i + 2] & 0xF0) == 0xF0)
+ || marker == DCA_MARKER_RAW_LE || marker == DCA_MARKER_RAW_BE) {
+ nMarkerFound++;
+ }
+ }
+ dwSizeRead = 0;
+
+ if (nMarkerFound >= 4) {
+ m_bDTS = true;
+ break;
+ }
+ }
+ SetPointer(0);
+
CDROM_READ_TOC_EX TOCEx;
ZeroMemory(&TOCEx, sizeof(TOCEx));
TOCEx.Format = CDROM_READ_TOC_EX_FORMAT_CDTEXT;
@@ -384,15 +420,15 @@ bool CCDDAStream::Load(const WCHAR* fnw)
const int lenW = _countof(pDesc->WText);
CString text = !pDesc->Unicode
- ? CString(CStringA((CHAR*)pDesc->Text, lenU))
- : CString(CStringW((WCHAR*)pDesc->WText, lenW));
+ ? CString(CStringA((CHAR*)pDesc->Text, lenU))
+ : CString(CStringW((WCHAR*)pDesc->WText, lenW));
int tlen = text.GetLength();
CString tmp = (tlen < 12 - 1)
- ? (!pDesc->Unicode
- ? CString(CStringA((CHAR*)pDesc->Text + tlen + 1, lenU - (tlen + 1)))
- : CString(CStringW((WCHAR*)pDesc->WText + tlen + 1, lenW - (tlen + 1))))
- : _T("");
+ ? (!pDesc->Unicode
+ ? CString(CStringA((CHAR*)pDesc->Text + tlen + 1, lenU - (tlen + 1)))
+ : CString(CStringW((WCHAR*)pDesc->WText + tlen + 1, lenW - (tlen + 1))))
+ : _T("");
if (pDesc->PackType < 0x80 || pDesc->PackType >= 0x80 + 0x10) {
continue;
@@ -437,15 +473,17 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
LONGLONG pos = m_llPosition;
size_t len = dwBytesToRead;
- if (pos < sizeof(m_header) && len > 0) {
- size_t l = std::min(len, size_t(sizeof(m_header) - pos));
- memcpy(pbBuffer, &((BYTE*)&m_header)[pos], l);
- pbBuffer += l;
- pos += l;
- len -= l;
- }
+ if (!m_bDTS) {
+ if (pos < sizeof(m_header) && len > 0) {
+ size_t l = std::min(len, size_t(sizeof(m_header) - pos));
+ memcpy(pbBuffer, &((BYTE*)&m_header)[pos], l);
+ pbBuffer += l;
+ pos += l;
+ len -= l;
+ }
- pos -= sizeof(m_header);
+ pos -= sizeof(m_header);
+ }
while (pos >= 0 && pos < m_llLength && len > 0) {
RAW_READ_INFO rawreadinfo;
@@ -486,7 +524,10 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
LONGLONG CCDDAStream::Size(LONGLONG* pSizeAvailable)
{
- LONGLONG size = sizeof(m_header) + m_llLength;
+ LONGLONG size = m_llLength;
+ if (!m_bDTS) {
+ size += sizeof(m_header);
+ }
if (pSizeAvailable) {
*pSizeAvailable = size;
}
diff --git a/src/filters/reader/CDDAReader/CDDAReader.h b/src/filters/reader/CDDAReader/CDDAReader.h
index 4f5a2e04ba9..fb34c6722ee 100644
--- a/src/filters/reader/CDDAReader/CDDAReader.h
+++ b/src/filters/reader/CDDAReader/CDDAReader.h
@@ -70,6 +70,7 @@ class CCDDAStream : public CAsyncStream
HANDLE m_hDrive;
CDROM_TOC m_TOC;
UINT m_nFirstSector, m_nStartSector, m_nStopSector;
+ bool m_bDTS;
WAVEChunck m_header;
@@ -83,6 +84,8 @@ class CCDDAStream : public CAsyncStream
bool Load(const WCHAR* fnw);
+ bool IsDTS() const { return m_bDTS; };
+
// overrides
HRESULT SetPointer(LONGLONG llPos);
HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
index 4a1bb1da53f..46e65017677 100644
--- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
@@ -672,7 +672,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString& _Error)
if (r.m_AdvRendSets.bVMR9FullscreenGUISupport && !m_bHighColorResolution) {
pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
}
- m_D3DDevExError = L"No m_pD3DEx";
+ m_D3DDevExError = _T("No m_pD3DEx");
if (!m_FocusThread) {
m_FocusThread = (CFocusThread*)AfxBeginThread(RUNTIME_CLASS(CFocusThread), 0, 0, 0);
@@ -701,7 +701,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString& _Error)
&pp, &DisplayMode, &m_pD3DDevEx);
}
- m_D3DDevExError = GetWindowsErrorMessage(hr, m_hD3D9);
+ m_D3DDevExError = FAILED(hr) ? GetWindowsErrorMessage(hr, m_hD3D9) : _T("");
if (m_pD3DDevEx) {
m_pD3DDev = m_pD3DDevEx;
m_BackbufferType = pp.BackBufferFormat;
@@ -1904,7 +1904,9 @@ void CDX9AllocatorPresenter::DrawStats()
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
- strText.Format(L"Formats : Surface %s Backbuffer %s Display %s Device %s D3DExError: %s", GetD3DFormatStr(m_SurfaceType), GetD3DFormatStr(m_BackbufferType), GetD3DFormatStr(m_DisplayType), m_pD3DDevEx ? L"D3DDevEx" : L"D3DDev", m_D3DDevExError.GetString());
+ strText.Format(L"Formats : Surface %s Backbuffer %s Display %s Device %s %s",
+ GetD3DFormatStr(m_SurfaceType), GetD3DFormatStr(m_BackbufferType), GetD3DFormatStr(m_DisplayType),
+ m_pD3DDevEx ? L"D3DDevEx" : L"D3DDev", m_D3DDevExError.IsEmpty() ? _T("") : _T("D3DExError: ") + m_D3DDevExError);
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
index 2890ac87052..4f4704c6d7d 100644
--- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
+++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -1365,22 +1365,22 @@ HRESULT CDX9RenderingEngine::CreateIccProfileLut(TCHAR* profilePath, float* lut3
return E_FAIL;
}
- unsigned short* lut3DOutput = nullptr;
- unsigned short* lut3DInput = nullptr;
+ uint16_t* lut3DOutput = nullptr;
+ uint16_t* lut3DInput = nullptr;
try {
// Create the 3D LUT input
- lut3DOutput = DEBUG_NEW unsigned short[m_Lut3DEntryCount * 3];
- lut3DInput = DEBUG_NEW unsigned short[m_Lut3DEntryCount * 3];
+ lut3DOutput = DEBUG_NEW uint16_t[m_Lut3DEntryCount * 3];
+ lut3DInput = DEBUG_NEW uint16_t[m_Lut3DEntryCount * 3];
- unsigned short* lut3DInputIterator = lut3DInput;
+ uint16_t* lut3DInputIterator = lut3DInput;
for (int b = 0; b < m_Lut3DSize; b++) {
for (int g = 0; g < m_Lut3DSize; g++) {
for (int r = 0; r < m_Lut3DSize; r++) {
- *lut3DInputIterator++ = r * 65535 / (m_Lut3DSize - 1);
- *lut3DInputIterator++ = g * 65535 / (m_Lut3DSize - 1);
- *lut3DInputIterator++ = b * 65535 / (m_Lut3DSize - 1);
+ *lut3DInputIterator++ = uint16_t(r * 65535 / (m_Lut3DSize - 1));
+ *lut3DInputIterator++ = uint16_t(g * 65535 / (m_Lut3DSize - 1));
+ *lut3DInputIterator++ = uint16_t(b * 65535 / (m_Lut3DSize - 1));
}
}
}
@@ -1397,9 +1397,6 @@ HRESULT CDX9RenderingEngine::CreateIccProfileLut(TCHAR* profilePath, float* lut3
delete [] lut3DOutput;
delete [] lut3DInput;
cmsDeleteTransform(hTransform);
-
- return S_OK;
-
} catch (...) {
// Cleanup
delete [] lut3DOutput;
diff --git a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp
index 248e4f863f0..c25c3728b4f 100644
--- a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -82,26 +82,36 @@ STDMETHODIMP CDXRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, vo
HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev)
{
- CheckPointer(pD3DDev, E_POINTER);
+ HRESULT hr = S_OK;
- const CRenderersSettings& r = GetRenderersSettings();
+ if (!pD3DDev) {
+ // release all resources
+ m_pSubPicQueue = nullptr;
+ m_pAllocator = nullptr;
+ return hr;
+ }
+ const CRenderersSettings& r = GetRenderersSettings();
InitMaxSubtitleTextureSize(r.subPicQueueSettings.nMaxRes, m_ScreenSize);
if (m_pAllocator) {
m_pAllocator->ChangeDevice(pD3DDev);
} else {
m_pAllocator = DEBUG_NEW CDX9SubPicAllocator(pD3DDev, m_maxSubtitleTextureSize, true);
+ m_condAllocatorReady.notify_one();
}
- HRESULT hr = S_OK;
- if (!m_pSubPicQueue) {
+ {
+ // Lock before check because m_pSubPicQueue might be initialized in CSubPicAllocatorPresenterImpl::Connect
CAutoLock cAutoLock(this);
- m_pSubPicQueue = r.subPicQueueSettings.nSize > 0
- ? (ISubPicQueue*)DEBUG_NEW CSubPicQueue(r.subPicQueueSettings, m_pAllocator, &hr)
- : (ISubPicQueue*)DEBUG_NEW CSubPicQueueNoThread(r.subPicQueueSettings, m_pAllocator, &hr);
- } else {
- m_pSubPicQueue->Invalidate();
+ if (!m_pSubPicQueue) {
+ m_pSubPicQueue = r.subPicQueueSettings.nSize > 0
+ ? (ISubPicQueue*)DEBUG_NEW CSubPicQueue(r.subPicQueueSettings, m_pAllocator, &hr)
+ : (ISubPicQueue*)DEBUG_NEW CSubPicQueueNoThread(r.subPicQueueSettings, m_pAllocator, &hr);
+ } else {
+ this->Unlock();
+ m_pSubPicQueue->Invalidate();
+ }
}
if (SUCCEEDED(hr) && m_pSubPicProvider) {
diff --git a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
index cdc4e774992..b391bd4b3b0 100644
--- a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -26,6 +26,7 @@
#include "IPinHook.h"
#include "MacrovisionKicker.h"
#include "IMPCVideoDecFilter.h"
+#include "../../../DSUtil/ArrayUtils.h"
#if (0) // Set to 1 to activate EVR traces
#define TRACE_EVR TRACE
@@ -102,16 +103,13 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
, m_nStepCount(0)
, m_bSignaledStarvation(false)
, m_StarvationClock(0)
- , m_hDXVA2Lib(nullptr)
- , m_hEVRLib(nullptr)
- , m_hAVRTLib(nullptr)
- , pfDXVA2CreateDirect3DDeviceManager9(nullptr)
- , pfMFCreateDXSurfaceBuffer(nullptr)
- , pfMFCreateVideoSampleFromSurface(nullptr)
- , pfMFCreateVideoMediaType(nullptr)
- , pfAvSetMmThreadCharacteristicsW(nullptr)
- , pfAvSetMmThreadPriority(nullptr)
- , pfAvRevertMmThreadCharacteristics(nullptr)
+ , fnDXVA2CreateDirect3DDeviceManager9("dxva2.dll", "DXVA2CreateDirect3DDeviceManager9")
+ , fnMFCreateDXSurfaceBuffer("evr.dll", "MFCreateDXSurfaceBuffer")
+ , fnMFCreateVideoSampleFromSurface("evr.dll", "MFCreateVideoSampleFromSurface")
+ , fnMFCreateMediaType("mfplat.dll", "MFCreateMediaType")
+ , fnAvSetMmThreadCharacteristicsW("avrt.dll", "AvSetMmThreadCharacteristicsW")
+ , fnAvSetMmThreadPriority("avrt.dll", "AvSetMmThreadPriority")
+ , fnAvRevertMmThreadCharacteristics("avrt.dll", "AvRevertMmThreadCharacteristics")
{
const CRenderersSettings& r = GetRenderersSettings();
@@ -123,62 +121,25 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
return;
}
- // Load EVR specific DLLs
- m_hDXVA2Lib = LoadLibrary(L"dxva2.dll");
- if (m_hDXVA2Lib) {
- pfDXVA2CreateDirect3DDeviceManager9 = (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress(m_hDXVA2Lib, "DXVA2CreateDirect3DDeviceManager9");
- }
-
- // Load EVR functions
- m_hEVRLib = LoadLibrary(L"evr.dll");
- if (m_hEVRLib) {
- pfMFCreateDXSurfaceBuffer = (PTR_MFCreateDXSurfaceBuffer) GetProcAddress(m_hEVRLib, "MFCreateDXSurfaceBuffer");
- pfMFCreateVideoSampleFromSurface = (PTR_MFCreateVideoSampleFromSurface) GetProcAddress(m_hEVRLib, "MFCreateVideoSampleFromSurface");
- pfMFCreateVideoMediaType = (PTR_MFCreateVideoMediaType) GetProcAddress(m_hEVRLib, "MFCreateVideoMediaType");
- }
-
- if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType) {
- if (!pfDXVA2CreateDirect3DDeviceManager9) {
+ if (!fnDXVA2CreateDirect3DDeviceManager9 || !fnMFCreateDXSurfaceBuffer || !fnMFCreateVideoSampleFromSurface || !fnMFCreateMediaType) {
+ if (!fnDXVA2CreateDirect3DDeviceManager9) {
_Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
}
- if (!pfMFCreateDXSurfaceBuffer) {
+ if (!fnMFCreateDXSurfaceBuffer) {
_Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
}
- if (!pfMFCreateVideoSampleFromSurface) {
+ if (!fnMFCreateVideoSampleFromSurface) {
_Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
}
- if (!pfMFCreateVideoMediaType) {
- _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
+ if (!fnMFCreateMediaType) {
+ _Error += L"Could not find MFCreateMediaType (mfplat.dll)\n";
}
hr = E_FAIL;
return;
}
- // Load mfplat fuctions
-#if 0
- m_hMFPlatLib = LoadLibrary(L"mfplat.dll");
- if (m_hMFPlatLib) {
- (FARPROC&)pMFCreateMediaType = GetProcAddress(m_hMFPlatLib, "MFCreateMediaType");
- (FARPROC&)pMFInitMediaTypeFromAMMediaType = GetProcAddress(m_hMFPlatLib, "MFInitMediaTypeFromAMMediaType");
- (FARPROC&)pMFInitAMMediaTypeFromMFMediaType = GetProcAddress(m_hMFPlatLib, "MFInitAMMediaTypeFromMFMediaType");
- }
-
- if (!pMFCreateMediaType || !pMFInitMediaTypeFromAMMediaType || !pMFInitAMMediaTypeFromMFMediaType) {
- hr = E_FAIL;
- return;
- }
-#endif
-
- // Load Vista+ specific DLLs
- m_hAVRTLib = LoadLibrary(L"avrt.dll");
- if (m_hAVRTLib) {
- pfAvSetMmThreadCharacteristicsW = (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress(m_hAVRTLib, "AvSetMmThreadCharacteristicsW");
- pfAvSetMmThreadPriority = (PTR_AvSetMmThreadPriority) GetProcAddress(m_hAVRTLib, "AvSetMmThreadPriority");
- pfAvRevertMmThreadCharacteristics = (PTR_AvRevertMmThreadCharacteristics) GetProcAddress(m_hAVRTLib, "AvRevertMmThreadCharacteristics");
- }
-
// Init DXVA manager
- hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
+ hr = fnDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
if (SUCCEEDED(hr) && m_pD3DManager) {
hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
if (FAILED(hr)) {
@@ -189,7 +150,7 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
HANDLE hDevice;
if (SUCCEEDED(m_pD3DManager->OpenDeviceHandle(&hDevice)) &&
SUCCEEDED(m_pD3DManager->GetVideoService(hDevice, IID_PPV_ARGS(&pDecoderService)))) {
- TRACE_EVR("EVR: DXVA2 : device handle = 0x%08x", hDevice);
+ TRACE_EVR("EVR: DXVA2 : device handle = 0x%08x\n", hDevice);
HookDirectXVideoDecoderService(pDecoderService);
m_pD3DManager->CloseDeviceHandle(hDevice);
@@ -212,16 +173,6 @@ CEVRAllocatorPresenter::~CEVRAllocatorPresenter()
m_pMediaType = nullptr;
m_pClock = nullptr;
m_pD3DManager = nullptr;
-
- if (m_hDXVA2Lib) {
- FreeLibrary(m_hDXVA2Lib);
- }
- if (m_hEVRLib) {
- FreeLibrary(m_hEVRLib);
- }
- if (m_hAVRTLib) {
- FreeLibrary(m_hAVRTLib);
- }
}
void CEVRAllocatorPresenter::ResetStats()
@@ -713,95 +664,77 @@ HRESULT CEVRAllocatorPresenter::IsMediaTypeSupported(IMFMediaType* pMixerType)
return hr;
}
-HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** ppType)
+HRESULT CEVRAllocatorPresenter::CreateOptimalOutputType(IMFMediaType* pMixerProposedType, IMFMediaType* pMixerInputType, IMFMediaType** ppType)
{
HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia = nullptr;
- LARGE_INTEGER i64Size;
- MFVIDEOFORMAT* VideoFormat;
+ IMFMediaType* pOptimalMediaType;
- CHECK_HR(pMixerType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
+ CHECK_HR(fnMFCreateMediaType(&pOptimalMediaType));
+ CHECK_HR(pMixerProposedType->CopyAllItems(pOptimalMediaType));
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+ auto colorAttributes = make_array(
+ MF_MT_VIDEO_LIGHTING,
+ MF_MT_VIDEO_PRIMARIES,
+ MF_MT_TRANSFER_FUNCTION,
+ MF_MT_YUV_MATRIX,
+ MF_MT_VIDEO_CHROMA_SITING
+ );
- IMFVideoMediaType* pMediaType;
- hr = pfMFCreateVideoMediaType(VideoFormat, &pMediaType);
+ auto copyAttribute = [](IMFAttributes * pFrom, IMFAttributes * pTo, REFGUID guidKey) {
+ PROPVARIANT val;
+ HRESULT hr = pFrom->GetItem(guidKey, &val);
-#if 0
- // This code doesn't work, use same method as VMR9 instead
- if (VideoFormat->videoInfo.FramesPerSecond.Numerator != 0) {
- switch (VideoFormat->videoInfo.InterlaceMode) {
- case MFVideoInterlace_Progressive:
- case MFVideoInterlace_MixedInterlaceOrProgressive:
- default: {
- m_rtTimePerFrame = (10000000I64 * VideoFormat->videoInfo.FramesPerSecond.Denominator) / VideoFormat->videoInfo.FramesPerSecond.Numerator;
- m_bInterlaced = false;
- }
- break;
- case MFVideoInterlace_FieldSingleUpper:
- case MFVideoInterlace_FieldSingleLower:
- case MFVideoInterlace_FieldInterleavedUpperFirst:
- case MFVideoInterlace_FieldInterleavedLowerFirst: {
- m_rtTimePerFrame = (20000000I64 * VideoFormat->videoInfo.FramesPerSecond.Denominator) / VideoFormat->videoInfo.FramesPerSecond.Numerator;
- m_bInterlaced = true;
- }
- break;
+ if (SUCCEEDED(hr)) {
+ hr = pTo->SetItem(guidKey, val);
+ PropVariantClear(&val);
+ } else if (hr == MF_E_ATTRIBUTENOTFOUND) {
+ hr = pTo->DeleteItem(guidKey);
}
- }
-#endif
+ return hr;
+ };
- CSize videoSize;
- videoSize.cx = VideoFormat->videoInfo.dwWidth;
- videoSize.cy = VideoFormat->videoInfo.dwHeight;
-
- if (SUCCEEDED(hr)) {
- i64Size.HighPart = videoSize.cx;
- i64Size.LowPart = videoSize.cy;
- pMediaType->SetUINT64(MF_MT_FRAME_SIZE, i64Size.QuadPart);
-
- pMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
-
- const CRenderersSettings& r = GetRenderersSettings();
-
-#if 1
- if (r.m_AdvRendSets.iEVROutputRange == 1) {
- pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
- } else {
- pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+ for (REFGUID guidKey : colorAttributes) {
+ if (FAILED(hr = copyAttribute(pMixerInputType, pOptimalMediaType, guidKey))) {
+ TRACE_EVR(_T("Copying color attribute %s failed: 0x%08x\n"), CComBSTR(guidKey), hr);
}
+ }
- // m_pMediaType->SetUINT32 (MF_MT_TRANSFER_FUNCTION, MFVideoTransFunc_10);
-#else
-
- pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
- if (r.iEVROutputRange == 1) {
- pMediaType->SetUINT32(MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT601);
- } else {
- pMediaType->SetUINT32(MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT709);
- }
-#endif
+ pOptimalMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
+ const CRenderersSettings& r = GetRenderersSettings();
+ UINT32 nominalRange;
+ if (SUCCEEDED(pMixerInputType->GetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, &nominalRange))
+ && nominalRange == MFNominalRange_0_255) {
+ // EVR mixer always assume 16-235 input. To ensure that luminance range won't be expanded we requests 16-235 also on output.
+ // Request 16-235 to ensure untouched luminance range on output. It is the only way to pass 0-255 without changes.
+ nominalRange = MFNominalRange_16_235;
+ m_LastSetOutputRange = -1; // -1 to prevent renegotiations because of different value than this in settings.
+ } else {
+ nominalRange = (r.m_AdvRendSets.iEVROutputRange == 1) ? MFNominalRange_16_235 : MFNominalRange_0_255;
m_LastSetOutputRange = r.m_AdvRendSets.iEVROutputRange;
+ }
+ pOptimalMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, nominalRange);
- i64Size.HighPart = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
- i64Size.LowPart = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
- pMediaType->SetUINT64(MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
+ ULARGE_INTEGER ui64Size;
+ pOptimalMediaType->GetUINT64(MF_MT_FRAME_SIZE, &ui64Size.QuadPart);
- MFVideoArea Area = MakeArea(0, 0, videoSize.cx, videoSize.cy);
- pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
+ CSize videoSize((LONG)ui64Size.HighPart, (LONG)ui64Size.LowPart);
+ MFVideoArea Area = MakeArea(0, 0, videoSize.cx, videoSize.cy);
+ pOptimalMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
- }
+ ULARGE_INTEGER ui64AspectRatio;
+ pOptimalMediaType->GetUINT64(MF_MT_PIXEL_ASPECT_RATIO, &ui64AspectRatio.QuadPart);
- UINT64 dwARx = UINT64(VideoFormat->videoInfo.PixelAspectRatio.Numerator) * videoSize.cx;
- UINT64 dwARy = UINT64(VideoFormat->videoInfo.PixelAspectRatio.Denominator) * videoSize.cy;
- UINT64 gcd = GCD(dwARx, dwARy);
+ UINT64 ui64ARx = UINT64(ui64AspectRatio.HighPart) * ui64Size.HighPart;
+ UINT64 ui64ARy = UINT64(ui64AspectRatio.LowPart) * ui64Size.LowPart;
+ UINT64 gcd = GCD(ui64ARx, ui64ARy);
if (gcd > 1) {
- dwARx /= gcd;
- dwARy /= gcd;
+ ui64ARx /= gcd;
+ ui64ARy /= gcd;
}
- CSize aspectRatio((LONG)dwARx, (LONG)dwARy);
+ CSize aspectRatio((LONG)ui64ARx, (LONG)ui64ARy);
if (videoSize != m_nativeVideoSize || aspectRatio != m_aspectRatio) {
SetVideoSize(videoSize, aspectRatio);
@@ -811,8 +744,8 @@ HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerTyp
}
}
- pMixerType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
- pMediaType->QueryInterface(IID_PPV_ARGS(ppType));
+ *ppType = pOptimalMediaType;
+ (*ppType)->AddRef();
return hr;
}
@@ -1000,6 +933,7 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
HRESULT hr = S_OK;
CComPtr pMixerType;
+ CComPtr pMixerInputType;
CComPtr pType;
if (!m_pMixer) {
@@ -1009,13 +943,13 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
CInterfaceArray ValidMixerTypes;
// Get the mixer's input type
- hr = m_pMixer->GetInputCurrentType(0, &pType);
+ hr = m_pMixer->GetInputCurrentType(0, &pMixerInputType);
if (SUCCEEDED(hr)) {
AM_MEDIA_TYPE* pMT;
- hr = pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pMT);
+ hr = pMixerInputType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pMT);
if (SUCCEEDED(hr)) {
m_inputMediaType = *pMT;
- pType->FreeRepresentation(FORMAT_VideoInfo2, pMT);
+ pMixerInputType->FreeRepresentation(FORMAT_VideoInfo2, pMT);
}
}
@@ -1037,7 +971,7 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
}
if (SUCCEEDED(hr)) {
- hr = CreateProposedOutputType(pMixerType, &pType);
+ hr = CreateOptimalOutputType(pMixerType, pMixerInputType, &pType);
}
// Step 4. Check if the mixer will accept this media type.
@@ -1108,7 +1042,7 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
bool CEVRAllocatorPresenter::GetImageFromMixer()
{
- MFT_OUTPUT_DATA_BUFFER Buffer;
+ MFT_OUTPUT_DATA_BUFFER dataBuffer;
HRESULT hr = S_OK;
DWORD dwStatus;
REFERENCE_TIME nsSampleTime;
@@ -1127,18 +1061,20 @@ bool CEVRAllocatorPresenter::GetImageFromMixer()
break;
}
- ZeroMemory(&Buffer, sizeof(Buffer));
- Buffer.pSample = pSample;
+ ZeroMemory(&dataBuffer, sizeof(dataBuffer));
+ dataBuffer.pSample = pSample;
pSample->GetUINT32(GUID_SURFACE_INDEX, &dwSurface);
{
llClockBefore = GetRenderersData()->GetPerfCounter();
- hr = m_pMixer->ProcessOutput(0, 1, &Buffer, &dwStatus);
+ hr = m_pMixer->ProcessOutput(0, 1, &dataBuffer, &dwStatus);
llClockAfter = GetRenderersData()->GetPerfCounter();
}
if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) {
MoveToFreeList(pSample, false);
+ // Important: Release any events returned from the ProcessOutput method.
+ SAFE_RELEASE(dataBuffer.pEvents);
break;
}
@@ -1171,6 +1107,10 @@ bool CEVRAllocatorPresenter::GetImageFromMixer()
MoveToScheduledList(pSample, false);
bDoneSomething = true;
+
+ // Important: Release any events returned from the ProcessOutput method.
+ SAFE_RELEASE(dataBuffer.pEvents);
+
if (m_rtTimePerFrame == 0) {
break;
}
@@ -1529,10 +1469,11 @@ STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(IMFMediaType* pMediaType)
if (SUCCEEDED(hr)) {
for (int i = 0; i < m_nNbDXSurface; i++) {
CComPtr pMFSample;
- hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
+ hr = fnMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
if (SUCCEEDED(hr)) {
pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ CAutoLock sampleQueueLock(&m_SampleQueueLock);
m_FreeSamples.AddTail(pMFSample);
}
ASSERT(SUCCEEDED(hr));
@@ -1922,10 +1863,11 @@ STDMETHODIMP_(bool) CEVRAllocatorPresenter::ResetDevice()
for (int i = 0; i < m_nNbDXSurface; i++) {
CComPtr pMFSample;
- HRESULT hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
+ HRESULT hr = fnMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
if (SUCCEEDED(hr)) {
pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ CAutoLock sampleQueueLock(&m_SampleQueueLock);
m_FreeSamples.AddTail(pMFSample);
}
ASSERT(SUCCEEDED(hr));
@@ -1986,17 +1928,17 @@ void CEVRAllocatorPresenter::RenderThread()
// Tell Multimedia Class Scheduler we are a playback thread (increase priority)
HANDLE hAvrt = 0;
- if (pfAvSetMmThreadCharacteristicsW) {
+ if (fnAvSetMmThreadCharacteristicsW) {
DWORD dwTaskIndex = 0;
- hAvrt = pfAvSetMmThreadCharacteristicsW(L"Playback", &dwTaskIndex);
- if (pfAvSetMmThreadPriority) {
- pfAvSetMmThreadPriority(hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+ hAvrt = fnAvSetMmThreadCharacteristicsW(L"Playback", &dwTaskIndex);
+ if (fnAvSetMmThreadPriority) {
+ fnAvSetMmThreadPriority(hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
}
}
timeGetDevCaps(&tc, sizeof(TIMECAPS));
DWORD dwResolution = std::min(std::max(tc.wPeriodMin, 0u), tc.wPeriodMax);
- DWORD dwUser = timeBeginPeriod(dwResolution);
+ VERIFY(timeBeginPeriod(dwResolution) == 0);
const CRenderersSettings& r = GetRenderersSettings();
int NextSleepTime = 1;
@@ -2059,17 +2001,16 @@ void CEVRAllocatorPresenter::RenderThread()
m_pCurrentDisplaydSample = pMFSample;
bool bValidSampleTime = true;
- HRESULT hGetSampleTime = pMFSample->GetSampleTime(&nsSampleTime);
- if (hGetSampleTime != S_OK || nsSampleTime == 0) {
+ HRESULT hrGetSampleTime = pMFSample->GetSampleTime(&nsSampleTime);
+ if (hrGetSampleTime != S_OK || nsSampleTime == 0) {
bValidSampleTime = false;
}
// We assume that all samples have the same duration
LONGLONG SampleDuration = 0;
bool bValidSampleDuration = true;
- HRESULT hGetSampleDuration = pMFSample->GetSampleDuration(&SampleDuration);
-
+ HRESULT hrGetSampleDuration = pMFSample->GetSampleDuration(&SampleDuration);
// Some filters return invalid values, ignore them
- if (hGetSampleTime != S_OK || SampleDuration <= MIN_FRAME_TIME) {
+ if (hrGetSampleDuration != S_OK || SampleDuration <= MIN_FRAME_TIME) {
bValidSampleDuration = false;
}
@@ -2341,8 +2282,8 @@ void CEVRAllocatorPresenter::RenderThread()
}
timeEndPeriod(dwResolution);
- if (pfAvRevertMmThreadCharacteristics) {
- pfAvRevertMmThreadCharacteristics(hAvrt);
+ if (fnAvRevertMmThreadCharacteristics) {
+ fnAvRevertMmThreadCharacteristics(hAvrt);
}
}
@@ -2418,86 +2359,87 @@ void CEVRAllocatorPresenter::VSyncThread()
WaitForVBlankRange(ScanlineEnd, 5, true, true, false, bTakenLock);
LONGLONG TimeEnd = rd->GetPerfCounter();
- double nSeconds = double(TimeEnd - TimeStart) / 10000000.0;
- LONGLONG DiffMiddle = TimeMiddle - TimeStart;
- LONGLONG DiffEnd = TimeEnd - TimeMiddle;
- double DiffDiff;
- if (DiffEnd > DiffMiddle) {
- DiffDiff = double(DiffEnd) / double(DiffMiddle);
- } else {
- DiffDiff = double(DiffMiddle) / double(DiffEnd);
- }
- if (nSeconds > 0.003 && DiffDiff < 1.3) {
- double ScanLineSeconds;
- double nScanLines;
- if (ScanLineMiddle > ScanlineEnd) {
- ScanLineSeconds = double(TimeMiddle - TimeStart) / 10000000.0;
- nScanLines = ScanLineMiddle - ScanlineStart;
- } else {
- ScanLineSeconds = double(TimeEnd - TimeMiddle) / 10000000.0;
- nScanLines = ScanlineEnd - ScanLineMiddle;
- }
-
- double ScanLineTime = ScanLineSeconds / nScanLines;
-
- int iPos = m_DetectedRefreshRatePos % 100;
- m_ldDetectedScanlineRateList[iPos] = ScanLineTime;
- if (m_DetectedScanlineTime && ScanlineStart != ScanlineEnd) {
- int Diff = ScanlineEnd - ScanlineStart;
- nSeconds -= double(Diff) * m_DetectedScanlineTime;
- }
- m_ldDetectedRefreshRateList[iPos] = nSeconds;
- double Average = 0;
- double AverageScanline = 0;
- int nPos = std::min(iPos + 1, 100);
- for (int i = 0; i < nPos; ++i) {
- Average += m_ldDetectedRefreshRateList[i];
- AverageScanline += m_ldDetectedScanlineRateList[i];
- }
-
- if (nPos) {
- Average /= double(nPos);
- AverageScanline /= double(nPos);
- } else {
- Average = 0;
- AverageScanline = 0;
- }
+ double nSeconds = (TimeEnd - TimeStart) / 10000000.0;
+ LONGLONG llDiffMiddle = TimeMiddle - TimeStart;
+ ASSERT(llDiffMiddle > 0);
+
+ if (nSeconds > 0.003 && llDiffMiddle > 0) {
+ double dDiffMiddle = double(llDiffMiddle);
+ double dDiffEnd = double(TimeEnd - TimeMiddle);
+
+ double dDiffDiff = dDiffEnd / dDiffMiddle;
+ if (dDiffDiff < 1.3 && dDiffDiff > (1 / 1.3)) {
+ double ScanLineSeconds;
+ double nScanLines;
+ if (ScanLineMiddle > ScanlineEnd) {
+ ScanLineSeconds = dDiffMiddle / 10000000.0;
+ nScanLines = ScanLineMiddle - ScanlineStart;
+ } else {
+ ScanLineSeconds = dDiffEnd / 10000000.0;
+ nScanLines = ScanlineEnd - ScanLineMiddle;
+ }
- double ThisValue = Average;
+ double ScanLineTime = ScanLineSeconds / nScanLines;
- if (Average > 0.0 && AverageScanline > 0.0) {
- CAutoLock Lock(&m_refreshRateLock);
- ++m_DetectedRefreshRatePos;
- if (m_DetectedRefreshTime == 0 || m_DetectedRefreshTime / ThisValue > 1.01 || m_DetectedRefreshTime / ThisValue < 0.99) {
- m_DetectedRefreshTime = ThisValue;
- m_DetectedRefreshTimePrim = 0;
- }
- if (_isnan(m_DetectedRefreshTime)) {
- m_DetectedRefreshTime = 0.0;
+ int iPos = m_DetectedRefreshRatePos % 100;
+ m_ldDetectedScanlineRateList[iPos] = ScanLineTime;
+ if (m_DetectedScanlineTime && ScanlineStart != ScanlineEnd) {
+ int Diff = ScanlineEnd - ScanlineStart;
+ nSeconds -= double(Diff) * m_DetectedScanlineTime;
}
- if (_isnan(m_DetectedRefreshTimePrim)) {
- m_DetectedRefreshTimePrim = 0.0;
+ m_ldDetectedRefreshRateList[iPos] = nSeconds;
+ double Average = 0;
+ double AverageScanline = 0;
+ int nPos = std::min(iPos + 1, 100);
+ for (int i = 0; i < nPos; ++i) {
+ Average += m_ldDetectedRefreshRateList[i];
+ AverageScanline += m_ldDetectedScanlineRateList[i];
}
- ModerateFloat(m_DetectedRefreshTime, ThisValue, m_DetectedRefreshTimePrim, 1.5);
- if (m_DetectedRefreshTime > 0.0) {
- m_DetectedRefreshRate = 1.0 / m_DetectedRefreshTime;
+ if (nPos) {
+ Average /= double(nPos);
+ AverageScanline /= double(nPos);
} else {
- m_DetectedRefreshRate = 0.0;
+ Average = 0;
+ AverageScanline = 0;
}
- if (m_DetectedScanlineTime == 0 || m_DetectedScanlineTime / AverageScanline > 1.01 || m_DetectedScanlineTime / AverageScanline < 0.99) {
- m_DetectedScanlineTime = AverageScanline;
- m_DetectedScanlineTimePrim = 0;
- }
- ModerateFloat(m_DetectedScanlineTime, AverageScanline, m_DetectedScanlineTimePrim, 1.5);
- if (m_DetectedScanlineTime > 0.0) {
- m_DetectedScanlinesPerFrame = m_DetectedRefreshTime / m_DetectedScanlineTime;
- } else {
- m_DetectedScanlinesPerFrame = 0;
+ double ThisValue = Average;
+
+ if (Average > 0.0 && AverageScanline > 0.0) {
+ CAutoLock Lock(&m_refreshRateLock);
+ ++m_DetectedRefreshRatePos;
+ if (m_DetectedRefreshTime == 0 || m_DetectedRefreshTime / ThisValue > 1.01 || m_DetectedRefreshTime / ThisValue < 0.99) {
+ m_DetectedRefreshTime = ThisValue;
+ m_DetectedRefreshTimePrim = 0;
+ }
+ if (_isnan(m_DetectedRefreshTime)) {
+ m_DetectedRefreshTime = 0.0;
+ }
+ if (_isnan(m_DetectedRefreshTimePrim)) {
+ m_DetectedRefreshTimePrim = 0.0;
+ }
+
+ ModerateFloat(m_DetectedRefreshTime, ThisValue, m_DetectedRefreshTimePrim, 1.5);
+ if (m_DetectedRefreshTime > 0.0) {
+ m_DetectedRefreshRate = 1.0 / m_DetectedRefreshTime;
+ } else {
+ m_DetectedRefreshRate = 0.0;
+ }
+
+ if (m_DetectedScanlineTime == 0 || m_DetectedScanlineTime / AverageScanline > 1.01 || m_DetectedScanlineTime / AverageScanline < 0.99) {
+ m_DetectedScanlineTime = AverageScanline;
+ m_DetectedScanlineTimePrim = 0;
+ }
+ ModerateFloat(m_DetectedScanlineTime, AverageScanline, m_DetectedScanlineTimePrim, 1.5);
+ if (m_DetectedScanlineTime > 0.0) {
+ m_DetectedScanlinesPerFrame = m_DetectedRefreshTime / m_DetectedScanlineTime;
+ } else {
+ m_DetectedScanlinesPerFrame = 0;
+ }
}
+ //TRACE(_T("Refresh: %f\n"), RefreshRate);
}
- //TRACE(_T("Refresh: %f\n"), RefreshRate);
}
}
} else {
@@ -2534,7 +2476,8 @@ void CEVRAllocatorPresenter::OnResetDevice()
void CEVRAllocatorPresenter::RemoveAllSamples()
{
- CAutoLock AutoLock(&m_ImageProcessingLock);
+ CAutoLock imageProcesssingLock(&m_ImageProcessingLock);
+ CAutoLock sampleQueueLock(&m_SampleQueueLock);
FlushSamples();
m_ScheduledSamples.RemoveAll();
diff --git a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h
index eb70c61c589..292b7a4e1ea 100644
--- a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -23,25 +23,10 @@
#include "DX9AllocatorPresenter.h"
#include // API Media Foundation
#include
+#include "../../../DSUtil/WinapiFunc.h"
namespace DSObjects
{
- // dxva.dll
- typedef HRESULT(__stdcall* PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
-
- // mf.dll
- typedef HRESULT(__stdcall* PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
-
- // evr.dll
- typedef HRESULT(__stdcall* PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
- typedef HRESULT(__stdcall* PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
- typedef HRESULT(__stdcall* PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
-
- // avrt.dll
- typedef HANDLE(__stdcall* PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
- typedef BOOL (__stdcall* PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
- typedef BOOL (__stdcall* PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
-
class COuterEVR;
class CEVRAllocatorPresenter :
@@ -262,31 +247,20 @@ namespace DSObjects
// === Media type negotiation functions
HRESULT RenegotiateMediaType();
HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
- HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
+ HRESULT CreateOptimalOutputType(IMFMediaType* pMixerProposedType, IMFMediaType* pMixerInputType, IMFMediaType** pType);
HRESULT SetMediaType(IMFMediaType* pType);
HRESULT GetMediaTypeFourCC(IMFMediaType* pType, DWORD* pFourCC);
HRESULT GetMediaTypeMerit(IMFMediaType* pType, int* pMerit);
LPCTSTR GetMediaTypeFormatDesc(IMFMediaType* pMediaType);
- // === Functions pointers on Vista+ / .NET Framework 3.5 specific library
- HMODULE m_hDXVA2Lib;
- HMODULE m_hEVRLib;
- HMODULE m_hAVRTLib;
-
- PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
- PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
- PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
- PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
-
-#if 0
- HRESULT(__stdcall* pMFCreateMediaType)(__deref_out IMFMediaType** ppMFType);
- HRESULT(__stdcall* pMFInitMediaTypeFromAMMediaType)(__in IMFMediaType* pMFType, __in const AM_MEDIA_TYPE* pAMType);
- HRESULT(__stdcall* pMFInitAMMediaTypeFromMFMediaType)(__in IMFMediaType* pMFType, __in GUID guidFormatBlockType, __inout AM_MEDIA_TYPE* pAMType);
-#endif
-
- PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
- PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
- PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
+ const WinapiFunc fnDXVA2CreateDirect3DDeviceManager9;
+ const WinapiFunc fnMFCreateDXSurfaceBuffer;
+ const WinapiFunc fnMFCreateVideoSampleFromSurface;
+ const WinapiFunc fnMFCreateMediaType;
+
+ const WinapiFunc fnAvSetMmThreadCharacteristicsW;
+ const WinapiFunc fnAvSetMmThreadPriority;
+ const WinapiFunc fnAvRevertMmThreadCharacteristics;
};
}
diff --git a/src/filters/renderer/VideoRenderers/IPinHook.cpp b/src/filters/renderer/VideoRenderers/IPinHook.cpp
index 3dc19a98e3b..e445a0e5b3d 100644
--- a/src/filters/renderer/VideoRenderers/IPinHook.cpp
+++ b/src/filters/renderer/VideoRenderers/IPinHook.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -47,6 +47,7 @@ GUID g_guidDXVADecoder = GUID_NULL;
int g_nDXVAVersion = 0;
IPinCVtbl* g_pPinCVtbl = nullptr;
+IPinCVtbl* g_pPinCVtblVideoDriverWorkAround = nullptr;
IMemInputPinCVtbl* g_pMemInputPinCVtbl = nullptr;
struct D3DFORMAT_TYPE {
@@ -152,8 +153,8 @@ static HRESULT(STDMETHODCALLTYPE* ReceiveConnectionOrg)(IPinC* This, /* [in] */
static HRESULT STDMETHODCALLTYPE ReceiveConnectionMine(IPinC* This, /* [in] */ IPinC* pConnector, /* [in] */ const AM_MEDIA_TYPE* pmt)
{
- // Force the renderer to always reject the P010 pixel format
- if (pmt && pmt->subtype == MEDIASUBTYPE_P010) {
+ // Force the renderer to always reject the P010 and P016 pixel formats
+ if (pmt && (pmt->subtype == MEDIASUBTYPE_P010 || pmt->subtype == MEDIASUBTYPE_P016)) {
return VFW_E_TYPE_NOT_ACCEPTED;
} else {
return ReceiveConnectionOrg(This, pConnector, pmt);
@@ -183,53 +184,47 @@ static HRESULT STDMETHODCALLTYPE ReceiveMine(IMemInputPinC* This, IMediaSample*
return ReceiveMineI(This, pSample);
}
-void HookWorkAroundNVIDIADriverBug(IPinC* pPinC)
+void HookWorkAroundVideoDriversBug(IBaseFilter* pBF)
{
- // Work-around a bug in NVIDIA drivers v344.11: this driver mistakenly
- // accepts P010 pixel format as input for EVR so use the pin hook to
- // add our own level of verification
-#if MPC_VERSION_MAJOR > 1 || MPC_VERSION_MINOR > 7 || MPC_VERSION_PATCH > 6
-#pragma message("WARNING: Check if this bug is fixed in currently distributed driver")
+ // Work-around a bug in some video drivers: some drivers mistakenly
+ // accepts P010 and P016 pixel formats as input for VMR/EVR renderers
+ // so use the pin hook to add our own level of verification.
+#if MPC_VERSION_MAJOR > 1 || MPC_VERSION_MINOR > 7 || MPC_VERSION_PATCH > 9
+#pragma message("WARNING: Check if this bug is fixed in currently distributed drivers")
#endif
- if (ReceiveConnectionOrg == nullptr) {
- ReceiveConnectionOrg = pPinC->lpVtbl->ReceiveConnection;
- }
- pPinC->lpVtbl->ReceiveConnection = ReceiveConnectionMine;
-}
-void UnhookWorkAroundNVIDIADriverBug()
-{
- if (g_pPinCVtbl->ReceiveConnection == ReceiveConnectionMine) {
- g_pPinCVtbl->ReceiveConnection = ReceiveConnectionOrg;
- }
- ReceiveConnectionOrg = nullptr;
-}
-
-void HookWorkAroundNVIDIADriverBug(IBaseFilter* pBF)
-{
- DWORD flOldProtect = 0;
+ if (CComPtr pPin = GetFirstPin(pBF)) {
+ IPinC* pPinC = (IPinC*)(IPin*)pPin;
- // Unhook previous VTable
- if (g_pPinCVtbl) {
- if (VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect)) {
- UnhookWorkAroundNVIDIADriverBug();
- VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
- g_pPinCVtbl = nullptr;
+ DWORD flOldProtect = 0;
+ if (VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect)) {
+ if (ReceiveConnectionOrg == nullptr) {
+ ReceiveConnectionOrg = pPinC->lpVtbl->ReceiveConnection;
+ }
+ pPinC->lpVtbl->ReceiveConnection = ReceiveConnectionMine;
+ VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
+ g_pPinCVtblVideoDriverWorkAround = pPinC->lpVtbl;
} else {
- TRACE(_T("HookWorkAroundNVIDIADriverBug: Could not unhook previous VTable"));
+ TRACE(_T("HookWorkAroundVideoDriversBug: Could not hook the VTable"));
ASSERT(FALSE);
}
}
+}
- if (CComPtr pPin = GetFirstPin(pBF)) {
- IPinC* pPinC = (IPinC*)(IPin*)pPin;
-
- if (VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect)) {
- HookWorkAroundNVIDIADriverBug(pPinC);
- VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
- g_pPinCVtbl = pPinC->lpVtbl;
+void UnhookWorkAroundVideoDriversBug()
+{
+ // Unhook previous VTable
+ if (g_pPinCVtblVideoDriverWorkAround) {
+ DWORD flOldProtect = 0;
+ if (VirtualProtect(g_pPinCVtblVideoDriverWorkAround, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect)) {
+ if (g_pPinCVtblVideoDriverWorkAround->ReceiveConnection == ReceiveConnectionMine) {
+ g_pPinCVtblVideoDriverWorkAround->ReceiveConnection = ReceiveConnectionOrg;
+ }
+ ReceiveConnectionOrg = nullptr;
+ VirtualProtect(g_pPinCVtblVideoDriverWorkAround, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
+ g_pPinCVtblVideoDriverWorkAround = nullptr;
} else {
- TRACE(_T("HookWorkAroundNVIDIADriverBug: Could not hook the VTable"));
+ TRACE(_T("UnhookWorkAroundVideoDriversBug: Could not unhook previous VTable"));
ASSERT(FALSE);
}
}
@@ -245,7 +240,6 @@ void UnhookNewSegmentAndReceive()
if (g_pPinCVtbl->NewSegment == NewSegmentMine) {
g_pPinCVtbl->NewSegment = NewSegmentOrg;
}
- UnhookWorkAroundNVIDIADriverBug();
VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
g_pPinCVtbl = nullptr;
NewSegmentOrg = nullptr;
@@ -289,7 +283,6 @@ bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPinC)
NewSegmentOrg = pPinC->lpVtbl->NewSegment;
}
pPinC->lpVtbl->NewSegment = NewSegmentMine; // Function sets global variable(s)
- HookWorkAroundNVIDIADriverBug(pPinC);
VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
g_pPinCVtbl = pPinC->lpVtbl;
} else {
diff --git a/src/filters/renderer/VideoRenderers/IPinHook.h b/src/filters/renderer/VideoRenderers/IPinHook.h
index 1712b3e34d1..adb5f8d8304 100644
--- a/src/filters/renderer/VideoRenderers/IPinHook.h
+++ b/src/filters/renderer/VideoRenderers/IPinHook.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -76,7 +76,8 @@ extern bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPin);
extern void UnhookNewSegmentAndReceive();
extern REFERENCE_TIME g_tSegmentStart, g_tSampleStart, g_rtTimePerFrame;
-extern void HookWorkAroundNVIDIADriverBug(IBaseFilter* pBF);
+extern void HookWorkAroundVideoDriversBug(IBaseFilter* pBF);
+extern void UnhookWorkAroundVideoDriversBug();
//
diff --git a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp
index 879103f880e..98a943d5aed 100644
--- a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -87,9 +87,8 @@ HRESULT CRM7AllocatorPresenter::AllocSurfaces()
ddsd.ddpfPixelFormat.dwYUVBitCount = 16;
ddsd.ddpfPixelFormat.dwFourCC = '2YUY';
- m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, nullptr);
-
- if (FAILED(m_pVideoSurfaceOff->Blt(nullptr, m_pVideoSurfaceYUY2, nullptr, DDBLT_WAIT, nullptr))) {
+ if (FAILED(m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, nullptr)) ||
+ FAILED(m_pVideoSurfaceOff->Blt(nullptr, m_pVideoSurfaceYUY2, nullptr, DDBLT_WAIT, nullptr))) {
m_pVideoSurfaceYUY2 = nullptr;
}
diff --git a/src/filters/renderer/VideoRenderers/RenderersSettings.cpp b/src/filters/renderer/VideoRenderers/RenderersSettings.cpp
index 89813297e6a..3f04ec5966f 100644
--- a/src/filters/renderer/VideoRenderers/RenderersSettings.cpp
+++ b/src/filters/renderer/VideoRenderers/RenderersSettings.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -108,21 +108,15 @@ CRenderersData::CRenderersData()
// Don't disable hardware features before initializing a renderer
m_bFP16Support = true;
m_b10bitSupport = true;
+ QueryPerformanceFrequency(&llPerfFrequency);
}
LONGLONG CRenderersData::GetPerfCounter() const
{
LARGE_INTEGER i64Ticks100ns;
- LARGE_INTEGER llPerfFrequency;
- QueryPerformanceFrequency(&llPerfFrequency);
- if (llPerfFrequency.QuadPart != 0) {
- QueryPerformanceCounter(&i64Ticks100ns);
- return llMulDiv(i64Ticks100ns.QuadPart, 10000000, llPerfFrequency.QuadPart, 0);
- } else {
- // ms to 100ns units
- return LONGLONG(timeGetTime()) * 10000;
- }
+ QueryPerformanceCounter(&i64Ticks100ns);
+ return llMulDiv(i64Ticks100ns.QuadPart, 10000000, llPerfFrequency.QuadPart, 0);
}
HINSTANCE CRenderersData::GetD3X9Dll()
diff --git a/src/filters/renderer/VideoRenderers/RenderersSettings.h b/src/filters/renderer/VideoRenderers/RenderersSettings.h
index c8c9e60cc3d..2e57c929a17 100644
--- a/src/filters/renderer/VideoRenderers/RenderersSettings.h
+++ b/src/filters/renderer/VideoRenderers/RenderersSettings.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -131,8 +131,9 @@ class CRenderersSettings
class CRenderersData
{
- HINSTANCE m_hD3DX9Dll;
- UINT m_nDXSdkRelease;
+ HINSTANCE m_hD3DX9Dll;
+ UINT m_nDXSdkRelease;
+ LARGE_INTEGER llPerfFrequency;
public:
CRenderersData();
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
index cc25407b7cf..e4c13b40692 100644
--- a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
+++ b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2010-2014 see Authors.txt
+ * (C) 2010-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -45,6 +45,7 @@
#include "SyncRenderer.h"
#include "version.h"
#include "FocusThread.h"
+#include "../../../DSUtil/ArrayUtils.h"
// only for debugging
//#define DISABLE_USING_D3D9EX
@@ -79,7 +80,7 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
, m_pAudioStats(nullptr)
, m_nNextJitter(0)
, m_nNextSyncOffset(0)
- , m_llLastSyncTime(0)
+ , m_llLastSyncTime(LONGLONG_ERROR)
, m_fAvrFps(0.0)
, m_fJitterStdDev(0.0)
, m_fSyncOffsetStdDev(0.0)
@@ -381,6 +382,7 @@ void CBaseAP::ResetStats()
m_MaxSyncOffset = MINLONG64;
m_uSyncGlitches = 0;
m_pcFramesDropped = 0;
+ m_llLastSyncTime = LONGLONG_ERROR;
}
bool CBaseAP::SettingsNeedResetDevice()
@@ -711,14 +713,13 @@ HRESULT CBaseAP::ResetDXDevice(CString& _Error)
CComPtr rendererInputEnum;
std::vector> decoderOutput;
std::vector> rendererInput;
- FILTER_INFO filterInfo;
- ZeroMemory(&filterInfo, sizeof(filterInfo));
+ CFilterInfo filterInfo;
- bool disconnected = FALSE;
+ bool disconnected = false;
// Disconnect all pins to release video memory resources
if (m_pD3DDev) {
- m_pOuterEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
+ m_pOuterEVR->QueryFilterInfo(&filterInfo);
if (SUCCEEDED(m_pOuterEVR->EnumPins(&rendererInputEnum))) {
CComPtr input;
CComPtr output;
@@ -735,13 +736,15 @@ HRESULT CBaseAP::ResetDXDevice(CString& _Error)
} else {
return hr;
}
- for (DWORD i = 0; i < decoderOutput.size(); i++) {
- TRACE(_T("Disconnecting pin\n"));
- filterInfo.pGraph->Disconnect(decoderOutput.at(i).p);
- filterInfo.pGraph->Disconnect(rendererInput.at(i).p);
- TRACE(_T("Pin disconnected\n"));
+ if (filterInfo.pGraph) {
+ for (size_t i = 0; i < decoderOutput.size(); i++) {
+ TRACE(_T("Disconnecting pin\n"));
+ filterInfo.pGraph->Disconnect(decoderOutput[i].p);
+ filterInfo.pGraph->Disconnect(rendererInput[i].p);
+ TRACE(_T("Pin disconnected\n"));
+ }
+ disconnected = true;
}
- disconnected = true;
}
// Release more resources
@@ -859,15 +862,11 @@ HRESULT CBaseAP::ResetDXDevice(CString& _Error)
}
if (disconnected) {
- for (DWORD i = 0; i < decoderOutput.size(); i++) {
- if (FAILED(filterInfo.pGraph->ConnectDirect(decoderOutput.at(i).p, rendererInput.at(i).p, nullptr))) {
+ for (size_t i = 0; i < decoderOutput.size(); i++) {
+ if (FAILED(filterInfo.pGraph->ConnectDirect(decoderOutput[i].p, rendererInput[i].p, nullptr))) {
return hr;
}
}
-
- if (filterInfo.pGraph != nullptr) {
- filterInfo.pGraph->Release();
- }
}
m_pPSC.Attach(DEBUG_NEW CPixelShaderCompiler(m_pD3DDev, true));
@@ -1461,6 +1460,10 @@ HRESULT CBaseAP::AlphaBlt(RECT* pSrc, const RECT* pDst, IDirect3DTexture9* pText
// Update the array m_pllJitter with a new vsync period. Calculate min, max and stddev.
void CBaseAP::SyncStats(LONGLONG syncTime)
{
+ if (m_llLastSyncTime == LONGLONG_ERROR) {
+ m_llLastSyncTime = syncTime;
+ }
+
m_nNextJitter = (m_nNextJitter + 1) % NB_JITTER;
LONGLONG jitter = syncTime - m_llLastSyncTime;
m_pllJitter[m_nNextJitter] = jitter;
@@ -2401,9 +2404,6 @@ STDMETHODIMP CBaseAP::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScr
CSyncAP::CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
: CBaseAP(hWnd, bFullscreen, hr, _Error)
- , m_hDXVA2Lib(nullptr)
- , m_hEVRLib(nullptr)
- , m_hAVRTLib(nullptr)
, m_nResetToken(0)
, m_hRenderThread(nullptr)
, m_hMixerThread(nullptr)
@@ -2426,13 +2426,13 @@ CSyncAP::CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
, m_bPrerolled(false)
, m_LastClockState(MFCLOCK_STATE_INVALID)
, m_bEvtSkip(false)
- , pfDXVA2CreateDirect3DDeviceManager9(nullptr)
- , pfMFCreateDXSurfaceBuffer(nullptr)
- , pfMFCreateVideoSampleFromSurface(nullptr)
- , pfMFCreateVideoMediaType(nullptr)
- , pfAvSetMmThreadCharacteristicsW(nullptr)
- , pfAvSetMmThreadPriority(nullptr)
- , pfAvRevertMmThreadCharacteristics(nullptr)
+ , fnDXVA2CreateDirect3DDeviceManager9("dxva2.dll", "DXVA2CreateDirect3DDeviceManager9")
+ , fnMFCreateDXSurfaceBuffer("evr.dll", "MFCreateDXSurfaceBuffer")
+ , fnMFCreateVideoSampleFromSurface("evr.dll", "MFCreateVideoSampleFromSurface")
+ , fnMFCreateMediaType("mfplat.dll", "MFCreateMediaType")
+ , fnAvSetMmThreadCharacteristicsW("avrt.dll", "AvSetMmThreadCharacteristicsW")
+ , fnAvSetMmThreadPriority("avrt.dll", "AvSetMmThreadPriority")
+ , fnAvRevertMmThreadCharacteristics("avrt.dll", "AvRevertMmThreadCharacteristics")
{
const CRenderersSettings& r = GetRenderersSettings();
@@ -2441,47 +2441,25 @@ CSyncAP::CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
return;
}
- // Load EVR specific DLLs
- m_hDXVA2Lib = LoadLibrary(L"dxva2.dll");
- if (m_hDXVA2Lib) {
- pfDXVA2CreateDirect3DDeviceManager9 = (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress(m_hDXVA2Lib, "DXVA2CreateDirect3DDeviceManager9");
- }
-
- // Load EVR functions
- m_hEVRLib = LoadLibrary(L"evr.dll");
- if (m_hEVRLib) {
- pfMFCreateDXSurfaceBuffer = (PTR_MFCreateDXSurfaceBuffer)GetProcAddress(m_hEVRLib, "MFCreateDXSurfaceBuffer");
- pfMFCreateVideoSampleFromSurface = (PTR_MFCreateVideoSampleFromSurface)GetProcAddress(m_hEVRLib, "MFCreateVideoSampleFromSurface");
- pfMFCreateVideoMediaType = (PTR_MFCreateVideoMediaType)GetProcAddress(m_hEVRLib, "MFCreateVideoMediaType");
- }
-
- if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType) {
- if (!pfDXVA2CreateDirect3DDeviceManager9) {
+ if (!fnDXVA2CreateDirect3DDeviceManager9 || !fnMFCreateDXSurfaceBuffer || !fnMFCreateVideoSampleFromSurface || !fnMFCreateMediaType) {
+ if (!fnDXVA2CreateDirect3DDeviceManager9) {
_Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
}
- if (!pfMFCreateDXSurfaceBuffer) {
+ if (!fnMFCreateDXSurfaceBuffer) {
_Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
}
- if (!pfMFCreateVideoSampleFromSurface) {
+ if (!fnMFCreateVideoSampleFromSurface) {
_Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
}
- if (!pfMFCreateVideoMediaType) {
- _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
+ if (!fnMFCreateMediaType) {
+ _Error += L"Could not find MFCreateMediaType (mfplat.dll)\n";
}
hr = E_FAIL;
return;
}
- // Load Vista+ specific DLLs
- m_hAVRTLib = LoadLibrary(L"avrt.dll");
- if (m_hAVRTLib) {
- pfAvSetMmThreadCharacteristicsW = (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress(m_hAVRTLib, "AvSetMmThreadCharacteristicsW");
- pfAvSetMmThreadPriority = (PTR_AvSetMmThreadPriority) GetProcAddress(m_hAVRTLib, "AvSetMmThreadPriority");
- pfAvRevertMmThreadCharacteristics = (PTR_AvRevertMmThreadCharacteristics) GetProcAddress(m_hAVRTLib, "AvRevertMmThreadCharacteristics");
- }
-
// Init DXVA manager
- hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
+ hr = fnDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
if (SUCCEEDED(hr) && m_pD3DManager) {
hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
if (FAILED(hr)) {
@@ -2515,16 +2493,6 @@ CSyncAP::~CSyncAP()
m_pMediaType = nullptr;
m_pClock = nullptr;
m_pD3DManager = nullptr;
-
- if (m_hDXVA2Lib) {
- FreeLibrary(m_hDXVA2Lib);
- }
- if (m_hEVRLib) {
- FreeLibrary(m_hEVRLib);
- }
- if (m_hAVRTLib) {
- FreeLibrary(m_hAVRTLib);
- }
}
HRESULT CSyncAP::CheckShutdown() const
@@ -2940,52 +2908,78 @@ HRESULT CSyncAP::IsMediaTypeSupported(IMFMediaType* pMixerType)
return hr;
}
-HRESULT CSyncAP::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** ppType)
+HRESULT CSyncAP::CreateOptimalOutputType(IMFMediaType* pMixerProposedType, IMFMediaType* pMixerInputType, IMFMediaType** ppType)
{
HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia = nullptr;
- LARGE_INTEGER i64Size;
- MFVIDEOFORMAT* VideoFormat;
+ IMFMediaType* pOptimalMediaType;
- CHECK_HR(pMixerType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
+ CHECK_HR(fnMFCreateMediaType(&pOptimalMediaType));
+ CHECK_HR(pMixerProposedType->CopyAllItems(pOptimalMediaType));
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
- hr = pfMFCreateVideoMediaType(VideoFormat, &m_pMediaType);
+ auto colorAttributes = make_array(
+ MF_MT_VIDEO_LIGHTING,
+ MF_MT_VIDEO_PRIMARIES,
+ MF_MT_TRANSFER_FUNCTION,
+ MF_MT_YUV_MATRIX,
+ MF_MT_VIDEO_CHROMA_SITING
+ );
- CSize videoSize;
- videoSize.cx = VideoFormat->videoInfo.dwWidth;
- videoSize.cy = VideoFormat->videoInfo.dwHeight;
+ auto copyAttribute = [](IMFAttributes * pFrom, IMFAttributes * pTo, REFGUID guidKey) {
+ PROPVARIANT val;
+ HRESULT hr = pFrom->GetItem(guidKey, &val);
- if (SUCCEEDED(hr)) {
- i64Size.HighPart = videoSize.cx;
- i64Size.LowPart = videoSize.cy;
- m_pMediaType->SetUINT64(MF_MT_FRAME_SIZE, i64Size.QuadPart);
- m_pMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
- const CRenderersSettings& r = GetRenderersSettings();
+ if (SUCCEEDED(hr)) {
+ hr = pTo->SetItem(guidKey, val);
+ PropVariantClear(&val);
+ } else if (hr == MF_E_ATTRIBUTENOTFOUND) {
+ hr = pTo->DeleteItem(guidKey);
+ }
+ return hr;
+ };
- if (r.m_AdvRendSets.iEVROutputRange == 1) {
- m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
- } else {
- m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+ for (REFGUID guidKey : colorAttributes) {
+ if (FAILED(hr = copyAttribute(pMixerInputType, pOptimalMediaType, guidKey))) {
+ TRACE(_T("Copying color attribute %s failed: 0x%08x\n"), CComBSTR(guidKey), hr);
}
+ }
- m_LastSetOutputRange = r.m_AdvRendSets.iEVROutputRange;
- i64Size.HighPart = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
- i64Size.LowPart = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
- m_pMediaType->SetUINT64(MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
+ pOptimalMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
- MFVideoArea Area = GetArea(0, 0, videoSize.cx, videoSize.cy);
- m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
+ const CRenderersSettings& r = GetRenderersSettings();
+
+ UINT32 nominalRange;
+ if (SUCCEEDED(pMixerInputType->GetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, &nominalRange))
+ && nominalRange == MFNominalRange_0_255) {
+ // EVR mixer always assume 16-235 input. To ensure that luminance range won't be expanded we requests 16-235 also on output.
+ // Request 16-235 to ensure untouched luminance range on output. It is the only way to pass 0-255 without changes.
+ nominalRange = MFNominalRange_16_235;
+ m_LastSetOutputRange = -1; // -1 to prevent renegotiations because of different value than this in settings.
+ } else {
+ nominalRange = (r.m_AdvRendSets.iEVROutputRange == 1) ? MFNominalRange_16_235 : MFNominalRange_0_255;
+ m_LastSetOutputRange = r.m_AdvRendSets.iEVROutputRange;
}
+ pOptimalMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, nominalRange);
+
+ m_LastSetOutputRange = r.m_AdvRendSets.iEVROutputRange;
- UINT64 dwARx = UINT64(VideoFormat->videoInfo.PixelAspectRatio.Numerator) * videoSize.cx;
- UINT64 dwARy = UINT64(VideoFormat->videoInfo.PixelAspectRatio.Denominator) * videoSize.cy;
- UINT64 gcd = GCD(dwARx, dwARy);
+ ULARGE_INTEGER ui64Size;
+ pOptimalMediaType->GetUINT64(MF_MT_FRAME_SIZE, &ui64Size.QuadPart);
+
+ CSize videoSize((LONG)ui64Size.HighPart, (LONG)ui64Size.LowPart);
+ MFVideoArea Area = GetArea(0, 0, videoSize.cx, videoSize.cy);
+ pOptimalMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
+
+ ULARGE_INTEGER ui64AspectRatio;
+ pOptimalMediaType->GetUINT64(MF_MT_PIXEL_ASPECT_RATIO, &ui64AspectRatio.QuadPart);
+
+ UINT64 ui64ARx = UINT64(ui64AspectRatio.HighPart) * ui64Size.HighPart;
+ UINT64 ui64ARy = UINT64(ui64AspectRatio.LowPart) * ui64Size.LowPart;
+ UINT64 gcd = GCD(ui64ARx, ui64ARy);
if (gcd > 1) {
- dwARx /= gcd;
- dwARy /= gcd;
+ ui64ARx /= gcd;
+ ui64ARy /= gcd;
}
- CSize aspectRatio((LONG)dwARx, (LONG)dwARy);
+ CSize aspectRatio((LONG)ui64ARx, (LONG)ui64ARy);
if (videoSize != m_nativeVideoSize || aspectRatio != m_aspectRatio) {
SetVideoSize(videoSize, aspectRatio);
@@ -2996,8 +2990,8 @@ HRESULT CSyncAP::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType
}
}
- pMixerType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
- m_pMediaType->QueryInterface(IID_PPV_ARGS(ppType));
+ *ppType = pOptimalMediaType;
+ (*ppType)->AddRef();
return hr;
}
@@ -3013,6 +3007,9 @@ HRESULT CSyncAP::SetMediaType(IMFMediaType* pType)
hr = InitializeDevice(pAMMedia);
if (SUCCEEDED(hr)) {
+ CAutoLock lock(this);
+ m_pMediaType = pType;
+
strTemp = GetMediaTypeName(pAMMedia->subtype);
strTemp.Replace(L"MEDIASUBTYPE_", L"");
m_strStatsMsg[MSG_MIXEROUT].Format(L"Mixer output : %s", strTemp);
@@ -3066,6 +3063,7 @@ HRESULT CSyncAP::RenegotiateMediaType()
HRESULT hr = S_OK;
CComPtr pMixerType;
+ CComPtr pMixerInputType;
CComPtr pType;
if (!m_pMixer) {
@@ -3073,13 +3071,13 @@ HRESULT CSyncAP::RenegotiateMediaType()
}
// Get the mixer's input type
- hr = m_pMixer->GetInputCurrentType(0, &pType);
+ hr = m_pMixer->GetInputCurrentType(0, &pMixerInputType);
if (SUCCEEDED(hr)) {
AM_MEDIA_TYPE* pMT;
- hr = pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pMT);
+ hr = pMixerInputType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pMT);
if (SUCCEEDED(hr)) {
m_inputMediaType = *pMT;
- pType->FreeRepresentation(FORMAT_VideoInfo2, pMT);
+ pMixerInputType->FreeRepresentation(FORMAT_VideoInfo2, pMT);
}
}
@@ -3089,7 +3087,6 @@ HRESULT CSyncAP::RenegotiateMediaType()
while ((hr != MF_E_NO_MORE_TYPES)) {
pMixerType = nullptr;
pType = nullptr;
- m_pMediaType = nullptr;
// Step 1. Get the next media type supported by mixer.
hr = m_pMixer->GetOutputAvailableType(0, iTypeIndex++, &pMixerType);
@@ -3101,7 +3098,7 @@ HRESULT CSyncAP::RenegotiateMediaType()
hr = IsMediaTypeSupported(pMixerType);
}
if (SUCCEEDED(hr)) {
- hr = CreateProposedOutputType(pMixerType, &pType);
+ hr = CreateOptimalOutputType(pMixerType, pMixerInputType, &pType);
}
// Step 4. Check if the mixer will accept this media type.
if (SUCCEEDED(hr)) {
@@ -3151,7 +3148,7 @@ HRESULT CSyncAP::RenegotiateMediaType()
bool CSyncAP::GetSampleFromMixer()
{
- MFT_OUTPUT_DATA_BUFFER Buffer;
+ MFT_OUTPUT_DATA_BUFFER dataBuffer;
HRESULT hr = S_OK;
DWORD dwStatus;
LONGLONG llClockBefore = 0;
@@ -3168,17 +3165,19 @@ bool CSyncAP::GetSampleFromMixer()
break;
}
- ZeroMemory(&Buffer, sizeof(Buffer));
- Buffer.pSample = pSample;
+ ZeroMemory(&dataBuffer, sizeof(dataBuffer));
+ dataBuffer.pSample = pSample;
pSample->GetUINT32(GUID_SURFACE_INDEX, &dwSurface);
{
llClockBefore = GetRenderersData()->GetPerfCounter();
- hr = m_pMixer->ProcessOutput(0 , 1, &Buffer, &dwStatus);
+ hr = m_pMixer->ProcessOutput(0 , 1, &dataBuffer, &dwStatus);
llClockAfter = GetRenderersData()->GetPerfCounter();
}
if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { // There are no samples left in the mixer
MoveToFreeList(pSample, false);
+ // Important: Release any events returned from the ProcessOutput method.
+ SAFE_RELEASE(dataBuffer.pEvents);
break;
}
if (m_pSink) {
@@ -3203,6 +3202,8 @@ bool CSyncAP::GetSampleFromMixer()
m_nTearingPos = (m_nTearingPos + 7) % m_nativeVideoSize.cx;
}
MoveToScheduledList(pSample, false); // Schedule, then go back to see if there is more where that came from
+ // Important: Release any events returned from the ProcessOutput method.
+ SAFE_RELEASE(dataBuffer.pEvents);
}
return newSample;
}
@@ -3532,9 +3533,10 @@ STDMETHODIMP CSyncAP::InitializeDevice(AM_MEDIA_TYPE* pMediaType)
for (int i = 0; i < m_nDXSurface; i++) {
CComPtr pMFSample;
- hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
+ hr = fnMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
if (SUCCEEDED(hr)) {
pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ CAutoLock sampleQueueLock(&m_SampleQueueLock);
m_FreeSamples.AddTail(pMFSample);
}
ASSERT(SUCCEEDED(hr));
@@ -3617,18 +3619,18 @@ void CSyncAP::RenderThread()
// Tell Multimedia Class Scheduler we are doing threaded playback (increase priority)
HANDLE hAvrt = 0;
- if (pfAvSetMmThreadCharacteristicsW) {
+ if (fnAvSetMmThreadCharacteristicsW) {
DWORD dwTaskIndex = 0;
- hAvrt = pfAvSetMmThreadCharacteristicsW(L"Playback", &dwTaskIndex);
- if (pfAvSetMmThreadPriority) {
- pfAvSetMmThreadPriority(hAvrt, AVRT_PRIORITY_HIGH);
+ hAvrt = fnAvSetMmThreadCharacteristicsW(L"Playback", &dwTaskIndex);
+ if (fnAvSetMmThreadPriority) {
+ fnAvSetMmThreadPriority(hAvrt, AVRT_PRIORITY_HIGH);
}
}
// Set timer resolution
timeGetDevCaps(&tc, sizeof(TIMECAPS));
DWORD dwResolution = std::min(std::max(tc.wPeriodMin, 0u), tc.wPeriodMax);
- DWORD dwUser = timeBeginPeriod(dwResolution);
+ VERIFY(timeBeginPeriod(dwResolution) == 0);
pNewSample = nullptr;
while (!bQuit) {
@@ -3808,8 +3810,8 @@ void CSyncAP::RenderThread()
pNewSample = nullptr;
}
timeEndPeriod(dwResolution);
- if (pfAvRevertMmThreadCharacteristics) {
- pfAvRevertMmThreadCharacteristics(hAvrt);
+ if (fnAvRevertMmThreadCharacteristics) {
+ fnAvRevertMmThreadCharacteristics(hAvrt);
}
}
@@ -3818,15 +3820,17 @@ STDMETHODIMP_(bool) CSyncAP::ResetDevice()
CAutoLock lock(this);
CAutoLock lock2(&m_ImageProcessingLock);
CAutoLock cRenderLock(&m_allocatorLock);
+
RemoveAllSamples();
bool bResult = __super::ResetDevice();
for (int i = 0; i < m_nDXSurface; i++) {
CComPtr pMFSample;
- HRESULT hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
+ HRESULT hr = fnMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
if (SUCCEEDED(hr)) {
pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ CAutoLock sampleQueueLock(&m_SampleQueueLock);
m_FreeSamples.AddTail(pMFSample);
}
ASSERT(SUCCEEDED(hr));
@@ -3849,7 +3853,9 @@ void CSyncAP::OnResetDevice()
void CSyncAP::RemoveAllSamples()
{
- CAutoLock AutoLock(&m_ImageProcessingLock);
+ CAutoLock imageProcesssingLock(&m_ImageProcessingLock);
+ CAutoLock sampleQueueLock(&m_SampleQueueLock);
+
FlushSamples();
m_ScheduledSamples.RemoveAll();
m_FreeSamples.RemoveAll();
@@ -3905,11 +3911,11 @@ void CSyncAP::MoveToFreeList(IMFSample* pSample, bool bTail)
void CSyncAP::MoveToScheduledList(IMFSample* pSample, bool _bSorted)
{
+ CAutoLock lock(&m_SampleQueueLock);
+
if (_bSorted) {
- CAutoLock lock(&m_SampleQueueLock);
m_ScheduledSamples.AddHead(pSample);
} else {
- CAutoLock lock(&m_SampleQueueLock);
m_ScheduledSamples.AddTail(pSample);
}
}
@@ -3942,10 +3948,9 @@ HRESULT CSyncAP::BeginStreaming()
m_pcFramesDrawn = 0;
CComPtr pEVR;
- FILTER_INFO filterInfo;
- ZeroMemory(&filterInfo, sizeof(filterInfo));
+ CFilterInfo filterInfo;
m_pOuterEVR->QueryInterface(IID_PPV_ARGS(&pEVR));
- pEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
+ pEVR->QueryFilterInfo(&filterInfo);
BeginEnumFilters(filterInfo.pGraph, pEF, pBF);
if (CComQIPtr pAS = pBF) {
@@ -3954,9 +3959,6 @@ HRESULT CSyncAP::BeginStreaming()
EndEnumFilters;
pEVR->GetSyncSource(&m_pRefClock);
- if (filterInfo.pGraph) {
- filterInfo.pGraph->Release();
- }
m_pGenlock->SetMonitor(GetAdapter(m_pD3D, m_hWnd));
m_pGenlock->GetTiming();
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.h b/src/filters/renderer/VideoRenderers/SyncRenderer.h
index fca1d67dd89..7455e0e0c9c 100644
--- a/src/filters/renderer/VideoRenderers/SyncRenderer.h
+++ b/src/filters/renderer/VideoRenderers/SyncRenderer.h
@@ -1,5 +1,5 @@
/*
- * (C) 2010-2014 see Authors.txt
+ * (C) 2010-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -25,6 +25,7 @@
#include "SyncAllocatorPresenter.h"
#include "AllocatorCommon.h"
#include
+#include "../../../DSUtil/WinapiFunc.h"
#define VMRBITMAP_UPDATE 0x80000000
#define MAX_PICTURE_SLOTS (60 + 2) // Last 2 for pixels shader!
@@ -449,19 +450,6 @@ namespace GothSync
MFCLOCK_STATE m_LastClockState;
private:
- // dxva.dll
- typedef HRESULT(__stdcall* PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
- // mf.dll
- typedef HRESULT(__stdcall* PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
- // evr.dll
- typedef HRESULT(__stdcall* PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
- typedef HRESULT(__stdcall* PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
- typedef HRESULT(__stdcall* PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
- // avrt.dll
- typedef HANDLE(__stdcall* PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
- typedef BOOL (__stdcall* PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
- typedef BOOL (__stdcall* PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
-
enum RENDER_STATE {
Started = State_Running,
Stopped = State_Stopped,
@@ -473,7 +461,7 @@ namespace GothSync
CComPtr m_pD3DManager;
CComPtr m_pMixer;
CComPtr m_pSink;
- CComPtr m_pMediaType;
+ CComPtr m_pMediaType;
MFVideoAspectRatioMode m_dwVideoAspectRatioMode;
MFVideoRenderPrefs m_dwVideoRenderPrefs;
COLORREF m_BorderColor;
@@ -529,22 +517,17 @@ namespace GothSync
LONGLONG GetMediaTypeMerit(IMFMediaType* pMediaType);
HRESULT RenegotiateMediaType();
HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
- HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
+ HRESULT CreateOptimalOutputType(IMFMediaType* pMixerProposedType, IMFMediaType* pMixerInputType, IMFMediaType** ppType);
HRESULT SetMediaType(IMFMediaType* pType);
- // Functions pointers for Vista+ / .NET Framework 3.5 specific library
- HMODULE m_hDXVA2Lib;
- HMODULE m_hEVRLib;
- HMODULE m_hAVRTLib;
-
- PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
- PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
- PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
- PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
+ const WinapiFunc fnDXVA2CreateDirect3DDeviceManager9;
+ const WinapiFunc fnMFCreateDXSurfaceBuffer;
+ const WinapiFunc fnMFCreateVideoSampleFromSurface;
+ const WinapiFunc fnMFCreateMediaType;
- PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
- PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
- PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
+ const WinapiFunc fnAvSetMmThreadCharacteristicsW;
+ const WinapiFunc fnAvSetMmThreadPriority;
+ const WinapiFunc fnAvRevertMmThreadCharacteristics;
};
class CSyncRenderer:
diff --git a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp
index 0124367e6c3..3faf3784d6e 100644
--- a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -23,7 +23,8 @@
#include "../../../SubPic/DX9SubPic.h"
#include "../../../SubPic/SubPicQueueImpl.h"
#include "RenderersSettings.h"
-#include "moreuuids.h"
+#include
+
using namespace DSObjects;
@@ -88,8 +89,6 @@ STDMETHODIMP CmadVRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid,
HRESULT CmadVRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev)
{
- const CRenderersSettings& r = GetRenderersSettings();
-
if (!pD3DDev) {
// release all resources
m_pSubPicQueue = nullptr;
@@ -97,6 +96,7 @@ HRESULT CmadVRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev)
return S_OK;
}
+ const CRenderersSettings& r = GetRenderersSettings();
InitMaxSubtitleTextureSize(r.subPicQueueSettings.nMaxRes, m_ScreenSize);
if (m_pAllocator) {
@@ -187,6 +187,8 @@ STDMETHODIMP_(void) CmadVRAllocatorPresenter::SetPosition(RECT w, RECT v)
if (CComQIPtr pVW = m_pDXR) {
pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
}
+
+ SetVideoSize(GetVideoSize(), GetVideoSize(true));
}
STDMETHODIMP_(SIZE) CmadVRAllocatorPresenter::GetVideoSize(bool bCorrectAR) const
diff --git a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h
index b7290103491..2bbf45e0615 100644
--- a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -20,11 +20,8 @@
#pragma once
-#include "AllocatorCommon.h"
-#include "../../../SubPic/SubPicAllocatorPresenterImpl.h"
-#include "../../../SubPic/ISubRender.h"
-
-#include
+#include "../SubPic/SubPicAllocatorPresenterImpl.h"
+#include "../SubPic/ISubRender.h"
namespace DSObjects
{
@@ -94,7 +91,7 @@ namespace DSObjects
// ISubPicAllocatorPresenter
STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
- STDMETHODIMP_(SIZE) GetVideoSize(bool bCorrectAR) const;
+ STDMETHODIMP_(SIZE) GetVideoSize(bool bCorrectAR = true) const;
STDMETHODIMP_(bool) Paint(bool bAll);
STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
diff --git a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
index 1cdedbb203e..0c20030daff 100644
--- a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
+++ b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -27,6 +27,9 @@
#include
#include "moreuuids.h"
+// Even if we don't use this, it is needed for mvrInterfaces.h
+typedef interface IDirect3DDevice9* LPDIRECT3DDEVICE9;
+#include
//
// CBaseVideoFilter
diff --git a/src/filters/transform/VSFilter/Copy.cpp b/src/filters/transform/VSFilter/Copy.cpp
index 3d9293b0e52..b6c65e0d8f8 100644
--- a/src/filters/transform/VSFilter/Copy.cpp
+++ b/src/filters/transform/VSFilter/Copy.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -44,7 +44,7 @@ void BltLineRGB32(DWORD* d, BYTE* sub, int w, const GUID& subtype)
for (; db < dbtend; sub += 4, db++) {
if (sub[3] < 0xff) {
int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
- *db = y; // w/o colors
+ *db = BYTE(y); // w/o colors
}
}
} else if (subtype == MEDIASUBTYPE_YUY2) {
@@ -54,7 +54,7 @@ void BltLineRGB32(DWORD* d, BYTE* sub, int w, const GUID& subtype)
for (; ds < dstend; sub += 4, ds++) {
if (sub[3] < 0xff) {
int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
- *ds = 0x8000 | y; // w/o colors
+ *ds = WORD(0x8000 | y); // w/o colors
}
}
} else if (subtype == MEDIASUBTYPE_RGB555) {
diff --git a/src/filters/transform/VSFilter/DirectVobSub.cpp b/src/filters/transform/VSFilter/DirectVobSub.cpp
index e9fb9ead8dd..f8cdc9b1c79 100644
--- a/src/filters/transform/VSFilter/DirectVobSub.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSub.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -300,12 +300,12 @@ STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* colo
return E_INVALIDARG;
}
- ((LOGFONT*)lf)->lfCharSet = m_defStyle.charSet;
- ((LOGFONT*)lf)->lfItalic = m_defStyle.fItalic;
+ ((LOGFONT*)lf)->lfCharSet = (BYTE)m_defStyle.charSet;
+ ((LOGFONT*)lf)->lfItalic = (BYTE)m_defStyle.fItalic;
((LOGFONT*)lf)->lfHeight = (LONG)m_defStyle.fontSize;
((LOGFONT*)lf)->lfWeight = m_defStyle.fontWeight;
- ((LOGFONT*)lf)->lfStrikeOut = m_defStyle.fStrikeOut;
- ((LOGFONT*)lf)->lfUnderline = m_defStyle.fUnderline;
+ ((LOGFONT*)lf)->lfStrikeOut = (BYTE)m_defStyle.fStrikeOut;
+ ((LOGFONT*)lf)->lfUnderline = (BYTE)m_defStyle.fUnderline;
}
if (color) {
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
index db2d287acb5..beefbdeac7a 100644
--- a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -1622,31 +1622,30 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream)
pRTS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc);
pRTS->Deinit();
- } else if (clsid == __uuidof(CRLECodedSubtitle)) {
- CRLECodedSubtitle* pRHS = (CRLECodedSubtitle*)pSubStream;
-
- DXVA2_ExtendedFormat extFormat;
- extFormat.value = m_cf;
- CString yuvMatrix = (extFormat.NominalRange == DXVA2_NominalRange_Normal) ? _T("PC.") : _T("TV.");
+ }
- switch (extFormat.VideoTransferMatrix) {
- case DXVA2_VideoTransferMatrix_BT601:
- yuvMatrix.Append(_T("601"));
- break;
- case DXVA2_VideoTransferMatrix_BT709:
- yuvMatrix.Append(_T("709"));
- break;
- case DXVA2_VideoTransferMatrix_SMPTE240M:
- yuvMatrix.Append(_T("240M"));
- break;
- default:
- yuvMatrix = _T("None");
- break;
- }
+ DXVA2_ExtendedFormat extFormat;
+ extFormat.value = m_cf;
+ CString yuvMatrix = (extFormat.NominalRange == DXVA2_NominalRange_Normal) ? _T("PC.") : _T("TV.");
- // Actually VSFilter expect full range (A)RGB frames to work with.
- pRHS->SetSourceTargetInfo(yuvMatrix, 0, 255);
+ switch (extFormat.VideoTransferMatrix) {
+ case DXVA2_VideoTransferMatrix_BT601:
+ yuvMatrix.Append(_T("601"));
+ break;
+ case DXVA2_VideoTransferMatrix_BT709:
+ yuvMatrix.Append(_T("709"));
+ break;
+ case DXVA2_VideoTransferMatrix_SMPTE240M:
+ yuvMatrix.Append(_T("240M"));
+ break;
+ default:
+ yuvMatrix = _T("None");
+ break;
}
+
+ yuvMatrix.Append(_T(".VSFilter"));
+ // Actually VSFilter expect full range (A)RGB frames to work with.
+ pSubStream->SetSourceTargetInfo(yuvMatrix, 0, 255);
}
int i = 0;
diff --git a/src/filters/transform/VSFilter/StyleEditorDialog.cpp b/src/filters/transform/VSFilter/StyleEditorDialog.cpp
index 806e6cff51d..3e4e4773429 100644
--- a/src/filters/transform/VSFilter/StyleEditorDialog.cpp
+++ b/src/filters/transform/VSFilter/StyleEditorDialog.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -193,7 +193,8 @@ void CStyleEditorDialog::OnOK()
m_stss.marginRect = m_margin;
for (size_t i = 0; i < m_alpha.size(); i++) {
- m_stss.alpha[i] = BYTE_MAX - m_alpha[i];
+ ASSERT(m_alpha[i] <= BYTE_MAX);
+ m_stss.alpha[i] = BYTE_MAX - BYTE(m_alpha[i]);
}
__super::OnOK();
diff --git a/src/filters/transform/VSFilter/installer/build_installer.bat b/src/filters/transform/VSFilter/installer/build_installer.bat
index 13314751a96..c397f3ec810 100755
--- a/src/filters/transform/VSFilter/installer/build_installer.bat
+++ b/src/filters/transform/VSFilter/installer/build_installer.bat
@@ -1,5 +1,5 @@
@ECHO OFF
-REM (C) 2012-2013 see Authors.txt
+REM (C) 2012-2013, 2015 see Authors.txt
REM
REM This file is part of MPC-HC.
REM
@@ -18,17 +18,14 @@ REM along with this program. If not, see .
SETLOCAL
-PUSHD %~dp0
-
-REM You can set here the Inno Setup path if for example you have Inno Setup Unicode
-REM installed and you want to use the ANSI Inno Setup which is in another location
-IF NOT DEFINED InnoSetupPath SET "InnoSetupPath=H:\progs\thirdparty\isetup"
+SET "FILE_DIR=%~dp0"
+PUSHD "%FILE_DIR%"
SET ROOT_DIR=..\..\..\..\..
SET "BIN_DIR=%ROOT_DIR%\bin"
-CALL :SubDetectInnoSetup
-IF EXIST "%~dp0%ROOT_DIR%\signinfo.txt" (
+CALL "%FILE_DIR%%ROOT_DIR%\common.bat" :SubDetectInnoSetup
+IF EXIST "%FILE_DIR%%ROOT_DIR%\signinfo.txt" (
CALL :SubSign VSFilter.dll x86
CALL :SubSign VSFilter.dll x64
)
@@ -48,7 +45,7 @@ REM %1 is name of the file to sign
REM %2 is the platform
PUSHD "%BIN_DIR%\Filters_%~2\"
-CALL "%~dp0%ROOT_DIR%\contrib\sign.bat" "%1" || (ECHO Problem signing %1 & GOTO Break)
+CALL "%FILE_DIR%%ROOT_DIR%\contrib\sign.bat" "%1" || (ECHO Problem signing %1 & GOTO Break)
ECHO %1 signed successfully.
:Break
@@ -60,7 +57,7 @@ EXIT /B
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
ECHO.
TITLE Building VSFilter installer...
-"%InnoSetupPath%\ISCC.exe" /SMySignTool="cmd /c "%~dp0%ROOT_DIR%\contrib\sign.bat" $f" /Q^
+"%InnoSetupPath%\ISCC.exe" /SMySignTool="cmd /c "%FILE_DIR%%ROOT_DIR%\contrib\sign.bat" $f" /Q^
"vsfilter_setup.iss" /D%~1
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
IF /I "%~1%" == "x64Build" (
@@ -71,34 +68,6 @@ IF /I "%~1%" == "x64Build" (
EXIT /B
-:SubDetectInnoSetup
-REM Detect if we are running on 64bit Windows and use Wow6432Node since Inno Setup is
-REM a 32-bit application, and set the registry key of Inno Setup accordingly
-IF DEFINED PROGRAMFILES(x86) (
- SET "U_=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
-) ELSE (
- SET "U_=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
-)
-
-IF DEFINED InnoSetupPath IF NOT EXIST "%InnoSetupPath%" (
- ECHO "%InnoSetupPath%" wasn't found on this machine! I will try to detect Inno Setup's path from the registry...
-)
-
-IF NOT EXIST "%InnoSetupPath%" (
- FOR /F "delims=" %%a IN (
- 'REG QUERY "%U_%\Inno Setup 5_is1" /v "Inno Setup: App Path"2^>Nul^|FIND "REG_SZ"') DO (
- SET "InnoSetupPath=%%a" & CALL :SubInnoSetupPath %%InnoSetupPath:*Z=%%)
-)
-
-IF NOT EXIST "%InnoSetupPath%" ECHO Inno Setup wasn't found! & GOTO EndWithError
-EXIT /B
-
-
-:SubInnoSetupPath
-SET "InnoSetupPath=%*"
-EXIT /B
-
-
:EndWithError
Title Building VSFilter installer [ERROR]
COLOR 0C
diff --git a/src/mpc-hc/AboutDlg.cpp b/src/mpc-hc/AboutDlg.cpp
index d394a5073ed..e6bb01994b9 100644
--- a/src/mpc-hc/AboutDlg.cpp
+++ b/src/mpc-hc/AboutDlg.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2012-2014 see Authors.txt
+ * (C) 2012-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -31,7 +31,6 @@
#include "PathUtils.h"
#include
-extern "C" char g_Gcc_Compiler[];
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
@@ -216,7 +215,7 @@ void CAboutDlg::OnCopyToClipboard()
info += _T(" LAV Splitter: ") + CFGFilterLAV::GetVersion(CFGFilterLAV::SPLITTER) + _T("\r\n");
info += _T(" LAV Video: ") + CFGFilterLAV::GetVersion(CFGFilterLAV::VIDEO_DECODER) + _T("\r\n");
info += _T(" LAV Audio: ") + CFGFilterLAV::GetVersion(CFGFilterLAV::AUDIO_DECODER) + _T("\r\n");
- info += _T(" FFmpeg compiler: ") + CString(g_Gcc_Compiler) + _T("\r\n\r\n");
+ info += _T(" FFmpeg compiler: ") + VersionInfo::GetGCCVersion() + _T("\r\n\r\n");
#endif
info += _T("Operating system:\r\n");
info += _T(" Name: ") + m_OSName + _T("\r\n");
diff --git a/src/mpc-hc/AppSettings.cpp b/src/mpc-hc/AppSettings.cpp
index 381bd1dec58..75107c56543 100644
--- a/src/mpc-hc/AppSettings.cpp
+++ b/src/mpc-hc/AppSettings.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -24,7 +24,8 @@
#include "AppSettings.h"
#include "FGFilter.h"
#include "FileAssoc.h"
-#include "MiniDump.h"
+#include "CrashReporter.h"
+#include "CrashReporterDialog.h"
#include "VersionInfo.h"
#include "SysVersion.h"
#include "WinAPIUtils.h"
@@ -32,6 +33,7 @@
#include "Translations.h"
#include "UpdateChecker.h"
#include "moreuuids.h"
+#include
#pragma warning(push)
@@ -53,6 +55,7 @@ CAppSettings::CAppSettings()
, nOSDSize(0)
, nSpeakerChannels(2)
, fRemainingTime(false)
+ , bHighPrecisionTimer(false)
, nUpdaterAutoCheck(-1)
, nUpdaterDelay(7)
, fBDAUseOffset(false)
@@ -198,6 +201,7 @@ CAppSettings::CAppSettings()
, nJpegQuality(90)
, bEnableCoverArt(true)
, nCoverArtSizeLimit(600)
+ , bEnableLogging(false)
{
// Internal source filter
#if INTERNAL_SOURCEFILTER_CDDA
@@ -212,8 +216,11 @@ CAppSettings::CAppSettings()
#if INTERNAL_SOURCEFILTER_FLIC
SrcFiltersKeys[SRC_FLIC] = FilterKey(_T("SRC_FLIC"), true);
#endif
-#if INTERNAL_SOURCEFILTER_DTSAC3
- SrcFiltersKeys[SRC_DTSAC3] = FilterKey(_T("SRC_DTSAC3"), true);
+#if INTERNAL_SOURCEFILTER_AC3
+ SrcFiltersKeys[SRC_AC3] = FilterKey(_T("SRC_AC3"), true);
+#endif
+#if INTERNAL_SOURCEFILTER_DTS
+ SrcFiltersKeys[SRC_DTS] = FilterKey(_T("SRC_DTS"), true);
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
SrcFiltersKeys[SRC_MATROSKA] = FilterKey(_T("SRC_MATROSKA"), true);
@@ -270,6 +277,9 @@ CAppSettings::CAppSettings()
#if INTERNAL_SOURCEFILTER_ASF
SrcFiltersKeys[SRC_ASF] = FilterKey(_T("SRC_ASF"), false);
#endif
+#if INTERNAL_SOURCEFILTER_WTV
+ SrcFiltersKeys[SRC_WTV] = FilterKey(_T("SRC_WTV"), true);
+#endif
#if INTERNAL_SOURCEFILTER_FLAC
SrcFiltersKeys[SRC_FLAC] = FilterKey(_T("SRC_FLAC"), true);
#endif
@@ -396,195 +406,194 @@ CAppSettings::CAppSettings()
void CAppSettings::CreateCommands()
{
-#define ADDCMD(cmd) wmcmds.AddTail(wmcmd##cmd)
- ADDCMD((ID_FILE_OPENQUICK, 'Q', FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_0));
- ADDCMD((ID_FILE_OPENMEDIA, 'O', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_FILE));
- ADDCMD((ID_FILE_OPENDVDBD, 'D', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_DVD));
- ADDCMD((ID_FILE_OPENDEVICE, 'V', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_DEVICE));
- ADDCMD((ID_FILE_REOPEN, 'E', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_REOPEN));
- ADDCMD((ID_FILE_RECYCLE, 0, FVIRTKEY | FNOINVERT, IDS_FILE_RECYCLE));
-
- ADDCMD((ID_FILE_SAVE_COPY, 0, FVIRTKEY | FNOINVERT, IDS_AG_SAVE_COPY));
- ADDCMD((ID_FILE_SAVE_IMAGE, 'I', FVIRTKEY | FALT | FNOINVERT, IDS_AG_SAVE_IMAGE));
- ADDCMD((ID_FILE_SAVE_IMAGE_AUTO, VK_F5, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_6));
- ADDCMD((ID_FILE_SAVE_THUMBNAILS, 0, FVIRTKEY | FNOINVERT, IDS_FILE_SAVE_THUMBNAILS));
-
- ADDCMD((ID_FILE_LOAD_SUBTITLE, 'L', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_LOAD_SUBTITLE));
- ADDCMD((ID_FILE_SAVE_SUBTITLE, 'S', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_SAVE_SUBTITLE));
- ADDCMD((ID_FILE_CLOSE_AND_RESTORE, 'C', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_CLOSE));
- ADDCMD((ID_FILE_PROPERTIES, VK_F10, FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PROPERTIES));
- ADDCMD((ID_FILE_EXIT, 'X', FVIRTKEY | FALT | FNOINVERT, IDS_AG_EXIT));
- ADDCMD((ID_PLAY_PLAYPAUSE, VK_SPACE, FVIRTKEY | FNOINVERT, IDS_AG_PLAYPAUSE, APPCOMMAND_MEDIA_PLAY_PAUSE, wmcmd::LUP, wmcmd::LUP));
- ADDCMD((ID_PLAY_PLAY, 0, FVIRTKEY | FNOINVERT, IDS_AG_PLAY, APPCOMMAND_MEDIA_PLAY));
- ADDCMD((ID_PLAY_PAUSE, 0, FVIRTKEY | FNOINVERT, IDS_AG_PAUSE, APPCOMMAND_MEDIA_PAUSE));
- ADDCMD((ID_PLAY_STOP, VK_OEM_PERIOD, FVIRTKEY | FNOINVERT, IDS_AG_STOP, APPCOMMAND_MEDIA_STOP));
- ADDCMD((ID_PLAY_FRAMESTEP, VK_RIGHT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_FRAMESTEP));
- ADDCMD((ID_PLAY_FRAMESTEPCANCEL, VK_LEFT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_16));
- ADDCMD((ID_NAVIGATE_GOTO, 'G', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_GO_TO));
- ADDCMD((ID_PLAY_INCRATE, VK_UP, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_INCREASE_RATE));
- ADDCMD((ID_PLAY_DECRATE, VK_DOWN, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_DECREASE_RATE));
- ADDCMD((ID_PLAY_RESETRATE, 'R', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_RESET_RATE));
- ADDCMD((ID_PLAY_INCAUDDELAY, VK_ADD, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_21));
- ADDCMD((ID_PLAY_DECAUDDELAY, VK_SUBTRACT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_22));
- ADDCMD((ID_PLAY_SEEKFORWARDSMALL, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_23));
- ADDCMD((ID_PLAY_SEEKBACKWARDSMALL, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_24));
- ADDCMD((ID_PLAY_SEEKFORWARDMED, VK_RIGHT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_25));
- ADDCMD((ID_PLAY_SEEKBACKWARDMED, VK_LEFT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_26));
- ADDCMD((ID_PLAY_SEEKFORWARDLARGE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_27));
- ADDCMD((ID_PLAY_SEEKBACKWARDLARGE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_28));
- ADDCMD((ID_PLAY_SEEKKEYFORWARD, VK_RIGHT, FVIRTKEY | FSHIFT | FNOINVERT, IDS_MPLAYERC_29));
- ADDCMD((ID_PLAY_SEEKKEYBACKWARD, VK_LEFT, FVIRTKEY | FSHIFT | FNOINVERT, IDS_MPLAYERC_30));
- ADDCMD((ID_PLAY_SEEKSET, VK_HOME, FVIRTKEY | FNOINVERT, IDS_AG_SEEKSET));
- ADDCMD((ID_NAVIGATE_SKIPFORWARD, VK_NEXT, FVIRTKEY | FNOINVERT, IDS_AG_NEXT, APPCOMMAND_MEDIA_NEXTTRACK, wmcmd::X2DOWN, wmcmd::X2DOWN));
- ADDCMD((ID_NAVIGATE_SKIPBACK, VK_PRIOR, FVIRTKEY | FNOINVERT, IDS_AG_PREVIOUS, APPCOMMAND_MEDIA_PREVIOUSTRACK, wmcmd::X1DOWN, wmcmd::X1DOWN));
- ADDCMD((ID_NAVIGATE_SKIPFORWARDFILE, VK_NEXT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_NEXT_FILE));
- ADDCMD((ID_NAVIGATE_SKIPBACKFILE, VK_PRIOR, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PREVIOUS_FILE));
- ADDCMD((ID_NAVIGATE_TUNERSCAN, 'T', FVIRTKEY | FSHIFT | FNOINVERT, IDS_NAVIGATE_TUNERSCAN));
- ADDCMD((ID_FAVORITES_QUICKADDFAVORITE, 'Q', FVIRTKEY | FSHIFT | FNOINVERT, IDS_FAVORITES_QUICKADDFAVORITE));
- ADDCMD((ID_VIEW_CAPTIONMENU, '0', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CAPTION));
- ADDCMD((ID_VIEW_SEEKER, '1', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SEEKER));
- ADDCMD((ID_VIEW_CONTROLS, '2', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CONTROLS));
- ADDCMD((ID_VIEW_INFORMATION, '3', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_INFO));
- ADDCMD((ID_VIEW_STATISTICS, '4', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_STATS));
- ADDCMD((ID_VIEW_STATUS, '5', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_STATUS));
- ADDCMD((ID_VIEW_SUBRESYNC, '6', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SUBRESYNC));
- ADDCMD((ID_VIEW_PLAYLIST, '7', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_PLAYLIST));
- ADDCMD((ID_VIEW_CAPTURE, '8', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CAPTURE));
- ADDCMD((ID_VIEW_NAVIGATION, '9', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_NAVIGATION));
- ADDCMD((ID_VIEW_DEBUGSHADERS, 0, FVIRTKEY | FNOINVERT, IDS_AG_TOGGLE_DEBUGSHADERS));
- ADDCMD((ID_VIEW_PRESETS_MINIMAL, '1', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_MINIMAL));
- ADDCMD((ID_VIEW_PRESETS_COMPACT, '2', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_COMPACT));
- ADDCMD((ID_VIEW_PRESETS_NORMAL, '3', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_NORMAL));
- ADDCMD((ID_VIEW_FULLSCREEN, VK_RETURN, FVIRTKEY | FALT | FNOINVERT, IDS_AG_FULLSCREEN, 0, wmcmd::LDBLCLK, wmcmd::LDBLCLK));
- ADDCMD((ID_VIEW_FULLSCREEN_SECONDARY, VK_F11, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_39));
- ADDCMD((ID_VIEW_ZOOM_50, '1', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_50));
- ADDCMD((ID_VIEW_ZOOM_100, '2', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_100));
- ADDCMD((ID_VIEW_ZOOM_200, '3', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_200));
- ADDCMD((ID_VIEW_ZOOM_AUTOFIT, '4', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_AUTO_FIT));
- ADDCMD((ID_VIEW_ZOOM_AUTOFIT_LARGER, '5', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_AUTO_FIT_LARGER));
- ADDCMD((ID_ASPECTRATIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_AG_NEXT_AR_PRESET));
- ADDCMD((ID_VIEW_VF_HALF, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_HALF));
- ADDCMD((ID_VIEW_VF_NORMAL, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_NORMAL));
- ADDCMD((ID_VIEW_VF_DOUBLE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_DOUBLE));
- ADDCMD((ID_VIEW_VF_STRETCH, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_STRETCH));
- ADDCMD((ID_VIEW_VF_FROMINSIDE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_INSIDE));
- ADDCMD((ID_VIEW_VF_ZOOM1, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_ZOOM1));
- ADDCMD((ID_VIEW_VF_ZOOM2, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_ZOOM2));
- ADDCMD((ID_VIEW_VF_FROMOUTSIDE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_OUTSIDE));
- ADDCMD((ID_VIEW_VF_SWITCHZOOM, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_SWITCHZOOM));
- ADDCMD((ID_ONTOP_ALWAYS, 'A', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_ALWAYS_ON_TOP));
- ADDCMD((ID_VIEW_RESET, VK_NUMPAD5, FVIRTKEY | FNOINVERT, IDS_AG_PNS_RESET));
- ADDCMD((ID_VIEW_INCSIZE, VK_NUMPAD9, FVIRTKEY | FNOINVERT, IDS_AG_PNS_INC_SIZE));
- ADDCMD((ID_VIEW_INCWIDTH, VK_NUMPAD6, FVIRTKEY | FNOINVERT, IDS_AG_PNS_INC_WIDTH));
- ADDCMD((ID_VIEW_INCHEIGHT, VK_NUMPAD8, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_47));
- ADDCMD((ID_VIEW_DECSIZE, VK_NUMPAD1, FVIRTKEY | FNOINVERT, IDS_AG_PNS_DEC_SIZE));
- ADDCMD((ID_VIEW_DECWIDTH, VK_NUMPAD4, FVIRTKEY | FNOINVERT, IDS_AG_PNS_DEC_WIDTH));
- ADDCMD((ID_VIEW_DECHEIGHT, VK_NUMPAD2, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_50));
- ADDCMD((ID_PANSCAN_CENTER, VK_NUMPAD5, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_CENTER));
- ADDCMD((ID_PANSCAN_MOVELEFT, VK_NUMPAD4, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_LEFT));
- ADDCMD((ID_PANSCAN_MOVERIGHT, VK_NUMPAD6, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_RIGHT));
- ADDCMD((ID_PANSCAN_MOVEUP, VK_NUMPAD8, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UP));
- ADDCMD((ID_PANSCAN_MOVEDOWN, VK_NUMPAD2, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_DOWN));
- ADDCMD((ID_PANSCAN_MOVEUPLEFT, VK_NUMPAD7, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UPLEFT));
- ADDCMD((ID_PANSCAN_MOVEUPRIGHT, VK_NUMPAD9, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UPRIGHT));
- ADDCMD((ID_PANSCAN_MOVEDOWNLEFT, VK_NUMPAD1, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_DOWNLEFT));
- ADDCMD((ID_PANSCAN_MOVEDOWNRIGHT, VK_NUMPAD3, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_59));
- ADDCMD((ID_PANSCAN_ROTATEXP, VK_NUMPAD8, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEX_P));
- ADDCMD((ID_PANSCAN_ROTATEXM, VK_NUMPAD2, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEX_M));
- ADDCMD((ID_PANSCAN_ROTATEYP, VK_NUMPAD4, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEY_P));
- ADDCMD((ID_PANSCAN_ROTATEYM, VK_NUMPAD6, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEY_M));
- ADDCMD((ID_PANSCAN_ROTATEZP, VK_NUMPAD1, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEZ_P));
- ADDCMD((ID_PANSCAN_ROTATEZM, VK_NUMPAD3, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEZ_M));
- ADDCMD((ID_VOLUME_UP, VK_UP, FVIRTKEY | FNOINVERT, IDS_AG_VOLUME_UP, 0, wmcmd::WUP, wmcmd::WUP));
- ADDCMD((ID_VOLUME_DOWN, VK_DOWN, FVIRTKEY | FNOINVERT, IDS_AG_VOLUME_DOWN, 0, wmcmd::WDOWN, wmcmd::WDOWN));
- ADDCMD((ID_VOLUME_MUTE, 'M', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_VOLUME_MUTE, 0));
- ADDCMD((ID_VOLUME_BOOST_INC, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_INC));
- ADDCMD((ID_VOLUME_BOOST_DEC, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_DEC));
- ADDCMD((ID_VOLUME_BOOST_MIN, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_MIN));
- ADDCMD((ID_VOLUME_BOOST_MAX, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_MAX));
- ADDCMD((ID_CUSTOM_CHANNEL_MAPPING, 0, FVIRTKEY | FNOINVERT, IDS_CUSTOM_CHANNEL_MAPPING));
- ADDCMD((ID_NORMALIZE, 0, FVIRTKEY | FNOINVERT, IDS_NORMALIZE));
- ADDCMD((ID_REGAIN_VOLUME, 0, FVIRTKEY | FNOINVERT, IDS_REGAIN_VOLUME));
- ADDCMD((ID_COLOR_BRIGHTNESS_INC, 0, FVIRTKEY | FNOINVERT, IDS_BRIGHTNESS_INC));
- ADDCMD((ID_COLOR_BRIGHTNESS_DEC, 0, FVIRTKEY | FNOINVERT, IDS_BRIGHTNESS_DEC));
- ADDCMD((ID_COLOR_CONTRAST_INC, 0, FVIRTKEY | FNOINVERT, IDS_CONTRAST_INC));
- ADDCMD((ID_COLOR_CONTRAST_DEC, 0, FVIRTKEY | FNOINVERT, IDS_CONTRAST_DEC));
- ADDCMD((ID_COLOR_HUE_INC, 0, FVIRTKEY | FNOINVERT, IDS_HUE_INC));
- ADDCMD((ID_COLOR_HUE_DEC, 0, FVIRTKEY | FNOINVERT, IDS_HUE_DEC));
- ADDCMD((ID_COLOR_SATURATION_INC, 0, FVIRTKEY | FNOINVERT, IDS_SATURATION_INC));
- ADDCMD((ID_COLOR_SATURATION_DEC, 0, FVIRTKEY | FNOINVERT, IDS_SATURATION_DEC));
- ADDCMD((ID_COLOR_RESET, 0, FVIRTKEY | FNOINVERT, IDS_RESET_COLOR));
- ADDCMD((ID_NAVIGATE_TITLEMENU, 'T', FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_63));
- ADDCMD((ID_NAVIGATE_ROOTMENU, 'R', FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_ROOT_MENU));
- ADDCMD((ID_NAVIGATE_SUBPICTUREMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_65));
- ADDCMD((ID_NAVIGATE_AUDIOMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_66));
- ADDCMD((ID_NAVIGATE_ANGLEMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_67));
- ADDCMD((ID_NAVIGATE_CHAPTERMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_68));
- ADDCMD((ID_NAVIGATE_MENU_LEFT, VK_LEFT, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_LEFT));
- ADDCMD((ID_NAVIGATE_MENU_RIGHT, VK_RIGHT, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_70));
- ADDCMD((ID_NAVIGATE_MENU_UP, VK_UP, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_UP));
- ADDCMD((ID_NAVIGATE_MENU_DOWN, VK_DOWN, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_DOWN));
- ADDCMD((ID_NAVIGATE_MENU_ACTIVATE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_73));
- ADDCMD((ID_NAVIGATE_MENU_BACK, 0, FVIRTKEY | FNOINVERT, IDS_AG_DVD_MENU_BACK));
- ADDCMD((ID_NAVIGATE_MENU_LEAVE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_75));
- ADDCMD((ID_BOSS, 'B', FVIRTKEY | FNOINVERT, IDS_AG_BOSS_KEY));
- ADDCMD((ID_MENU_PLAYER_SHORT, VK_APPS, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_77, 0, wmcmd::RUP, wmcmd::RUP));
- ADDCMD((ID_MENU_PLAYER_LONG, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_78));
- ADDCMD((ID_MENU_FILTERS, 0, FVIRTKEY | FNOINVERT, IDS_AG_FILTERS_MENU));
- ADDCMD((ID_VIEW_OPTIONS, 'O', FVIRTKEY | FNOINVERT, IDS_AG_OPTIONS));
- ADDCMD((ID_STREAM_AUDIO_NEXT, 'A', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_AUDIO));
- ADDCMD((ID_STREAM_AUDIO_PREV, 'A', FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PREV_AUDIO));
- ADDCMD((ID_STREAM_SUB_NEXT, 'S', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_SUBTITLE));
- ADDCMD((ID_STREAM_SUB_PREV, 'S', FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PREV_SUBTITLE));
- ADDCMD((ID_STREAM_SUB_ONOFF, 'W', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_85));
- ADDCMD((ID_SUBTITLES_SUBITEM_START + 2, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_86));
- ADDCMD((ID_FILE_ISDB_DOWNLOAD, 'D', FVIRTKEY | FNOINVERT, IDS_DOWNLOAD_SUBS));
- ADDCMD((ID_OGM_AUDIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_87));
- ADDCMD((ID_OGM_AUDIO_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_88));
- ADDCMD((ID_OGM_SUB_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_89));
- ADDCMD((ID_OGM_SUB_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_90));
- ADDCMD((ID_DVD_ANGLE_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_91));
- ADDCMD((ID_DVD_ANGLE_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_92));
- ADDCMD((ID_DVD_AUDIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_93));
- ADDCMD((ID_DVD_AUDIO_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_94));
- ADDCMD((ID_DVD_SUB_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_95));
- ADDCMD((ID_DVD_SUB_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_96));
- ADDCMD((ID_DVD_SUB_ONOFF, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_97));
- ADDCMD((ID_VIEW_TEARING_TEST, 'T', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TEARING_TEST));
- ADDCMD((ID_VIEW_REMAINING_TIME, 'I', FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_98));
- ADDCMD((ID_SHADERS_PRESET_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_AG_SHADERS_PRESET_NEXT));
- ADDCMD((ID_SHADERS_PRESET_PREV, 0, FVIRTKEY | FNOINVERT, IDS_AG_SHADERS_PRESET_PREV));
- ADDCMD((ID_D3DFULLSCREEN_TOGGLE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_99));
- ADDCMD((ID_GOTO_PREV_SUB, 'Y', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_100));
- ADDCMD((ID_GOTO_NEXT_SUB, 'U', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_101));
- ADDCMD((ID_SHIFT_SUB_DOWN, VK_NEXT, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_102));
- ADDCMD((ID_SHIFT_SUB_UP, VK_PRIOR, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_103));
- ADDCMD((ID_VIEW_DISPLAYSTATS, 'J', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_DISPLAY_STATS));
- ADDCMD((ID_VIEW_RESETSTATS, 'R', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_RESET_STATS));
- ADDCMD((ID_VIEW_VSYNC, 'V', FVIRTKEY | FNOINVERT, IDS_AG_VSYNC));
- ADDCMD((ID_VIEW_ENABLEFRAMETIMECORRECTION, 0, FVIRTKEY | FNOINVERT, IDS_AG_ENABLEFRAMETIMECORRECTION));
- ADDCMD((ID_VIEW_VSYNCACCURATE, 'V', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCACCURATE));
- ADDCMD((ID_VIEW_VSYNCOFFSET_DECREASE, VK_UP, FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCOFFSET_DECREASE));
- ADDCMD((ID_VIEW_VSYNCOFFSET_INCREASE, VK_DOWN, FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCOFFSET_INCREASE));
- ADDCMD((ID_SUB_DELAY_DOWN, VK_F1, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_104));
- ADDCMD((ID_SUB_DELAY_UP, VK_F2, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_105));
-
- ADDCMD((ID_AFTERPLAYBACK_CLOSE, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_CLOSE));
- ADDCMD((ID_AFTERPLAYBACK_STANDBY, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_STANDBY));
- ADDCMD((ID_AFTERPLAYBACK_HIBERNATE, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_HIBERNATE));
- ADDCMD((ID_AFTERPLAYBACK_SHUTDOWN, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_SHUTDOWN));
- ADDCMD((ID_AFTERPLAYBACK_LOGOFF, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_LOGOFF));
- ADDCMD((ID_AFTERPLAYBACK_LOCK, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_LOCK));
- ADDCMD((ID_AFTERPLAYBACK_MONITOROFF, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_MONITOROFF));
- ADDCMD((ID_AFTERPLAYBACK_PLAYNEXT, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_PLAYNEXT));
-
- ADDCMD((ID_VIEW_EDITLISTEDITOR, 0, FVIRTKEY | FNOINVERT, IDS_AG_TOGGLE_EDITLISTEDITOR));
- ADDCMD((ID_EDL_IN, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_IN));
- ADDCMD((ID_EDL_OUT, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_OUT));
- ADDCMD((ID_EDL_NEWCLIP, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_NEW_CLIP));
- ADDCMD((ID_EDL_SAVE, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_SAVE));
-
-#undef ADDCMD
+ wmcmds.AddTail({ID_FILE_OPENQUICK, 'Q', FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_0});
+ wmcmds.AddTail({ID_FILE_OPENMEDIA, 'O', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_FILE});
+ wmcmds.AddTail({ID_FILE_OPENDVDBD, 'D', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_DVD});
+ wmcmds.AddTail({ID_FILE_OPENDEVICE, 'V', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_DEVICE});
+ wmcmds.AddTail({ID_FILE_REOPEN, 'E', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_REOPEN});
+ wmcmds.AddTail({ID_FILE_RECYCLE, 0, FVIRTKEY | FNOINVERT, IDS_FILE_RECYCLE});
+
+ wmcmds.AddTail({ID_FILE_SAVE_COPY, 0, FVIRTKEY | FNOINVERT, IDS_AG_SAVE_COPY});
+ wmcmds.AddTail({ID_FILE_SAVE_IMAGE, 'I', FVIRTKEY | FALT | FNOINVERT, IDS_AG_SAVE_IMAGE});
+ wmcmds.AddTail({ID_FILE_SAVE_IMAGE_AUTO, VK_F5, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_6});
+ wmcmds.AddTail({ID_FILE_SAVE_THUMBNAILS, 0, FVIRTKEY | FNOINVERT, IDS_FILE_SAVE_THUMBNAILS});
+
+ wmcmds.AddTail({ID_FILE_LOAD_SUBTITLE, 'L', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_LOAD_SUBTITLE});
+ wmcmds.AddTail({ID_FILE_SAVE_SUBTITLE, 'S', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_SAVE_SUBTITLE});
+ wmcmds.AddTail({ID_FILE_CLOSE_AND_RESTORE, 'C', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_CLOSE});
+ wmcmds.AddTail({ID_FILE_PROPERTIES, VK_F10, FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PROPERTIES});
+ wmcmds.AddTail({ID_FILE_EXIT, 'X', FVIRTKEY | FALT | FNOINVERT, IDS_AG_EXIT});
+ wmcmds.AddTail({ID_PLAY_PLAYPAUSE, VK_SPACE, FVIRTKEY | FNOINVERT, IDS_AG_PLAYPAUSE, APPCOMMAND_MEDIA_PLAY_PAUSE, wmcmd::LUP, wmcmd::LUP});
+ wmcmds.AddTail({ID_PLAY_PLAY, 0, FVIRTKEY | FNOINVERT, IDS_AG_PLAY, APPCOMMAND_MEDIA_PLAY});
+ wmcmds.AddTail({ID_PLAY_PAUSE, 0, FVIRTKEY | FNOINVERT, IDS_AG_PAUSE, APPCOMMAND_MEDIA_PAUSE});
+ wmcmds.AddTail({ID_PLAY_STOP, VK_OEM_PERIOD, FVIRTKEY | FNOINVERT, IDS_AG_STOP, APPCOMMAND_MEDIA_STOP});
+ wmcmds.AddTail({ID_PLAY_FRAMESTEP, VK_RIGHT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_FRAMESTEP});
+ wmcmds.AddTail({ID_PLAY_FRAMESTEPCANCEL, VK_LEFT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_16});
+ wmcmds.AddTail({ID_NAVIGATE_GOTO, 'G', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_GO_TO});
+ wmcmds.AddTail({ID_PLAY_INCRATE, VK_UP, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_INCREASE_RATE});
+ wmcmds.AddTail({ID_PLAY_DECRATE, VK_DOWN, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_DECREASE_RATE});
+ wmcmds.AddTail({ID_PLAY_RESETRATE, 'R', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_RESET_RATE});
+ wmcmds.AddTail({ID_PLAY_INCAUDDELAY, VK_ADD, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_21});
+ wmcmds.AddTail({ID_PLAY_DECAUDDELAY, VK_SUBTRACT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_22});
+ wmcmds.AddTail({ID_PLAY_SEEKFORWARDSMALL, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_23});
+ wmcmds.AddTail({ID_PLAY_SEEKBACKWARDSMALL, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_24});
+ wmcmds.AddTail({ID_PLAY_SEEKFORWARDMED, VK_RIGHT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_25});
+ wmcmds.AddTail({ID_PLAY_SEEKBACKWARDMED, VK_LEFT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_26});
+ wmcmds.AddTail({ID_PLAY_SEEKFORWARDLARGE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_27});
+ wmcmds.AddTail({ID_PLAY_SEEKBACKWARDLARGE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_28});
+ wmcmds.AddTail({ID_PLAY_SEEKKEYFORWARD, VK_RIGHT, FVIRTKEY | FSHIFT | FNOINVERT, IDS_MPLAYERC_29});
+ wmcmds.AddTail({ID_PLAY_SEEKKEYBACKWARD, VK_LEFT, FVIRTKEY | FSHIFT | FNOINVERT, IDS_MPLAYERC_30});
+ wmcmds.AddTail({ID_PLAY_SEEKSET, VK_HOME, FVIRTKEY | FNOINVERT, IDS_AG_SEEKSET});
+ wmcmds.AddTail({ID_NAVIGATE_SKIPFORWARD, VK_NEXT, FVIRTKEY | FNOINVERT, IDS_AG_NEXT, APPCOMMAND_MEDIA_NEXTTRACK, wmcmd::X2DOWN, wmcmd::X2DOWN});
+ wmcmds.AddTail({ID_NAVIGATE_SKIPBACK, VK_PRIOR, FVIRTKEY | FNOINVERT, IDS_AG_PREVIOUS, APPCOMMAND_MEDIA_PREVIOUSTRACK, wmcmd::X1DOWN, wmcmd::X1DOWN});
+ wmcmds.AddTail({ID_NAVIGATE_SKIPFORWARDFILE, VK_NEXT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_NEXT_FILE});
+ wmcmds.AddTail({ID_NAVIGATE_SKIPBACKFILE, VK_PRIOR, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PREVIOUS_FILE});
+ wmcmds.AddTail({ID_NAVIGATE_TUNERSCAN, 'T', FVIRTKEY | FSHIFT | FNOINVERT, IDS_NAVIGATE_TUNERSCAN});
+ wmcmds.AddTail({ID_FAVORITES_QUICKADDFAVORITE, 'Q', FVIRTKEY | FSHIFT | FNOINVERT, IDS_FAVORITES_QUICKADDFAVORITE});
+ wmcmds.AddTail({ID_VIEW_CAPTIONMENU, '0', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CAPTION});
+ wmcmds.AddTail({ID_VIEW_SEEKER, '1', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SEEKER});
+ wmcmds.AddTail({ID_VIEW_CONTROLS, '2', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CONTROLS});
+ wmcmds.AddTail({ID_VIEW_INFORMATION, '3', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_INFO});
+ wmcmds.AddTail({ID_VIEW_STATISTICS, '4', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_STATS});
+ wmcmds.AddTail({ID_VIEW_STATUS, '5', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_STATUS});
+ wmcmds.AddTail({ID_VIEW_SUBRESYNC, '6', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SUBRESYNC});
+ wmcmds.AddTail({ID_VIEW_PLAYLIST, '7', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_PLAYLIST});
+ wmcmds.AddTail({ID_VIEW_CAPTURE, '8', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CAPTURE});
+ wmcmds.AddTail({ID_VIEW_NAVIGATION, '9', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_NAVIGATION});
+ wmcmds.AddTail({ID_VIEW_DEBUGSHADERS, 0, FVIRTKEY | FNOINVERT, IDS_AG_TOGGLE_DEBUGSHADERS});
+ wmcmds.AddTail({ID_VIEW_PRESETS_MINIMAL, '1', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_MINIMAL});
+ wmcmds.AddTail({ID_VIEW_PRESETS_COMPACT, '2', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_COMPACT});
+ wmcmds.AddTail({ID_VIEW_PRESETS_NORMAL, '3', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_NORMAL});
+ wmcmds.AddTail({ID_VIEW_FULLSCREEN, VK_RETURN, FVIRTKEY | FALT | FNOINVERT, IDS_AG_FULLSCREEN, 0, wmcmd::LDBLCLK, wmcmd::LDBLCLK});
+ wmcmds.AddTail({ID_VIEW_FULLSCREEN_SECONDARY, VK_F11, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_39});
+ wmcmds.AddTail({ID_VIEW_ZOOM_50, '1', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_50});
+ wmcmds.AddTail({ID_VIEW_ZOOM_100, '2', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_100});
+ wmcmds.AddTail({ID_VIEW_ZOOM_200, '3', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_200});
+ wmcmds.AddTail({ID_VIEW_ZOOM_AUTOFIT, '4', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_AUTO_FIT});
+ wmcmds.AddTail({ID_VIEW_ZOOM_AUTOFIT_LARGER, '5', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_AUTO_FIT_LARGER});
+ wmcmds.AddTail({ID_ASPECTRATIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_AG_NEXT_AR_PRESET});
+ wmcmds.AddTail({ID_VIEW_VF_HALF, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_HALF});
+ wmcmds.AddTail({ID_VIEW_VF_NORMAL, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_NORMAL});
+ wmcmds.AddTail({ID_VIEW_VF_DOUBLE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_DOUBLE});
+ wmcmds.AddTail({ID_VIEW_VF_STRETCH, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_STRETCH});
+ wmcmds.AddTail({ID_VIEW_VF_FROMINSIDE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_INSIDE});
+ wmcmds.AddTail({ID_VIEW_VF_ZOOM1, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_ZOOM1});
+ wmcmds.AddTail({ID_VIEW_VF_ZOOM2, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_ZOOM2});
+ wmcmds.AddTail({ID_VIEW_VF_FROMOUTSIDE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_OUTSIDE});
+ wmcmds.AddTail({ID_VIEW_VF_SWITCHZOOM, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_SWITCHZOOM});
+ wmcmds.AddTail({ID_ONTOP_ALWAYS, 'A', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_ALWAYS_ON_TOP});
+ wmcmds.AddTail({ID_VIEW_RESET, VK_NUMPAD5, FVIRTKEY | FNOINVERT, IDS_AG_PNS_RESET});
+ wmcmds.AddTail({ID_VIEW_INCSIZE, VK_NUMPAD9, FVIRTKEY | FNOINVERT, IDS_AG_PNS_INC_SIZE});
+ wmcmds.AddTail({ID_VIEW_INCWIDTH, VK_NUMPAD6, FVIRTKEY | FNOINVERT, IDS_AG_PNS_INC_WIDTH});
+ wmcmds.AddTail({ID_VIEW_INCHEIGHT, VK_NUMPAD8, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_47});
+ wmcmds.AddTail({ID_VIEW_DECSIZE, VK_NUMPAD1, FVIRTKEY | FNOINVERT, IDS_AG_PNS_DEC_SIZE});
+ wmcmds.AddTail({ID_VIEW_DECWIDTH, VK_NUMPAD4, FVIRTKEY | FNOINVERT, IDS_AG_PNS_DEC_WIDTH});
+ wmcmds.AddTail({ID_VIEW_DECHEIGHT, VK_NUMPAD2, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_50});
+ wmcmds.AddTail({ID_PANSCAN_CENTER, VK_NUMPAD5, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_CENTER});
+ wmcmds.AddTail({ID_PANSCAN_MOVELEFT, VK_NUMPAD4, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_LEFT});
+ wmcmds.AddTail({ID_PANSCAN_MOVERIGHT, VK_NUMPAD6, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_RIGHT});
+ wmcmds.AddTail({ID_PANSCAN_MOVEUP, VK_NUMPAD8, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UP});
+ wmcmds.AddTail({ID_PANSCAN_MOVEDOWN, VK_NUMPAD2, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_DOWN});
+ wmcmds.AddTail({ID_PANSCAN_MOVEUPLEFT, VK_NUMPAD7, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UPLEFT});
+ wmcmds.AddTail({ID_PANSCAN_MOVEUPRIGHT, VK_NUMPAD9, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UPRIGHT});
+ wmcmds.AddTail({ID_PANSCAN_MOVEDOWNLEFT, VK_NUMPAD1, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_DOWNLEFT});
+ wmcmds.AddTail({ID_PANSCAN_MOVEDOWNRIGHT, VK_NUMPAD3, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_59});
+ wmcmds.AddTail({ID_PANSCAN_ROTATEXP, VK_NUMPAD8, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEX_P});
+ wmcmds.AddTail({ID_PANSCAN_ROTATEXM, VK_NUMPAD2, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEX_M});
+ wmcmds.AddTail({ID_PANSCAN_ROTATEYP, VK_NUMPAD4, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEY_P});
+ wmcmds.AddTail({ID_PANSCAN_ROTATEYM, VK_NUMPAD6, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEY_M});
+ wmcmds.AddTail({ID_PANSCAN_ROTATEZP, VK_NUMPAD1, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEZ_P});
+ wmcmds.AddTail({ID_PANSCAN_ROTATEZM, VK_NUMPAD3, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEZ_M});
+ wmcmds.AddTail({ID_VOLUME_UP, VK_UP, FVIRTKEY | FNOINVERT, IDS_AG_VOLUME_UP, 0, wmcmd::WUP, wmcmd::WUP});
+ wmcmds.AddTail({ID_VOLUME_DOWN, VK_DOWN, FVIRTKEY | FNOINVERT, IDS_AG_VOLUME_DOWN, 0, wmcmd::WDOWN, wmcmd::WDOWN});
+ wmcmds.AddTail({ID_VOLUME_MUTE, 'M', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_VOLUME_MUTE, 0});
+ wmcmds.AddTail({ID_VOLUME_BOOST_INC, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_INC});
+ wmcmds.AddTail({ID_VOLUME_BOOST_DEC, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_DEC});
+ wmcmds.AddTail({ID_VOLUME_BOOST_MIN, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_MIN});
+ wmcmds.AddTail({ID_VOLUME_BOOST_MAX, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_MAX});
+ wmcmds.AddTail({ID_CUSTOM_CHANNEL_MAPPING, 0, FVIRTKEY | FNOINVERT, IDS_CUSTOM_CHANNEL_MAPPING});
+ wmcmds.AddTail({ID_NORMALIZE, 0, FVIRTKEY | FNOINVERT, IDS_NORMALIZE});
+ wmcmds.AddTail({ID_REGAIN_VOLUME, 0, FVIRTKEY | FNOINVERT, IDS_REGAIN_VOLUME});
+ wmcmds.AddTail({ID_COLOR_BRIGHTNESS_INC, 0, FVIRTKEY | FNOINVERT, IDS_BRIGHTNESS_INC});
+ wmcmds.AddTail({ID_COLOR_BRIGHTNESS_DEC, 0, FVIRTKEY | FNOINVERT, IDS_BRIGHTNESS_DEC});
+ wmcmds.AddTail({ID_COLOR_CONTRAST_INC, 0, FVIRTKEY | FNOINVERT, IDS_CONTRAST_INC});
+ wmcmds.AddTail({ID_COLOR_CONTRAST_DEC, 0, FVIRTKEY | FNOINVERT, IDS_CONTRAST_DEC});
+ wmcmds.AddTail({ID_COLOR_HUE_INC, 0, FVIRTKEY | FNOINVERT, IDS_HUE_INC});
+ wmcmds.AddTail({ID_COLOR_HUE_DEC, 0, FVIRTKEY | FNOINVERT, IDS_HUE_DEC});
+ wmcmds.AddTail({ID_COLOR_SATURATION_INC, 0, FVIRTKEY | FNOINVERT, IDS_SATURATION_INC});
+ wmcmds.AddTail({ID_COLOR_SATURATION_DEC, 0, FVIRTKEY | FNOINVERT, IDS_SATURATION_DEC});
+ wmcmds.AddTail({ID_COLOR_RESET, 0, FVIRTKEY | FNOINVERT, IDS_RESET_COLOR});
+ wmcmds.AddTail({ID_NAVIGATE_TITLEMENU, 'T', FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_63});
+ wmcmds.AddTail({ID_NAVIGATE_ROOTMENU, 'R', FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_ROOT_MENU});
+ wmcmds.AddTail({ID_NAVIGATE_SUBPICTUREMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_65});
+ wmcmds.AddTail({ID_NAVIGATE_AUDIOMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_66});
+ wmcmds.AddTail({ID_NAVIGATE_ANGLEMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_67});
+ wmcmds.AddTail({ID_NAVIGATE_CHAPTERMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_68});
+ wmcmds.AddTail({ID_NAVIGATE_MENU_LEFT, VK_LEFT, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_LEFT});
+ wmcmds.AddTail({ID_NAVIGATE_MENU_RIGHT, VK_RIGHT, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_70});
+ wmcmds.AddTail({ID_NAVIGATE_MENU_UP, VK_UP, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_UP});
+ wmcmds.AddTail({ID_NAVIGATE_MENU_DOWN, VK_DOWN, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_DOWN});
+ wmcmds.AddTail({ID_NAVIGATE_MENU_ACTIVATE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_73});
+ wmcmds.AddTail({ID_NAVIGATE_MENU_BACK, 0, FVIRTKEY | FNOINVERT, IDS_AG_DVD_MENU_BACK});
+ wmcmds.AddTail({ID_NAVIGATE_MENU_LEAVE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_75});
+ wmcmds.AddTail({ID_BOSS, 'B', FVIRTKEY | FNOINVERT, IDS_AG_BOSS_KEY});
+ wmcmds.AddTail({ID_MENU_PLAYER_SHORT, VK_APPS, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_77, 0, wmcmd::RUP, wmcmd::RUP});
+ wmcmds.AddTail({ID_MENU_PLAYER_LONG, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_78});
+ wmcmds.AddTail({ID_MENU_FILTERS, 0, FVIRTKEY | FNOINVERT, IDS_AG_FILTERS_MENU});
+ wmcmds.AddTail({ID_VIEW_OPTIONS, 'O', FVIRTKEY | FNOINVERT, IDS_AG_OPTIONS});
+ wmcmds.AddTail({ID_STREAM_AUDIO_NEXT, 'A', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_AUDIO});
+ wmcmds.AddTail({ID_STREAM_AUDIO_PREV, 'A', FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PREV_AUDIO});
+ wmcmds.AddTail({ID_STREAM_SUB_NEXT, 'S', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_SUBTITLE});
+ wmcmds.AddTail({ID_STREAM_SUB_PREV, 'S', FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PREV_SUBTITLE});
+ wmcmds.AddTail({ID_STREAM_SUB_ONOFF, 'W', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_85});
+ wmcmds.AddTail({ID_SUBTITLES_SUBITEM_START + 2, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_86});
+ wmcmds.AddTail({ID_FILE_ISDB_DOWNLOAD, 'D', FVIRTKEY | FNOINVERT, IDS_DOWNLOAD_SUBS});
+ wmcmds.AddTail({ID_OGM_AUDIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_87});
+ wmcmds.AddTail({ID_OGM_AUDIO_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_88});
+ wmcmds.AddTail({ID_OGM_SUB_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_89});
+ wmcmds.AddTail({ID_OGM_SUB_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_90});
+ wmcmds.AddTail({ID_DVD_ANGLE_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_91});
+ wmcmds.AddTail({ID_DVD_ANGLE_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_92});
+ wmcmds.AddTail({ID_DVD_AUDIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_93});
+ wmcmds.AddTail({ID_DVD_AUDIO_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_94});
+ wmcmds.AddTail({ID_DVD_SUB_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_95});
+ wmcmds.AddTail({ID_DVD_SUB_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_96});
+ wmcmds.AddTail({ID_DVD_SUB_ONOFF, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_97});
+ wmcmds.AddTail({ID_VIEW_TEARING_TEST, 'T', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TEARING_TEST});
+ wmcmds.AddTail({ID_VIEW_OSD_DISPLAY_TIME, 'I', FVIRTKEY | FCONTROL | FNOINVERT, IDS_OSD_DISPLAY_CURRENT_TIME});
+ wmcmds.AddTail({ID_VIEW_OSD_SHOW_FILENAME, 'N', FVIRTKEY | FNOINVERT, IDS_OSD_SHOW_FILENAME});
+ wmcmds.AddTail({ID_SHADERS_PRESET_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_AG_SHADERS_PRESET_NEXT});
+ wmcmds.AddTail({ID_SHADERS_PRESET_PREV, 0, FVIRTKEY | FNOINVERT, IDS_AG_SHADERS_PRESET_PREV});
+ wmcmds.AddTail({ID_D3DFULLSCREEN_TOGGLE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_99});
+ wmcmds.AddTail({ID_GOTO_PREV_SUB, 'Y', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_100});
+ wmcmds.AddTail({ID_GOTO_NEXT_SUB, 'U', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_101});
+ wmcmds.AddTail({ID_SHIFT_SUB_DOWN, VK_NEXT, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_102});
+ wmcmds.AddTail({ID_SHIFT_SUB_UP, VK_PRIOR, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_103});
+ wmcmds.AddTail({ID_VIEW_DISPLAY_RENDERER_STATS, 'J', FVIRTKEY | FCONTROL | FNOINVERT, IDS_OSD_DISPLAY_RENDERER_STATS});
+ wmcmds.AddTail({ID_VIEW_RESET_RENDERER_STATS, 'R', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_OSD_RESET_RENDERER_STATS});
+ wmcmds.AddTail({ID_VIEW_VSYNC, 'V', FVIRTKEY | FNOINVERT, IDS_AG_VSYNC});
+ wmcmds.AddTail({ID_VIEW_ENABLEFRAMETIMECORRECTION, 0, FVIRTKEY | FNOINVERT, IDS_AG_ENABLEFRAMETIMECORRECTION});
+ wmcmds.AddTail({ID_VIEW_VSYNCACCURATE, 'V', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCACCURATE});
+ wmcmds.AddTail({ID_VIEW_VSYNCOFFSET_DECREASE, VK_UP, FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCOFFSET_DECREASE});
+ wmcmds.AddTail({ID_VIEW_VSYNCOFFSET_INCREASE, VK_DOWN, FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCOFFSET_INCREASE});
+ wmcmds.AddTail({ID_SUB_DELAY_DOWN, VK_F1, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_104});
+ wmcmds.AddTail({ID_SUB_DELAY_UP, VK_F2, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_105});
+
+ wmcmds.AddTail({ID_AFTERPLAYBACK_DONOTHING, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_DONOTHING});
+ wmcmds.AddTail({ID_AFTERPLAYBACK_PLAYNEXT, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_PLAYNEXT});
+ wmcmds.AddTail({ID_AFTERPLAYBACK_MONITOROFF, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_MONITOROFF});
+ wmcmds.AddTail({ID_AFTERPLAYBACK_EXIT, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_EXIT});
+ wmcmds.AddTail({ID_AFTERPLAYBACK_STANDBY, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_STANDBY});
+ wmcmds.AddTail({ID_AFTERPLAYBACK_HIBERNATE, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_HIBERNATE});
+ wmcmds.AddTail({ID_AFTERPLAYBACK_SHUTDOWN, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_SHUTDOWN});
+ wmcmds.AddTail({ID_AFTERPLAYBACK_LOGOFF, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_LOGOFF});
+ wmcmds.AddTail({ID_AFTERPLAYBACK_LOCK, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_LOCK});
+
+ wmcmds.AddTail({ID_VIEW_EDITLISTEDITOR, 0, FVIRTKEY | FNOINVERT, IDS_AG_TOGGLE_EDITLISTEDITOR});
+ wmcmds.AddTail({ID_EDL_IN, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_IN});
+ wmcmds.AddTail({ID_EDL_OUT, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_OUT});
+ wmcmds.AddTail({ID_EDL_NEWCLIP, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_NEW_CLIP});
+ wmcmds.AddTail({ID_EDL_SAVE, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_SAVE});
}
CAppSettings::~CAppSettings()
@@ -638,6 +647,11 @@ bool CAppSettings::IsVideoRendererAvailable(int iVideoRendererType)
}
}
+bool CAppSettings::IsInitialized() const
+{
+ return bInitialized;
+}
+
CString CAppSettings::SelectedAudioRenderer() const
{
CString strResult;
@@ -859,15 +873,14 @@ void CAppSettings::SaveSettings()
pApp->WriteProfileString(IDS_R_COMMANDS, nullptr, nullptr);
POSITION pos = wmcmds.GetHeadPosition();
for (int i = 0; pos;) {
- wmcmd& wc = wmcmds.GetNext(pos);
+ const wmcmd& wc = wmcmds.GetNext(pos);
if (wc.IsModified()) {
CString str;
str.Format(_T("CommandMod%d"), i);
CString str2;
- str2.Format(_T("%u %x %x %s %d %u %u %u"),
- wc.cmd, wc.fVirt, wc.key,
- _T("\"") + CString(wc.rmcmd) + _T("\""), wc.rmrepcnt,
- wc.mouse, wc.appcmd, wc.mouseFS);
+ str2.Format(_T("%hu %hx %hx \"%S\" %d %u %u %u"),
+ wc.cmd, (WORD)wc.fVirt, wc.key, wc.rmcmd,
+ wc.rmrepcnt, wc.mouse, wc.appcmd, wc.mouseFS);
pApp->WriteProfileString(IDS_R_COMMANDS, str, str2);
i++;
}
@@ -951,6 +964,7 @@ void CAppSettings::SaveSettings()
}
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMAINING_TIME, fRemainingTime);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIGH_PRECISION_TIMER, bHighPrecisionTimer);
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_AUTO_CHECK, nUpdaterAutoCheck);
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_DELAY, nUpdaterDelay);
@@ -962,6 +976,8 @@ void CAppSettings::SaveSettings()
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COVER_ART, bEnableCoverArt);
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COVER_ART_SIZE_LIMIT, nCoverArtSizeLimit);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOGGING, bEnableLogging);
+
pApp->FlushProfile();
}
@@ -1192,6 +1208,13 @@ void CAppSettings::LoadSettings()
language = 0;
}
}
+#ifndef DEBUG
+ if (language) {
+ auto pCrashReporterUIThread = CCrashReporterUIThread::GetInstance();
+ pCrashReporterUIThread->WaitThreadReady();
+ pCrashReporterUIThread->GetCrashDialog().LoadTranslatableResources();
+ }
+#endif
CreateCommands();
@@ -1447,29 +1470,35 @@ void CAppSettings::LoadSettings()
if (str2.IsEmpty()) {
break;
}
- int cmd, fVirt, key, repcnt;
- UINT mouse, mouseFS, appcmd;
- TCHAR buff[128];
+
+ wmcmd tmp;
int n;
- if (5 > (n = _stscanf_s(str2, _T("%d %x %x %s %d %u %u %u"), &cmd, &fVirt, &key, buff, _countof(buff), &repcnt, &mouse, &appcmd, &mouseFS))) {
+ int fVirt = 0;
+ if (5 > (n = _stscanf_s(str2, _T("%hu %x %hx %S %d %u %u %u"),
+ &tmp.cmd, &fVirt, &tmp.key, tmp.rmcmd.GetBuffer(128), 128,
+ &tmp.rmrepcnt, &tmp.mouse, &tmp.appcmd, &tmp.mouseFS))) {
break;
}
- if (POSITION pos = wmcmds.Find(cmd)) {
+ tmp.rmcmd.ReleaseBuffer();
+ if (n >= 2) {
+ tmp.fVirt = (BYTE)fVirt;
+ }
+ if (POSITION pos = wmcmds.Find(tmp)) {
wmcmd& wc = wmcmds.GetAt(pos);
- wc.cmd = cmd;
- wc.fVirt = fVirt;
- wc.key = key;
+ wc.cmd = tmp.cmd;
+ wc.fVirt = tmp.fVirt;
+ wc.key = tmp.key;
if (n >= 6) {
- wc.mouse = mouse;
+ wc.mouse = tmp.mouse;
}
if (n >= 7) {
- wc.appcmd = appcmd;
+ wc.appcmd = tmp.appcmd;
}
// If there is no distinct bindings for windowed and
// fullscreen modes we use the same for both.
- wc.mouseFS = (n >= 8) ? mouseFS : wc.mouse;
- wc.rmcmd = CStringA(buff).Trim('\"');
- wc.rmrepcnt = repcnt;
+ wc.mouseFS = (n >= 8) ? tmp.mouseFS : wc.mouse;
+ wc.rmcmd = tmp.rmcmd.Trim('\"');
+ wc.rmrepcnt = tmp.rmrepcnt;
}
}
@@ -1642,6 +1671,7 @@ void CAppSettings::LoadSettings()
fLastFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTFULLSCREEN, FALSE);
fRemainingTime = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMAINING_TIME, FALSE);
+ bHighPrecisionTimer = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIGH_PRECISION_TIMER, FALSE);
nUpdaterAutoCheck = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_AUTO_CHECK, AUTOUPDATE_UNKNOWN);
nUpdaterDelay = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_DELAY, 7);
@@ -1659,6 +1689,8 @@ void CAppSettings::LoadSettings()
bEnableCoverArt = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COVER_ART, TRUE);
nCoverArtSizeLimit = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COVER_ART_SIZE_LIMIT, 600);
+ bEnableLogging = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGGING, FALSE);
+
if (fLaunchfullscreen) {
nCLSwitches |= CLSW_FULLSCREEN;
}
@@ -1930,6 +1962,8 @@ void CAppSettings::ParseCommandLine(CAtlList& cmdln)
nCLSwitches |= CLSW_DEVICE;
} else if (sw == _T("add")) {
nCLSwitches |= CLSW_ADD;
+ } else if (sw == _T("randomize")) {
+ nCLSwitches |= CLSW_RANDOMIZE;
} else if (sw == _T("regvid")) {
nCLSwitches |= CLSW_REGEXTVID;
} else if (sw == _T("regaud")) {
@@ -1995,8 +2029,8 @@ void CAppSettings::ParseCommandLine(CAtlList& cmdln)
}
} else if (sw == _T("debug")) {
fShowDebugInfo = true;
- } else if (sw == _T("nominidump")) {
- CMiniDump::Disable();
+ } else if (sw == _T("nocrashreporter")) {
+ CrashReporter::Disable();
} else if (sw == _T("audiorenderer") && pos) {
SetAudioRenderer(_ttoi(cmdln.GetNext(pos)));
} else if (sw == _T("shaderpreset") && pos) {
@@ -2375,6 +2409,10 @@ void CAppSettings::UpdateSettings()
VERIFY(pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DISABLE_SUBTITLE_ANIMATION, bDisableSubtitleAnimation));
}
// no break
+ case 5:
+ copyInt(IDS_R_INTERNAL_FILTERS, _T("SRC_DTSAC3"), IDS_R_INTERNAL_FILTERS, _T("SRC_DTS"));
+ copyInt(IDS_R_INTERNAL_FILTERS, _T("SRC_DTSAC3"), IDS_R_INTERNAL_FILTERS, _T("SRC_AC3"));
+ // no break
default:
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_R_VERSION, APPSETTINGS_VERSION);
}
diff --git a/src/mpc-hc/AppSettings.h b/src/mpc-hc/AppSettings.h
index bfd53c27ac6..70184f9b32d 100644
--- a/src/mpc-hc/AppSettings.h
+++ b/src/mpc-hc/AppSettings.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -59,15 +59,17 @@ enum : UINT64 {
CLSW_LOCK = CLSW_LOGOFF << 1,
CLSW_MONITOROFF = CLSW_LOCK << 1,
CLSW_PLAYNEXT = CLSW_MONITOROFF << 1,
- CLSW_AFTERPLAYBACK_MASK = CLSW_CLOSE | CLSW_STANDBY | CLSW_SHUTDOWN | CLSW_HIBERNATE | CLSW_LOGOFF | CLSW_LOCK | CLSW_MONITOROFF | CLSW_PLAYNEXT,
- CLSW_FULLSCREEN = CLSW_PLAYNEXT << 1,
+ CLSW_DONOTHING = CLSW_PLAYNEXT << 1,
+ CLSW_AFTERPLAYBACK_MASK = CLSW_CLOSE | CLSW_STANDBY | CLSW_SHUTDOWN | CLSW_HIBERNATE | CLSW_LOGOFF | CLSW_LOCK | CLSW_MONITOROFF | CLSW_PLAYNEXT | CLSW_DONOTHING,
+ CLSW_FULLSCREEN = CLSW_DONOTHING << 1,
CLSW_NEW = CLSW_FULLSCREEN << 1,
CLSW_HELP = CLSW_NEW << 1,
CLSW_DVD = CLSW_HELP << 1,
CLSW_CD = CLSW_DVD << 1,
CLSW_DEVICE = CLSW_CD << 1,
CLSW_ADD = CLSW_DEVICE << 1,
- CLSW_MINIMIZED = CLSW_ADD << 1,
+ CLSW_RANDOMIZE = CLSW_ADD << 1,
+ CLSW_MINIMIZED = CLSW_RANDOMIZE << 1,
CLSW_REGEXTVID = CLSW_MINIMIZED << 1,
CLSW_REGEXTAUD = CLSW_REGEXTVID << 1,
CLSW_REGEXTPL = CLSW_REGEXTAUD << 1,
@@ -82,7 +84,7 @@ enum : UINT64 {
CLSW_SLAVE = CLSW_ADMINOPTION << 1,
CLSW_AUDIORENDERER = CLSW_SLAVE << 1,
CLSW_RESET = CLSW_AUDIORENDERER << 1,
- CLSW_UNRECOGNIZEDSWITCH = CLSW_RESET << 1 // 33
+ CLSW_UNRECOGNIZEDSWITCH = CLSW_RESET << 1 // 35
};
enum MpcCaptionState {
@@ -273,35 +275,31 @@ class wmcmd : public ACCEL
CStringA rmcmd;
int rmrepcnt;
- wmcmd(WORD cmd = 0)
- : appcmd(0)
- , appcmdorg(0)
- , dwname(0)
- , mouse(NONE)
- , mouseorg(NONE)
- , mouseFS(NONE)
- , mouseFSorg(NONE)
- , rmrepcnt(0) {
- this->cmd = cmd;
- this->key = 0;
- this->fVirt = 0;
- ZeroMemory(&backup, sizeof(backup));
+ explicit wmcmd(WORD cmd = 0)
+ : ACCEL( { 0, 0, cmd })
+ , backup({ 0, 0, cmd })
+ , appcmdorg(0)
+ , mouseorg(NONE)
+ , mouseFSorg(NONE)
+ , dwname(0)
+ , appcmd(0)
+ , mouse(NONE)
+ , mouseFS(NONE)
+ , rmrepcnt(0) {
}
wmcmd(WORD cmd, WORD key, BYTE fVirt, DWORD dwname, UINT appcmd = 0, UINT mouse = NONE, UINT mouseFS = NONE, LPCSTR rmcmd = "", int rmrepcnt = 5)
- : appcmd(appcmd)
- , appcmdorg(appcmd)
- , dwname(dwname)
- , mouse(mouse)
- , mouseorg(mouse)
- , mouseFS(mouseFS)
- , mouseFSorg(mouseFS)
- , rmcmd(rmcmd)
- , rmrepcnt(rmrepcnt) {
- this->cmd = cmd;
- this->key = key;
- this->fVirt = fVirt;
- backup = *this;
+ : ACCEL( { fVirt, key, cmd })
+ , backup({ fVirt, key, cmd })
+ , appcmdorg(appcmd)
+ , mouseorg(mouse)
+ , mouseFSorg(mouseFS)
+ , dwname(dwname)
+ , appcmd(appcmd)
+ , mouse(mouse)
+ , mouseFS(mouseFS)
+ , rmcmd(rmcmd)
+ , rmrepcnt(rmrepcnt) {
}
bool operator == (const wmcmd& wc) const {
@@ -370,7 +368,7 @@ class CUIceClient : public CRemoteCtrlClient
CUIceClient();
};
-#define APPSETTINGS_VERSION 5
+#define APPSETTINGS_VERSION 6
class CAppSettings
{
@@ -656,6 +654,7 @@ class CAppSettings
UINT nLastWindowType;
UINT nLastUsedPage;
bool fRemainingTime;
+ bool bHighPrecisionTimer;
bool fLastFullScreen;
bool fIntRealMedia;
@@ -670,10 +669,13 @@ class CAppSettings
bool bEnableCoverArt;
int nCoverArtSizeLimit;
+ bool bEnableLogging;
+
bool IsD3DFullscreen() const;
CString SelectedAudioRenderer() const;
bool IsISRAutoLoadEnabled() const;
bool IsISRAvailable() const;
+ bool IsInitialized() const;
static bool IsVideoRendererAvailable(int iVideoRendererType);
CFileAssoc fileAssoc;
diff --git a/src/mpc-hc/AuthDlg.cpp b/src/mpc-hc/AuthDlg.cpp
index 496f5cc172b..47569ac7325 100644
--- a/src/mpc-hc/AuthDlg.cpp
+++ b/src/mpc-hc/AuthDlg.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -22,7 +22,7 @@
#include "stdafx.h"
#include "AuthDlg.h"
#include "SysVersion.h"
-#include "version.h"
+#include "VersionInfo.h"
// We need to dynamically link to the functions provided by CredUI.lib in order
// to be able to use the features available to the OS.
@@ -103,7 +103,7 @@ HRESULT PromptForCredentials(HWND hWnd, const CString& strCaptionText, const CSt
const DWORD dwFlags = CREDUI_FLAGS_ALWAYS_SHOW_UI | CREDUI_FLAGS_GENERIC_CREDENTIALS/* | CREDUI_FLAGS_EXPECT_CONFIRMATION*/ | CREDUI_FLAGS_COMPLETE_USERNAME | CREDUI_FLAGS_DO_NOT_PERSIST | (bSave ? CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX : 0);
CString strUserDomain(strUsername);
if (!strDomain.GetLength()) {
- strDomain = _T("mpc-hc/") MPC_VERSION_STR;
+ strDomain = _T("mpc-hc/") + VersionInfo::GetVersionString();
}
DWORD dwResult = fnCredUIPromptForCredentialsW(&info, strDomain.Left(dwDomain), nullptr, dwAuthError,
@@ -116,7 +116,7 @@ HRESULT PromptForCredentials(HWND hWnd, const CString& strCaptionText, const CSt
strDomain.ReleaseBuffer();
//dwResult = CredUIConfirmCredentials(szDomain.Left(cchDomain), TRUE);
- if (strDomain == _T("mpc-hc/") MPC_VERSION_STR) {
+ if (strDomain == _T("mpc-hc/") + VersionInfo::GetVersionString()) {
strDomain.Empty();
}
diff --git a/src/mpc-hc/ChildView.cpp b/src/mpc-hc/ChildView.cpp
index 53e03420576..1e4d28580d8 100644
--- a/src/mpc-hc/ChildView.cpp
+++ b/src/mpc-hc/ChildView.cpp
@@ -165,10 +165,7 @@ void CChildView::LoadImgInternal(HGDIOBJ hImg)
CSize CChildView::GetLogoSize()
{
- BITMAP bitmap;
- ZeroMemory(&bitmap, sizeof(BITMAP));
- m_img.GetBitmap(&bitmap);
- return CSize(bitmap.bmWidth, bitmap.bmHeight);
+ return m_img.GetSize();
}
IMPLEMENT_DYNAMIC(CChildView, CMouseWnd)
@@ -224,18 +221,20 @@ BOOL CChildView::OnEraseBkgnd(CDC* pDC)
r = CRect(CPoint(x, y), CSize(std::lround(dImgWidth), std::lround(dImgHeight)));
- if (m_resizedImg.IsNull() || r.Width() != m_resizedImg.GetWidth() || r.Height() != m_resizedImg.GetHeight() || img.GetBPP() != m_resizedImg.GetBPP()) {
- m_resizedImg.Destroy();
- m_resizedImg.Create(r.Width(), r.Height(), img.GetBPP());
+ if (!r.IsRectEmpty()) {
+ if (m_resizedImg.IsNull() || r.Width() != m_resizedImg.GetWidth() || r.Height() != m_resizedImg.GetHeight() || img.GetBPP() != m_resizedImg.GetBPP()) {
+ m_resizedImg.Destroy();
+ m_resizedImg.Create(r.Width(), r.Height(), std::max(img.GetBPP(), 24));
- HDC hDC = m_resizedImg.GetDC();
- SetStretchBltMode(hDC, STRETCH_HALFTONE);
- img.StretchBlt(hDC, 0, 0, r.Width(), r.Height(), SRCCOPY);
- m_resizedImg.ReleaseDC();
- }
+ HDC hDC = m_resizedImg.GetDC();
+ SetStretchBltMode(hDC, STRETCH_HALFTONE);
+ img.StretchBlt(hDC, 0, 0, r.Width(), r.Height(), SRCCOPY);
+ m_resizedImg.ReleaseDC();
+ }
- m_resizedImg.BitBlt(*pDC, r.TopLeft());
- pDC->ExcludeClipRect(r);
+ m_resizedImg.BitBlt(*pDC, r.TopLeft());
+ pDC->ExcludeClipRect(r);
+ }
}
img.Detach();
diff --git a/src/mpc-hc/CrashReporter.cpp b/src/mpc-hc/CrashReporter.cpp
new file mode 100644
index 00000000000..e4b62e1fd4d
--- /dev/null
+++ b/src/mpc-hc/CrashReporter.cpp
@@ -0,0 +1,147 @@
+/*
+ * (C) 2015 see Authors.txt
+ *
+ * This file is part of MPC-HC.
+ *
+ * MPC-HC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MPC-HC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "stdafx.h"
+#include "CrashReporter.h"
+#ifndef _DEBUG
+#include
+#include "CrashReporterDialog.h"
+#include "VersionInfo.h"
+#include "mpc-hc_config.h"
+#include "DoctorDump/CrashRpt.h"
+
+
+using namespace crash_rpt;
+
+namespace CrashReporter
+{
+ static bool g_bEnabled = false;
+ static CrashRpt g_crashReporter(L"CrashReporter\\crashrpt.dll");
+
+ static CrashProcessingCallbackResult CALLBACK CrashProcessingCallback(CrashProcessingCallbackStage stage,
+ ExceptionInfo* pExceptionInfo,
+ LPVOID pUserData);
+}
+#endif
+
+void CrashReporter::Enable()
+{
+#ifndef _DEBUG
+ static crash_rpt::ApplicationInfo appInfo = {
+ sizeof(appInfo),
+ "31c48823-ce52-401b-8425-888388161757",
+ "mpc-hc",
+ L"MPC-HC",
+ L"MPC-HC Team",
+ {
+ USHORT(VersionInfo::GetMajorNumber()),
+ USHORT(VersionInfo::GetMinorNumber()),
+ USHORT(VersionInfo::GetPatchNumber()),
+ USHORT(VersionInfo::GetRevisionNumber()),
+ },
+ 0,
+ nullptr
+ };
+
+ const MINIDUMP_TYPE dumpType = MINIDUMP_TYPE(
+#if ENABLE_FULLDUMP
+ MiniDumpWithFullMemory |
+ MiniDumpWithTokenInformation |
+#else
+ MiniDumpWithIndirectlyReferencedMemory |
+ MiniDumpWithDataSegs |
+#endif // ENABLE_FULLDUMP
+ MiniDumpWithHandleData |
+ MiniDumpWithThreadInfo |
+ MiniDumpWithProcessThreadData |
+ MiniDumpWithFullMemoryInfo |
+ MiniDumpWithUnloadedModules |
+ MiniDumpIgnoreInaccessibleMemory
+ );
+
+ static crash_rpt::HandlerSettings handlerSettings = {
+ sizeof(handlerSettings),
+ FALSE, // Don't keep the dumps
+ FALSE, // Don't open the problem page in the browser
+ FALSE, // Don't use WER (for now)
+ 0, // Anonymous submitter
+ FALSE, // Ask before sending additional info
+ TRUE, // Override the "full" dump settings
+ dumpType, // "Full" dump custom settings
+ nullptr, // No lang file (for now)
+ nullptr, // Default path for SendRpt
+ nullptr, // Default path for DbgHelp
+ CrashProcessingCallback, // Callback function
+ nullptr // No user defined parameter for the callback function
+ };
+
+ if (!g_crashReporter.IsCrashHandlingEnabled()) {
+ g_bEnabled = g_crashReporter.InitCrashRpt(&appInfo, &handlerSettings);
+ // Ensure the crash reporter UI thread is running
+ VERIFY(CCrashReporterUIThread::GetInstance() != nullptr);
+ } else {
+ g_bEnabled = true;
+ }
+#endif
+};
+
+void CrashReporter::Disable()
+{
+#ifndef _DEBUG
+ g_bEnabled = false;
+#endif
+};
+
+#ifndef _DEBUG
+CrashProcessingCallbackResult CALLBACK CrashReporter::CrashProcessingCallback(CrashProcessingCallbackStage stage,
+ ExceptionInfo* pExceptionInfo,
+ LPVOID pUserData)
+{
+ if (!g_bEnabled) {
+ return SkipSendReportReturnDefaultResult;
+ }
+
+ // All variables are allocated statically to reduce allocations after crashing
+ if (stage == BeforeSendReport) {
+ // We need to make sure the message pump is ready
+ static CCrashReporterUIThread* pCrashReporterUIThread = CCrashReporterUIThread::GetInstance();
+ pCrashReporterUIThread->WaitThreadReady();
+ // before actually showing the dialog
+ static CCrashReporterDialog& crashDlg = pCrashReporterUIThread->GetCrashDialog();
+ crashDlg.ShowWindow(SW_SHOWNORMAL);
+ crashDlg.SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ crashDlg.SetForegroundWindow();
+
+ static CString email, description;
+ if (crashDlg.WaitForUserInput(email, description)) {
+ if (!email.IsEmpty()) {
+ g_crashReporter.AddUserInfoToReport(L"email", email);
+ }
+ if (!description.IsEmpty()) {
+ g_crashReporter.AddUserInfoToReport(L"description", description);
+ }
+ }
+ crashDlg.SignalDataRead();
+ WaitForSingleObject(CCrashReporterUIThread::GetInstance()->m_hThread, INFINITE);
+ }
+
+ return DoDefaultActions;
+};
+#endif
diff --git a/src/mpc-hc/MiniDump.h b/src/mpc-hc/CrashReporter.h
similarity index 79%
rename from src/mpc-hc/MiniDump.h
rename to src/mpc-hc/CrashReporter.h
index 38cb03a58db..ed54b972040 100644
--- a/src/mpc-hc/MiniDump.h
+++ b/src/mpc-hc/CrashReporter.h
@@ -1,31 +1,27 @@
-/*
- * (C) 2009-2014 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#pragma once
-
-namespace CMiniDump
-{
- void Enable();
- void Disable();
-
-#ifndef _DEBUG
- LONG WINAPI UnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers);
-#endif
-};
+/*
+ * (C) 2015 see Authors.txt
+ *
+ * This file is part of MPC-HC.
+ *
+ * MPC-HC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MPC-HC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#pragma once
+
+namespace CrashReporter
+{
+ void Enable();
+ void Disable();
+};
diff --git a/src/mpc-hc/CrashReporterDialog.cpp b/src/mpc-hc/CrashReporterDialog.cpp
new file mode 100644
index 00000000000..bba5c2626fd
--- /dev/null
+++ b/src/mpc-hc/CrashReporterDialog.cpp
@@ -0,0 +1,155 @@
+/*
+ * (C) 2015 see Authors.txt
+ *
+ * This file is part of MPC-HC.
+ *
+ * MPC-HC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MPC-HC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "stdafx.h"
+#include "CrashReporterDialog.h"
+#include "resource.h"
+#include "mplayerc.h"
+#include "DSUtil.h"
+
+CCrashReporterDialog::CCrashReporterDialog()
+ : CDialog()
+{
+ // Listen for language changes
+ EventRouter::EventSelection receives;
+ receives.insert(MpcEvent::CHANGING_UI_LANGUAGE);
+ GetEventd().Connect(m_eventc, receives, std::bind(&CCrashReporterDialog::EventCallback, this, std::placeholders::_1));
+}
+
+BOOL CCrashReporterDialog::Create()
+{
+ // Try to preallocate memory for the result strings
+ m_email.Preallocate(128);
+ m_description.Preallocate(4096);
+
+ BOOL res = __super::Create(IDD, CWnd::GetDesktopWindow());
+
+ // Because we set LR_SHARED, there is no need to explicitly destroy the icon
+ VERIFY(SetIcon((HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 48, 48, LR_SHARED), true) == nullptr);
+
+ return res;
+}
+
+BOOL CCrashReporterDialog::OnInitDialog()
+{
+ __super::OnInitDialog();
+ return FALSE; // return FALSE so that the dialog does not steal focus
+}
+
+void CCrashReporterDialog::LoadTranslatableResources()
+{
+ // Load the template in a temporary dialog and get the strings from there.
+ // We don't use MFC to avoid side effects caused by creating another dialog.
+ HWND hDlg = ::CreateDialog(AfxGetResourceHandle(), MAKEINTRESOURCE(IDD), nullptr, nullptr);
+ if (hDlg) {
+ auto setTextFromDlg = [&](int nID) {
+ CWnd* pItem = CWnd::FromHandle(::GetDlgItem(hDlg, nID));
+ if (pItem && IsWindow(pItem->m_hWnd)) {
+ CString text;
+ pItem->GetWindowText(text);
+ if (!text.IsEmpty()) {
+ GetDlgItem(nID)->SetWindowText(text);
+ }
+ }
+ };
+
+ setTextFromDlg(IDC_STATIC1);
+ setTextFromDlg(IDC_STATIC2);
+ setTextFromDlg(IDC_STATIC3);
+ setTextFromDlg(IDC_STATIC4);
+ setTextFromDlg(IDOK);
+
+ ::DestroyWindow(hDlg);
+ }
+}
+
+void CCrashReporterDialog::EventCallback(MpcEvent ev)
+{
+ switch (ev) {
+ case MpcEvent::CHANGING_UI_LANGUAGE:
+ LoadTranslatableResources();
+ break;
+ default:
+ ASSERT(FALSE);
+ }
+}
+
+bool CCrashReporterDialog::WaitForUserInput(CString& email, CString& description)
+{
+ m_eventDataAvailable.Wait();
+
+ if (m_bHasData) {
+ email = m_email;
+ description = m_description;
+ }
+
+ return m_bHasData;
+}
+
+void CCrashReporterDialog::OnQuit()
+{
+ if (m_bHasData) {
+ GetDlgItem(IDC_EDIT1)->GetWindowText(m_email);
+ GetDlgItem(IDC_EDIT2)->GetWindowText(m_description);
+ }
+ m_eventDataAvailable.Set();
+ m_eventDataRead.Wait();
+ DestroyWindow();
+}
+
+BEGIN_MESSAGE_MAP(CCrashReporterDialog, CDialog)
+END_MESSAGE_MAP()
+
+IMPLEMENT_DYNCREATE(CCrashReporterUIThread, CWinThread)
+
+CCrashReporterUIThread::CCrashReporterUIThread()
+ : CWinThread()
+ , m_bThreadReady(false)
+ , m_eventThreadReady(TRUE)
+{}
+
+BOOL CCrashReporterUIThread::InitInstance()
+{
+ __super::InitInstance();
+
+ SetThreadName(DWORD(-1), "Crash Reporter UI Thread");
+
+ m_dlg.Create();
+ m_pMainWnd = &m_dlg;
+ return TRUE;
+}
+
+int CCrashReporterUIThread::ExitInstance()
+{
+ m_dlg.DestroyWindow();
+ return __super::ExitInstance();
+}
+
+BOOL CCrashReporterUIThread::OnIdle(LONG lCount)
+{
+ if (!m_bThreadReady) {
+ m_bThreadReady = true;
+ m_eventThreadReady.Set();
+ }
+ return __super::OnIdle(lCount);
+}
+
+BEGIN_MESSAGE_MAP(CCrashReporterUIThread, CWinThread)
+END_MESSAGE_MAP()
diff --git a/src/mpc-hc/CrashReporterDialog.h b/src/mpc-hc/CrashReporterDialog.h
new file mode 100644
index 00000000000..ff763887295
--- /dev/null
+++ b/src/mpc-hc/CrashReporterDialog.h
@@ -0,0 +1,88 @@
+/*
+ * (C) 2015 see Authors.txt
+ *
+ * This file is part of MPC-HC.
+ *
+ * MPC-HC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MPC-HC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#pragma once
+
+#include
+#include "BaseClasses/wxutil.h"
+#include "resource.h"
+
+class CCrashReporterDialog : public CDialog
+{
+private:
+ CAMEvent m_eventDataAvailable, m_eventDataRead;
+ bool m_bHasData = false;
+ CString m_email, m_description;
+
+ EventClient m_eventc;
+
+public:
+ CCrashReporterDialog();
+
+ BOOL Create();
+ BOOL OnInitDialog() override;
+ void LoadTranslatableResources();
+
+ bool WaitForUserInput(CString& email, CString& description);
+ void SignalDataRead() { m_eventDataRead.Set(); };
+
+ // Dialog Data
+ enum { IDD = IDD_CRASH_REPORTER };
+
+protected:
+ DECLARE_MESSAGE_MAP()
+
+ virtual void OnOK() { m_bHasData = true; OnQuit(); };
+ virtual void OnCancel() { m_bHasData = false; OnQuit(); };
+
+private:
+ void EventCallback(MpcEvent ev);
+ void OnQuit();
+};
+
+class CCrashReporterUIThread : public CWinThread
+{
+private:
+ CAMEvent m_eventThreadReady;
+ bool m_bThreadReady;
+ CCrashReporterDialog m_dlg;
+
+ DECLARE_DYNCREATE(CCrashReporterUIThread)
+
+protected:
+ CCrashReporterUIThread();
+
+public:
+ static CCrashReporterUIThread* GetInstance() {
+ static CCrashReporterUIThread* pUIThread = (CCrashReporterUIThread*)AfxBeginThread(RUNTIME_CLASS(CCrashReporterUIThread));
+ return pUIThread;
+ };
+
+ virtual BOOL InitInstance();
+ virtual int ExitInstance();
+
+ virtual BOOL OnIdle(LONG lCount);
+
+ void WaitThreadReady() { m_eventThreadReady.Wait(); };
+
+ CCrashReporterDialog& GetCrashDialog() { return m_dlg; };
+
+ DECLARE_MESSAGE_MAP()
+};
diff --git a/src/mpc-hc/DVBChannel.cpp b/src/mpc-hc/DVBChannel.cpp
index 48d2f81ba44..e4a0b7e41fe 100644
--- a/src/mpc-hc/DVBChannel.cpp
+++ b/src/mpc-hc/DVBChannel.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2009-2014 see Authors.txt
+ * (C) 2009-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -150,6 +150,7 @@ void CDVBChannel::AddStreamInfo(ULONG ulPID, DVB_STREAM_TYPE nType, PES_STREAM_T
switch (nType) {
case DVB_MPV:
case DVB_H264:
+ case DVB_HEVC:
m_ulVideoPID = ulPID;
m_nVideoType = nType;
break;
diff --git a/src/mpc-hc/DVBChannel.h b/src/mpc-hc/DVBChannel.h
index d338fc1e077..61558e98519 100644
--- a/src/mpc-hc/DVBChannel.h
+++ b/src/mpc-hc/DVBChannel.h
@@ -1,5 +1,5 @@
/*
- * (C) 2009-2014 see Authors.txt
+ * (C) 2009-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -50,6 +50,7 @@ enum DVB_STREAM_TYPE {
DVB_MPA = 0x02,
DVB_AC3 = 0x03,
DVB_EAC3 = 0x04,
+ DVB_HEVC = 0x05,
DVB_LATM = 0x11,
DVB_PSI = 0x80,
DVB_TIF = 0x81,
diff --git a/src/mpc-hc/DebugShadersDlg.cpp b/src/mpc-hc/DebugShadersDlg.cpp
index bfd94d1c63e..3adb9007ae0 100644
--- a/src/mpc-hc/DebugShadersDlg.cpp
+++ b/src/mpc-hc/DebugShadersDlg.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2013-2014 see Authors.txt
+ * (C) 2013-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -64,7 +64,7 @@ CDebugShadersDlg::CDebugShadersDlg()
SetSizeGripVisibility(FALSE);
SetMinTrackSize(CSize(360, 100));
AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_STATIC, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor((UINT)IDC_STATIC, TOP_LEFT, BOTTOM_RIGHT);
AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
AddAnchor(IDC_RADIO1, TOP_RIGHT);
AddAnchor(IDC_RADIO2, TOP_RIGHT);
diff --git a/src/mpc-hc/DropTarget.cpp b/src/mpc-hc/DropTarget.cpp
new file mode 100644
index 00000000000..e70b79238a5
--- /dev/null
+++ b/src/mpc-hc/DropTarget.cpp
@@ -0,0 +1,126 @@
+/*
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2012, 2015 see Authors.txt
+ *
+ * This file is part of MPC-HC.
+ *
+ * MPC-HC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MPC-HC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "stdafx.h"
+#include "DropTarget.h"
+
+CDropTarget::CDropTarget()
+{
+ m_pDropHelper.CoCreateInstance(CLSID_DragDropHelper, nullptr, CLSCTX_INPROC_SERVER);
+};
+
+DROPEFFECT CDropTarget::OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
+{
+ DROPEFFECT dropEffect = DROPEFFECT_NONE;
+
+ auto pClient = dynamic_cast(pWnd);
+ if (pClient && (pDataObject->IsDataAvailable(CF_HDROP) || pDataObject->IsDataAvailable(CF_URL))) {
+ dropEffect = pClient->OnDropAccept(pDataObject, dwKeyState, point);
+ }
+
+ if (m_pDropHelper) {
+ m_pDropHelper->DragEnter(pWnd->GetSafeHwnd(), pDataObject->GetIDataObject(FALSE), &point, dropEffect);
+ }
+
+ return dropEffect;
+}
+
+DROPEFFECT CDropTarget::OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
+{
+ DROPEFFECT dropEffect = DROPEFFECT_NONE;
+
+ auto pClient = dynamic_cast(pWnd);
+ if (pClient && (pDataObject->IsDataAvailable(CF_HDROP) || pDataObject->IsDataAvailable(CF_URL))) {
+ dropEffect = pClient->OnDropAccept(pDataObject, dwKeyState, point);
+ }
+
+ if (m_pDropHelper) {
+ m_pDropHelper->DragOver(&point, dropEffect);
+ }
+
+ return dropEffect;
+}
+
+BOOL CDropTarget::OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
+{
+ BOOL bResult = FALSE;
+ CAtlList slFiles;
+
+ if (auto pClient = dynamic_cast(pWnd)) {
+ if (pDataObject->IsDataAvailable(CF_HDROP)) {
+ if (HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_HDROP)) {
+ if (HDROP hDrop = (HDROP)GlobalLock(hGlobal)) {
+ UINT nFiles = ::DragQueryFile(hDrop, UINT_MAX, nullptr, 0);
+ for (UINT iFile = 0; iFile < nFiles; iFile++) {
+ CString fn;
+ fn.ReleaseBuffer(::DragQueryFile(hDrop, iFile, fn.GetBuffer(MAX_PATH), MAX_PATH));
+ slFiles.AddTail(fn);
+ }
+ ::DragFinish(hDrop);
+ pClient->OnDropFiles(slFiles, dropEffect);
+ bResult = TRUE;
+ }
+ GlobalUnlock(hGlobal);
+ }
+ } else if (pDataObject->IsDataAvailable(CF_URL)) {
+ FORMATETC fmt = { CF_URL, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+ if (HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt)) {
+ LPCSTR pText = (LPCSTR)GlobalLock(hGlobal);
+ if (AfxIsValidString(pText)) {
+ CAtlList sl;
+ sl.AddTail(pText);
+ pClient->OnDropFiles(sl, dropEffect);
+ GlobalUnlock(hGlobal);
+ bResult = TRUE;
+ }
+ }
+ }
+ }
+
+ if (m_pDropHelper) {
+ m_pDropHelper->Drop(pDataObject->GetIDataObject(FALSE), &point, dropEffect);
+ }
+
+ return bResult;
+}
+
+DROPEFFECT CDropTarget::OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point)
+{
+ if (OnDrop(pWnd, pDataObject, dropDefault, point)) {
+ return dropDefault;
+ }
+ return DROPEFFECT_NONE;
+}
+
+void CDropTarget::OnDragLeave(CWnd* pWnd)
+{
+ if (m_pDropHelper) {
+ m_pDropHelper->DragLeave();
+ }
+}
+
+DROPEFFECT CDropTarget::OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point)
+{
+ return DROPEFFECT_NONE;
+}
+
+BEGIN_MESSAGE_MAP(CDropTarget, COleDropTarget)
+END_MESSAGE_MAP()
diff --git a/src/mpc-hc/FileDropTarget.h b/src/mpc-hc/DropTarget.h
similarity index 55%
rename from src/mpc-hc/FileDropTarget.h
rename to src/mpc-hc/DropTarget.h
index b7868206f9f..8df0680ed34 100644
--- a/src/mpc-hc/FileDropTarget.h
+++ b/src/mpc-hc/DropTarget.h
@@ -1,72 +1,51 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#pragma once
-
-#include
-
-
-class CDropTarget
-{
-public:
- CDropTarget() {}
-
- virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {
- return DROPEFFECT_NONE;
- }
- virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {
- return DROPEFFECT_NONE;
- }
- virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point) {
- return FALSE;
- }
- virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point) {
- return (DROPEFFECT) - 1;
- }
- virtual void OnDragLeave() {}
- virtual DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point) {
- return DROPEFFECT_NONE;
- }
-};
-
-// CFileDropTarget command target
-
-class CFileDropTarget : public COleDropTarget
-{
- // DECLARE_DYNAMIC(CFileDropTarget)
-
-private:
- CDropTarget* m_pDropTarget;
-
-public:
- CFileDropTarget(CDropTarget* pDropTarget);
- virtual ~CFileDropTarget();
-
-protected:
- DECLARE_MESSAGE_MAP()
-
- DROPEFFECT OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- BOOL OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
- DROPEFFECT OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
- void OnDragLeave(CWnd* pWnd);
- DROPEFFECT OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point);
-};
+/*
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2012, 2015 see Authors.txt
+ *
+ * This file is part of MPC-HC.
+ *
+ * MPC-HC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MPC-HC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#pragma once
+
+#include
+
+
+struct CDropClient {
+ virtual void OnDropFiles(CAtlList& slFiles, DROPEFFECT dropEffect) PURE;
+ virtual DROPEFFECT OnDropAccept(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) PURE;
+};
+
+class CDropTarget : public COleDropTarget
+{
+public:
+ CDropTarget();
+ virtual ~CDropTarget() = default;
+
+private:
+ const CLIPFORMAT CF_URL = (CLIPFORMAT)RegisterClipboardFormat(_T("UniformResourceLocator"));
+ CComPtr m_pDropHelper;
+
+protected:
+ DECLARE_MESSAGE_MAP()
+
+ DROPEFFECT OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ BOOL OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
+ DROPEFFECT OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
+ void OnDragLeave(CWnd* pWnd);
+ DROPEFFECT OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point);
+};
diff --git a/src/mpc-hc/EventDispatcher.h b/src/mpc-hc/EventDispatcher.h
index f5ea31c73a0..5f2ddeaca83 100644
--- a/src/mpc-hc/EventDispatcher.h
+++ b/src/mpc-hc/EventDispatcher.h
@@ -1,5 +1,5 @@
/*
- * (C) 2013-2014 see Authors.txt
+ * (C) 2013-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -44,6 +44,7 @@ enum class MpcEvent {
SYSTEM_MENU_POPUP_INITIALIZED,
SYSTEM_MENU_POPUP_UNINITIALIZED,
CHANGING_UI_LANGUAGE,
+ STREAM_POS_UPDATE_REQUEST
};
class EventClient;
diff --git a/src/mpc-hc/FGFilter.cpp b/src/mpc-hc/FGFilter.cpp
index de49fdef617..9b5f3d7058e 100644
--- a/src/mpc-hc/FGFilter.cpp
+++ b/src/mpc-hc/FGFilter.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -29,6 +29,7 @@
#include "SyncAllocatorPresenter.h"
#include "IPinHook.h" // For the NVIDIA driver bug work-around
#include "moreuuids.h"
+#include
//
@@ -104,12 +105,11 @@ CFGFilterRegistry::CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit)
return;
}
- LPOLESTR str = nullptr;
+ CComHeapPtr str;
if (FAILED(m_pMoniker->GetDisplayName(0, 0, &str))) {
return;
}
m_DisplayName = m_name = str;
- CoTaskMemFree(str), str = nullptr;
QueryProperties();
@@ -147,17 +147,17 @@ void CFGFilterRegistry::QueryProperties()
CComPtr pPB;
if (SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPB)))) {
CComVariant var;
- if (SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, nullptr))) {
+ if (SUCCEEDED(pPB->Read(_T("FriendlyName"), &var, nullptr))) {
m_name = var.bstrVal;
var.Clear();
}
- if (SUCCEEDED(pPB->Read(CComBSTR(_T("CLSID")), &var, nullptr))) {
+ if (SUCCEEDED(pPB->Read(_T("CLSID"), &var, nullptr))) {
CLSIDFromString(var.bstrVal, &m_clsid);
var.Clear();
}
- if (SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, nullptr))) {
+ if (SUCCEEDED(pPB->Read(_T("FilterData"), &var, nullptr))) {
BSTR* pstr;
if (SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr))) {
ExtractFilterData((BYTE*)pstr, var.parray->cbElements * (var.parray->rgsabound[0].cElements));
@@ -427,10 +427,18 @@ HRESULT CFGFilterFile::Create(IBaseFilter** ppBF, CInterfaceList& pUnks)
{
TRACE(_T("--> CFGFilterVideoRenderer::Create on thread: %lu\n"), GetCurrentThreadId());
@@ -460,6 +468,9 @@ HRESULT CFGFilterVideoRenderer::Create(IBaseFilter** ppBF, CInterfaceList pMVRSR = pCAP) {
+ VERIFY(SUCCEEDED(pMVRSR->DisableSubclassing()));
+ }
if (CComQIPtr pVW = pCAP) {
pVW->put_Owner((OAHWND)m_hWnd);
}
@@ -472,8 +483,6 @@ HRESULT CFGFilterVideoRenderer::Create(IBaseFilter** ppBF, CInterfaceList pConfig = pBF;
pConfig->SetNumberOfStreams(3);
-
- HookWorkAroundNVIDIADriverBug(pBF);
}
BeginEnumPins(pBF, pEP, pPin) {
@@ -490,6 +499,9 @@ HRESULT CFGFilterVideoRenderer::Create(IBaseFilter** ppBF, CInterfaceList& pUnks);
};
diff --git a/src/mpc-hc/FGFilterLAV.cpp b/src/mpc-hc/FGFilterLAV.cpp
index 7979e59a1ca..d5cd8cc20cd 100644
--- a/src/mpc-hc/FGFilterLAV.cpp
+++ b/src/mpc-hc/FGFilterLAV.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2013-2014 see Authors.txt
+ * (C) 2013-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -559,6 +559,7 @@ LPCTSTR CFGFilterLAVVideo::GetUserFriendlyDecoderName(const CString& decoderName
make_pair(_T("avcodec"), _T("FFmpeg")),
make_pair(_T("dxva2n"), _T("DXVA2 Native")),
make_pair(_T("dxva2cb"), _T("DXVA2 Copy-back")),
+ make_pair(_T("dxva2cb direct"), _T("DXVA2 Copy-back (Direct)")),
make_pair(_T("cuvid"), _T("NVIDIA CUVID")),
make_pair(_T("quicksync"), _T("Intel QuickSync"))
};
diff --git a/src/mpc-hc/FGManager.cpp b/src/mpc-hc/FGManager.cpp
index d9308fc643a..91fa9a60eed 100644
--- a/src/mpc-hc/FGManager.cpp
+++ b/src/mpc-hc/FGManager.cpp
@@ -30,7 +30,6 @@
#include "AllocatorCommon7.h"
#include "AllocatorCommon.h"
#include "SyncAllocatorPresenter.h"
-#include "madVRAllocatorPresenter.h"
#include "DeinterlacerFilter.h"
#include "../DeCSS/VobFile.h"
#include
@@ -42,6 +41,7 @@
#include
#include "IPinHook.h"
#include "moreuuids.h"
+#include
//
// CFGManager
@@ -215,12 +215,6 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl
}
}
- // exceptions first
-
- if (ext == _T(".dvr-ms") || ext == _T(".wtv")) { // doh, this is stupid
- fl.Insert(LookupFilterRegistry(CLSID_StreamBufferSource, m_override, MERIT64_PREFERRED), 0);
- }
-
if (hFile == INVALID_HANDLE_VALUE) {
// internal / protocol
@@ -1473,6 +1467,13 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
+#if INTERNAL_SOURCEFILTER_WTV
+ if (src[SRC_WTV]) {
+ pFGLAVSplitterSource->m_extensions.AddTail(_T(".wtv"));
+ pFGLAVSplitterSource->AddEnabledFormat("wtv");
+ }
+#endif
+
#if INTERNAL_SOURCEFILTER_MATROSKA
if (src[SRC_MATROSKA]) {
pFGLAVSplitterSource->m_chkbytes.AddTail(_T("0,4,,1A45DFA3"));
@@ -1529,20 +1530,27 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
-#if INTERNAL_SOURCEFILTER_DTSAC3
- if (src[SRC_DTSAC3]) {
- pFGLAVSplitterSource->m_chkbytes.AddTail(_T("0,4,,7FFE8001")); // DTS
- pFGLAVSplitterSource->m_chkbytes.AddTail(_T("0,4,,fE7f0180")); // DTS LE
+#if INTERNAL_SOURCEFILTER_AC3
+ if (src[SRC_AC3]) {
pFGLAVSplitterSource->m_chkbytes.AddTail(_T("0,2,,0B77")); // AC3, E-AC3
- pFGLAVSplitterSource->m_chkbytes.AddTail(_T("0,4,,52494646,8,8,,57415645666D7420"));// RIFFxxxxWAVEfmt_ for DTSWAV
pFGLAVSplitterSource->m_chkbytes.AddTail(_T("4,4,,F8726FBB")); // MLP
pFGLAVSplitterSource->m_extensions.AddTail(_T(".ac3"));
- pFGLAVSplitterSource->m_extensions.AddTail(_T(".dts"));
pFGLAVSplitterSource->m_extensions.AddTail(_T(".eac3"));
pFGLAVSplitterSource->AddEnabledFormat("ac3");
+ pFGLAVSplitterSource->AddEnabledFormat("eac3");
+ }
+#endif
+
+#if INTERNAL_SOURCEFILTER_DTS
+ if (src[SRC_DTS]) {
+ pFGLAVSplitterSource->m_chkbytes.AddTail(_T("0,4,,7FFE8001")); // DTS
+ pFGLAVSplitterSource->m_chkbytes.AddTail(_T("0,4,,fE7f0180")); // DTS LE
+ pFGLAVSplitterSource->m_chkbytes.AddTail(_T("0,4,,52494646,8,8,,57415645666D7420"));// RIFFxxxxWAVEfmt_ for DTSWAV
+ pFGLAVSplitterSource->m_extensions.AddTail(_T(".dts"));
+ pFGLAVSplitterSource->m_extensions.AddTail(_T(".dtshd"));
+ pFGLAVSplitterSource->m_extensions.AddTail(_T(".dtsma"));
pFGLAVSplitterSource->AddEnabledFormat("dts");
pFGLAVSplitterSource->AddEnabledFormat("dtshd");
- pFGLAVSplitterSource->AddEnabledFormat("eac3");
}
#endif
@@ -1679,6 +1687,26 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
+#if INTERNAL_SOURCEFILTER_AC3
+ if (src[SRC_AC3]) {
+ pFGLAVSplitter->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DOLBY_AC3);
+ pFGLAVSplitter->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DOLBY_TRUEHD);
+ pFGLAVSplitter->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DOLBY_DDPLUS);
+ pFGLAVSplitter->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MLP);
+ pFGLAVSplitter->AddEnabledFormat("ac3");
+ pFGLAVSplitter->AddEnabledFormat("eac3");
+ }
+#endif
+
+#if INTERNAL_SOURCEFILTER_DTS
+ if (src[SRC_DTS]) {
+ pFGLAVSplitter->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DTS);
+ pFGLAVSplitter->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DTS_HD);
+ pFGLAVSplitter->AddEnabledFormat("dts");
+ pFGLAVSplitter->AddEnabledFormat("dtshd");
+ }
+#endif
+
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
if (src[SRC_MPA]) {
pFGLAVSplitter->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1Audio);
@@ -1776,6 +1804,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DTS);
pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DTS);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DTS);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DTS_HD);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
#endif
@@ -1851,6 +1880,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#if INTERNAL_DECODER_PCM
pFGF = tra[TRA_PCM] ? pFGLAVAudio : pFGLAVAudioLM;
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_NONE);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_RAW);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_TWOS);
@@ -2257,7 +2287,7 @@ STDMETHODIMP CFGManagerCustom::AddFilter(IBaseFilter* pBF, LPCWSTR pName)
if (GetCLSID(pBF) == CLSID_DMOWrapperFilter) {
if (CComQIPtr pPB = pBF) {
CComVariant var(true);
- pPB->Write(CComBSTR(L"_HIRESOUTPUT"), &var);
+ pPB->Write(_T("_HIRESOUTPUT"), &var);
}
}
diff --git a/src/mpc-hc/FGManagerBDA.cpp b/src/mpc-hc/FGManagerBDA.cpp
index e7391717874..cbb84cf2e22 100644
--- a/src/mpc-hc/FGManagerBDA.cpp
+++ b/src/mpc-hc/FGManagerBDA.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2009-2014 see Authors.txt
+ * (C) 2009-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -38,7 +38,11 @@
#include "Mpeg2SectionData.h"
#include "MainFrm.h"
#include "SysVersion.h"
+#include "Logger.h"
+#define LOG Logger::LOG
+#define CheckAndLogBDA(x, msg) hr = ##x; if (FAILED(hr)) { LOG(msg _T(": 0x%08x\n"), hr); return hr; }
+#define CheckAndLogBDANoRet(x, msg) hr = ##x; if (FAILED(hr)) { LOG(msg _T(": 0x%08x\n"), hr); }
/// Format, Video MPEG2
static VIDEOINFOHEADER2 sMpv_fmt = {
@@ -78,8 +82,6 @@ static AM_MEDIA_TYPE mt_Mpv = {
(LPBYTE)& sMpv_fmt // pbFormat
};
-#define FCC_h264 MAKEFOURCC('h', '2', '6', '4')
-
/// Format, Video H264
static VIDEOINFOHEADER2 vih2_H264 = {
{0, 0, 0, 0}, // rcSource
@@ -95,12 +97,12 @@ static VIDEOINFOHEADER2 vih2_H264 = {
0, // dwReserved2
{
// bmiHeader
- sizeof(BITMAPINFOHEADER), // biSize
- 720, // biWidth
- 576, // biHeight
- 1, // biPlanes
- 0, // biBitCount
- FCC_h264 // biCompression
+ sizeof(BITMAPINFOHEADER), // biSize
+ 720, // biWidth
+ 576, // biHeight
+ 1, // biPlanes
+ 0, // biBitCount
+ MAKEFOURCC('h', '2', '6', '4') // biCompression
}
// implicitly sets the others fields to 0
};
@@ -118,6 +120,44 @@ static AM_MEDIA_TYPE mt_H264 = {
(LPBYTE)& vih2_H264 // pbFormat
};
+/// Format, Video HEVC
+static VIDEOINFOHEADER2 vih2_HEVC = {
+ {0, 0, 0, 0}, // rcSource
+ {0, 0, 0, 0}, // rcTarget
+ 0, // dwBitRate,
+ 0, // dwBitErrorRate
+ 0, // AvgTimePerFrame
+ 0, // dwInterlaceFlags
+ 0, // dwCopyProtectFlags
+ 0, // dwPictAspectRatioX
+ 0, // dwPictAspectRatioY
+ {0}, // dwControlFlag & dwReserved1
+ 0, // dwReserved2
+ {
+ // bmiHeader
+ sizeof(BITMAPINFOHEADER), // biSize
+ 720, // biWidth
+ 576, // biHeight
+ 1, // biPlanes
+ 0, // biBitCount
+ MAKEFOURCC('H', 'E', 'V', 'C') // biCompression
+ }
+ // implicitly sets the others fields to 0
+};
+
+/// Media type, Video HEVC
+static AM_MEDIA_TYPE mt_HEVC = {
+ MEDIATYPE_Video, // majortype
+ MEDIASUBTYPE_HEVC, // subtype
+ FALSE, // bFixedSizeSamples
+ TRUE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_VideoInfo2, // formattype
+ nullptr, // pUnk
+ sizeof(vih2_HEVC), // cbFormat
+ (LPBYTE)& vih2_HEVC // pbFormat
+};
+
// Format, Audio MPEG2
static BYTE MPEG2AudioFormat[] = {
0x50, 0x00, //wFormatTag
@@ -294,6 +334,8 @@ CFGManagerBDA::CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
if (pChannel) {
if (pChannel->GetVideoType() == DVB_H264) {
UpdateMediaType(&vih2_H264, pChannel);
+ } else if (pChannel->GetVideoType() == DVB_HEVC) {
+ UpdateMediaType(&vih2_HEVC, pChannel);
} else if (pChannel->GetVideoType() == DVB_MPV) {
UpdateMediaType(&sMpv_fmt, pChannel);
}
@@ -301,6 +343,7 @@ CFGManagerBDA::CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
m_DVBStreams[DVB_MPV] = CDVBStream(L"mpv", &mt_Mpv);
m_DVBStreams[DVB_H264] = CDVBStream(L"h264", &mt_H264);
+ m_DVBStreams[DVB_HEVC] = CDVBStream(L"HEVC", &mt_HEVC);
m_DVBStreams[DVB_MPA] = CDVBStream(L"mpa", &mt_Mpa);
m_DVBStreams[DVB_AC3] = CDVBStream(L"ac3", &mt_Ac3);
m_DVBStreams[DVB_EAC3] = CDVBStream(L"eac3", &mt_Eac3);
@@ -354,11 +397,11 @@ HRESULT CFGManagerBDA::CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, cons
BeginEnumSysDev(KSCategory, pMoniker) {
CComPtr pPB;
CComVariant var;
- LPOLESTR strName = nullptr;
+ CComHeapPtr strName;
if (SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPB))) &&
SUCCEEDED(pMoniker->GetDisplayName(nullptr, nullptr, &strName)) &&
- SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, nullptr))) {
- CStringW Name = CStringW(strName);
+ SUCCEEDED(pPB->Read(_T("FriendlyName"), &var, nullptr))) {
+ CStringW Name = strName;
if (Name != DisplayName) {
continue;
}
@@ -369,10 +412,6 @@ HRESULT CFGManagerBDA::CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, cons
}
break;
}
-
- if (strName) {
- CoTaskMemFree(strName);
- }
}
EndEnumSysDev;
@@ -424,19 +463,24 @@ HRESULT CFGManagerBDA::ConnectFilters(IBaseFilter* pOutFilter, IBaseFilter* pInF
&& S_OK != IsPinConnected(pInPin)) {
hr = this->ConnectDirect(pOutPin, pInPin, nullptr);
- /*#ifdef _DEBUG
- PIN_INFO InfoPinIn, InfoPinOut;
- FILTER_INFO InfoFilterIn, InfoFilterOut;
- pInPin->QueryPinInfo (&InfoPinIn);
- pOutPin->QueryPinInfo (&InfoPinOut);
- InfoPinIn.pFilter->QueryFilterInfo(&InfoFilterIn);
- InfoPinOut.pFilter->QueryFilterInfo(&InfoFilterOut);
+#if 0 && defined(_DEBUG) // Disabled by default because it can be verbose
+ CPinInfo infoPinIn, infoPinOut;
+ infoPinIn.achName[0] = infoPinOut.achName[0] = L'\0';
+ CFilterInfo infoFilterIn, infoFilterOut;
+ infoFilterIn.achName[0] = infoFilterOut.achName[0] = L'\0';
- TRACE(_T("%s - %s => %s - %s (hr=0x%08x)\n"), InfoFilterOut.achName, InfoPinOut.achName, InfoFilterIn.achName, InfoPinIn.achName, hr);
+ pInPin->QueryPinInfo(&infoPinIn);
+ if (infoPinIn.pFilter) {
+ infoPinIn.pFilter->QueryFilterInfo(&infoFilterIn);
+ }
+ pOutPin->QueryPinInfo(&infoPinOut);
+ if (infoPinOut.pFilter) {
+ infoPinOut.pFilter->QueryFilterInfo(&infoFilterOut);
+ }
+
+ TRACE(_T("%s - %s => %s - %s (hr=0x%08x)\n"), infoFilterOut.achName, infoPinOut.achName, infoFilterIn.achName, infoPinIn.achName, hr);
+#endif
- InfoPinIn.pFilter->Release();
- InfoPinOut.pFilter->Release();
- #endif*/
if (SUCCEEDED(hr)) {
return hr;
}
@@ -653,6 +697,9 @@ HRESULT CFGManagerBDA::ClearMaps()
if (m_DVBStreams[DVB_H264].GetMappedPID()) {
CheckNoLog(m_DVBStreams[DVB_H264].Unmap(m_DVBStreams[DVB_H264].GetMappedPID()));
}
+ if (m_DVBStreams[DVB_HEVC].GetMappedPID()) {
+ CheckNoLog(m_DVBStreams[DVB_HEVC].Unmap(m_DVBStreams[DVB_HEVC].GetMappedPID()));
+ }
if (m_DVBStreams[DVB_MPA].GetMappedPID()) {
CheckNoLog(m_DVBStreams[DVB_MPA].Unmap(m_DVBStreams[DVB_MPA].GetMappedPID()));
}
@@ -959,6 +1006,7 @@ HRESULT CFGManagerBDA::CreateMicrosoftDemux(CComPtr& pMpeg2Demux)
case DVB_MPV:
case DVB_H264:
+ case DVB_HEVC:
if ((nType == m_nCurVideoType) || (m_nDVBRebuildFilterGraph == DVB_REBUILD_FG_NEVER)) {
if (!Stream.GetFindExisting() ||
(pPin = FindPin(pMpeg2Demux, PINDIR_OUTPUT, Stream.GetMediaType())) == nullptr) {
@@ -1040,6 +1088,9 @@ HRESULT CFGManagerBDA::SetChannelInternal(CDVBChannel* pChannel)
if (pChannel->GetVideoType() == DVB_H264) {
UpdateMediaType(&vih2_H264, pChannel);
hr = pDemux->SetOutputPinMediaType(L"h264", const_cast(&mt_H264));
+ } else if (pChannel->GetVideoType() == DVB_HEVC) {
+ UpdateMediaType(&vih2_HEVC, pChannel);
+ hr = pDemux->SetOutputPinMediaType(L"HEVC", const_cast(&mt_HEVC));
} else {
UpdateMediaType(&sMpv_fmt, pChannel);
hr = pDemux->SetOutputPinMediaType(L"mpv", const_cast(&mt_Mpv));
@@ -1086,7 +1137,8 @@ HRESULT CFGManagerBDA::SetChannelInternal(CDVBChannel* pChannel)
CheckNoLog(m_DVBStreams[DVB_SUB].Map(pChannel->GetDefaultSubtitlePID()));
}
LOG(_T("Stream maps:"));
- LOG(_T("Mapped PID MPEG-2: %u, Mapped PID H.264: %u."), m_DVBStreams[DVB_MPV].GetMappedPID(), m_DVBStreams[DVB_H264].GetMappedPID());
+ LOG(_T("Mapped PID MPEG-2: %u, Mapped PID H.264: %u, Mapped PID HEVC: %u."),
+ m_DVBStreams[DVB_MPV].GetMappedPID(), m_DVBStreams[DVB_H264].GetMappedPID(), m_DVBStreams[DVB_HEVC].GetMappedPID());
LOG(_T("Mapped PID MPA: %u, Mapped PID AC3: %u, Mapped PID EAC3: %u, Mapped PID AAC-LATM: %u."), m_DVBStreams[DVB_MPA].GetMappedPID(),
m_DVBStreams[DVB_AC3].GetMappedPID(), m_DVBStreams[DVB_EAC3].GetMappedPID(), m_DVBStreams[DVB_LATM].GetMappedPID());
LOG(_T("Mapped PID Subtitles: %u."), m_DVBStreams[DVB_SUB].GetMappedPID());
@@ -1144,7 +1196,7 @@ HRESULT CFGManagerBDA::SwitchStream(DVB_STREAM_TYPE nOldType, DVB_STREAM_TYPE nN
CComPtr pNewOut = GetFirstPin(pFGNew, PINDIR_OUTPUT);
CComPtr pNewOutDynamic;
- if ((nNewType != DVB_H264) && (nNewType != DVB_MPV) && GetState() != State_Stopped) {
+ if (nNewType != DVB_MPV && nNewType != DVB_H264 && nNewType != DVB_HEVC && GetState() != State_Stopped) {
CComPtr pDemux;
m_pDemux->QueryInterface(IID_PPV_ARGS(&pDemux));
diff --git a/src/mpc-hc/FGManagerBDA.h b/src/mpc-hc/FGManagerBDA.h
index b314b6f1b00..aeb46c5dac9 100644
--- a/src/mpc-hc/FGManagerBDA.h
+++ b/src/mpc-hc/FGManagerBDA.h
@@ -1,5 +1,5 @@
/*
- * (C) 2009-2014 see Authors.txt
+ * (C) 2009-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -173,44 +173,3 @@ class CFGManagerBDA : public CFGManagerPlayer, IBDATuner, IAMStreamSelect
HRESULT SearchIBDATopology(const CComPtr& pTuner, REFIID iid, CComPtr& pUnk);
};
-
-#ifdef _DEBUG
-#include
-#include
-
-#define CheckAndLogBDA(x, msg) hr = ##x; if (FAILED(hr)) { LOG(msg _T(": 0x%08x\n"), hr); return hr; }
-#define CheckAndLogBDANoRet(x, msg) hr = ##x; if (FAILED(hr)) { LOG(msg _T(": 0x%08x\n"), hr); }
-
-#define LOG_FILE _T("bda.log")
-
-static void LOG(LPCTSTR fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- TCHAR buff[3000];
- FILE* f;
- _timeb timebuffer;
- TCHAR time1[8];
- TCHAR wbuf[26];
-
- _ftime_s(&timebuffer);
- _tctime_s(wbuf, _countof(wbuf), &timebuffer.time);
-
- for (size_t i = 0; i < _countof(time1); i++) {
- time1[i] = wbuf[i + 11];
- }
-
- _vstprintf_s(buff, _countof(buff), fmt, args);
- if (_tfopen_s(&f, LOG_FILE, _T("at")) == 0) {
- fseek(f, 0, 2);
- _ftprintf_s(f, _T("%.8s.%03hu - %s\n"), time1, timebuffer.millitm, buff);
- fclose(f);
- }
-
- va_end(args);
-}
-#else
-inline void LOG(LPCTSTR fmt, ...) {}
-#define CheckAndLogBDA(x, msg) hr = ##x; if (FAILED(hr)) { TRACE(msg _T(": 0x%08x\n"), hr); return hr; }
-#define CheckAndLogBDANoRet(x, msg) hr = ##x; if (FAILED(hr)) { TRACE(msg _T(": 0x%08x\n"), hr); }
-#endif
diff --git a/src/mpc-hc/FileDropTarget.cpp b/src/mpc-hc/FileDropTarget.cpp
deleted file mode 100644
index e1fd73be4de..00000000000
--- a/src/mpc-hc/FileDropTarget.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-#include "stdafx.h"
-#include "mplayerc.h"
-#include "FileDropTarget.h"
-
-
-// CFileDropTarget
-
-//IMPLEMENT_DYNAMIC(CFileDropTarget, COleDropTarget)
-CFileDropTarget::CFileDropTarget(CDropTarget* pDropTarget)
- : m_pDropTarget(pDropTarget)
-{
- ASSERT(m_pDropTarget);
-}
-
-CFileDropTarget::~CFileDropTarget()
-{
-}
-
-DROPEFFECT CFileDropTarget::OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
-{
- return m_pDropTarget ? m_pDropTarget->OnDragEnter(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
-}
-
-DROPEFFECT CFileDropTarget::OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
-{
- return m_pDropTarget ? m_pDropTarget->OnDragOver(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
-}
-
-BOOL CFileDropTarget::OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
-{
- return m_pDropTarget ? m_pDropTarget->OnDrop(pDataObject, dropEffect, point) : DROPEFFECT_NONE;
-}
-
-DROPEFFECT CFileDropTarget::OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point)
-{
- return m_pDropTarget ? m_pDropTarget->OnDropEx(pDataObject, dropDefault, dropList, point) : DROPEFFECT_NONE;
-}
-
-void CFileDropTarget::OnDragLeave(CWnd* pWnd)
-{
- if (m_pDropTarget) {
- m_pDropTarget->OnDragLeave();
- }
-}
-
-DROPEFFECT CFileDropTarget::OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point)
-{
- return m_pDropTarget ? m_pDropTarget->OnDragScroll(dwKeyState, point) : DROPEFFECT_NONE;
-}
-
-BEGIN_MESSAGE_MAP(CFileDropTarget, COleDropTarget)
-END_MESSAGE_MAP()
diff --git a/src/mpc-hc/FilterEnum.h b/src/mpc-hc/FilterEnum.h
index 1c4360068dc..bbd6b1a8979 100644
--- a/src/mpc-hc/FilterEnum.h
+++ b/src/mpc-hc/FilterEnum.h
@@ -1,5 +1,5 @@
/*
- * (C) 2010-2014 see Authors.txt
+ * (C) 2010-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -43,8 +43,11 @@ enum SOURCE_FILTER {
#if INTERNAL_SOURCEFILTER_FLIC
SRC_FLIC,
#endif
-#if INTERNAL_SOURCEFILTER_DTSAC3
- SRC_DTSAC3,
+#if INTERNAL_SOURCEFILTER_AC3
+ SRC_AC3,
+#endif
+#if INTERNAL_SOURCEFILTER_DTS
+ SRC_DTS,
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
SRC_MATROSKA,
@@ -101,6 +104,9 @@ enum SOURCE_FILTER {
#if INTERNAL_SOURCEFILTER_ASF
SRC_ASF,
#endif
+#if INTERNAL_SOURCEFILTER_WTV
+ SRC_WTV,
+#endif
#if INTERNAL_SOURCEFILTER_FLAC
SRC_FLAC,
#endif
diff --git a/src/mpc-hc/FreeviewEPGDecode.cpp b/src/mpc-hc/FreeviewEPGDecode.cpp
index 90d7b6fd1f8..c6ad4f5028c 100644
--- a/src/mpc-hc/FreeviewEPGDecode.cpp
+++ b/src/mpc-hc/FreeviewEPGDecode.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006-2008 Team MediaPortal http://www.team-mediaportal.com
- * (C) 2013 see Authors.txt
+ * (C) 2013, 2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -21,6 +21,7 @@
#include "stdafx.h"
#include "FreeviewEPGDecode.h"
+#include "Logger.h"
#define bitrev16(d) ((d << 8) & 0xff00) + ((d >> 8) & 0x00ff)
#define START '\0'
@@ -738,7 +739,7 @@ CString DecodeFreeviewEPG(const BYTE* pBuffer, size_t uLength)
prevc = nextc;
} while (nextc != STOP);
} else {
- TRACE(_T("DecodeFreeviewEPG: unsupported huffman table version %d, only version 1 and 2 are supported\n"), pBuffer[0]);
+ Logger::LOG(_T("DecodeFreeviewEPG: unsupported huffman table version %d, only version 1 and 2 are supported\n"), pBuffer[0]);
}
return uncompressedString;
diff --git a/src/mpc-hc/ISDb.cpp b/src/mpc-hc/ISDb.cpp
index 1c82fcd12df..b8bb731f38c 100644
--- a/src/mpc-hc/ISDb.cpp
+++ b/src/mpc-hc/ISDb.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -43,12 +43,11 @@ namespace ISDb
return false;
}
- LPOLESTR name;
+ CComHeapPtr name;
if (FAILED(pFSF->GetCurFile(&name, nullptr))) {
return false;
}
fh.name = name;
- CoTaskMemFree(name);
LONGLONG size, available;
if (pAR->Length(&size, &available) != S_OK) { // Don't accept estimates
diff --git a/src/mpc-hc/InternalFiltersConfig.h b/src/mpc-hc/InternalFiltersConfig.h
index 8ad417d7e02..d5878e22d5c 100644
--- a/src/mpc-hc/InternalFiltersConfig.h
+++ b/src/mpc-hc/InternalFiltersConfig.h
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -37,13 +37,15 @@
#define INTERNAL_SOURCEFILTER_CDDA INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_CDXA INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_DSM INTERNAL_FILTERS_ENABLED
-#define INTERNAL_SOURCEFILTER_DTSAC3 INTERNAL_FILTERS_ENABLED
+#define INTERNAL_SOURCEFILTER_AC3 INTERNAL_FILTERS_ENABLED
+#define INTERNAL_SOURCEFILTER_DTS INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_VTS INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_FLIC INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_FLAC INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_FLV INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_GIF INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_ASF INTERNAL_FILTERS_ENABLED
+#define INTERNAL_SOURCEFILTER_WTV INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_MATROSKA INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_MP4 INTERNAL_FILTERS_ENABLED
#define INTERNAL_SOURCEFILTER_OGG INTERNAL_FILTERS_ENABLED
@@ -104,12 +106,12 @@
// Groups
#define HAS_SOURCEFILTERS \
- (INTERNAL_SOURCEFILTER_AVI || INTERNAL_SOURCEFILTER_CDDA || INTERNAL_SOURCEFILTER_CDXA || INTERNAL_SOURCEFILTER_DSM || INTERNAL_SOURCEFILTER_DTSAC3 || \
- INTERNAL_SOURCEFILTER_VTS || INTERNAL_SOURCEFILTER_FLIC || INTERNAL_SOURCEFILTER_FLAC || INTERNAL_SOURCEFILTER_FLV || INTERNAL_SOURCEFILTER_ASF || \
- INTERNAL_SOURCEFILTER_MATROSKA || INTERNAL_SOURCEFILTER_MP4 || INTERNAL_SOURCEFILTER_OGG || INTERNAL_SOURCEFILTER_MPEGAUDIO || INTERNAL_SOURCEFILTER_MPEG || \
- INTERNAL_SOURCEFILTER_REALMEDIA || INTERNAL_SOURCEFILTER_HTTP || INTERNAL_SOURCEFILTER_UDP ||INTERNAL_SOURCEFILTER_RTP || INTERNAL_SOURCEFILTER_RTSP || \
- INTERNAL_SOURCEFILTER_AVI2AC3 || INTERNAL_SOURCEFILTER_RFS || INTERNAL_SOURCEFILTER_RTSP || INTERNAL_SOURCEFILTER_MMS || INTERNAL_SOURCEFILTER_RTMP || \
- INTERNAL_SOURCEFILTER_AVS || INTERNAL_SOURCEFILTER_GIF)
+ (INTERNAL_SOURCEFILTER_AVI || INTERNAL_SOURCEFILTER_CDDA || INTERNAL_SOURCEFILTER_CDXA || INTERNAL_SOURCEFILTER_DSM || INTERNAL_SOURCEFILTER_AC3 || \
+ INTERNAL_SOURCEFILTER_DTS || INTERNAL_SOURCEFILTER_VTS || INTERNAL_SOURCEFILTER_FLIC || INTERNAL_SOURCEFILTER_FLAC || INTERNAL_SOURCEFILTER_FLV || \
+ INTERNAL_SOURCEFILTER_ASF ||INTERNAL_SOURCEFILTER_WTV || INTERNAL_SOURCEFILTER_MATROSKA || INTERNAL_SOURCEFILTER_MP4 || INTERNAL_SOURCEFILTER_OGG || \
+ INTERNAL_SOURCEFILTER_MPEGAUDIO || INTERNAL_SOURCEFILTER_MPEG || INTERNAL_SOURCEFILTER_REALMEDIA || INTERNAL_SOURCEFILTER_HTTP || INTERNAL_SOURCEFILTER_UDP || \
+ INTERNAL_SOURCEFILTER_RTP || INTERNAL_SOURCEFILTER_RTSP || INTERNAL_SOURCEFILTER_AVI2AC3 || INTERNAL_SOURCEFILTER_RFS || INTERNAL_SOURCEFILTER_RTSP || \
+ INTERNAL_SOURCEFILTER_MMS || INTERNAL_SOURCEFILTER_RTMP || INTERNAL_SOURCEFILTER_AVS || INTERNAL_SOURCEFILTER_GIF)
#define HAS_AUDIO_DECODERS \
(INTERNAL_DECODER_LPCM || INTERNAL_DECODER_PS2AUDIO || INTERNAL_DECODER_REALAUDIO || INTERNAL_DECODER_PCM || INTERNAL_DECODER_AC3 || \
diff --git a/src/mpc-hc/LcdSupport.cpp b/src/mpc-hc/LcdSupport.cpp
index 9e64b518d70..ad36171d324 100644
--- a/src/mpc-hc/LcdSupport.cpp
+++ b/src/mpc-hc/LcdSupport.cpp
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2013 see Authors.txt
+ * (C) 2006-2013, 2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -657,7 +657,13 @@ void CMPC_Lcd::SetVolume(__int64 nVol)
//handle 64bit integers LCDUI only supports int for Range
//Since it also supports floats for position,
//This will always work in percentage
- float fVol = ((float)(nVol - m_nVolumeStart) * 100) / (float)(m_nVolumeStop - m_nVolumeStart);
+ float fVol;
+ if (m_nVolumeStart != m_nVolumeStop) {
+ fVol = float(nVol - m_nVolumeStart) * 100.0f / float(m_nVolumeStop - m_nVolumeStart);
+ } else {
+ fVol = 0.0f;
+ ASSERT(FALSE); // This isn't supposed to happen
+ }
EnterCriticalSection(&cs);
m_MonoPage.m_ProgBar[0].SetPos(fVol);
@@ -681,7 +687,12 @@ void CMPC_Lcd::SetMediaPos(__int64 nPos)
//handle 64bit integers LCDUI only supports int for Range
//Since it also supports floats for position,
//This will always work in percentage
- float fPos = ((float)(nPos - m_nMediaStart) * 100) / (float)(m_nMediaStop - m_nMediaStart);
+ float fPos;
+ if (m_nMediaStart != m_nMediaStop) {
+ fPos = float(nPos - m_nMediaStart) * 100.0f / float(m_nMediaStop - m_nMediaStart);
+ } else { // The duration might be unknown
+ fPos = 0.0f;
+ }
EnterCriticalSection(&cs);
m_MonoPage.m_ProgBar[1].SetPos(fPos);
diff --git a/src/mpc-hc/Logger.h b/src/mpc-hc/Logger.h
new file mode 100644
index 00000000000..6855733e3ff
--- /dev/null
+++ b/src/mpc-hc/Logger.h
@@ -0,0 +1,90 @@
+/*
+ * (C) 2015 see Authors.txt
+ *
+ * This file is part of MPC-HC.
+ *
+ * MPC-HC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MPC-HC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#pragma once
+
+#include
+#include
+#include "mplayerc.h"
+
+enum class LogTargets {
+ BDA
+};
+
+template
+struct LoggerFile;
+
+template<>
+struct LoggerFile {
+protected:
+ const LPCTSTR filename = _T("bda.log");
+ virtual ~LoggerFile() = default;
+};
+
+template
+class Logger final : public LoggerFile
+{
+public:
+ static void LOG(LPCTSTR fmt...) {
+ static Logger logger;
+
+ va_list args;
+ va_start(args, fmt);
+ logger.WriteToFile(fmt, args);
+ va_end(args);
+ };
+
+private:
+ const bool m_bLogging = AfxGetAppSettings().bEnableLogging;
+ std::mutex m_mutex;
+
+ Logger() {
+ // Check if logging is enabled only during initialization
+ // to avoid incomplete logs
+ ASSERT(AfxGetAppSettings().IsInitialized());
+ }
+
+ void WriteToFile(LPCTSTR fmt, va_list& args) {
+ if (!m_bLogging) {
+ return;
+ }
+
+ TCHAR buff[3000];
+ FILE* f;
+ _timeb timebuffer;
+ TCHAR time1[8];
+ TCHAR wbuf[26];
+
+ _ftime_s(&timebuffer);
+ _tctime_s(wbuf, _countof(wbuf), &timebuffer.time);
+
+ for (size_t i = 0; i < _countof(time1); i++) {
+ time1[i] = wbuf[i + 11];
+ }
+
+ _vstprintf_s(buff, _countof(buff), fmt, args);
+
+ std::lock_guard lock(m_mutex);
+ if (_tfopen_s(&f, filename, _T("at")) == 0) {
+ _ftprintf_s(f, _T("%.8s.%03hu - %s\n"), time1, timebuffer.millitm, buff);
+ fclose(f);
+ }
+ }
+};
diff --git a/src/mpc-hc/MPCPngImage.cpp b/src/mpc-hc/MPCPngImage.cpp
index 3bfbd73d5b4..e4b6ba6ea63 100644
--- a/src/mpc-hc/MPCPngImage.cpp
+++ b/src/mpc-hc/MPCPngImage.cpp
@@ -7,18 +7,6 @@
CImage* CMPCPngImage::m_pImage;
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-CMPCPngImage::CMPCPngImage()
-{
-}
-
-CMPCPngImage::~CMPCPngImage()
-{
-}
-
//////////////////////////////////////////////////////////////////////
// Operations
//////////////////////////////////////////////////////////////////////
@@ -112,3 +100,13 @@ BOOL CMPCPngImage::LoadFromBuffer(const LPBYTE lpBuffer, UINT uiSize)
return bRes;
}
+
+CSize CMPCPngImage::GetSize()
+{
+ CSize size;
+ BITMAP bm;
+ if (GetBitmap(&bm)) {
+ size.SetSize(bm.bmWidth, bm.bmHeight);
+ }
+ return size;
+}
diff --git a/src/mpc-hc/MPCPngImage.h b/src/mpc-hc/MPCPngImage.h
index 91129a3e969..47448a7ff4a 100644
--- a/src/mpc-hc/MPCPngImage.h
+++ b/src/mpc-hc/MPCPngImage.h
@@ -6,8 +6,8 @@ class CMPCPngImage : public CBitmap
{
// Construction/Destruction
public:
- CMPCPngImage();
- virtual ~CMPCPngImage();
+ CMPCPngImage() = default;
+ virtual ~CMPCPngImage() = default;
// Attributes:
protected:
@@ -21,6 +21,8 @@ class CMPCPngImage : public CBitmap
BOOL LoadFromFile(LPCTSTR lpszPath);
BOOL LoadFromBuffer(const LPBYTE lpBuffer, UINT uiSize);
+ CSize GetSize();
+
static void __stdcall CleanUp() {
SAFE_DELETE(m_pImage);
}
diff --git a/src/mpc-hc/MainFrm.cpp b/src/mpc-hc/MainFrm.cpp
index c6a565e4f18..86fcf7d71be 100644
--- a/src/mpc-hc/MainFrm.cpp
+++ b/src/mpc-hc/MainFrm.cpp
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
- * (C) 2006-2014 see Authors.txt
+ * (C) 2006-2015 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -101,6 +101,9 @@
#include "../Subtitles/RLECodedSubtitle.h"
#include "../Subtitles/PGSSub.h"
+#include
+#include
+
template
bool NEARLY_EQ(T a, T b, T tol)
{
@@ -247,7 +250,6 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_OPEN_OPTICAL_DISK_START, ID_FILE_OPEN_OPTICAL_DISK_END, OnUpdateFileOpen)
ON_COMMAND(ID_FILE_REOPEN, OnFileReopen)
ON_COMMAND(ID_FILE_RECYCLE, OnFileRecycle)
- ON_WM_DROPFILES()
ON_COMMAND(ID_FILE_SAVE_COPY, OnFileSaveAs)
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_COPY, OnUpdateFileSaveAs)
ON_COMMAND(ID_FILE_SAVE_IMAGE, OnFileSaveImage)
@@ -332,9 +334,9 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
// Casimir666
ON_UPDATE_COMMAND_UI(ID_VIEW_TEARING_TEST, OnUpdateViewTearingTest)
ON_COMMAND(ID_VIEW_TEARING_TEST, OnViewTearingTest)
- ON_UPDATE_COMMAND_UI(ID_VIEW_DISPLAYSTATS, OnUpdateViewDisplayStats)
- ON_COMMAND(ID_VIEW_RESETSTATS, OnViewResetStats)
- ON_COMMAND(ID_VIEW_DISPLAYSTATS, OnViewDisplayStatsSC)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_DISPLAY_RENDERER_STATS, OnUpdateViewDisplayRendererStats)
+ ON_COMMAND(ID_VIEW_RESET_RENDERER_STATS, OnViewResetRendererStats)
+ ON_COMMAND(ID_VIEW_DISPLAY_RENDERER_STATS, OnViewDisplayRendererStats)
ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREENGUISUPPORT, OnUpdateViewFullscreenGUISupport)
ON_UPDATE_COMMAND_UI(ID_VIEW_HIGHCOLORRESOLUTION, OnUpdateViewHighColorResolution)
ON_UPDATE_COMMAND_UI(ID_VIEW_FORCEINPUTHIGHCOLORRESOLUTION, OnUpdateViewForceInputHighColorResolution)
@@ -417,8 +419,10 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_COMMAND(ID_VIEW_VSYNCOFFSET_INCREASE, OnViewVSyncOffsetIncrease)
ON_COMMAND(ID_VIEW_VSYNCOFFSET_DECREASE, OnViewVSyncOffsetDecrease)
- ON_UPDATE_COMMAND_UI(ID_VIEW_REMAINING_TIME, OnUpdateViewRemainingTime)
- ON_COMMAND(ID_VIEW_REMAINING_TIME, OnViewRemainingTime)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_OSD_DISPLAY_TIME, OnUpdateViewOSDDisplayTime)
+ ON_COMMAND(ID_VIEW_OSD_DISPLAY_TIME, OnViewOSDDisplayTime)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_OSD_SHOW_FILENAME, OnUpdateViewOSDShowFileName)
+ ON_COMMAND(ID_VIEW_OSD_SHOW_FILENAME, OnViewOSDShowFileName)
ON_COMMAND(ID_D3DFULLSCREEN_TOGGLE, OnD3DFullscreenToggle)
ON_COMMAND_RANGE(ID_GOTO_PREV_SUB, ID_GOTO_NEXT_SUB, OnGotoSubtitle)
ON_COMMAND_RANGE(ID_SHIFT_SUB_DOWN, ID_SHIFT_SUB_UP, OnShiftSubtitle)
@@ -465,10 +469,10 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_COMMAND_RANGE(ID_NORMALIZE, ID_REGAIN_VOLUME, OnNormalizeRegainVolume)
ON_UPDATE_COMMAND_UI_RANGE(ID_NORMALIZE, ID_REGAIN_VOLUME, OnUpdateNormalizeRegainVolume)
ON_COMMAND_RANGE(ID_COLOR_BRIGHTNESS_INC, ID_COLOR_RESET, OnPlayColor)
- ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_MONITOROFF, OnUpdateAfterplayback)
- ON_COMMAND_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_MONITOROFF, OnAfterplayback)
- ON_UPDATE_COMMAND_UI(ID_AFTERPLAYBACK_PLAYNEXT, OnUpdateAfterplayback)
- ON_COMMAND_RANGE(ID_AFTERPLAYBACK_PLAYNEXT, ID_AFTERPLAYBACK_PLAYNEXT, OnAfterplayback)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_MONITOROFF, OnUpdateAfterplayback)
+ ON_COMMAND_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_MONITOROFF, OnAfterplayback)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_PLAYNEXT, ID_AFTERPLAYBACK_DONOTHING, OnUpdateAfterplayback)
+ ON_COMMAND_RANGE(ID_AFTERPLAYBACK_PLAYNEXT, ID_AFTERPLAYBACK_DONOTHING, OnAfterplayback)
ON_COMMAND_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnNavigateSkip)
ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnUpdateNavigateSkip)
@@ -674,6 +678,10 @@ void CMainFrame::EventCallback(MpcEvent ev)
case MpcEvent::CHANGING_UI_LANGUAGE:
UpdateUILanguage();
break;
+ case MpcEvent::STREAM_POS_UPDATE_REQUEST:
+ OnTimer(TIMER_STREAMPOSPOLLER);
+ OnTimer(TIMER_STREAMPOSPOLLER2);
+ break;
default:
ASSERT(FALSE);
}
@@ -715,18 +723,16 @@ CMainFrame::CMainFrame()
, m_fOpeningAborted(false)
, m_bBuffering(false)
, m_bUsingDXVA(false)
- , m_fileDropTarget(this)
, m_bTrayIcon(false)
, m_pFullscreenWnd(nullptr)
, m_pVideoWnd(nullptr)
- , m_bRemainingTime(false)
+ , m_bOSDDisplayTime(false)
, m_nCurSubtitle(-1)
, m_lSubtitleShift(0)
, m_nStepForwardCount(0)
, m_rtStepForwardStart(0)
, m_lCurrentChapter(0)
, m_lChapterStartTime(0xFFFFFFFF)
- , m_pTaskbarList(nullptr)
, m_pGraphThread(nullptr)
, m_bOpenedThroughThread(false)
, m_evOpenPrivateFinished(FALSE, TRUE)
@@ -783,6 +789,7 @@ CMainFrame::CMainFrame()
receives.insert(MpcEvent::DISPLAY_MODE_AUTOCHANGING);
receives.insert(MpcEvent::DISPLAY_MODE_AUTOCHANGED);
receives.insert(MpcEvent::CHANGING_UI_LANGUAGE);
+ receives.insert(MpcEvent::STREAM_POS_UPDATE_REQUEST);
EventRouter::EventSelection fires;
fires.insert(MpcEvent::SWITCHING_TO_FULLSCREEN);
fires.insert(MpcEvent::SWITCHED_TO_FULLSCREEN);
@@ -902,7 +909,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
pair.second->ShowWindow(SW_HIDE);
}
- m_fileDropTarget.Register(this);
+ m_dropTarget.Register(this);
const CAppSettings& s = AfxGetAppSettings();
@@ -910,8 +917,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
ShowTrayIcon(s.fTrayIcon);
- SetFocus();
-
m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
if (m_pGraphThread) {
@@ -939,7 +944,7 @@ void CMainFrame::OnDestroy()
{
WTSUnRegisterSessionNotification();
ShowTrayIcon(false);
- m_fileDropTarget.Revoke();
+ m_dropTarget.Revoke();
if (m_pDebugShaders && IsWindow(m_pDebugShaders->m_hWnd)) {
VERIFY(m_pDebugShaders->DestroyWindow());
@@ -988,62 +993,6 @@ void CMainFrame::OnClose()
__super::OnClose();
}
-DROPEFFECT CMainFrame::OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
-{
- return DROPEFFECT_NONE;
-}
-
-DROPEFFECT CMainFrame::OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
-{
- UpdateControlState(UPDATE_CONTROLS_VISIBILITY);
- UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
- return pDataObject->IsDataAvailable(CF_URL) ? DROPEFFECT_COPY : DROPEFFECT_NONE;
-}
-
-BOOL CMainFrame::OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
-{
- UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
- BOOL bResult = FALSE;
-
- // If we are dropping a file, let OnDropFiles handle drag-and-drop
- if (!pDataObject->IsDataAvailable(CF_HDROP) && pDataObject->IsDataAvailable(CF_URL)) {
- FORMATETC fmt = {CF_URL, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- if (HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt)) {
- LPCSTR pText = (LPCSTR)GlobalLock(hGlobal);
- if (AfxIsValidString(pText)) {
- CStringA url(pText);
-
- SetForegroundWindow();
-
- CAtlList sl;
- sl.AddTail(CString(url));
-
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
-
- GlobalUnlock(hGlobal);
- bResult = TRUE;
- }
- }
- }
-
- return bResult;
-}
-
-DROPEFFECT CMainFrame::OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point)
-{
- return (DROPEFFECT) - 1;
-}
-
-void CMainFrame::OnDragLeave()
-{
-}
-
-DROPEFFECT CMainFrame::OnDragScroll(DWORD dwKeyState, CPoint point)
-{
- return DROPEFFECT_NONE;
-}
-
LPCTSTR CMainFrame::GetRecentFile() const
{
CRecentFileList& MRU = AfxGetAppSettings().MRU;
@@ -1605,7 +1554,7 @@ void CMainFrame::OnWindowPosChanging(WINDOWPOS* lpwndpos)
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
// Only stop screensaver if video playing; allow for audio only
- if ((GetMediaState() == State_Running && !m_fAudioOnly)
+ if ((GetMediaState() == State_Running && !m_fEndOfStream && !m_fAudioOnly)
&& (((nID & 0xFFF0) == SC_SCREENSAVE) || ((nID & 0xFFF0) == SC_MONITORPOWER))) {
TRACE(_T("SC_SCREENSAVE, nID = %u, lParam = %d\n"), nID, lParam);
return;
@@ -1807,7 +1756,7 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent)
m_lSubtitleShift = 0;
}
- m_wndStatusBar.SetStatusTimer(rtNow, rtDur, !!m_wndSubresyncBar.IsWindowVisible(), GetTimeFormat());
+ m_wndStatusBar.SetStatusTimer(rtNow, rtDur, IsSubresyncBarVisible(), GetTimeFormat());
break;
case PM_DVD:
g_bExternalSubtitleTime = true;
@@ -1830,7 +1779,7 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent)
}
}
}
- m_wndStatusBar.SetStatusTimer(rtNow, rtDur, !!m_wndSubresyncBar.IsWindowVisible(), GetTimeFormat());
+ m_wndStatusBar.SetStatusTimer(rtNow, rtDur, IsSubresyncBarVisible(), GetTimeFormat());
break;
case PM_ANALOG_CAPTURE:
g_bExternalSubtitleTime = true;
@@ -1879,7 +1828,7 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent)
case PM_FILE:
// no break
case PM_DVD:
- if (m_bRemainingTime) {
+ if (m_bOSDDisplayTime) {
m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer());
}
break;
@@ -1891,7 +1840,7 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent)
REFERENCE_TIME rtNow = REFERENCE_TIME(tNow - NowNext.startTime) * 10000000;
REFERENCE_TIME rtDur = REFERENCE_TIME(NowNext.duration) * 10000000;
m_wndStatusBar.SetStatusTimer(rtNow, rtDur, false, TIME_FORMAT_MEDIA_TIME);
- if (m_bRemainingTime) {
+ if (m_bOSDDisplayTime) {
m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer());
}
} else {
@@ -1983,7 +1932,7 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent)
DWORD nAvg = pBRI->GetAverageBitRate() / 1000;
if (nAvg > 0) {
- sInfo.AppendFormat(_T("[%u]: %lu/%lu Kb/s "), i, nAvg, pBRI->GetCurrentBitRate() / 1000);
+ sInfo.AppendFormat(_T("[%u]: %lu/%lu kb/s "), i, nAvg, pBRI->GetCurrentBitRate() / 1000);
}
}
i++;
@@ -2234,7 +2183,9 @@ void CMainFrame::DoAfterPlaybackEvent()
bool bExitFullScreen = false;
bool bNoMoreMedia = false;
- if (s.nCLSwitches & CLSW_CLOSE) {
+ if (s.nCLSwitches & CLSW_DONOTHING) {
+ // Do nothing
+ } else if (s.nCLSwitches & CLSW_CLOSE) {
SendMessage(WM_COMMAND, ID_FILE_EXIT);
} else if (s.nCLSwitches & CLSW_MONITOROFF) {
m_fEndOfStream = true;
@@ -2304,6 +2255,10 @@ void CMainFrame::DoAfterPlaybackEvent()
}
}
+ if (AfxGetMyApp()->m_fClosingState) {
+ return;
+ }
+
if (m_fEndOfStream) {
m_OSD.EnableShowMessage(false);
SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
@@ -2345,7 +2300,7 @@ void CMainFrame::GraphEventComplete()
DoAfterPlaybackEvent();
} else if (m_wndPlaylistBar.GetCount() > 1) {
int nLoops = m_nLoops;
- SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
+ SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARDFILE);
m_nLoops = nLoops;
} else {
if (GetMediaState() == State_Stopped) {
@@ -2374,7 +2329,7 @@ LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam)
LONG evCode = 0;
LONG_PTR evParam1, evParam2;
- while (m_pME && SUCCEEDED(m_pME->GetEvent(&evCode, &evParam1, &evParam2, 0))) {
+ while (!AfxGetMyApp()->m_fClosingState && m_pME && SUCCEEDED(m_pME->GetEvent(&evCode, &evParam1, &evParam2, 0))) {
#ifdef _DEBUG
TRACE(_T("--> CMainFrame::OnGraphNotify on thread: %lu; event: 0x%08x (%ws)\n"), GetCurrentThreadId(), evCode, GetEventString(evCode));
#endif
@@ -4111,6 +4066,13 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
bool fSetForegroundWindow = false;
+ auto applyRandomizeSwitch = [&]() {
+ if (s.nCLSwitches & CLSW_RANDOMIZE) {
+ m_wndPlaylistBar.Randomize();
+ s.nCLSwitches &= ~CLSW_RANDOMIZE;
+ }
+ };
+
if ((s.nCLSwitches & CLSW_DVD) && !s.slFiles.IsEmpty()) {
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
fSetForegroundWindow = true;
@@ -4141,6 +4103,7 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
}
m_wndPlaylistBar.Open(sl, true);
+ applyRandomizeSwitch();
OpenCurPlaylistItem();
} else if (s.nCLSwitches & CLSW_DEVICE) {
SendMessage(WM_COMMAND, ID_FILE_OPENDEVICE);
@@ -4148,7 +4111,7 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
CAtlList sl;
sl.AddTailList(&s.slFiles);
- ParseDirs(sl);
+ PathUtils::ParseDirs(sl);
bool fMulti = sl.GetCount() > 1;
@@ -4176,6 +4139,7 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
if ((s.nCLSwitches & CLSW_ADD) && !IsPlaylistEmpty()) {
m_wndPlaylistBar.Append(sl, fMulti, &s.slSubs);
+ applyRandomizeSwitch();
if (s.nCLSwitches & (CLSW_OPEN | CLSW_PLAY)) {
m_wndPlaylistBar.SetLast();
@@ -4186,6 +4150,7 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
fSetForegroundWindow = true;
m_wndPlaylistBar.Open(sl, fMulti, &s.slSubs);
+ applyRandomizeSwitch();
OpenCurPlaylistItem((s.nCLSwitches & CLSW_STARTVALID) ? s.rtStart : 0);
s.nCLSwitches &= ~CLSW_STARTVALID;
@@ -4193,6 +4158,7 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
}
}
} else {
+ applyRandomizeSwitch();
s.nCLSwitches = CLSW_NONE;
}
@@ -4359,39 +4325,39 @@ void CMainFrame::OnFileReopen()
OpenCurPlaylistItem();
}
-void CMainFrame::OnDropFiles(HDROP hDropInfo)
+DROPEFFECT CMainFrame::OnDropAccept(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
- SetForegroundWindow();
-
- UINT nFiles = ::DragQueryFile(hDropInfo, UINT_MAX, nullptr, 0);
-
- CAtlList sl;
- for (UINT iFile = 0; iFile < nFiles; iFile++) {
- CString fn;
- fn.ReleaseBuffer(::DragQueryFile(hDropInfo, iFile, fn.GetBuffer(MAX_PATH), MAX_PATH));
- sl.AddTail(fn);
+ ClientToScreen(&point);
+ if (CMouse::CursorOnRootWindow(point, *this)) {
+ UpdateControlState(UPDATE_CONTROLS_VISIBILITY);
+ return (dwKeyState & MK_CONTROL) ? DROPEFFECT_COPY : DROPEFFECT_MOVE;
}
- ::DragFinish(hDropInfo);
+ return DROPEFFECT_NONE;
+}
+
+void CMainFrame::OnDropFiles(CAtlList& slFiles, DROPEFFECT dropEffect)
+{
+ SetForegroundWindow();
- if (sl.IsEmpty()) {
+ if (slFiles.IsEmpty()) {
return;
}
- if (sl.GetCount() == 1 && OpenBD(sl.GetHead())) {
+ if (slFiles.GetCount() == 1 && OpenBD(slFiles.GetHead())) {
return;
}
- ParseDirs(sl);
+ PathUtils::ParseDirs(slFiles);
SubtitleInput subInputSelected;
if (GetLoadState() == MLS::LOADED && !IsPlaybackCaptureMode() && !m_fAudioOnly && m_pCAP) {
- POSITION pos = sl.GetHeadPosition();
+ POSITION pos = slFiles.GetHeadPosition();
while (pos) {
// Try to open all dropped files as subtitles. If one of the files
// cannot be loaded as subtitle, add all files to the playlist.
SubtitleInput subInput;
- if (LoadSubtitle(sl.GetNext(pos), &subInput)) {
+ if (LoadSubtitle(slFiles.GetNext(pos), &subInput)) {
if (!subInputSelected.pSubStream) {
subInputSelected = subInput;
}
@@ -4408,16 +4374,20 @@ void CMainFrame::OnDropFiles(HDROP hDropInfo)
SetSubtitle(subInputSelected);
CString filenames;
- POSITION pos = sl.GetHeadPosition();
+ POSITION pos = slFiles.GetHeadPosition();
while (pos) {
- CPath fn(sl.GetNext(pos));
+ CPath fn(slFiles.GetNext(pos));
fn.StripPath();
filenames.AppendFormat(pos ? _T("%s, ") : _T("%s"), fn);
}
SendStatusMessage(filenames + ResStr(IDS_SUB_LOADED_SUCCESS), 3000);
} else {
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
+ if (dropEffect & DROPEFFECT_COPY) {
+ m_wndPlaylistBar.Append(slFiles, true);
+ } else {
+ m_wndPlaylistBar.Open(slFiles, true);
+ OpenCurPlaylistItem();
+ }
}
}
@@ -5415,7 +5385,7 @@ void CMainFrame::OnViewTearingTest()
AfxGetMyApp()->m_Renderers.m_bTearingTest = !AfxGetMyApp()->m_Renderers.m_bTearingTest;
}
-void CMainFrame::OnUpdateViewDisplayStats(CCmdUI* pCmdUI)
+void CMainFrame::OnUpdateViewDisplayRendererStats(CCmdUI* pCmdUI)
{
const CAppSettings& s = AfxGetAppSettings();
bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS
@@ -5426,12 +5396,12 @@ void CMainFrame::OnUpdateViewDisplayStats(CCmdUI* pCmdUI)
pCmdUI->SetCheck(supported && AfxGetMyApp()->m_Renderers.m_iDisplayStats);
}
-void CMainFrame::OnViewResetStats()
+void CMainFrame::OnViewResetRendererStats()
{
AfxGetMyApp()->m_Renderers.m_bResetStats = true; // Reset by "consumer"
}
-void CMainFrame::OnViewDisplayStatsSC()
+void CMainFrame::OnViewDisplayRendererStats()
{
const CAppSettings& s = AfxGetAppSettings();
bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS
@@ -6167,24 +6137,67 @@ void CMainFrame::OnViewVSyncOffsetDecrease()
m_OSD.DisplayMessage(OSD_TOPRIGHT, strOSD);
}
-void CMainFrame::OnUpdateViewRemainingTime(CCmdUI* pCmdUI)
+void CMainFrame::OnUpdateViewOSDDisplayTime(CCmdUI* pCmdUI)
{
const CAppSettings& s = AfxGetAppSettings();
- pCmdUI->Enable(s.fShowOSD && (GetLoadState() != MLS::CLOSED));
- pCmdUI->SetCheck(m_bRemainingTime);
+ pCmdUI->Enable(s.fShowOSD && GetLoadState() != MLS::CLOSED);
+ pCmdUI->SetCheck(m_bOSDDisplayTime);
}
-void CMainFrame::OnViewRemainingTime()
+void CMainFrame::OnViewOSDDisplayTime()
{
- m_bRemainingTime = !m_bRemainingTime;
+ m_bOSDDisplayTime = !m_bOSDDisplayTime;
- if (!m_bRemainingTime) {
+ if (!m_bOSDDisplayTime) {
m_OSD.ClearMessage();
}
OnTimer(TIMER_STREAMPOSPOLLER2);
}
+void CMainFrame::OnUpdateViewOSDShowFileName(CCmdUI* pCmdUI)
+{
+ const CAppSettings& s = AfxGetAppSettings();
+ pCmdUI->Enable(s.fShowOSD && GetLoadState() != MLS::CLOSED);
+}
+
+void CMainFrame::OnViewOSDShowFileName()
+{
+ CString strOSD;
+ switch (GetPlaybackMode()) {
+ case PM_FILE:
+ strOSD = GetFileName();
+ break;
+ case PM_DVD:
+ strOSD = _T("DVD");
+ if (m_pDVDI) {
+ CString path;
+ ULONG len = 0;
+ if (SUCCEEDED(m_pDVDI->GetDVDDirectory(path.GetBuffer(MAX_PATH), MAX_PATH, &len)) && len) {
+ path.ReleaseBuffer();
+ if (path.Find(_T("\\VIDEO_TS")) == 2) {
+ strOSD.AppendFormat(_T(" - %s"), GetDriveLabel(CPath(path)));
+ } else {
+ strOSD.AppendFormat(_T(" - %s"), path);
+ }
+ }
+ }
+ break;
+ case PM_ANALOG_CAPTURE:
+ strOSD = GetCaptureTitle();
+ break;
+ case PM_DIGITAL_CAPTURE:
+ UpdateCurrentChannelInfo(true, false);
+ break;
+ default: // Shouldn't happen
+ ASSERT(FALSE);
+ return;
+ }
+ if (!strOSD.IsEmpty()) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strOSD);
+ }
+}
+
void CMainFrame::OnD3DFullscreenToggle()
{
CAppSettings& s = AfxGetAppSettings();
@@ -6507,7 +6520,7 @@ void CMainFrame::OnViewFullscreenSecondary()
{
const CAppSettings& s = AfxGetAppSettings();
- if (IsD3DFullScreenMode() || (s.IsD3DFullscreen() && !m_fFullScreen)) {
+ if (IsD3DFullScreenMode() || (s.IsD3DFullscreen() && !m_fFullScreen && !m_fAudioOnly)) {
ToggleD3DFullscreen(false);
} else {
ToggleFullscreen(true, false);
@@ -7163,7 +7176,7 @@ void CMainFrame::OnPlayStop()
__int64 start, stop;
m_wndSeekBar.GetRange(start, stop);
if (!IsPlaybackCaptureMode()) {
- m_wndStatusBar.SetStatusTimer(m_wndSeekBar.GetPos(), stop, !!m_wndSubresyncBar.IsWindowVisible(), GetTimeFormat());
+ m_wndStatusBar.SetStatusTimer(m_wndSeekBar.GetPos(), stop, IsSubresyncBarVisible(), GetTimeFormat());
}
SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
@@ -7407,7 +7420,6 @@ void CMainFrame::OnPlaySeekKey(UINT nID)
void CMainFrame::OnUpdatePlaySeek(CCmdUI* pCmdUI)
{
bool fEnable = false;
- OAFilterState fs = GetMediaState();
if (GetLoadState() == MLS::LOADED) {
fEnable = true;
@@ -8136,58 +8148,89 @@ void CMainFrame::OnAfterplayback(UINT nID)
WORD osdMsg = 0;
bool bDisable = false;
- auto toogleOption = [&](UINT64 nID) {
+ auto toggleOption = [&](UINT64 nID) {
bDisable = !!(s.nCLSwitches & nID);
s.nCLSwitches &= ~CLSW_AFTERPLAYBACK_MASK | nID;
s.nCLSwitches ^= nID;
};
switch (nID) {
- case ID_AFTERPLAYBACK_CLOSE:
- toogleOption(CLSW_CLOSE);
- osdMsg = IDS_AFTERPLAYBACK_CLOSE;
+ case ID_AFTERPLAYBACK_EXIT:
+ toggleOption(CLSW_CLOSE);
+ osdMsg = IDS_AFTERPLAYBACK_EXIT;
break;
case ID_AFTERPLAYBACK_STANDBY:
- toogleOption(CLSW_STANDBY);
+ toggleOption(CLSW_STANDBY);
osdMsg = IDS_AFTERPLAYBACK_STANDBY;
break;
case ID_AFTERPLAYBACK_HIBERNATE:
- toogleOption(CLSW_HIBERNATE);
+ toggleOption(CLSW_HIBERNATE);
osdMsg = IDS_AFTERPLAYBACK_HIBERNATE;
break;
case ID_AFTERPLAYBACK_SHUTDOWN:
- toogleOption(CLSW_SHUTDOWN);
+ toggleOption(CLSW_SHUTDOWN);
osdMsg = IDS_AFTERPLAYBACK_SHUTDOWN;
break;
case ID_AFTERPLAYBACK_LOGOFF:
- toogleOption(CLSW_LOGOFF);
+ toggleOption(CLSW_LOGOFF);
osdMsg = IDS_AFTERPLAYBACK_LOGOFF;
break;
case ID_AFTERPLAYBACK_LOCK:
- toogleOption(CLSW_LOCK);
+ toggleOption(CLSW_LOCK);
osdMsg = IDS_AFTERPLAYBACK_LOCK;
break;
case ID_AFTERPLAYBACK_MONITOROFF:
- toogleOption(CLSW_MONITOROFF);
+ toggleOption(CLSW_MONITOROFF);
osdMsg = IDS_AFTERPLAYBACK_MONITOROFF;
break;
case ID_AFTERPLAYBACK_PLAYNEXT:
- toogleOption(CLSW_PLAYNEXT);
+ toggleOption(CLSW_PLAYNEXT);
osdMsg = IDS_AFTERPLAYBACK_PLAYNEXT;
break;
+ case ID_AFTERPLAYBACK_DONOTHING:
+ toggleOption(CLSW_DONOTHING);
+ osdMsg = IDS_AFTERPLAYBACK_DONOTHING;
+ break;
+ }
+ if (bDisable) {
+ switch (s.eAfterPlayback) {
+ case CAppSettings::AfterPlayback::PLAY_NEXT:
+ osdMsg = IDS_AFTERPLAYBACK_PLAYNEXT;
+ break;
+ case CAppSettings::AfterPlayback::REWIND:
+ osdMsg = IDS_AFTERPLAYBACK_REWIND;
+ break;
+ case CAppSettings::AfterPlayback::MONITOROFF:
+ osdMsg = IDS_AFTERPLAYBACK_MONITOROFF;
+ break;
+ case CAppSettings::AfterPlayback::CLOSE:
+ osdMsg = IDS_AFTERPLAYBACK_CLOSE;
+ break;
+ case CAppSettings::AfterPlayback::EXIT:
+ osdMsg = IDS_AFTERPLAYBACK_EXIT;
+ break;
+ default:
+ ASSERT(FALSE);
+ // no break
+ case CAppSettings::AfterPlayback::DO_NOTHING:
+ osdMsg = IDS_AFTERPLAYBACK_DONOTHING;
+ break;
+ }
}
- m_OSD.DisplayMessage(OSD_TOPLEFT, bDisable ? ResStr(IDS_AFTERPLAYBACK_DONOTHING) : ResStr(osdMsg));
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(osdMsg));
}
void CMainFrame::OnUpdateAfterplayback(CCmdUI* pCmdUI)
{
const CAppSettings& s = AfxGetAppSettings();
- bool bChecked = false;
+ bool bChecked;
+ bool bRadio = false;
switch (pCmdUI->m_nID) {
- case ID_AFTERPLAYBACK_CLOSE:
+ case ID_AFTERPLAYBACK_EXIT:
bChecked = !!(s.nCLSwitches & CLSW_CLOSE);
+ bRadio = s.eAfterPlayback == CAppSettings::AfterPlayback::EXIT;
break;
case ID_AFTERPLAYBACK_STANDBY:
bChecked = !!(s.nCLSwitches & CLSW_STANDBY);
@@ -8206,14 +8249,29 @@ void CMainFrame::OnUpdateAfterplayback(CCmdUI* pCmdUI)
break;
case ID_AFTERPLAYBACK_MONITOROFF:
bChecked = !!(s.nCLSwitches & CLSW_MONITOROFF);
+ bRadio = s.eAfterPlayback == CAppSettings::AfterPlayback::MONITOROFF;
break;
case ID_AFTERPLAYBACK_PLAYNEXT:
bChecked = !!(s.nCLSwitches & CLSW_PLAYNEXT);
+ bRadio = s.eAfterPlayback == CAppSettings::AfterPlayback::PLAY_NEXT;
break;
+ case ID_AFTERPLAYBACK_DONOTHING:
+ bChecked = !!(s.nCLSwitches & CLSW_DONOTHING);
+ bRadio = s.eAfterPlayback == CAppSettings::AfterPlayback::DO_NOTHING;
+ break;
+ default:
+ ASSERT(FALSE);
+ return;
}
- pCmdUI->Enable();
- pCmdUI->SetCheck(bChecked);
+ if (IsMenu(*pCmdUI->m_pMenu)) {
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_FTYPE | MIIM_STATE;
+ mii.fType = (bRadio ? MFT_RADIOCHECK : 0);
+ mii.fState = (bRadio ? MFS_DISABLED : 0) | (bChecked || bRadio ? MFS_CHECKED : 0);
+ VERIFY(pCmdUI->m_pMenu->SetMenuItemInfo(pCmdUI->m_nID, &mii));
+ }
}
bool CMainFrame::SeekToFileChapter(int iChapter, bool bRelative /*= false*/)
@@ -8246,7 +8304,9 @@ bool CMainFrame::SeekToFileChapter(int iChapter, bool bRelative /*= false*/)
}
CComBSTR name;
- if (iChapter >= 0 && DWORD(iChapter) < nChapters && SUCCEEDED(m_pCB->ChapGet(iChapter, &rt, &name))) {
+ REFERENCE_TIME rtStart, rtStop;
+ m_wndSeekBar.GetRange(rtStart, rtStop);
+ if (iChapter >= 0 && DWORD(iChapter) < nChapters && SUCCEEDED(m_pCB->ChapGet(iChapter, &rt, &name)) && rt < rtStop) {
SeekTo(rt, false);
SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
ret = true;
@@ -8604,7 +8664,7 @@ void CMainFrame::OnNavigateMenuItem(UINT nID)
m_pDVDC->SelectRelativeButton(DVD_Relative_Lower);
break;
case 4:
- if (m_iDVDDomain != DVD_DOMAIN_Title) { // Casimir666 : for the remote control
+ if (m_iDVDDomain == DVD_DOMAIN_Title || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu || m_iDVDDomain == DVD_DOMAIN_VideoManagerMenu) {
m_pDVDC->ActivateButton();
} else {
OnPlayPlay();
@@ -8740,11 +8800,10 @@ void CMainFrame::AddFavorite(bool fDisplayMessage, bool fShowDialog)
BeginEnumFilters(m_pGB, pEF, pBF) {
CComQIPtr pFSF = pBF;
if (pFSF) {
- LPOLESTR pFN = nullptr;
+ CComHeapPtr pFN;
AM_MEDIA_TYPE mt;
if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
fn = CStringW(pFN);
- CoTaskMemFree(pFN);
}
break;
}
@@ -9095,7 +9154,7 @@ void CMainFrame::OnHelpToolbarImages()
void CMainFrame::OnHelpDonate()
{
- ShellExecute(m_hWnd, _T("open"), _T("http://mpc-hc.org/donate/"), nullptr, nullptr, SW_SHOWDEFAULT);
+ ShellExecute(m_hWnd, _T("open"), _T("https://mpc-hc.org/donate/"), nullptr, nullptr, SW_SHOWDEFAULT);
}
//////////////////////////////////
@@ -9119,7 +9178,7 @@ void CMainFrame::SetDefaultWindowRect(int iMonitor)
ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0, SWP_NOZORDER);
}
SetMenuBarVisibility(AFX_MBV_DISPLAYONFOCUS | AFX_MBV_DISPLAYONF10);
- SetWindowPos(nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
+ SetWindowPos(nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
CSize windowSize;
@@ -9156,23 +9215,17 @@ void CMainFrame::SetDefaultWindowRect(int iMonitor)
if (!bRestoredWindowPosition) {
CMonitors monitors;
CMonitor monitor;
- if (iMonitor > 0) {
+ if (iMonitor > 0 && iMonitor <= monitors.GetCount()) {
monitor = monitors.GetMonitor(--iMonitor);
} else {
monitor = CMonitors::GetNearestMonitor(this);
}
- SetWindowPos(nullptr, 0, 0, windowSize.cx, windowSize.cy, SWP_NOMOVE | SWP_NOZORDER);
- monitor.CenterWindowToMonitor(this, TRUE);
- }
-
- if (s.fRememberWindowSize && s.fRememberWindowPos) {
- UINT lastWindowType = s.nLastWindowType;
- if (lastWindowType == SIZE_MAXIMIZED) {
- ShowWindow(SW_MAXIMIZE);
- } else if (lastWindowType == SIZE_MINIMIZED) {
- ShowWindow(SW_MINIMIZE);
- }
+ MINMAXINFO mmi;
+ OnGetMinMaxInfo(&mmi);
+ CRect windowRect(0, 0, max(windowSize.cx, mmi.ptMinTrackSize.x), max(windowSize.cy, mmi.ptMinTrackSize.y));
+ monitor.CenterRectToMonitor(windowRect, TRUE);
+ SetWindowPos(nullptr, windowRect.left, windowRect.top, windowSize.cx, windowSize.cy, SWP_NOZORDER | SWP_NOACTIVATE);
}
if (s.fSavePnSZoom) {
@@ -10094,7 +10147,7 @@ double CMainFrame::GetZoomAutoFitScale(bool bLargerOnly)
LONG width = wa.right - wa.left;
LONG height = wa.bottom - wa.top;
- if (bLargerOnly && (arxy.cx + decorationsSize.cx < width && arxy.cy + decorationsSize.cy < height)) {
+ if (bLargerOnly && (arxy.cx + decorationsSize.cx <= width && arxy.cy + decorationsSize.cy <= height)) {
return 1.0;
}
@@ -10471,13 +10524,16 @@ void CMainFrame::OpenFile(OpenFileData* pOFD)
if (bMainFile) {
pOFD->title = fn;
- if (!(m_pFSF = m_pGB)) {
- BeginEnumFilters(m_pGB, pEF, pBF);
- if (m_pFSF = pBF) {
- break;
- }
- EndEnumFilters;
+
+ m_pFSF = m_pGB;
+ BeginEnumFilters(m_pGB, pEF, pBF);
+ if (!m_pFSF) {
+ m_pFSF = pBF;
}
+ if (!m_pKFI) {
+ m_pKFI = pBF;
+ }
+ EndEnumFilters;
}
bMainFile = false;
@@ -11156,6 +11212,8 @@ void CMainFrame::OpenSetupCaptureBar()
void CMainFrame::OpenSetupInfoBar(bool bClear /*= true*/)
{
+ bool bRecalcLayout = false;
+
if (bClear) {
m_wndInfoBar.RemoveAllLines();
}
@@ -11189,19 +11247,23 @@ void CMainFrame::OpenSetupInfoBar(bool bClear /*= true*/)
}
EndEnumFilters;
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_TITLE), title);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_TITLE), title);
UpdateChapterInInfoBar();
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_COPYRIGHT), copyright);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_RATING), rating);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DESCRIPTION), description);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_COPYRIGHT), copyright);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_RATING), rating);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DESCRIPTION), description);
} else if (GetPlaybackMode() == PM_DVD) {
CString info('-');
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), info);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), info);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), info);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), info);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), info);
+ bRecalcLayout |= m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), info);
+ }
+
+ if (bRecalcLayout) {
+ RecalcLayout();
}
}
@@ -11223,7 +11285,9 @@ void CMainFrame::UpdateChapterInInfoBar()
}
}
}
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_CHAPTER), chapter);
+ if (m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_CHAPTER), chapter)) {
+ RecalcLayout();
+ }
}
@@ -11728,6 +11792,7 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr pOMD)
m_pGB->FindInterface(IID_PPV_ARGS(&m_pVMRMC), TRUE);
m_pGB->FindInterface(IID_PPV_ARGS(&pVMB), TRUE);
m_pGB->FindInterface(IID_PPV_ARGS(&pMFVMB), TRUE);
+ m_pMVRSR = m_pCAP;
m_pMVRS = m_pCAP;
pMVTO = m_pCAP;
@@ -11784,9 +11849,14 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr pOMD)
// Set start time but seek only after all files are loaded
if (pFileData->rtStart > 0) { // Check if an explicit start time was given
rtPos = pFileData->rtStart;
- } else if (m_bRememberFilePos && !s.filePositions.AddEntry(fn)) {
- // else check if we have a remembered position to restore
- rtPos = s.filePositions.GetLatestEntry()->llPosition;
+ }
+ if (m_bRememberFilePos) { // Check if we want to remember the position
+ // Always update the file positions list so that the position
+ // is correctly saved but only restore the remembered position
+ // if no explicit start time was already set.
+ if (!s.filePositions.AddEntry(fn) && !rtPos) {
+ rtPos = s.filePositions.GetLatestEntry()->llPosition;
+ }
}
if (rtPos) {
@@ -11890,6 +11960,7 @@ void CMainFrame::CloseMediaPrivate()
// IMPORTANT: IVMRSurfaceAllocatorNotify/IVMRSurfaceAllocatorNotify9 has to be released before the VMR/VMR9, otherwise it will crash in Release()
m_OSD.Stop();
m_pMVRS.Release();
+ m_pMVRSR.Release();
m_pCAP2.Release();
m_pCAP.Release();
m_pVMRWC.Release();
@@ -11924,6 +11995,7 @@ void CMainFrame::CloseMediaPrivate()
m_pME.Release();
m_pMC.Release();
m_pFSF.Release();
+ m_pKFI.Release();
if (m_pGB) {
m_pGB->RemoveFromROT();
@@ -11938,30 +12010,6 @@ void CMainFrame::CloseMediaPrivate()
m_AudDispName.Empty();
}
-void CMainFrame::ParseDirs(CAtlList& sl)
-{
- POSITION pos = sl.GetHeadPosition();
-
- while (pos) {
- CString fn = sl.GetNext(pos);
- WIN32_FIND_DATA fd;
- ZeroMemory(&fd, sizeof(WIN32_FIND_DATA));
- HANDLE hFind = FindFirstFile(fn, &fd);
-
- if (hFind != INVALID_HANDLE_VALUE) {
- if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- if (fn[fn.GetLength() - 1] != '\\') {
- fn += '\\';
- }
-
- COpenDirHelper::RecurseAddDir(fn, &sl);
- }
-
- FindClose(hFind);
- }
- }
-}
-
bool CMainFrame::SearchInDir(bool bDirForward, bool bLoop /*= false*/)
{
ASSERT(GetPlaybackMode() == PM_FILE);
@@ -13572,36 +13620,34 @@ void CMainFrame::SetSubtitle(const SubtitleInput& subInput)
pRTS->SetOverride(s.fUseDefaultSubtitlesStyle, s.subtitlesDefStyle);
pRTS->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos);
pRTS->Deinit();
- } else if (clsid == __uuidof(CRLECodedSubtitle)) {
- CRLECodedSubtitle* pRHS = (CRLECodedSubtitle*)(ISubStream*)subInput.pSubStream;
-
- CComQIPtr pSRO = m_pCAP;
- CComQIPtr pMVRI = m_pCAP;
-
- LPWSTR yuvMatrix = nullptr;
- int nLen;
- if (pMVRI) {
- pMVRI->GetString("yuvMatrix", &yuvMatrix, &nLen);
- } else if (pSRO) {
- pSRO->GetString("yuvMatrix", &yuvMatrix, &nLen);
- }
+ }
- int targetBlackLevel = 0, targetWhiteLevel = 255;
- if (m_pMVRS) {
- m_pMVRS->SettingsGetInteger(L"Black", &targetBlackLevel);
- m_pMVRS->SettingsGetInteger(L"White", &targetWhiteLevel);
- } else if (pSRO) {
- int range = 0;
- pSRO->GetInt("supportedLevels", &range);
- if (range == 3) {
- targetBlackLevel = 16;
- targetWhiteLevel = 235;
- }
- }
+ CComQIPtr pSRO = m_pCAP;
+ CComQIPtr pMVRI = m_pCAP;
- pRHS->SetSourceTargetInfo(yuvMatrix, targetBlackLevel, targetWhiteLevel);
- LocalFree(yuvMatrix);
+ LPWSTR yuvMatrix = nullptr;
+ int nLen;
+ if (pMVRI) {
+ pMVRI->GetString("yuvMatrix", &yuvMatrix, &nLen);
+ } else if (pSRO) {
+ pSRO->GetString("yuvMatrix", &yuvMatrix, &nLen);
}
+
+ int targetBlackLevel = 0, targetWhiteLevel = 255;
+ if (m_pMVRS) {
+ m_pMVRS->SettingsGetInteger(L"Black", &targetBlackLevel);
+ m_pMVRS->SettingsGetInteger(L"White", &targetWhiteLevel);
+ } else if (pSRO) {
+ int range = 0;
+ pSRO->GetInt("supportedLevels", &range);
+ if (range == 3) {
+ targetBlackLevel = 16;
+ targetWhiteLevel = 235;
+ }
+ }
+
+ subInput.pSubStream->SetSourceTargetInfo(yuvMatrix, targetBlackLevel, targetWhiteLevel);
+ LocalFree(yuvMatrix);
}
m_pCurrentSubInput = subInput;
@@ -13743,18 +13789,12 @@ bool CMainFrame::GetNeighbouringKeyFrames(REFERENCE_TIME rtTarget, std::pair[ pKFI;
- BeginEnumFilters(m_pGB, pEF, pBF);
- if (pKFI = pBF) {
- break;
- }
- EndEnumFilters;
UINT nKFs = 0;
m_kfs.clear();
- if (pKFI && S_OK == pKFI->GetKeyFrameCount(nKFs) && nKFs > 1) {
+ if (m_pKFI && S_OK == m_pKFI->GetKeyFrameCount(nKFs) && nKFs > 1) {
UINT k = nKFs;
m_kfs.resize(k);
- if (FAILED(pKFI->GetKeyFrames(&TIME_FORMAT_MEDIA_TIME, m_kfs.data(), k)) || k != nKFs) {
+ if (FAILED(m_pKFI->GetKeyFrames(&TIME_FORMAT_MEDIA_TIME, m_kfs.data(), k)) || k != nKFs) {
m_kfs.clear();
}
}
@@ -13801,7 +13841,7 @@ void CMainFrame::SeekTo(REFERENCE_TIME rtPos, bool bShowOSD /*= true*/)
if (rtPos > stop) {
rtPos = stop;
}
- m_wndStatusBar.SetStatusTimer(rtPos, stop, !!m_wndSubresyncBar.IsWindowVisible(), GetTimeFormat());
+ m_wndStatusBar.SetStatusTimer(rtPos, stop, IsSubresyncBarVisible(), GetTimeFormat());
if (bShowOSD) {
m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 1500);
@@ -14136,6 +14176,7 @@ bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPrevi
CComPtr]