---
A separate d3d11va.h is needed similar to the public dxva2.h as the
decoder needs two D3D11 objects
Consequently all API calls to the DirectX decoder must take in account
the two different structures.
---
 configure                     | 31 +++++++++++++-
 libavcodec/Makefile           |  7 ++++
 libavcodec/allcodecs.c        |  5 +++
 libavcodec/d3d11va.c          | 24 +++++++++++
 libavcodec/d3d11va.h          | 98 +++++++++++++++++++++++++++++++++++++++++++
 libavcodec/d3d11va_h264.c     | 41 ++++++++++++++++++
 libavcodec/d3d11va_hevc.c     | 41 ++++++++++++++++++
 libavcodec/d3d11va_internal.h | 56 +++++++++++++++++++++++++
 libavcodec/d3d11va_mpeg2.c    | 41 ++++++++++++++++++
 libavcodec/d3d11va_vc1.c      | 54 ++++++++++++++++++++++++
 libavcodec/h264_slice.c       |  3 ++
 libavcodec/hevc.c             |  3 ++
 libavcodec/mpeg12dec.c        |  3 ++
 libavcodec/vc1dec.c           |  3 ++
 libavutil/pixdesc.c           |  6 +++
 libavutil/pixfmt.h            |  5 +++
 16 files changed, 420 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/d3d11va.c
 create mode 100644 libavcodec/d3d11va.h
 create mode 100644 libavcodec/d3d11va_h264.c
 create mode 100644 libavcodec/d3d11va_hevc.c
 create mode 100644 libavcodec/d3d11va_internal.h
 create mode 100644 libavcodec/d3d11va_mpeg2.c
 create mode 100644 libavcodec/d3d11va_vc1.c

diff --git a/configure b/configure
index f3e5154..fcab3d2 100755
--- a/configure
+++ b/configure
@@ -133,6 +133,7 @@ Component options:
   --disable-faan           disable floating point AAN (I)DCT code
 
 Hardware accelerators:
+  --enable-d3d11va         enable D3D11VA code
   --enable-dxva2           enable DXVA2 code
   --enable-vaapi           enable VAAPI code
   --enable-vda             enable VDA code
@@ -1206,6 +1207,7 @@ FEATURE_LIST="
 "
 
 HWACCEL_LIST="
+    d3d11va
     dxva2
     vaapi
     vda
@@ -1396,6 +1398,7 @@ HEADERS_LIST="
     dev_video_meteor_ioctl_meteor_h
     direct_h
     dlfcn_h
+    d3d11_h
     dxva_h
     gsm_h
     io_h
@@ -1551,6 +1554,8 @@ HAVE_LIST="
     $TYPES_LIST
     atomics_native
     dos_paths
+    d3d11_cobj
+    d3d11va_lib
     dxva2_lib
     libc_msvcrt
     libdc1394_1
@@ -1965,6 +1970,7 @@ zmbv_decoder_deps="zlib"
 zmbv_encoder_deps="zlib"
 
 # hardware accelerators
+d3d11va_deps="d3d11_h dxva_h"
 dxva2_deps="dxva2api_h"
 vaapi_deps="va_va_h"
 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
@@ -1975,6 +1981,8 @@ h263_vaapi_hwaccel_deps="vaapi"
 h263_vaapi_hwaccel_select="h263_decoder"
 h263_vdpau_hwaccel_deps="vdpau"
 h263_vdpau_hwaccel_select="h263_decoder"
+h264_d3d11va_hwaccel_deps="d3d11va"
+h264_d3d11va_hwaccel_select="h264_decoder"
 h264_dxva2_hwaccel_deps="dxva2"
 h264_dxva2_hwaccel_select="h264_decoder"
 h264_mmal_decoder_deps="mmal"
@@ -1990,10 +1998,14 @@ h264_vda_old_hwaccel_deps="vda"
 h264_vda_old_hwaccel_select="h264_decoder"
 h264_vdpau_hwaccel_deps="vdpau"
 h264_vdpau_hwaccel_select="h264_decoder"
+hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
+hevc_d3d11va_hwaccel_select="hevc_decoder"
 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
 hevc_dxva2_hwaccel_select="hevc_decoder"
 mpeg1_vdpau_hwaccel_deps="vdpau"
 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
+mpeg2_d3d11va_hwaccel_deps="d3d11va"
+mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
 mpeg2_dxva2_hwaccel_deps="dxva2"
 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
 mpeg2_vaapi_hwaccel_deps="vaapi"
@@ -2004,12 +2016,15 @@ mpeg4_vaapi_hwaccel_deps="vaapi"
 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
 mpeg4_vdpau_hwaccel_deps="vdpau"
 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
+vc1_d3d11va_hwaccel_deps="d3d11va"
+vc1_d3d11va_hwaccel_select="vc1_decoder"
 vc1_dxva2_hwaccel_deps="dxva2"
 vc1_dxva2_hwaccel_select="vc1_decoder"
 vc1_vaapi_hwaccel_deps="vaapi"
 vc1_vaapi_hwaccel_select="vc1_decoder"
 vc1_vdpau_hwaccel_deps="vdpau"
 vc1_vdpau_hwaccel_select="vc1_decoder"
+wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
@@ -2288,7 +2303,7 @@ enable swscale_alpha
 enable valgrind_backtrace
 
 # By default, enable only those hwaccels that have no external dependencies.
-enable dxva2 vda vdpau
+enable d3d11va dxva2 vda vdpau
 
 # build settings
 SHFLAGS='-shared -Wl,-soname,$$(@F)'
@@ -4157,6 +4172,7 @@ check_header direct.h
 check_header dlfcn.h
 check_header dxva.h
 check_header dxva2api.h
+check_header d3d11.h
 check_header io.h
 check_header mach/mach_time.h
 check_header malloc.h
@@ -4371,6 +4387,15 @@ if enabled x11grab; then
     require Xext X11/extensions/XShm.h XShmCreateImage -lXext
     require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
 fi
+enabled d3d11_h &&
+    check_cc <<EOF && enable d3d11_cobj
+#define _WIN32_WINNT 0x0600
+#define COBJMACROS
+#include <windows.h>
+#include <d3d11.h>
+int main(void) { ID3D11VideoDecoder *o = NULL; ID3D11VideoDecoder_Release(o); 
return 0; }
+EOF
+
 
 enabled vaapi && enabled xlib &&
     check_lib2 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 &&
@@ -4597,6 +4622,10 @@ enabled_all dxva2 CoTaskMemFree &&
     prepend avconv_libs $($ldflags_filter "-lole32") &&
     enable dxva2_lib
 
+enabled_all d3d11va d3d11_cobj CoTaskMemFree &&
+    prepend avconv_libs $($ldflags_filter "-lole32") &&
+    enable d3d11va_lib
+
 ! enabled_any memalign posix_memalign aligned_malloc &&
     enabled simd_align_16 && enable memalign_hack
 
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 293f067..1d04d93 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -3,6 +3,7 @@ NAME = avcodec
 HEADERS = avcodec.h                                                     \
           avfft.h                                                       \
           dv_profile.h                                                  \
+          d3d11va.h                                                     \
           dxva2.h                                                       \
           qsv.h                                                         \
           vaapi.h                                                       \
@@ -557,6 +558,7 @@ OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER)       += adpcm.o 
adpcm_data.o
 OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER)       += adpcmenc.o adpcm_data.o
 
 # hardware accelerators
+OBJS-$(CONFIG_D3D11VA)                    += d3d11va.o
 OBJS-$(CONFIG_DXVA2)                      += dxva2.o
 OBJS-$(CONFIG_VAAPI)                      += vaapi.o
 OBJS-$(CONFIG_VDA)                        += vda.o
@@ -564,17 +566,21 @@ OBJS-$(CONFIG_VDPAU)                      += vdpau.o
 
 OBJS-$(CONFIG_H263_VAAPI_HWACCEL)         += vaapi_mpeg4.o
 OBJS-$(CONFIG_H263_VDPAU_HWACCEL)         += vdpau_mpeg4.o
