Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-12 Thread Mironov, Mikhail
> -Original Message-
> From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of Diego
> Biurrun
> Sent: February 11, 2018 1:00 PM
> To: libav development 
> Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> based on AMF SDK
> 
> On Thu, Feb 08, 2018 at 03:17:03PM +0100, Diego Biurrun wrote:
> > On Wed, Feb 07, 2018 at 06:39:39PM +, Mironov, Mikhail wrote:
> > > I quickly searched but did not find any formal standard on include guards.
> I did see some recommendations in forums though.
> >
> > I suggest searching the C99 standard instead of random forums:
> >
> > ISO/IEC 9899:1999 (E)
> > 7.1.3 Reserved identifiers
> > — All identifiers that begin with an underscore and either an
> > uppercase letter or another underscore are always reserved for any use.
> >
> > > To get some statistics: I checked few header files in Windows SDK,
> OpenCL SDK, OpenGL, Intel Media SDK - I see all kind of styles including
> __FILE_H__.
> > > For example:
> > > https://github.com/Intel-Media-
> SDK/MediaSDK/blob/master/api/include/
> > > mfxvideo.h
> >
> > Yes, bad practices abound. People look at kernel headers or libc
> > headers and wrongly believe that that is the example to follow. Then
> > others look at other projects for inspiration and cargo cult the error
> around.
> >
> > Please be a good example and fix it instead of perpetuating this
> > malpractice. It's as easy as
> >
> >   find . -name \*.h | xargs sed -i -e 's/ __AMF\(.*\)__/ AMF_\1/'
> >
> > from the root of the AMF source tree or the include dir (requires GNU sed).
> 
> Did that for you, please apply the attached patch.
> 
> Diego

HI, Thanks for the patch. I will use it but the update will be pushed later. 
The upcoming update 
already branched out and is kind of locked for any but critical change. It will 
include .
Please understand that AMF code is used to build several binaries in the driver 
and changes go through certain protocol.
Thanks,
Mikhail
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-11 Thread Diego Biurrun
On Fri, Feb 09, 2018 at 08:23:28PM +, Mironov, Mikhail wrote:
> > From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of Diego
> > On Wed, Feb 07, 2018 at 09:46:29AM +0100, Diego Biurrun wrote:
> > > On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> > > > I have a developer who will cover AMF integration on regular basis
> > (together with me). He starts tomorrow and will be up to date soon.
> > > > I will ask him to cleanup the things you mentioned if you will not 
> > > > submit
> > the changes first.
> > > > He is on BCC for now.
> > >
> > > It seems a bit more cleanup is needed on your side as well:
> > >
> > > /home/libav/libs/include/AMF/core/Platform.h:431:16: error: implicit
> > declaration of function ‘memcmp’ [-Werror=implicit-function-declaration]
> > >
> > > Indeed that header is missing a string.h #include and things break on one
> > of my systems.
> > 
> > I worked around that locally and added FATE (compile) testing for AMF:
> > 
> > https://fate.libav.org/x86_64-linux-external-libs/20180209180449
> 
> We will push this fix to AMF repo with upcoming update  - hopefully next week.

Please include the patch I sent while you're at it. :)

Let me know when the fix is public so I can get rid of my local workaround.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-11 Thread Diego Biurrun
On Thu, Feb 08, 2018 at 03:17:03PM +0100, Diego Biurrun wrote:
> On Wed, Feb 07, 2018 at 06:39:39PM +, Mironov, Mikhail wrote:
> > I quickly searched but did not find any formal standard on include guards. 
> > I did see some recommendations in forums though.
> 
> I suggest searching the C99 standard instead of random forums:
> 
> ISO/IEC 9899:1999 (E)
> 7.1.3 Reserved identifiers
> — All identifiers that begin with an underscore and either an uppercase 
> letter or another
> underscore are always reserved for any use.
> 
> > To get some statistics: I checked few header files in Windows SDK, OpenCL 
> > SDK, OpenGL, Intel Media SDK - I see all kind of styles including  
> > __FILE_H__.
> > For example: 
> > https://github.com/Intel-Media-SDK/MediaSDK/blob/master/api/include/mfxvideo.h
> 
> Yes, bad practices abound. People look at kernel headers or libc headers
> and wrongly believe that that is the example to follow. Then others look
> at other projects for inspiration and cargo cult the error around.
> 
> Please be a good example and fix it instead of perpetuating this
> malpractice. It's as easy as
> 
>   find . -name \*.h | xargs sed -i -e 's/ __AMF\(.*\)__/ AMF_\1/'
> 
> from the root of the AMF source tree or the include dir (requires GNU sed).

Did that for you, please apply the attached patch.

Diego
>From 42544648c332fa48d846632cf1d1f38571171379 Mon Sep 17 00:00:00 2001
From: Diego Biurrun 
Date: Sun, 11 Feb 2018 18:51:39 +0100
Subject: [PATCH] Do not use C99-reserved identifiers as multiple inclusion
 guards

Identifiers starting with __ or _ and a capital letter are reserved,
see section 7.1.3 Reserved identifiers of the C99 standard.
---
 amf/public/include/components/Ambisonic2SRenderer.h  | 6 +++---
 amf/public/include/components/AudioCapture.h | 6 +++---
 amf/public/include/components/Component.h| 6 +++---
 amf/public/include/components/ComponentCaps.h| 6 +++---
 amf/public/include/components/DisplayCapture.h   | 6 +++---
 amf/public/include/components/FFMPEGAudioConverter.h | 6 +++---
 amf/public/include/components/FFMPEGAudioDecoder.h   | 6 +++---
 amf/public/include/components/FFMPEGAudioEncoder.h   | 6 +++---
 amf/public/include/components/FFMPEGComponents.h | 6 +++---
 amf/public/include/components/FFMPEGFileDemuxer.h| 6 +++---
 amf/public/include/components/FFMPEGFileMuxer.h  | 6 +++---
 amf/public/include/components/MediaSource.h  | 6 +++---
 amf/public/include/components/VideoConverter.h   | 6 +++---
 amf/public/include/components/VideoEncoderHEVC.h | 6 +++---
 amf/public/include/components/VideoEncoderVCE.h  | 6 +++---
 amf/public/include/core/AudioBuffer.h| 6 +++---
 amf/public/include/core/Buffer.h | 6 +++---
 amf/public/include/core/Compute.h| 6 +++---
 amf/public/include/core/ComputeFactory.h | 7 ---
 amf/public/include/core/Context.h| 6 +++---
 amf/public/include/core/Data.h   | 6 +++---
 amf/public/include/core/Debug.h  | 6 +++---
 amf/public/include/core/Dump.h   | 4 ++--
 amf/public/include/core/Factory.h| 4 ++--
 amf/public/include/core/Interface.h  | 6 +++---
 amf/public/include/core/Plane.h  | 6 +++---
 amf/public/include/core/Platform.h   | 6 +++---
 amf/public/include/core/PropertyStorage.h| 6 +++---
 amf/public/include/core/PropertyStorageEx.h  | 6 +++---
 amf/public/include/core/Result.h | 6 +++---
 amf/public/include/core/Surface.h| 6 +++---
 amf/public/include/core/Trace.h  | 6 +++---
 amf/public/include/core/Variant.h| 6 +++---
 amf/public/include/core/Version.h| 6 +++---
 34 files changed, 101 insertions(+), 100 deletions(-)

diff --git a/amf/public/include/components/Ambisonic2SRenderer.h b/amf/public/include/components/Ambisonic2SRenderer.h
index af9c882..46bc623 100644
--- a/amf/public/include/components/Ambisonic2SRenderer.h
+++ b/amf/public/include/components/Ambisonic2SRenderer.h
@@ -34,8 +34,8 @@
 // interface declaration;  Ambisonic to Stereo Renderer
 //-
 
