diff mbox

[FFmpeg-devel] qsv: Use the installed mfx include headers if possibile

Message ID 20180511075242.28201-1-haihao.xiang@intel.com
State New
Headers show

Commit Message

Xiang, Haihao May 11, 2018, 7:52 a.m. UTC
Currently an extra copy of mfx include headers from {MSDK_INSTALL_PREFIX}/include
to {MSDK_INSTALL_PREFIX}/include/mfx is required when using pkg-config for
libmfx detection. This fix checks the installed mfx include headers first,
and falls back to the legacy way if that fails

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
---
 configure                        |  3 ++-
 fftools/ffmpeg_qsv.c             |  5 +++++
 libavcodec/qsv.c                 | 10 ++++++++++
 libavcodec/qsv.h                 |  4 ++++
 libavcodec/qsv_internal.h        |  4 ++++
 libavcodec/qsvdec.c              |  4 ++++
 libavcodec/qsvdec.h              |  4 ++++
 libavcodec/qsvdec_h2645.c        |  4 ++++
 libavcodec/qsvdec_other.c        |  4 ++++
 libavcodec/qsvenc.c              |  5 +++++
 libavcodec/qsvenc.h              |  4 ++++
 libavcodec/qsvenc_h264.c         |  4 ++++
 libavcodec/qsvenc_hevc.c         |  4 ++++
 libavcodec/qsvenc_jpeg.c         |  4 ++++
 libavcodec/qsvenc_mpeg2.c        |  4 ++++
 libavfilter/qsvvpp.h             |  4 ++++
 libavfilter/vf_deinterlace_qsv.c |  4 ++++
 libavfilter/vf_scale_qsv.c       |  4 ++++
 libavutil/hwcontext_opencl.c     |  4 ++++
 libavutil/hwcontext_qsv.c        |  4 ++++
 libavutil/hwcontext_qsv.h        |  4 ++++
 21 files changed, 90 insertions(+), 1 deletion(-)

Comments

Mark Thompson May 11, 2018, 10:38 a.m. UTC | #1
On 11/05/18 08:52, Haihao Xiang wrote:
> Currently an extra copy of mfx include headers from {MSDK_INSTALL_PREFIX}/include
> to {MSDK_INSTALL_PREFIX}/include/mfx is required when using pkg-config for
> libmfx detection. This fix checks the installed mfx include headers first,
> and falls back to the legacy way if that fails
> 
> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
> ---
>  configure                        |  3 ++-
>  fftools/ffmpeg_qsv.c             |  5 +++++
>  libavcodec/qsv.c                 | 10 ++++++++++
>  libavcodec/qsv.h                 |  4 ++++
>  libavcodec/qsv_internal.h        |  4 ++++
>  libavcodec/qsvdec.c              |  4 ++++
>  libavcodec/qsvdec.h              |  4 ++++
>  libavcodec/qsvdec_h2645.c        |  4 ++++
>  libavcodec/qsvdec_other.c        |  4 ++++
>  libavcodec/qsvenc.c              |  5 +++++
>  libavcodec/qsvenc.h              |  4 ++++
>  libavcodec/qsvenc_h264.c         |  4 ++++
>  libavcodec/qsvenc_hevc.c         |  4 ++++
>  libavcodec/qsvenc_jpeg.c         |  4 ++++
>  libavcodec/qsvenc_mpeg2.c        |  4 ++++
>  libavfilter/qsvvpp.h             |  4 ++++
>  libavfilter/vf_deinterlace_qsv.c |  4 ++++
>  libavfilter/vf_scale_qsv.c       |  4 ++++
>  libavutil/hwcontext_opencl.c     |  4 ++++
>  libavutil/hwcontext_qsv.c        |  4 ++++
>  libavutil/hwcontext_qsv.h        |  4 ++++
>  21 files changed, 90 insertions(+), 1 deletion(-)

I don't think it's a good idea to put an #ifdef like this in every file.