+OBJS-$(CONFIG_H264_D3D11VA_HWACCEL)       += d3d11va_h264.o
 OBJS-$(CONFIG_H264_DXVA2_HWACCEL)         += dxva2_h264.o
 OBJS-$(CONFIG_H264_VAAPI_HWACCEL)         += vaapi_h264.o
 OBJS-$(CONFIG_H264_VDA_HWACCEL)           += vda_h264.o
 OBJS-$(CONFIG_H264_VDPAU_HWACCEL)         += vdpau_h264.o
+OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)       += d3d11va_hevc.o
 OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL)         += dxva2_hevc.o
 OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL)        += vdpau_mpeg12.o
+OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL)      += d3d11va_mpeg2.o
 OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL)        += dxva2_mpeg2.o
 OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)        += vaapi_mpeg2.o
 OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL)        += vdpau_mpeg12.o
 OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL)        += vaapi_mpeg4.o
 OBJS-$(CONFIG_MPEG4_VDPAU_HWACCEL)        += vdpau_mpeg4.o
+OBJS-$(CONFIG_VC1_D3D11VA_HWACCEL)        += d3d11va_vc1.o
 OBJS-$(CONFIG_VC1_DXVA2_HWACCEL)          += dxva2_vc1.o
 OBJS-$(CONFIG_VC1_VAAPI_HWACCEL)          += vaapi_vc1.o
 OBJS-$(CONFIG_VC1_VDPAU_HWACCEL)          += vdpau_vc1.o
@@ -723,6 +729,7 @@ SKIPHEADERS                            += %_tablegen.h      
            \
                                           tableprint.h                  \
                                           $(ARCH)/vp56_arith.h          \
 
+SKIPHEADERS-$(CONFIG_D3D11VA)          += d3d11va.h d3d11va_internal.h 
dxva_internal_template.h
 SKIPHEADERS-$(CONFIG_DXVA2)            += dxva2.h dxva2_internal.h 
dxva_internal_template.h
 SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER)  += libschroedinger.h
 SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d2679ad..a8b5b53 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -76,6 +76,7 @@ void avcodec_register_all(void)
     /* hardware accelerators */
     REGISTER_HWACCEL(H263_VAAPI,        h263_vaapi);
     REGISTER_HWACCEL(H263_VDPAU,        h263_vdpau);
+    REGISTER_HWACCEL(H264_D3D11VA,      h264_d3d11va);
     REGISTER_HWACCEL(H264_DXVA2,        h264_dxva2);
     REGISTER_HWACCEL(H264_MMAL,         h264_mmal);
     REGISTER_HWACCEL(H264_QSV,          h264_qsv);
@@ -83,16 +84,20 @@ void avcodec_register_all(void)
     REGISTER_HWACCEL(H264_VDA,          h264_vda);
     REGISTER_HWACCEL(H264_VDA_OLD,      h264_vda_old);
     REGISTER_HWACCEL(H264_VDPAU,        h264_vdpau);
+    REGISTER_HWACCEL(HEVC_D3D11VA,      hevc_d3d11va);
     REGISTER_HWACCEL(HEVC_DXVA2,        hevc_dxva2);
     REGISTER_HWACCEL(MPEG1_VDPAU,       mpeg1_vdpau);
+    REGISTER_HWACCEL(MPEG2_D3D11VA,     mpeg2_d3d11va);
     REGISTER_HWACCEL(MPEG2_DXVA2,       mpeg2_dxva2);
     REGISTER_HWACCEL(MPEG2_VAAPI,       mpeg2_vaapi);
     REGISTER_HWACCEL(MPEG2_VDPAU,       mpeg2_vdpau);
     REGISTER_HWACCEL(MPEG4_VAAPI,       mpeg4_vaapi);
     REGISTER_HWACCEL(MPEG4_VDPAU,       mpeg4_vdpau);