-#ifndef __AMFAmbisonic2SRendererHW__h__
-#define __AMFAmbisonic2SRendererHW__h__
+#ifndef AMF_Ambisonic2SRenderer_h
+#define AMF_Ambisonic2SRenderer_h
 #pragma once
 
 #include "public/include/components/Component.h"
@@ -76,4 +76,4 @@ extern "C"
 {
 AMF_RESULT AMF_CDECL_CALL AMFCreateComponentAmbisonic(amf::AMFContext* pContext, void* reserved, amf::AMFComponent** ppComponent);
 }
-#endif //#ifndef __AMFAmbisonic2SRendererHW__h__
+#endif //#ifndef AMF_Ambisonic2SRenderer_h
diff --git a/amf/public/include/components/AudioCapture.h b/amf/public/include/components/AudioCapture.h

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-09 Thread Mironov, Mikhail
> -Original Message-
> From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of Diego
> Biurrun
> Sent: February 9, 2018 1:06 PM
> To: libav development 
> Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> based on AMF SDK
> 
> On Wed, Feb 07, 2018 at 09:46:29AM +0100, Diego Biurrun wrote:
> > On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> > > I have a developer who will cover AMF integration on regular basis
> (together with me). He starts tomorrow and will be up to date soon.
> > > I will ask him to cleanup the things you mentioned if you will not submit
> the changes first.
> > > He is on BCC for now.
> >
> > It seems a bit more cleanup is needed on your side as well:
> >
> > /home/libav/libs/include/AMF/core/Platform.h:431:16: error: implicit
> declaration of function ‘memcmp’ [-Werror=implicit-function-declaration]
> >
> > Indeed that header is missing a string.h #include and things break on one
> of my systems.
> 
> I worked around that locally and added FATE (compile) testing for AMF:
> 
> https://fate.libav.org/x86_64-linux-external-libs/20180209180449
> 
> Diego
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel

We will push this fix to AMF repo with upcoming update  - hopefully next week.
Thanks,
Mikhail
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-09 Thread Diego Biurrun
On Wed, Feb 07, 2018 at 09:46:29AM +0100, Diego Biurrun wrote:
> On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> > I have a developer who will cover AMF integration on regular basis 
> > (together with me). He starts tomorrow and will be up to date soon. 
> > I will ask him to cleanup the things you mentioned if you will not submit 
> > the changes first.
> > He is on BCC for now.
> 
> It seems a bit more cleanup is needed on your side as well:
> 
> /home/libav/libs/include/AMF/core/Platform.h:431:16: error: implicit 
> declaration of function ‘memcmp’ [-Werror=implicit-function-declaration]
> 
> Indeed that header is missing a string.h #include and things break on one of 
> my systems.

I worked around that locally and added FATE (compile) testing for AMF:

https://fate.libav.org/x86_64-linux-external-libs/20180209180449

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-08 Thread Diego Biurrun
On Wed, Feb 07, 2018 at 07:35:05PM +, Mironov, Mikhail wrote:
> Regarding PRId64 macro:
> Started to look into this and found that at least in Microsoft's version of 
> inttypes.h there no definitions for Unicode strings. All AMF tracing /logging 
> is Unicode. 
> So the thought was to have a full set of macros in one place: LPRId64 and 
> AMFPRId64 rather to just add missing macros.

Been there, done that. It works better if you just define missing macros
for the (fewer and fewer) legacy platforms. You avoid the clutter of
locally-defined macros in your code and you only have to maintain a few
fallback definitions.

> > -Original Message-
> > From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of
> > Mironov, Mikhail
> > Sent: February 7, 2018 1:40 PM
> > To: libav development 
> > Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> > based on AMF SDK
> > 
> > Not yet, I mean we will fix them, in libav or in AMF.
> > I quickly searched but did not find any formal standard on include guards. I
> > did see some recommendations in forums though.
> > To get some statistics: I checked few header files in Windows SDK, OpenCL
> > SDK, OpenGL, Intel Media SDK - I see all kind of styles including  
> > __FILE_H__.
> > For example: https://github.com/Intel-Media-
> > SDK/MediaSDK/blob/master/api/include/mfxvideo.h
> > 
> > Mikhail
> > 
> > > -Original Message-
> > > From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of
> > > Diego Biurrun
> > > Sent: February 7, 2018 12:37 PM
> > > To: libav development 
> > > Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> > > based on AMF SDK
> > >
> > > On Wed, Feb 07, 2018 at 04:27:30PM +, Mironov, Mikhail wrote:
> > > > Warnings should be fixed. More comments inline.
> > >
> > > Fixed as in fixed if I pull in fresh headers from Git?
> > >
> > > > > On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> > > > > > I have a developer who will cover AMF integration on regular
> > > > > > basis
> > > > > (together with me). He starts tomorrow and will be up to date soon.
> > > > > > I will ask him to cleanup the things you mentioned if you will
> > > > > > not submit the
> > > > > changes first.
> > > > > > He is on BCC for now.
> > > > >
> > > > > It seems a bit more cleanup is needed on your side as well:
> > > > >
> > > > > /home/libav/libs/include/AMF/core/Platform.h:431:16: error:
> > > > > implicit declaration of function ‘memcmp’
> > > > > [-Werror=implicit-function-declaration]
> > > > >
> > > > > Indeed that header is missing a string.h #include and things break
> > > > > on one of my systems.
> > > > >
> > > > > Also, there are a bunch of warnings:
> > > > >
> > > > > ~/src/build/amf $ make libavcodec/amfenc.o
> > > > > CC  libavcodec/amfenc.o
> > > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > > > > ‘amf_init_context’:
> > > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: warning:
> > > > > passing argument 2 of ‘ctx->trace->pVtbl->RegisterWriter’ from
> > > > > incompatible pointer type [-Wincompatible-pointer-types]
> > > > >  ctx->trace->pVtbl->RegisterWriter(ctx->trace, ctx->writer_id,
> > > > > (AMFTraceWriter *)>tracer, 1);
> > > > >^~~
> > > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: note:
> > > > > expected ‘const wchar_t * {aka const int *}’ but argument is of
> > > > > type ‘char
> > > *’
> > > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: warning:
> > > > > passing argument 2 of ‘ctx->trace->pVtbl->SetWriterLevel’ from
> > > > > incompatible pointer type [-Wincompatible-pointer-types]
> > > > >  ctx->trace->pVtbl->SetWriterLevel(ctx->trace, ctx->writer_id,
> > > > > AMF_TRACE_TRACE);
> > > > >^~~
> > > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: note:
> > > > > expected ‘const wchar_t * {aka const int *}’ but argument is of
> > > > > type ‘char
> > > *’
> > > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > > > > ‘ff_amf_encode_close’:
> > > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: warning:
> > > > > passing argument 2 of ‘ctx->trace->pVtbl->UnregisterWriter’ from
> > > > > incompatible pointer type [-Wincompatible-pointer-types]
> > > > >  ctx->trace->pVtbl->UnregisterWriter(ctx->trace, 
> > > > > ctx->writer_id);
> > > > >  ^~~
> > > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: note:
> > > > > expected ‘const wchar_t * {aka const int *}’ but argument is of
> > > > > type ‘char
> > > *’
> > > > >
> > > > > One could just cast them away, but probably it's better to ajust the
> > types.
> > > > >
> > > > >
> > > > > Also, I noticed two issues in your headers (at a glance):
> > 

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-08 Thread Diego Biurrun
It would help the flow of discussion if you and/or your mailer did proper
interleaved replies instead of top-posting.

On Wed, Feb 07, 2018 at 06:39:39PM +, Mironov, Mikhail wrote:
> Not yet, I mean we will fix them, in libav or in AMF.

Libav is not the place to fix missing #includes in AMF headers.

> I quickly searched but did not find any formal standard on include guards. I 
> did see some recommendations in forums though.

I suggest searching the C99 standard instead of random forums:

ISO/IEC 9899:1999 (E)
7.1.3 Reserved identifiers
— All identifiers that begin with an underscore and either an uppercase letter 
or another
underscore are always reserved for any use.

