Discussion:
[libav-devel] [PATCH] force WINAPI_FAMILY to WINAPI_FAMILY_DESKTOP_APP to use DVXA
Steve Lhomme
2015-07-23 17:09:50 UTC
Permalink
otherwise the API is hidden for Windows Phone / WindowsRT when in fact
it's there and working
---
configure | 2 +-
libavcodec/dxva2_internal.h | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 84b7826..d2ebfa9 100755
--- a/configure
+++ b/configure
@@ -4264,7 +4264,7 @@ check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi

check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss

-check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
+check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP
check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0600

diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 3b651a4..9b6bbbc3 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -34,6 +34,9 @@
#include "d3d11va.h"
#endif
#if HAVE_DXVA_H
+/* dxva.h defines nothing otherwise but it works */
+#undef WINAPI_FAMILY
+#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
#include <dxva.h>
#endif
--
2.4.5
Martin Storsjö
2015-07-23 17:45:48 UTC
Permalink
Post by Steve Lhomme
otherwise the API is hidden for Windows Phone / WindowsRT when in fact
it's there and working
---
configure | 2 +-
libavcodec/dxva2_internal.h | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 84b7826..d2ebfa9 100755
--- a/configure
+++ b/configure
@@ -4264,7 +4264,7 @@ check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
-check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
+check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP
check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0600
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 3b651a4..9b6bbbc3 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -34,6 +34,9 @@
#include "d3d11va.h"
#endif
#if HAVE_DXVA_H
+/* dxva.h defines nothing otherwise but it works */
+#undef WINAPI_FAMILY
+#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
#include <dxva.h>
#endif
--
2.4.5
This is getting closer. The change to dxva2_internal.h is good and fixes
building in a number of cases for me, that's good.

It's worth noting that this doesn't have any effect
when using the Windows Phone 8.0 or 8.1 SDKs, since those have a separate
set of include files, that don't include dxva.h at all, so configure
doesn't enable it at all.



The part for configure doesn't work when targeting ARM though; the
configure check fails like this:

cl -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -nologo
-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline
-FIstdlib.h -Dstrtoll=_strtoi64 -DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP
-MD -D__ARM_PCS_VFP -D_WIN32_WINNT=0x0602
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -c -Fo./ffconf.NfCxNaxT.o
./ffconf.sX1qjUur.c
ffconf.sX1qjUur.c
10\include\10.0.10069.0\ucrt\corecrt.h(205):
fatal error C1189: #error: Compiling Desktop applications for the ARM
platform is not supported.

It doesn't hurt to add this change to configure, but it doesn't work as
intended in all cases.

// Martin
Martin Storsjö
2015-07-24 09:34:15 UTC
Permalink
Post by Martin Storsjö
Post by Steve Lhomme
otherwise the API is hidden for Windows Phone / WindowsRT when in fact
it's there and working
---
configure | 2 +-
libavcodec/dxva2_internal.h | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 84b7826..d2ebfa9 100755
--- a/configure
+++ b/configure
@@ -4264,7 +4264,7 @@ check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
-check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
+check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP
check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode
-D_WIN32_WINNT=0x0600
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 3b651a4..9b6bbbc3 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -34,6 +34,9 @@
#include "d3d11va.h"
#endif
#if HAVE_DXVA_H
+/* dxva.h defines nothing otherwise but it works */
+#undef WINAPI_FAMILY
+#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
#include <dxva.h>
#endif
--
2.4.5
This is getting closer. The change to dxva2_internal.h is good and fixes
building in a number of cases for me, that's good.
It's worth noting that this doesn't have any effect when using the Windows
Phone 8.0 or 8.1 SDKs, since those have a separate set of include files, that
don't include dxva.h at all, so configure doesn't enable it at all.
The part for configure doesn't work when targeting ARM though; the configure
cl -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -nologo
-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h
-Dstrtoll=_strtoi64 -DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP -MD
-D__ARM_PCS_VFP -D_WIN32_WINNT=0x0602
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -c -Fo./ffconf.NfCxNaxT.o
./ffconf.sX1qjUur.c
ffconf.sX1qjUur.c
Compiling Desktop applications for the ARM platform is not supported.
This part seems to be workaroundable by adding
-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1 in this particular test.
It's not very pretty, but should work to make the test work the intended
way at least. (For the normal code, this isn't an issue as long as
corecrt.h has been included already before redefining WINAPI_FAMILY.)

With this change (if it seems acceptable to you), I think this patch is
good to go.

// Martin
Steve Lhomme
2015-07-26 11:35:47 UTC
Permalink
The struct definitions in dxva.h, which are necessary in order to
actually use d3d11va, are hidden when WINAPI_FAMILY targets Windows Phone
or WindowsRT.

