Skip to content

Commit 4919b2a

Browse files
committed
merge upstream
2 parents e1ac828 + c0ea325 commit 4919b2a

File tree

154 files changed

+708
-679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+708
-679
lines changed

distrib/mpc-hc_setup.iss

+1-5
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
#define INCLUDE_MPCVR = true
122122
#else
123123
#define INCLUDE_MPCVR = false
124-
#bla
125124
#endif
126125

127126
#ifexist mediainfo_dll
@@ -233,9 +232,6 @@ Name: custom; Description: {cm:types_CustomInstallation};
233232

234233
[Components]
235234
Name: main; Description: {#app_vername}; Types: default custom; Flags: fixed
236-
#if INCLUDE_MPCVR
237-
Name: mpcvr; Description: MPC Video Renderer; Types: default custom
238-
#endif
239235
Name: mpciconlib; Description: {cm:comp_mpciconlib}; Types: default custom
240236
#if localize == "true"
241237
Name: mpcresources; Description: {cm:comp_mpcresources}; Types: default custom; Flags: disablenouninstallwarning
@@ -278,7 +274,7 @@ Source: {#platform}\sendrpt.exe; DestDir: {app}\CrashReporter;
278274
Source: CrashReporter_LICENSE.txt; DestDir: {app}\CrashReporter; Components: main; Flags: ignoreversion
279275
#endif
280276
#if INCLUDE_MPCVR
281-
Source: ..\distrib\mpcvr\{#mpcvr_ax}; DestDir: {app}\MPCVR; Components: mpcvr; Flags: ignoreversion
277+
Source: ..\distrib\mpcvr\{#mpcvr_ax}; DestDir: {app}\MPCVR; Components: main; Flags: ignoreversion
282278
#endif
283279

284280

docs/Compilation.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ releases.
5757

5858
## Part D: Yasm
5959

60-
1. Download YASM from <http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe>
61-
2. Rename it to **yasm.exe** and put it in a folder that is included in %PATH%. For example **`C:\Windows`** or **`C:\MSYS64\usr\bin`** (see part C).
60+
1. Download Microsoft Visual C++ 2010 Redistributable Package from <https://www.microsoft.com/en-us/download/details.aspx?id=26999> and install it.
61+
2. Download YASM from <http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe>
62+
3. Rename it to **yasm.exe** and put it in a folder that is included in %PATH%. For example **`C:\Windows`** or **`C:\MSYS64\usr\bin`** (see part C).
6263

6364
## PART E: NASM
6465

include/version.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef ISPP_INVOKED
22
/*
3-
* (C) 2010-2024 see Authors.txt
3+
* (C) 2010-2025 see Authors.txt
44
*
55
* This file is part of MPC-HC.
66
*
@@ -47,8 +47,8 @@
4747
#endif
4848

4949
#define MPC_VERSION_MAJOR 2
50-
#define MPC_VERSION_MINOR 3
51-
#define MPC_VERSION_PATCH 7
50+
#define MPC_VERSION_MINOR 4
51+
#define MPC_VERSION_PATCH 0
5252

5353
#if MPC_VERSION_REV > 0
5454
#define MPC_NIGHTLY_RELEASE 1
@@ -57,7 +57,7 @@
5757
#endif
5858

5959
#define MPC_COMP_NAME_STR _T("MPC-HC Team")
60-
#define MPC_COPYRIGHT_STR _T("Copyright 2002-2024 clsid2 and others")
60+
#define MPC_COPYRIGHT_STR _T("Copyright 2002-2025 clsid2 and others")
6161
#define MPC_VERSION_COMMENTS WEBSITE_URL
6262

6363

src/DSUtil/DSUtil.cpp

+17-7
Original file line numberDiff line numberDiff line change
@@ -1364,14 +1364,24 @@ bool UnloadUnusedExternalObjects()
13641364

13651365
void ExtendMaxPathLengthIfNeeded(CString& path, bool no_url /*= false */)
13661366
{
1367+
if (!no_url && path.Find(_T("://")) >= 0) { // URL
1368+
return;
1369+
}
1370+
1371+
// Get long path if shortened
1372+
if (path.Find(L'~') > 0) {
1373+
wchar_t destbuf[4096];
1374+
DWORD len = GetLongPathName(path, destbuf, 4096);
1375+
if (len > 0 && len < 4096) {
1376+
path = destbuf;
1377+
}
1378+
}
13671379
if (path.GetLength() >= MAX_PATH) {
1368-
if (no_url || path.Find(_T("://")) < 0) { // not URL
1369-
if (path.Left(4) != _T("\\\\?\\")) { // not already have long path prefix
1370-
if (path.Left(2) == _T("\\\\")) { // UNC
1371-
path = _T("\\\\?\\UNC") + path.Mid(1);
1372-
} else { // normal
1373-
path = _T("\\\\?\\") + path;
1374-
}
1380+
if (path.Left(4) != _T("\\\\?\\")) { // not already have long path prefix
1381+
if (path.Left(2) == _T("\\\\")) { // UNC
1382+
path = _T("\\\\?\\UNC") + path.Mid(1);
1383+
} else { // normal
1384+
path = _T("\\\\?\\") + path;
13751385
}
13761386
}
13771387
}

src/DSUtil/ISOLang.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ namespace
8787
{ "Bini", "bin", "" },
8888
{ "Bislama", "bis", "bi" },
8989
{ "Blin", "byn", "" },
90-
{ "Bokmål", "nob", "nb", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT) },
91-
{ "Bokmal", "nob", "nb", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT) },
90+
{ "Bokmål", "nob", "nb", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL), SORT_DEFAULT) },
91+
{ "Bokmal", "nob", "nb", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL), SORT_DEFAULT) },
9292
{ "Bosnian", "bos", "bs" },
9393
{ "Braj", "bra", "" },
9494
{ "Breton", "bre", "br", MAKELCID(MAKELANGID(LANG_BRETON, SUBLANG_DEFAULT), SORT_DEFAULT) },
@@ -171,6 +171,7 @@ namespace
171171
{ "Fanti", "fat", "" },
172172
{ "Faroese", "fao", "fo", MAKELCID(MAKELANGID(LANG_FAEROESE, SUBLANG_DEFAULT), SORT_DEFAULT) },
173173
{ "Fijian", "fij", "fj" },
174+
{ "Filipino", "fil", "", MAKELCID(MAKELANGID(LANG_FILIPINO, SUBLANG_DEFAULT), SORT_DEFAULT) },
174175
{ "Finnish", "fin", "fi", MAKELCID(MAKELANGID(LANG_FINNISH, SUBLANG_DEFAULT), SORT_DEFAULT) },
175176
{ "Finno-Ugrian", "fiu", "" },
176177
{ "Flemish", "dut", "nl", MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT) },
@@ -370,16 +371,16 @@ namespace
370371
{ "North American Indian", "nai", "" },
371372
{ "North Ndebele", "nde", "nd" },
372373
{ "Northern Sami", "sme", "se" },
373-
{ "Norwegian", "nob", "nb", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT) },
374-
{ "Norwegian", "nno", "nn", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT) },
375374
{ "Norwegian", "nor", "no", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT) },
375+
{ "Norwegian", "nob", "nb", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL), SORT_DEFAULT) },
376+
{ "Norwegian", "nno", "nn", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK), SORT_DEFAULT) },
376377
{ "Nubian languages", "nub", "" },
377378
{ "Nyamwezi", "nym", "" },
378379
{ "Nyanja", "nya", "ny" },
379380
{ "Chichewa", "nya", "ny" },
380381
{ "Chewa", "nya", "ny" },
381382
{ "Nyankole", "nyn", "" },
382-
{ "Nynorsk", "nno", "nn", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT) },
383+
{ "Nynorsk", "nno", "nn", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK), SORT_DEFAULT) },
383384
{ "Nyoro", "nyo", "" },
384385
{ "Nzima", "nzi", "" },
385386
{ "Occitan", "oci", "oc", MAKELCID(MAKELANGID(LANG_OCCITAN, SUBLANG_DEFAULT), SORT_DEFAULT) },