> To get some statistics: I checked few header files in Windows SDK, OpenCL 
> SDK, OpenGL, Intel Media SDK - I see all kind of styles including  __FILE_H__.
> For example: 
> https://github.com/Intel-Media-SDK/MediaSDK/blob/master/api/include/mfxvideo.h

Yes, bad practices abound. People look at kernel headers or libc headers
and wrongly believe that that is the example to follow. Then others look
at other projects for inspiration and cargo cult the error around.

Please be a good example and fix it instead of perpetuating this
malpractice. It's as easy as

  find . -name \*.h | xargs sed -i -e 's/ __AMF\(.*\)__/ AMF_\1/'

from the root of the AMF source tree or the include dir (requires GNU sed).
At least one of the examples you cite above is from Intel, you could fix
that one as well :)

Feel free to also run

  find . -name \*.h | xargs sed -i -e 
's/AMF_Ambisonic2SRendererHW__h/AMF_Ambisonic2SRendererHW_h/'

to fix a silly typo.

> > -Original Message-
> > From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of Diego
> > Biurrun
> > Sent: February 7, 2018 12:37 PM
> > To: libav development 
> > Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> > based on AMF SDK
> > 
> > On Wed, Feb 07, 2018 at 04:27:30PM +, Mironov, Mikhail wrote:
> > > Warnings should be fixed. More comments inline.
> > 
> > Fixed as in fixed if I pull in fresh headers from Git?
> > 
> > > > On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> > > > > I have a developer who will cover AMF integration on regular basis
> > > > (together with me). He starts tomorrow and will be up to date soon.
> > > > > I will ask him to cleanup the things you mentioned if you will not
> > > > > submit the
> > > > changes first.
> > > > > He is on BCC for now.
> > > >
> > > > It seems a bit more cleanup is needed on your side as well:
> > > >
> > > > /home/libav/libs/include/AMF/core/Platform.h:431:16: error: implicit
> > > > declaration of function ‘memcmp’
> > > > [-Werror=implicit-function-declaration]
> > > >
> > > > Indeed that header is missing a string.h #include and things break
> > > > on one of my systems.
> > > >
> > > > Also, there are a bunch of warnings:
> > > >
> > > > ~/src/build/amf $ make libavcodec/amfenc.o
> > > > CC  libavcodec/amfenc.o
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > > > ‘amf_init_context’:
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: warning:
> > > > passing argument 2 of ‘ctx->trace->pVtbl->RegisterWriter’ from
> > > > incompatible pointer type [-Wincompatible-pointer-types]
> > > >  ctx->trace->pVtbl->RegisterWriter(ctx->trace, ctx->writer_id,
> > > > (AMFTraceWriter *)>tracer, 1);
> > > >^~~
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: note:
> > > > expected ‘const wchar_t * {aka const int *}’ but argument is of type 
> > > > ‘char
> > *’
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: warning:
> > > > passing argument 2 of ‘ctx->trace->pVtbl->SetWriterLevel’ from
> > > > incompatible pointer type [-Wincompatible-pointer-types]
> > > >  ctx->trace->pVtbl->SetWriterLevel(ctx->trace, ctx->writer_id,
> > > > AMF_TRACE_TRACE);
> > > >^~~
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: note:
> > > > expected ‘const wchar_t * {aka const int *}’ but argument is of type 
> > > > ‘char
> > *’
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > > > ‘ff_amf_encode_close’:
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: warning:
> > > > passing argument 2 of ‘ctx->trace->pVtbl->UnregisterWriter’ from
> > > > incompatible pointer type [-Wincompatible-pointer-types]
> > > >  ctx->trace->pVtbl->UnregisterWriter(ctx->trace, 
> > > > ctx->writer_id);
> > > >  ^~~
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: note:
> > > > expected ‘const wchar_t * {aka const int *}’ but argument is of type 
> > > > ‘char
> > *’
> > > >
> > > > One could just cast them away, but probably it's better to ajust the 
> > > > types.
> > > >
> > > >
> 

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-07 Thread wm4
On Wed, 7 Feb 2018 19:35:05 +
"Mironov, Mikhail"  wrote:

> Regarding PRId64 macro:
> Started to look into this and found that at least in Microsoft's version of 
> inttypes.h there no definitions for Unicode strings. All AMF tracing /logging 
> is Unicode. 
> So the thought was to have a full set of macros in one place: LPRId64 and 
> AMFPRId64 rather to just add missing macros.

Can't you switch to UTF-8?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-07 Thread Mironov, Mikhail
Regarding PRId64 macro:
Started to look into this and found that at least in Microsoft's version of 
inttypes.h there no definitions for Unicode strings. All AMF tracing /logging 
is Unicode. 
So the thought was to have a full set of macros in one place: LPRId64 and 
AMFPRId64 rather to just add missing macros.
Mikhail

> -Original Message-
> From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of
> Mironov, Mikhail
> Sent: February 7, 2018 1:40 PM
> To: libav development 
> Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> based on AMF SDK
> 
> Not yet, I mean we will fix them, in libav or in AMF.
> I quickly searched but did not find any formal standard on include guards. I
> did see some recommendations in forums though.
> To get some statistics: I checked few header files in Windows SDK, OpenCL
> SDK, OpenGL, Intel Media SDK - I see all kind of styles including  __FILE_H__.
> For example: https://github.com/Intel-Media-
> SDK/MediaSDK/blob/master/api/include/mfxvideo.h
> 
> Mikhail
> 
> > -Original Message-
> > From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of
> > Diego Biurrun
> > Sent: February 7, 2018 12:37 PM
> > To: libav development 
> > Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> > based on AMF SDK
> >
> > On Wed, Feb 07, 2018 at 04:27:30PM +, Mironov, Mikhail wrote:
> > > Warnings should be fixed. More comments inline.
> >
> > Fixed as in fixed if I pull in fresh headers from Git?
> >
> > > > On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> > > > > I have a developer who will cover AMF integration on regular
> > > > > basis
> > > > (together with me). He starts tomorrow and will be up to date soon.
> > > > > I will ask him to cleanup the things you mentioned if you will
> > > > > not submit the
> > > > changes first.
> > > > > He is on BCC for now.
> > > >
> > > > It seems a bit more cleanup is needed on your side as well:
> > > >
> > > > /home/libav/libs/include/AMF/core/Platform.h:431:16: error:
> > > > implicit declaration of function ‘memcmp’
> > > > [-Werror=implicit-function-declaration]
> > > >
> > > > Indeed that header is missing a string.h #include and things break
> > > > on one of my systems.
> > > >
> > > > Also, there are a bunch of warnings:
> > > >
> > > > ~/src/build/amf $ make libavcodec/amfenc.o
> > > > CC  libavcodec/amfenc.o
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > > > ‘amf_init_context’:
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: warning:
> > > > passing argument 2 of ‘ctx->trace->pVtbl->RegisterWriter’ from
> > > > incompatible pointer type [-Wincompatible-pointer-types]
> > > >  ctx->trace->pVtbl->RegisterWriter(ctx->trace, ctx->writer_id,
> > > > (AMFTraceWriter *)>tracer, 1);
> > > >^~~
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: note:
> > > > expected ‘const wchar_t * {aka const int *}’ but argument is of
> > > > type ‘char
> > *’
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: warning:
> > > > passing argument 2 of ‘ctx->trace->pVtbl->SetWriterLevel’ from
> > > > incompatible pointer type [-Wincompatible-pointer-types]
> > > >  ctx->trace->pVtbl->SetWriterLevel(ctx->trace, ctx->writer_id,
> > > > AMF_TRACE_TRACE);
> > > >^~~
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: note:
> > > > expected ‘const wchar_t * {aka const int *}’ but argument is of
> > > > type ‘char
> > *’
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > > > ‘ff_amf_encode_close’:
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: warning:
> > > > passing argument 2 of ‘ctx->trace->pVtbl->UnregisterWriter’ from
> > > > incompatible pointer type [-Wincompatible-pointer-types]
> > > >  ctx->trace->pVtbl->UnregisterWriter(ctx->trace, 
> > > > ctx->writer_id);
> > > >  ^~~
> > > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: note:
> > > > expected ‘const wchar_t * {aka const int *}’ but argument is of
> > > > type ‘char
> > *’
> > > >
> > > > One could just cast them away, but probably it's better to ajust the
> types.
> > > >
> > > >
> > > > Also, I noticed two issues in your headers (at a glance):
> > > >
> > > > 1) You recreate parts of inttypes.h, i.e.
> > > >
> > > >#define AMFPRId64"lld"
> > > >
> > > >and similar - why, oh, why? What ass-backwards systems are you
> > > > trying
> > to
> > > >support there?
> > >
> > > I don’t remember right now which system required the custom macro
> > > but it
> > was real issue five years ago.
> > > This is AMF SDK issue, not libav integration, we should clean this
> > > up
> > though.
> >
> > 5 years ago on Linux or with some of 

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-07 Thread Mironov, Mikhail
Not yet, I mean we will fix them, in libav or in AMF.
I quickly searched but did not find any formal standard on include guards. I 
did see some recommendations in forums though.
To get some statistics: I checked few header files in Windows SDK, OpenCL SDK, 
OpenGL, Intel Media SDK - I see all kind of styles including  __FILE_H__.
For example: 
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/api/include/mfxvideo.h

