Required for dxva video playback by Chromium-based browsers and the Chromium Embedded Framework, including Adobe Photoshop's rich tooltip videos.
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- configure.ac | 1 + dlls/msmpeg2vdec/Makefile.in | 6 ++++++ dlls/msmpeg2vdec/main.c | 32 +++++++++++++++++++++++++++++++ dlls/msmpeg2vdec/msmpeg2vdec.spec | 8 ++++++++ 4 files changed, 47 insertions(+) create mode 100644 dlls/msmpeg2vdec/Makefile.in create mode 100644 dlls/msmpeg2vdec/main.c create mode 100644 dlls/msmpeg2vdec/msmpeg2vdec.spec
diff --git a/configure.ac b/configure.ac index 48445cc7b2f..d2e0127f262 100644 --- a/configure.ac +++ b/configure.ac @@ -2750,6 +2750,7 @@ WINE_CONFIG_MAKEFILE(dlls/msimtf) WINE_CONFIG_MAKEFILE(dlls/msisip) WINE_CONFIG_MAKEFILE(dlls/msisys.ocx) WINE_CONFIG_MAKEFILE(dlls/msls31) +WINE_CONFIG_MAKEFILE(dlls/msmpeg2vdec) WINE_CONFIG_MAKEFILE(dlls/msnet32) WINE_CONFIG_MAKEFILE(dlls/mspatcha) WINE_CONFIG_MAKEFILE(dlls/mspatcha/tests) diff --git a/dlls/msmpeg2vdec/Makefile.in b/dlls/msmpeg2vdec/Makefile.in new file mode 100644 index 00000000000..54ada2f20c4 --- /dev/null +++ b/dlls/msmpeg2vdec/Makefile.in @@ -0,0 +1,6 @@ +MODULE = msmpeg2vdec.dll + +EXTRADLLFLAGS = -Wb,--prefer-native + +C_SRCS = \ + main.c diff --git a/dlls/msmpeg2vdec/main.c b/dlls/msmpeg2vdec/main.c new file mode 100644 index 00000000000..61ada37b2f6 --- /dev/null +++ b/dlls/msmpeg2vdec/main.c @@ -0,0 +1,32 @@ +/* + * Copyright 2022 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msmpeg2vdec); + +HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, LPVOID *ppv) +{ + FIXME("(%s %s %p)\n", debugstr_guid(clsid), debugstr_guid(riid), ppv); + return CLASS_E_CLASSNOTAVAILABLE; +} diff --git a/dlls/msmpeg2vdec/msmpeg2vdec.spec b/dlls/msmpeg2vdec/msmpeg2vdec.spec new file mode 100644 index 00000000000..b81b77ce108 --- /dev/null +++ b/dlls/msmpeg2vdec/msmpeg2vdec.spec @@ -0,0 +1,8 @@ +@ stub GetH264DecoderFunctionTable +@ stub ?GetSurface@CVIDEOfilter@@QEAAJHPEAEJ@Z +@ stub ?GetSurfaceSize@CVIDEOfilter@@QEAAJHPEAJ@Z +@ stub ?LoadSurface@CVIDEOfilter@@QEAAJHPEAEK@Z +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetClassObject(ptr ptr ptr) +@ stdcall -private DllRegisterServer() +@ stdcall -private DllUnregisterServer()
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v2: - Remove winegstreamer addition. --- include/wmcodecdsp.idl | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/include/wmcodecdsp.idl b/include/wmcodecdsp.idl index dcf28ab682c..0846b08382c 100644 --- a/include/wmcodecdsp.idl +++ b/include/wmcodecdsp.idl @@ -44,6 +44,11 @@ coclass CResamplerMediaObject {} ] coclass CMSH264DecoderMFT {}
+[ + uuid(2d709e52-123f-49b5-9cbc-9af5cde28fb9) +] +coclass CMSMPEGDecoderMFT {} + [ uuid(2eeb4adf-4578-4d10-bca7-bb955f56320a) ]
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v2: - Fix MSMPEGDecoderMFTFactory_CreateInstance. --- dlls/msmpeg2vdec/Makefile.in | 3 + dlls/msmpeg2vdec/main.c | 80 +++++++++++++++++++++++- dlls/msmpeg2vdec/msmpeg2vdec_classes.idl | 21 +++++++ 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 dlls/msmpeg2vdec/msmpeg2vdec_classes.idl
diff --git a/dlls/msmpeg2vdec/Makefile.in b/dlls/msmpeg2vdec/Makefile.in index 54ada2f20c4..44377594b91 100644 --- a/dlls/msmpeg2vdec/Makefile.in +++ b/dlls/msmpeg2vdec/Makefile.in @@ -1,6 +1,9 @@ MODULE = msmpeg2vdec.dll +IMPORTS = mfuuid uuid
EXTRADLLFLAGS = -Wb,--prefer-native
C_SRCS = \ main.c + +IDL_SRCS = msmpeg2vdec_classes.idl diff --git a/dlls/msmpeg2vdec/main.c b/dlls/msmpeg2vdec/main.c index 61ada37b2f6..5ae00b36a5f 100644 --- a/dlls/msmpeg2vdec/main.c +++ b/dlls/msmpeg2vdec/main.c @@ -18,15 +18,93 @@
#include <stdarg.h>
+#define COBJMACROS + #include "windef.h" #include "winbase.h" +#include "mfidl.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msmpeg2vdec);
+typedef struct { + IClassFactory IClassFactory_iface; + LONG ref; + HRESULT (*create_instance)(REFIID riid, void **obj); +} msmpeg2vdec_class_factory; + +static inline msmpeg2vdec_class_factory *impl_from_IClassFactory(IClassFactory *iface) +{ + return CONTAINING_RECORD(iface, msmpeg2vdec_class_factory, IClassFactory_iface); +} + +static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **obj) +{ + TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), obj); + + if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) + { + *obj = iface; + IClassFactory_AddRef(iface); + return S_OK; + } + + WARN("no interface for %s\n", debugstr_guid(riid)); + *obj = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface) +{ + return 2; +} + +static ULONG WINAPI ClassFactory_Release(IClassFactory *iface) +{ + return 1; +} + +static HRESULT WINAPI MSMPEGDecoderMFTFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **obj) +{ + msmpeg2vdec_class_factory *factory = impl_from_IClassFactory(iface); + + TRACE("(iface %p, outer %p, riid %s, obj %p)\n", iface, outer, debugstr_guid(riid), obj); + + if (outer) + { + *obj = NULL; + return CLASS_E_NOAGGREGATION; + } + + return factory->create_instance(riid, obj); +} + +static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL lock) +{ + FIXME("(%d) stub\n", lock); + return S_OK; +} + +static const IClassFactoryVtbl MSMPEGDecoderMFTFactoryVtbl = +{ + ClassFactory_QueryInterface, + ClassFactory_AddRef, + ClassFactory_Release, + MSMPEGDecoderMFTFactory_CreateInstance, + ClassFactory_LockServer, +}; + +static IClassFactory MSMPEGDecoderMFTFactory = { &MSMPEGDecoderMFTFactoryVtbl }; + HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, LPVOID *ppv) { - FIXME("(%s %s %p)\n", debugstr_guid(clsid), debugstr_guid(riid), ppv); + TRACE("(%s, %s, %p)\n", debugstr_guid(clsid), debugstr_guid(riid), ppv); + + if (IsEqualGUID(clsid, &CLSID_MSMPEGDecoderMFT)) + return ClassFactory_QueryInterface(&MSMPEGDecoderMFTFactory, riid, ppv); + + WARN("Unsupported class %s.\n", debugstr_guid(clsid)); + *ppv = NULL; return CLASS_E_CLASSNOTAVAILABLE; } diff --git a/dlls/msmpeg2vdec/msmpeg2vdec_classes.idl b/dlls/msmpeg2vdec/msmpeg2vdec_classes.idl new file mode 100644 index 00000000000..2df633a06dd --- /dev/null +++ b/dlls/msmpeg2vdec/msmpeg2vdec_classes.idl @@ -0,0 +1,21 @@ +/* + * COM Classes for msmpeg2vdec + * + * Copyright 2022 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#pragma makedep register
On 4/21/22 10:55, Mohamad Al-Jaf wrote:
Required for dxva video playback by Chromium-based browsers and the Chromium Embedded Framework, including Adobe Photoshop's rich tooltip videos.
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com
configure.ac | 1 + dlls/msmpeg2vdec/Makefile.in | 6 ++++++ dlls/msmpeg2vdec/main.c | 32 +++++++++++++++++++++++++++++++ dlls/msmpeg2vdec/msmpeg2vdec.spec | 8 ++++++++ 4 files changed, 47 insertions(+) create mode 100644 dlls/msmpeg2vdec/Makefile.in create mode 100644 dlls/msmpeg2vdec/main.c create mode 100644 dlls/msmpeg2vdec/msmpeg2vdec.spec
Like I said for v1, if this only helps with some error message I don't think it's worth having, without a plan on how to implement it.
On Thu, Apr 21, 2022 at 1:10 PM Nikolay Sivov nsivov@codeweavers.com wrote:
Like I said for v1, if this only helps with some error message I don't think it's worth having, without a plan on how to implement it.
As of now, this along with msvproc is all that's needed. In MS Edge at least, it spawns a GPU process with video playback so it looks like it's using hardware acceleration somehow. It doesn't call any functions in msmpeg2vdec so I don't know what you mean by implementing it. Well, the way Media Foundation is implemented in Wine seems different from Windows so it might not even need to be implemented in a traditional sense.
Do you see a way to implement it?
Also, it was my understanding that errors are considered serious and should be fixed. -- Kind regards, Mohamad
On Apr 21, 2022, at 3:30 PM, Mohamad Al-Jaf mohamadaljaf@gmail.com wrote:
On Thu, Apr 21, 2022 at 1:10 PM Nikolay Sivov nsivov@codeweavers.com wrote:
Like I said for v1, if this only helps with some error message I don't think it's worth having, without a plan on how to implement it.
As of now, this along with msvproc is all that's needed. In MS Edge at least, it spawns a GPU process with video playback so it looks like it's using hardware acceleration somehow. It doesn't call any functions in msmpeg2vdec so I don't know what you mean by implementing it. Well, the way Media Foundation is implemented in Wine seems different from Windows so it might not even need to be implemented in a traditional sense.
Interesting, at least in the latest Chromium it looks like this is loaded explicitly before the sandbox is initialized (I assume because video decoding will need it but the sandbox would prevent it from being loaded), this failure only results in an error message. (https://source.chromium.org/chromium/chromium/src/+/main:media/gpu/windows/d...)
However, at some point it also checks whether the DLL is loaded (with GetModuleHandle), if this fails it assumes that it’s on Windows N (which lacks media foundation) and doesn’t try to use video decode acceleration. (https://source.chromium.org/chromium/chromium/src/+/main:media/gpu/windows/d...)
So a stub DLL really does enable acceleration.
Brendan
On 4/22/22 02:32, Brendan Shanks wrote:
On Apr 21, 2022, at 3:30 PM, Mohamad Al-Jaf mohamadaljaf@gmail.com wrote:
On Thu, Apr 21, 2022 at 1:10 PM Nikolay Sivov nsivov@codeweavers.com wrote:
Like I said for v1, if this only helps with some error message I don't think it's worth having, without a plan on how to implement it.
As of now, this along with msvproc is all that's needed. In MS Edge at least, it spawns a GPU process with video playback so it looks like it's using hardware acceleration somehow. It doesn't call any functions in msmpeg2vdec so I don't know what you mean by implementing it. Well, the way Media Foundation is implemented in Wine seems different from Windows so it might not even need to be implemented in a traditional sense.
Interesting, at least in the latest Chromium it looks like this is loaded explicitly before the sandbox is initialized (I assume because video decoding will need it but the sandbox would prevent it from being loaded), this failure only results in an error message. (https://source.chromium.org/chromium/chromium/src/+/main:media/gpu/windows/d...)
However, at some point it also checks whether the DLL is loaded (with GetModuleHandle), if this fails it assumes that it’s on Windows N (which lacks media foundation) and doesn’t try to use video decode acceleration. (https://source.chromium.org/chromium/chromium/src/+/main:media/gpu/windows/d...)
So a stub DLL really does enable acceleration.
Looks like it will fail anyway later, on ID3D11VideoDevice, or decoder creation.
Brendan
On Fri, Apr 22, 2022 at 12:57 AM Nikolay Sivov nsivov@codeweavers.com wrote:
On 4/22/22 02:32, Brendan Shanks wrote:
So a stub DLL really does enable acceleration.
Looks like it will fail anyway later, on ID3D11VideoDevice, or decoder creation.
If it enables acceleration, why does that matter? How is it using acceleration if what you're saying is true. It looks like the stub is enabling it to use acceleration even as a fallback through an alternative means when, as you say, ID3D11VideoDevice fails.
-- Kind regards, Mohamad
On Fri, Apr 22, 2022 at 12:57 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Looks like it will fail anyway later, on ID3D11VideoDevice, or decoder creation.
Do you see a way to prevent this? This isn't something I'm familiar with so I can't work on this part unless you think it's trivial to fix. The stub is enough to get it to this point and that's all I'm capable of at the moment. Still, it spawns a GPU process when I run it and play videos so I don't know how it's using hardware acceleration if it seemingly fails.
-- Kind regards, Mohamad
On Sat, Apr 23, 2022 at 5:05 AM Mohamad Al-Jaf mohamadaljaf@gmail.com wrote:
On Fri, Apr 22, 2022 at 12:57 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Looks like it will fail anyway later, on ID3D11VideoDevice, or decoder creation.
Do you see a way to prevent this? This isn't something I'm familiar with so I can't work on this part unless you think it's trivial to fix. The stub is enough to get it to this point and that's all I'm capable of at the moment. Still, it spawns a GPU process when I run it and play videos so I don't know how it's using hardware acceleration if it seemingly fails.
I'd appreciate a response, Nikolay. If you were looking into this then it's fine to not respond until you're done, but you have a tendency to abandon conversations.
Also, just because you think it fails later doesn't mean this dll shouldn't be added. It's at least a start. Something is better than nothing. I've brought this issue to light and this should matter. If you'd like to teach me how to further develop it, I'd be interested in learning. Otherwise, adding the dll is all I can do at the moment.
After searching some more, I found a CrossOver user that wants the dlls msmpeg2vdec and msvproc for their software.[1]
And another CrossOver user that says videos are not working in the games Trails in the Sky and Monster Train. Both of these games try to load msmpeg2vdec.[2]
In Proton:
- Far Cry 4 loads this dll[3] - Assassins Creed Origins loads this dll[4]
In these games, it looks like it's the UPlay launcher that's loading the dll so it's like CEF. In this case, since game launchers tend to play videos, it's needed to prevent high CPU usage which can heat up some people's machines and/or drain battery life, like laptops and the Steam Deck.
Some of these may or may not require msmpeg2vdec with Wine, but they likely use it. Perhaps the native Media Foundation is codependent on the dll, but further testing is required.
- Shadows Awakening black screen is solved with msmpeg2vdec[5] - The Dark Pictures Anthology: Man of Medan videos only work with msmpeg2vdec[6] - Blair Witch cutscenes only work with msmpeg2vdec[7] - Fairy Fencer F Advent Dark Force cutscenes only work with msmpeg2vdec[8] - ARAYA is completely broken unless native MF is used, including msmpeg2vdec[9] - Danganronpa V3: Killing Harmony works with msmpeg2vdec[10] - Blair Witch does not start unless msmpeg2vdec is used[11]
[1] https://www.codeweavers.com/support/forums/general?t=27;forumcurPos=0;msg=25... [2] https://www.codeweavers.com/support/forums/general/?t=27;mhl=252167;msg=2521... [3] https://github.com/ValveSoftware/Proton/issues/2143 [4] https://github.com/ValveSoftware/Proton/issues/928#issuecomment-1081056774 [5] https://github.com/ValveSoftware/Proton/issues/1102#issuecomment-419678627 [6] https://www.protondb.com/app/939850#ntDBsW3V8 [7] https://www.protondb.com/app/1092660#fZwEEAGvDb [8] https://www.protondb.com/app/524580#xUZjNgNSWS [9] https://www.protondb.com/app/466740#1FNdGj0V7G [10] https://github.com/ValveSoftware/Proton/issues/838#issuecomment-447379664 [11] https://github.com/ValveSoftware/Proton/issues/3174 -- Kind regards, Mohamad
On 4/25/22 09:23, Mohamad Al-Jaf wrote:
On Sat, Apr 23, 2022 at 5:05 AM Mohamad Al-Jaf mohamadaljaf@gmail.com wrote:
On Fri, Apr 22, 2022 at 12:57 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Looks like it will fail anyway later, on ID3D11VideoDevice, or decoder creation.
Do you see a way to prevent this? This isn't something I'm familiar with so I can't work on this part unless you think it's trivial to fix. The stub is enough to get it to this point and that's all I'm capable of at the moment. Still, it spawns a GPU process when I run it and play videos so I don't know how it's using hardware acceleration if it seemingly fails.
I'd appreciate a response, Nikolay. If you were looking into this then it's fine to not respond until you're done, but you have a tendency to abandon conversations.
I don't see what's left there to discuss. I explained how it works already, and how it does in wine.
If you want to study how d3d video decoding/mixing is exposed on Windows, and how we could map that to Linux equivalent API (or even better to Vulkan directly), I can only encourage that.
Also, just because you think it fails later doesn't mean this dll shouldn't be added. It's at least a start.
It doesn't matter what I think. The fact is, this stub does not improve CEF behavior, and doesn't make it any easier to implement missing functionality later.
Something is better than nothing.
This is not always the case, no.
I've brought this issue to light and this should matter. If you'd like to teach me how to further develop it, I'd be interested in learning. Otherwise, adding the dll is all I can do at the moment.
I definitely won't have time for that.
After searching some more, I found a CrossOver user that wants the dlls msmpeg2vdec and msvproc for their software.[1]
What does this have to do with anything?
And another CrossOver user that says videos are not working in the games Trails in the Sky and Monster Train. Both of these games try to load msmpeg2vdec.[2]
In Proton:
- Far Cry 4 loads this dll[3]
- Assassins Creed Origins loads this dll[4]
In these games, it looks like it's the UPlay launcher that's loading the dll so it's like CEF. In this case, since game launchers tend to play videos, it's needed to prevent high CPU usage which can heat up some people's machines and/or drain battery life, like laptops and the Steam Deck.
And this stub dll helps with any of that? Like you already found out, CEF is fine with is it missing.
Some of these may or may not require msmpeg2vdec with Wine, but they likely use it. Perhaps the native Media Foundation is codependent on the dll, but further testing is required.
- Shadows Awakening black screen is solved with msmpeg2vdec[5]
- The Dark Pictures Anthology: Man of Medan videos only work with msmpeg2vdec[6]
- Blair Witch cutscenes only work with msmpeg2vdec[7]
- Fairy Fencer F Advent Dark Force cutscenes only work with msmpeg2vdec[8]
- ARAYA is completely broken unless native MF is used, including msmpeg2vdec[9]
- Danganronpa V3: Killing Harmony works with msmpeg2vdec[10]
- Blair Witch does not start unless msmpeg2vdec is used[11]
I checked a few, they were about installing native components, that I are not redistributable as far as I know.
[1] https://www.codeweavers.com/support/forums/general?t=27;forumcurPos=0;msg=25... [2] https://www.codeweavers.com/support/forums/general/?t=27;mhl=252167;msg=2521... [3] https://github.com/ValveSoftware/Proton/issues/2143 [4] https://github.com/ValveSoftware/Proton/issues/928#issuecomment-1081056774 [5] https://github.com/ValveSoftware/Proton/issues/1102#issuecomment-419678627 [6] https://www.protondb.com/app/939850#ntDBsW3V8 [7] https://www.protondb.com/app/1092660#fZwEEAGvDb [8] https://www.protondb.com/app/524580#xUZjNgNSWS [9] https://www.protondb.com/app/466740#1FNdGj0V7G [10] https://github.com/ValveSoftware/Proton/issues/838#issuecomment-447379664 [11] https://github.com/ValveSoftware/Proton/issues/3174 -- Kind regards, Mohamad