Skip to content

Commit

Permalink
dxva: add support for new dxva2 and d3d11 hwaccel APIs
Browse files Browse the repository at this point in the history
This also adds support to avconv (which is trivial due to the new
hwaccel API being generic enough).

The new decoder setup code in dxva2.c is significantly based on work by
Steve Lhomme <robux4@gmail.com>, but with heavy changes/rewrites.

Merges Libav commit f9e7a2f.
Also adds untested VP9 support.
The check for DXVA2 COBJs is removed. Just update your MinGW to
something newer than a 5 year old release.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
  • Loading branch information
wm4 committed Jun 27, 2017
1 parent 5659f74 commit 70143a3
Show file tree
Hide file tree
Showing 22 changed files with 885 additions and 476 deletions.
1 change: 1 addition & 0 deletions Changelog
Expand Up @@ -25,6 +25,7 @@ version <next>:
- The x86 assembler default switched from yasm to nasm, pass
--x86asmexe=yasm to configure to restore the old behavior.
- additional frame format support for Interplay MVE movies
- support for decoding through D3D11VA in ffmpeg

version 3.3:
- CrystalHD decoder moved to new decode API
Expand Down
1 change: 0 additions & 1 deletion Makefile
Expand Up @@ -38,7 +38,6 @@ ifndef CONFIG_VIDEOTOOLBOX
OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o
endif
OBJS-ffmpeg-$(CONFIG_CUVID) += ffmpeg_cuvid.o
OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o
OBJS-ffserver += ffserver_config.o

TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
Expand Down
30 changes: 13 additions & 17 deletions configure
Expand Up @@ -2056,8 +2056,6 @@ HAVE_LIST="
alsa
atomics_native
dos_paths
dxva2_lib
dxva2api_cobj
jack
libc_msvcrt
makeinfo
Expand Down Expand Up @@ -2594,9 +2592,8 @@ crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
cuda_deps_any="dlopen LoadLibrary"
cuvid_deps="cuda"
d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder ID3D11VideoContext"
dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode"
dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32"
dxva2_extralibs="-luser32"
dxva2_lib_deps="dxva2"
vda_framework_deps="VideoDecodeAcceleration_VDADecoder_h blocks_extension"
vda_framework_extralibs="-framework VideoDecodeAcceleration"
vda_deps="vda_framework pthreads"
Expand All @@ -2613,6 +2610,8 @@ h264_cuvid_hwaccel_deps="cuda cuvid"
h264_cuvid_hwaccel_select="h264_cuvid_decoder"
h264_d3d11va_hwaccel_deps="d3d11va"
h264_d3d11va_hwaccel_select="h264_decoder"
h264_d3d11va2_hwaccel_deps="d3d11va"
h264_d3d11va2_hwaccel_select="h264_decoder"
h264_dxva2_hwaccel_deps="dxva2"
h264_dxva2_hwaccel_select="h264_decoder"
h264_mediacodec_hwaccel_deps="mediacodec"
Expand All @@ -2633,6 +2632,8 @@ hevc_cuvid_hwaccel_select="hevc_cuvid_decoder"
hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
hevc_d3d11va_hwaccel_select="hevc_decoder"
hevc_mediacodec_hwaccel_deps="mediacodec"
hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
hevc_d3d11va2_hwaccel_select="hevc_decoder"
hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
hevc_dxva2_hwaccel_select="hevc_decoder"
hevc_qsv_hwaccel_deps="libmfx"
Expand All @@ -2656,6 +2657,8 @@ mpeg2_cuvid_hwaccel_deps="cuda cuvid"
mpeg2_cuvid_hwaccel_select="mpeg2_cuvid_decoder"
mpeg2_d3d11va_hwaccel_deps="d3d11va"
mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
mpeg2_d3d11va2_hwaccel_deps="d3d11va"
mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder"
mpeg2_dxva2_hwaccel_deps="dxva2"
mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
mpeg2_mediacodec_hwaccel_deps="mediacodec"
Expand Down Expand Up @@ -2684,6 +2687,8 @@ vc1_cuvid_hwaccel_deps="cuda cuvid"
vc1_cuvid_hwaccel_select="vc1_cuvid_decoder"
vc1_d3d11va_hwaccel_deps="d3d11va"
vc1_d3d11va_hwaccel_select="vc1_decoder"
vc1_d3d11va2_hwaccel_deps="d3d11va"
vc1_d3d11va2_hwaccel_select="vc1_decoder"
vc1_dxva2_hwaccel_deps="dxva2"
vc1_dxva2_hwaccel_select="vc1_decoder"
vc1_mmal_hwaccel_deps="mmal"
Expand All @@ -2701,12 +2706,15 @@ vp8_mediacodec_hwaccel_deps="mediacodec"
vp8_qsv_hwaccel_deps="libmfx"
vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
vp9_d3d11va_hwaccel_select="vp9_decoder"
vp9_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
vp9_d3d11va2_hwaccel_select="vp9_decoder"
vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9"
vp9_dxva2_hwaccel_select="vp9_decoder"
vp9_mediacodec_hwaccel_deps="mediacodec"
vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth"
vp9_vaapi_hwaccel_select="vp9_decoder"
wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel"
wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
Expand Down Expand Up @@ -5705,6 +5713,7 @@ check_header asm/types.h
# so we also check that atomics actually work here
check_builtin stdatomic_h stdatomic.h "atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0)"