Mikhail

> -Original Message-
> From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of Diego
> Biurrun
> Sent: February 7, 2018 12:37 PM
> To: libav development 
> Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> based on AMF SDK
> 
> On Wed, Feb 07, 2018 at 04:27:30PM +, Mironov, Mikhail wrote:
> > Warnings should be fixed. More comments inline.
> 
> Fixed as in fixed if I pull in fresh headers from Git?
> 
> > > On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> > > > I have a developer who will cover AMF integration on regular basis
> > > (together with me). He starts tomorrow and will be up to date soon.
> > > > I will ask him to cleanup the things you mentioned if you will not
> > > > submit the
> > > changes first.
> > > > He is on BCC for now.
> > >
> > > It seems a bit more cleanup is needed on your side as well:
> > >
> > > /home/libav/libs/include/AMF/core/Platform.h:431:16: error: implicit
> > > declaration of function ‘memcmp’
> > > [-Werror=implicit-function-declaration]
> > >
> > > Indeed that header is missing a string.h #include and things break
> > > on one of my systems.
> > >
> > > Also, there are a bunch of warnings:
> > >
> > > ~/src/build/amf $ make libavcodec/amfenc.o
> > > CC  libavcodec/amfenc.o
> > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > > ‘amf_init_context’:
> > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: warning:
> > > passing argument 2 of ‘ctx->trace->pVtbl->RegisterWriter’ from
> > > incompatible pointer type [-Wincompatible-pointer-types]
> > >  ctx->trace->pVtbl->RegisterWriter(ctx->trace, ctx->writer_id,
> > > (AMFTraceWriter *)>tracer, 1);
> > >^~~
> > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: note:
> > > expected ‘const wchar_t * {aka const int *}’ but argument is of type ‘char
> *’
> > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: warning:
> > > passing argument 2 of ‘ctx->trace->pVtbl->SetWriterLevel’ from
> > > incompatible pointer type [-Wincompatible-pointer-types]
> > >  ctx->trace->pVtbl->SetWriterLevel(ctx->trace, ctx->writer_id,
> > > AMF_TRACE_TRACE);
> > >^~~
> > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: note:
> > > expected ‘const wchar_t * {aka const int *}’ but argument is of type ‘char
> *’
> > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > > ‘ff_amf_encode_close’:
> > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: warning:
> > > passing argument 2 of ‘ctx->trace->pVtbl->UnregisterWriter’ from
> > > incompatible pointer type [-Wincompatible-pointer-types]
> > >  ctx->trace->pVtbl->UnregisterWriter(ctx->trace, ctx->writer_id);
> > >  ^~~
> > > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: note:
> > > expected ‘const wchar_t * {aka const int *}’ but argument is of type ‘char
> *’
> > >
> > > One could just cast them away, but probably it's better to ajust the 
> > > types.
> > >
> > >
> > > Also, I noticed two issues in your headers (at a glance):
> > >
> > > 1) You recreate parts of inttypes.h, i.e.
> > >
> > >#define AMFPRId64"lld"
> > >
> > >and similar - why, oh, why? What ass-backwards systems are you trying
> to
> > >support there?
> >
> > I don’t remember right now which system required the custom macro but it
> was real issue five years ago.
> > This is AMF SDK issue, not libav integration, we should clean this up
> though.
> 
> 5 years ago on Linux or with some of those horrible, now-obsolete MSVC
> versions? The latter I believe right away, but finding Linux systems that were
> not C99 compliant was difficult even in 2012...
> 
> > > 2) You are invading system namespace:
> > >
> > >#ifndef __AMFPlatform_h__
> > >
> > >Identifiers starting with __ (or _ and an uppercase letter) are 
> > > reserved
> > >for the system. Should be easy enough to replace these with
> >
> > This is a decision made for AMF SDK which is external for libav integration.
> Which standard or recommendation are you refer to?
> 
> The C standard reserves those identifiers for the system, i.e. the kernel or 
> the
> C library.
> 
> Diego
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-07 Thread Diego Biurrun
On Wed, Feb 07, 2018 at 04:27:30PM +, Mironov, Mikhail wrote:
> Warnings should be fixed. More comments inline.

Fixed as in fixed if I pull in fresh headers from Git?

> > On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> > > I have a developer who will cover AMF integration on regular basis
> > (together with me). He starts tomorrow and will be up to date soon.
> > > I will ask him to cleanup the things you mentioned if you will not submit 
> > > the
> > changes first.
> > > He is on BCC for now.
> > 
> > It seems a bit more cleanup is needed on your side as well:
> > 
> > /home/libav/libs/include/AMF/core/Platform.h:431:16: error: implicit
> > declaration of function ‘memcmp’ [-Werror=implicit-function-declaration]
> > 
> > Indeed that header is missing a string.h #include and things break on one of
> > my systems.
> > 
> > Also, there are a bunch of warnings:
> > 
> > ~/src/build/amf $ make libavcodec/amfenc.o
> > CC  libavcodec/amfenc.o
> > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > ‘amf_init_context’:
> > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: warning: passing
> > argument 2 of ‘ctx->trace->pVtbl->RegisterWriter’ from incompatible pointer
> > type [-Wincompatible-pointer-types]
> >  ctx->trace->pVtbl->RegisterWriter(ctx->trace, ctx->writer_id,
> > (AMFTraceWriter *)>tracer, 1);
> >^~~
> > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: note: expected
> > ‘const wchar_t * {aka const int *}’ but argument is of type ‘char *’
> > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: warning: passing
> > argument 2 of ‘ctx->trace->pVtbl->SetWriterLevel’ from incompatible pointer
> > type [-Wincompatible-pointer-types]
> >  ctx->trace->pVtbl->SetWriterLevel(ctx->trace, ctx->writer_id,
> > AMF_TRACE_TRACE);
> >^~~
> > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: note: expected
> > ‘const wchar_t * {aka const int *}’ but argument is of type ‘char *’
> > /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> > ‘ff_amf_encode_close’:
> > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: warning: passing
> > argument 2 of ‘ctx->trace->pVtbl->UnregisterWriter’ from incompatible
> > pointer type [-Wincompatible-pointer-types]
> >  ctx->trace->pVtbl->UnregisterWriter(ctx->trace, ctx->writer_id);
> >  ^~~
> > /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: note: expected
> > ‘const wchar_t * {aka const int *}’ but argument is of type ‘char *’
> > 
> > One could just cast them away, but probably it's better to ajust the types.
> > 
> > 
> > Also, I noticed two issues in your headers (at a glance):
> > 
> > 1) You recreate parts of inttypes.h, i.e.
> > 
> >#define AMFPRId64"lld"
> > 
> >and similar - why, oh, why? What ass-backwards systems are you trying to
> >support there?
> 
> I don’t remember right now which system required the custom macro but it was 
> real issue five years ago. 
> This is AMF SDK issue, not libav integration, we should clean this up though.