Building with WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP is disallowed
when targeting ARM. ("Compiling Desktop applications for the ARM
platform is not supported.") So we set _CRT_BUILD_DESKTOP_APP to 0
to tell the runtime not to detect some issues with this mismatching.

The same tweaks to detect if the API is available is done in dxva2_internal.h
when compiling each DXVA2/D3D11VA decoders.
---
configure | 2 +-
libavcodec/dxva2_internal.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 5ef2e0d..1ea94b3 100755
--- a/configure
+++ b/configure
@@ -4264,7 +4264,7 @@ check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi

check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss

-check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
+check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0600

diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 3b651a4..d2896aa 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -27,6 +27,9 @@

#include "config.h"

+/* define the proper COM entries before forcing desktop APIs */
+#include <objbase.h>
+
#if CONFIG_DXVA2
#include "dxva2.h"
#endif
@@ -34,6 +37,10 @@
#include "d3d11va.h"
#endif
#if HAVE_DXVA_H
+/* dxva.h defines nothing otherwise but it works */
+#undef WINAPI_FAMILY
+#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
+#define _CRT_BUILD_DESKTOP_APP 0
#include <dxva.h>
#endif
--
2.4.5
Martin Storsjö
2015-07-26 16:47:29 UTC
Permalink
Post by Steve Lhomme
The struct definitions in dxva.h, which are necessary in order to
actually use d3d11va, are hidden when WINAPI_FAMILY targets Windows Phone
or WindowsRT.
Building with WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP is disallowed
when targeting ARM. ("Compiling Desktop applications for the ARM
platform is not supported.") So we set _CRT_BUILD_DESKTOP_APP to 0
to tell the runtime not to detect some issues with this mismatching.
The same tweaks to detect if the API is available is done in dxva2_internal.h
when compiling each DXVA2/D3D11VA decoders.
---
configure | 2 +-
libavcodec/dxva2_internal.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 5ef2e0d..1ea94b3 100755
--- a/configure
+++ b/configure
@@ -4264,7 +4264,7 @@ check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
-check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
+check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0600
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 3b651a4..d2896aa 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -27,6 +27,9 @@
#include "config.h"
+/* define the proper COM entries before forcing desktop APIs */
+#include <objbase.h>
+
#if CONFIG_DXVA2
#include "dxva2.h"
#endif
@@ -34,6 +37,10 @@
#include "d3d11va.h"
#endif
#if HAVE_DXVA_H
+/* dxva.h defines nothing otherwise but it works */
+#undef WINAPI_FAMILY
+#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
+#define _CRT_BUILD_DESKTOP_APP 0
#include <dxva.h>
#endif
In my version of the patch, I had extended this comment like this:

+/* When targeting WINAPI_FAMILY_PHONE_APP or WINAPI_FAMILY_APP, dxva.h
+ * defines nothing. Force the struct definitions to be visible. */

I'm ok with this patch, but I'll change the comment, since it's a bit
unclear otherwise.

// Martin
Martin Storsjö
2015-07-26 17:17:47 UTC
Permalink
Post by Steve Lhomme
The struct definitions in dxva.h, which are necessary in order to
actually use d3d11va, are hidden when WINAPI_FAMILY targets Windows Phone
or WindowsRT.
Building with WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP is disallowed
when targeting ARM. ("Compiling Desktop applications for the ARM
platform is not supported.") So we set _CRT_BUILD_DESKTOP_APP to 0
to tell the runtime not to detect some issues with this mismatching.
The same tweaks to detect if the API is available is done in
dxva2_internal.h
when compiling each DXVA2/D3D11VA decoders.
---
configure | 2 +-
libavcodec/dxva2_internal.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 5ef2e0d..1ea94b3 100755
--- a/configure
+++ b/configure
@@ -4264,7 +4264,7 @@ check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
-check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
+check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
-DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode
-D_WIN32_WINNT=0x0600
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 3b651a4..d2896aa 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -27,6 +27,9 @@
#include "config.h"
+/* define the proper COM entries before forcing desktop APIs */
+#include <objbase.h>
+
#if CONFIG_DXVA2
#include "dxva2.h"
#endif
@@ -34,6 +37,10 @@
#include "d3d11va.h"
#endif
#if HAVE_DXVA_H
+/* dxva.h defines nothing otherwise but it works */
+#undef WINAPI_FAMILY
+#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
+#define _CRT_BUILD_DESKTOP_APP 0
I'll add an #undef here as well, to squelch some warnings, before pushing.

// Martin

Loading...