> 
> diff --git a/configure b/configure
> index a1f13a7109..e1f72495fb 100755
> --- a/configure
> +++ b/configure
> @@ -6007,7 +6007,8 @@ enabled libkvazaar        && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kv
>  # Media SDK or Intel Media Server Studio, these don't come with
>  # pkg-config support.  Instead, users should make sure that the build
>  # can find the libraries and headers through other means.
> -enabled libmfx            && { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit ||
> +enabled libmfx            && { { check_pkg_config libmfx libmfx "mfxvideo.h" MFXInit && add_cflags -DMFX_DEFAULT_INC_PATH; } ||
> +                               { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit; } ||
>                                 { require libmfx "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } }
>  enabled libmodplug        && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load
>  enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame $libm_extralibs
So in the current code, the first test is for the open-source dispatcher (<https://github.com/lu-zero/mfx_dispatch>), which gets used everywhere that pkgconfig is supported, including mingw on Windows.  The second test is for Windows cases where you can't make make pkgconfig work.

What installs the headers directly in $PREFIX/include?  Presumably this is a new change - can we ask them not to do that?  (Because organising them in a subdirectory is I think much more sensible.)

- Mark
wm4 May 11, 2018, 10:48 a.m. UTC | #2
On Fri, 11 May 2018 11:38:52 +0100
Mark Thompson <sw@jkqxz.net> wrote:

> On 11/05/18 08:52, Haihao Xiang wrote:
> > Currently an extra copy of mfx include headers from {MSDK_INSTALL_PREFIX}/include
> > to {MSDK_INSTALL_PREFIX}/include/mfx is required when using pkg-config for
> > libmfx detection. This fix checks the installed mfx include headers first,
> > and falls back to the legacy way if that fails
> > 
> > Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
> > ---
> >  configure                        |  3 ++-
> >  fftools/ffmpeg_qsv.c             |  5 +++++
> >  libavcodec/qsv.c                 | 10 ++++++++++
> >  libavcodec/qsv.h                 |  4 ++++
> >  libavcodec/qsv_internal.h        |  4 ++++
> >  libavcodec/qsvdec.c              |  4 ++++
> >  libavcodec/qsvdec.h              |  4 ++++
> >  libavcodec/qsvdec_h2645.c        |  4 ++++
> >  libavcodec/qsvdec_other.c        |  4 ++++
> >  libavcodec/qsvenc.c              |  5 +++++
> >  libavcodec/qsvenc.h              |  4 ++++
> >  libavcodec/qsvenc_h264.c         |  4 ++++
> >  libavcodec/qsvenc_hevc.c         |  4 ++++
> >  libavcodec/qsvenc_jpeg.c         |  4 ++++
> >  libavcodec/qsvenc_mpeg2.c        |  4 ++++
> >  libavfilter/qsvvpp.h             |  4 ++++
> >  libavfilter/vf_deinterlace_qsv.c |  4 ++++
> >  libavfilter/vf_scale_qsv.c       |  4 ++++
> >  libavutil/hwcontext_opencl.c     |  4 ++++
> >  libavutil/hwcontext_qsv.c        |  4 ++++
> >  libavutil/hwcontext_qsv.h        |  4 ++++
> >  21 files changed, 90 insertions(+), 1 deletion(-)  
> 
> I don't think it's a good idea to put an #ifdef like this in every file.

+1
Xiang, Haihao May 14, 2018, 12:50 a.m. UTC | #3
> On 11/05/18 08:52, Haihao Xiang wrote:

> > Currently an extra copy of mfx include headers from

> > {MSDK_INSTALL_PREFIX}/include

> > to {MSDK_INSTALL_PREFIX}/include/mfx is required when using pkg-config for

> > libmfx detection. This fix checks the installed mfx include headers first,

> > and falls back to the legacy way if that fails

> > 

> > Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>

> > ---

> >  configure                        |  3 ++-

> >  fftools/ffmpeg_qsv.c             |  5 +++++

> >  libavcodec/qsv.c                 | 10 ++++++++++

> >  libavcodec/qsv.h                 |  4 ++++

> >  libavcodec/qsv_internal.h        |  4 ++++

> >  libavcodec/qsvdec.c              |  4 ++++

> >  libavcodec/qsvdec.h              |  4 ++++

> >  libavcodec/qsvdec_h2645.c        |  4 ++++

> >  libavcodec/qsvdec_other.c        |  4 ++++

> >  libavcodec/qsvenc.c              |  5 +++++

> >  libavcodec/qsvenc.h              |  4 ++++

> >  libavcodec/qsvenc_h264.c         |  4 ++++

> >  libavcodec/qsvenc_hevc.c         |  4 ++++

> >  libavcodec/qsvenc_jpeg.c         |  4 ++++

> >  libavcodec/qsvenc_mpeg2.c        |  4 ++++

> >  libavfilter/qsvvpp.h             |  4 ++++

> >  libavfilter/vf_deinterlace_qsv.c |  4 ++++

> >  libavfilter/vf_scale_qsv.c       |  4 ++++

> >  libavutil/hwcontext_opencl.c     |  4 ++++

> >  libavutil/hwcontext_qsv.c        |  4 ++++

> >  libavutil/hwcontext_qsv.h        |  4 ++++

> >  21 files changed, 90 insertions(+), 1 deletion(-)

> 

> I don't think it's a good idea to put an #ifdef like this in every file.

> 

> > 

> > diff --git a/configure b/configure

> > index a1f13a7109..e1f72495fb 100755

> > --- a/configure

> > +++ b/configure

> > @@ -6007,7 +6007,8 @@ enabled libkvazaar        && require_pkg_config

> > libkvazaar "kvazaar >= 0.8.1" kv

> >  # Media SDK or Intel Media Server Studio, these don't come with

> >  # pkg-config support.  Instead, users should make sure that the build

> >  # can find the libraries and headers through other means.

> > -enabled libmfx            && { check_pkg_config libmfx libmfx

> > "mfx/mfxvideo.h" MFXInit ||

> > +enabled libmfx            && { { check_pkg_config libmfx libmfx

> > "mfxvideo.h" MFXInit && add_cflags -DMFX_DEFAULT_INC_PATH; } ||

> > +                               { check_pkg_config libmfx libmfx

> > "mfx/mfxvideo.h" MFXInit; } ||

> >                                 { require libmfx "mfx/mfxvideo.h" MFXInit "-

> > llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } }

> >  enabled libmodplug        && require_pkg_config libmodplug libmodplug

> > libmodplug/modplug.h ModPlug_Load

> >  enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h

> > lame_set_VBR_quality -lmp3lame $libm_extralibs

> 

> So in the current code, the first test is for the open-source dispatcher (<htt

> ps://github.com/lu-zero/mfx_dispatch>), which gets used everywhere that

> pkgconfig is supported, including mingw on Windows.  The second test is for

> Windows cases where you can't make make pkgconfig work.

> 

> What installs the headers directly in $PREFIX/include?  Presumably this is a

> new change - can we ask them not to do that?  (Because organising them in a

> subdirectory is I think much more sensible.)

> 


Link below is the open-source version of MediaSDK which installs the headers
directly in $PREFIX/include. User needn't the open-source dispatcher any more on
Linux

https://github.com/Intel-Media-SDK/MediaSDK

> - Mark

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Xiang, Haihao May 14, 2018, 2:38 a.m. UTC | #4
On Mon, 2018-05-14 at 00:50 +0000, Xiang, Haihao wrote:
> > On 11/05/18 08:52, Haihao Xiang wrote:

> > > Currently an extra copy of mfx include headers from

> > > {MSDK_INSTALL_PREFIX}/include

> > > to {MSDK_INSTALL_PREFIX}/include/mfx is required when using pkg-config for

> > > libmfx detection. This fix checks the installed mfx include headers first,

> > > and falls back to the legacy way if that fails

> > > 

> > > Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>

> > > ---

> > >  configure                        |  3 ++-

> > >  fftools/ffmpeg_qsv.c             |  5 +++++

> > >  libavcodec/qsv.c                 | 10 ++++++++++

> > >  libavcodec/qsv.h                 |  4 ++++

> > >  libavcodec/qsv_internal.h        |  4 ++++

> > >  libavcodec/qsvdec.c              |  4 ++++

> > >  libavcodec/qsvdec.h              |  4 ++++

> > >  libavcodec/qsvdec_h2645.c        |  4 ++++

> > >  libavcodec/qsvdec_other.c        |  4 ++++

> > >  libavcodec/qsvenc.c              |  5 +++++

> > >  libavcodec/qsvenc.h              |  4 ++++

> > >  libavcodec/qsvenc_h264.c         |  4 ++++

> > >  libavcodec/qsvenc_hevc.c         |  4 ++++

> > >  libavcodec/qsvenc_jpeg.c         |  4 ++++

> > >  libavcodec/qsvenc_mpeg2.c        |  4 ++++

> > >  libavfilter/qsvvpp.h             |  4 ++++

> > >  libavfilter/vf_deinterlace_qsv.c |  4 ++++

> > >  libavfilter/vf_scale_qsv.c       |  4 ++++

> > >  libavutil/hwcontext_opencl.c     |  4 ++++

> > >  libavutil/hwcontext_qsv.c        |  4 ++++

> > >  libavutil/hwcontext_qsv.h        |  4 ++++

> > >  21 files changed, 90 insertions(+), 1 deletion(-)

> > 

> > I don't think it's a good idea to put an #ifdef like this in every file.

> > 

> > > 

> > > diff --git a/configure b/configure

> > > index a1f13a7109..e1f72495fb 100755

> > > --- a/configure

> > > +++ b/configure

> > > @@ -6007,7 +6007,8 @@ enabled libkvazaar        && require_pkg_config

> > > libkvazaar "kvazaar >= 0.8.1" kv

> > >  # Media SDK or Intel Media Server Studio, these don't come with

> > >  # pkg-config support.  Instead, users should make sure that the build

> > >  # can find the libraries and headers through other means.

> > > -enabled libmfx            && { check_pkg_config libmfx libmfx

> > > "mfx/mfxvideo.h" MFXInit ||

> > > +enabled libmfx            && { { check_pkg_config libmfx libmfx

> > > "mfxvideo.h" MFXInit && add_cflags -DMFX_DEFAULT_INC_PATH; } ||

> > > +                               { check_pkg_config libmfx libmfx

> > > "mfx/mfxvideo.h" MFXInit; } ||

> > >                                 { require libmfx "mfx/mfxvideo.h" MFXInit

> > > "-

> > > llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; }

> > > }

> > >  enabled libmodplug        && require_pkg_config libmodplug libmodplug

> > > libmodplug/modplug.h ModPlug_Load

> > >  enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h

> > > lame_set_VBR_quality -lmp3lame $libm_extralibs

> > 

> > So in the current code, the first test is for the open-source dispatcher

> > (<htt

> > ps://github.com/lu-zero/mfx_dispatch>), which gets used everywhere that

> > pkgconfig is supported, including mingw on Windows.  The second test is for

> > Windows cases where you can't make make pkgconfig work.

> > 

> > What installs the headers directly in $PREFIX/include?  Presumably this is a

> > new change - can we ask them not to do that?  (Because organising them in a

> > subdirectory is I think much more sensible.)

> > 

> 

> Link below is the open-source version of MediaSDK which installs the headers

> directly in $PREFIX/include. User needn't the open-source dispatcher any more

> on

> Linux

> 

> https://github.com/Intel-Media-SDK/MediaSDK

> 


I filed https://github.com/Intel-Media-SDK/MediaSDK/issues/199, hope they can
change the install path for mfx headers.

Thanks
Haihao


> > - Mark

> > _______________________________________________

> > ffmpeg-devel mailing list

> > ffmpeg-devel@ffmpeg.org

> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

> 

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Zhong Li May 15, 2018, 5:33 a.m. UTC | #5
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Xiang, Haihao

> Sent: Monday, May 14, 2018 10:38 AM

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH] qsv: Use the installed mfx include

> headers if possibile

> 

> On Mon, 2018-05-14 at 00:50 +0000, Xiang, Haihao wrote:

> > > On 11/05/18 08:52, Haihao Xiang wrote:

> > > > Currently an extra copy of mfx include headers from

> > > > {MSDK_INSTALL_PREFIX}/include to

> {MSDK_INSTALL_PREFIX}/include/mfx

> > > > is required when using pkg-config for libmfx detection. This fix

> > > > checks the installed mfx include headers first, and falls back to

> > > > the legacy way if that fails

> > > >

> > > > Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>

> > > > ---

> > > >  configure                        |  3 ++-

> > > >  fftools/ffmpeg_qsv.c             |  5 +++++

> > > >  libavcodec/qsv.c                 | 10 ++++++++++

> > > >  libavcodec/qsv.h                 |  4 ++++

> > > >  libavcodec/qsv_internal.h        |  4 ++++

> > > >  libavcodec/qsvdec.c              |  4 ++++

> > > >  libavcodec/qsvdec.h              |  4 ++++

> > > >  libavcodec/qsvdec_h2645.c        |  4 ++++

> > > >  libavcodec/qsvdec_other.c        |  4 ++++

> > > >  libavcodec/qsvenc.c              |  5 +++++

> > > >  libavcodec/qsvenc.h              |  4 ++++

> > > >  libavcodec/qsvenc_h264.c         |  4 ++++

> > > >  libavcodec/qsvenc_hevc.c         |  4 ++++

> > > >  libavcodec/qsvenc_jpeg.c         |  4 ++++

> > > >  libavcodec/qsvenc_mpeg2.c        |  4 ++++

> > > >  libavfilter/qsvvpp.h             |  4 ++++

> > > >  libavfilter/vf_deinterlace_qsv.c |  4 ++++

> > > >  libavfilter/vf_scale_qsv.c       |  4 ++++

> > > >  libavutil/hwcontext_opencl.c     |  4 ++++

> > > >  libavutil/hwcontext_qsv.c        |  4 ++++

> > > >  libavutil/hwcontext_qsv.h        |  4 ++++

> > > >  21 files changed, 90 insertions(+), 1 deletion(-)

> > >

> > > I don't think it's a good idea to put an #ifdef like this in every file.

> > >

> > > >

> > > > diff --git a/configure b/configure index a1f13a7109..e1f72495fb

> > > > 100755

> > > > --- a/configure

> > > > +++ b/configure

> > > > @@ -6007,7 +6007,8 @@ enabled libkvazaar        &&

> require_pkg_config

> > > > libkvazaar "kvazaar >= 0.8.1" kv

> > > >  # Media SDK or Intel Media Server Studio, these don't come with

> > > > # pkg-config support.  Instead, users should make sure that the

> > > > build  # can find the libraries and headers through other means.

> > > > -enabled libmfx            && { check_pkg_config libmfx libmfx

> > > > "mfx/mfxvideo.h" MFXInit ||

> > > > +enabled libmfx            && { { check_pkg_config libmfx libmfx

> > > > "mfxvideo.h" MFXInit && add_cflags -DMFX_DEFAULT_INC_PATH; } ||

> > > > +                               { check_pkg_config libmfx

> libmfx

> > > > "mfx/mfxvideo.h" MFXInit; } ||

> > > >                                 { require libmfx

> "mfx/mfxvideo.h"

> > > > MFXInit

> > > > "-

> > > > llibmfx $advapi32_extralibs" && warn "using libmfx without

> > > > pkg-config"; } }

> > > >  enabled libmodplug        && require_pkg_config libmodplug

> libmodplug

> > > > libmodplug/modplug.h ModPlug_Load

> > > >  enabled libmp3lame        && require "libmp3lame >= 3.98.3"

> lame/lame.h

> > > > lame_set_VBR_quality -lmp3lame $libm_extralibs

> > >

> > > So in the current code, the first test is for the open-source

> > > dispatcher (<htt ps://github.com/lu-zero/mfx_dispatch>), which gets

> > > used everywhere that pkgconfig is supported, including mingw on

> > > Windows.  The second test is for Windows cases where you can't make

> > > make pkgconfig work.

> > >

> > > What installs the headers directly in $PREFIX/include?  Presumably

> > > this is a new change - can we ask them not to do that?  (Because

> > > organising them in a subdirectory is I think much more sensible.)

> > >

> >

> > Link below is the open-source version of MediaSDK which installs the

> > headers directly in $PREFIX/include. User needn't the open-source

> > dispatcher any more on Linux

> >

> > https://github.com/Intel-Media-SDK/MediaSDK

> >

> 

> I filed https://github.com/Intel-Media-SDK/MediaSDK/issues/199, hope they

> can change the install path for mfx headers.


Changing it in open source MSDK should be a better solution.

> 

> Thanks

> Haihao
diff mbox

Patch

diff --git a/configure b/configure
index a1f13a7109..e1f72495fb 100755
--- a/configure
+++ b/configure
@@ -6007,7 +6007,8 @@  enabled libkvazaar        && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kv
 # Media SDK or Intel Media Server Studio, these don't come with
 # pkg-config support.  Instead, users should make sure that the build
 # can find the libraries and headers through other means.
-enabled libmfx            && { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit ||
+enabled libmfx            && { { check_pkg_config libmfx libmfx "mfxvideo.h" MFXInit && add_cflags -DMFX_DEFAULT_INC_PATH; } ||
+                               { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit; } ||
                                { require libmfx "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } }
 enabled libmodplug        && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load
 enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame $libm_extralibs
diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
index 7442750029..aa6f8d5270 100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
@@ -16,7 +16,12 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
+
 #include <stdlib.h>
 
 #include "libavutil/dict.h"
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 45e1c25c68..88f68d6ab5 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -18,9 +18,15 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#include <mfxplugin.h>
+#include <mfxjpeg.h>
+#else
 #include <mfx/mfxvideo.h>
 #include <mfx/mfxplugin.h>
 #include <mfx/mfxjpeg.h>
+#endif
 
 #include <stdio.h>
 #include <string.h>
@@ -36,8 +42,12 @@ 
 #include "qsv_internal.h"
 
 #if QSV_VERSION_ATLEAST(1, 12)
+#ifdef MFX_DEFAULT_INC_PATH
+#include "mfxvp8.h"
+#else
 #include "mfx/mfxvp8.h"
 #endif
+#endif
 
 int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 {
diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h
index b77158ec26..0116fe9422 100644
--- a/libavcodec/qsv.h
+++ b/libavcodec/qsv.h
@@ -21,7 +21,11 @@ 
 #ifndef AVCODEC_QSV_H
 #define AVCODEC_QSV_H
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/buffer.h"
 
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 394c558883..f77ad63664 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -21,7 +21,11 @@ 
 #ifndef AVCODEC_QSV_INTERNAL_H
 #define AVCODEC_QSV_INTERNAL_H
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/frame.h"
 
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 32f1fe79d7..9921158100 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -24,7 +24,11 @@ 
 #include <string.h>
 #include <sys/types.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/common.h"
 #include "libavutil/hwcontext.h"
diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
index 5b7b03a48b..3b4541fff1 100644
--- a/libavcodec/qsvdec.h
+++ b/libavcodec/qsvdec.h
@@ -26,7 +26,11 @@ 
 #include <stdint.h>
 #include <sys/types.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/fifo.h"
 #include "libavutil/frame.h"
diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index 831252f2d7..e2b90afee9 100644
--- a/libavcodec/qsvdec_h2645.c
+++ b/libavcodec/qsvdec_h2645.c
@@ -25,7 +25,11 @@ 
 #include <stdint.h>
 #include <string.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/common.h"
 #include "libavutil/fifo.h"
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index 3c872dcfc2..dd0082164b 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -24,7 +24,11 @@ 
 #include <stdint.h>
 #include <string.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/common.h"
 #include "libavutil/fifo.h"
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 3ce5ffecd5..3dbb23716c 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -23,7 +23,12 @@ 
 
 #include <string.h>
 #include <sys/types.h>
+
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/common.h"
 #include "libavutil/hwcontext.h"
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index d48272224c..16cd74eccf 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -26,7 +26,11 @@ 
 #include <stdint.h>
 #include <sys/types.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/avutil.h"
 #include "libavutil/fifo.h"
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 7aa65e96bc..6ba85ea50a 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -24,7 +24,11 @@ 
 #include <stdint.h>
 #include <sys/types.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 4339b316a3..a5ed2ef38b 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -22,7 +22,11 @@ 
 #include <stdint.h>
 #include <sys/types.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c
index c18fe91940..b0300faa33 100644
--- a/libavcodec/qsvenc_jpeg.c
+++ b/libavcodec/qsvenc_jpeg.c
@@ -22,7 +22,11 @@ 
 #include <stdint.h>
 #include <sys/types.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c
index a7427d8109..ff1907237b 100644
--- a/libavcodec/qsvenc_mpeg2.c
+++ b/libavcodec/qsvenc_mpeg2.c
@@ -22,7 +22,11 @@ 
 #include <stdint.h>
 #include <sys/types.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
index ff02b64c41..401bc45bd4 100644
--- a/libavfilter/qsvvpp.h
+++ b/libavfilter/qsvvpp.h
@@ -24,7 +24,11 @@ 
 #ifndef AVFILTER_QSVVPP_H
 #define AVFILTER_QSVVPP_H
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "avfilter.h"
 
diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index c9e76c6056..45db51b7cf 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -21,7 +21,11 @@ 
  * deinterlace video filter - QSV
  */
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include <stdio.h>
 #include <string.h>
diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index d1189942d1..f242a49f96 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -21,7 +21,11 @@ 
  * scale video filter - QSV
  */
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include <stdio.h>
 #include <string.h>
diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index 43b5c5ae0c..ab105287d1 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -46,7 +46,11 @@ 
 #endif
 
 #if HAVE_OPENCL_VAAPI_INTEL_MEDIA
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxstructures.h>
+#else
 #include <mfx/mfxstructures.h>
+#endif
 #include <va/va.h>
 #include <CL/va_ext.h>
 #include "hwcontext_vaapi.h"
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 250091c4e8..61e7a55e99 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -19,7 +19,11 @@ 
 #include <stdint.h>
 #include <string.h>
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 #include "config.h"
 
diff --git a/libavutil/hwcontext_qsv.h b/libavutil/hwcontext_qsv.h
index b98d611cfc..56180394fc 100644
--- a/libavutil/hwcontext_qsv.h
+++ b/libavutil/hwcontext_qsv.h
@@ -19,7 +19,11 @@ 
 #ifndef AVUTIL_HWCONTEXT_QSV_H
 #define AVUTIL_HWCONTEXT_QSV_H
 
+#ifdef MFX_DEFAULT_INC_PATH
+#include <mfxvideo.h>
+#else
 #include <mfx/mfxvideo.h>
+#endif
 
 /**
  * @file