5 years ago on Linux or with some of those horrible, now-obsolete MSVC
versions? The latter I believe right away, but finding Linux systems
that were not C99 compliant was difficult even in 2012...

> > 2) You are invading system namespace:
> > 
> >#ifndef __AMFPlatform_h__
> > 
> >Identifiers starting with __ (or _ and an uppercase letter) are reserved
> >for the system. Should be easy enough to replace these with
> 
> This is a decision made for AMF SDK which is external for libav integration. 
> Which standard or recommendation are you refer to?

The C standard reserves those identifiers for the system, i.e. the kernel
or the C library.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-07 Thread Mironov, Mikhail
Warnings should be fixed. More comments inline.
Mikhail

> -Original Message-
> From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of Diego
> Biurrun
> Sent: February 7, 2018 3:46 AM
> To: libav development 
> Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> based on AMF SDK
> 
> On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> > I have a developer who will cover AMF integration on regular basis
> (together with me). He starts tomorrow and will be up to date soon.
> > I will ask him to cleanup the things you mentioned if you will not submit 
> > the
> changes first.
> > He is on BCC for now.
> 
> It seems a bit more cleanup is needed on your side as well:
> 
> /home/libav/libs/include/AMF/core/Platform.h:431:16: error: implicit
> declaration of function ‘memcmp’ [-Werror=implicit-function-declaration]
> 
> Indeed that header is missing a string.h #include and things break on one of
> my systems.
> 
> Also, there are a bunch of warnings:
> 
> ~/src/build/amf $ make libavcodec/amfenc.o
> CC  libavcodec/amfenc.o
> /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> ‘amf_init_context’:
> /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: warning: passing
> argument 2 of ‘ctx->trace->pVtbl->RegisterWriter’ from incompatible pointer
> type [-Wincompatible-pointer-types]
>  ctx->trace->pVtbl->RegisterWriter(ctx->trace, ctx->writer_id,
> (AMFTraceWriter *)>tracer, 1);
>^~~
> /home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: note: expected
> ‘const wchar_t * {aka const int *}’ but argument is of type ‘char *’
> /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: warning: passing
> argument 2 of ‘ctx->trace->pVtbl->SetWriterLevel’ from incompatible pointer
> type [-Wincompatible-pointer-types]
>  ctx->trace->pVtbl->SetWriterLevel(ctx->trace, ctx->writer_id,
> AMF_TRACE_TRACE);
>^~~
> /home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: note: expected
> ‘const wchar_t * {aka const int *}’ but argument is of type ‘char *’
> /home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function
> ‘ff_amf_encode_close’:
> /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: warning: passing
> argument 2 of ‘ctx->trace->pVtbl->UnregisterWriter’ from incompatible
> pointer type [-Wincompatible-pointer-types]
>  ctx->trace->pVtbl->UnregisterWriter(ctx->trace, ctx->writer_id);
>  ^~~
> /home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: note: expected
> ‘const wchar_t * {aka const int *}’ but argument is of type ‘char *’
> 
> One could just cast them away, but probably it's better to ajust the types.
> 
> 
> Also, I noticed two issues in your headers (at a glance):
> 
> 1) You recreate parts of inttypes.h, i.e.
> 
>#define AMFPRId64"lld"
> 
>and similar - why, oh, why? What ass-backwards systems are you trying to
>support there?

I don’t remember right now which system required the custom macro but it was 
real issue five years ago. 
This is AMF SDK issue, not libav integration, we should clean this up though.

> 
> 2) You are invading system namespace:
> 
>#ifndef __AMFPlatform_h__
> 
>Identifiers starting with __ (or _ and an uppercase letter) are reserved
>for the system. Should be easy enough to replace these with

This is a decision made for AMF SDK which is external for libav integration. 
Which standard or recommendation are you refer to?

> 
>#ifndef AMF_Platform_h
> 
>and similar.
> 
> Diego
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-07 Thread Diego Biurrun
On Sun, Feb 04, 2018 at 07:04:39PM +, Mironov, Mikhail wrote:
> I have a developer who will cover AMF integration on regular basis (together 
> with me). He starts tomorrow and will be up to date soon. 
> I will ask him to cleanup the things you mentioned if you will not submit the 
> changes first.
> He is on BCC for now.

It seems a bit more cleanup is needed on your side as well:

/home/libav/libs/include/AMF/core/Platform.h:431:16: error: implicit 
declaration of function ‘memcmp’ [-Werror=implicit-function-declaration]

Indeed that header is missing a string.h #include and things break on one of my 
systems.

Also, there are a bunch of warnings:

~/src/build/amf $ make libavcodec/amfenc.o
CC  libavcodec/amfenc.o
/home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function 
‘amf_init_context’:
/home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: warning: passing 
argument 2 of ‘ctx->trace->pVtbl->RegisterWriter’ from incompatible pointer 
type [-Wincompatible-pointer-types]
 ctx->trace->pVtbl->RegisterWriter(ctx->trace, ctx->writer_id, 
(AMFTraceWriter *)>tracer, 1);
   ^~~
/home/diego/src/libav.vanilla/libavcodec/amfenc.c:159:51: note: expected ‘const 
wchar_t * {aka const int *}’ but argument is of type ‘char *’
/home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: warning: passing 
argument 2 of ‘ctx->trace->pVtbl->SetWriterLevel’ from incompatible pointer 
type [-Wincompatible-pointer-types]
 ctx->trace->pVtbl->SetWriterLevel(ctx->trace, ctx->writer_id, 
AMF_TRACE_TRACE);
   ^~~
/home/diego/src/libav.vanilla/libavcodec/amfenc.c:160:51: note: expected ‘const 
wchar_t * {aka const int *}’ but argument is of type ‘char *’
/home/diego/src/libav.vanilla/libavcodec/amfenc.c: In function 
‘ff_amf_encode_close’:
/home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: warning: passing 
argument 2 of ‘ctx->trace->pVtbl->UnregisterWriter’ from incompatible pointer 
type [-Wincompatible-pointer-types]
 ctx->trace->pVtbl->UnregisterWriter(ctx->trace, ctx->writer_id);
 ^~~
/home/diego/src/libav.vanilla/libavcodec/amfenc.c:265:57: note: expected ‘const 
wchar_t * {aka const int *}’ but argument is of type ‘char *’

One could just cast them away, but probably it's better to ajust the types.


Also, I noticed two issues in your headers (at a glance):

1) You recreate parts of inttypes.h, i.e.

   #define AMFPRId64"lld"

   and similar - why, oh, why? What ass-backwards systems are you trying to
   support there?

2) You are invading system namespace:

   #ifndef __AMFPlatform_h__

   Identifiers starting with __ (or _ and an uppercase letter) are reserved
   for the system. Should be easy enough to replace these with

   #ifndef AMF_Platform_h

   and similar.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-04 Thread Mironov, Mikhail
I have a developer who will cover AMF integration on regular basis (together 
with me). He starts tomorrow and will be up to date soon. 
I will ask him to cleanup the things you mentioned if you will not submit the 
changes first.
He is on BCC for now.
Thanks,
Mikhail