+    REGISTER_HWACCEL(VC1_D3D11VA,       vc1_d3d11va);
     REGISTER_HWACCEL(VC1_DXVA2,         vc1_dxva2);
     REGISTER_HWACCEL(VC1_VAAPI,         vc1_vaapi);
     REGISTER_HWACCEL(VC1_VDPAU,         vc1_vdpau);
+    REGISTER_HWACCEL(WMV3_D3D11VA,      wmv3_d3d11va);
     REGISTER_HWACCEL(WMV3_DXVA2,        wmv3_dxva2);
     REGISTER_HWACCEL(WMV3_VAAPI,        wmv3_vaapi);
     REGISTER_HWACCEL(WMV3_VDPAU,        wmv3_vdpau);
diff --git a/libavcodec/d3d11va.c b/libavcodec/d3d11va.c
new file mode 100644
index 0000000..9bbe420
--- /dev/null
+++ b/libavcodec/d3d11va.c
@@ -0,0 +1,24 @@
+/*
+ * Direct3D11 HW acceleration.
+ *
+ * copyright (c) 2010 Laurent Aimar
+ * copyright (c) 2015 Steve Lhomme
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "d3d11va_internal.h"
+#include "dxva2.c"
diff --git a/libavcodec/d3d11va.h b/libavcodec/d3d11va.h
new file mode 100644
index 0000000..bc2852e
--- /dev/null
+++ b/libavcodec/d3d11va.h
@@ -0,0 +1,98 @@
+/*
+ * Direct3D11 HW acceleration
+ *
+ * copyright (c) 2009 Laurent Aimar
+ * copyright (c) 2015 Steve Lhomme
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_D3D11VA_H
+#define AVCODEC_D3D11VA_H
+
+/**
+ * @file
+ * @ingroup lavc_codec_hwaccel_d3d11va
+ * Public libavcodec D3D11VA header.
+ */
+
+#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#endif
+
+#include <stdint.h>
+#include <d3d11.h>
+
+/**
+ * @defgroup lavc_codec_hwaccel_d3d11va Direct3D11
+ * @ingroup lavc_codec_hwaccel
+ *
+ * @{
+ */
+
+#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for 
Direct3D11 and old UVD/UVD+ ATI video cards
+#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO    2 ///< Work around for 
Direct3D11 and old Intel GPUs with ClearVideo interface
+
+/**
+ * This structure is used to provides the necessary configurations and data
+ * to the Direct3D11 Libav HWAccel implementation.
+ *
+ * The application must make it available as AVCodecContext.hwaccel_context.
+ */
+struct av_d3d11va_context {
+    /**
+     * D3D11 decoder object
+     */
+    ID3D11VideoDecoder *decoder;
+
+    /**
+      * D3D11 VideoContext
+      */
+    ID3D11VideoContext *video_context;
+
+    /**
+     * D3D11 configuration used to create the decoder
+     */
+    D3D11_VIDEO_DECODER_CONFIG *cfg;
+
+    /**
+     * The number of surface in the surface array
+     */
+    unsigned surface_count;
+
+    /**
+     * The array of Direct3D surfaces used to create the decoder
+     */
+    ID3D11VideoDecoderOutputView **surface;
+
+    /**
+     * A bit field configuring the workarounds needed for using the decoder
+     */
+    uint64_t workaround;
+
+    /**
+     * Private to the Libav AVHWAccel implementation
+     */
+    unsigned report_id;
+};
+
+/**
+ * @}
+ */
+
+#endif /* AVCODEC_D3D11VA_H */
diff --git a/libavcodec/d3d11va_h264.c b/libavcodec/d3d11va_h264.c
new file mode 100644
index 0000000..90d64c5
--- /dev/null
+++ b/libavcodec/d3d11va_h264.c
@@ -0,0 +1,41 @@
+/*
+ * Direct3D11 H264 HW acceleration.
+ *
+ * copyright (c) 2009 Laurent Aimar
+ * copyright (c) 2015 Steve Lhomme
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "d3d11va_internal.h"
+
+#define dxva2_h264_start_frame   d3d11va_h264_start_frame
+#define dxva2_h264_decode_slice  d3d11va_h264_decode_slice
+#define dxva2_h264_end_frame     d3d11va_h264_end_frame
+
+#include "dxva_h264_template.c"
+
+AVHWAccel ff_h264_d3d11va_hwaccel = {
+    .name           = "h264_d3d11va",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_H264,
+    .pix_fmt        = AV_PIX_FMT_D3D11VA_VLD,
+    .start_frame    = d3d11va_h264_start_frame,
+    .decode_slice   = d3d11va_h264_decode_slice,
+    .end_frame      = d3d11va_h264_end_frame,
+    .frame_priv_data_size = sizeof(struct dxva2_picture_context),
+};
diff --git a/libavcodec/d3d11va_hevc.c b/libavcodec/d3d11va_hevc.c
new file mode 100644
index 0000000..b998184
--- /dev/null
+++ b/libavcodec/d3d11va_hevc.c
@@ -0,0 +1,41 @@
+/*
+ * Direct3D11 HEVC HW acceleration.
+ *
+ * copyright (c) 2014 - 2015 Hendrik Leppkes
+ * copyright (c) 2015 Steve Lhomme
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "d3d11va_internal.h"
+
+#define dxva2_hevc_start_frame   d3d11va_hevc_start_frame
+#define dxva2_hevc_decode_slice  d3d11va_hevc_decode_slice
+#define dxva2_hevc_end_frame     d3d11va_hevc_end_frame
+
+#include "dxva_hevc_template.c"
+
+AVHWAccel ff_hevc_d3d11va_hwaccel = {
+    .name           = "hevc_d3d11va",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_HEVC,
+    .pix_fmt        = AV_PIX_FMT_D3D11VA_VLD,
+    .start_frame    = d3d11va_hevc_start_frame,
+    .decode_slice   = d3d11va_hevc_decode_slice,
+    .end_frame      = d3d11va_hevc_end_frame,
+    .frame_priv_data_size = sizeof(struct hevc_dxva2_picture_context),
+};
diff --git a/libavcodec/d3d11va_internal.h b/libavcodec/d3d11va_internal.h
new file mode 100644
index 0000000..b43fb32
--- /dev/null
+++ b/libavcodec/d3d11va_internal.h
@@ -0,0 +1,56 @@
+/*
+ * Direct3D11 HW acceleration
+ *
+ * copyright (c) 2010 Laurent Aimar
+ * copyright (c) 2015 Steve Lhomme
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_D3D11VA_INTERNAL_H
+#define AVCODEC_D3D11VA_INTERNAL_H
+
+#define COBJMACROS
+
+#include "d3d11va.h"
+#include <dxva.h>
+
+#define dxva_context                      av_d3d11va_context
+#define dxva_surface_t                    ID3D11VideoDecoderOutputView
+#define DECODER_BUFFER_DESC               D3D11_VIDEO_DECODER_BUFFER_DESC
+#define DECODER_BUFFER_TYPE               D3D11_VIDEO_DECODER_BUFFER_TYPE
+#define DECODER_GET_BUFFER(ctx,t,b,s)     
ID3D11VideoContext_GetDecoderBuffer(ctx->video_context, ctx->decoder, t,s,b)
+#define DECODER_SUBMIT_BUFFER(ctx,b,c)    
ID3D11VideoContext_SubmitDecoderBuffers(ctx->video_context, ctx->decoder, c,b)
+#define DECODER_RELEASE_BUFFER(ctx,t)     
ID3D11VideoContext_ReleaseDecoderBuffer(ctx->video_context, ctx->decoder, t)
+#define DECODER_BEGIN_FRAME(ctx,s)        
ID3D11VideoContext_DecoderBeginFrame(ctx->video_context, ctx->decoder, s, 0, 
NULL)
+#define DECODER_END_FRAME(ctx)            
ID3D11VideoContext_DecoderEndFrame(ctx->video_context, ctx->decoder)
+
+#define DECODER_BUFTYPE_PICTURE_PARAMS    
D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS
+#define DECODER_BUFTYPE_QUANT_MATRIX      
D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX
+#define DECODER_BUFTYPE_BITSTREAM         D3D11_VIDEO_DECODER_BUFFER_BITSTREAM
+#define DECODER_BUFTYPE_SLICE_CONTROL     
D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL
+
+#define DECODER_BUFFER_DESC_SET_TYPE(dsc, type)   dsc->BufferType = type
+
+#define ff_dxva2_get_surface(f)                        
ff_d3d11va_get_surface(f)
+#define ff_dxva2_get_surface_index(c, f)               
ff_d3d11va_get_surface_index(c, f)
+#define ff_dxva2_commit_buffer(ctx,dc,d,t,p,ps,c)      
ff_d3d11va_commit_buffer(ctx,dc,d,t,p,ps,c)
+#define ff_dxva2_common_end_frame(ctx,f,p,ps,q,qs,cb)  
ff_d3d11va_common_end_frame(ctx,f,p,ps,q,qs,cb)
+
+#include "dxva_internal_template.h"
+
+#endif /* AVCODEC_D3D11VA_INTERNAL_H */
diff --git a/libavcodec/d3d11va_mpeg2.c b/libavcodec/d3d11va_mpeg2.c
new file mode 100644
index 0000000..6c46382
--- /dev/null
+++ b/libavcodec/d3d11va_mpeg2.c
@@ -0,0 +1,41 @@
+/*
+ * Direct3D11 MPEG-2 HW acceleration.
+ *
+ * copyright (c) 2010 Laurent Aimar
+ * copyright (c) 2015 Steve Lhomme
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "d3d11va_internal.h"
+
+#define dxva2_mpeg2_start_frame   d3d11va_mpeg2_start_frame
+#define dxva2_mpeg2_decode_slice  d3d11va_mpeg2_decode_slice
+#define dxva2_mpeg2_end_frame     d3d11va_mpeg2_end_frame
+
+#include "dxva_mpeg2_template.c"
+
+AVHWAccel ff_mpeg2_d3d11va_hwaccel = {
+    .name           = "mpeg2_d3d11va",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_MPEG2VIDEO,
+    .pix_fmt        = AV_PIX_FMT_D3D11VA_VLD,
+    .start_frame    = d3d11va_mpeg2_start_frame,
+    .decode_slice   = d3d11va_mpeg2_decode_slice,
+    .end_frame      = d3d11va_mpeg2_end_frame,
+    .frame_priv_data_size = sizeof(struct dxva2_picture_context),
+};
diff --git a/libavcodec/d3d11va_vc1.c b/libavcodec/d3d11va_vc1.c
new file mode 100644
index 0000000..69ca5c0
--- /dev/null
+++ b/libavcodec/d3d11va_vc1.c
@@ -0,0 +1,54 @@
+/*
+ * Direct3D11 WMV3/VC-1 HW acceleration.
+ *
+ * copyright (c) 2010 Laurent Aimar
+ * copyright (c) 2015 Steve Lhomme
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "d3d11va_internal.h"
+
+#define dxva2_vc1_start_frame   d3d11va_vc1_start_frame
+#define dxva2_vc1_decode_slice  d3d11va_vc1_decode_slice
+#define dxva2_vc1_end_frame     d3d11va_vc1_end_frame
+
+#include "dxva_vc1_template.c"
+
+#if CONFIG_WMV3_D3D11VA_HWACCEL
+AVHWAccel ff_wmv3_d3d11va_hwaccel = {
+    .name           = "wmv3_d3d11va",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_WMV3,
+    .pix_fmt        = AV_PIX_FMT_D3D11VA_VLD,
+    .start_frame    = d3d11va_vc1_start_frame,
+    .decode_slice   = d3d11va_vc1_decode_slice,
+    .end_frame      = d3d11va_vc1_end_frame,
+    .frame_priv_data_size = sizeof(struct dxva2_picture_context),
+};
+#endif
+
+AVHWAccel ff_vc1_d3d11va_hwaccel = {
+    .name           = "vc1_d3d11va",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_VC1,
+    .pix_fmt        = AV_PIX_FMT_D3D11VA_VLD,
+    .start_frame    = d3d11va_vc1_start_frame,
+    .decode_slice   = d3d11va_vc1_decode_slice,
+    .end_frame      = d3d11va_vc1_end_frame,
+    .frame_priv_data_size = sizeof(struct dxva2_picture_context),
+};
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index a250237..1cee634 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -861,6 +861,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h)
 #if CONFIG_H264_DXVA2_HWACCEL
             *fmt++ = AV_PIX_FMT_DXVA2_VLD;
 #endif
+#if CONFIG_H264_D3D11VA_HWACCEL
+            *fmt++ = AV_PIX_FMT_D3D11VA_VLD;
+#endif
 #if CONFIG_H264_VAAPI_HWACCEL
             *fmt++ = AV_PIX_FMT_VAAPI_VLD;
 #endif
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 4c06fb8..a6ee773 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -446,6 +446,9 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
 #if CONFIG_HEVC_DXVA2_HWACCEL
         *fmt++ = AV_PIX_FMT_DXVA2_VLD;
 #endif
+#if CONFIG_HEVC_D3D11VA_HWACCEL
+        *fmt++ = AV_PIX_FMT_D3D11VA_VLD;
+#endif
     }
 
     *fmt++ = sps->pix_fmt;
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 6ed151a..e8eaa86 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1175,6 +1175,9 @@ static const enum AVPixelFormat 
mpeg12_hwaccel_pixfmt_list_420[] = {
 #if CONFIG_MPEG2_DXVA2_HWACCEL
     AV_PIX_FMT_DXVA2_VLD,
 #endif
+#if CONFIG_MPEG2_D3D11VA_HWACCEL
+    AV_PIX_FMT_D3D11VA_VLD,
+#endif
 #if CONFIG_MPEG2_VAAPI_HWACCEL
     AV_PIX_FMT_VAAPI_VLD,
 #endif
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 0d578cd..b027d08 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -954,6 +954,9 @@ static const enum AVPixelFormat 
vc1_hwaccel_pixfmt_list_420[] = {
 #if CONFIG_VC1_DXVA2_HWACCEL
     AV_PIX_FMT_DXVA2_VLD,
 #endif
+#if CONFIG_VC1_D3D11VA_HWACCEL
+    AV_PIX_FMT_D3D11VA_VLD,
+#endif
 #if CONFIG_VC1_VAAPI_HWACCEL
     AV_PIX_FMT_VAAPI_VLD,
 #endif
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index ea432f9..6a4f35d 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1339,6 +1339,12 @@ const AVPixFmtDescriptor 
av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
         .log2_chroma_h = 1,
         .flags = AV_PIX_FMT_FLAG_HWACCEL,
     },
+    [AV_PIX_FMT_D3D11VA_VLD] = {
+        .name = "d3d11va_vld",
+        .log2_chroma_w = 1,
+        .log2_chroma_h = 1,
+        .flags = AV_PIX_FMT_FLAG_HWACCEL,
+    },
     [AV_PIX_FMT_YA8] = {
         .name = "ya8",
         .nb_components = 2,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index e21100f..38f47f1 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -220,6 +220,11 @@ enum AVPixelFormat {
      */
     AV_PIX_FMT_MMAL,
 
+    /**
+     * HW decoding through Direct3D11, Picture.data[3] contains a 
ID3D11VideoDecoderOutputView pointer
+     */
+    AV_PIX_FMT_D3D11VA_VLD,
+
     AV_PIX_FMT_NB,        ///< number of pixel formats, DO NOT USE THIS if you 
want to link with shared libav* because the number of formats might differ 
between versions
 
 #if FF_API_PIX_FMT
-- 
2.4.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to