src/DSUtil/SimpleBuffer.h

+22-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) 2017-2023 see Authors.txt
2+
* (C) 2017-2025 see Authors.txt
33
*
44
* This file is part of MPC-HC.
55
*
@@ -20,29 +20,41 @@
2020

2121
#pragma once
2222

23+
#include <cstdlib>
24+
25+
#define SIMPLE_BLOCK_ALIGNMENT 16
26+
2327
// CSimpleBlock - simple container
2428
template <typename T>
2529
class CSimpleBlock
2630
{
2731
protected:
32+
#if (__STDCPP_DEFAULT_NEW_ALIGNMENT__ >= SIMPLE_BLOCK_ALIGNMENT)
2833
std::unique_ptr<T[]> m_data;
34+
#else
35+
std::unique_ptr<T[], std::integral_constant<decltype(&_aligned_free), &_aligned_free>> m_data;
36+
#endif
2937
size_t m_size = 0;
3038

3139
public:
3240
// Returns pointer to the data.
3341
auto* Data() { return m_data.get(); }
3442

3543
// Returns the number of elements.
36-
auto Size() { return m_size; }
44+
auto Size() const { return m_size; }
3745

3846
// Returns allocated size in bytes.
39-
size_t Bytes() { return m_size * sizeof(T); }
47+
size_t Bytes() const { return m_size * sizeof(T); }
4048

4149
// Set new size. Old data will be lost.
4250
void SetSize(const size_t size)
4351
{
4452
if (size != m_size) {
53+
#if (__STDCPP_DEFAULT_NEW_ALIGNMENT__ >= SIMPLE_BLOCK_ALIGNMENT)
4554
m_data.reset(size ? new T[size] : nullptr);
55+
#else
56+
m_data.reset(size ? static_cast<T*>(_aligned_malloc(sizeof(T) * size, SIMPLE_BLOCK_ALIGNMENT)) : nullptr);
57+
#endif
4658
m_size = size;
4759
}
4860
}
@@ -56,12 +68,16 @@ class CSimpleBlock
5668
template <typename T>
5769
class CSimpleBuffer : public CSimpleBlock<T>
5870
{
71+
size_t CalcRoundedSize(size_t size) {
72+
return ((size * sizeof(T) + 255) & ~(size_t)255) / sizeof(T); // rounded up a multiple of 256 bytes.
73+
}
74+
5975
public:
6076
// Increase the size if necessary. Old data may be lost. The size will be rounded up to a multiple of 256 bytes.
6177
void ExtendSize(const size_t size)
6278
{
6379
if (size > this->m_size) {
64-
size_t newsize = ((size * sizeof(T) + 255) & ~(size_t)255) / sizeof(T); // rounded up a multiple of 256 bytes.
80+
size_t newsize = CalcRoundedSize(size);
6581
this->SetSize(newsize);
6682
}
6783
}
@@ -71,10 +87,10 @@ class CSimpleBuffer : public CSimpleBlock<T>
7187
{
7288
if (size > this->m_size) {
7389
size_t old_bytes = this->Bytes();
74-
std::unique_ptr<T[]> old_data = std::move(this->m_data);
90+
auto old_data = std::move(this->m_data);
7591
this->m_size = 0;
7692

77-
size_t newsize = ((size * sizeof(T) + 255) & ~(size_t)255) / sizeof(T); // rounded up a multiple of 256 bytes.
93+
size_t newsize = CalcRoundedSize(size);
7894
this->SetSize(newsize);
7995

8096
memcpy(this->m_data.get(), old_data.get(), old_bytes);

src/Subtitles/LibassContext.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ void ParseSrtLine(std::string& srtLine, const STSStyle& style) {
120120
} else if (attribute_name == "family") {
121121
}
122122
if (attribute_name == "size") {
123-
int font_size = (int)std::round(std::stod(attribute_value));
124-
subtitle_output.append("{\\fs" + std::to_string(font_size) + "}");
123+
try {
124+
int font_size = (int)std::round(std::stod(attribute_value));
125+
subtitle_output.append("{\\fs" + std::to_string(font_size) + "}");
126+
} catch (...) {}
125127
} else if (attribute_name == "color") {
126128
MatchColorSrt(attribute_value);
127129

@@ -838,6 +840,7 @@ void LibassContext::LoadASSFont() {
838840
if (SUCCEEDED(bag->ResGet(i, &name.GetBSTR(), &desc.GetBSTR(), &mime.GetBSTR(), &pData, &len, nullptr))) {
839841
if (wcscmp(mime.GetBSTR(), L"application/x-truetype-font") == 0 // see https://gitlab.com/mbunkus/mkvtoolnix/-/issues/3137
840842
|| wcscmp(mime.GetBSTR(), L"application/vnd.ms-opentype") == 0
843+
|| wcscmp(mime.GetBSTR(), L"application/x-font-otf") == 0
841844
|| wcscmp(mime.GetBSTR(), L"application/x-font-ttf") == 0
842845
|| wcscmp(mime.GetBSTR(), L"application/font-sfnt") == 0
843846
|| wcscmp(mime.GetBSTR(), L"font/otf") == 0

src/Subtitles/PGSSub.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,15 @@ bool CPGSSub::ParseCompositionObject(CGolombBuffer* pGBuffer, const std::unique_
456456
pCompositionObject->m_horizontal_position = pGBuffer->ReadShort();
457457
pCompositionObject->m_vertical_position = pGBuffer->ReadShort();
458458

459+
if (pCompositionObject->m_horizontal_position < 0) {
460+
TRACE(_T("PGS - negative horizontal position.\n"));
461+
pCompositionObject->m_horizontal_position = 0;
462+
}
463+
if (pCompositionObject->m_vertical_position < 0) {
464+
TRACE(_T("PGS - negative vertical position.\n"));
465+
pCompositionObject->m_vertical_position = 0;
466+
}
467+
459468
if (pCompositionObject->m_object_cropped_flag) {
460469
if (pGBuffer->RemainingSize() < 8) {
461470
ASSERT(FALSE);

src/Subtitles/Rasterizer.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,10 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x
18851885

18861886
void Rasterizer::FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nHeight, DWORD lColor) const
18871887
{
1888+
if (x < 0 || y < 0) {
1889+
ASSERT(FALSE);
1890+
return;
1891+
}
18881892
ASSERT(spd.w >= x + nWidth && spd.h >= y + nHeight);
18891893
BYTE* dst = (BYTE*)((DWORD*)(spd.bits + spd.pitch * y) + x);
18901894
DrawInternal(m_bUseAVX2, dst, spd.pitch, BYTE(0x40), nWidth, nHeight, lColor);

src/Subtitles/STS.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,9 @@ bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
20402040
fRet = true;
20412041
below_script_info = false;
20422042
} else if (entry == L"language") {
2043-
ret.openTypeLangHint = WToA(GetStrW(pszBuff, nBuffLength));
2043+
if (nBuffLength) {
2044+
ret.openTypeLangHint = WToA(GetStrW(pszBuff, nBuffLength));
2045+
}
20442046
} else if (entry == L"fontname") {
20452047
LoadUUEFont(file);
20462048
} else if (entry == L"ycbcr matrix") {

src/Subtitles/SubtitleHelpers.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ void Subtitle::GetSubFileNames(CString fn, const CAtlArray<CString>& paths, CAtl
139139
}
140140

141141
if (!bMatchAnotherVid) {
142+
ExtendMaxPathLengthIfNeeded(fn2, MAX_PATH);
142143
SubFile f;
143144
f.fn = fn2;
144145
ret.Add(f);
@@ -157,6 +158,7 @@ void Subtitle::GetSubFileNames(CString fn, const CAtlArray<CString>& paths, CAtl
157158
CString fn2 = path + wfd.cFileName;
158159
CString ext = CPath(fn2).GetExtension();
159160
if (ext == L".srt" || ext == L".ass" || ext == L".ssa" || ext == L".webvtt" || ext == L".vtt") {
161+
ExtendMaxPathLengthIfNeeded(fn2, MAX_PATH);
160162
SubFile f;
161163
f.fn = fn2;
162164
ret.Add(f);

src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp

+15-46
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
170170
(FARPROC&)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
171171
}
172172

173-
Direct3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
174-
if (m_pD3DEx) {
175-
m_pD3D = m_pD3DEx;
176-
}
177-
178173
const CRenderersSettings& r = GetRenderersSettings();
179174

180175
if (r.m_AdvRendSets.bVMRDisableDesktopComposition) {
@@ -186,7 +181,14 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
186181
m_bDesktopCompositionDisabled = false;
187182
}
188183

189-
hr = CreateDevice(_Error);
184+
Direct3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
185+
if (m_pD3DEx) {
186+
m_pD3D = m_pD3DEx;
187+
hr = CreateDevice(_Error);
188+
} else {
189+
_Error += L"Failed to create D3D9\n";
190+
hr = E_UNEXPECTED;
191+
}
190192
}
191193
#pragma warning(pop)
192194

@@ -537,6 +539,11 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString& _Error)
537539

538540
CleanupRenderingEngine();
539541

542+
if (!m_pD3D) {
543+
_Error += L"Failed to create D3D9\n";
544+
return E_UNEXPECTED;
545+
}
546+
540547
UINT currentAdapter = GetAdapter(m_pD3D);
541548
bool bTryToReset = (currentAdapter == m_CurrentAdapter);
542549

@@ -546,48 +553,8 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString& _Error)
546553
m_CurrentAdapter = currentAdapter;
547554
}
548555

549-
if (!m_pD3D) {
550-
_Error += L"Failed to create D3D9\n";
551-
return E_UNEXPECTED;
552-
}
553-
554556
HRESULT hr = S_OK;
555557

556-
/*// TODO : add NVIDIA PerfHUD !!!
557-
558-
// Set default settings
559-
UINT AdapterToUse=D3DADAPTER_DEFAULT;
560-
D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL;
561-
562-
#if SHIPPING_VERSION
563-
// When building a shipping version, disable PerfHUD (opt-out)
564-
#else
565-
// Look for 'NVIDIA PerfHUD' adapter
566-
// If it is present, override default settings
567-
for (UINT Adapter=0;Adapter<g_pD3D->GetAdapterCount();Adapter++)
568-
{
569-
D3DADAPTER_IDENTIFIER9 Identifier;
570-
HRESULT Res;
571-
572-
Res = g_pD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
573-
if (strstr(Identifier.Description,"PerfHUD") != 0)
574-
{
575-
AdapterToUse=Adapter;
576-
DeviceType=D3DDEVTYPE_REF;
577-
break;
578-
}
579-
}
580-
#endif
581-
582-
if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd,
583-
D3DCREATE_HARDWARE_VERTEXPROCESSING,
584-
&d3dpp, &g_pd3dDevice) ) )
585-
{
586-
return E_FAIL;
587-
}
588-
*/
589-
590-
591558
//#define ENABLE_DDRAWSYNC
592559
#ifdef ENABLE_DDRAWSYNC
593560
hr = DirectDrawCreate(nullptr, &m_pDirectDraw, nullptr);
@@ -1705,6 +1672,8 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::ResetDevice()
17051672
DeleteSurfaces();
17061673

17071674
if (m_pD3DEx) {
1675+
m_pD3DDevEx.Release();
1676+
m_pD3DDev.Release();
17081677
m_pD3DEx.Release();
17091678
m_pD3D = nullptr;
17101679
Direct3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);

0 commit comments

Comments
 (0)