> -Original Message-
> From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of Diego
> Biurrun
> Sent: February 4, 2018 9:09 AM
> To: libav development 
> Subject: Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs
> based on AMF SDK
> 
> Do we have coverage for this on FATE? I'll send a bunch of patches for AMF
> shortly.
> 
> On Wed, Jan 03, 2018 at 12:55:53PM -0500, Mikhail Mironov wrote:
> > --- a/configure
> > +++ b/configure
> > @@ -231,6 +231,7 @@ External library support:
> >
> >The following libraries provide various hardware acceleration features:
> > +  --enable-amf AMF video encoding code [auto]
> >--enable-cudaNvidia CUDA (dynamically linked)
> >--enable-cuvid   Nvidia CUVID video decode acceleration
> >--enable-d3d11va Microsoft Direct3D 11 video acceleration [auto]
> 
> That's a copy and paste error, amf is not autodetected, it needs to be
> enabled explicitly.
> 
> > @@ -2238,6 +2240,7 @@
> wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
> >
> >  # hardware-accelerated codecs
> > +amf_deps_any="dlopen LoadLibrary"
> >  nvenc_deps_any="libdl LoadLibrary"
> >  omx_deps="libdl pthreads"
> >  omx_rpi_select="omx"
> > @@ -4573,6 +4578,11 @@ for func in $MATH_FUNCS; do
> >
> >  # these are off by default, so fail if requested and not available
> > +
> > +enabled amf &&
> > +check_cpp_condition "AMF/core/Version.h" \
> > +"(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 |
> AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >=
> 0x0001000400040001" ||
> > +disable amf
> 
> See the comment just above the line you added. You need to fail (i.e. call the
> die() function), not just disable AMF.
> 
> > --- /dev/null
> > +++ b/libavcodec/amfenc.c
> > @@ -0,0 +1,608 @@
> > +static int amf_copy_buffer(AVCodecContext *avctx, AVPacket *pkt,
> > +AMFBuffer *buffer) {
> > +//if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0) {
> > +if  (ret = ff_alloc_packet(pkt, size)) {
> 
> commented-out cruft
> 
> > --- /dev/null
> > +++ b/libavcodec/amfenc.h
> > @@ -0,0 +1,158 @@
> > +
> > +#ifndef AVCODEC_AMFENC_H
> > +#define AVCODEC_AMFENC_H
> > +
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +#include "libavutil/fifo.h"
> > +
> > +#include "config.h"
> > +#include "avcodec.h"
> 
> config.h is not used in this header; it's better to move it elsewhere.
> 
> > +/**
> > +* AMF encoder context
> > +*/
> > +typedef struct AmfContext {
> > +AVClass*avclass;
> > +// access to AMF runtime
> > +amf_handle  library; ///< handle to DLL library
> > +AMFFactory *factory; ///< pointer to AMF factory
> > +AMFDebug   *debug;   ///< pointer to AMF debug interface
> > +AMFTrace   *trace;   ///< pointer to AMF trace interface
> > +
> > +amf_uint64  version; ///< version of AMF runtime
> > +AmfTraceWriter  tracer;  ///< AMF writer registered with AMF
> > +AMFContext *context; ///< AMF context
> > +//encoder
> > +AMFComponent   *encoder; ///< AMF encoder object
> > +amf_booleof; ///< flag indicating EOF happened
> > +AMF_SURFACE_FORMAT  format;  ///< AMF surface format
> > +
> > +AVBufferRef*hw_device_ctx; ///< pointer to HW accelerator
> (decoder)
> > +AVBufferRef*hw_frames_ctx; ///< pointer to HW accelerator
> (frame allocator)
> > +} AmfContext;
> > +
> > +/**
> > +* Common encoder initization function */ int
> > +ff_amf_encode_init(AVCodecContext *avctx);
> > +/**
> > +* Common encoder termination function */ int
> > +ff_amf_encode_close(AVCodecContext *avctx);
> > +
> > +/**
> > +* Ecoding one frame - common function for all AMF encoders */ int
> > +ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame); int
> > +ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
> 
> Most of these comments are redundant and pointless.
> 
> Diego
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-04 Thread Diego Biurrun
On Sun, Feb 04, 2018 at 02:32:48PM +, Mark Thompson wrote:
> On 03/02/18 17:23, Diego Biurrun wrote:
> > On Thu, Jan 04, 2018 at 02:59:02PM +, Mironov, Mikhail wrote:
> >>> On 1/3/2018 7:53 PM, Sean McGovern wrote:
>  2 things:
> 
>  - does this actually depend on dlopen directly, or should it be libdl,
>  like the entries below it?
> >>>
> >>> If this is Windows only as the doxy states, then LoadLibrary should be the
> >>> only dep. But otherwise you're right, it should be libdl and not dlopen.
> >>
> >> We plan to add Linux support so eventually libdl will be needed. For now I 
> >> am OK with either solution.
> > 
> > If this is Windows-only (for now at least), then there is no need for all 
> > the
> > ifdeffery. We can add complexity if and when it is needed, no need to 
> > clutter
> > the code for an uncertain and possibly distant future.
> 
> On 04/02/18 14:08, Diego Biurrun wrote:
> > Do we have coverage for this on FATE?
> 
> This is why the vestigial libdl etc. support is useful - given the headers on 
> Linux, it's just another external library you can build anywhere.

OK, I'll look into adding it to my external libs FATE/Oracle instances.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-04 Thread Mark Thompson
On 03/02/18 17:23, Diego Biurrun wrote:
> On Thu, Jan 04, 2018 at 02:59:02PM +, Mironov, Mikhail wrote:
>>> On 1/3/2018 7:53 PM, Sean McGovern wrote:
 2 things:

 - does this actually depend on dlopen directly, or should it be libdl,
 like the entries below it?
>>>
>>> If this is Windows only as the doxy states, then LoadLibrary should be the
>>> only dep. But otherwise you're right, it should be libdl and not dlopen.
>>
>> We plan to add Linux support so eventually libdl will be needed. For now I 
>> am OK with either solution.
> 
> If this is Windows-only (for now at least), then there is no need for all the
> ifdeffery. We can add complexity if and when it is needed, no need to clutter
> the code for an uncertain and possibly distant future.

On 04/02/18 14:08, Diego Biurrun wrote:
> Do we have coverage for this on FATE?

This is why the vestigial libdl etc. support is useful - given the headers on 
Linux, it's just another external library you can build anywhere.

- Mark
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-02-04 Thread Diego Biurrun
Do we have coverage for this on FATE? I'll send a bunch of patches for
AMF shortly.

On Wed, Jan 03, 2018 at 12:55:53PM -0500, Mikhail Mironov wrote:
> --- a/configure
> +++ b/configure
> @@ -231,6 +231,7 @@ External library support:
>  
>The following libraries provide various hardware acceleration features:
> +  --enable-amf AMF video encoding code [auto]
>--enable-cudaNvidia CUDA (dynamically linked)
>--enable-cuvid   Nvidia CUVID video decode acceleration
>--enable-d3d11va Microsoft Direct3D 11 video acceleration [auto]

That's a copy and paste error, amf is not autodetected, it needs to be
enabled explicitly.

> @@ -2238,6 +2240,7 @@ wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
>  
>  # hardware-accelerated codecs
> +amf_deps_any="dlopen LoadLibrary"
>  nvenc_deps_any="libdl LoadLibrary"
>  omx_deps="libdl pthreads"
>  omx_rpi_select="omx"
> @@ -4573,6 +4578,11 @@ for func in $MATH_FUNCS; do
>  
>  # these are off by default, so fail if requested and not available
> +
> +enabled amf &&
> +check_cpp_condition "AMF/core/Version.h" \
> +"(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | 
> AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x0001000400040001" ||
> +disable amf

See the comment just above the line you added. You need to fail (i.e. call
the die() function), not just disable AMF.

> --- /dev/null
> +++ b/libavcodec/amfenc.c
> @@ -0,0 +1,608 @@
> +static int amf_copy_buffer(AVCodecContext *avctx, AVPacket *pkt, AMFBuffer 
> *buffer)
> +{
> +//if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0) {
> +if  (ret = ff_alloc_packet(pkt, size)) {

commented-out cruft

> --- /dev/null
> +++ b/libavcodec/amfenc.h
> @@ -0,0 +1,158 @@
> +
> +#ifndef AVCODEC_AMFENC_H
> +#define AVCODEC_AMFENC_H
> +
> +#include 
> +
> +#include 
> +#include 
> +
> +#include "libavutil/fifo.h"
> +
> +#include "config.h"
> +#include "avcodec.h"

config.h is not used in this header; it's better to move it elsewhere.

> +/**
> +* AMF encoder context
> +*/
> +typedef struct AmfContext {
> +AVClass*avclass;
> +// access to AMF runtime
> +amf_handle  library; ///< handle to DLL library
> +AMFFactory *factory; ///< pointer to AMF factory
> +AMFDebug   *debug;   ///< pointer to AMF debug interface
> +AMFTrace   *trace;   ///< pointer to AMF trace interface
> +
> +amf_uint64  version; ///< version of AMF runtime
> +AmfTraceWriter  tracer;  ///< AMF writer registered with AMF
> +AMFContext *context; ///< AMF context
> +//encoder
> +AMFComponent   *encoder; ///< AMF encoder object
> +amf_booleof; ///< flag indicating EOF happened
> +AMF_SURFACE_FORMAT  format;  ///< AMF surface format
> +
> +AVBufferRef*hw_device_ctx; ///< pointer to HW accelerator 
> (decoder)
> +AVBufferRef*hw_frames_ctx; ///< pointer to HW accelerator (frame 
> allocator)
> +} AmfContext;
> +
> +/**
> +* Common encoder initization function
> +*/
> +int ff_amf_encode_init(AVCodecContext *avctx);
> +/**
> +* Common encoder termination function
> +*/
> +int ff_amf_encode_close(AVCodecContext *avctx);
> +
> +/**
> +* Ecoding one frame - common function for all AMF encoders
> +*/
> +int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame);
> +int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);

