On Tue, 13 Dec 2016 14:19:03 +0100
Steve Lhomme <rob...@gmail.com> wrote:

> From: Steve Lhomme <rob...@videolabs.io>
> 
> The code is similar to avconv_dxva2. The decoded output needs to be copied 
> into
> a staging texture that can be accessed by the CPU as the decoder texture can't
> be accessed by the CPU.
> ---
>  Makefile                       |   1 +
>  avconv.h                       |   2 +
>  avconv_d3d11va.c               | 410 
> +++++++++++++++++++++++++++++++++++++++++
>  avconv_opt.c                   |   3 +
>  configure                      |  14 ++
>  libavutil/Makefile             |   3 +
>  libavutil/hwcontext.c          |   3 +
>  libavutil/hwcontext.h          |   1 +
>  libavutil/hwcontext_internal.h |   1 +
>  libavutil/version.h            |   2 +-
>  10 files changed, 439 insertions(+), 1 deletion(-)
>  create mode 100644 avconv_d3d11va.c
> 
> diff --git a/Makefile b/Makefile
> index d4c2b8e..d604827 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -85,6 +85,7 @@ OBJS-avconv                   += avconv_opt.o 
> avconv_filter.o
>  OBJS-avconv-$(CONFIG_LIBMFX)  += avconv_qsv.o
>  OBJS-avconv-$(CONFIG_VAAPI)   += avconv_vaapi.o
>  OBJS-avconv-$(CONFIG_VDA)     += avconv_vda.o
> +OBJS-avconv-$(HAVE_D3D11VA_LIB) += avconv_d3d11va.o
>  OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o
>  OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o
>  
> diff --git a/avconv.h b/avconv.h
> index 6360f76..fcaf84e 100644
> --- a/avconv.h
> +++ b/avconv.h
> @@ -52,6 +52,7 @@ enum HWAccelID {
>      HWACCEL_NONE = 0,
>      HWACCEL_AUTO,
>      HWACCEL_VDPAU,
> +    HWACCEL_D3D11VA,
>      HWACCEL_DXVA2,
>      HWACCEL_VDA,
>      HWACCEL_QSV,
> @@ -498,6 +499,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, 
> const AVFrame *frame);
>  int avconv_parse_options(int argc, char **argv);
>  
>  int vdpau_init(AVCodecContext *s);
> +int d3d11va_init(AVCodecContext *s);
>  int dxva2_init(AVCodecContext *s);
>  int vda_init(AVCodecContext *s);
>  int qsv_init(AVCodecContext *s);
> diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c
> new file mode 100644
> index 0000000..41c7354
> --- /dev/null
> +++ b/avconv_d3d11va.c
> @@ -0,0 +1,410 @@
> +/*
> + * 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 <windows.h>
> +
> +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600
> +#undef _WIN32_WINNT
> +#define _WIN32_WINNT 0x0600
> +#endif
> +#define COBJMACROS
> +
> +#include <stdint.h>
> +
> +#include <d3d11.h>
> +
> +#include "avconv.h"
> +
> +#include "libavcodec/d3d11va.h"
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/buffer.h"
> +#include "libavutil/frame.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/pixfmt.h"
> +
> +#include "libavutil/hwcontext.h"
> +#include "libavutil/hwcontext_d3d11va.h"
> +
> +/* define all the GUIDs used directly here,
> +   to avoid problems with inconsistent dxva2api.h versions in mingw-w64 and 
> different MSVC version */
> +#include <initguid.h>
> +DEFINE_GUID(DXVA2_ModeMPEG2_VLD,      0xee27417f, 
> 0x5e28,0x4e65,0xbe,0xea,0x1d,0x26,0xb5,0x08,0xad,0xc9);
> +DEFINE_GUID(DXVA2_ModeMPEG2and1_VLD,  0x86695f12, 
> 0x340e,0x4f04,0x9f,0xd3,0x92,0x53,0xdd,0x32,0x74,0x60);
> +DEFINE_GUID(DXVA2_ModeH264_E,         0x1b81be68, 
> 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
> +DEFINE_GUID(DXVA2_ModeH264_F,         0x1b81be69, 
> 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
> +DEFINE_GUID(DXVADDI_Intel_ModeH264_E, 0x604F8E68, 
> 0x4951,0x4C54,0x88,0xFE,0xAB,0xD2,0x5C,0x15,0xB3,0xD6);
> +DEFINE_GUID(DXVA2_ModeVC1_D,          0x1b81beA3, 
> 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
> +DEFINE_GUID(DXVA2_ModeVC1_D2010,      0x1b81beA4, 
> 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
> +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main,  0x5b11d51b, 
> 0x2f4c,0x4452,0xbc,0xc3,0x09,0xf2,0xa1,0x16,0x0c,0xc0);
> +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 
> 0xef1a,0x4d19,0xab,0xa8,0x67,0xa1,0x63,0x07,0x3d,0x13);
> +DEFINE_GUID(DXVA2_NoEncrypt,          0x1b81beD0, 
> 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
> +
> +typedef struct d3d11va_mode {
> +  const GUID     *guid;
> +  enum AVCodecID codec;
> +} d3d11va_mode;
> +
> +static const d3d11va_mode d3d11va_modes[] = {
> +    /* MPEG-2 */
> +    { &DXVA2_ModeMPEG2_VLD,      AV_CODEC_ID_MPEG2VIDEO },
> +    { &DXVA2_ModeMPEG2and1_VLD,  AV_CODEC_ID_MPEG2VIDEO },
> +
> +    /* H.264 */
> +    { &DXVA2_ModeH264_F,         AV_CODEC_ID_H264 },
> +    { &DXVA2_ModeH264_E,         AV_CODEC_ID_H264 },
> +    /* Intel specific H.264 mode */
> +    { &DXVADDI_Intel_ModeH264_E, AV_CODEC_ID_H264 },
> +
> +    /* VC-1 / WMV3 */
> +    { &DXVA2_ModeVC1_D2010,      AV_CODEC_ID_VC1  },
> +    { &DXVA2_ModeVC1_D2010,      AV_CODEC_ID_WMV3 },
> +    { &DXVA2_ModeVC1_D,          AV_CODEC_ID_VC1  },
> +    { &DXVA2_ModeVC1_D,          AV_CODEC_ID_WMV3 },
> +
> +    /* HEVC/H.265 */
> +    { &DXVA2_ModeHEVC_VLD_Main,  AV_CODEC_ID_HEVC },
> +    { &DXVA2_ModeHEVC_VLD_Main10, AV_CODEC_ID_HEVC },
> +
> +    { NULL,                      0 },
> +};
> +
> +typedef struct D3D11VAContext {
> +    D3D11_VIDEO_DECODER_CONFIG   decoder_config;
> +
> +    AVFrame                     *tmp_frame;
> +
> +    AVBufferRef                 *hw_device_ctx;
> +    AVBufferRef                 *hw_frames_ctx;
> +} D3D11VAContext;
> +
> +static void d3d11va_uninit(AVCodecContext *s)
> +{
> +    InputStream  *ist = s->opaque;
> +    D3D11VAContext *ctx = ist->hwaccel_ctx;
> +
> +    ist->hwaccel_uninit        = NULL;
> +    ist->hwaccel_get_buffer    = NULL;
> +    ist->hwaccel_retrieve_data = NULL;
> +
> +    av_buffer_unref(&ctx->hw_frames_ctx);
> +    av_buffer_unref(&ctx->hw_device_ctx);
> +
> +    av_frame_free(&ctx->tmp_frame);
> +
> +    av_freep(&ist->hwaccel_ctx);
> +    av_freep(&s->hwaccel_context);
> +}
> +
> +static int d3d11va_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
> +{
> +    InputStream  *ist = s->opaque;
> +    D3D11VAContext *ctx = ist->hwaccel_ctx;
> +
> +    return av_hwframe_get_buffer(ctx->hw_frames_ctx, frame, 0);
> +}
> +
> +static int d3d11va_retrieve_data(AVCodecContext *s, AVFrame *frame)
> +{
> +    InputStream        *ist = s->opaque;
> +    D3D11VAContext     *ctx = ist->hwaccel_ctx;
> +    int                ret;
> +
> +    ret = av_hwframe_transfer_data(ctx->tmp_frame, frame, 0);
> +    if (ret < 0)
> +        return ret;
> +
> +    ret = av_frame_copy_props(ctx->tmp_frame, frame);
> +    if (ret < 0) {
> +        av_frame_unref(ctx->tmp_frame);
> +        return ret;
> +    }
> +
> +    av_frame_unref(frame);
> +    av_frame_move_ref(frame, ctx->tmp_frame);
> +
> +    return 0;
> +}
> +
> +static int d3d11va_alloc(AVCodecContext *s)
> +{
> +    InputStream  *ist = s->opaque;
> +    D3D11VAContext *ctx;
> +
> +    int ret;
> +
> +    ctx = av_mallocz(sizeof(*ctx));
> +    if (!ctx)
> +        return AVERROR(ENOMEM);
> +
> +    ist->hwaccel_ctx           = ctx;
> +    ist->hwaccel_uninit        = d3d11va_uninit;
> +    ist->hwaccel_get_buffer    = d3d11va_get_buffer;
> +    ist->hwaccel_retrieve_data = d3d11va_retrieve_data;
> +
> +    ret = av_hwdevice_ctx_create(&ctx->hw_device_ctx, 
> AV_HWDEVICE_TYPE_D3D11VA,
> +                                 ist->hwaccel_device, NULL, 0);
> +    if (ret < 0)
> +        goto fail;
> +
> +    ctx->tmp_frame = av_frame_alloc();
> +    if (!ctx->tmp_frame)
> +        goto fail;
> +
> +    s->hwaccel_context = av_mallocz(sizeof(AVD3D11VAContext));
> +    if (!s->hwaccel_context)
> +        goto fail;
> +
> +    return 0;
> +fail:
> +    d3d11va_uninit(s);
> +    return AVERROR(EINVAL);
> +}
> +
> +static int d3d11va_get_decoder_configuration(AVCodecContext *s,
> +                                           const D3D11_VIDEO_DECODER_DESC 
> *desc,
> +                                           D3D11_VIDEO_DECODER_CONFIG 
> *config)
> +{
> +    InputStream  *ist = s->opaque;
> +    int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : 
> AV_LOG_ERROR;
> +    D3D11VAContext *ctx = ist->hwaccel_ctx;
> +    unsigned cfg_count = 0, best_score = 0;
> +    D3D11_VIDEO_DECODER_CONFIG best_cfg = {{0}};
> +    HRESULT hr;
> +    int i;
> +    AVHWDeviceContext    *device_ctx = 
> (AVHWDeviceContext*)ctx->hw_device_ctx->data;
> +    AVD3D11VADeviceContext *device_hwctx = device_ctx->hwctx;
> +
> +    hr = 
> ID3D11VideoDevice_GetVideoDecoderConfigCount(device_hwctx->video_device, 
> desc, &cfg_count);
> +    if (FAILED(hr)) {
> +        av_log(NULL, loglevel, "Unable to retrieve decoder 
> configurations\n");
> +        return AVERROR(EINVAL);
> +    }
> +
> +    for (i = 0; i < cfg_count; i++) {
> +        unsigned score;
> +        D3D11_VIDEO_DECODER_CONFIG cfg;
> +        hr = 
> ID3D11VideoDevice_GetVideoDecoderConfig(device_hwctx->video_device, desc, i, 
> &cfg );
> +        if (FAILED(hr)) {
> +            av_log(NULL, loglevel, "Unable to retrieve decoder 
> configurations. (hr=0x%lX)\n", hr);
> +            return AVERROR(EINVAL);
> +        }
> +
> +        if (cfg.ConfigBitstreamRaw == 1)
> +            score = 1;
> +        else if (s->codec_id == AV_CODEC_ID_H264 && cfg.ConfigBitstreamRaw 
> == 2)
> +            score = 2;
> +        else
> +            continue;
> +        if (IsEqualGUID(&cfg.guidConfigBitstreamEncryption, 
> &DXVA2_NoEncrypt))
> +            score += 16;
> +        if (score > best_score) {
> +            best_score = score;
> +            best_cfg   = cfg;
> +        }
> +    }
> +
> +    if (!best_score) {
> +        av_log(NULL, loglevel, "No valid decoder configuration available\n");
> +        return AVERROR(EINVAL);
> +    }
> +
> +    *config = best_cfg;
> +    return 0;
> +}
> +
> +static int d3d11va_create_decoder(AVCodecContext *s)
> +{
> +    InputStream  *ist = s->opaque;
> +    int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : 
> AV_LOG_ERROR;
> +    D3D11VAContext *ctx = ist->hwaccel_ctx;
> +    AVD3D11VAContext *dxva_ctx = s->hwaccel_context;
> +    GUID *guid_list = NULL;
> +    unsigned guid_count = 0, i, j;
> +    GUID device_guid = GUID_NULL;
> +    const DXGI_FORMAT surface_format = (s->sw_pix_fmt == 
> AV_PIX_FMT_YUV420P10) ? DXGI_FORMAT_P010 : DXGI_FORMAT_NV12;
> +    DXGI_FORMAT target_format = DXGI_FORMAT_UNKNOWN;
> +    D3D11_VIDEO_DECODER_DESC desc = { 0 };
> +    D3D11_VIDEO_DECODER_CONFIG config;
> +    HRESULT hr;
> +    int surface_alignment, num_surfaces;
> +    int ret;
> +
> +    AVD3D11VAFramesContext *frames_hwctx;
> +    AVHWFramesContext *frames_ctx;
> +
> +    AVHWDeviceContext    *device_ctx;
> +    AVD3D11VADeviceContext *device_hwctx;
> +    device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data;
> +    device_hwctx = device_ctx->hwctx;
> +
> +    guid_count = 
> ID3D11VideoDevice_GetVideoDecoderProfileCount(device_hwctx->video_device);
> +    guid_list = av_malloc(sizeof(*guid_list) * guid_count);
> +    if (guid_list==NULL) {
> +        av_log(NULL, loglevel, "Failed to allocate decoder device GUIDs\n");
> +        goto fail;
> +    }
> +    for (i=0; i<guid_count; i++) {
> +        hr = 
> ID3D11VideoDevice_GetVideoDecoderProfile(device_hwctx->video_device, i, 
> &guid_list[i]);
> +        if (FAILED(hr)) {
> +            av_log(NULL, loglevel, "Failed to retrieve decoder GUID %d\n", 
> i);
> +            goto fail;
> +        }
> +    }
> +
> +    for (i = 0; d3d11va_modes[i].guid; i++) {
> +        BOOL is_supported = FALSE;
> +        const d3d11va_mode *mode = &d3d11va_modes[i];
> +        if (mode->codec != s->codec_id)
> +            continue;
> +
> +        for (j = 0; j < guid_count; j++) {
> +            if (IsEqualGUID(mode->guid, &guid_list[j]))
> +                break;
> +        }
> +        if (j == guid_count)
> +            continue;
> +
> +        hr = 
> ID3D11VideoDevice_CheckVideoDecoderFormat(device_hwctx->video_device, 
> mode->guid,
> +                                                       surface_format, 
> &is_supported);
> +        if (SUCCEEDED(hr) && is_supported) {
> +            target_format = surface_format;
> +            device_guid = *mode->guid;
> +            break;
> +        }
> +    }
> +
> +    if (IsEqualGUID(&device_guid, &GUID_NULL)) {
> +        av_log(NULL, loglevel, "No decoder device for codec found\n");
> +        goto fail;
> +    }
> +
> +    desc.SampleWidth  = s->coded_width;
> +    desc.SampleHeight = s->coded_height;
> +    desc.OutputFormat = target_format;
> +    desc.Guid         = device_guid;
> +
> +    ret = d3d11va_get_decoder_configuration(s, &desc, &config);
> +    if (ret < 0) {
> +        goto fail;
> +    }
> +
> +    /* decoding MPEG-2 requires additional alignment on some Intel GPUs,
> +       but it causes issues for H.264 on certain AMD GPUs..... */
> +    if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO)
> +        surface_alignment = 32;
> +    /* the HEVC DXVA2 spec asks for 128 pixel aligned surfaces to ensure
> +       all coding features have enough room to work with */
> +    else if  (s->codec_id == AV_CODEC_ID_HEVC)
> +        surface_alignment = 128;
> +    else
> +        surface_alignment = 16;
> +
> +    /* 4 base work surfaces */
> +    num_surfaces = 4;
> +
> +    /* add surfaces based on number of possible refs */
> +    if (s->codec_id == AV_CODEC_ID_H264 || s->codec_id == AV_CODEC_ID_HEVC)
> +        num_surfaces += 16;
> +    else
> +        num_surfaces += 2;
> +
> +    /* add extra surfaces for frame threading */
> +    if (s->active_thread_type & FF_THREAD_FRAME)
> +        num_surfaces += s->thread_count;
> +
> +    ctx->hw_frames_ctx = av_hwframe_ctx_alloc(ctx->hw_device_ctx);
> +    if (!ctx->hw_frames_ctx)
> +        goto fail;
> +    frames_ctx   = (AVHWFramesContext*)ctx->hw_frames_ctx->data;
> +    frames_hwctx = frames_ctx->hwctx;
> +
> +    frames_ctx->format            = AV_PIX_FMT_D3D11VA_VLD;
> +    frames_ctx->sw_format         = (target_format == DXGI_FORMAT_P010 ? 
> AV_PIX_FMT_P010 : AV_PIX_FMT_NV12);
> +    frames_ctx->width             = FFALIGN(s->coded_width, 
> surface_alignment);
> +    frames_ctx->height            = FFALIGN(s->coded_height, 
> surface_alignment);
> +    frames_ctx->initial_pool_size = num_surfaces;
> +
> +    hr = ID3D11VideoDevice_CreateVideoDecoder(device_hwctx->video_device, 
> &desc,
> +                                              &config, 
> &frames_hwctx->decoder_to_release);
> +    if (FAILED(hr)) {
> +        av_log(NULL, loglevel, "Failed to create D3D11VA video decoder\n");
> +        goto fail;
> +    }
> +
> +    ret = av_hwframe_ctx_init(ctx->hw_frames_ctx);
> +    if (ret < 0) {
> +        av_log(NULL, loglevel, "Failed to initialize the HW frames 
> context\n");
> +        goto fail;
> +    }
> +
> +    ctx->decoder_config = config;
> +
> +    dxva_ctx->cfg           = &ctx->decoder_config;
> +    dxva_ctx->decoder       = frames_hwctx->decoder_to_release;
> +    dxva_ctx->surface       = frames_hwctx->surfaces;
> +    dxva_ctx->surface_count = frames_hwctx->nb_surfaces;
> +    dxva_ctx->video_context = device_hwctx->video_context;
> +
> +    if (IsEqualGUID(&device_guid, &DXVADDI_Intel_ModeH264_E))
> +        dxva_ctx->workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
> +
> +    av_free(guid_list);
> +    return 0;
> +fail:
> +    av_free(guid_list);
> +    av_buffer_unref(&ctx->hw_frames_ctx);
> +    return AVERROR(EINVAL);
> +}
> +
> +int d3d11va_init(AVCodecContext *s)
> +{
> +    InputStream *ist = s->opaque;
> +    int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : 
> AV_LOG_ERROR;
> +    D3D11VAContext *ctx;
> +    int ret;
> +
> +    if (!ist->hwaccel_ctx) {
> +        ret = d3d11va_alloc(s);
> +        if (ret < 0)
> +            return ret;
> +    }
> +    ctx = ist->hwaccel_ctx;
> +
> +    if (s->codec_id == AV_CODEC_ID_H264 &&
> +        (s->profile & ~FF_PROFILE_H264_CONSTRAINED) > FF_PROFILE_H264_HIGH) {
> +        av_log(NULL, loglevel, "Unsupported H.264 profile for D3D11VA 
> HWAccel: %d\n", s->profile);
> +        return AVERROR(EINVAL);
> +    }
> +
> +    if (s->codec_id == AV_CODEC_ID_HEVC &&
> +        s->profile != FF_PROFILE_HEVC_MAIN && s->profile != 
> FF_PROFILE_HEVC_MAIN_10) {
> +        av_log(NULL, loglevel, "Unsupported HEVC profile for D3D11VA 
> HWAccel: %d\n", s->profile);
> +        return AVERROR(EINVAL);
> +    }
> +
> +    av_buffer_unref(&ctx->hw_frames_ctx);
> +
> +    ret = d3d11va_create_decoder(s);
> +    if (ret < 0) {
> +        av_log(NULL, loglevel, "Error creating the D3D11VA decoder\n");
> +        return ret;
> +    }
> +
> +    return 0;
> +}
> diff --git a/avconv_opt.c b/avconv_opt.c
> index 4d7140d..7f79dc1 100644
> --- a/avconv_opt.c
> +++ b/avconv_opt.c
> @@ -59,6 +59,9 @@ const HWAccel hwaccels[] = {
>  #if HAVE_VDPAU_X11
>      { "vdpau", vdpau_init, HWACCEL_VDPAU, AV_PIX_FMT_VDPAU },
>  #endif
> +#if HAVE_D3D11VA_LIB
> +    { "d3d11va", d3d11va_init, HWACCEL_D3D11VA, AV_PIX_FMT_D3D11VA_VLD },
> +#endif
>  #if HAVE_DXVA2_LIB
>      { "dxva2", dxva2_init, HWACCEL_DXVA2, AV_PIX_FMT_DXVA2_VLD },
>  #endif
> diff --git a/configure b/configure
> index 6d809f7..89e04db 100755
> --- a/configure
> +++ b/configure
> @@ -1677,6 +1677,8 @@ HAVE_LIST="
>      $TOOLCHAIN_FEATURES
>      $TYPES_LIST
>      dos_paths
> +    d3d11va_lib
> +    d3d11vaapi_cobj
>      dxva2_lib
>      libc_msvcrt
>      MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS
> @@ -4777,6 +4779,15 @@ if enabled libxcb; then
>      add_extralibs "$xcb_shape_extralibs $xcb_shm_extralibs 
> $xcb_xfixes_extralibs"
>  fi
>  
> +enabled d3d11_h &&
> +    check_cc <<EOF && enable d3d11vaapi_cobj
> +#define _WIN32_WINNT 0x0600
> +#define COBJMACROS
> +#include <windows.h>
> +#include <d3d11.h>
> +int main(void) { ID3D11VideoDevice *o = NULL; ID3D11VideoDevice_Release(o); 
> return 0; }
> +EOF
> +
>  enabled dxva2 &&
>      check_lib windows.h CoTaskMemFree -lole32 &&
>      enable dxva2_lib
> @@ -5059,6 +5070,9 @@ check_deps $CONFIG_LIST       \
>             $HAVE_LIST         \
>             $ALL_COMPONENTS    \
>  
> +enabled_all d3d11va d3d11vaapi_cobj &&
> +    enable d3d11va_lib
> +
>  map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
>  
>  for thread in $THREADS_LIST; do
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index f34c799..962dcf2 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -26,6 +26,7 @@ HEADERS = adler32.h                                         
>             \
>            hmac.h                                                        \
>            hwcontext.h                                                   \
>            hwcontext_cuda.h                                              \
> +          hwcontext_d3d11va.h                                           \
>            hwcontext_dxva2.h                                             \
>            hwcontext_qsv.h                                               \
>            hwcontext_vaapi.h                                             \
> @@ -111,6 +112,7 @@ OBJS = adler32.o                                          
>               \
>         xtea.o                                                           \
>  
>  OBJS-$(CONFIG_CUDA)                     += hwcontext_cuda.o
> +OBJS-$(CONFIG_D3D11VA)                  += hwcontext_d3d11va.o
>  OBJS-$(CONFIG_DXVA2)                    += hwcontext_dxva2.o
>  OBJS-$(CONFIG_LIBMFX)                   += hwcontext_qsv.o
>  OBJS-$(CONFIG_LZO)                      += lzo.o
> @@ -120,6 +122,7 @@ OBJS-$(CONFIG_VDPAU)                    += 
> hwcontext_vdpau.o
>  OBJS += $(COMPAT_OBJS:%=../compat/%)
>  
>  SKIPHEADERS-$(CONFIG_CUDA)             += hwcontext_cuda.h
> +SKIPHEADERS-$(CONFIG_D3D11VA)          += hwcontext_d3d11va.h
>  SKIPHEADERS-$(CONFIG_DXVA2)            += hwcontext_dxva2.h
>  SKIPHEADERS-$(CONFIG_LIBMFX)           += hwcontext_qsv.h
>  SKIPHEADERS-$(CONFIG_VAAPI)            += hwcontext_vaapi.h
> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
> index 83f733e..ae27c51 100644
> --- a/libavutil/hwcontext.c
> +++ b/libavutil/hwcontext.c
> @@ -32,6 +32,9 @@ static const HWContextType *hw_table[] = {
>  #if CONFIG_CUDA
>      &ff_hwcontext_type_cuda,
>  #endif
> +#if CONFIG_D3D11VA
> +    &ff_hwcontext_type_d3d11va,
> +#endif
>  #if CONFIG_DXVA2
>      &ff_hwcontext_type_dxva2,
>  #endif
> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
> index 037ca64..c93dd3a 100644
> --- a/libavutil/hwcontext.h
> +++ b/libavutil/hwcontext.h
> @@ -28,6 +28,7 @@ enum AVHWDeviceType {
>      AV_HWDEVICE_TYPE_VDPAU,
>      AV_HWDEVICE_TYPE_CUDA,
>      AV_HWDEVICE_TYPE_VAAPI,
> +    AV_HWDEVICE_TYPE_D3D11VA,
>      AV_HWDEVICE_TYPE_DXVA2,
>      AV_HWDEVICE_TYPE_QSV,
>  };
> diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h
> index 11e3a68..9083ce6 100644
> --- a/libavutil/hwcontext_internal.h
> +++ b/libavutil/hwcontext_internal.h
> @@ -140,6 +140,7 @@ int ff_hwframe_map_create(AVBufferRef *hwframe_ref,
>  
>  
>  extern const HWContextType ff_hwcontext_type_cuda;
> +extern const HWContextType ff_hwcontext_type_d3d11va;
>  extern const HWContextType ff_hwcontext_type_dxva2;
>  extern const HWContextType ff_hwcontext_type_qsv;
>  extern const HWContextType ff_hwcontext_type_vaapi;
> diff --git a/libavutil/version.h b/libavutil/version.h
> index f110231..6afaf8e 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -55,7 +55,7 @@
>  
>  #define LIBAVUTIL_VERSION_MAJOR 55
>  #define LIBAVUTIL_VERSION_MINOR 29
> -#define LIBAVUTIL_VERSION_MICRO  0
> +#define LIBAVUTIL_VERSION_MICRO  1
>  
>  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
>                                                 LIBAVUTIL_VERSION_MINOR, \

Same as I said on ffmpeg-devel.
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to