check_lib ole32 "windows.h" CoTaskMemFree -lole32
check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32
check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom -ladvapi32
check_lib psapi "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
Expand Down Expand Up @@ -6111,19 +6120,6 @@ fi

check_func_headers "windows.h" CreateDIBSection "$gdigrab_indev_extralibs"

enabled dxva2api_h &&
check_cc <<EOF && enable dxva2api_cobj
#define _WIN32_WINNT 0x0600
#define COBJMACROS
#include <windows.h>
#include <d3d9.h>
#include <dxva2api.h>
int main(void) { IDirectXVideoDecoder *o = NULL; IDirectXVideoDecoder_Release(o); return 0; }
EOF

enabled dxva2 &&
check_lib dxva2_lib windows.h CoTaskMemFree -lole32

enabled vaapi &&
check_lib vaapi va/va.h vaInitialize -lva

Expand Down
6 changes: 6 additions & 0 deletions doc/APIchanges
Expand Up @@ -15,6 +15,12 @@ libavutil: 2015-08-28

API changes, most recent first:

2017-xx-xx - xxxxxxx - lavc 57.100.100 - avcodec.h
DXVA2 and D3D11 hardware accelerated decoding now supports the new hwaccel API,
which can create the decoder context and allocate hardware frame automatically.
See AVCodecContext.hw_device_ctx and AVCodecContext.hw_frames_ctx. For D3D11,
the new AV_PIX_FMT_D3D11 pixfmt must be used with the new API.

2017-xx-xx - xxxxxxx - lavu 56.67.100 - hwcontext.h
Add AV_HWDEVICE_TYPE_D3D11VA and AV_PIX_FMT_D3D11.

Expand Down
2 changes: 1 addition & 1 deletion ffmpeg.h
Expand Up @@ -68,6 +68,7 @@ enum HWAccelID {
HWACCEL_QSV,
HWACCEL_VAAPI,
HWACCEL_CUVID,
HWACCEL_D3D11VA,
};

typedef struct HWAccel {
Expand Down Expand Up @@ -661,7 +662,6 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame);

int ffmpeg_parse_options(int argc, char **argv);

int dxva2_init(AVCodecContext *s);
int vda_init(AVCodecContext *s);
int videotoolbox_init(AVCodecContext *s);
int qsv_init(AVCodecContext *s);
Expand Down

0 comments on commit 70143a3

Please sign in to comment.