Most of these comments are redundant and pointless.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-01-03 Thread James Almer
On 1/3/2018 7:53 PM, Sean McGovern wrote:
> 2 things:
> 
> - does this actually depend on dlopen directly, or should it be libdl, like
> the entries below it?

If this is Windows only as the doxy states, then LoadLibrary should be
the only dep. But otherwise you're right, it should be libdl and not dlopen.

> - would be nice to test, if I could oh maybe get a hold of a Vega *grmbl*

It works with any GCN based GPU, so HD7xxx and newer (Older models only
support h264).

> 
> Sean McG.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-01-03 Thread Sean McGovern
Hi,

On Jan 3, 2018 12:55, "Mikhail Mironov"  wrote:

From 0b90d9c0eb300099ca6845e8ba42bce881670a83 Mon Sep 17 00:00:00 2001
From: Michael Wootton 
Date: Mon, 4 Dec 2017 02:29:01 -0500
Subject: [PATCH] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF
SDK
 Requires AMF headers for at least version 1.4.4.1.

Signed-off-by: Mikhail Mironov 
---
 configure|  10 +
 doc/general.texi |  10 +
 libavcodec/Makefile  |   4 +
 libavcodec/allcodecs.c   |   2 +
 libavcodec/amfenc.c  | 608 ++
+
 libavcodec/amfenc.h  | 158 
 libavcodec/amfenc_h264.c | 400 +++
 libavcodec/amfenc_hevc.c | 332 ++
 8 files changed, 1524 insertions(+)
 create mode 100644 libavcodec/amfenc.c
 create mode 100644 libavcodec/amfenc.h
 create mode 100644 libavcodec/amfenc_h264.c
 create mode 100644 libavcodec/amfenc_hevc.c

diff --git a/configure b/configure
index d31cb56..63d5f3a 100755
--- a/configure
+++ b/configure
@@ -231,6 +231,7 @@ External library support:
   --enable-zlib  compression [autodetect]

   The following libraries provide various hardware acceleration features:
+  --enable-amf AMF video encoding code [auto]
   --enable-cudaNvidia CUDA (dynamically linked)
   --enable-cuvid   Nvidia CUVID video decode acceleration
   --enable-d3d11va Microsoft Direct3D 11 video acceleration [auto]
@@ -1255,6 +1256,7 @@ HWACCEL_LIBRARY_NONFREE_LIST="
 "
 HWACCEL_LIBRARY_LIST="
 $HWACCEL_LIBRARY_NONFREE_LIST
+amf
 d3d11va
 dxva2
 libmfx
@@ -2238,6 +2240,7 @@ wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"

 # hardware-accelerated codecs
+amf_deps_any="dlopen LoadLibrary"
 nvenc_deps_any="libdl LoadLibrary"
 omx_deps="libdl pthreads"
 omx_rpi_select="omx"
@@ -2250,6 +2253,7 @@ vaapi_encode_deps="vaapi"
 hwupload_cuda_filter_deps="cuda"
 scale_npp_filter_deps="cuda libnpp"

+h264_amf_encoder_deps="amf"
 h264_mmal_decoder_deps="mmal"
 h264_nvenc_encoder_deps="nvenc"
 h264_omx_encoder_deps="omx"
@@ -2257,6 +2261,7 @@ h264_qsv_decoder_select="h264_mp4toannexb_bsf
h264_parser qsvdec"
 h264_qsv_encoder_select="qsvenc"
 h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
 h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
+hevc_amf_encoder_deps="amf"
 hevc_nvenc_encoder_deps="nvenc"
 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec"
 hevc_qsv_encoder_select="hevcparse qsvenc"
@@ -4573,6 +4578,11 @@ for func in $MATH_FUNCS; do
 done

 # these are off by default, so fail if requested and not available
+
+enabled amf &&
+check_cpp_condition "AMF/core/Version.h" \
+"(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 |
AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x0001000400040001" ||
+disable amf
 enabled avisynth  && require_header avisynth/avisynth_c.h
 enabled avxsynth  && require_header avxsynth/avxsynth_c.h
 enabled cuda  && require cuda cuda.h cuInit -lcuda
diff --git a/doc/general.texi b/doc/general.texi
index 6e39d5c..0c92761 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -237,6 +237,16 @@ The dispatcher is open source and can be downloaded
from
 with the @code{--enable-libmfx} option and @code{pkg-config} needs to be
able to
 locate the dispatcher's @code{.pc} files.

+@section AMD VCE
+
+Libav can use the AMD Advanced Media Framework library for accelerated
H.264 and HEVC encoding on VCE enabled hardware under Windows.
+
+To enable support you must obtain the AMF framework header files from @url{
https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git}.
+
+Create an @code{AMF/} directory in the system include path.
+Copy the contents of @code{AMF/amf/public/include/} into that directory.
+Then Configure Libav with @code{--enable-amf}.
+
 @chapter Supported File Formats and Codecs

 You can use the @code{-formats} and @code{-codecs} options to have an
exhaustive list.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d04902b..99969ac 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -48,6 +48,7 @@ OBJS = ac3_parser.o
   \
 OBJS-$(CONFIG_AANDCTTABLES)+= aandcttab.o
 OBJS-$(CONFIG_AC3DSP)  += ac3dsp.o
 OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o
+OBJS-$(CONFIG_AMF) += amfenc.o
 OBJS-$(CONFIG_AUDIO_FRAME_QUEUE)   += audio_frame_queue.o
 OBJS-$(CONFIG_AUDIODSP)+= audiodsp.o
 OBJS-$(CONFIG_BLOCKDSP)+= blockdsp.o
@@ -271,6 +272,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264dec.o
h264_cabac.o h264_cavlc.o \
   h264_mb.o h264_picture.o \
   h264_refs.o h264_sei.o \
   h264_slice.o h264data.o

