History

libavcodec/amfenc: Vulkan initialization support for encoder.

Added linux support for amf encoder through vulkan. To use h.264(AMD VCE) encoder on linux amdgru-pro version 19.20+ and amf-amdgpu-pro package(amdgru-pro contains, but does not install automatically) are required. This driver can be installed using amdgpu-pro-install script in official amd driver archive. Initialization of amf encoder occurs in this order: 1) trying to initialize through dx11(only windows) 2) trying to initialize through dx9(only windows) 3) trying to initialize through vulkan Only Vulkan initialization available on linux.

OvchinnikovDmitrii committed 7 years ago

Commit f8ad2dd1 parent b319feb4 files · +30 −6Browse files

Unified · Split

4 files
  1. Changelog +1 −0
  2. doc/general.texi +13 −3
  3. libavcodec/amfenc.c +15 −2
  4. libavcodec/version.h +1 −1
Changelog+1−0
@@ -6,6 +6,7 @@ version <next>: · 5 unmodified lines
66 - Intel QSV-accelerated MJPEG decoding
77 - Intel QSV-accelerated VP9 decoding
88 - support for TrueHD in mp4
9+- Supoort AMD AMF encoder on Linux (via Vulkan)
910
1011
1112 version 4.2:
doc/general.texi+13−3
@@ -27,16 +27,26 @@ enable it. · 26 unmodified lines
2727
2828 @section AMD AMF/VCE
2929
30−FFmpeg can use the AMD Advanced Media Framework library under Windows
31−for accelerated H.264 and HEVC encoding on hardware with Video Coding Engine (VCE).
30+FFmpeg can use the AMD Advanced Media Framework library
31+for accelerated H.264 and HEVC(only windows) encoding on hardware with Video Coding Engine (VCE).
3232
33−To enable support you must obtain the AMF framework header files from
33+To enable support you must obtain the AMF framework header files(version 1.4.9+) from
3434 @url{https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git}.
3535
3636 Create an @code{AMF/} directory in the system include path.
3737 Copy the contents of @code{AMF/amf/public/include/} into that directory.
3838 Then configure FFmpeg with @code{--enable-amf}.
3939
40+Initialization of amf encoder occurs in this order:
41+1) trying to initialize through dx11(only windows)
42+2) trying to initialize through dx9(only windows)
43+3) trying to initialize through vulkan
44+
45+To use h.264(AMD VCE) encoder on linux amdgru-pro version 19.20+ and amf-amdgpu-pro
46+package(amdgru-pro contains, but does not install automatically) are required.
47+
48+This driver can be installed using amdgpu-pro-install script in official amd driver archive.
49+
4050 @section AviSynth
4151
4252 FFmpeg can read AviSynth scripts as input. To enable support, pass
libavcodec/amfenc.c+15−2
@@ -213,6 +213,7 @@ static int amf_init_from_dxva2_device(AVCodecContext *avctx, AVDXVA2DeviceContex · 212 unmodified lines
213213 static int amf_init_context(AVCodecContext *avctx)
214214 {
215215 AmfContext *ctx = avctx->priv_data;
216+ AMFContext1 *context1 = NULL;
216217 AMF_RESULT res;
217218 av_unused int ret;
218219
@@ -311,8 +312,20 @@ static int amf_init_context(AVCodecContext *avctx) · 92 unmodified lines
311312 if (res == AMF_OK) {
312313 av_log(avctx, AV_LOG_VERBOSE, "AMF initialisation succeeded via D3D9.\n");
313314 } else {
314− av_log(avctx, AV_LOG_ERROR, "AMF initialisation failed via D3D9: error %d.\n", res);
315− return AVERROR(ENOSYS);
315+ AMFGuid guid = IID_AMFContext1();
316+ res = ctx->context->pVtbl->QueryInterface(ctx->context, &guid, (void**)&context1);
317+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, "CreateContext1() failed with error %d\n", res);
318+
319+ res = context1->pVtbl->InitVulkan(context1, NULL);
320+ context1->pVtbl->Release(context1);
321+ if (res != AMF_OK) {
322+ if (res == AMF_NOT_SUPPORTED)
323+ av_log(avctx, AV_LOG_ERROR, "AMF via Vulkan is not supported on the given device.\n");
324+ else
325+ av_log(avctx, AV_LOG_ERROR, "AMF failed to initialise on the given Vulkan device: %d.\n", res);
326+ return AVERROR(ENOSYS);
327+ }
328+ av_log(avctx, AV_LOG_VERBOSE, "AMF initialisation succeeded via Vulkan.\n");
316329 }
317330 }
318331 }
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 58
3131 #define LIBAVCODEC_VERSION_MINOR 55
32−#define LIBAVCODEC_VERSION_MICRO 101
32+#define LIBAVCODEC_VERSION_MICRO 102
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3535 LIBAVCODEC_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t