Re: [libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-01-03 Thread Luca Barbato

On 03/01/2018 18:55, Mikhail Mironov wrote:

 From 0b90d9c0eb300099ca6845e8ba42bce881670a83 Mon Sep 17 00:00:00 2001
From: Michael Wootton 
Date: Mon, 4 Dec 2017 02:29:01 -0500
Subject: [PATCH] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK
  Requires AMF headers for at least version 1.4.4.1.

Signed-off-by: Mikhail Mironov 


Thank you a lot!

If nobody has other comments I'd fold in the hwaccel caps/.wrapper_name 
support in and push.


diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
index 47a057fdfa..01b0c3a562 100644
--- a/libavcodec/amfenc_h264.c
+++ b/libavcodec/amfenc_h264.c
@@ -366,7 +366,6 @@ static av_cold int 
amf_encode_init_h264(AVCodecContext *avctx)

 static const AVCodecDefault defaults[] = {
 { "refs",   "-1"  },
 { "aspect", "0"   },
-//{ "sar","0"   },
 { "qmin",   "-1"  },
 { "qmax",   "-1"  },
 { "b",  "2M"  },
@@ -381,7 +380,7 @@ static const AVClass h264_amf_class = {
 .option = options,
 .version = LIBAVUTIL_VERSION_INT,
 };
-//TODO declare as HW encoder when available
+
 AVCodec ff_h264_amf_encoder = {
 .name   = "h264_amf",
 .long_name  = NULL_IF_CONFIG_SMALL("AMD AMF H.264 Encoder"),
@@ -394,7 +393,8 @@ AVCodec ff_h264_amf_encoder = {
 .priv_data_size = sizeof(AmfContext),
 .priv_class = _amf_class,
 .defaults   = defaults,
-.capabilities   = AV_CODEC_CAP_DELAY,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .pix_fmts   = ff_amf_pix_fmts,
+.wrapper_name   = "amf",
 };
diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c
index b014a50c9a..fc64decde3 100644
--- a/libavcodec/amfenc_hevc.c
+++ b/libavcodec/amfenc_hevc.c
@@ -301,7 +301,6 @@ static av_cold int 
amf_encode_init_hevc(AVCodecContext *avctx)

 static const AVCodecDefault defaults[] = {
 { "refs",   "-1"  },
 { "aspect", "0"   },
-//{ "sar","0"   },
 { "b",  "2M"  },
 { "g",  "250" },
 { "slices", "1"   },
@@ -313,7 +312,7 @@ static const AVClass hevc_amf_class = {
 .option = options,
 .version = LIBAVUTIL_VERSION_INT,
 };
-//TODO declare as HW encoder when available
+
 AVCodec ff_hevc_amf_encoder = {
 .name   = "hevc_amf",
 .long_name  = NULL_IF_CONFIG_SMALL("AMD AMF HEVC encoder"),
@@ -326,7 +325,8 @@ AVCodec ff_hevc_amf_encoder = {
 .priv_data_size = sizeof(AmfContext),
 .priv_class = _amf_class,
 .defaults   = defaults,
-.capabilities   = AV_CODEC_CAP_DELAY,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .pix_fmts   = ff_amf_pix_fmts,
+.wrapper_name   = "amf",
 };
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK

2018-01-03 Thread Mikhail Mironov
From 0b90d9c0eb300099ca6845e8ba42bce881670a83 Mon Sep 17 00:00:00 2001
From: Michael Wootton 
Date: Mon, 4 Dec 2017 02:29:01 -0500
Subject: [PATCH] Add HW H.264 and HEVC encoding for AMD GPUs based on AMF SDK
 Requires AMF headers for at least version 1.4.4.1.

Signed-off-by: Mikhail Mironov 
---
 configure|  10 +
 doc/general.texi |  10 +
 libavcodec/Makefile  |   4 +
 libavcodec/allcodecs.c   |   2 +
 libavcodec/amfenc.c  | 608 +++
 libavcodec/amfenc.h  | 158 
 libavcodec/amfenc_h264.c | 400 +++
 libavcodec/amfenc_hevc.c | 332 ++
 8 files changed, 1524 insertions(+)
 create mode 100644 libavcodec/amfenc.c
 create mode 100644 libavcodec/amfenc.h
 create mode 100644 libavcodec/amfenc_h264.c
 create mode 100644 libavcodec/amfenc_hevc.c

diff --git a/configure b/configure
index d31cb56..63d5f3a 100755
--- a/configure
+++ b/configure
@@ -231,6 +231,7 @@ External library support:
   --enable-zlib  compression [autodetect]
 
   The following libraries provide various hardware acceleration features:
+  --enable-amf AMF video encoding code [auto]
   --enable-cudaNvidia CUDA (dynamically linked)
   --enable-cuvid   Nvidia CUVID video decode acceleration
   --enable-d3d11va Microsoft Direct3D 11 video acceleration [auto]
@@ -1255,6 +1256,7 @@ HWACCEL_LIBRARY_NONFREE_LIST="
 "
 HWACCEL_LIBRARY_LIST="
 $HWACCEL_LIBRARY_NONFREE_LIST
+amf
 d3d11va
 dxva2
 libmfx
@@ -2238,6 +2240,7 @@ wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
 
 # hardware-accelerated codecs
+amf_deps_any="dlopen LoadLibrary"
 nvenc_deps_any="libdl LoadLibrary"
 omx_deps="libdl pthreads"
 omx_rpi_select="omx"
@@ -2250,6 +2253,7 @@ vaapi_encode_deps="vaapi"
 hwupload_cuda_filter_deps="cuda"
 scale_npp_filter_deps="cuda libnpp"
 
+h264_amf_encoder_deps="amf"
 h264_mmal_decoder_deps="mmal"
 h264_nvenc_encoder_deps="nvenc"
 h264_omx_encoder_deps="omx"
@@ -2257,6 +2261,7 @@ h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser 
qsvdec"
 h264_qsv_encoder_select="qsvenc"
 h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
 h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
+hevc_amf_encoder_deps="amf"
 hevc_nvenc_encoder_deps="nvenc"
 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec"
 hevc_qsv_encoder_select="hevcparse qsvenc"
@@ -4573,6 +4578,11 @@ for func in $MATH_FUNCS; do
 done
 
 # these are off by default, so fail if requested and not available
+
+enabled amf &&
+check_cpp_condition "AMF/core/Version.h" \
+"(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | 
AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x0001000400040001" ||
+disable amf
 enabled avisynth  && require_header avisynth/avisynth_c.h
 enabled avxsynth  && require_header avxsynth/avxsynth_c.h
 enabled cuda  && require cuda cuda.h cuInit -lcuda
diff --git a/doc/general.texi b/doc/general.texi
index 6e39d5c..0c92761 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -237,6 +237,16 @@ The dispatcher is open source and can be downloaded from
 with the @code{--enable-libmfx} option and @code{pkg-config} needs to be able 
to
 locate the dispatcher's @code{.pc} files.
 
+@section AMD VCE
+
+Libav can use the AMD Advanced Media Framework library for accelerated H.264 
and HEVC encoding on VCE enabled hardware under Windows.
+
+To enable support you must obtain the AMF framework header files from 
@url{https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git}.
+
+Create an @code{AMF/} directory in the system include path.
+Copy the contents of @code{AMF/amf/public/include/} into that directory.
+Then Configure Libav with @code{--enable-amf}.
+
 @chapter Supported File Formats and Codecs
 
 You can use the @code{-formats} and @code{-codecs} options to have an 
exhaustive list.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d04902b..99969ac 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -48,6 +48,7 @@ OBJS = ac3_parser.o   
  \
 OBJS-$(CONFIG_AANDCTTABLES)+= aandcttab.o
 OBJS-$(CONFIG_AC3DSP)  += ac3dsp.o
 OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o
+OBJS-$(CONFIG_AMF) += amfenc.o
 OBJS-$(CONFIG_AUDIO_FRAME_QUEUE)   += audio_frame_queue.o
 OBJS-$(CONFIG_AUDIODSP)+= audiodsp.o
 OBJS-$(CONFIG_BLOCKDSP)+= blockdsp.o
@@ -271,6 +272,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264dec.o 
h264_cabac.o h264_cavlc.o \
   h264_mb.o h264_picture.o \
   h264_refs.o h264_sei.o \
   h264_slice.o h264data.o
+OBJS-$(CONFIG_H264_AMF_ENCODER)+=