[FFmpeg-devel] Added HW accelerated H.264 and HEVC encoding for AMD GPUs based on AMF SDK
mmironov
mikhail.mironov at amd.com
Thu Sep 28 21:58:02 EEST 2017
>From 4a47f0e1ee57239fbbc597c0084f486e815ec267 Mon Sep 17 00:00:00 2001
From: mmironov <mikhail.mironov at amd.com>
Date: Thu, 28 Sep 2017 12:30:30 -0400
Subject: [PATCH] Added HW accelerated H.264 and HEVC encoding for AMD GPUs
based on AMF SDK
Signed-off-by: mmironov <mikhail.mironov at amd.com>
---
Changelog | 2 +
compat/amd/amf/LICENSE.txt | 31 +
compat/amd/amf/README.md | 32 +
.../include/components/Ambisonic2SRenderer.h | 79 +
.../amd/amf/public/include/components/Component.h | 393 +++++
.../amf/public/include/components/ComponentCaps.h | 172 ++
.../include/components/FFMPEGAudioConverter.h | 62 +
.../public/include/components/FFMPEGAudioDecoder.h | 68 +
.../public/include/components/FFMPEGAudioEncoder.h | 66 +
.../public/include/components/FFMPEGComponents.h | 50 +
.../public/include/components/FFMPEGFileDemuxer.h | 88 +
.../public/include/components/FFMPEGFileMuxer.h | 80 +
.../amf/public/include/components/MediaSource.h | 79 +
.../amf/public/include/components/VideoConverter.h | 87 +
.../public/include/components/VideoDecoderUVD.h | 87 +
.../public/include/components/VideoEncoderHEVC.h | 189 +++
.../public/include/components/VideoEncoderVCE.h | 222 +++
compat/amd/amf/public/include/core/AudioBuffer.h | 184 +++
compat/amd/amf/public/include/core/Buffer.h | 160 ++
compat/amd/amf/public/include/core/Compute.h | 284 ++++
.../amd/amf/public/include/core/ComputeFactory.h | 146 ++
compat/amd/amf/public/include/core/Context.h | 437 +++++
compat/amd/amf/public/include/core/Data.h | 159 ++
compat/amd/amf/public/include/core/Debug.h | 78 +
compat/amd/amf/public/include/core/Dump.h | 112 ++
compat/amd/amf/public/include/core/Factory.h | 118 ++
compat/amd/amf/public/include/core/Interface.h | 258 +++
compat/amd/amf/public/include/core/Plane.h | 112 ++
compat/amd/amf/public/include/core/Platform.h | 438 +++++
.../amd/amf/public/include/core/PropertyStorage.h | 225 +++
.../amf/public/include/core/PropertyStorageEx.h | 197 +++
compat/amd/amf/public/include/core/Result.h | 127 ++
compat/amd/amf/public/include/core/Surface.h | 232 +++
compat/amd/amf/public/include/core/Trace.h | 183 +++
compat/amd/amf/public/include/core/Variant.h | 1707 ++++++++++++++++++++
compat/amd/amf/public/include/core/Version.h | 59 +
configure | 31 +-
libavcodec/Makefile | 4 +
libavcodec/allcodecs.c | 4 +
libavcodec/amfenc.c | 463 ++++++
libavcodec/amfenc.h | 129 ++
libavcodec/amfenc_h264.c | 467 ++++++
libavcodec/amfenc_hevc.c | 354 ++++
libavcodec/version.h | 4 +-
44 files changed, 8456 insertions(+), 3 deletions(-)
create mode 100644 compat/amd/amf/LICENSE.txt
create mode 100644 compat/amd/amf/README.md
create mode 100644 compat/amd/amf/public/include/components/Ambisonic2SRenderer.h
create mode 100644 compat/amd/amf/public/include/components/Component.h
create mode 100644 compat/amd/amf/public/include/components/ComponentCaps.h
create mode 100644 compat/amd/amf/public/include/components/FFMPEGAudioConverter.h
create mode 100644 compat/amd/amf/public/include/components/FFMPEGAudioDecoder.h
create mode 100644 compat/amd/amf/public/include/components/FFMPEGAudioEncoder.h
create mode 100644 compat/amd/amf/public/include/components/FFMPEGComponents.h
create mode 100644 compat/amd/amf/public/include/components/FFMPEGFileDemuxer.h
create mode 100644 compat/amd/amf/public/include/components/FFMPEGFileMuxer.h
create mode 100644 compat/amd/amf/public/include/components/MediaSource.h
create mode 100644 compat/amd/amf/public/include/components/VideoConverter.h
create mode 100644 compat/amd/amf/public/include/components/VideoDecoderUVD.h
create mode 100644 compat/amd/amf/public/include/components/VideoEncoderHEVC.h
create mode 100644 compat/amd/amf/public/include/components/VideoEncoderVCE.h
create mode 100644 compat/amd/amf/public/include/core/AudioBuffer.h
create mode 100644 compat/amd/amf/public/include/core/Buffer.h
create mode 100644 compat/amd/amf/public/include/core/Compute.h
create mode 100644 compat/amd/amf/public/include/core/ComputeFactory.h
create mode 100644 compat/amd/amf/public/include/core/Context.h
create mode 100644 compat/amd/amf/public/include/core/Data.h
create mode 100644 compat/amd/amf/public/include/core/Debug.h
create mode 100644 compat/amd/amf/public/include/core/Dump.h
create mode 100644 compat/amd/amf/public/include/core/Factory.h
create mode 100644 compat/amd/amf/public/include/core/Interface.h
create mode 100644 compat/amd/amf/public/include/core/Plane.h
create mode 100644 compat/amd/amf/public/include/core/Platform.h
create mode 100644 compat/amd/amf/public/include/core/PropertyStorage.h
create mode 100644 compat/amd/amf/public/include/core/PropertyStorageEx.h
create mode 100644 compat/amd/amf/public/include/core/Result.h
create mode 100644 compat/amd/amf/public/include/core/Surface.h
create mode 100644 compat/amd/amf/public/include/core/Trace.h
create mode 100644 compat/amd/amf/public/include/core/Variant.h
create mode 100644 compat/amd/amf/public/include/core/Version.h
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/Changelog b/Changelog
index 678dcda..aa9a241 100644
--- a/Changelog
+++ b/Changelog
@@ -50,6 +50,8 @@ version <next>:
- KMS screen grabber
- CUDA thumbnail filter
- V4L2 mem2mem HW assisted codecs
+- AMF H.264 encoder
+- AMF HEVC encoder
version 3.3:
diff --git a/compat/amd/amf/LICENSE.txt b/compat/amd/amf/LICENSE.txt
new file mode 100644
index 0000000..5b88538
--- /dev/null
+++ b/compat/amd/amf/LICENSE.txt
@@ -0,0 +1,31 @@
+Notice Regarding Standards. AMD does not provide a license or sublicense to
+any Intellectual Property Rights relating to any standards, including but not
+limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+(collectively, the "Media Technologies"). For clarity, you will pay any
+royalties due for such third party technologies, which may include the Media
+Technologies that are owed as a result of AMD providing the Software to you.
+
+This software uses libraries from the FFmpeg project under the LGPLv2.1.
+
+MIT license
+
+Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/compat/amd/amf/README.md b/compat/amd/amf/README.md
new file mode 100644
index 0000000..00626af
--- /dev/null
+++ b/compat/amd/amf/README.md
@@ -0,0 +1,32 @@
+# Advanced Media Framework (AMF) SDK
+
+AMF is a light-weight, portable multimedia framework that abstracts away most of the platform and API-specific details and allows for easy implementation of multimedia applications using a variety of technologies, such as DirectX 11, OpenGL, and OpenCL and facilitates an efficient interop between them.
+
+These features are a part of the initial 1.3 version of AMF. Version 1.4 of the AMF SDK includes support for the H.265 encoder(HEVC) and bug fixes. Version 1.4.4 has support for FFmpeg 3.3.1.
+
+<div>
+ <a href="https://github.com/GPUOpen-LibrariesAndSDKs/AMF/releases/latest/"><img src="http://gpuopen-librariesandsdks.github.io/media/latest-release-button.svg" alt="Latest release" title="Latest release"></a>
+</div>
+
+### Prerequisites
+* Windows® 7 (SP1 with the [Platform Update](https://msdn.microsoft.com/en-us/library/windows/desktop/jj863687.aspx)), Windows® 8.1, or Windows® 10
+* Visual Studio® 2013, Visual Studio® 2015 or Visual Studio® 2017
+* Version 1.4.4: AMD Radeon Software Crimson Edition 17.7.2 (17.30.1041) or newer
+* Version 1.4: AMD Radeon Software Crimson Edition 17.1.1 (16.50.2611) or newer
+* Version 1.3: AMD Radeon Software Crimson Edition 16.7.3 (16.30.2311) or newer
+* Version 1.4.4 or later requires OCL_SDK_Light: https://github.com/GPUOpen-LibrariesAndSDKs/OCL-SDK/releases. Previous versions of AMF require the AMD APP SDK (Version 3.0 or later), Windows 10 SDK (Version 10586) and some samples require the Microsoft Foundation Class Library (MFC)
+
+The AMF framework is compatible with most recent Radeon GPUs starting with the Southern Islands family and APUs of the Kabini, Kaveri, Carrizo families and newer.
+
+### Getting Started
+* Visual Studio solutions can be found in the `amf\public\samples` directory.
+* Additional documentation can be found in the `amf\doc` directory.
+
+### Third-Party Software
+* FFmpeg is distributed under the terms of the LGPLv2.1.
+
+### Attribution
+* AMD, the AMD Arrow logo, Radeon, and combinations thereof are either registered trademarks or trademarks of Advanced Micro Devices, Inc. in the United States and/or other countries.
+* Microsoft, DirectX, Visual Studio, and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.
+* OpenGL and the oval logo are trademarks or registered trademarks of Silicon Graphics, Inc. in the United States and/or other countries worldwide.
+* OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos.
diff --git a/compat/amd/amf/public/include/components/Ambisonic2SRenderer.h b/compat/amd/amf/public/include/components/Ambisonic2SRenderer.h
new file mode 100644
index 0000000..af9c882
--- /dev/null
+++ b/compat/amd/amf/public/include/components/Ambisonic2SRenderer.h
@@ -0,0 +1,79 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// interface declaration; Ambisonic to Stereo Renderer
+//-------------------------------------------------------------------------------------------------
+
+#ifndef __AMFAmbisonic2SRendererHW__h__
+#define __AMFAmbisonic2SRendererHW__h__
+#pragma once
+
+#include "public/include/components/Component.h"
+
+#define AMFAmbisonic2SRendererHW L"AMFAmbisonic2SRenderer"
+
+enum AMF_AMBISONIC2SRENDERER_MODE_ENUM
+{
+ AMF_AMBISONIC2SRENDERER_MODE_SIMPLE = 0,
+ AMF_AMBISONIC2SRENDERER_MODE_HRTF_AMD0 = 1,
+ AMF_AMBISONIC2SRENDERER_MODE_HRTF_MIT1 = 2,
+};
+
+
+// static properties
+#define AMF_AMBISONIC2SRENDERER_IN_AUDIO_SAMPLE_RATE L"InSampleRate" // amf_int64 (default = 0)
+#define AMF_AMBISONIC2SRENDERER_IN_AUDIO_CHANNELS L"InChannels" // amf_int64 (only = 4)
+#define AMF_AMBISONIC2SRENDERER_IN_AUDIO_SAMPLE_FORMAT L"InSampleFormat" // amf_int64(AMF_AUDIO_FORMAT) (default = AMFAF_FLTP)
+
+#define AMF_AMBISONIC2SRENDERER_OUT_AUDIO_CHANNELS L"OutChannels" // amf_int64 (only = 2 - stereo)
+#define AMF_AMBISONIC2SRENDERER_OUT_AUDIO_SAMPLE_FORMAT L"OutSampleFormat" // amf_int64(AMF_AUDIO_FORMAT) (only = AMFAF_FLTP)
+#define AMF_AMBISONIC2SRENDERER_OUT_AUDIO_CHANNEL_LAYOUT L"OutChannelLayout" // amf_int64 (only = 3 - defalut stereo L R)
+
+#define AMF_AMBISONIC2SRENDERER_MODE L"StereoMode" //TODO: AMF_AMBISONIC2SRENDERER_MODE_ENUM(default=AMF_AMBISONIC2SRENDERER_MODE_HRTF)
+
+
+// dynamic properties
+#define AMF_AMBISONIC2SRENDERER_W L"w" //amf_int64 (default=0)
+#define AMF_AMBISONIC2SRENDERER_X L"x" //amf_int64 (default=1)
+#define AMF_AMBISONIC2SRENDERER_Y L"y" //amf_int64 (default=2)
+#define AMF_AMBISONIC2SRENDERER_Z L"z" //amf_int64 (default=3)
+
+#define AMF_AMBISONIC2SRENDERER_THETA L"Theta" //double (default=0.0)
+#define AMF_AMBISONIC2SRENDERER_PHI L"Phi" //double (default=0.0)
+#define AMF_AMBISONIC2SRENDERER_RHO L"Rho" //double (default=0.0)
+
+extern "C"
+{
+ AMF_RESULT AMF_CDECL_CALL AMFCreateComponentAmbisonic(amf::AMFContext* pContext, void* reserved, amf::AMFComponent** ppComponent);
+}
+#endif //#ifndef __AMFAmbisonic2SRendererHW__h__
diff --git a/compat/amd/amf/public/include/components/Component.h b/compat/amd/amf/public/include/components/Component.h
new file mode 100644
index 0000000..72ab7f5
--- /dev/null
+++ b/compat/amd/amf/public/include/components/Component.h
@@ -0,0 +1,393 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+/**
+ ***************************************************************************************************
+ * @file Component.h
+ * @brief AMFComponent interface declaration
+ ***************************************************************************************************
+ */
+#ifndef __AMFComponent_h__
+#define __AMFComponent_h__
+#pragma once
+
+#include "../core/Data.h"
+#include "../core/PropertyStorageEx.h"
+#include "../core/Surface.h"
+#include "../core/Context.h"
+#include "ComponentCaps.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ // AMFDataAllocatorCB interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFDataAllocatorCB : public AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0x4bf46198, 0x8b7b, 0x49d0, 0xaa, 0x72, 0x48, 0xd4, 0x7, 0xce, 0x24, 0xc5 )
+
+ virtual AMF_RESULT AMF_STD_CALL AllocBuffer(AMF_MEMORY_TYPE type, amf_size size, AMFBuffer** ppBuffer) = 0;
+ virtual AMF_RESULT AMF_STD_CALL AllocSurface(AMF_MEMORY_TYPE type, AMF_SURFACE_FORMAT format,
+ amf_int32 width, amf_int32 height, amf_int32 hPitch, amf_int32 vPitch, AMFSurface** ppSurface) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFDataAllocatorCB> AMFDataAllocatorCBPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFDataAllocatorCB, 0x4bf46198, 0x8b7b, 0x49d0, 0xaa, 0x72, 0x48, 0xd4, 0x7, 0xce, 0x24, 0xc5 )
+ typedef struct AMFDataAllocatorCB AMFDataAllocatorCB;
+
+ typedef struct AMFDataAllocatorCBVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFDataAllocatorCB* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFDataAllocatorCB* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFDataAllocatorCB* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+ // AMFDataAllocatorCB interface
+ AMF_RESULT (AMF_STD_CALL *AllocBuffer)(AMFDataAllocatorCB* pThis, AMF_MEMORY_TYPE type, amf_size size, AMFBuffer** ppBuffer);
+ AMF_RESULT (AMF_STD_CALL *AllocSurface)(AMFDataAllocatorCB* pThis, AMF_MEMORY_TYPE type, AMF_SURFACE_FORMAT format,
+ amf_int32 width, amf_int32 height, amf_int32 hPitch, amf_int32 vPitch, AMFSurface** ppSurface);
+ } AMFDataAllocatorCBVtbl;
+
+ struct AMFDataAllocatorCB
+ {
+ const AMFDataAllocatorCBVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFComponentOptimizationCallback
+ {
+ public:
+ virtual AMF_RESULT AMF_STD_CALL OnComponentOptimizationProgress(amf_uint percent) = 0;
+ };
+#else // #if defined(__cplusplus)
+ typedef struct AMFComponentOptimizationCallback AMFComponentOptimizationCallback;
+ typedef struct AMFComponentOptimizationCallbackVtbl
+ {
+ // AMFDataAllocatorCB interface
+ AMF_RESULT (AMF_STD_CALL *OnComponentOptimizationProgress)(AMFComponentOptimizationCallback* pThis, amf_uint percent);
+ } AMFComponentOptimizationCallbackVtbl;
+
+ struct AMFComponentOptimizationCallback
+ {
+ const AMFComponentOptimizationCallbackVtbl *pVtbl;
+ };
+
+#endif //#if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+ // AMFComponent interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFComponent : public AMFPropertyStorageEx
+ {
+ public:
+ AMF_DECLARE_IID(0x8b51e5e4, 0x455d, 0x4034, 0xa7, 0x46, 0xde, 0x1b, 0xed, 0xc3, 0xc4, 0x6)
+
+ virtual AMF_RESULT AMF_STD_CALL Init(AMF_SURFACE_FORMAT format,amf_int32 width,amf_int32 height) = 0;
+ virtual AMF_RESULT AMF_STD_CALL ReInit(amf_int32 width,amf_int32 height) = 0;
+ virtual AMF_RESULT AMF_STD_CALL Terminate() = 0;
+ virtual AMF_RESULT AMF_STD_CALL Drain() = 0;
+ virtual AMF_RESULT AMF_STD_CALL Flush() = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL SubmitInput(AMFData* pData) = 0;
+ virtual AMF_RESULT AMF_STD_CALL QueryOutput(AMFData** ppData) = 0;
+ virtual AMFContext* AMF_STD_CALL GetContext() = 0;
+ virtual AMF_RESULT AMF_STD_CALL SetOutputDataAllocatorCB(AMFDataAllocatorCB* callback) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL GetCaps(AMFCaps** ppCaps) = 0;
+ virtual AMF_RESULT AMF_STD_CALL Optimize(AMFComponentOptimizationCallback* pCallback) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFComponent> AMFComponentPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFComponent, 0x8b51e5e4, 0x455d, 0x4034, 0xa7, 0x46, 0xde, 0x1b, 0xed, 0xc3, 0xc4, 0x6)
+ typedef struct AMFComponent AMFComponent;
+
+ typedef struct AMFComponentVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFComponent* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFComponent* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFComponent* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFComponent* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFComponent* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFComponent* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFComponent* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFComponent* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFComponent* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFComponent* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFComponent* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFComponent* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFComponent* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFPropertyStorageEx interface
+
+ amf_size (AMF_STD_CALL *GetPropertiesInfoCount)(AMFComponent* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfoAt)(AMFComponent* pThis, amf_size index, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfo)(AMFComponent* pThis, const wchar_t* name, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *ValidateProperty)(AMFComponent* pThis, const wchar_t* name, AMFVariantStruct value, AMFVariantStruct* pOutValidated);
+
+ // AMFComponent interface
+
+ AMF_RESULT (AMF_STD_CALL *Init)(AMFComponent* pThis, AMF_SURFACE_FORMAT format,amf_int32 width,amf_int32 height);
+ AMF_RESULT (AMF_STD_CALL *ReInit)(AMFComponent* pThis, amf_int32 width,amf_int32 height);
+ AMF_RESULT (AMF_STD_CALL *Terminate)(AMFComponent* pThis);
+ AMF_RESULT (AMF_STD_CALL *Drain)(AMFComponent* pThis);
+ AMF_RESULT (AMF_STD_CALL *Flush)(AMFComponent* pThis);
+
+ AMF_RESULT (AMF_STD_CALL *SubmitInput)(AMFComponent* pThis, AMFData* pData);
+ AMF_RESULT (AMF_STD_CALL *QueryOutput)(AMFComponent* pThis, AMFData** ppData);
+ AMFContext* (AMF_STD_CALL *GetContext)(AMFComponent* pThis);
+ AMF_RESULT (AMF_STD_CALL *SetOutputDataAllocatorCB)(AMFComponent* pThis, AMFDataAllocatorCB* callback);
+
+ AMF_RESULT (AMF_STD_CALL *GetCaps)(AMFComponent* pThis, AMFCaps** ppCaps);
+ AMF_RESULT (AMF_STD_CALL *Optimize)(AMFComponent* pThis, AMFComponentOptimizationCallback* pCallback);
+ } AMFComponentVtbl;
+
+ struct AMFComponent
+ {
+ const AMFComponentVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+ // AMFInput interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFInput : public AMFPropertyStorageEx
+ {
+ public:
+ AMF_DECLARE_IID(0x1181eee7, 0x95f2, 0x434a, 0x9b, 0x96, 0xea, 0x55, 0xa, 0xa7, 0x84, 0x89)
+
+ virtual AMF_RESULT AMF_STD_CALL SubmitInput(AMFData* pData) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFInput> AMFInputPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFInput, 0x1181eee7, 0x95f2, 0x434a, 0x9b, 0x96, 0xea, 0x55, 0xa, 0xa7, 0x84, 0x89)
+ typedef struct AMFInput AMFInput;
+
+ typedef struct AMFInputVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFInput* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFInput* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFInput* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFInput* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFInput* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFInput* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFInput* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFInput* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFInput* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFInput* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFInput* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFInput* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFInput* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFPropertyStorageEx interface
+
+ amf_size (AMF_STD_CALL *GetPropertiesInfoCount)(AMFInput* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfoAt)(AMFInput* pThis, amf_size index, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfo)(AMFInput* pThis, const wchar_t* name, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *ValidateProperty)(AMFInput* pThis, const wchar_t* name, AMFVariantStruct value, AMFVariantStruct* pOutValidated);
+
+ // AMFInput interface
+ AMF_RESULT (AMF_STD_CALL *SubmitInput)(AMFInput* pThis, AMFData* pData);
+
+ } AMFInputVtbl;
+
+ struct AMFInput
+ {
+ const AMFInputVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+ // AMFOutput interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFOutput : public AMFPropertyStorageEx
+ {
+ public:
+ AMF_DECLARE_IID(0x86a8a037, 0x912c, 0x4698, 0xb0, 0x46, 0x7, 0x5a, 0x1f, 0xac, 0x6b, 0x97);
+
+ virtual AMF_RESULT AMF_STD_CALL QueryOutput(AMFData** ppData) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFOutput> AMFOutputPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFOutput, 0x86a8a037, 0x912c, 0x4698, 0xb0, 0x46, 0x7, 0x5a, 0x1f, 0xac, 0x6b, 0x97);
+ typedef struct AMFOutput AMFOutput;
+
+ typedef struct AMFOutputVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFOutput* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFOutput* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFOutput* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFOutput* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFOutput* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFOutput* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFOutput* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFOutput* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFOutput* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFOutput* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFOutput* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFOutput* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFOutput* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFPropertyStorageEx interface
+
+ amf_size (AMF_STD_CALL *GetPropertiesInfoCount)(AMFOutput* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfoAt)(AMFOutput* pThis, amf_size index, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfo)(AMFOutput* pThis, const wchar_t* name, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *ValidateProperty)(AMFOutput* pThis, const wchar_t* name, AMFVariantStruct value, AMFVariantStruct* pOutValidated);
+
+ // AMFOutput interface
+ AMF_RESULT (AMF_STD_CALL *QueryOutput)(AMFOutput* pThis, AMFData** ppData);
+
+ } AMFOutputVtbl;
+
+ struct AMFOutput
+ {
+ const AMFOutputVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+ // AMFComponent interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFComponentEx : public AMFComponent
+ {
+ public:
+ AMF_DECLARE_IID(0xfda792af, 0x8712, 0x44df, 0x8e, 0xa0, 0xdf, 0xfa, 0xad, 0x2c, 0x80, 0x93)
+
+ virtual amf_int32 AMF_STD_CALL GetInputCount() = 0;
+ virtual amf_int32 AMF_STD_CALL GetOutputCount() = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL GetInput(amf_int32 index, AMFInput** ppInput) = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetOutput(amf_int32 index, AMFOutput** ppOutput) = 0;
+
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFComponentEx> AMFComponentExPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFComponentEx, 0xfda792af, 0x8712, 0x44df, 0x8e, 0xa0, 0xdf, 0xfa, 0xad, 0x2c, 0x80, 0x93)
+ typedef struct AMFComponentEx AMFComponentEx;
+
+ typedef struct AMFComponentExVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFComponentEx* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFComponentEx* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFComponentEx* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFComponentEx* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFComponentEx* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFComponentEx* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFComponentEx* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFComponentEx* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFComponentEx* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFComponentEx* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFComponentEx* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFComponentEx* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFComponentEx* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFPropertyStorageEx interface
+
+ amf_size (AMF_STD_CALL *GetPropertiesInfoCount)(AMFComponentEx* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfoAt)(AMFComponentEx* pThis, amf_size index, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfo)(AMFComponentEx* pThis, const wchar_t* name, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *ValidateProperty)(AMFComponentEx* pThis, const wchar_t* name, AMFVariantStruct value, AMFVariantStruct* pOutValidated);
+
+ // AMFComponent interface
+
+ AMF_RESULT (AMF_STD_CALL *Init)(AMFComponentEx* pThis, AMF_SURFACE_FORMAT format,amf_int32 width,amf_int32 height);
+ AMF_RESULT (AMF_STD_CALL *ReInit)(AMFComponentEx* pThis, amf_int32 width,amf_int32 height);
+ AMF_RESULT (AMF_STD_CALL *Terminate)(AMFComponentEx* pThis);
+ AMF_RESULT (AMF_STD_CALL *Drain)(AMFComponentEx* pThis);
+ AMF_RESULT (AMF_STD_CALL *Flush)(AMFComponentEx* pThis);
+
+ AMF_RESULT (AMF_STD_CALL *SubmitInput)(AMFComponentEx* pThis, AMFData* pData);
+ AMF_RESULT (AMF_STD_CALL *QueryOutput)(AMFComponentEx* pThis, AMFData** ppData);
+ AMFContext* (AMF_STD_CALL *GetContext)(AMFComponentEx* pThis);
+ AMF_RESULT (AMF_STD_CALL *SetOutputDataAllocatorCB)(AMFComponentEx* pThis, AMFDataAllocatorCB* callback);
+
+ AMF_RESULT (AMF_STD_CALL *GetCaps)(AMFComponentEx* pThis, AMFCaps** ppCaps);
+ AMF_RESULT (AMF_STD_CALL *Optimize)(AMFComponentEx* pThis, AMFComponentOptimizationCallback* pCallback);
+
+ // AMFComponentEx interface
+
+ amf_int32 (AMF_STD_CALL *GetInputCount)(AMFComponentEx* pThis);
+ amf_int32 (AMF_STD_CALL *GetOutputCount)(AMFComponentEx* pThis);
+
+ AMF_RESULT (AMF_STD_CALL *GetInput)(AMFComponentEx* pThis, amf_int32 index, AMFInput** ppInput);
+ AMF_RESULT (AMF_STD_CALL *GetOutput)(AMFComponentEx* pThis, amf_int32 index, AMFOutput** ppOutput);
+
+
+ } AMFComponentExVtbl;
+
+ struct AMFComponentEx
+ {
+ const AMFComponentExVtbl *pVtbl;
+ };
+
+
+#endif // #if defined(__cplusplus)
+#if defined(__cplusplus)
+} // namespace
+#endif
+
+#endif //#ifndef __AMFComponent_h__
diff --git a/compat/amd/amf/public/include/components/ComponentCaps.h b/compat/amd/amf/public/include/components/ComponentCaps.h
new file mode 100644
index 0000000..31daef5
--- /dev/null
+++ b/compat/amd/amf/public/include/components/ComponentCaps.h
@@ -0,0 +1,172 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFComponentCaps_h__
+#define __AMFComponentCaps_h__
+
+#pragma once
+
+#include "../core/Interface.h"
+#include "../core/PropertyStorage.h"
+#include "../core/Surface.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ typedef enum AMF_ACCELERATION_TYPE
+ {
+ AMF_ACCEL_NOT_SUPPORTED = -1,
+ AMF_ACCEL_HARDWARE,
+ AMF_ACCEL_GPU,
+ AMF_ACCEL_SOFTWARE
+ } AMF_ACCELERATION_TYPE;
+ //----------------------------------------------------------------------------------------------
+ // AMFIOCaps interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFIOCaps : public AMFInterface
+ {
+ public:
+ // Get supported resolution ranges in pixels/lines:
+ virtual void AMF_STD_CALL GetWidthRange(amf_int32* minWidth, amf_int32* maxWidth) const = 0;
+ virtual void AMF_STD_CALL GetHeightRange(amf_int32* minHeight, amf_int32* maxHeight) const = 0;
+
+ // Get memory alignment in lines: Vertical aligmnent should be multiples of this number
+ virtual amf_int32 AMF_STD_CALL GetVertAlign() const = 0;
+
+ // Enumerate supported surface pixel formats
+ virtual amf_int32 AMF_STD_CALL GetNumOfFormats() const = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetFormatAt(amf_int32 index, AMF_SURFACE_FORMAT* format, amf_bool* native) const = 0;
+
+ // Enumerate supported memory types
+ virtual amf_int32 AMF_STD_CALL GetNumOfMemoryTypes() const = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetMemoryTypeAt(amf_int32 index, AMF_MEMORY_TYPE* memType, amf_bool* native) const = 0;
+
+ virtual amf_bool AMF_STD_CALL IsInterlacedSupported() const = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFIOCaps> AMFIOCapsPtr;
+#else // #if defined(__cplusplus)
+ typedef struct AMFIOCaps AMFIOCaps;
+
+ typedef struct AMFIOCapsVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFIOCaps* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFIOCaps* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFIOCaps* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFIOCaps interface
+ // Get supported resolution ranges in pixels/lines:
+ void (AMF_STD_CALL *GetWidthRange)(AMFIOCaps* pThis, amf_int32* minWidth, amf_int32* maxWidth);
+ void (AMF_STD_CALL *GetHeightRange)(AMFIOCaps* pThis, amf_int32* minHeight, amf_int32* maxHeight);
+
+ // Get memory alignment in lines: Vertical aligmnent should be multiples of this number
+ amf_int32 (AMF_STD_CALL *GetVertAlign)(AMFIOCaps* pThis);
+
+ // Enumerate supported surface pixel formats
+ amf_int32 (AMF_STD_CALL *GetNumOfFormats)(AMFIOCaps* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetFormatAt)(AMFIOCaps* pThis, amf_int32 index, AMF_SURFACE_FORMAT* format, amf_bool* native);
+
+ // Enumerate supported memory types
+ amf_int32 (AMF_STD_CALL *GetNumOfMemoryTypes)(AMFIOCaps* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetMemoryTypeAt)(AMFIOCaps* pThis, amf_int32 index, AMF_MEMORY_TYPE* memType, amf_bool* native);
+
+ amf_bool (AMF_STD_CALL *IsInterlacedSupported)(AMFIOCaps* pThis);
+ } AMFIOCapsVtbl;
+
+ struct AMFIOCaps
+ {
+ const AMFIOCapsVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+ // AMFCaps interface - base interface for every h/w module supported by Capability Manager
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFCaps : public AMFPropertyStorage
+ {
+ public:
+ virtual AMF_ACCELERATION_TYPE AMF_STD_CALL GetAccelerationType() const = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetInputCaps(AMFIOCaps** input) = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetOutputCaps(AMFIOCaps** output) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFCaps> AMFCapsPtr;
+#else // #if defined(__cplusplus)
+ typedef struct AMFCaps AMFCaps;
+
+ typedef struct AMFCapsVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFCaps* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFCaps* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFCaps* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFCaps* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFCaps* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFCaps* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFCaps* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFCaps* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFCaps* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFCaps* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFCaps* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFCaps* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFCaps* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFCaps interface
+
+ AMF_ACCELERATION_TYPE (AMF_STD_CALL *GetAccelerationType)(AMFCaps* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetInputCaps)(AMFCaps* pThis, AMFIOCaps** input);
+ AMF_RESULT (AMF_STD_CALL *GetOutputCaps)(AMFCaps* pThis, AMFIOCaps** output);
+ } AMFCapsVtbl;
+
+ struct AMFCaps
+ {
+ const AMFCapsVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+}
+#endif
+
+#endif //#ifndef __AMFComponentCaps_h__
diff --git a/compat/amd/amf/public/include/components/FFMPEGAudioConverter.h b/compat/amd/amf/public/include/components/FFMPEGAudioConverter.h
new file mode 100644
index 0000000..8fdb400
--- /dev/null
+++ b/compat/amd/amf/public/include/components/FFMPEGAudioConverter.h
@@ -0,0 +1,62 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// AMFFAudioConverterFFMPEG interface declaration
+//-------------------------------------------------------------------------------------------------
+
+#ifndef __AMFAudioConverterFFMPEG_h__
+#define __AMFAudioConverterFFMPEG_h__
+
+#pragma once
+
+
+#define FFMPEG_AUDIO_CONVERTER L"AudioConverterFFMPEG"
+
+
+#define AUDIO_CONVERTER_IN_AUDIO_BIT_RATE L"In_BitRate" // amf_int64 (default = 128000)
+#define AUDIO_CONVERTER_IN_AUDIO_SAMPLE_RATE L"In_SampleRate" // amf_int64 (default = 0)
+#define AUDIO_CONVERTER_IN_AUDIO_CHANNELS L"In_Channels" // amf_int64 (default = 2)
+#define AUDIO_CONVERTER_IN_AUDIO_SAMPLE_FORMAT L"In_SampleFormat" // amf_int64 (default = AMFAF_UNKNOWN) (AMF_AUDIO_FORMAT)
+#define AUDIO_CONVERTER_IN_AUDIO_CHANNEL_LAYOUT L"In_ChannelLayout" // amf_int64 (default = 0)
+#define AUDIO_CONVERTER_IN_AUDIO_BLOCK_ALIGN L"In_BlockAlign" // amf_int64 (default = 0)
+
+#define AUDIO_CONVERTER_OUT_AUDIO_BIT_RATE L"Out_BitRate" // amf_int64 (default = 128000)
+#define AUDIO_CONVERTER_OUT_AUDIO_SAMPLE_RATE L"Out_SampleRate" // amf_int64 (default = 0)
+#define AUDIO_CONVERTER_OUT_AUDIO_CHANNELS L"Out_Channels" // amf_int64 (default = 2)
+#define AUDIO_CONVERTER_OUT_AUDIO_SAMPLE_FORMAT L"Out_SampleFormat" // amf_int64 (default = AMFAF_UNKNOWN) (AMF_AUDIO_FORMAT)
+#define AUDIO_CONVERTER_OUT_AUDIO_CHANNEL_LAYOUT L"Out_ChannelLayout" // amf_int64 (default = 0)
+#define AUDIO_CONVERTER_OUT_AUDIO_BLOCK_ALIGN L"Out_BlockAlign" // amf_int64 (default = 0)
+
+
+
+#endif //#ifndef __AMFAudioConverterFFMPEG_h__
diff --git a/compat/amd/amf/public/include/components/FFMPEGAudioDecoder.h b/compat/amd/amf/public/include/components/FFMPEGAudioDecoder.h
new file mode 100644
index 0000000..d786c19
--- /dev/null
+++ b/compat/amd/amf/public/include/components/FFMPEGAudioDecoder.h
@@ -0,0 +1,68 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// AudioDecoderFFMPEG interface declaration
+//-------------------------------------------------------------------------------------------------
+#ifndef __AMFAudioDecoderFFMPEG_h__
+#define __AMFAudioDecoderFFMPEG_h__
+
+#pragma once
+
+
+#define FFMPEG_AUDIO_DECODER L"AudioDecoderFFMPEG"
+
+
+#define AUDIO_DECODER_ENABLE_DEBUGGING L"EnableDebug" // bool (default = false) - trace some debug information if set to true
+#define AUDIO_DECODER_ENABLE_DECODING L"EnableDecoding" // bool (default = true) - if false, component will not decode anything
+
+#define AUDIO_DECODER_IN_AUDIO_CODEC_ID L"In_CodecID" // amf_int64 (default = AV_CODEC_ID_NONE) - FFMPEG codec ID
+#define AUDIO_DECODER_IN_AUDIO_BIT_RATE L"In_BitRate" // amf_int64 (default = 128000)
+#define AUDIO_DECODER_IN_AUDIO_EXTRA_DATA L"In_ExtraData" // interface to AMFBuffer
+#define AUDIO_DECODER_IN_AUDIO_SAMPLE_RATE L"In_SampleRate" // amf_int64 (default = 0)
+#define AUDIO_DECODER_IN_AUDIO_CHANNELS L"In_Channels" // amf_int64 (default = 2)
+#define AUDIO_DECODER_IN_AUDIO_SAMPLE_FORMAT L"In_SampleFormat" // amf_int64 (default = AMFAF_UNKNOWN) (AMF_AUDIO_FORMAT)
+#define AUDIO_DECODER_IN_AUDIO_CHANNEL_LAYOUT L"In_ChannelLayout" // amf_int64 (default = 0)
+#define AUDIO_DECODER_IN_AUDIO_BLOCK_ALIGN L"In_BlockAlign" // amf_int64 (default = 0)
+#define AUDIO_DECODER_IN_AUDIO_FRAME_SIZE L"In_FrameSize" // amf_int64 (default = 0)
+#define AUDIO_DECODER_IN_AUDIO_SEEK_POSITION L"In_SeekPosition" // amf_int64 (default = 0)
+
+#define AUDIO_DECODER_OUT_AUDIO_BIT_RATE L"Out_BitRate" // amf_int64 (default = 128000)
+#define AUDIO_DECODER_OUT_AUDIO_SAMPLE_RATE L"Out_SampleRate" // amf_int64 (default = 0)
+#define AUDIO_DECODER_OUT_AUDIO_CHANNELS L"Out_Channels" // amf_int64 (default = 2)
+#define AUDIO_DECODER_OUT_AUDIO_SAMPLE_FORMAT L"Out_SampleFormat" // amf_int64 (default = AMFAF_UNKNOWN) (AMF_AUDIO_FORMAT)
+#define AUDIO_DECODER_OUT_AUDIO_CHANNEL_LAYOUT L"Out_ChannelLayout" // amf_int64 (default = 0)
+#define AUDIO_DECODER_OUT_AUDIO_BLOCK_ALIGN L"Out_BlockAlign" // amf_int64 (default = 0)
+
+
+
+#endif //#ifndef __AMFAudioDecoderFFMPEG_h__
diff --git a/compat/amd/amf/public/include/components/FFMPEGAudioEncoder.h b/compat/amd/amf/public/include/components/FFMPEGAudioEncoder.h
new file mode 100644
index 0000000..5ff168c
--- /dev/null
+++ b/compat/amd/amf/public/include/components/FFMPEGAudioEncoder.h
@@ -0,0 +1,66 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// AudioEncoderFFMPEG interface declaration
+//-------------------------------------------------------------------------------------------------
+#ifndef __AMFAudioEncoderFFMPEG_h__
+#define __AMFAudioEncoderFFMPEG_h__
+
+#pragma once
+
+
+#define FFMPEG_AUDIO_ENCODER L"AudioEncoderFFMPEG"
+
+
+#define AUDIO_ENCODER_ENABLE_DEBUGGING L"EnableDebug" // bool (default = false) - trace some debug information if set to true
+#define AUDIO_ENCODER_ENABLE_ENCODING L"EnableEncoding" // bool (default = true) - if false, component will not encode anything
+#define AUDIO_ENCODER_AUDIO_CODEC_ID L"CodecID" // amf_int64 (default = AV_CODEC_ID_NONE) - FFMPEG codec ID
+
+#define AUDIO_ENCODER_IN_AUDIO_SAMPLE_RATE L"In_SampleRate" // amf_int64 (default = 44100)
+#define AUDIO_ENCODER_IN_AUDIO_CHANNELS L"In_Channels" // amf_int64 (default = 2)
+#define AUDIO_ENCODER_IN_AUDIO_SAMPLE_FORMAT L"In_SampleFormat" // amf_int64 (default = AMFAF_S16) (AMF_AUDIO_FORMAT)
+#define AUDIO_ENCODER_IN_AUDIO_CHANNEL_LAYOUT L"In_ChannelLayout" // amf_int64 (default = 3)
+#define AUDIO_ENCODER_IN_AUDIO_BLOCK_ALIGN L"In_BlockAlign" // amf_int64 (default = 0)
+
+#define AUDIO_ENCODER_OUT_AUDIO_BIT_RATE L"Out_BitRate" // amf_int64 (default = 128000)
+#define AUDIO_ENCODER_OUT_AUDIO_EXTRA_DATA L"Out_ExtraData" // interface to AMFBuffer
+#define AUDIO_ENCODER_OUT_AUDIO_SAMPLE_RATE L"Out_SampleRate" // amf_int64 (default = 44100)
+#define AUDIO_ENCODER_OUT_AUDIO_CHANNELS L"Out_Channels" // amf_int64 (default = 2)
+#define AUDIO_ENCODER_OUT_AUDIO_SAMPLE_FORMAT L"Out_SampleFormat" // amf_int64 (default = AMFAF_S16) (AMF_AUDIO_FORMAT)
+#define AUDIO_ENCODER_OUT_AUDIO_CHANNEL_LAYOUT L"Out_ChannelLayout" // amf_int64 (default = 0)
+#define AUDIO_ENCODER_OUT_AUDIO_BLOCK_ALIGN L"Out_BlockAlign" // amf_int64 (default = 0)
+#define AUDIO_ENCODER_OUT_AUDIO_FRAME_SIZE L"Out_FrameSize" // amf_int64 (default = 0)
+
+
+
+#endif //#ifndef __AMFAudioEncoderFFMPEG_h__
diff --git a/compat/amd/amf/public/include/components/FFMPEGComponents.h b/compat/amd/amf/public/include/components/FFMPEGComponents.h
new file mode 100644
index 0000000..f6af7d7
--- /dev/null
+++ b/compat/amd/amf/public/include/components/FFMPEGComponents.h
@@ -0,0 +1,50 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// FFMPEG components definitions
+//-------------------------------------------------------------------------------------------------
+
+#ifndef __AMFComponentsFFMPEG_h__
+#define __AMFComponentsFFMPEG_h__
+
+#pragma once
+
+
+#if defined(_M_AMD64)
+ #define FFMPEG_DLL_NAME L"amf-component-ffmpeg64.dll"
+#else
+ #define FFMPEG_DLL_NAME L"amf-component-ffmpeg32.dll"
+#endif
+
+
+#endif //#ifndef __AMFComponentsFFMPEG_h__
diff --git a/compat/amd/amf/public/include/components/FFMPEGFileDemuxer.h b/compat/amd/amf/public/include/components/FFMPEGFileDemuxer.h
new file mode 100644
index 0000000..7e2591a
--- /dev/null
+++ b/compat/amd/amf/public/include/components/FFMPEGFileDemuxer.h
@@ -0,0 +1,88 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// DemuxerFFMPEG interface declaration
+//-------------------------------------------------------------------------------------------------
+#ifndef __AMFFileDemuxerFFMPEG_h__
+#define __AMFFileDemuxerFFMPEG_h__
+
+#pragma once
+
+#define FFMPEG_DEMUXER L"DemuxerFFMPEG"
+
+enum FFMPEG_DEMUXER_STREAM_TYPE_ENUM
+{
+ DEMUXER_UNKNOWN = -1,
+ DEMUXER_VIDEO = 0,
+ DEMUXER_AUDIO = 1,
+ DEMUXER_DATA = 2,
+};
+
+
+// component properties
+#define FFMPEG_DEMUXER_PATH L"Path" // string - the file to open
+#define FFMPEG_DEMUXER_URL L"Url" // string - the stream url to open
+#define FFMPEG_DEMUXER_START_FRAME L"StartFrame" // amf_int64 (default = 0)
+#define FFMPEG_DEMUXER_FRAME_COUNT L"FramesNumber" // amf_int64 (default = 0)
+#define FFMPEG_DEMUXER_DURATION L"Duration" // amf_int64 (default = 0)
+#define FFMPEG_DEMUXER_CHECK_MVC L"CheckMVC" // bool (default = true)
+//#define FFMPEG_DEMUXER_SYNC_AV L"SyncAV" // bool (default = false)
+#define FFMPEG_DEMUXER_INDIVIDUAL_STREAM_MODE L"StreamMode" // bool (default = true)
+#define FFMPEG_DEMUXER_LISTEN L"Listen" // bool (default = false)
+
+//common stream properties
+#define FFMPEG_DEMUXER_STREAM_TYPE L"StreamType" // amf_int64( FFMPEG_DEMUXER_STREAM_TYPE_ENUM )
+#define FFMPEG_DEMUXER_STREAM_ENABLED L"Enabled" // bool( default = false )
+#define FFMPEG_DEMUXER_CODEC_ID L"CodecID" // amf_int64 (default = AV_CODEC_ID_NONE) - FFMPEG codec ID
+#define FFMPEG_DEMUXER_BIT_RATE L"BitRate" // amf_int64 (default = codec->bit_rate)
+#define FFMPEG_DEMUXER_EXTRA_DATA L"ExtraData" // interface to AMFBuffer - as is from FFMPEG
+
+// video stream properties
+#define FFMPEG_DEMUXER_VIDEO_DECODER_ID L"DecoderID" // string (default - name of the codec ID - see VideoDecoderUVD.h)
+#define FFMPEG_DEMUXER_VIDEO_FRAME_RATE L"FrameRate" // AMFRate; default - from file
+#define FFMPEG_DEMUXER_VIDEO_FRAMESIZE L"FrameSize" // AMFSize; default = 0,0; Frame size
+#define FFMPEG_DEMUXER_VIDEO_SURFACE_FORMAT L"SurfaceFormat" // amf_int64( AMF_OUTPUT_FORMATS_ENUM )
+#define FFMPEG_DEMUXER_VIDEO_PIXEL_ASPECT_RATIO L"PixelAspectRatio" // double (default = calculated)
+
+// audio stream properties
+#define FFMPEG_DEMUXER_AUDIO_SAMPLE_RATE L"SampleRate" // amf_int64 (default = codec->sample_rate)
+#define FFMPEG_DEMUXER_AUDIO_CHANNELS L"Channels" // amf_int64 (default = codec->channels)
+#define FFMPEG_DEMUXER_AUDIO_SAMPLE_FORMAT L"SampleFormat" // amf_int64( AMF_AUDIO_FORMAT )
+#define FFMPEG_DEMUXER_AUDIO_CHANNEL_LAYOUT L"ChannelLayout" // amf_int64 (default = codec->channel_layout)
+#define FFMPEG_DEMUXER_AUDIO_BLOCK_ALIGN L"BlockAlign" // amf_int64 (default = codec->block_align)
+#define FFMPEG_DEMUXER_AUDIO_FRAME_SIZE L"FrameSize" // amf_int64 (default = codec->frame_size)
+
+// buffer properties
+#define FFMPEG_DEMUXER_BUFFER_TYPE L"BufferType" // amf_int64 ( FFMPEG_DEMUXER_STREAM_TYPE_ENUM )
+#define FFMPEG_DEMUXER_BUFFER_STREAM_INDEX L"BufferStreamIndexType" // amf_int64 ( stream index )
+#endif //#ifndef __AMFFileDemuxerFFMPEG_h__
diff --git a/compat/amd/amf/public/include/components/FFMPEGFileMuxer.h b/compat/amd/amf/public/include/components/FFMPEGFileMuxer.h
new file mode 100644
index 0000000..eff516c
--- /dev/null
+++ b/compat/amd/amf/public/include/components/FFMPEGFileMuxer.h
@@ -0,0 +1,80 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// MuxerFFMPEG interface declaration
+//-------------------------------------------------------------------------------------------------
+#ifndef __AMFFileMuxerFFMPEG_h__
+#define __AMFFileMuxerFFMPEG_h__
+
+#pragma once
+
+#define FFMPEG_MUXER L"MuxerFFMPEG"
+
+enum FFMPEG_MUXER_STREAM_TYPE_ENUM
+{
+ MUXER_UNKNOWN = -1,
+ MUXER_VIDEO = 0,
+ MUXER_AUDIO = 1,
+ MUXER_DATA = 2,
+};
+
+
+// component properties
+#define FFMPEG_MUXER_PATH L"Path" // string - the file to open
+#define FFMPEG_MUXER_URL L"Url" // string - the stream url to open
+#define FFMPEG_MUXER_LISTEN L"Listen" // bool (default = false)
+#define FFMPEG_MUXER_ENABLE_VIDEO L"EnableVideo" // bool (default = true)
+#define FFMPEG_MUXER_ENABLE_AUDIO L"EnableAudio" // bool (default = false)
+
+//common stream properties
+#define FFMPEG_MUXER_STREAM_TYPE L"StreamType" // amf_int64( FFMPEG_MUXER_STREAM_TYPE_ENUM )
+#define FFMPEG_MUXER_STREAM_ENABLED L"Enabled" // bool( default = false )
+#define FFMPEG_MUXER_CODEC_ID L"CodecID" // amf_int64 (default = AV_CODEC_ID_NONE) - FFMPEG codec ID
+#define FFMPEG_MUXER_BIT_RATE L"BitRate" // amf_int64 (default = codec->bit_rate)
+#define FFMPEG_MUXER_EXTRA_DATA L"ExtraData" // interface to AMFBuffer
+
+// video stream properties
+#define FFMPEG_MUXER_VIDEO_FRAME_RATE L"FrameRate" // AMFRate;
+#define FFMPEG_MUXER_VIDEO_FRAMESIZE L"FrameSize" // AMFSize; default = 0,0; Frame size
+
+// audio stream properties
+#define FFMPEG_MUXER_AUDIO_SAMPLE_RATE L"SampleRate" // amf_int64 (default = codec->sample_rate)
+#define FFMPEG_MUXER_AUDIO_CHANNELS L"Channels" // amf_int64 (default = codec->channels)
+#define FFMPEG_MUXER_AUDIO_SAMPLE_FORMAT L"SampleFormat" // amf_int64( AMF_AUDIO_FORMAT )
+#define FFMPEG_MUXER_AUDIO_CHANNEL_LAYOUT L"ChannelLayout" // amf_int64 (default = codec->channel_layout)
+#define FFMPEG_MUXER_AUDIO_BLOCK_ALIGN L"BlockAlign" // amf_int64 (default = codec->block_align)
+#define FFMPEG_MUXER_AUDIO_FRAME_SIZE L"FrameSize" // amf_int64 (default = codec->frame_size)
+
+
+
+#endif //#ifndef __AMFFileMuxerFFMPEG_h__
diff --git a/compat/amd/amf/public/include/components/MediaSource.h b/compat/amd/amf/public/include/components/MediaSource.h
new file mode 100644
index 0000000..c6af342
--- /dev/null
+++ b/compat/amd/amf/public/include/components/MediaSource.h
@@ -0,0 +1,79 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFMediaSource_h__
+#define __AMFMediaSource_h__
+
+#pragma once
+
+#include "public/include/core/Interface.h"
+
+namespace amf
+{
+ enum AMF_SEEK_TYPE
+ {
+ AMF_SEEK_PREV = 0, // nearest packet before pts
+ AMF_SEEK_NEXT = 1, // nearest packet after pts
+ AMF_SEEK_PREV_KEYFRAME = 2, // nearest keyframe packet before pts
+ AMF_SEEK_NEXT_KEYFRAME = 3, // nearest keyframe packet after pts
+ };
+
+ //----------------------------------------------------------------------------------------------
+ // media source interface.
+ //----------------------------------------------------------------------------------------------
+ class AMFMediaSource : public AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0xb367695a, 0xdbd0, 0x4430, 0x95, 0x3b, 0xbc, 0x7d, 0xbd, 0x2a, 0xa7, 0x66)
+
+ // interface
+ virtual AMF_RESULT AMF_STD_CALL Seek(amf_pts pos, AMF_SEEK_TYPE seekType, amf_int32 whichStream) = 0;
+ virtual amf_pts AMF_STD_CALL GetPosition() = 0;
+ virtual amf_pts AMF_STD_CALL GetDuration() = 0;
+
+ virtual void AMF_STD_CALL SetMinPosition(amf_pts pts) = 0;
+ virtual amf_pts AMF_STD_CALL GetMinPosition() = 0;
+ virtual void AMF_STD_CALL SetMaxPosition(amf_pts pts) = 0;
+ virtual amf_pts AMF_STD_CALL GetMaxPosition() = 0;
+
+ virtual amf_uint64 AMF_STD_CALL GetFrameFromPts(amf_pts pts) = 0;
+ virtual amf_pts AMF_STD_CALL GetPtsFromFrame(amf_uint64 frame) = 0;
+
+ virtual bool AMF_STD_CALL SupportFramesAccess() = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFMediaSource> AMFMediaSourcePtr;
+} //namespace amf
+
+#endif //#ifndef __AMFMediaSource_h__
diff --git a/compat/amd/amf/public/include/components/VideoConverter.h b/compat/amd/amf/public/include/components/VideoConverter.h
new file mode 100644
index 0000000..78aa97f
--- /dev/null
+++ b/compat/amd/amf/public/include/components/VideoConverter.h
@@ -0,0 +1,87 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// AMFFVideoConverter interface declaration
+//-------------------------------------------------------------------------------------------------
+#ifndef __AMFVideoConverter_h__
+#define __AMFVideoConverter_h__
+#pragma once
+
+#include "Component.h"
+
+#define AMFVideoConverter L"AMFVideoConverter"
+
+enum AMF_VIDEO_CONVERTER_SCALE_ENUM
+{
+ AMF_VIDEO_CONVERTER_SCALE_INVALID = -1,
+ AMF_VIDEO_CONVERTER_SCALE_BILINEAR = 0,
+ AMF_VIDEO_CONVERTER_SCALE_BICUBIC = 1
+};
+
+enum AMF_VIDEO_CONVERTER_COLOR_PROFILE_ENUM
+{
+ AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN = -1,
+ AMF_VIDEO_CONVERTER_COLOR_PROFILE_601 = 0,
+ AMF_VIDEO_CONVERTER_COLOR_PROFILE_709 = 1,
+ AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020 = 2,
+ AMF_VIDEO_CONVERTER_COLOR_PROFILE_JPEG = 3, // full range
+ AMF_VIDEO_CONVERTER_COLOR_PROFILE_COUNT
+};
+
+
+#define AMF_VIDEO_CONVERTER_OUTPUT_FORMAT L"OutputFormat" // Values : AMF_SURFACE_NV12 or AMF_SURFACE_BGRA or AMF_SURFACE_YUV420P
+#define AMF_VIDEO_CONVERTER_MEMORY_TYPE L"MemoryType" // Values : AMF_MEMORY_DX11 or AMF_MEMORY_DX9 or AMF_MEMORY_UNKNOWN (get from input type)
+#define AMF_VIDEO_CONVERTER_COMPUTE_DEVICE L"ComputeDevice" // Values : AMF_MEMORY_COMPUTE_FOR_DX9 enumeration
+
+#define AMF_VIDEO_CONVERTER_OUTPUT_SIZE L"OutputSize" // AMFSize (default=0,0) width in pixels. default means no scaling
+#define AMF_VIDEO_CONVERTER_OUTPUT_RECT L"OutputRect" // AMFRect (default=0, 0, 0, 0) rectangle in pixels. default means no rect
+
+#define AMF_VIDEO_CONVERTER_KEEP_ASPECT_RATIO L"KeepAspectRatio" // bool (default=false) Keep aspect ratio if scaling.
+#define AMF_VIDEO_CONVERTER_FILL L"Fill" // bool (default=false) fill area out of ROI.
+#define AMF_VIDEO_CONVERTER_FILL_COLOR L"FillColor" // AMFColor
+
+
+#define AMF_VIDEO_CONVERTER_SCALE L"ScaleType"
+
+#define AMF_VIDEO_CONVERTER_GAMMA_MODE L"GammaMode"
+#define AMF_VIDEO_CONVERTER_GAMMA_VALUE L"GammaValue"
+#define AMF_VIDEO_CONVERTER_PQ_NORM_FACTOR L"PqNormFactor"
+
+#define AMF_VIDEO_CONVERTER_FORCE_OUTPUT_SURFACE_SIZE L"ForceOutputSurfaceSize" // bool (default=false) Force output size from output surface
+
+
+#define AMF_VIDEO_CONVERTER_COLOR_PROFILE L"ColorProfile"
+
+#define AMF_VIDEO_CONVERTER_LINEAR_RGB L"LinearRGB" // bool (default=false) Convert to/from linear RGB instead of sRGB
+
+#endif //#ifndef __AMFVideoConverter_h__
diff --git a/compat/amd/amf/public/include/components/VideoDecoderUVD.h b/compat/amd/amf/public/include/components/VideoDecoderUVD.h
new file mode 100644
index 0000000..d3d2e02
--- /dev/null
+++ b/compat/amd/amf/public/include/components/VideoDecoderUVD.h
@@ -0,0 +1,87 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// VideoDecoderUVD interface declaration
+//-------------------------------------------------------------------------------------------------
+#ifndef __VideoDecoderHW_UVD_h__
+#define __VideoDecoderHW_UVD_h__
+#pragma once
+
+#include "Component.h"
+
+#define AMFVideoDecoderUVD_MPEG2 L"AMFVideoDecoderUVD_MPEG2"
+#define AMFVideoDecoderUVD_MPEG4 L"AMFVideoDecoderUVD_MPEG4"
+#define AMFVideoDecoderUVD_WMV3 L"AMFVideoDecoderUVD_WMV3"
+#define AMFVideoDecoderUVD_VC1 L"AMFVideoDecoderUVD_VC1"
+#define AMFVideoDecoderUVD_H264_AVC L"AMFVideoDecoderUVD_H264_AVC"
+#define AMFVideoDecoderUVD_H264_MVC L"AMFVideoDecoderUVD_H264_MVC"
+#define AMFVideoDecoderUVD_H264_SVC L"AMFVideoDecoderUVD_H264_SVC"
+#define AMFVideoDecoderUVD_MJPEG L"AMFVideoDecoderUVD_MJPEG"
+#define AMFVideoDecoderHW_H265_HEVC L"AMFVideoDecoderHW_H265_HEVC"
+#define AMFVideoDecoderHW_H265_MAIN10 L"AMFVideoDecoderHW_H265_MAIN10"
+
+enum AMF_VIDEO_DECODER_MODE_ENUM
+{
+ AMF_VIDEO_DECODER_MODE_REGULAR = 0, // DPB delay is based on number of reference frames + 1 (from SPS)
+ AMF_VIDEO_DECODER_MODE_COMPLIANT, // DPB delay is based on profile - up to 16
+ AMF_VIDEO_DECODER_MODE_LOW_LATENCY, // DPB delay is 0. Expect stream with no reordering in P-Frames or B-Frames. B-frames can be present as long as they do not introduce any frame re-ordering
+};
+enum AMF_TIMESTAMP_MODE_ENUM
+{
+ AMF_TS_PRESENTATION = 0, // default. decoder will preserve timestamps from input to output
+ AMF_TS_SORT, // decoder will resort PTS list
+ AMF_TS_DECODE // timestamps reflect decode order - decoder will reuse them
+};
+
+#define AMF_VIDEO_DECODER_SURFACE_COPY L"SurfaceCopy" // amf_bool; default = false; return output surfaces as a copy
+#define AMF_VIDEO_DECODER_EXTRADATA L"ExtraData" // AMFInterface* -> AMFBuffer* - AVCC - size length + SPS/PPS; or as Annex B. Optional if stream is Annex B
+#define AMF_VIDEO_DECODER_FRAME_RATE L"FrameRate" // amf_double; default = 0.0, optional property to restore duration in the output if needed
+#define AMF_TIMESTAMP_MODE L"TimestampMode" // amf_int64(AMF_TIMESTAMP_MODE_ENUM) - default AMF_TS_PRESENTATION - how input timestamps are treated
+#define AMF_VIDEO_DECODER_FULL_RANGE_COLOR L"FullRangeColor" // bool; default = false; inidicates that YUV input is (0,255)
+
+// dynamic/adaptive resolution change
+#define AMF_VIDEO_DECODER_ADAPTIVE_RESOLUTION_CHANGE L"AdaptiveResolutionChange" // amf_bool; default = false; reuse allocated surfaces if new resolution is smaller
+#define AMF_VIDEO_DECODER_ALLOC_SIZE L"AllocSize" // AMFSize; default (1920,1088); size of allocated surface if AdaptiveResolutionChange is true
+#define AMF_VIDEO_DECODER_CURRENT_SIZE L"CurrentSize" // AMFSize; default = (0,0); current size of the video
+
+// reference frame management
+#define AMF_VIDEO_DECODER_REORDER_MODE L"ReorderMode" // amf_int64(AMF_VIDEO_DECODER_MODE_ENUM); default = AMF_VIDEO_DECODER_MODE_REGULAR; defines number of surfaces in DPB list.
+#define AMF_VIDEO_DECODER_SURFACE_POOL_SIZE L"SurfacePoolSize" // amf_int64; number of surfaces in the decode pool = DPB list size + number of surfaces for presentation
+#define AMF_VIDEO_DECODER_DPB_SIZE L"DPBSize" // amf_int64; minimum number of surfaces for reordering
+
+#define AMF_VIDEO_DECODER_DEFAULT_SURFACES_FOR_TRANSIT 5 // if AMF_VIDEO_DECODER_SURFACE_POOL_SIZE is 0 , AMF_VIDEO_DECODER_SURFACE_POOL_SIZE=AMF_VIDEO_DECODER_DEFAULT_SURFACES_FOR_TRANSIT+AMF_VIDEO_DECODER_DPB_SIZE
+
+// Decoder capabilities - exposed in AMFCaps interface
+#define AMF_VIDEO_DECODER_CAP_NUM_OF_STREAMS L"NumOfStreams" // amf_int64; maximum number of decode streams supported
+
+#endif //#ifndef __VideoDecoderHW_UVD_h__
diff --git a/compat/amd/amf/public/include/components/VideoEncoderHEVC.h b/compat/amd/amf/public/include/components/VideoEncoderHEVC.h
new file mode 100644
index 0000000..33b795d
--- /dev/null
+++ b/compat/amd/amf/public/include/components/VideoEncoderHEVC.h
@@ -0,0 +1,189 @@
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// VideoEncoderHW_HEVC interface declaration
+//-------------------------------------------------------------------------------------------------
+
+#ifndef __AMFVideoEncoderHW_HEVC_h__
+#define __AMFVideoEncoderHW_HEVC_h__
+#pragma once
+
+#include "Component.h"
+
+#define AMFVideoEncoder_HEVC L"AMFVideoEncoderHW_HEVC"
+
+enum AMF_VIDEO_ENCODER_HEVC_USAGE_ENUM
+{
+ AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCONDING = 0,
+ AMF_VIDEO_ENCODER_HEVC_USAGE_ULTRA_LOW_LATENCY,
+ AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY,
+ AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM
+};
+
+enum AMF_VIDEO_ENCODER_HEVC_PROFILE_ENUM
+{
+ AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN = 1
+};
+
+enum AMF_VIDEO_ENCODER_HEVC_TIER_ENUM
+{
+ AMF_VIDEO_ENCODER_HEVC_TIER_MAIN = 0,
+ AMF_VIDEO_ENCODER_HEVC_TIER_HIGH = 1
+};
+
+enum AMF_VIDEO_ENCODER_LEVEL_ENUM
+{
+ AMF_LEVEL_1 = 30,
+ AMF_LEVEL_2 = 60,
+ AMF_LEVEL_2_1 = 63,
+ AMF_LEVEL_3 = 90,
+ AMF_LEVEL_3_1 = 93,
+ AMF_LEVEL_4 = 120,
+ AMF_LEVEL_4_1 = 123,
+ AMF_LEVEL_5 = 150,
+ AMF_LEVEL_5_1 = 153,
+ AMF_LEVEL_5_2 = 156,
+ AMF_LEVEL_6 = 180,
+ AMF_LEVEL_6_1 = 183,
+ AMF_LEVEL_6_2 = 186
+};
+
+enum AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_ENUM
+{
+ AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP = 0,
+ AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR,
+ AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR,
+ AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CBR
+};
+
+enum AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_ENUM
+{
+ AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_NONE = 0,
+ AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_SKIP,
+ AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_IDR,
+ AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_I,
+ AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_P
+};
+
+enum AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE_ENUM
+{
+ AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE_IDR,
+ AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE_I,
+ AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE_P
+};
+
+enum AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_ENUM
+{
+ AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_QUALITY = 0,
+ AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_BALANCED = 5,
+ AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_SPEED = 10
+};
+
+enum AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_ENUM
+{
+ AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_NONE = 0,
+ AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_GOP_ALIGNED,
+ AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_IDR_ALIGNED
+};
+
+
+
+// Static properties - can be set before Init()
+#define AMF_VIDEO_ENCODER_HEVC_FRAMESIZE L"HevcFrameSize" // AMFSize; default = 0,0; Frame size
+
+#define AMF_VIDEO_ENCODER_HEVC_USAGE L"HevcUsage" // amf_int64(AMF_VIDEO_ENCODER_HEVC_USAGE_ENUM); default = N/A; Encoder usage type. fully configures parameter set.
+#define AMF_VIDEO_ENCODER_HEVC_PROFILE L"HevcProfile" // amf_int64(AMF_VIDEO_ENCODER_HEVC_PROFILE_ENUM) ; default = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN;
+#define AMF_VIDEO_ENCODER_HEVC_TIER L"HevcTier" // amf_int64(AMF_VIDEO_ENCODER_HEVC_TIER_ENUM) ; default = AMF_VIDEO_ENCODER_HEVC_TIER_MAIN;
+#define AMF_VIDEO_ENCODER_HEVC_PROFILE_LEVEL L"HevcProfileLevel" // amf_int64 (AMF_VIDEO_ENCODER_LEVEL_ENUM, default depends on HW capabilities);
+#define AMF_VIDEO_ENCODER_HEVC_MAX_LTR_FRAMES L"HevcMaxOfLTRFrames" // amf_int64; default = 0; Max number of LTR frames
+#define AMF_VIDEO_ENCODER_HEVC_MAX_NUM_REFRAMES L"HevcMaxNumRefFrames" // amf_int64; default = 1; Maximum number of reference frames
+#define AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET L"HevcQualityPreset" // amf_int64(AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_ENUM); default = depends on USAGE; Quality Preset
+#define AMF_VIDEO_ENCODER_HEVC_EXTRADATA L"HevcExtraData" // AMFInterface* - > AMFBuffer*; SPS/PPS buffer - read-only
+#define AMF_VIDEO_ENCODER_HEVC_ASPECT_RATIO L"HevcAspectRatio" // AMFRatio; default = 1, 1
+
+// Picture control properties
+#define AMF_VIDEO_ENCODER_HEVC_NUM_GOPS_PER_IDR L"HevcGOPSPerIDR" // amf_int64; default = 60; The frequency to insert IDR as start of a GOP. 0 means no IDR will be inserted.
+#define AMF_VIDEO_ENCODER_HEVC_GOP_SIZE L"HevcGOPSize" // amf_int64; default = 60; GOP Size, in frames
+#define AMF_VIDEO_ENCODER_HEVC_DE_BLOCKING_FILTER_DISABLE L"HevcDeBlockingFilter" // bool; default = depends on USAGE; De-blocking Filter
+#define AMF_VIDEO_ENCODER_HEVC_SLICES_PER_FRAME L"HevcSlicesPerFrame" // amf_int64; default = 1; Number of slices Per Frame
+#define AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE L"HevcHeaderInsertionMode" // amf_int64(AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_ENUM); default = NONE
+
+// Rate control properties
+#define AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD L"HevcRateControlMethod" // amf_int64(AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_MODE_ENUM); default = depends on USAGE; Rate Control Method
+#define AMF_VIDEO_ENCODER_HEVC_FRAMERATE L"HevcFrameRate" // AMFRate; default = depends on usage; Frame Rate
+#define AMF_VIDEO_ENCODER_HEVC_VBV_BUFFER_SIZE L"HevcVBVBufferSize" // amf_int64; default = depends on USAGE; VBV Buffer Size in bits
+#define AMF_VIDEO_ENCODER_HEVC_INITIAL_VBV_BUFFER_FULLNESS L"HevcInitialVBVBufferFullness" // amf_int64; default = 64; Initial VBV Buffer Fullness 0=0% 64=100%
+#define AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_PREANALYSIS_ENABLE L"HevcRateControlPreAnalysisEnable" // bool; default = depends on USAGE; enable Pre-analysis assisted rate control
+#define AMF_VIDEO_ENCODER_HEVC_ENABLE_VBAQ L"HevcEnableVBAQ" // // bool; default = depends on USAGE; Enable auto VBAQ
+
+// Motion estimation
+#define AMF_VIDEO_ENCODER_HEVC_MOTION_HALF_PIXEL L"HevcHalfPixel" // bool; default= true; Half Pixel
+#define AMF_VIDEO_ENCODER_HEVC_MOTION_QUARTERPIXEL L"HevcQuarterPixel" // bool; default= true; Quarter Pixel
+
+// Dynamic properties - can be set at any time
+
+// Rate control properties
+#define AMF_VIDEO_ENCODER_HEVC_ENFORCE_HRD L"HevcEnforceHRD" // bool; default = depends on USAGE; Enforce HRD
+#define AMF_VIDEO_ENCODER_HEVC_FILLER_DATA_ENABLE L"HevcFillerDataEnable" // bool; default = depends on USAGE; Enforce HRD
+#define AMF_VIDEO_ENCODER_HEVC_TARGET_BITRATE L"HevcTargetBitrate" // amf_int64; default = depends on USAGE; Target bit rate in bits
+#define AMF_VIDEO_ENCODER_HEVC_PEAK_BITRATE L"HevcPeakBitrate" // amf_int64; default = depends on USAGE; Peak bit rate in bits
+
+#define AMF_VIDEO_ENCODER_HEVC_MAX_AU_SIZE L"HevcMaxAUSize" // amf_int64; default = 60; Max AU Size in bits
+
+#define AMF_VIDEO_ENCODER_HEVC_MIN_QP_I L"HevcMinQP_I" // amf_int64; default = depends on USAGE; Min QP; range =
+#define AMF_VIDEO_ENCODER_HEVC_MAX_QP_I L"HevcMaxQP_I" // amf_int64; default = depends on USAGE; Max QP; range =
+#define AMF_VIDEO_ENCODER_HEVC_MIN_QP_P L"HevcMinQP_P" // amf_int64; default = depends on USAGE; Min QP; range =
+#define AMF_VIDEO_ENCODER_HEVC_MAX_QP_P L"HevcMaxQP_P" // amf_int64; default = depends on USAGE; Max QP; range =
+
+#define AMF_VIDEO_ENCODER_HEVC_QP_I L"HevcQP_I" // amf_int64; default = 26; P-frame QP; range = 0-51
+#define AMF_VIDEO_ENCODER_HEVC_QP_P L"HevcQP_P" // amf_int64; default = 26; P-frame QP; range = 0-51
+
+#define AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_SKIP_FRAME_ENABLE L"HevcRateControlSkipFrameEnable" // bool; default = depends on USAGE; Rate Control Based Frame Skip
+
+
+
+// Per-submittion properties - can be set on input surface interface
+#define AMF_VIDEO_ENCODER_HEVC_END_OF_SEQUENCE L"HevcEndOfSequence" // bool; default = false; generate end of sequence
+#define AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE L"HevcForcePictureType" // amf_int64(AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_ENUM); default = AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_NONE; generate particular picture type
+#define AMF_VIDEO_ENCODER_HEVC_INSERT_AUD L"HevcInsertAUD" // bool; default = false; insert AUD
+#define AMF_VIDEO_ENCODER_HEVC_INSERT_HEADER L"HevcInsertHeader" // bool; default = false; insert header(SPS, PPS, VPS)
+
+#define AMF_VIDEO_ENCODER_HEVC_MARK_CURRENT_WITH_LTR_INDEX L"HevcMarkCurrentWithLTRIndex" // amf_int64; default = N/A; Mark current frame with LTR index
+#define AMF_VIDEO_ENCODER_HEVC_FORCE_LTR_REFERENCE_BITFIELD L"HevcForceLTRReferenceBitfield"// amf_int64; default = 0; force LTR bit-field
+
+// Properties set by encoder on output buffer interface
+#define AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE L"HevcOutputDataType" // amf_int64(AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE_ENUM); default = N/A
+#define AMF_VIDEO_ENCODER_HEVC_OUTPUT_MARKED_LTR_INDEX L"HevcMarkedLTRIndex" // amf_int64; default = -1; Marked LTR index
+#define AMF_VIDEO_ENCODER_HEVC_OUTPUT_REFERENCED_LTR_INDEX_BITFIELD L"HevcReferencedLTRIndexBitfield"// amf_int64; default = 0; referenced LTR bit-field
+
+// HEVC Encoder capabilities - exposed in AMFCaps interface
+#define AMF_VIDEO_ENCODER_HEVC_CAP_MAX_BITRATE L"HevcMaxBitrate" // amf_int64; Maximum bit rate in bits
+#define AMF_VIDEO_ENCODER_HEVC_CAP_NUM_OF_STREAMS L"HevcNumOfStreams" // amf_int64; maximum number of encode streams supported
+#define AMF_VIDEO_ENCODER_HEVC_CAP_MAX_PROFILE L"HevcMaxProfile" // amf_int64(AMF_VIDEO_ENCODER_HEVC_PROFILE_ENUM)
+#define AMF_VIDEO_ENCODER_HEVC_CAP_MAX_TIER L"HevcMaxTier" // amf_int64(AMF_VIDEO_ENCODER_HEVC_TIER_ENUM) maximum profile tier
+#define AMF_VIDEO_ENCODER_HEVC_CAP_MAX_LEVEL L"HevcMaxLevel" // amf_int64 maximum profile level
+#define AMF_VIDEO_ENCODER_HEVC_CAP_MIN_REFERENCE_FRAMES L"HevcMinReferenceFrames" // amf_int64 minimum number of reference frames
+#define AMF_VIDEO_ENCODER_HEVC_CAP_MAX_REFERENCE_FRAMES L"HevcMaxReferenceFrames" // amf_int64 maximum number of reference frames
+
+
+#endif //#ifndef __AMFVideoEncoderHW_HEVC_h__
diff --git a/compat/amd/amf/public/include/components/VideoEncoderVCE.h b/compat/amd/amf/public/include/components/VideoEncoderVCE.h
new file mode 100644
index 0000000..2dabe82
--- /dev/null
+++ b/compat/amd/amf/public/include/components/VideoEncoderVCE.h
@@ -0,0 +1,222 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+//-------------------------------------------------------------------------------------------------
+// AMFVideoEncoderHW_AVC interface declaration
+//-------------------------------------------------------------------------------------------------
+
+#ifndef __AMFVideoEncoderHW_AVC_h__
+#define __AMFVideoEncoderHW_AVC_h__
+#pragma once
+
+#include "Component.h"
+
+#define AMFVideoEncoderVCE_AVC L"AMFVideoEncoderVCE_AVC"
+#define AMFVideoEncoderVCE_SVC L"AMFVideoEncoderVCE_SVC"
+
+enum AMF_VIDEO_ENCODER_USAGE_ENUM
+{
+ AMF_VIDEO_ENCODER_USAGE_TRANSCONDING = 0,
+ AMF_VIDEO_ENCODER_USAGE_ULTRA_LOW_LATENCY,
+ AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY,
+ AMF_VIDEO_ENCODER_USAGE_WEBCAM
+};
+
+enum AMF_VIDEO_ENCODER_PROFILE_ENUM
+{
+ AMF_VIDEO_ENCODER_PROFILE_BASELINE = 66,
+ AMF_VIDEO_ENCODER_PROFILE_MAIN = 77,
+ AMF_VIDEO_ENCODER_PROFILE_HIGH = 100
+};
+
+enum AMF_VIDEO_ENCODER_SCANTYPE_ENUM
+{
+ AMF_VIDEO_ENCODER_SCANTYPE_PROGRESSIVE = 0,
+ AMF_VIDEO_ENCODER_SCANTYPE_INTERLACED
+};
+
+enum AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_ENUM
+{
+ AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP = 0,
+ AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CBR,
+ AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR,
+ AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR
+};
+
+enum AMF_VIDEO_ENCODER_QUALITY_PRESET_ENUM
+{
+ AMF_VIDEO_ENCODER_QUALITY_PRESET_BALANCED = 0,
+ AMF_VIDEO_ENCODER_QUALITY_PRESET_SPEED,
+ AMF_VIDEO_ENCODER_QUALITY_PRESET_QUALITY
+};
+
+enum AMF_VIDEO_ENCODER_PICTURE_STRUCTURE_ENUM
+{
+ AMF_VIDEO_ENCODER_PICTURE_STRUCTURE_NONE = 0,
+ AMF_VIDEO_ENCODER_PICTURE_STRUCTURE_FRAME,
+ AMF_VIDEO_ENCODER_PICTURE_STRUCTURE_TOP_FIELD,
+ AMF_VIDEO_ENCODER_PICTURE_STRUCTURE_BOTTOM_FIELD
+};
+
+enum AMF_VIDEO_ENCODER_PICTURE_TYPE_ENUM
+{
+ AMF_VIDEO_ENCODER_PICTURE_TYPE_NONE = 0,
+ AMF_VIDEO_ENCODER_PICTURE_TYPE_SKIP,
+ AMF_VIDEO_ENCODER_PICTURE_TYPE_IDR,
+ AMF_VIDEO_ENCODER_PICTURE_TYPE_I,
+ AMF_VIDEO_ENCODER_PICTURE_TYPE_P,
+ AMF_VIDEO_ENCODER_PICTURE_TYPE_B
+};
+
+enum AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_ENUM
+{
+ AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_IDR,
+ AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_I,
+ AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_P,
+ AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_B
+};
+
+enum AMF_VIDEO_ENCODER_PREENCODE_MODE_ENUM
+{
+ AMF_VIDEO_ENCODER_PREENCODE_DISABLED = 0,
+ AMF_VIDEO_ENCODER_PREENCODE_ENABLED = 1,
+};
+
+enum AMF_VIDEO_ENCODER_CODING_ENUM
+{
+ AMF_VIDEO_ENCODER_UNDEFINED = 0, // BASELINE = CALV; MAIN, HIGH = CABAC
+ AMF_VIDEO_ENCODER_CABAC,
+ AMF_VIDEO_ENCODER_CALV,
+
+};
+
+
+// Static properties - can be set before Init()
+
+#define AMF_VIDEO_ENCODER_FRAMESIZE L"FrameSize" // AMFSize; default = 0,0; Frame size
+#define AMF_VIDEO_ENCODER_FRAMERATE L"FrameRate" // AMFRate; default = depends on usage; Frame Rate
+
+#define AMF_VIDEO_ENCODER_EXTRADATA L"ExtraData" // AMFInterface* - > AMFBuffer*; SPS/PPS buffer in Annex B format - read-only
+#define AMF_VIDEO_ENCODER_USAGE L"Usage" // amf_int64(AMF_VIDEO_ENCODER_USAGE_ENUM); default = N/A; Encoder usage type. fully configures parameter set.
+#define AMF_VIDEO_ENCODER_PROFILE L"Profile" // amf_int64(AMF_VIDEO_ENCODER_PROFILE_ENUM) ; default = AMF_VIDEO_ENCODER_PROFILE_MAIN; H264 profile
+#define AMF_VIDEO_ENCODER_PROFILE_LEVEL L"ProfileLevel" // amf_int64; default = 42; H264 profile level
+#define AMF_VIDEO_ENCODER_MAX_LTR_FRAMES L"MaxOfLTRFrames" // amf_int64; default = 0; Max number of LTR frames
+#define AMF_VIDEO_ENCODER_SCANTYPE L"ScanType" // amf_int64(AMF_VIDEO_ENCODER_SCANTYPE_ENUM); default = AMF_VIDEO_ENCODER_SCANTYPE_PROGRESSIVE; indicates input stream type
+#define AMF_VIDEO_ENCODER_MAX_NUM_REFRAMES L"MaxNumRefFrames" // amf_int64; Maximum number of reference frames
+#define AMF_VIDEO_ENCODER_ASPECT_RATIO L"AspectRatio" // AMFRatio; default = 1, 1
+#define AMF_VIDEO_ENCODER_FULL_RANGE_COLOR L"FullRangeColor" // bool; default = false; inidicates that YUV input is (0,255)
+#define AMF_VIDEO_ENCODER_RATE_CONTROL_PREANALYSIS_ENABLE L"RateControlPreanalysisEnable" // amf_int64(AMF_VIDEO_ENCODER_PREENCODE_MODE_ENUM); default = AMF_VIDEO_ENCODER_PREENCODE_DISABLED; controls Pre-analysis assisted rate control
+
+ // Quality preset property
+#define AMF_VIDEO_ENCODER_QUALITY_PRESET L"QualityPreset" // amf_int64(AMF_VIDEO_ENCODER_QUALITY_PRESET_ENUM); default = depends on USAGE; Quality Preset
+
+
+// Dynamic properties - can be set at any time
+
+ // Rate control properties
+#define AMF_VIDEO_ENCODER_B_PIC_DELTA_QP L"BPicturesDeltaQP" // amf_int64; default = depends on USAGE; B-picture Delta
+#define AMF_VIDEO_ENCODER_REF_B_PIC_DELTA_QP L"ReferenceBPicturesDeltaQP"// amf_int64; default = depends on USAGE; Reference B-picture Delta
+
+#define AMF_VIDEO_ENCODER_ENFORCE_HRD L"EnforceHRD" // bool; default = depends on USAGE; Enforce HRD
+#define AMF_VIDEO_ENCODER_FILLER_DATA_ENABLE L"FillerDataEnable" // bool; default = false; Filler Data Enable
+#define AMF_VIDEO_ENCODER_ENABLE_VBAQ L"EnableVBAQ" // bool; default = depends on USAGE; Enable VBAQ
+
+
+#define AMF_VIDEO_ENCODER_VBV_BUFFER_SIZE L"VBVBufferSize" // amf_int64; default = depends on USAGE; VBV Buffer Size in bits
+#define AMF_VIDEO_ENCODER_INITIAL_VBV_BUFFER_FULLNESS L"InitialVBVBufferFullness" // amf_int64; default = 64; Initial VBV Buffer Fullness 0=0% 64=100%
+
+#define AMF_VIDEO_ENCODER_MAX_AU_SIZE L"MaxAUSize" // amf_int64; default = 60; Max AU Size in bits
+
+#define AMF_VIDEO_ENCODER_MIN_QP L"MinQP" // amf_int64; default = depends on USAGE; Min QP; range = 0-51
+#define AMF_VIDEO_ENCODER_MAX_QP L"MaxQP" // amf_int64; default = depends on USAGE; Max QP; range = 0-51
+#define AMF_VIDEO_ENCODER_QP_I L"QPI" // amf_int64; default = 22; I-frame QP; range = 0-51
+#define AMF_VIDEO_ENCODER_QP_P L"QPP" // amf_int64; default = 22; P-frame QP; range = 0-51
+#define AMF_VIDEO_ENCODER_QP_B L"QPB" // amf_int64; default = 22; B-frame QP; range = 0-51
+#define AMF_VIDEO_ENCODER_TARGET_BITRATE L"TargetBitrate" // amf_int64; default = depends on USAGE; Target bit rate in bits
+#define AMF_VIDEO_ENCODER_PEAK_BITRATE L"PeakBitrate" // amf_int64; default = depends on USAGE; Peak bit rate in bits
+#define AMF_VIDEO_ENCODER_RATE_CONTROL_SKIP_FRAME_ENABLE L"RateControlSkipFrameEnable" // bool; default = depends on USAGE; Rate Control Based Frame Skip
+#define AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD L"RateControlMethod" // amf_int64(AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_ENUM); default = depends on USAGE; Rate Control Method
+
+ // Picture control properties
+#define AMF_VIDEO_ENCODER_HEADER_INSERTION_SPACING L"HeaderInsertionSpacing" // amf_int64; default = depends on USAGE; Header Insertion Spacing; range 0-1000
+#define AMF_VIDEO_ENCODER_B_PIC_PATTERN L"BPicturesPattern" // amf_int64; default = 3; B-picture Pattern (number of B-Frames)
+#define AMF_VIDEO_ENCODER_DE_BLOCKING_FILTER L"DeBlockingFilter" // bool; default = depends on USAGE; De-blocking Filter
+#define AMF_VIDEO_ENCODER_B_REFERENCE_ENABLE L"BReferenceEnable" // bool; default = true; Enable Refrence to B-frames
+#define AMF_VIDEO_ENCODER_IDR_PERIOD L"IDRPeriod" // amf_int64; default = depends on USAGE; IDR Period in frames
+#define AMF_VIDEO_ENCODER_INTRA_REFRESH_NUM_MBS_PER_SLOT L"IntraRefreshMBsNumberPerSlot" // amf_int64; default = depends on USAGE; Intra Refresh MBs Number Per Slot in Macroblocks
+#define AMF_VIDEO_ENCODER_SLICES_PER_FRAME L"SlicesPerFrame" // amf_int64; default = 1; Number of slices Per Frame
+#define AMF_VIDEO_ENCODER_CABAC_ENABLE L"CABACEnable" // amf_int64(AMF_VIDEO_ENCODER_CODING_ENUM) default = AMF_VIDEO_ENCODER_UNDEFINED
+
+ // Motion estimation
+#define AMF_VIDEO_ENCODER_MOTION_HALF_PIXEL L"HalfPixel" // bool; default= true; Half Pixel
+#define AMF_VIDEO_ENCODER_MOTION_QUARTERPIXEL L"QuarterPixel" // bool; default= true; Quarter Pixel
+
+ // SVC
+#define AMF_VIDEO_ENCODER_NUM_TEMPORAL_ENHANCMENT_LAYERS L"NumOfTemporalEnhancmentLayers" // amf_int64; default = 0; range = 0, min(2, caps->GetMaxNumOfTemporalLayers()) number of temporal enhancment Layers (SVC)
+
+// Per-submittion properties - can be set on input surface interface
+#define AMF_VIDEO_ENCODER_END_OF_SEQUENCE L"EndOfSequence" // bool; default = false; generate end of sequence
+#define AMF_VIDEO_ENCODER_END_OF_STREAM L"EndOfStream" // bool; default = false; generate end of stream
+#define AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE L"ForcePictureType" // amf_int64(AMF_VIDEO_ENCODER_PICTURE_TYPE_ENUM); default = AMF_VIDEO_ENCODER_PICTURE_TYPE_NONE; generate particular picture type
+#define AMF_VIDEO_ENCODER_INSERT_AUD L"InsertAUD" // bool; default = false; insert AUD
+#define AMF_VIDEO_ENCODER_INSERT_SPS L"InsertSPS" // bool; default = false; insert SPS
+#define AMF_VIDEO_ENCODER_INSERT_PPS L"InsertPPS" // bool; default = false; insert PPS
+#define AMF_VIDEO_ENCODER_PICTURE_STRUCTURE L"PictureStructure" // amf_int64(AMF_VIDEO_ENCODER_PICTURE_STRUCTURE_ENUM); default = AMF_VIDEO_ENCODER_PICTURE_STRUCTURE_FRAME; indicate picture type
+#define AMF_VIDEO_ENCODER_MARK_CURRENT_WITH_LTR_INDEX L"MarkCurrentWithLTRIndex" // //amf_int64; default = N/A; Mark current frame with LTR index
+#define AMF_VIDEO_ENCODER_FORCE_LTR_REFERENCE_BITFIELD L"ForceLTRReferenceBitfield"// amf_int64; default = 0; force LTR bit-field
+
+// properties set by encoder on output buffer interface
+#define AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE L"OutputDataType" // amf_int64(AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_ENUM); default = N/A
+#define AMF_VIDEO_ENCODER_OUTPUT_MARKED_LTR_INDEX L"MarkedLTRIndex" //amf_int64; default = -1; Marked LTR index
+#define AMF_VIDEO_ENCODER_OUTPUT_REFERENCED_LTR_INDEX_BITFIELD L"ReferencedLTRIndexBitfield" // amf_int64; default = 0; referenced LTR bit-field
+
+
+#define AMF_VIDEO_ENCODER_HDCP_COUNTER L"HDCPCounter" // const void*
+
+// Properties for multi-instance cloud gaming
+#define AMF_VIDEO_ENCODER_MAX_INSTANCES L"EncoderMaxInstances" // amf_uint32; default = 1; max number of encoder instances
+#define AMF_VIDEO_ENCODER_MULTI_INSTANCE_MODE L"MultiInstanceMode" // bool; default = false;
+#define AMF_VIDEO_ENCODER_CURRENT_QUEUE L"MultiInstanceCurrentQueue"// amf_uin32; default = 0;
+
+// VCE Encoder capabilities - exposed in AMFCaps interface
+#define AMF_VIDEO_ENCODER_CAP_MAX_BITRATE L"MaxBitrate" // amf_int64; Maximum bit rate in bits
+#define AMF_VIDEO_ENCODER_CAP_NUM_OF_STREAMS L"NumOfStreams" // amf_int64; maximum number of encode streams supported
+#define AMF_VIDEO_ENCODER_CAP_MAX_PROFILE L"MaxProfile" // AMF_VIDEO_ENCODER_PROFILE_ENUM
+#define AMF_VIDEO_ENCODER_CAP_MAX_LEVEL L"MaxLevel" // amf_int64 maximum profile level
+#define AMF_VIDEO_ENCODER_CAP_BFRAMES L"BFrames" // bool is B-Frames supported
+#define AMF_VIDEO_ENCODER_CAP_MIN_REFERENCE_FRAMES L"MinReferenceFrames" // amf_int64 minimum number of reference frames
+#define AMF_VIDEO_ENCODER_CAP_MAX_REFERENCE_FRAMES L"MaxReferenceFrames" // amf_int64 maximum number of reference frames
+#define AMF_VIDEO_ENCODER_CAP_MAX_TEMPORAL_LAYERS L"MaxTemporalLayers" // amf_int64 maximum number of temporal layers
+#define AMF_VIDEO_ENCODER_CAP_FIXED_SLICE_MODE L"FixedSliceMode" // bool is fixed slice mode supported
+#define AMF_VIDEO_ENCODER_CAP_NUM_OF_HW_INSTANCES L"NumOfHwInstances" // amf_int64 number of HW encoder instances
+
+#endif //#ifndef __AMFVideoEncoderHW_AVC_h__
diff --git a/compat/amd/amf/public/include/core/AudioBuffer.h b/compat/amd/amf/public/include/core/AudioBuffer.h
new file mode 100644
index 0000000..5b7fe1a
--- /dev/null
+++ b/compat/amd/amf/public/include/core/AudioBuffer.h
@@ -0,0 +1,184 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFAudioBuffer_h__
+#define __AMFAudioBuffer_h__
+#pragma once
+
+#include "Data.h"
+#if defined(_MSC_VER)
+ #pragma warning( push )
+ #pragma warning(disable : 4263)
+ #pragma warning(disable : 4264)
+#endif
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ typedef enum AMF_AUDIO_FORMAT
+ {
+ AMFAF_UNKNOWN =-1,
+ AMFAF_U8 = 0, // amf_uint8
+ AMFAF_S16 = 1, // amf_int16
+ AMFAF_S32 = 2, // amf_int32
+ AMFAF_FLT = 3, // amf_float
+ AMFAF_DBL = 4, // amf_double
+
+ AMFAF_U8P = 5, // amf_uint8
+ AMFAF_S16P = 6, // amf_int16
+ AMFAF_S32P = 7, // amf_int32
+ AMFAF_FLTP = 8, // amf_float
+ AMFAF_DBLP = 9, // amf_double
+ AMFAF_FIRST = AMFAF_U8,
+ AMFAF_LAST = AMFAF_DBLP,
+ } AMF_AUDIO_FORMAT;
+
+ //----------------------------------------------------------------------------------------------
+ // AMFAudioBufferObserver interface - callback
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMFAudioBuffer;
+ class AMF_NO_VTABLE AMFAudioBufferObserver
+ {
+ public:
+ virtual void AMF_STD_CALL OnBufferDataRelease(AMFAudioBuffer* pBuffer) = 0;
+ };
+#else // #if defined(__cplusplus)
+ typedef struct AMFAudioBuffer AMFAudioBuffer;
+ typedef struct AMFAudioBufferObserver AMFAudioBufferObserver;
+ typedef struct AMFAudioBufferObserverVtbl
+ {
+ void (AMF_STD_CALL *OnBufferDataRelease)(AMFAudioBufferObserver* pThis, AMFAudioBuffer* pBuffer);
+ } AMFAudioBufferObserverVtbl;
+
+ struct AMFAudioBufferObserver
+ {
+ const AMFAudioBufferObserverVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+ // AudioBuffer interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFAudioBuffer : public AMFData
+ {
+ public:
+ AMF_DECLARE_IID(0x2212ff8, 0x6107, 0x430b, 0xb6, 0x3c, 0xc7, 0xe5, 0x40, 0xe5, 0xf8, 0xeb)
+
+ virtual amf_int32 AMF_STD_CALL GetSampleCount() = 0;
+ virtual amf_int32 AMF_STD_CALL GetSampleRate() = 0;
+ virtual amf_int32 AMF_STD_CALL GetChannelCount() = 0;
+ virtual AMF_AUDIO_FORMAT AMF_STD_CALL GetSampleFormat() = 0;
+ virtual amf_int32 AMF_STD_CALL GetSampleSize() = 0;
+ virtual amf_uint32 AMF_STD_CALL GetChannelLayout() = 0;
+ virtual void* AMF_STD_CALL GetNative() = 0;
+ virtual amf_size AMF_STD_CALL GetSize() = 0;
+
+ // Observer management
+ virtual void AMF_STD_CALL AddObserver(AMFAudioBufferObserver* pObserver) = 0;
+ virtual void AMF_STD_CALL RemoveObserver(AMFAudioBufferObserver* pObserver) = 0;
+
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFAudioBuffer> AMFAudioBufferPtr;
+ //----------------------------------------------------------------------------------------------
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFAudioBuffer, 0x2212ff8, 0x6107, 0x430b, 0xb6, 0x3c, 0xc7, 0xe5, 0x40, 0xe5, 0xf8, 0xeb)
+
+ typedef struct AMFAudioBufferVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFAudioBuffer* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFAudioBuffer* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFAudioBuffer* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFAudioBuffer* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFAudioBuffer* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFAudioBuffer* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFAudioBuffer* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFAudioBuffer* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFAudioBuffer* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFAudioBuffer* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFAudioBuffer* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFAudioBuffer* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFAudioBuffer* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFData interface
+
+ AMF_MEMORY_TYPE (AMF_STD_CALL *GetMemoryType)(AMFAudioBuffer* pThis);
+
+ AMF_RESULT (AMF_STD_CALL *Duplicate)(AMFAudioBuffer* pThis, AMF_MEMORY_TYPE type, AMFData** ppData);
+ AMF_RESULT (AMF_STD_CALL *Convert)(AMFAudioBuffer* pThis, AMF_MEMORY_TYPE type); // optimal interop if possilble. Copy through host memory if needed
+ AMF_RESULT (AMF_STD_CALL *Interop)(AMFAudioBuffer* pThis, AMF_MEMORY_TYPE type); // only optimal interop if possilble. No copy through host memory for GPU objects
+
+ AMF_DATA_TYPE (AMF_STD_CALL *GetDataType)(AMFAudioBuffer* pThis);
+
+ amf_bool (AMF_STD_CALL *IsReusable)(AMFAudioBuffer* pThis);
+
+ void (AMF_STD_CALL *SetPts)(AMFAudioBuffer* pThis, amf_pts pts);
+ amf_pts (AMF_STD_CALL *GetPts)(AMFAudioBuffer* pThis);
+ void (AMF_STD_CALL *SetDuration)(AMFAudioBuffer* pThis, amf_pts duration);
+ amf_pts (AMF_STD_CALL *GetDuration)(AMFAudioBuffer* pThis);
+
+ // AMFAudioBuffer interface
+
+ amf_int32 (AMF_STD_CALL *GetSampleCount)(AMFAudioBuffer* pThis);
+ amf_int32 (AMF_STD_CALL *GetSampleRate)(AMFAudioBuffer* pThis);
+ amf_int32 (AMF_STD_CALL *GetChannelCount)(AMFAudioBuffer* pThis);
+ AMF_AUDIO_FORMAT (AMF_STD_CALL *GetSampleFormat)(AMFAudioBuffer* pThis);
+ amf_int32 (AMF_STD_CALL *GetSampleSize)(AMFAudioBuffer* pThis);
+ amf_uint32 (AMF_STD_CALL *GetChannelLayout)(AMFAudioBuffer* pThis);
+ void* (AMF_STD_CALL *GetNative)(AMFAudioBuffer* pThis);
+ amf_size (AMF_STD_CALL *GetSize)(AMFAudioBuffer* pThis);
+
+ // Observer management
+ void (AMF_STD_CALL *AddObserver_AudioBuffer)(AMFAudioBuffer* pThis, AMFAudioBufferObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver_AudioBuffer)(AMFAudioBuffer* pThis, AMFAudioBufferObserver* pObserver);
+
+ } AMFAudioBufferVtbl;
+
+ struct AMFAudioBuffer
+ {
+ const AMFAudioBufferVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+#if defined(__cplusplus)
+} // namespace
+#endif
+#if defined(_MSC_VER)
+ #pragma warning( pop )
+#endif
+#endif //#ifndef __AMFAudioBuffer_h__
diff --git a/compat/amd/amf/public/include/core/Buffer.h b/compat/amd/amf/public/include/core/Buffer.h
new file mode 100644
index 0000000..7973b54
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Buffer.h
@@ -0,0 +1,160 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFBuffer_h__
+#define __AMFBuffer_h__
+#pragma once
+
+#include "Data.h"
+
+#if defined(_MSC_VER)
+ #pragma warning( push )
+ #pragma warning(disable : 4263)
+ #pragma warning(disable : 4264)
+#endif
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ // AMFBufferObserver interface - callback
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMFBuffer;
+ class AMF_NO_VTABLE AMFBufferObserver
+ {
+ public:
+ virtual void AMF_STD_CALL OnBufferDataRelease(AMFBuffer* pBuffer) = 0;
+ };
+#else // #if defined(__cplusplus)
+ typedef struct AMFBuffer AMFBuffer;
+ typedef struct AMFBufferObserver AMFBufferObserver;
+
+ typedef struct AMFBufferObserverVtbl
+ {
+ void (AMF_STD_CALL *OnBufferDataRelease)(AMFBufferObserver* pThis, AMFBuffer* pBuffer);
+ } AMFBufferObserverVtbl;
+
+ struct AMFBufferObserver
+ {
+ const AMFBufferObserverVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+ // AMFBuffer interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFBuffer : public AMFData
+ {
+ public:
+ AMF_DECLARE_IID(0xb04b7248, 0xb6f0, 0x4321, 0xb6, 0x91, 0xba, 0xa4, 0x74, 0xf, 0x9f, 0xcb)
+
+ virtual AMF_RESULT AMF_STD_CALL SetSize(amf_size newSize) = 0;
+ virtual amf_size AMF_STD_CALL GetSize() = 0;
+ virtual void* AMF_STD_CALL GetNative() = 0;
+
+ // Observer management
+ virtual void AMF_STD_CALL AddObserver(AMFBufferObserver* pObserver) = 0;
+ virtual void AMF_STD_CALL RemoveObserver(AMFBufferObserver* pObserver) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFBuffer> AMFBufferPtr;
+ //----------------------------------------------------------------------------------------------
+
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFBuffer, 0xb04b7248, 0xb6f0, 0x4321, 0xb6, 0x91, 0xba, 0xa4, 0x74, 0xf, 0x9f, 0xcb)
+
+ typedef struct AMFBufferVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFBuffer* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFBuffer* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFBuffer* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFBuffer* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFBuffer* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFBuffer* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFBuffer* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFBuffer* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFBuffer* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFBuffer* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFBuffer* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFBuffer* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFBuffer* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFData interface
+
+ AMF_MEMORY_TYPE (AMF_STD_CALL *GetMemoryType)(AMFBuffer* pThis);
+
+ AMF_RESULT (AMF_STD_CALL *Duplicate)(AMFBuffer* pThis, AMF_MEMORY_TYPE type, AMFData** ppData);
+ AMF_RESULT (AMF_STD_CALL *Convert)(AMFBuffer* pThis, AMF_MEMORY_TYPE type); // optimal interop if possilble. Copy through host memory if needed
+ AMF_RESULT (AMF_STD_CALL *Interop)(AMFBuffer* pThis, AMF_MEMORY_TYPE type); // only optimal interop if possilble. No copy through host memory for GPU objects
+
+ AMF_DATA_TYPE (AMF_STD_CALL *GetDataType)(AMFBuffer* pThis);
+
+ amf_bool (AMF_STD_CALL *IsReusable)(AMFBuffer* pThis);
+
+ void (AMF_STD_CALL *SetPts)(AMFBuffer* pThis, amf_pts pts);
+ amf_pts (AMF_STD_CALL *GetPts)(AMFBuffer* pThis);
+ void (AMF_STD_CALL *SetDuration)(AMFBuffer* pThis, amf_pts duration);
+ amf_pts (AMF_STD_CALL *GetDuration)(AMFBuffer* pThis);
+
+ // AMFBuffer interface
+
+ AMF_RESULT (AMF_STD_CALL *SetSize)(AMFBuffer* pThis, amf_size newSize);
+ amf_size (AMF_STD_CALL *GetSize)(AMFBuffer* pThis);
+ void* (AMF_STD_CALL *GetNative)(AMFBuffer* pThis);
+
+ // Observer management
+ void (AMF_STD_CALL *AddObserver_Buffer)(AMFBuffer* pThis, AMFBufferObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver_Buffer)(AMFBuffer* pThis, AMFBufferObserver* pObserver);
+
+ } AMFBufferVtbl;
+
+ struct AMFBuffer
+ {
+ const AMFBufferVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+#if defined(__cplusplus)
+} // namespace
+#endif
+#if defined(_MSC_VER)
+ #pragma warning( pop )
+#endif
+#endif //#ifndef __AMFBuffer_h__
diff --git a/compat/amd/amf/public/include/core/Compute.h b/compat/amd/amf/public/include/core/Compute.h
new file mode 100644
index 0000000..3cabdbb
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Compute.h
@@ -0,0 +1,284 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+/**
+ ***************************************************************************************************
+ * @file Compute.h
+ * @brief AMFCompute interface declaration
+ ***************************************************************************************************
+ */
+#ifndef __AMFCompute_h__
+#define __AMFCompute_h__
+#pragma once
+
+#include "Buffer.h"
+#include "Surface.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ typedef amf_uint64 AMF_KERNEL_ID;
+
+ //----------------------------------------------------------------------------------------------
+ // enumerations for plane conversion
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_CHANNEL_ORDER
+ {
+ AMF_CHANNEL_ORDER_INVALID = 0,
+ AMF_CHANNEL_ORDER_R = 1,
+ AMF_CHANNEL_ORDER_RG = 2,
+ AMF_CHANNEL_ORDER_BGRA = 3,
+ AMF_CHANNEL_ORDER_RGBA = 4,
+ AMF_CHANNEL_ORDER_ARGB = 5,
+ } AMF_CHANNEL_ORDER;
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_CHANNEL_TYPE
+ {
+ AMF_CHANNEL_INVALID = 0,
+ AMF_CHANNEL_UNSIGNED_INT8 = 1,
+ AMF_CHANNEL_UNSIGNED_INT32 = 2,
+ AMF_CHANNEL_UNORM_INT8 = 3,
+ AMF_CHANNEL_UNORM_INT16 = 4,
+ AMF_CHANNEL_SNORM_INT16 = 5,
+ AMF_CHANNEL_FLOAT = 6,
+ AMF_CHANNEL_FLOAT16 = 7,
+ } AMF_CHANNEL_TYPE;
+ //----------------------------------------------------------------------------------------------
+ // enumeration argument type
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_ARGUMENT_ACCESS_TYPE
+ {
+ AMF_ARGUMENT_ACCESS_READ = 0,
+ AMF_ARGUMENT_ACCESS_WRITE = 1,
+ AMF_ARGUMENT_ACCESS_READWRITE = 2,
+ } AMF_ARGUMENT_ACCESS_TYPE;
+ //----------------------------------------------------------------------------------------------
+ // AMFComputeKernel interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFComputeKernel : public AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0x94815701, 0x6c84, 0x4ba6, 0xa9, 0xfe, 0xe9, 0xad, 0x40, 0xf8, 0x8, 0x8)
+
+ virtual void* AMF_STD_CALL GetNative() = 0;
+ virtual const wchar_t* AMF_STD_CALL GetIDName() = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL SetArgPlaneNative(amf_size index, void* pPlane, AMF_ARGUMENT_ACCESS_TYPE eAccess) = 0;
+ virtual AMF_RESULT AMF_STD_CALL SetArgBufferNative(amf_size index, void* pBuffer, AMF_ARGUMENT_ACCESS_TYPE eAccess) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL SetArgPlane(amf_size index, AMFPlane* pPlane, AMF_ARGUMENT_ACCESS_TYPE eAccess) = 0;
+ virtual AMF_RESULT AMF_STD_CALL SetArgBuffer(amf_size index, AMFBuffer* pBuffer, AMF_ARGUMENT_ACCESS_TYPE eAccess) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL SetArgInt32(amf_size index, amf_int32 data) = 0;
+ virtual AMF_RESULT AMF_STD_CALL SetArgInt64(amf_size index, amf_int64 data) = 0;
+ virtual AMF_RESULT AMF_STD_CALL SetArgFloat(amf_size index, amf_float data) = 0;
+ virtual AMF_RESULT AMF_STD_CALL SetArgBlob(amf_size index, amf_size dataSize, const void* pData) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL GetCompileWorkgroupSize(amf_size workgroupSize[3]) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL Enqueue(amf_size dimension, amf_size globalOffset[3], amf_size globalSize[3], amf_size localSize[3]) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFComputeKernel> AMFComputeKernelPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFComputeKernel, 0x94815701, 0x6c84, 0x4ba6, 0xa9, 0xfe, 0xe9, 0xad, 0x40, 0xf8, 0x8, 0x8)
+ typedef struct AMFComputeKernel AMFComputeKernel;
+
+ typedef struct AMFComputeKernelVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFComputeKernel* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFComputeKernel* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFComputeKernel* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFComputeKernel interface
+
+ } AMFComputeKernelVtbl;
+
+ struct AMFComputeKernel
+ {
+ const AMFComputeKernelVtbl *pVtbl;
+ };
+
+#endif //#if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+ // AMFComputeSyncPoint interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFComputeSyncPoint : public AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0x66f33fe6, 0xaae, 0x4e65, 0xba, 0x3, 0xea, 0x8b, 0xa3, 0x60, 0x11, 0x2)
+
+ virtual amf_bool AMF_STD_CALL IsCompleted() = 0;
+ virtual void AMF_STD_CALL Wait() = 0;
+ };
+ typedef AMFInterfacePtr_T<AMFComputeSyncPoint> AMFComputeSyncPointPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFComputeSyncPoint, 0x66f33fe6, 0xaae, 0x4e65, 0xba, 0x3, 0xea, 0x8b, 0xa3, 0x60, 0x11, 0x2)
+ typedef struct AMFComputeSyncPoint AMFComputeSyncPoint;
+
+ typedef struct AMFComputeSyncPointVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFComputeSyncPoint* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFComputeSyncPoint* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFComputeSyncPoint* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFComputeSyncPoint interface
+ amf_bool (AMF_STD_CALL *IsCompleted)(AMFComputeSyncPoint* pThis);
+ void (AMF_STD_CALL *Wait)(AMFComputeSyncPoint* pThis);
+
+ } AMFComputeSyncPointVtbl;
+
+ struct AMFComputeSyncPoint
+ {
+ const AMFComputeSyncPointVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+ // AMFCompute interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFCompute : public AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0x3846233a, 0x3f43, 0x443f, 0x8a, 0x45, 0x75, 0x22, 0x11, 0xa9, 0xfb, 0xd5)
+
+ virtual AMF_MEMORY_TYPE AMF_STD_CALL GetMemoryType() = 0;
+
+ virtual void* AMF_STD_CALL GetNativeContext() = 0;
+ virtual void* AMF_STD_CALL GetNativeDeviceID() = 0;
+ virtual void* AMF_STD_CALL GetNativeCommandQueue() = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL GetKernel(AMF_KERNEL_ID kernelID, AMFComputeKernel** kernel) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL PutSyncPoint(AMFComputeSyncPoint** ppSyncPoint) = 0;
+ virtual AMF_RESULT AMF_STD_CALL FinishQueue() = 0;
+ virtual AMF_RESULT AMF_STD_CALL FlushQueue() = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL FillPlane(AMFPlane *pPlane, const amf_size origin[3], const amf_size region[3], const void* pColor) = 0;
+ virtual AMF_RESULT AMF_STD_CALL FillBuffer(AMFBuffer* pBuffer, amf_size dstOffset, amf_size dstSize, const void* pSourcePattern, amf_size patternSize) = 0;
+ virtual AMF_RESULT AMF_STD_CALL ConvertPlaneToBuffer(AMFPlane *pSrcPlane, AMFBuffer** ppDstBuffer) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL CopyBuffer(AMFBuffer* pSrcBuffer, amf_size srcOffset, amf_size size, AMFBuffer* pDstBuffer, amf_size dstOffset) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CopyPlane(AMFPlane *pSrcPlane, const amf_size srcOrigin[3], const amf_size region[3], AMFPlane *pDstPlane, const amf_size dstOrigin[3]) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL CopyBufferToHost(AMFBuffer* pSrcBuffer, amf_size srcOffset, amf_size size, void* pDest, amf_bool blocking) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CopyBufferFromHost(const void* pSource, amf_size size, AMFBuffer* pDstBuffer, amf_size dstOffsetInBytes, amf_bool blocking) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL CopyPlaneToHost(AMFPlane *pSrcPlane, const amf_size origin[3], const amf_size region[3], void* pDest, amf_size dstPitch, amf_bool blocking) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CopyPlaneFromHost(void* pSource, const amf_size origin[3], const amf_size region[3], amf_size srcPitch, AMFPlane *pDstPlane, amf_bool blocking) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL ConvertPlaneToPlane(AMFPlane* pSrcPlane, AMFPlane** ppDstPlane, AMF_CHANNEL_ORDER order, AMF_CHANNEL_TYPE type) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFCompute> AMFComputePtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFCompute, 0x3846233a, 0x3f43, 0x443f, 0x8a, 0x45, 0x75, 0x22, 0x11, 0xa9, 0xfb, 0xd5)
+ typedef struct AMFCompute AMFCompute;
+
+ typedef struct AMFComputeVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFCompute* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFCompute* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFCompute* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFCompute interface
+ AMF_MEMORY_TYPE (AMF_STD_CALL *GetMemoryType)(AMFCompute* pThis);
+ void* (AMF_STD_CALL *GetNativeContext)(AMFCompute* pThis);
+ void* (AMF_STD_CALL *GetNativeDeviceID)(AMFCompute* pThis);
+ void* (AMF_STD_CALL *GetNativeCommandQueue)(AMFCompute* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetKernel)(AMFCompute* pThis, AMF_KERNEL_ID kernelID, AMFComputeKernel** kernel);
+ AMF_RESULT (AMF_STD_CALL *PutSyncPoint)(AMFCompute* pThis, AMFComputeSyncPoint** ppSyncPoint);
+ AMF_RESULT (AMF_STD_CALL *FinishQueue)(AMFCompute* pThis);
+ AMF_RESULT (AMF_STD_CALL *FlushQueue)(AMFCompute* pThis);
+ AMF_RESULT (AMF_STD_CALL *FillPlane)(AMFCompute* pThis, AMFPlane *pPlane, const amf_size origin[3], const amf_size region[3], const void* pColor);
+ AMF_RESULT (AMF_STD_CALL *FillBuffer)(AMFCompute* pThis, AMFBuffer* pBuffer, amf_size dstOffset, amf_size dstSize, const void* pSourcePattern, amf_size patternSize);
+ AMF_RESULT (AMF_STD_CALL *ConvertPlaneToBuffer)(AMFCompute* pThis, AMFPlane *pSrcPlane, AMFBuffer** ppDstBuffer);
+ AMF_RESULT (AMF_STD_CALL *CopyBuffer)(AMFCompute* pThis, AMFBuffer* pSrcBuffer, amf_size srcOffset, amf_size size, AMFBuffer* pDstBuffer, amf_size dstOffset);
+ AMF_RESULT (AMF_STD_CALL *CopyPlane)(AMFCompute* pThis, AMFPlane *pSrcPlane, const amf_size srcOrigin[3], const amf_size region[3], AMFPlane *pDstPlane, const amf_size dstOrigin[3]);
+ AMF_RESULT (AMF_STD_CALL *CopyBufferToHost)(AMFCompute* pThis, AMFBuffer* pSrcBuffer, amf_size srcOffset, amf_size size, void* pDest, amf_bool blocking);
+ AMF_RESULT (AMF_STD_CALL *CopyBufferFromHost)(AMFCompute* pThis, const void* pSource, amf_size size, AMFBuffer* pDstBuffer, amf_size dstOffsetInBytes, amf_bool blocking);
+ AMF_RESULT (AMF_STD_CALL *CopyPlaneToHost)(AMFCompute* pThis, AMFPlane *pSrcPlane, const amf_size origin[3], const amf_size region[3], void* pDest, amf_size dstPitch, amf_bool blocking);
+ AMF_RESULT (AMF_STD_CALL *CopyPlaneFromHost)(AMFCompute* pThis, void* pSource, const amf_size origin[3], const amf_size region[3], amf_size srcPitch, AMFPlane *pDstPlane, amf_bool blocking);
+ AMF_RESULT (AMF_STD_CALL *ConvertPlaneToPlane)(AMFCompute* pThis, AMFPlane* pSrcPlane, AMFPlane** ppDstPlane, AMF_CHANNEL_ORDER order, AMF_CHANNEL_TYPE type);
+ } AMFComputeVtbl;
+
+ struct AMFCompute
+ {
+ const AMFComputeVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+ // AMFPrograms interface - singleton
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFPrograms
+ {
+ public:
+ virtual AMF_RESULT AMF_STD_CALL RegisterKernelSourceFile(AMF_KERNEL_ID* pKernelID, const wchar_t* kernelid_name, const char* kernelName, const wchar_t* filepath, const char* options) = 0;
+ virtual AMF_RESULT AMF_STD_CALL RegisterKernelSource(AMF_KERNEL_ID* pKernelID, const wchar_t* kernelid_name, const char* kernelName, amf_size dataSize, const amf_uint8* data, const char* options) = 0;
+ virtual AMF_RESULT AMF_STD_CALL RegisterKernelBinary(AMF_KERNEL_ID* pKernelID, const wchar_t* kernelid_name, const char* kernelName, amf_size dataSize, const amf_uint8* data, const char* options) = 0;
+ };
+#else // #if defined(__cplusplus)
+ typedef struct AMFPrograms AMFPrograms;
+ typedef struct AMFProgramsVtbl
+ {
+ AMF_RESULT (AMF_STD_CALL *RegisterKernelSourceFile)(AMFPrograms* pThis, AMF_KERNEL_ID* pKernelID, const wchar_t* kernelid_name, const char* kernelName, const wchar_t* filepath, const char* options);
+ AMF_RESULT (AMF_STD_CALL *RegisterKernelSource)(AMFPrograms* pThis, AMF_KERNEL_ID* pKernelID, const wchar_t* kernelid_name, const char* kernelName, amf_size dataSize, const amf_uint8* data, const char* options);
+ AMF_RESULT (AMF_STD_CALL *RegisterKernelBinary)(AMFPrograms* pThis, AMF_KERNEL_ID* pKernelID, const wchar_t* kernelid_name, const char* kernelName, amf_size dataSize, const amf_uint8* data, const char* options);
+ } AMFProgramsVtbl;
+
+ struct AMFPrograms
+ {
+ const AMFProgramsVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+
+#if defined(__cplusplus)
+} // namespace amf
+#endif
+
+#endif // __AMFCompute_h__
\ No newline at end of file
diff --git a/compat/amd/amf/public/include/core/ComputeFactory.h b/compat/amd/amf/public/include/core/ComputeFactory.h
new file mode 100644
index 0000000..29e2d1b
--- /dev/null
+++ b/compat/amd/amf/public/include/core/ComputeFactory.h
@@ -0,0 +1,146 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFComputeCaps_h__
+#define __AMFComputeCaps_h__
+#pragma once
+
+#include "Compute.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+// compute device audio capabilities accessed via GetProperties() from AMFComputeDevice
+#define AMF_DEVICE_NAME L"DeviceName" // char*, string, device name
+#define AMF_DRIVER_VERSION_NAME L"DriverVersion" // char*, string, driver version
+#define AMF_AUDIO_CONVOLUTION_MAX_STREAMS L"ConvolutionMaxStreams" // amf_int64, maximum number of audio streams supported in realtime
+#define AMF_AUDIO_CONVOLUTION_LENGTH L"ConvolutionLength" // amf_int64, length of convolution in samples
+#define AMF_AUDIO_CONVOLUTION_BUFFER_SIZE L"ConvolutionBufferSize" // amf_int64, buffer size in samples
+#define AMF_AUDIO_CONVOLUTION_SAMPLE_RATE L"ConvolutionSampleRate" // amf_int64, sample rate
+
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFComputeDevice : public AMFPropertyStorage
+ {
+ public:
+ AMF_DECLARE_IID(0xb79d7cf6, 0x2c5c, 0x4deb, 0xb8, 0x96, 0xa2, 0x9e, 0xbe, 0xa6, 0xe3, 0x97);
+
+ virtual void* AMF_STD_CALL GetNativePlatform() = 0;
+ virtual void* AMF_STD_CALL GetNativeDeviceID() = 0;
+ virtual void* AMF_STD_CALL GetNativeContext() = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL CreateCompute(void *reserved, AMFCompute **ppCompute) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CreateComputeEx(void* pCommandQueue, AMFCompute **ppCompute) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFComputeDevice> AMFComputeDevicePtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFComputeDevice, 0xb79d7cf6, 0x2c5c, 0x4deb, 0xb8, 0x96, 0xa2, 0x9e, 0xbe, 0xa6, 0xe3, 0x97);
+ typedef struct AMFComputeDevice AMFComputeDevice;
+
+ typedef struct AMFComputeDeviceVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFComputeDevice* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFComputeDevice* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFComputeDevice* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFComputeDevice* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFComputeDevice* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFComputeDevice* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFComputeDevice* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFComputeDevice* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFComputeDevice* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFComputeDevice* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFComputeDevice* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFComputeDevice* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFComputeDevice* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFComputeDevice interface
+ void* (AMF_STD_CALL *GetNativePlatform)(AMFComputeDevice* pThis);
+ void* (AMF_STD_CALL *GetNativeDeviceID)(AMFComputeDevice* pThis);
+ void* (AMF_STD_CALL *GetNativeContext)(AMFComputeDevice* pThis);
+
+ AMF_RESULT (AMF_STD_CALL *CreateCompute)(AMFComputeDevice* pThis, void *reserved, AMFCompute **ppCompute);
+ AMF_RESULT (AMF_STD_CALL *CreateComputeEx)(AMFComputeDevice* pThis, void* pCommandQueue, AMFCompute **ppCompute);
+
+ } AMFComputeDeviceVtbl;
+
+ struct AMFComputeDevice
+ {
+ const AMFComputeDeviceVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFComputeFactory : public AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0xe3c24bd7, 0x2d83, 0x416c, 0x8c, 0x4e, 0xfd, 0x13, 0xca, 0x86, 0xf4, 0xd0);
+
+ virtual amf_int32 AMF_STD_CALL GetDeviceCount() = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetDeviceAt(amf_int32 index, AMFComputeDevice **ppDevice) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFComputeFactory> AMFComputeFactoryPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFComputeFactory, 0xe3c24bd7, 0x2d83, 0x416c, 0x8c, 0x4e, 0xfd, 0x13, 0xca, 0x86, 0xf4, 0xd0);
+ typedef struct AMFComputeFactory AMFComputeFactory;
+
+ typedef struct AMFComputeFactoryVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFComputeFactory* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFComputeFactory* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFComputeFactory* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFComputeFactory interface
+ amf_int32 (AMF_STD_CALL *GetDeviceCount)(AMFComputeFactory* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetDeviceAt)(AMFComputeFactory* pThis, amf_int32 index, AMFComputeDevice **ppDevice);
+ } AMFComputeFactoryVtbl;
+
+ struct AMFComputeFactory
+ {
+ const AMFComputeFactoryVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+}; // namespace amf
+#endif
+#endif // __AMFComputeCaps_h__
\ No newline at end of file
diff --git a/compat/amd/amf/public/include/core/Context.h b/compat/amd/amf/public/include/core/Context.h
new file mode 100644
index 0000000..0973f63
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Context.h
@@ -0,0 +1,437 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFContext_h__
+#define __AMFContext_h__
+#pragma once
+
+#include "Buffer.h"
+#include "AudioBuffer.h"
+#include "Surface.h"
+#include "Compute.h"
+#include "ComputeFactory.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ // AMFContext interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFContext : public AMFPropertyStorage
+ {
+ public:
+ AMF_DECLARE_IID(0xa76a13f0, 0xd80e, 0x4fcc, 0xb5, 0x8, 0x65, 0xd0, 0xb5, 0x2e, 0xd9, 0xee)
+
+ // Cleanup
+ virtual AMF_RESULT AMF_STD_CALL Terminate() = 0;
+
+ // DX9
+ virtual AMF_RESULT AMF_STD_CALL InitDX9(void* pDX9Device) = 0;
+ virtual void* AMF_STD_CALL GetDX9Device(AMF_DX_VERSION dxVersionRequired = AMF_DX9) = 0;
+ virtual AMF_RESULT AMF_STD_CALL LockDX9() = 0;
+ virtual AMF_RESULT AMF_STD_CALL UnlockDX9() = 0;
+ class AMFDX9Locker;
+
+ // DX11
+ virtual AMF_RESULT AMF_STD_CALL InitDX11(void* pDX11Device, AMF_DX_VERSION dxVersionRequired = AMF_DX11_0) = 0;
+ virtual void* AMF_STD_CALL GetDX11Device(AMF_DX_VERSION dxVersionRequired = AMF_DX11_0) = 0;
+ virtual AMF_RESULT AMF_STD_CALL LockDX11() = 0;
+ virtual AMF_RESULT AMF_STD_CALL UnlockDX11() = 0;
+ class AMFDX11Locker;
+
+ // OpenCL
+ virtual AMF_RESULT AMF_STD_CALL InitOpenCL(void* pCommandQueue = NULL) = 0;
+ virtual void* AMF_STD_CALL GetOpenCLContext() = 0;
+ virtual void* AMF_STD_CALL GetOpenCLCommandQueue() = 0;
+ virtual void* AMF_STD_CALL GetOpenCLDeviceID() = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetOpenCLComputeFactory(AMFComputeFactory **ppFactory) = 0; // advanced compute - multiple queries
+ virtual AMF_RESULT AMF_STD_CALL InitOpenCLEx(AMFComputeDevice *pDevice) = 0;
+ virtual AMF_RESULT AMF_STD_CALL LockOpenCL() = 0;
+ virtual AMF_RESULT AMF_STD_CALL UnlockOpenCL() = 0;
+ class AMFOpenCLLocker;
+
+ // OpenGL
+ virtual AMF_RESULT AMF_STD_CALL InitOpenGL(amf_handle hOpenGLContext, amf_handle hWindow, amf_handle hDC) = 0;
+ virtual amf_handle AMF_STD_CALL GetOpenGLContext() = 0;
+ virtual amf_handle AMF_STD_CALL GetOpenGLDrawable() = 0;
+ virtual AMF_RESULT AMF_STD_CALL LockOpenGL() = 0;
+ virtual AMF_RESULT AMF_STD_CALL UnlockOpenGL() = 0;
+ class AMFOpenGLLocker;
+
+ // XV - Linux
+ virtual AMF_RESULT AMF_STD_CALL InitXV(void* pXVDevice) = 0;
+ virtual void* AMF_STD_CALL GetXVDevice() = 0;
+ virtual AMF_RESULT AMF_STD_CALL LockXV() = 0;
+ virtual AMF_RESULT AMF_STD_CALL UnlockXV() = 0;
+ class AMFXVLocker;
+
+ // Gralloc - Android
+ virtual AMF_RESULT AMF_STD_CALL InitGralloc(void* pGrallocDevice) = 0;
+ virtual void* AMF_STD_CALL GetGrallocDevice() = 0;
+ virtual AMF_RESULT AMF_STD_CALL LockGralloc() = 0;
+ virtual AMF_RESULT AMF_STD_CALL UnlockGralloc() = 0;
+ class AMFGrallocLocker;
+
+ // Allocation
+ virtual AMF_RESULT AMF_STD_CALL AllocBuffer(AMF_MEMORY_TYPE type, amf_size size, AMFBuffer** ppBuffer) = 0;
+ virtual AMF_RESULT AMF_STD_CALL AllocSurface(AMF_MEMORY_TYPE type, AMF_SURFACE_FORMAT format, amf_int32 width, amf_int32 height, AMFSurface** ppSurface) = 0;
+ virtual AMF_RESULT AMF_STD_CALL AllocAudioBuffer(AMF_MEMORY_TYPE type, AMF_AUDIO_FORMAT format, amf_int32 samples, amf_int32 sampleRate, amf_int32 channels,
+ AMFAudioBuffer** ppAudioBuffer) = 0;
+
+ // Wrap existing objects
+ virtual AMF_RESULT AMF_STD_CALL CreateBufferFromHostNative(void* pHostBuffer, amf_size size, AMFBuffer** ppBuffer, AMFBufferObserver* pObserver) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CreateSurfaceFromHostNative(AMF_SURFACE_FORMAT format, amf_int32 width, amf_int32 height, amf_int32 hPitch, amf_int32 vPitch, void* pData,
+ AMFSurface** ppSurface, AMFSurfaceObserver* pObserver) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CreateSurfaceFromDX9Native(void* pDX9Surface, AMFSurface** ppSurface, AMFSurfaceObserver* pObserver) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CreateSurfaceFromDX11Native(void* pDX11Surface, AMFSurface** ppSurface, AMFSurfaceObserver* pObserver) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CreateSurfaceFromOpenGLNative(AMF_SURFACE_FORMAT format, amf_handle hGLTextureID, AMFSurface** ppSurface, AMFSurfaceObserver* pObserver) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CreateSurfaceFromGrallocNative(amf_handle hGrallocSurface, AMFSurface** ppSurface, AMFSurfaceObserver* pObserver) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CreateSurfaceFromOpenCLNative(AMF_SURFACE_FORMAT format, amf_int32 width, amf_int32 height, void** pClPlanes,
+ AMFSurface** ppSurface, AMFSurfaceObserver* pObserver) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CreateBufferFromOpenCLNative(void* pCLBuffer, amf_size size, AMFBuffer** ppBuffer) = 0;
+
+ // Access to AMFCompute interface - AMF_MEMORY_OPENCL, AMF_MEMORY_COMPUTE_FOR_DX9, AMF_MEMORY_COMPUTE_FOR_DX11 are currently supported
+ virtual AMF_RESULT AMF_STD_CALL GetCompute(AMF_MEMORY_TYPE eMemType, AMFCompute** ppCompute) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFContext> AMFContextPtr;
+#else
+ typedef struct AMFContext AMFContext;
+ AMF_DECLARE_IID(AMFContext, 0xa76a13f0, 0xd80e, 0x4fcc, 0xb5, 0x8, 0x65, 0xd0, 0xb5, 0x2e, 0xd9, 0xee)
+
+ typedef struct AMFContextVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFContext* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFContext* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFContext* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFInterface AMFPropertyStorage
+
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFContext* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFContext* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFContext* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFContext* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFContext* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFContext* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFContext* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFContext* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFContext interface
+
+ // Cleanup
+ AMF_RESULT (AMF_STD_CALL *Terminate)(AMFContext* pThis);
+
+ // DX9
+ AMF_RESULT (AMF_STD_CALL *InitDX9)(AMFContext* pThis, void* pDX9Device);
+ void* (AMF_STD_CALL *GetDX9Device)(AMFContext* pThis, AMF_DX_VERSION dxVersionRequired);
+ AMF_RESULT (AMF_STD_CALL *LockDX9)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *UnlockDX9)(AMFContext* pThis);
+ // DX11
+ AMF_RESULT (AMF_STD_CALL *InitDX11)(AMFContext* pThis, void* pDX11Device, AMF_DX_VERSION dxVersionRequired);
+ void* (AMF_STD_CALL *GetDX11Device)(AMFContext* pThis, AMF_DX_VERSION dxVersionRequired);
+ AMF_RESULT (AMF_STD_CALL *LockDX11)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *UnlockDX11)(AMFContext* pThis);
+
+ // OpenCL
+ AMF_RESULT (AMF_STD_CALL *InitOpenCL)(AMFContext* pThis, void* pCommandQueue);
+ void* (AMF_STD_CALL *GetOpenCLContext)(AMFContext* pThis);
+ void* (AMF_STD_CALL *GetOpenCLCommandQueue)(AMFContext* pThis);
+ void* (AMF_STD_CALL *GetOpenCLDeviceID)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetOpenCLComputeFactory)(AMFContext* pThis, AMFComputeFactory **ppFactory); // advanced compute - multiple queries
+ AMF_RESULT (AMF_STD_CALL *InitOpenCLEx)(AMFContext* pThis, AMFComputeDevice *pDevice);
+ AMF_RESULT (AMF_STD_CALL *LockOpenCL)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *UnlockOpenCL)(AMFContext* pThis);
+
+ // OpenGL
+ AMF_RESULT (AMF_STD_CALL *InitOpenGL)(AMFContext* pThis, amf_handle hOpenGLContext, amf_handle hWindow, amf_handle hDC);
+ amf_handle (AMF_STD_CALL *GetOpenGLContext)(AMFContext* pThis);
+ amf_handle (AMF_STD_CALL *GetOpenGLDrawable)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *LockOpenGL)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *UnlockOpenGL)(AMFContext* pThis);
+ // XV - Linux
+ AMF_RESULT (AMF_STD_CALL *InitXV)(AMFContext* pThis, void* pXVDevice);
+ void* (AMF_STD_CALL *GetXVDevice)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *LockXV)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *UnlockXV)(AMFContext* pThis);
+
+ // Gralloc - Android
+ AMF_RESULT (AMF_STD_CALL *InitGralloc)(AMFContext* pThis, void* pGrallocDevice);
+ void* (AMF_STD_CALL *GetGrallocDevice)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *LockGralloc)(AMFContext* pThis);
+ AMF_RESULT (AMF_STD_CALL *UnlockGralloc)(AMFContext* pThis);
+ // Allocation
+ AMF_RESULT (AMF_STD_CALL *AllocBuffer)(AMFContext* pThis, AMF_MEMORY_TYPE type, amf_size size, AMFBuffer** ppBuffer);
+ AMF_RESULT (AMF_STD_CALL *AllocSurface)(AMFContext* pThis, AMF_MEMORY_TYPE type, AMF_SURFACE_FORMAT format, amf_int32 width, amf_int32 height, AMFSurface** ppSurface);
+ AMF_RESULT (AMF_STD_CALL *AllocAudioBuffer)(AMFContext* pThis, AMF_MEMORY_TYPE type, AMF_AUDIO_FORMAT format, amf_int32 samples, amf_int32 sampleRate, amf_int32 channels,
+ AMFAudioBuffer** ppAudioBuffer);
+
+ // Wrap existing objects
+ AMF_RESULT (AMF_STD_CALL *CreateBufferFromHostNative)(AMFContext* pThis, void* pHostBuffer, amf_size size, AMFBuffer** ppBuffer, AMFBufferObserver* pObserver);
+ AMF_RESULT (AMF_STD_CALL *CreateSurfaceFromHostNative)(AMFContext* pThis, AMF_SURFACE_FORMAT format, amf_int32 width, amf_int32 height, amf_int32 hPitch, amf_int32 vPitch, void* pData,
+ AMFSurface** ppSurface, AMFSurfaceObserver* pObserver);
+ AMF_RESULT (AMF_STD_CALL *CreateSurfaceFromDX9Native)(AMFContext* pThis, void* pDX9Surface, AMFSurface** ppSurface, AMFSurfaceObserver* pObserver);
+ AMF_RESULT (AMF_STD_CALL *CreateSurfaceFromDX11Native)(AMFContext* pThis, void* pDX11Surface, AMFSurface** ppSurface, AMFSurfaceObserver* pObserver);
+ AMF_RESULT (AMF_STD_CALL *CreateSurfaceFromOpenGLNative)(AMFContext* pThis, AMF_SURFACE_FORMAT format, amf_handle hGLTextureID, AMFSurface** ppSurface, AMFSurfaceObserver* pObserver);
+ AMF_RESULT (AMF_STD_CALL *CreateSurfaceFromGrallocNative)(AMFContext* pThis, amf_handle hGrallocSurface, AMFSurface** ppSurface, AMFSurfaceObserver* pObserver);
+ AMF_RESULT (AMF_STD_CALL *CreateSurfaceFromOpenCLNative)(AMFContext* pThis, AMF_SURFACE_FORMAT format, amf_int32 width, amf_int32 height, void** pClPlanes,
+ AMFSurface** ppSurface, AMFSurfaceObserver* pObserver);
+ AMF_RESULT (AMF_STD_CALL *CreateBufferFromOpenCLNative)(AMFContext* pThis, void* pCLBuffer, amf_size size, AMFBuffer** ppBuffer);
+
+ // Access to AMFCompute interface - AMF_MEMORY_OPENCL, AMF_MEMORY_COMPUTE_FOR_DX9, AMF_MEMORY_COMPUTE_FOR_DX11 are currently supported
+ AMF_RESULT (AMF_STD_CALL *GetCompute)(AMFContext* pThis, AMF_MEMORY_TYPE eMemType, AMFCompute** ppCompute);
+
+ } AMFContextVtbl;
+
+ struct AMFContext
+ {
+ const AMFContextVtbl *pVtbl;
+ };
+
+#endif
+
+#if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+ // Lockers
+ //----------------------------------------------------------------------------------------------
+ class AMFContext::AMFDX9Locker
+ {
+ public:
+ AMFDX9Locker() : m_Context(NULL)
+ {}
+ AMFDX9Locker(AMFContext* resources) : m_Context(NULL)
+ {
+ Lock(resources);
+ }
+ ~AMFDX9Locker()
+ {
+ if(m_Context != NULL)
+ {
+ m_Context->UnlockDX9();
+ }
+ }
+ void Lock(AMFContext* resources)
+ {
+ if(m_Context != NULL)
+ {
+ m_Context->UnlockDX9();
+ }
+ m_Context = resources;
+ if(m_Context != NULL)
+ {
+ m_Context->LockDX9();
+ }
+ }
+ protected:
+ AMFContext* m_Context;
+
+ private:
+ AMFDX9Locker(const AMFDX9Locker&);
+ AMFDX9Locker& operator=(const AMFDX9Locker&);
+ };
+ //----------------------------------------------------------------------------------------------
+ class AMFContext::AMFDX11Locker
+ {
+ public:
+ AMFDX11Locker() : m_Context(NULL)
+ {}
+ AMFDX11Locker(AMFContext* resources) : m_Context(NULL)
+ {
+ Lock(resources);
+ }
+ ~AMFDX11Locker()
+ {
+ if(m_Context != NULL)
+ {
+ m_Context->UnlockDX11();
+ }
+ }
+ void Lock(AMFContext* resources)
+ {
+ if(m_Context != NULL)
+ {
+ m_Context->UnlockDX11();
+ }
+ m_Context = resources;
+ if(m_Context != NULL)
+ {
+ m_Context->LockDX11();
+ }
+ }
+ protected:
+ AMFContext* m_Context;
+
+ private:
+ AMFDX11Locker(const AMFDX11Locker&);
+ AMFDX11Locker& operator=(const AMFDX11Locker&);
+ };
+ //----------------------------------------------------------------------------------------------
+ class AMFContext::AMFOpenCLLocker
+ {
+ public:
+ AMFOpenCLLocker() : m_Context(NULL)
+ {}
+ AMFOpenCLLocker(AMFContext* resources) : m_Context(NULL)
+ {
+ Lock(resources);
+ }
+ ~AMFOpenCLLocker()
+ {
+ if(m_Context != NULL)
+ {
+ m_Context->UnlockOpenCL();
+ }
+ }
+ void Lock(AMFContext* resources)
+ {
+ if(m_Context != NULL)
+ {
+ m_Context->UnlockOpenCL();
+ }
+ m_Context = resources;
+ if(m_Context != NULL)
+ {
+ m_Context->LockOpenCL();
+ }
+ }
+ protected:
+ AMFContext* m_Context;
+ private:
+ AMFOpenCLLocker(const AMFOpenCLLocker&);
+ AMFOpenCLLocker& operator=(const AMFOpenCLLocker&);
+ };
+ //----------------------------------------------------------------------------------------------
+ class AMFContext::AMFOpenGLLocker
+ {
+ public:
+ AMFOpenGLLocker(AMFContext* pContext) : m_pContext(pContext),
+ m_GLLocked(false)
+ {
+ if(m_pContext != NULL)
+ {
+ if(m_pContext->LockOpenGL() == AMF_OK)
+ {
+ m_GLLocked = true;
+ }
+ }
+ }
+ ~AMFOpenGLLocker()
+ {
+ if(m_GLLocked)
+ {
+ m_pContext->UnlockOpenGL();
+ }
+ }
+ private:
+ AMFContext* m_pContext;
+ amf_bool m_GLLocked; ///< AMFOpenGLLocker can be called when OpenGL is not initialized yet
+ ///< in this case don't call UnlockOpenGL
+ AMFOpenGLLocker(const AMFOpenGLLocker&);
+ AMFOpenGLLocker& operator=(const AMFOpenGLLocker&);
+ };
+ //----------------------------------------------------------------------------------------------
+ class AMFContext::AMFXVLocker
+ {
+ public:
+ AMFXVLocker() : m_pContext(NULL)
+ {}
+ AMFXVLocker(AMFContext* pContext) : m_pContext(NULL)
+ {
+ Lock(pContext);
+ }
+ ~AMFXVLocker()
+ {
+ if(m_pContext != NULL)
+ {
+ m_pContext->UnlockXV();
+ }
+ }
+ void Lock(AMFContext* pContext)
+ {
+ if((pContext != NULL) && (pContext->GetXVDevice() != NULL))
+ {
+ m_pContext = pContext;
+ m_pContext->LockXV();
+ }
+ }
+ protected:
+ AMFContext* m_pContext;
+ private:
+ AMFXVLocker(const AMFXVLocker&);
+ AMFXVLocker& operator=(const AMFXVLocker&);
+ };
+ //----------------------------------------------------------------------------------------------
+ class AMFContext::AMFGrallocLocker
+ {
+ public:
+ AMFGrallocLocker() : m_pContext(NULL)
+ {}
+ AMFGrallocLocker(AMFContext* pContext) : m_pContext(NULL)
+ {
+ Lock(pContext);
+ }
+ ~AMFGrallocLocker()
+ {
+ if(m_pContext != NULL)
+ {
+ m_pContext->UnlockGralloc();
+ }
+ }
+ void Lock(AMFContext* pContext)
+ {
+ if((pContext != NULL) && (pContext->GetGrallocDevice() != NULL))
+ {
+ m_pContext = pContext;
+ m_pContext->LockGralloc();
+ }
+ }
+ protected:
+ AMFContext* m_pContext;
+ private:
+ AMFGrallocLocker(const AMFGrallocLocker&);
+ AMFGrallocLocker& operator=(const AMFGrallocLocker&);
+ };
+#endif
+ //----------------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+}
+#endif
+
+#endif //#ifndef __AMFContext_h__
diff --git a/compat/amd/amf/public/include/core/Data.h b/compat/amd/amf/public/include/core/Data.h
new file mode 100644
index 0000000..83376a9
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Data.h
@@ -0,0 +1,159 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFData_h__
+#define __AMFData_h__
+#pragma once
+
+#include "PropertyStorage.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_DATA_TYPE
+ {
+ AMF_DATA_BUFFER = 0,
+ AMF_DATA_SURFACE = 1,
+ AMF_DATA_AUDIO_BUFFER = 2,
+ AMF_DATA_USER = 1000,
+ // all extensions will be AMF_DATA_USER+i
+ } AMF_DATA_TYPE;
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_MEMORY_TYPE
+ {
+ AMF_MEMORY_UNKNOWN = 0,
+ AMF_MEMORY_HOST = 1,
+ AMF_MEMORY_DX9 = 2,
+ AMF_MEMORY_DX11 = 3,
+ AMF_MEMORY_OPENCL = 4,
+ AMF_MEMORY_OPENGL = 5,
+ AMF_MEMORY_XV = 6,
+ AMF_MEMORY_GRALLOC = 7,
+ AMF_MEMORY_COMPUTE_FOR_DX9 = 8,
+ AMF_MEMORY_COMPUTE_FOR_DX11 = 9,
+ } AMF_MEMORY_TYPE;
+
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_DX_VERSION
+ {
+ AMF_DX9 = 90,
+ AMF_DX9_EX = 91,
+ AMF_DX11_0 = 110,
+ AMF_DX11_1 = 111
+ } AMF_DX_VERSION;
+ //----------------------------------------------------------------------------------------------
+ // AMFData interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFData : public AMFPropertyStorage
+ {
+ public:
+ AMF_DECLARE_IID(0xa1159bf6, 0x9104, 0x4107, 0x8e, 0xaa, 0xc5, 0x3d, 0x5d, 0xba, 0xc5, 0x11)
+
+ virtual AMF_MEMORY_TYPE AMF_STD_CALL GetMemoryType() = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL Duplicate(AMF_MEMORY_TYPE type, AMFData** ppData) = 0;
+ virtual AMF_RESULT AMF_STD_CALL Convert(AMF_MEMORY_TYPE type) = 0; // optimal interop if possilble. Copy through host memory if needed
+ virtual AMF_RESULT AMF_STD_CALL Interop(AMF_MEMORY_TYPE type) = 0; // only optimal interop if possilble. No copy through host memory for GPU objects
+
+ virtual AMF_DATA_TYPE AMF_STD_CALL GetDataType() = 0;
+
+ virtual amf_bool AMF_STD_CALL IsReusable() = 0;
+
+ virtual void AMF_STD_CALL SetPts(amf_pts pts) = 0;
+ virtual amf_pts AMF_STD_CALL GetPts() = 0;
+ virtual void AMF_STD_CALL SetDuration(amf_pts duration) = 0;
+ virtual amf_pts AMF_STD_CALL GetDuration() = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFData> AMFDataPtr;
+ //----------------------------------------------------------------------------------------------
+
+#else // #if defined(__cplusplus)
+ typedef struct AMFData AMFData;
+ AMF_DECLARE_IID(AMFData, 0xa1159bf6, 0x9104, 0x4107, 0x8e, 0xaa, 0xc5, 0x3d, 0x5d, 0xba, 0xc5, 0x11)
+
+ typedef struct AMFDataVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFData* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFData* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFData* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFData* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFData* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFData* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFData* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFData* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFData* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFData* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFData* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFData* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFData* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFData interface
+
+ AMF_MEMORY_TYPE (AMF_STD_CALL *GetMemoryType)(AMFData* pThis);
+
+ AMF_RESULT (AMF_STD_CALL *Duplicate)(AMFData* pThis, AMF_MEMORY_TYPE type, AMFData** ppData);
+ AMF_RESULT (AMF_STD_CALL *Convert)(AMFData* pThis, AMF_MEMORY_TYPE type); // optimal interop if possilble. Copy through host memory if needed
+ AMF_RESULT (AMF_STD_CALL *Interop)(AMFData* pThis, AMF_MEMORY_TYPE type); // only optimal interop if possilble. No copy through host memory for GPU objects
+
+ AMF_DATA_TYPE (AMF_STD_CALL *GetDataType)(AMFData* pThis);
+
+ amf_bool (AMF_STD_CALL *IsReusable)(AMFData* pThis);
+
+ void (AMF_STD_CALL *SetPts)(AMFData* pThis, amf_pts pts);
+ amf_pts (AMF_STD_CALL *GetPts)(AMFData* pThis);
+ void (AMF_STD_CALL *SetDuration)(AMFData* pThis, amf_pts duration);
+ amf_pts (AMF_STD_CALL *GetDuration)(AMFData* pThis);
+
+ } AMFDataVtbl;
+
+ struct AMFData
+ {
+ const AMFDataVtbl *pVtbl;
+ };
+
+
+#endif // #if defined(__cplusplus)
+
+#if defined(__cplusplus)
+} // namespace
+#endif
+
+#endif //#ifndef __AMFData_h__
diff --git a/compat/amd/amf/public/include/core/Debug.h b/compat/amd/amf/public/include/core/Debug.h
new file mode 100644
index 0000000..f9cff82
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Debug.h
@@ -0,0 +1,78 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFDebug_h__
+#define __AMFDebug_h__
+#pragma once
+
+#include "Platform.h"
+#include "Result.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ // AMFDebug interface - singleton
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFDebug
+ {
+ public:
+ virtual void AMF_STD_CALL EnablePerformanceMonitor(amf_bool enable) = 0;
+ virtual amf_bool AMF_STD_CALL PerformanceMonitorEnabled() = 0;
+ virtual void AMF_STD_CALL AssertsEnable(amf_bool enable) = 0;
+ virtual amf_bool AMF_STD_CALL AssertsEnabled() = 0;
+ };
+#else // #if defined(__cplusplus)
+ typedef struct AMFDebug AMFDebug;
+ typedef struct AMFDebugVtbl
+ {
+ // AMFDebug interface
+ void (AMF_STD_CALL *EnablePerformanceMonitor)(AMFDebug* pThis, amf_bool enable);
+ amf_bool (AMF_STD_CALL *PerformanceMonitorEnabled)(AMFDebug* pThis);
+ void (AMF_STD_CALL *AssertsEnable)(AMFDebug* pThis, amf_bool enable);
+ amf_bool (AMF_STD_CALL *AssertsEnabled)(AMFDebug* pThis);
+ } AMFDebugVtbl;
+
+ struct AMFDebug
+ {
+ const AMFDebugVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // __AMFDebug_h__
diff --git a/compat/amd/amf/public/include/core/Dump.h b/compat/amd/amf/public/include/core/Dump.h
new file mode 100644
index 0000000..ec6b6aa
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Dump.h
@@ -0,0 +1,112 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFDump_h__
+#define __AMFDump_h__
+#pragma once
+
+#include "Platform.h"
+#include "Result.h"
+#include "Interface.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFDump : public AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0x75366ad4, 0x504c, 0x430b, 0xbb, 0xe2, 0xad, 0x21, 0x82, 0x8, 0xf, 0x72);
+
+
+ virtual const wchar_t* AMF_STD_CALL GetDumpBasePath() const = 0; // Get application dump base path
+ virtual AMF_RESULT AMF_STD_CALL SetDumpBasePath(const wchar_t* path) = 0; // Set application dump base path
+
+ // Enable/disable input and/or output stream dumps
+ virtual bool AMF_STD_CALL IsInputDumpEnabled() const = 0;
+ virtual AMF_RESULT AMF_STD_CALL EnableInputDump(bool enabled) = 0;
+ virtual const wchar_t* AMF_STD_CALL GetInputDumpFullName() const = 0; // Get full name of dump file
+
+ // Enable/disable input and/or output stream dumps
+ virtual bool AMF_STD_CALL IsOutputDumpEnabled() const = 0;
+ virtual AMF_RESULT AMF_STD_CALL EnableOutputDump(bool enabled) = 0;
+ virtual const wchar_t* AMF_STD_CALL GetOutputDumpFullName() const = 0; // Get full name of dump file
+
+ // When enabled, each new application session will create a subfolder with a time stamp in the base path tree (disabled by default)
+ virtual bool AMF_STD_CALL IsPerSessionDumpEnabled() const = 0;
+ virtual void AMF_STD_CALL EnablePerSessionDump(bool enabled) = 0;
+ };
+ typedef AMFInterfacePtr_T<AMFDump> AMFDumpPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFDump, 0x75366ad4, 0x504c, 0x430b, 0xbb, 0xe2, 0xad, 0x21, 0x82, 0x8, 0xf, 0x72);
+ typedef struct AMFDump AMFDump;
+
+ typedef struct AMFDumpVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFDump* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFDump* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFDump* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFDump interface
+ const wchar_t* (AMF_STD_CALL *GetDumpBasePath)(AMFDump* pThis) const; // Get application dump base path
+ AMF_RESULT (AMF_STD_CALL *SetDumpBasePath)(AMFDump* pThis, const wchar_t* path); // Set application dump base path
+
+ // Enable/disable input and/or output stream dumps
+ bool (AMF_STD_CALL *IsInputDumpEnabled)(AMFDump* pThis) const;
+ AMF_RESULT (AMF_STD_CALL *EnableInputDump)(AMFDump* pThis, bool enabled);
+ const wchar_t* (AMF_STD_CALL *GetInputDumpFullName)(AMFDump* pThis) const; // Get full name of dump file
+
+ // Enable/disable input and/or output stream dumps
+ bool (AMF_STD_CALL *IsOutputDumpEnabled)(AMFDump* pThis) const;
+ AMF_RESULT (AMF_STD_CALL *EnableOutputDump)(AMFDump* pThis, bool enabled);
+ const wchar_t* (AMF_STD_CALL *GetOutputDumpFullName)(AMFDump* pThis) const; // Get full name of dump file
+
+ // When enabled, each new application session will create a subfolder with a time stamp in the base path tree (disabled by default)
+ bool (AMF_STD_CALL *IsPerSessionDumpEnabled)(AMFDump* pThis) const;
+ void (AMF_STD_CALL *EnablePerSessionDump)(AMFDump* pThis, bool enabled);
+
+ } AMFDumpVtbl;
+
+ struct AMFDump
+ {
+ const AMFDumpVtbl *pVtbl;
+ };
+
+
+#endif // #if defined(__cplusplus)
+#if defined(__cplusplus)
+} // namespace
+#endif
+
+#endif //__AMFDump_h__
diff --git a/compat/amd/amf/public/include/core/Factory.h b/compat/amd/amf/public/include/core/Factory.h
new file mode 100644
index 0000000..efc0a64
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Factory.h
@@ -0,0 +1,118 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFFactory_h__
+#define __AMFFactory_h__
+#pragma once
+
+#include "Platform.h"
+#include "Version.h"
+#include "Result.h"
+#include "Context.h"
+#include "Debug.h"
+#include "Trace.h"
+#include "Compute.h"
+
+#include "../components/Component.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ // AMFFactory interface - singleton
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFFactory
+ {
+ public:
+ virtual AMF_RESULT AMF_STD_CALL CreateContext(AMFContext** ppContext) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CreateComponent(AMFContext* pContext, const wchar_t* id, AMFComponent** ppComponent) = 0;
+ virtual AMF_RESULT AMF_STD_CALL SetCacheFolder(const wchar_t* path) = 0;
+ virtual const wchar_t* AMF_STD_CALL GetCacheFolder() = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetDebug(AMFDebug** ppDebug) = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetTrace(AMFTrace** ppTrace) = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetPrograms(AMFPrograms** ppPrograms) = 0;
+ };
+#else
+ typedef struct AMFFactory AMFFactory;
+
+ typedef struct AMFFactoryVtbl
+ {
+ AMF_RESULT (AMF_STD_CALL *CreateContext)(AMFFactory* pThis, AMFContext** ppContext);
+ AMF_RESULT (AMF_STD_CALL *CreateComponent)(AMFFactory* pThis, AMFContext* pContext, const wchar_t* id, AMFComponent** ppComponent);
+ AMF_RESULT (AMF_STD_CALL *SetCacheFolder)(AMFFactory* pThis, const wchar_t* path);
+ const wchar_t* (AMF_STD_CALL *GetCacheFolder)(AMFFactory* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetDebug)(AMFFactory* pThis, AMFDebug** ppDebug);
+ AMF_RESULT (AMF_STD_CALL *GetTrace)(AMFFactory* pThis, AMFTrace** ppTrace);
+ AMF_RESULT (AMF_STD_CALL *GetPrograms)(AMFFactory* pThis, AMFPrograms** ppPrograms);
+ } AMFFactoryVtbl;
+
+ struct AMFFactory
+ {
+ const AMFFactoryVtbl *pVtbl;
+ };
+
+#endif
+#if defined(__cplusplus)
+}
+#endif
+
+//----------------------------------------------------------------------------------------------
+// DLL entry points
+//----------------------------------------------------------------------------------------------
+
+#define AMF_INIT_FUNCTION_NAME "AMFInit"
+#define AMF_QUERY_VERSION_FUNCTION_NAME "AMFQueryVersion"
+
+#if defined(__cplusplus)
+extern "C"
+{
+ typedef AMF_RESULT (AMF_CDECL_CALL *AMFInit_Fn)(amf_uint64 version, amf::AMFFactory **ppFactory);
+ typedef AMF_RESULT (AMF_CDECL_CALL *AMFQueryVersion_Fn)(amf_uint64 *pVersion);
+}
+#else
+ typedef AMF_RESULT (AMF_CDECL_CALL *AMFInit_Fn)(amf_uint64 version, AMFFactory **ppFactory);
+ typedef AMF_RESULT (AMF_CDECL_CALL *AMFQueryVersion_Fn)(amf_uint64 *pVersion);
+#endif
+
+#if defined(_M_AMD64)
+ #define AMF_DLL_NAME L"amfrt64.dll"
+ #define AMF_DLL_NAMEA "amfrt64.dll"
+#else
+ #define AMF_DLL_NAME L"amfrt32.dll"
+ #define AMF_DLL_NAMEA "amfrt32.dll"
+#endif
+
+//----------------------------------------------------------------------------------------------
+
+#endif
\ No newline at end of file
diff --git a/compat/amd/amf/public/include/core/Interface.h b/compat/amd/amf/public/include/core/Interface.h
new file mode 100644
index 0000000..02b8428
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Interface.h
@@ -0,0 +1,258 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFInterface_h__
+#define __AMFInterface_h__
+#pragma once
+
+#include "Result.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+#if defined(__cplusplus)
+ #define AMF_DECLARE_IID(_data1, _data2, _data3, _data41, _data42, _data43, _data44, _data45, _data46, _data47, _data48) \
+ AMF_INLINE static const amf::AMFGuid IID() \
+ { \
+ amf::AMFGuid uid = {_data1, _data2, _data3, _data41, _data42, _data43, _data44, _data45, _data46, _data47, _data48}; \
+ return uid; \
+ }
+#else
+#define AMF_DECLARE_IID(name, _data1, _data2, _data3, _data41, _data42, _data43, _data44, _data45, _data46, _data47, _data48) \
+ AMF_INLINE static const AMFGuid IID_##name(void) \
+ { \
+ AMFGuid uid = {_data1, _data2, _data3, _data41, _data42, _data43, _data44, _data45, _data46, _data47, _data48}; \
+ return uid; \
+ }
+#endif
+
+ //------------------------------------------------------------------------
+ // AMFInterface interface - base class for all AMF interfaces
+ //------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0x9d872f34, 0x90dc, 0x4b93, 0xb6, 0xb2, 0x6c, 0xa3, 0x7c, 0x85, 0x25, 0xdb)
+
+ virtual amf_long AMF_STD_CALL Acquire() = 0;
+ virtual amf_long AMF_STD_CALL Release() = 0;
+ virtual AMF_RESULT AMF_STD_CALL QueryInterface(const AMFGuid& interfaceID, void** ppInterface) = 0;
+ };
+#else
+ AMF_DECLARE_IID(AMFInterface, 0x9d872f34, 0x90dc, 0x4b93, 0xb6, 0xb2, 0x6c, 0xa3, 0x7c, 0x85, 0x25, 0xdb)
+ typedef struct AMFInterface AMFInterface;
+
+ typedef struct AMFInterfaceVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFInterface* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFInterface* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFInterface* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+ } AMFInterfaceVtbl;
+
+ struct AMFInterface
+ {
+ const AMFInterfaceVtbl *pVtbl;
+ };
+#endif
+ //------------------------------------------------------------------------
+ // template for AMF smart pointer
+ //------------------------------------------------------------------------
+#if defined(__cplusplus)
+ template<typename _Interf>
+ class AMFInterfacePtr_T
+ {
+ private:
+ _Interf* m_pInterf;
+
+ void InternalAcquire()
+ {
+ if(m_pInterf != NULL)
+ {
+ m_pInterf->Acquire();
+ }
+ }
+ void InternalRelease()
+ {
+ if(m_pInterf != NULL)
+ {
+ m_pInterf->Release();
+ }
+ }
+ public:
+ AMFInterfacePtr_T() : m_pInterf(NULL)
+ {}
+
+ AMFInterfacePtr_T(const AMFInterfacePtr_T<_Interf>& p) : m_pInterf(p.m_pInterf)
+ {
+ InternalAcquire();
+ }
+
+ AMFInterfacePtr_T(_Interf* pInterface) : m_pInterf(pInterface)
+ {
+ InternalAcquire();
+ }
+
+ template<typename _OtherInterf>
+ explicit AMFInterfacePtr_T(const AMFInterfacePtr_T<_OtherInterf>& cp) : m_pInterf(NULL)
+ {
+ void* pInterf = NULL;
+ if((cp == NULL) || (cp->QueryInterface(_Interf::IID(), &pInterf) != AMF_OK))
+ {
+ pInterf = NULL;
+ }
+ m_pInterf = static_cast<_Interf*>(pInterf);
+ }
+
+ template<typename _OtherInterf>
+ explicit AMFInterfacePtr_T(_OtherInterf* cp) : m_pInterf(NULL)
+ {
+ void* pInterf = NULL;
+ if((cp == NULL) || (cp->QueryInterface(_Interf::IID(), &pInterf) != AMF_OK))
+ {
+ pInterf = NULL;
+ }
+ m_pInterf = static_cast<_Interf*>(pInterf);
+ }
+
+ ~AMFInterfacePtr_T()
+ {
+ InternalRelease();
+ }
+
+ AMFInterfacePtr_T& operator=(_Interf* pInterface)
+ {
+ if(m_pInterf != pInterface)
+ {
+ _Interf* pOldInterface = m_pInterf;
+ m_pInterf = pInterface;
+ InternalAcquire();
+ if(pOldInterface != NULL)
+ {
+ pOldInterface->Release();
+ }
+ }
+ return *this;
+ }
+
+ AMFInterfacePtr_T& operator=(const AMFInterfacePtr_T<_Interf>& cp)
+ {
+ return operator=(cp.m_pInterf);
+ }
+
+ void Attach(_Interf* pInterface)
+ {
+ InternalRelease();
+ m_pInterf = pInterface;
+ }
+
+ _Interf* Detach()
+ {
+ _Interf* const pOld = m_pInterf;
+ m_pInterf = NULL;
+ return pOld;
+ }
+ void Release()
+ {
+ InternalRelease();
+ m_pInterf = NULL;
+ }
+
+ operator _Interf*() const
+ {
+ return m_pInterf;
+ }
+
+ _Interf& operator*() const
+ {
+ return *m_pInterf;
+ }
+
+ // Returns the address of the interface pointer contained in this
+ // class. This is required for initializing from C-style factory function to
+ // avoid getting an incorrect ref count at the beginning.
+
+ _Interf** operator&()
+ {
+ InternalRelease();
+ m_pInterf = 0;
+ return &m_pInterf;
+ }
+
+ _Interf* operator->() const
+ {
+ return m_pInterf;
+ }
+
+ bool operator==(const AMFInterfacePtr_T<_Interf>& p)
+ {
+ return (m_pInterf == p.m_pInterf);
+ }
+
+ bool operator==(_Interf* p)
+ {
+ return (m_pInterf == p);
+ }
+
+ bool operator!=(const AMFInterfacePtr_T<_Interf>& p)
+ {
+ return !(operator==(p));
+ }
+ bool operator!=(_Interf* p)
+ {
+ return !(operator==(p));
+ }
+
+ _Interf* GetPtr()
+ {
+ return m_pInterf;
+ }
+
+ const _Interf* GetPtr() const
+ {
+ return m_pInterf;
+ }
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFInterface> AMFInterfacePtr;
+ //----------------------------------------------------------------------------------------------
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif //#ifndef __AMFInterface_h__
diff --git a/compat/amd/amf/public/include/core/Plane.h b/compat/amd/amf/public/include/core/Plane.h
new file mode 100644
index 0000000..d993cf8
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Plane.h
@@ -0,0 +1,112 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFPlane_h__
+#define __AMFPlane_h__
+#pragma once
+
+#include "Interface.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //---------------------------------------------------------------------------------------------
+ typedef enum AMF_PLANE_TYPE
+ {
+ AMF_PLANE_UNKNOWN = 0,
+ AMF_PLANE_PACKED = 1, // for all packed formats: BGRA, YUY2, etc
+ AMF_PLANE_Y = 2,
+ AMF_PLANE_UV = 3,
+ AMF_PLANE_U = 4,
+ AMF_PLANE_V = 5,
+ } AMF_PLANE_TYPE;
+ //---------------------------------------------------------------------------------------------
+ // AMFPlane interface
+ //---------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFPlane : public AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0xbede1aa6, 0xd8fa, 0x4625, 0x94, 0x65, 0x6c, 0x82, 0xc4, 0x37, 0x71, 0x2e)
+
+ virtual AMF_PLANE_TYPE AMF_STD_CALL GetType() = 0;
+ virtual void* AMF_STD_CALL GetNative() = 0;
+ virtual amf_int32 AMF_STD_CALL GetPixelSizeInBytes() = 0;
+ virtual amf_int32 AMF_STD_CALL GetOffsetX() = 0;
+ virtual amf_int32 AMF_STD_CALL GetOffsetY() = 0;
+ virtual amf_int32 AMF_STD_CALL GetWidth() = 0;
+ virtual amf_int32 AMF_STD_CALL GetHeight() = 0;
+ virtual amf_int32 AMF_STD_CALL GetHPitch() = 0;
+ virtual amf_int32 AMF_STD_CALL GetVPitch() = 0;
+ virtual bool AMF_STD_CALL IsTiled() = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFPlane> AMFPlanePtr;
+ //----------------------------------------------------------------------------------------------
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFPlane, 0xbede1aa6, 0xd8fa, 0x4625, 0x94, 0x65, 0x6c, 0x82, 0xc4, 0x37, 0x71, 0x2e)
+ typedef struct AMFPlane AMFPlane;
+ typedef struct AMFPlaneVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFPlane* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFPlane* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFPlane* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPlane interface
+ AMF_PLANE_TYPE (AMF_STD_CALL *GetType)(AMFPlane* pThis);
+ void* (AMF_STD_CALL *GetNative)(AMFPlane* pThis);
+ amf_int32 (AMF_STD_CALL *GetPixelSizeInBytes)(AMFPlane* pThis);
+ amf_int32 (AMF_STD_CALL *GetOffsetX)(AMFPlane* pThis);
+ amf_int32 (AMF_STD_CALL *GetOffsetY)(AMFPlane* pThis);
+ amf_int32 (AMF_STD_CALL *GetWidth)(AMFPlane* pThis);
+ amf_int32 (AMF_STD_CALL *GetHeight)(AMFPlane* pThis);
+ amf_int32 (AMF_STD_CALL *GetHPitch)(AMFPlane* pThis);
+ amf_int32 (AMF_STD_CALL *GetVPitch)(AMFPlane* pThis);
+ amf_bool (AMF_STD_CALL *IsTiled)(AMFPlane* pThis);
+
+ } AMFPlaneVtbl;
+
+ struct AMFPlane
+ {
+ const AMFPlaneVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+
+#if defined(__cplusplus)
+} // namespace amf
+#endif
+
+#endif //#ifndef __AMFPlane_h__
diff --git a/compat/amd/amf/public/include/core/Platform.h b/compat/amd/amf/public/include/core/Platform.h
new file mode 100644
index 0000000..fff8939
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Platform.h
@@ -0,0 +1,438 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFPlatform_h__
+#define __AMFPlatform_h__
+#pragma once
+
+//----------------------------------------------------------------------------------------------
+// export declaration
+//----------------------------------------------------------------------------------------------
+#ifdef _WIN32
+ #if defined(AMF_CORE_STATIC)
+ #define AMF_CORE_LINK
+ #else
+ #if defined(AMF_CORE_EXPORTS)
+ #define AMF_CORE_LINK __declspec(dllexport)
+ #else
+ #define AMF_CORE_LINK __declspec(dllimport)
+ #endif
+ #endif
+#else // #ifdef _WIN32
+ #define AMF_CORE_LINK
+#endif // #ifdef _WIN32
+
+#define AMF_MACRO_STRING2(x) #x
+#define AMF_MACRO_STRING(x) AMF_MACRO_STRING2(x)
+
+#define AMF_TODO(_todo) (__FILE__ "(" AMF_MACRO_STRING(__LINE__) "): TODO: "_todo)
+
+
+ #if defined(__GNUC__) || defined(__clang__)
+ #define AMF_ALIGN(n) __attribute__((aligned(n)))
+ #elif defined(_MSC_VER) || defined(__INTEL_COMPILER)
+ #define AMF_ALIGN(n) __declspec(align(n))
+ #else
+ #define AMF_ALIGN(n)
+// #error Need to define AMF_ALIGN
+ #endif
+
+#include <stdio.h>
+#include <stdint.h>
+
+#if defined(_WIN32)
+
+
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+ #define AMF_STD_CALL __stdcall
+ #define AMF_CDECL_CALL __cdecl
+ #define AMF_FAST_CALL __fastcall
+#if defined(__GNUC__) || defined(__clang__)
+ #define AMF_INLINE inline
+ #define AMF_FORCEINLINE inline
+#else
+ #define AMF_INLINE __inline
+ #define AMF_FORCEINLINE __forceinline
+#endif
+ #define AMF_NO_VTABLE __declspec(novtable)
+
+ #define AMFPRId64 "I64d"
+ #define LPRId64 L"I64d"
+
+ #define AMFPRIud64 "Iu64d"
+ #define LPRIud64 L"Iu64d"
+
+ #define AMFPRIx64 "I64x"
+ #define LPRIx64 L"I64x"
+
+#else // !WIN32 - Linux and Mac
+
+ #define AMF_STD_CALL
+ #define AMF_CDECL_CALL
+ #define AMF_FAST_CALL
+#if defined(__GNUC__) || defined(__clang__)
+ #define AMF_INLINE inline
+ #define AMF_FORCEINLINE inline
+#else
+ #define AMF_INLINE __inline__
+ #define AMF_FORCEINLINE __inline__
+#endif
+ #define AMF_NO_VTABLE
+
+ #if !defined(AMFPRId64)
+ #define AMFPRId64 "lld"
+ #define LPRId64 L"lld"
+
+ #define AMFPRIud64 "ulld"
+ #define LPRIud64 L"ulld"
+
+ #define AMFPRIx64 "llx"
+ #define LPRIx64 L"llx"
+ #endif
+
+#endif // WIN32
+
+
+#if defined(_MSC_VER)
+#define AMF_WEAK __declspec( selectany )
+#elif defined (__GCC__) || defined(__clang__)//GCC or CLANG
+#define AMF_WEAK __attribute__((weak))
+#endif
+
+#define amf_countof(x) (sizeof(x) / sizeof(x[0]))
+
+//-------------------------------------------------------------------------------------------------
+// basic data types
+//-------------------------------------------------------------------------------------------------
+typedef int64_t amf_int64;
+typedef int32_t amf_int32;
+typedef int16_t amf_int16;
+typedef int8_t amf_int8;
+
+typedef uint64_t amf_uint64;
+typedef uint32_t amf_uint32;
+typedef uint16_t amf_uint16;
+typedef uint8_t amf_uint8;
+typedef size_t amf_size;
+
+typedef void* amf_handle;
+typedef double amf_double;
+typedef float amf_float;
+
+typedef void amf_void;
+
+#if defined(__cplusplus)
+typedef bool amf_bool;
+#else
+typedef amf_uint16 amf_bool;
+#define true 1
+#define false 0
+#endif
+
+typedef long amf_long;
+typedef int amf_int;
+typedef unsigned long amf_ulong;
+typedef unsigned int amf_uint;
+
+typedef amf_int64 amf_pts; // in 100 nanosecs
+
+#define AMF_SECOND 10000000L // 1 second in 100 nanoseconds
+
+#define AMF_MIN(a, b) ((a) < (b) ? (a) : (b))
+#define AMF_MAX(a, b) ((a) > (b) ? (a) : (b))
+
+#if defined(_WIN32)
+ #define PATH_SEPARATOR_WSTR L"\\"
+ #define PATH_SEPARATOR_WCHAR L'\\'
+#elif defined(__linux) // Linux
+ #define PATH_SEPARATOR_WSTR L"/"
+ #define PATH_SEPARATOR_WCHAR L'/'
+#endif
+
+typedef struct AMFRect
+{
+ amf_int32 left;
+ amf_int32 top;
+ amf_int32 right;
+ amf_int32 bottom;
+#if defined(__cplusplus)
+ bool operator==(const AMFRect& other) const
+ {
+ return left == other.left && top == other.top && right == other.right && bottom == other.bottom;
+ }
+ AMF_INLINE bool operator!=(const AMFRect& other) const { return !operator==(other); }
+ amf_int32 Width() const { return right - left; }
+ amf_int32 Height() const { return bottom - top; }
+#endif
+} AMFRect;
+
+AMF_INLINE struct AMFRect AMFConstructRect(amf_int32 left, amf_int32 top, amf_int32 right, amf_int32 bottom)
+{
+ struct AMFRect object = {left, top, right, bottom};
+ return object;
+}
+
+typedef struct AMFSize
+{
+ amf_int32 width;
+ amf_int32 height;
+#if defined(__cplusplus)
+ bool operator==(const AMFSize& other) const
+ {
+ return width == other.width && height == other.height;
+ }
+ AMF_INLINE bool operator!=(const AMFSize& other) const { return !operator==(other); }
+#endif
+} AMFSize;
+
+AMF_INLINE struct AMFSize AMFConstructSize(amf_int32 width, amf_int32 height)
+{
+ struct AMFSize object = {width, height};
+ return object;
+}
+
+typedef struct AMFPoint
+{
+ amf_int32 x;
+ amf_int32 y;
+#if defined(__cplusplus)
+ bool operator==(const AMFPoint& other) const
+ {
+ return x == other.x && y == other.y;
+ }
+ AMF_INLINE bool operator!=(const AMFPoint& other) const { return !operator==(other); }
+#endif
+} AMFPoint;
+
+AMF_INLINE struct AMFPoint AMFConstructPoint(amf_int32 x, amf_int32 y)
+{
+ struct AMFPoint object = {x, y};
+ return object;
+}
+
+typedef struct AMFRate
+{
+ amf_uint32 num;
+ amf_uint32 den;
+#if defined(__cplusplus)
+ bool operator==(const AMFRate& other) const
+ {
+ return num == other.num && den == other.den;
+ }
+ AMF_INLINE bool operator!=(const AMFRate& other) const { return !operator==(other); }
+#endif
+} AMFRate;
+
+AMF_INLINE struct AMFRate AMFConstructRate(amf_uint32 num, amf_uint32 den)
+{
+ struct AMFRate object = {num, den};
+ return object;
+}
+
+typedef struct AMFRatio
+{
+ amf_uint32 num;
+ amf_uint32 den;
+#if defined(__cplusplus)
+ bool operator==(const AMFRatio& other) const
+ {
+ return num == other.num && den == other.den;
+ }
+ AMF_INLINE bool operator!=(const AMFRatio& other) const { return !operator==(other); }
+#endif
+} AMFRatio;
+
+AMF_INLINE struct AMFRatio AMFConstructRatio(amf_uint32 num, amf_uint32 den)
+{
+ struct AMFRatio object = {num, den};
+ return object;
+}
+
+#pragma pack(push, 1)
+#if defined(_MSC_VER)
+ #pragma warning( push )
+#endif
+#if defined(WIN32)
+#if defined(_MSC_VER)
+ #pragma warning(disable : 4200)
+ #pragma warning(disable : 4201)
+#endif
+#endif
+typedef struct AMFColor
+{
+ union
+ {
+ struct
+ {
+ amf_uint8 r;
+ amf_uint8 g;
+ amf_uint8 b;
+ amf_uint8 a;
+ };
+ amf_uint32 rgba;
+ };
+#if defined(__cplusplus)
+ bool operator==(const AMFColor& other) const
+ {
+ return r == other.r && g == other.g && b == other.b && a == other.a;
+ }
+ AMF_INLINE bool operator!=(const AMFColor& other) const { return !operator==(other); }
+#endif
+} AMFColor;
+#if defined(_MSC_VER)
+ #pragma warning( pop )
+#endif
+#pragma pack(pop)
+
+
+AMF_INLINE struct AMFColor AMFConstructColor(amf_uint8 r, amf_uint8 g, amf_uint8 b, amf_uint8 a)
+{
+ struct AMFColor object;
+ object.r = r;
+ object.g = g;
+ object.b = b;
+ object.a = a;
+ return object;
+}
+
+#if defined(_WIN32)
+ #include <combaseapi.h>
+
+ #if defined(__cplusplus)
+ extern "C"
+ {
+ #endif
+ // allocator
+ AMF_INLINE void* AMF_CDECL_CALL amf_variant_alloc(amf_size count)
+ {
+ return CoTaskMemAlloc(count);
+ }
+ AMF_INLINE void AMF_CDECL_CALL amf_variant_free(void* ptr)
+ {
+ CoTaskMemFree(ptr);
+ }
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#else // defined(_WIN32)
+ #include <stdlib.h>
+ #if defined(__cplusplus)
+ extern "C"
+ {
+ #endif
+ // allocator
+ AMF_INLINE void* AMF_CDECL_CALL amf_variant_alloc(amf_size count)
+ {
+ return malloc(count);
+ }
+ AMF_INLINE void AMF_CDECL_CALL amf_variant_free(void* ptr)
+ {
+ free(ptr);
+ }
+ #if defined(__cplusplus)
+ }
+ #endif
+#endif // defined(_WIN32)
+
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ typedef struct AMFGuid
+ {
+ amf_uint32 data1;
+ amf_uint16 data2;
+ amf_uint16 data3;
+ amf_uint8 data41;
+ amf_uint8 data42;
+ amf_uint8 data43;
+ amf_uint8 data44;
+ amf_uint8 data45;
+ amf_uint8 data46;
+ amf_uint8 data47;
+ amf_uint8 data48;
+#if defined(__cplusplus)
+ AMFGuid(amf_uint32 _data1, amf_uint16 _data2, amf_uint16 _data3,
+ amf_uint8 _data41, amf_uint8 _data42, amf_uint8 _data43, amf_uint8 _data44,
+ amf_uint8 _data45, amf_uint8 _data46, amf_uint8 _data47, amf_uint8 _data48)
+ : data1 (_data1),
+ data2 (_data2),
+ data3 (_data3),
+ data41(_data41),
+ data42(_data42),
+ data43(_data43),
+ data44(_data44),
+ data45(_data45),
+ data46(_data46),
+ data47(_data47),
+ data48(_data48)
+ {}
+
+ bool operator==(const AMFGuid& other) const
+ {
+ return
+ data1 == other.data1 &&
+ data2 == other.data2 &&
+ data3 == other.data3 &&
+ data41 == other.data41 &&
+ data42 == other.data42 &&
+ data43 == other.data43 &&
+ data44 == other.data44 &&
+ data45 == other.data45 &&
+ data46 == other.data46 &&
+ data47 == other.data47 &&
+ data48 == other.data48;
+ }
+ AMF_INLINE bool operator!=(const AMFGuid& other) const { return !operator==(other); }
+#endif
+ } AMFGuid;
+
+#if defined(__cplusplus)
+ AMF_INLINE bool AMFCompareGUIDs(const AMFGuid& guid1, const AMFGuid& guid2)
+ {
+ return guid1 == guid2;
+ }
+#else
+ AMF_INLINE amf_bool AMFCompareGUIDs(const struct AMFGuid guid1, const struct AMFGuid guid2)
+ {
+ return memcmp(&guid1, &guid2, sizeof(guid1)) == 0;
+ }
+#endif
+#if defined(__cplusplus)
+}
+#endif
+
+#endif //#ifndef __AMFPlatform_h__
diff --git a/compat/amd/amf/public/include/core/PropertyStorage.h b/compat/amd/amf/public/include/core/PropertyStorage.h
new file mode 100644
index 0000000..6370845
--- /dev/null
+++ b/compat/amd/amf/public/include/core/PropertyStorage.h
@@ -0,0 +1,225 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFPropertyStorage_h__
+#define __AMFPropertyStorage_h__
+#pragma once
+
+#include "Variant.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ // AMFPropertyStorageObserver interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+
+ class AMF_NO_VTABLE AMFPropertyStorageObserver
+ {
+ public:
+ virtual void AMF_STD_CALL OnPropertyChanged(const wchar_t* name) = 0;
+ };
+#else //#if defined(__cplusplus)
+ typedef struct AMFPropertyStorageObserver AMFPropertyStorageObserver;
+ typedef struct AMFPropertyStorageObserverVtbl
+ {
+ void (AMF_STD_CALL *OnPropertyChanged)(AMFPropertyStorageObserver *pThis, const wchar_t* name);
+ } AMFPropertyStorageObserverVtbl;
+
+ struct AMFPropertyStorageObserver
+ {
+ const AMFPropertyStorageObserverVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+#if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+ // AMFPropertyStorage interface
+ //----------------------------------------------------------------------------------------------
+ class AMF_NO_VTABLE AMFPropertyStorage : public AMFInterface
+ {
+ public:
+ AMF_DECLARE_IID(0xc7cec05b, 0xcfb9, 0x48af, 0xac, 0xe3, 0xf6, 0x8d, 0xf8, 0x39, 0x5f, 0xe3)
+
+ virtual AMF_RESULT AMF_STD_CALL SetProperty(const wchar_t* name, AMFVariantStruct value) = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetProperty(const wchar_t* name, AMFVariantStruct* pValue) const = 0;
+
+ virtual amf_bool AMF_STD_CALL HasProperty(const wchar_t* name) const = 0;
+ virtual amf_size AMF_STD_CALL GetPropertyCount() const = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetPropertyAt(amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue) const = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL Clear() = 0;
+ virtual AMF_RESULT AMF_STD_CALL AddTo(AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep) const= 0;
+ virtual AMF_RESULT AMF_STD_CALL CopyTo(AMFPropertyStorage* pDest, amf_bool deep) const = 0;
+
+ virtual void AMF_STD_CALL AddObserver(AMFPropertyStorageObserver* pObserver) = 0;
+ virtual void AMF_STD_CALL RemoveObserver(AMFPropertyStorageObserver* pObserver) = 0;
+
+ template<typename _T>
+ AMF_RESULT AMF_STD_CALL SetProperty(const wchar_t* name, const _T& value);
+ template<typename _T>
+ AMF_RESULT AMF_STD_CALL GetProperty(const wchar_t* name, _T* pValue) const;
+ template<typename _T>
+ AMF_RESULT AMF_STD_CALL GetPropertyString(const wchar_t* name, _T* pValue) const;
+ template<typename _T>
+ AMF_RESULT AMF_STD_CALL GetPropertyWString(const wchar_t* name, _T* pValue) const;
+
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFPropertyStorage> AMFPropertyStoragePtr;
+ //----------------------------------------------------------------------------------------------
+
+#else // #if defined(__cplusplus)
+ typedef struct AMFPropertyStorage AMFPropertyStorage;
+ AMF_DECLARE_IID(AMFPropertyStorage, 0xc7cec05b, 0xcfb9, 0x48af, 0xac, 0xe3, 0xf6, 0x8d, 0xf8, 0x39, 0x5f, 0xe3)
+
+ typedef struct AMFPropertyStorageVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFPropertyStorage* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFPropertyStorage* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFPropertyStorage* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFPropertyStorage* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFPropertyStorage* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFPropertyStorage* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFPropertyStorage* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFPropertyStorage* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFPropertyStorage* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFPropertyStorage* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFPropertyStorage* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFPropertyStorage* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFPropertyStorage* pThis, AMFPropertyStorageObserver* pObserver);
+
+ } AMFPropertyStorageVtbl;
+
+ struct AMFPropertyStorage
+ {
+ const AMFPropertyStorageVtbl *pVtbl;
+ };
+
+ #define AMF_ASSIGN_PROPERTY_DATA(res, varType, pThis, name, val ) \
+ { \
+ AMFVariantStruct var = {0}; \
+ AMFVariantAssign##varType(&var, val); \
+ res = pThis->pVtbl->SetProperty(pThis, name, var ); \
+ }
+ #define AMF_ASSIGN_PROPERTY_TYPE(res, varType, dataType , pThis, name, val ) AMF_ASSIGN_PROPERTY_DATA(res, varType, pThis, name, (dataType)val)
+
+ #define AMF_ASSIGN_PROPERTY_INT64(res, pThis, name, val ) AMF_ASSIGN_PROPERTY_TYPE(res, Int64, amf_int64, pThis, name, val)
+ #define AMF_ASSIGN_PROPERTY_DOUBLE(res, pThis, name, val ) AMF_ASSIGN_PROPERTY_TYPE(res, Double, amf_double, pThis, name, val)
+ #define AMF_ASSIGN_PROPERTY_BOOL(res, pThis, name, val ) AMF_ASSIGN_PROPERTY_TYPE(res, Bool, amf_bool, pThis, name, val)
+ #define AMF_ASSIGN_PROPERTY_RECT(res, pThis, name, val ) AMF_ASSIGN_PROPERTY_DATA(res, Rect, pThis, name, &val)
+ #define AMF_ASSIGN_PROPERTY_SIZE(res, pThis, name, val ) AMF_ASSIGN_PROPERTY_DATA(res, Size, pThis, name, &val)
+ #define AMF_ASSIGN_PROPERTY_POINT(res, pThis, name, val ) AMF_ASSIGN_PROPERTY_DATA(res, Point, pThis, name, &val)
+ #define AMF_ASSIGN_PROPERTY_RATE(res, pThis, name, val ) AMF_ASSIGN_PROPERTY_DATA(res, Rate, pThis, name, &val)
+ #define AMF_ASSIGN_PROPERTY_RATIO(res, pThis, name, val ) AMF_ASSIGN_PROPERTY_DATA(res, Ratio, pThis, name, &val)
+ #define AMF_ASSIGN_PROPERTY_COLOR(res, pThis, name, val ) AMF_ASSIGN_PROPERTY_DATA(res, Color, pThis, name, &val)
+
+#endif // #if defined(__cplusplus)
+
+
+#if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+ // template methods implementations
+ //----------------------------------------------------------------------------------------------
+ template<typename _T> inline
+ AMF_RESULT AMF_STD_CALL AMFPropertyStorage::SetProperty(const wchar_t* name, const _T& value)
+ {
+ AMF_RESULT err = SetProperty(name, static_cast<const AMFVariantStruct&>(AMFVariant(value)));
+ return err;
+ }
+ //----------------------------------------------------------------------------------------------
+ template<typename _T> inline
+ AMF_RESULT AMF_STD_CALL AMFPropertyStorage::GetProperty(const wchar_t* name, _T* pValue) const
+ {
+ AMFVariant var;
+ AMF_RESULT err = GetProperty(name, static_cast<AMFVariantStruct*>(&var));
+ if(err == AMF_OK)
+ {
+ *pValue = static_cast<_T>(var);
+ }
+ return err;
+ }
+ //----------------------------------------------------------------------------------------------
+ template<typename _T> inline
+ AMF_RESULT AMF_STD_CALL AMFPropertyStorage::GetPropertyString(const wchar_t* name, _T* pValue) const
+ {
+ AMFVariant var;
+ AMF_RESULT err = GetProperty(name, static_cast<AMFVariantStruct*>(&var));
+ if(err == AMF_OK)
+ {
+ *pValue = var.ToString().c_str();
+ }
+ return err;
+ }
+ //----------------------------------------------------------------------------------------------
+ template<typename _T> inline
+ AMF_RESULT AMF_STD_CALL AMFPropertyStorage::GetPropertyWString(const wchar_t* name, _T* pValue) const
+ {
+ AMFVariant var;
+ AMF_RESULT err = GetProperty(name, static_cast<AMFVariantStruct*>(&var));
+ if(err == AMF_OK)
+ {
+ *pValue = var.ToWString().c_str();
+ }
+ return err;
+ }
+ //----------------------------------------------------------------------------------------------
+ template<> inline
+ AMF_RESULT AMF_STD_CALL AMFPropertyStorage::GetProperty(const wchar_t* name,
+ AMFInterface** ppValue) const
+ {
+ AMFVariant var;
+ AMF_RESULT err = GetProperty(name, static_cast<AMFVariantStruct*>(&var));
+ if(err == AMF_OK)
+ {
+ *ppValue = static_cast<AMFInterface*>(var);
+ }
+ if(*ppValue)
+ {
+ (*ppValue)->Acquire();
+ }
+ return err;
+ }
+#endif // #if defined(__cplusplus)
+
+#if defined(__cplusplus)
+} //namespace amf
+#endif
+
+#endif // #ifndef __AMFPropertyStorage_h__
diff --git a/compat/amd/amf/public/include/core/PropertyStorageEx.h b/compat/amd/amf/public/include/core/PropertyStorageEx.h
new file mode 100644
index 0000000..e3872d2
--- /dev/null
+++ b/compat/amd/amf/public/include/core/PropertyStorageEx.h
@@ -0,0 +1,197 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFPropertyStorageEx_h__
+#define __AMFPropertyStorageEx_h__
+#pragma once
+
+#include "PropertyStorage.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_PROPERTY_CONTENT_ENUM
+ {
+ AMF_PROPERTY_CONTENT_DEFAULT = 0,
+ AMF_PROPERTY_CONTENT_XML, // m_eType is AMF_VARIANT_STRING
+
+ AMF_PROPERTY_CONTENT_FILE_OPEN_PATH, // m_eType AMF_VARIANT_WSTRING
+ AMF_PROPERTY_CONTENT_FILE_SAVE_PATH // m_eType AMF_VARIANT_WSTRING
+ } AMF_PROPERTY_CONTENT_ENUM;
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_PROPERTY_ACCESS_TYPE
+ {
+ AMF_PROPERTY_ACCESS_PRIVATE = 0,
+ AMF_PROPERTY_ACCESS_READ = 0x1,
+ AMF_PROPERTY_ACCESS_WRITE = 0x2,
+ AMF_PROPERTY_ACCESS_READ_WRITE = (AMF_PROPERTY_ACCESS_READ | AMF_PROPERTY_ACCESS_WRITE),
+ AMF_PROPERTY_ACCESS_WRITE_RUNTIME = 0x4,
+ AMF_PROPERTY_ACCESS_FULL = 0xFF,
+ } AMF_PROPERTY_ACCESS_TYPE;
+ //----------------------------------------------------------------------------------------------
+ typedef struct AMFEnumDescriptionEntry
+ {
+ amf_int value;
+ const wchar_t* name;
+ } AMFEnumDescriptionEntry;
+ //----------------------------------------------------------------------------------------------
+ typedef amf_uint32 AMF_PROPERTY_CONTENT_TYPE;
+
+ typedef struct AMFPropertyInfo
+ {
+ const wchar_t* name;
+ const wchar_t* desc;
+ AMF_VARIANT_TYPE type;
+ AMF_PROPERTY_CONTENT_TYPE contentType;
+
+ AMFVariantStruct defaultValue;
+ AMFVariantStruct minValue;
+ AMFVariantStruct maxValue;
+ AMF_PROPERTY_ACCESS_TYPE accessType;
+ const AMFEnumDescriptionEntry* pEnumDescription;
+
+#if defined(__cplusplus)
+ AMFPropertyInfo() :
+ name(NULL),
+ desc(NULL),
+ type(),
+ contentType(),
+ defaultValue(),
+ minValue(),
+ maxValue(),
+ accessType(AMF_PROPERTY_ACCESS_FULL),
+ pEnumDescription(NULL)
+ {}
+ AMFPropertyInfo(const AMFPropertyInfo& propery) : name(propery.name),
+ desc(propery.desc),
+ type(propery.type),
+ contentType(propery.contentType),
+ defaultValue(propery.defaultValue),
+ minValue(propery.minValue),
+ maxValue(propery.maxValue),
+ accessType(propery.accessType),
+ pEnumDescription(propery.pEnumDescription)
+ {}
+ virtual ~AMFPropertyInfo(){}
+
+ amf_bool AMF_STD_CALL AllowedRead() const
+ {
+ return (accessType & AMF_PROPERTY_ACCESS_READ) != 0;
+ }
+ amf_bool AMF_STD_CALL AllowedWrite() const
+ {
+ return (accessType & AMF_PROPERTY_ACCESS_WRITE) != 0;
+ }
+ amf_bool AMF_STD_CALL AllowedChangeInRuntime() const
+ {
+ return (accessType & AMF_PROPERTY_ACCESS_WRITE_RUNTIME) != 0;
+ }
+
+ AMFPropertyInfo& operator=(const AMFPropertyInfo& propery)
+ {
+ desc = propery.desc;
+ type = propery.type;
+ contentType = propery.contentType;
+ defaultValue = propery.defaultValue;
+ minValue = propery.minValue;
+ maxValue = propery.maxValue;
+ accessType = propery.accessType;
+ pEnumDescription = propery.pEnumDescription;
+
+ return *this;
+ }
+#endif // #if defined(__cplusplus)
+ } AMFPropertyInfo;
+ //----------------------------------------------------------------------------------------------
+ // AMFPropertyStorageEx interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFPropertyStorageEx : public AMFPropertyStorage
+ {
+ public:
+ AMF_DECLARE_IID(0x16b8958d, 0xe943, 0x4a33, 0xa3, 0x5a, 0x88, 0x5a, 0xd8, 0x28, 0xf2, 0x67)
+
+ virtual amf_size AMF_STD_CALL GetPropertiesInfoCount() const = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetPropertyInfo(amf_size index, const AMFPropertyInfo** ppInfo) const = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetPropertyInfo(const wchar_t* name, const AMFPropertyInfo** ppInfo) const = 0;
+ virtual AMF_RESULT AMF_STD_CALL ValidateProperty(const wchar_t* name, AMFVariantStruct value, AMFVariantStruct* pOutValidated) const = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFPropertyStorageEx> AMFPropertyStorageExPtr;
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFPropertyStorageEx, 0x16b8958d, 0xe943, 0x4a33, 0xa3, 0x5a, 0x88, 0x5a, 0xd8, 0x28, 0xf2, 0x67)
+ typedef struct AMFPropertyStorageEx AMFPropertyStorageEx;
+
+ typedef struct AMFPropertyStorageExVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFPropertyStorageEx* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFPropertyStorageEx* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFPropertyStorageEx* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFPropertyStorageEx* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFPropertyStorageEx* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFPropertyStorageEx* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFPropertyStorageEx* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFPropertyStorageEx* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFPropertyStorageEx* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFPropertyStorageEx* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFPropertyStorageEx* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFPropertyStorageEx* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFPropertyStorageEx* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFPropertyStorageEx interface
+
+ amf_size (AMF_STD_CALL *GetPropertiesInfoCount)(AMFPropertyStorageEx* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfoAt)(AMFPropertyStorageEx* pThis, amf_size index, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyInfo)(AMFPropertyStorageEx* pThis, const wchar_t* name, const AMFPropertyInfo** ppInfo);
+ AMF_RESULT (AMF_STD_CALL *ValidateProperty)(AMFPropertyStorageEx* pThis, const wchar_t* name, AMFVariantStruct value, AMFVariantStruct* pOutValidated);
+
+ } AMFPropertyStorageExVtbl;
+
+ struct AMFPropertyStorageEx
+ {
+ const AMFPropertyStorageExVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+} //namespace amf
+#endif
+
+
+#endif //#ifndef __AMFPropertyStorageEx_h__
diff --git a/compat/amd/amf/public/include/core/Result.h b/compat/amd/amf/public/include/core/Result.h
new file mode 100644
index 0000000..3967aa9
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Result.h
@@ -0,0 +1,127 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFResult_h__
+#define __AMFResult_h__
+#pragma once
+
+#include "Platform.h"
+
+//----------------------------------------------------------------------------------------------
+// result codes
+//----------------------------------------------------------------------------------------------
+
+typedef enum AMF_RESULT
+{
+ AMF_OK = 0,
+ AMF_FAIL ,
+
+// common errors
+ AMF_UNEXPECTED ,
+
+ AMF_ACCESS_DENIED ,
+ AMF_INVALID_ARG ,
+ AMF_OUT_OF_RANGE ,
+
+ AMF_OUT_OF_MEMORY ,
+ AMF_INVALID_POINTER ,
+
+ AMF_NO_INTERFACE ,
+ AMF_NOT_IMPLEMENTED ,
+ AMF_NOT_SUPPORTED ,
+ AMF_NOT_FOUND ,
+
+ AMF_ALREADY_INITIALIZED ,
+ AMF_NOT_INITIALIZED ,
+
+ AMF_INVALID_FORMAT ,// invalid data format
+
+ AMF_WRONG_STATE ,
+ AMF_FILE_NOT_OPEN ,// cannot open file
+
+// device common codes
+ AMF_NO_DEVICE ,
+
+// device directx
+ AMF_DIRECTX_FAILED ,
+// device opencl
+ AMF_OPENCL_FAILED ,
+// device opengl
+ AMF_GLX_FAILED ,//failed to use GLX
+// device XV
+ AMF_XV_FAILED , //failed to use Xv extension
+// device alsa
+ AMF_ALSA_FAILED ,//failed to use ALSA
+
+// component common codes
+
+ //result codes
+ AMF_EOF ,
+ AMF_REPEAT ,
+ AMF_INPUT_FULL ,//returned by AMFComponent::SubmitInput if input queue is full
+ AMF_RESOLUTION_CHANGED ,//resolution changed client needs to Drain/Terminate/Init
+ AMF_RESOLUTION_UPDATED ,//resolution changed in adaptive mode. New ROI will be set on output on newly decoded frames
+
+ //error codes
+ AMF_INVALID_DATA_TYPE ,//invalid data type
+ AMF_INVALID_RESOLUTION ,//invalid resolution (width or height)
+ AMF_CODEC_NOT_SUPPORTED ,//codec not supported
+ AMF_SURFACE_FORMAT_NOT_SUPPORTED ,//surface format not supported
+ AMF_SURFACE_MUST_BE_SHARED ,//surface should be shared (DX11: (MiscFlags & D3D11_RESOURCE_MISC_SHARED) == 0, DX9: No shared handle found)
+
+// component video decoder
+ AMF_DECODER_NOT_PRESENT ,//failed to create the decoder
+ AMF_DECODER_SURFACE_ALLOCATION_FAILED ,//failed to create the surface for decoding
+ AMF_DECODER_NO_FREE_SURFACES ,
+
+// component video encoder
+ AMF_ENCODER_NOT_PRESENT ,//failed to create the encoder
+
+// component video processor
+
+// component video conveter
+
+// component dem
+ AMF_DEM_ERROR ,
+ AMF_DEM_PROPERTY_READONLY ,
+ AMF_DEM_REMOTE_DISPLAY_CREATE_FAILED ,
+ AMF_DEM_START_ENCODING_FAILED ,
+ AMF_DEM_QUERY_OUTPUT_FAILED ,
+
+// component TAN
+ AMF_TAN_CLIPPING_WAS_REQUIRED , // Resulting data was truncated to meet output type's value limits.
+ AMF_TAN_UNSUPPORTED_VERSION , // Not supported version requested, solely for TANCreateContext().
+
+ AMF_NEED_MORE_INPUT ,//returned by AMFComponent::SubmitInput did not produce buffer
+} AMF_RESULT;
+
+#endif //#ifndef __AMFResult_h__
diff --git a/compat/amd/amf/public/include/core/Surface.h b/compat/amd/amf/public/include/core/Surface.h
new file mode 100644
index 0000000..e7a6fd5
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Surface.h
@@ -0,0 +1,232 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFSurface_h__
+#define __AMFSurface_h__
+#pragma once
+
+#include "Data.h"
+#include "Plane.h"
+
+#if defined(_MSC_VER)
+ #pragma warning( push )
+ #pragma warning(disable : 4263)
+ #pragma warning(disable : 4264)
+#endif
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ typedef enum AMF_SURFACE_FORMAT
+ {
+ AMF_SURFACE_UNKNOWN = 0,
+ AMF_SURFACE_NV12, ///< 1 - planar Y width x height + packed UV width/2 x height/2 - 8 bit per component
+ AMF_SURFACE_YV12, ///< 2 - planar Y width x height + V width/2 x height/2 + U width/2 x height/2 - 8 bit per component
+ AMF_SURFACE_BGRA, ///< 3 - packed - 8 bit per component
+ AMF_SURFACE_ARGB, ///< 4 - packed - 8 bit per component
+ AMF_SURFACE_RGBA, ///< 5 - packed - 8 bit per component
+ AMF_SURFACE_GRAY8, ///< 6 - single component - 8 bit
+ AMF_SURFACE_YUV420P, ///< 7 - planar Y width x height + U width/2 x height/2 + V width/2 x height/2 - 8 bit per component
+ AMF_SURFACE_U8V8, ///< 8 - double component - 8 bit per component
+ AMF_SURFACE_YUY2, ///< 9 - YUY2: Byte 0=8-bit Y'0; Byte 1=8-bit Cb; Byte 2=8-bit Y'1; Byte 3=8-bit Cr
+ AMF_SURFACE_P010, ///< 10- planar Y width x height + packed UV width/2 x height/2 - 10 bit per component (16 allocated, upper 10 bits are used)
+ AMF_SURFACE_RGBA_F16, ///< 11 - packed - 16 bit per component float
+
+ AMF_SURFACE_FIRST = AMF_SURFACE_NV12,
+ AMF_SURFACE_LAST = AMF_SURFACE_RGBA_F16
+ } AMF_SURFACE_FORMAT;
+
+ //----------------------------------------------------------------------------------------------
+ // frame type
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_FRAME_TYPE
+ {
+ // flags
+ AMF_FRAME_STEREO_FLAG = 0x10000000,
+ AMF_FRAME_LEFT_FLAG = AMF_FRAME_STEREO_FLAG | 0x20000000,
+ AMF_FRAME_RIGHT_FLAG = AMF_FRAME_STEREO_FLAG | 0x40000000,
+ AMF_FRAME_BOTH_FLAG = AMF_FRAME_LEFT_FLAG | AMF_FRAME_RIGHT_FLAG,
+ AMF_FRAME_INTERLEAVED_FLAG = 0x01000000,
+ AMF_FRAME_FIELD_FLAG = 0x02000000,
+ AMF_FRAME_EVEN_FLAG = 0x04000000,
+ AMF_FRAME_ODD_FLAG = 0x08000000,
+
+ // values
+ AMF_FRAME_UNKNOWN =-1,
+ AMF_FRAME_PROGRESSIVE = 0,
+
+ AMF_FRAME_INTERLEAVED_EVEN_FIRST = AMF_FRAME_INTERLEAVED_FLAG | AMF_FRAME_EVEN_FLAG,
+ AMF_FRAME_INTERLEAVED_ODD_FIRST = AMF_FRAME_INTERLEAVED_FLAG | AMF_FRAME_ODD_FLAG,
+ AMF_FRAME_FIELD_SINGLE_EVEN = AMF_FRAME_FIELD_FLAG | AMF_FRAME_EVEN_FLAG,
+ AMF_FRAME_FIELD_SINGLE_ODD = AMF_FRAME_FIELD_FLAG | AMF_FRAME_ODD_FLAG,
+
+ AMF_FRAME_STEREO_LEFT = AMF_FRAME_LEFT_FLAG,
+ AMF_FRAME_STEREO_RIGHT = AMF_FRAME_RIGHT_FLAG,
+ AMF_FRAME_STEREO_BOTH = AMF_FRAME_BOTH_FLAG,
+
+ AMF_FRAME_INTERLEAVED_EVEN_FIRST_STEREO_LEFT = AMF_FRAME_INTERLEAVED_FLAG | AMF_FRAME_EVEN_FLAG | AMF_FRAME_LEFT_FLAG,
+ AMF_FRAME_INTERLEAVED_EVEN_FIRST_STEREO_RIGHT = AMF_FRAME_INTERLEAVED_FLAG | AMF_FRAME_EVEN_FLAG | AMF_FRAME_RIGHT_FLAG,
+ AMF_FRAME_INTERLEAVED_EVEN_FIRST_STEREO_BOTH = AMF_FRAME_INTERLEAVED_FLAG | AMF_FRAME_EVEN_FLAG | AMF_FRAME_BOTH_FLAG,
+
+ AMF_FRAME_INTERLEAVED_ODD_FIRST_STEREO_LEFT = AMF_FRAME_INTERLEAVED_FLAG | AMF_FRAME_ODD_FLAG | AMF_FRAME_LEFT_FLAG,
+ AMF_FRAME_INTERLEAVED_ODD_FIRST_STEREO_RIGHT = AMF_FRAME_INTERLEAVED_FLAG | AMF_FRAME_ODD_FLAG | AMF_FRAME_RIGHT_FLAG,
+ AMF_FRAME_INTERLEAVED_ODD_FIRST_STEREO_BOTH = AMF_FRAME_INTERLEAVED_FLAG | AMF_FRAME_ODD_FLAG | AMF_FRAME_BOTH_FLAG,
+ } AMF_FRAME_TYPE;
+
+ //----------------------------------------------------------------------------------------------
+ // AMFSurfaceObserver interface - callback; is called before internal release resources.
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMFSurface;
+ class AMF_NO_VTABLE AMFSurfaceObserver
+ {
+ public:
+ virtual void AMF_STD_CALL OnSurfaceDataRelease(AMFSurface* pSurface) = 0;
+ };
+#else // #if defined(__cplusplus)
+ typedef struct AMFSurface AMFSurface;
+ typedef struct AMFSurfaceObserver AMFSurfaceObserver;
+
+ typedef struct AMFSurfaceObserverVtbl
+ {
+ void (AMF_STD_CALL *OnSurfaceDataRelease)(AMFSurfaceObserver* pThis, AMFSurface* pSurface);
+ } AMFSurfaceObserverVtbl;
+
+ struct AMFSurfaceObserver
+ {
+ const AMFSurfaceObserverVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+ // AMFSurface interface
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFSurface : public AMFData
+ {
+ public:
+ AMF_DECLARE_IID(0x3075dbe3, 0x8718, 0x4cfa, 0x86, 0xfb, 0x21, 0x14, 0xc0, 0xa5, 0xa4, 0x51)
+
+ virtual AMF_SURFACE_FORMAT AMF_STD_CALL GetFormat() = 0;
+
+ // do not store planes outside. should be used together with Surface
+ virtual amf_size AMF_STD_CALL GetPlanesCount() = 0;
+ virtual AMFPlane* AMF_STD_CALL GetPlaneAt(amf_size index) = 0;
+ virtual AMFPlane* AMF_STD_CALL GetPlane(AMF_PLANE_TYPE type) = 0;
+
+ virtual AMF_FRAME_TYPE AMF_STD_CALL GetFrameType() = 0;
+ virtual void AMF_STD_CALL SetFrameType(AMF_FRAME_TYPE type) = 0;
+
+ virtual AMF_RESULT AMF_STD_CALL SetCrop(amf_int32 x,amf_int32 y, amf_int32 width, amf_int32 height) = 0;
+ virtual AMF_RESULT AMF_STD_CALL CopySurfaceRegion(AMFSurface* pDest, amf_int32 dstX, amf_int32 dstY, amf_int32 srcX, amf_int32 srcY, amf_int32 width, amf_int32 height) = 0;
+
+ // Observer management
+ virtual void AMF_STD_CALL AddObserver(AMFSurfaceObserver* pObserver) = 0;
+ virtual void AMF_STD_CALL RemoveObserver(AMFSurfaceObserver* pObserver) = 0;
+ };
+ //----------------------------------------------------------------------------------------------
+ // smart pointer
+ //----------------------------------------------------------------------------------------------
+ typedef AMFInterfacePtr_T<AMFSurface> AMFSurfacePtr;
+ //----------------------------------------------------------------------------------------------
+#else // #if defined(__cplusplus)
+ AMF_DECLARE_IID(AMFSurface, 0x3075dbe3, 0x8718, 0x4cfa, 0x86, 0xfb, 0x21, 0x14, 0xc0, 0xa5, 0xa4, 0x51)
+ typedef struct AMFSurfaceVtbl
+ {
+ // AMFInterface interface
+ amf_long (AMF_STD_CALL *Acquire)(AMFSurface* pThis);
+ amf_long (AMF_STD_CALL *Release)(AMFSurface* pThis);
+ enum AMF_RESULT (AMF_STD_CALL *QueryInterface)(AMFSurface* pThis, const struct AMFGuid *interfaceID, void** ppInterface);
+
+ // AMFPropertyStorage interface
+ AMF_RESULT (AMF_STD_CALL *SetProperty)(AMFSurface* pThis, const wchar_t* name, AMFVariantStruct value);
+ AMF_RESULT (AMF_STD_CALL *GetProperty)(AMFSurface* pThis, const wchar_t* name, AMFVariantStruct* pValue);
+ amf_bool (AMF_STD_CALL *HasProperty)(AMFSurface* pThis, const wchar_t* name);
+ amf_size (AMF_STD_CALL *GetPropertyCount)(AMFSurface* pThis);
+ AMF_RESULT (AMF_STD_CALL *GetPropertyAt)(AMFSurface* pThis, amf_size index, wchar_t* name, amf_size nameSize, AMFVariantStruct* pValue);
+ AMF_RESULT (AMF_STD_CALL *Clear)(AMFSurface* pThis);
+ AMF_RESULT (AMF_STD_CALL *AddTo)(AMFSurface* pThis, AMFPropertyStorage* pDest, amf_bool overwrite, amf_bool deep);
+ AMF_RESULT (AMF_STD_CALL *CopyTo)(AMFSurface* pThis, AMFPropertyStorage* pDest, amf_bool deep);
+ void (AMF_STD_CALL *AddObserver)(AMFSurface* pThis, AMFPropertyStorageObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver)(AMFSurface* pThis, AMFPropertyStorageObserver* pObserver);
+
+ // AMFData interface
+
+ AMF_MEMORY_TYPE (AMF_STD_CALL *GetMemoryType)(AMFSurface* pThis);
+
+ AMF_RESULT (AMF_STD_CALL *Duplicate)(AMFSurface* pThis, AMF_MEMORY_TYPE type, AMFData** ppData);
+ AMF_RESULT (AMF_STD_CALL *Convert)(AMFSurface* pThis, AMF_MEMORY_TYPE type); // optimal interop if possilble. Copy through host memory if needed
+ AMF_RESULT (AMF_STD_CALL *Interop)(AMFSurface* pThis, AMF_MEMORY_TYPE type); // only optimal interop if possilble. No copy through host memory for GPU objects
+
+ AMF_DATA_TYPE (AMF_STD_CALL *GetDataType)(AMFSurface* pThis);
+
+ amf_bool (AMF_STD_CALL *IsReusable)(AMFSurface* pThis);
+
+ void (AMF_STD_CALL *SetPts)(AMFSurface* pThis, amf_pts pts);
+ amf_pts (AMF_STD_CALL *GetPts)(AMFSurface* pThis);
+ void (AMF_STD_CALL *SetDuration)(AMFSurface* pThis, amf_pts duration);
+ amf_pts (AMF_STD_CALL *GetDuration)(AMFSurface* pThis);
+
+ // AMFSurface interface
+
+ AMF_SURFACE_FORMAT (AMF_STD_CALL *GetFormat)(AMFSurface* pThis);
+
+ // do not store planes outside. should be used together with Surface
+ amf_size (AMF_STD_CALL *GetPlanesCount)(AMFSurface* pThis);
+ AMFPlane* (AMF_STD_CALL *GetPlaneAt)(AMFSurface* pThis, amf_size index);
+ AMFPlane* (AMF_STD_CALL *GetPlane)(AMFSurface* pThis, AMF_PLANE_TYPE type);
+
+ AMF_FRAME_TYPE (AMF_STD_CALL *GetFrameType)(AMFSurface* pThis);
+ void (AMF_STD_CALL *SetFrameType)(AMFSurface* pThis, AMF_FRAME_TYPE type);
+
+ AMF_RESULT (AMF_STD_CALL *SetCrop)(AMFSurface* pThis, amf_int32 x,amf_int32 y, amf_int32 width, amf_int32 height);
+ AMF_RESULT (AMF_STD_CALL *CopySurfaceRegion)(AMFSurface* pThis, AMFSurface* pDest, amf_int32 dstX, amf_int32 dstY, amf_int32 srcX, amf_int32 srcY, amf_int32 width, amf_int32 height);
+
+
+ // Observer management
+ void (AMF_STD_CALL *AddObserver_Surface)(AMFSurface* pThis, AMFSurfaceObserver* pObserver);
+ void (AMF_STD_CALL *RemoveObserver_Surface)(AMFSurface* pThis, AMFSurfaceObserver* pObserver);
+
+ } AMFSurfaceVtbl;
+
+ struct AMFSurface
+ {
+ const AMFSurfaceVtbl *pVtbl;
+ };
+#endif // #if defined(__cplusplus)
+#if defined(__cplusplus)
+}
+#endif
+#if defined(_MSC_VER)
+ #pragma warning( pop )
+#endif
+#endif //#ifndef __AMFSurface_h__
diff --git a/compat/amd/amf/public/include/core/Trace.h b/compat/amd/amf/public/include/core/Trace.h
new file mode 100644
index 0000000..00d081a
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Trace.h
@@ -0,0 +1,183 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFTrace_h__
+#define __AMFTrace_h__
+#pragma once
+
+#include "Platform.h"
+#include "Result.h"
+#include "Surface.h"
+#include "AudioBuffer.h"
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ // trace levels
+ //----------------------------------------------------------------------------------------------
+ #define AMF_TRACE_ERROR 0
+ #define AMF_TRACE_WARNING 1
+ #define AMF_TRACE_INFO 2 // default in sdk
+ #define AMF_TRACE_DEBUG 3
+ #define AMF_TRACE_TRACE 4
+
+ #define AMF_TRACE_TEST 5
+ #define AMF_TRACE_NOLOG 100
+
+ //----------------------------------------------------------------------------------------------
+ // available trace writers
+ //----------------------------------------------------------------------------------------------
+ #define AMF_TRACE_WRITER_CONSOLE L"Console"
+ #define AMF_TRACE_WRITER_DEBUG_OUTPUT L"DebugOutput"
+ #define AMF_TRACE_WRITER_FILE L"File"
+
+ //----------------------------------------------------------------------------------------------
+ // AMFTraceWriter interface - callback
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFTraceWriter
+ {
+ public:
+ virtual void AMF_CDECL_CALL Write(const wchar_t* scope, const wchar_t* message) = 0;
+ virtual void AMF_CDECL_CALL Flush() = 0;
+ };
+#else // #if defined(__cplusplus)
+ typedef struct AMFTraceWriter AMFTraceWriter;
+
+ typedef struct AMFTraceWriterVtbl
+ {
+ // AMFTraceWriter interface
+ void (AMF_CDECL_CALL *Write)(AMFTraceWriter* pThis, const wchar_t* scope, const wchar_t* message);
+ void (AMF_CDECL_CALL *Flush)(AMFTraceWriter* pThis);
+ } AMFTraceWriterVtbl;
+
+ struct AMFTraceWriter
+ {
+ const AMFTraceWriterVtbl *pVtbl;
+ };
+
+#endif // #if defined(__cplusplus)
+
+ //----------------------------------------------------------------------------------------------
+ // AMFTrace interface - singleton
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ class AMF_NO_VTABLE AMFTrace
+ {
+ public:
+ virtual void AMF_STD_CALL TraceW(const wchar_t* src_path, amf_int32 line, amf_int32 level, const wchar_t* scope,amf_int32 countArgs, const wchar_t* format, ...) = 0;
+ virtual void AMF_STD_CALL Trace(const wchar_t* src_path, amf_int32 line, amf_int32 level, const wchar_t* scope, const wchar_t* message, va_list* pArglist) = 0;
+
+ virtual amf_int32 AMF_STD_CALL SetGlobalLevel(amf_int32 level) = 0;
+ virtual amf_int32 AMF_STD_CALL GetGlobalLevel() = 0;
+
+ virtual amf_bool AMF_STD_CALL EnableWriter(const wchar_t* writerID, bool enable) = 0;
+ virtual amf_bool AMF_STD_CALL WriterEnabled(const wchar_t* writerID) = 0;
+ virtual AMF_RESULT AMF_STD_CALL TraceEnableAsync(amf_bool enable) = 0;
+ virtual AMF_RESULT AMF_STD_CALL TraceFlush() = 0;
+ virtual AMF_RESULT AMF_STD_CALL SetPath(const wchar_t* path) = 0;
+ virtual AMF_RESULT AMF_STD_CALL GetPath(wchar_t* path, amf_size* pSize) = 0;
+ virtual amf_int32 AMF_STD_CALL SetWriterLevel(const wchar_t* writerID, amf_int32 level) = 0;
+ virtual amf_int32 AMF_STD_CALL GetWriterLevel(const wchar_t* writerID) = 0;
+ virtual amf_int32 AMF_STD_CALL SetWriterLevelForScope(const wchar_t* writerID, const wchar_t* scope, amf_int32 level) = 0;
+ virtual amf_int32 AMF_STD_CALL GetWriterLevelForScope(const wchar_t* writerID, const wchar_t* scope) = 0;
+
+ virtual amf_int32 AMF_STD_CALL GetIndentation() = 0;
+ virtual void AMF_STD_CALL Indent(amf_int32 addIndent) = 0;
+
+ virtual void AMF_STD_CALL RegisterWriter(const wchar_t* writerID, AMFTraceWriter* pWriter, amf_bool enable) = 0;
+ virtual void AMF_STD_CALL UnregisterWriter(const wchar_t* writerID) = 0;
+
+ virtual const wchar_t* AMF_STD_CALL GetResultText(AMF_RESULT res) = 0;
+ virtual const wchar_t* AMF_STD_CALL SurfaceGetFormatName(const AMF_SURFACE_FORMAT eSurfaceFormat) = 0;
+ virtual AMF_SURFACE_FORMAT AMF_STD_CALL SurfaceGetFormatByName(const wchar_t* name) = 0;
+
+ virtual const wchar_t* const AMF_STD_CALL GetMemoryTypeName(const AMF_MEMORY_TYPE memoryType) = 0;
+ virtual AMF_MEMORY_TYPE AMF_STD_CALL GetMemoryTypeByName(const wchar_t* name) = 0;
+
+ virtual const wchar_t* const AMF_STD_CALL GetSampleFormatName(const AMF_AUDIO_FORMAT eFormat) = 0;
+ virtual AMF_AUDIO_FORMAT AMF_STD_CALL GetSampleFormatByName(const wchar_t* name) = 0;
+ };
+#else // #if defined(__cplusplus)
+ typedef struct AMFTrace AMFTrace;
+
+ typedef struct AMFTraceVtbl
+ {
+ // AMFTrace interface
+ void (AMF_STD_CALL *TraceW)(AMFTrace* pThis, const wchar_t* src_path, amf_int32 line, amf_int32 level, const wchar_t* scope,amf_int32 countArgs, const wchar_t* format, ...);
+ void (AMF_STD_CALL *Trace)(AMFTrace* pThis, const wchar_t* src_path, amf_int32 line, amf_int32 level, const wchar_t* scope, const wchar_t* message, va_list* pArglist);
+
+ amf_int32 (AMF_STD_CALL *SetGlobalLevel)(AMFTrace* pThis, amf_int32 level);
+ amf_int32 (AMF_STD_CALL *GetGlobalLevel)(AMFTrace* pThis);
+
+ amf_bool (AMF_STD_CALL *EnableWriter)(AMFTrace* pThis, const wchar_t* writerID, amf_bool enable);
+ amf_bool (AMF_STD_CALL *WriterEnabled)(AMFTrace* pThis, const wchar_t* writerID);
+ AMF_RESULT (AMF_STD_CALL *TraceEnableAsync)(AMFTrace* pThis, amf_bool enable);
+ AMF_RESULT (AMF_STD_CALL *TraceFlush)(AMFTrace* pThis);
+ AMF_RESULT (AMF_STD_CALL *SetPath)(AMFTrace* pThis, const wchar_t* path);
+ AMF_RESULT (AMF_STD_CALL *GetPath)(AMFTrace* pThis, wchar_t* path, amf_size* pSize);
+ amf_int32 (AMF_STD_CALL *SetWriterLevel)(AMFTrace* pThis, const wchar_t* writerID, amf_int32 level);
+ amf_int32 (AMF_STD_CALL *GetWriterLevel)(AMFTrace* pThis, const wchar_t* writerID);
+ amf_int32 (AMF_STD_CALL *SetWriterLevelForScope)(AMFTrace* pThis, const wchar_t* writerID, const wchar_t* scope, amf_int32 level);
+ amf_int32 (AMF_STD_CALL *GetWriterLevelForScope)(AMFTrace* pThis, const wchar_t* writerID, const wchar_t* scope);
+
+ amf_int32 (AMF_STD_CALL *GetIndentation)(AMFTrace* pThis);
+ void (AMF_STD_CALL *Indent)(AMFTrace* pThis, amf_int32 addIndent);
+
+ void (AMF_STD_CALL *RegisterWriter)(AMFTrace* pThis, const wchar_t* writerID, AMFTraceWriter* pWriter, amf_bool enable);
+ void (AMF_STD_CALL *UnregisterWriter)(AMFTrace* pThis, const wchar_t* writerID);
+
+ const wchar_t* (AMF_STD_CALL *GetResultText)(AMFTrace* pThis, AMF_RESULT res);
+ const wchar_t* (AMF_STD_CALL *SurfaceGetFormatName)(AMFTrace* pThis, const AMF_SURFACE_FORMAT eSurfaceFormat);
+ AMF_SURFACE_FORMAT (AMF_STD_CALL *SurfaceGetFormatByName)(AMFTrace* pThis, const wchar_t* name);
+
+ const wchar_t* const (AMF_STD_CALL *GetMemoryTypeName)(AMFTrace* pThis, const AMF_MEMORY_TYPE memoryType);
+ AMF_MEMORY_TYPE (AMF_STD_CALL *GetMemoryTypeByName)(AMFTrace* pThis, const wchar_t* name);
+
+ const wchar_t* const (AMF_STD_CALL *GetSampleFormatName)(AMFTrace* pThis, const AMF_AUDIO_FORMAT eFormat);
+ AMF_AUDIO_FORMAT (AMF_STD_CALL *GetSampleFormatByName)(AMFTrace* pThis, const wchar_t* name);
+ } AMFTraceVtbl;
+
+ struct AMFTrace
+ {
+ const AMFTraceVtbl *pVtbl;
+ };
+
+#endif
+#if defined(__cplusplus)
+}
+#endif
+
+
+#endif // __AMFTrace_h__
diff --git a/compat/amd/amf/public/include/core/Variant.h b/compat/amd/amf/public/include/core/Variant.h
new file mode 100644
index 0000000..2a9e515
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Variant.h
@@ -0,0 +1,1707 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#ifndef __AMFVariant_h__
+#define __AMFVariant_h__
+#pragma once
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4996)
+#endif
+
+#include "Interface.h"
+#include <locale.h>
+#include <wchar.h>
+#include <string.h>
+
+#if defined(__cplusplus)
+namespace amf
+{
+#endif
+ //----------------------------------------------------------------------------------------------
+ // variant types
+ //----------------------------------------------------------------------------------------------
+ typedef enum AMF_VARIANT_TYPE
+ {
+ AMF_VARIANT_EMPTY = 0,
+
+ AMF_VARIANT_BOOL = 1,
+ AMF_VARIANT_INT64 = 2,
+ AMF_VARIANT_DOUBLE = 3,
+
+ AMF_VARIANT_RECT = 4,
+ AMF_VARIANT_SIZE = 5,
+ AMF_VARIANT_POINT = 6,
+ AMF_VARIANT_RATE = 7,
+ AMF_VARIANT_RATIO = 8,
+ AMF_VARIANT_COLOR = 9,
+
+ AMF_VARIANT_STRING = 10, // value is char*
+ AMF_VARIANT_WSTRING = 11, // value is wchar_t*
+ AMF_VARIANT_INTERFACE = 12, // value is AMFInterface*
+ } AMF_VARIANT_TYPE;
+ //----------------------------------------------------------------------------------------------
+ // variant struct
+ //----------------------------------------------------------------------------------------------
+ typedef struct AMFVariantStruct
+ {
+ AMF_VARIANT_TYPE type;
+ union
+ {
+ amf_bool boolValue;
+ amf_int64 int64Value;
+ amf_double doubleValue;
+ char* stringValue;
+ wchar_t* wstringValue;
+ AMFInterface* pInterface;
+ struct AMFRect rectValue;
+ struct AMFSize sizeValue;
+ struct AMFPoint pointValue;
+ struct AMFRate rateValue;
+ struct AMFRatio ratioValue;
+ struct AMFColor colorValue;
+ };
+ } AMFVariantStruct;
+ //----------------------------------------------------------------------------------------------
+ // variant accessors
+ //----------------------------------------------------------------------------------------------
+
+ AMF_INLINE AMF_VARIANT_TYPE AMF_STD_CALL AMFVariantGetType(const AMFVariantStruct* _variant) { return (_variant)->type; }
+#if defined(__cplusplus)
+ AMF_INLINE AMF_VARIANT_TYPE& AMF_STD_CALL AMFVariantGetType(AMFVariantStruct* _variant) { return (_variant)->type; }
+#endif
+ AMF_INLINE amf_bool AMF_STD_CALL AMFVariantGetBool(const AMFVariantStruct* _variant) { return (_variant)->boolValue; }
+ AMF_INLINE amf_int64 AMF_STD_CALL AMFVariantGetInt64(const AMFVariantStruct* _variant) { return (_variant)->int64Value; }
+ AMF_INLINE amf_double AMF_STD_CALL AMFVariantGetDouble(const AMFVariantStruct* _variant) { return (_variant)->doubleValue; }
+ AMF_INLINE const char* AMF_STD_CALL AMFVariantGetString(const AMFVariantStruct* _variant) { return (_variant)->stringValue; }
+ AMF_INLINE const wchar_t* AMF_STD_CALL AMFVariantGetWString(const AMFVariantStruct* _variant) { return (_variant)->wstringValue; }
+#if defined(__cplusplus)
+ AMF_INLINE const AMFInterface* AMF_STD_CALL AMFVariantGetInterface(const AMFVariantStruct* _variant) { return (_variant)->pInterface; }
+#endif
+ AMF_INLINE AMFInterface* AMF_STD_CALL AMFVariantGetInterface(AMFVariantStruct* _variant) { return (_variant)->pInterface; }
+
+#if defined(__cplusplus)
+ AMF_INLINE const AMFRect & AMF_STD_CALL AMFVariantGetRect (const AMFVariantStruct* _variant) { return (_variant)->rectValue; }
+ AMF_INLINE const AMFSize & AMF_STD_CALL AMFVariantGetSize (const AMFVariantStruct* _variant) { return (_variant)->sizeValue; }
+ AMF_INLINE const AMFPoint& AMF_STD_CALL AMFVariantGetPoint(const AMFVariantStruct* _variant) { return (_variant)->pointValue; }
+ AMF_INLINE const AMFRate & AMF_STD_CALL AMFVariantGetRate (const AMFVariantStruct* _variant) { return (_variant)->rateValue; }
+ AMF_INLINE const AMFRatio& AMF_STD_CALL AMFVariantGetRatio(const AMFVariantStruct* _variant) { return (_variant)->ratioValue; }
+ AMF_INLINE const AMFColor& AMF_STD_CALL AMFVariantGetColor(const AMFVariantStruct* _variant) { return (_variant)->colorValue; }
+#else // #if defined(__cplusplus)
+ AMF_INLINE const AMFRect AMF_STD_CALL AMFVariantGetRect (const AMFVariantStruct* _variant) { return (_variant)->rectValue; }
+ AMF_INLINE const AMFSize AMF_STD_CALL AMFVariantGetSize (const AMFVariantStruct* _variant) { return (_variant)->sizeValue; }
+ AMF_INLINE const AMFPoint AMF_STD_CALL AMFVariantGetPoint(const AMFVariantStruct* _variant) { return (_variant)->pointValue; }
+ AMF_INLINE const AMFRate AMF_STD_CALL AMFVariantGetRate (const AMFVariantStruct* _variant) { return (_variant)->rateValue; }
+ AMF_INLINE const AMFRatio AMF_STD_CALL AMFVariantGetRatio(const AMFVariantStruct* _variant) { return (_variant)->ratioValue; }
+ AMF_INLINE const AMFColor AMF_STD_CALL AMFVariantGetColor(const AMFVariantStruct* _variant) { return (_variant)->colorValue; }
+#endif // #if defined(__cplusplus)
+
+
+ #define AMFVariantEmpty(_variant) 0
+ #define AMFVariantBool(_variant) (_variant)->boolValue
+ #define AMFVariantInt64(_variant) (_variant)->int64Value
+ #define AMFVariantDouble(_variant) (_variant)->doubleValue
+
+ #define AMFVariantRect(_variant) (_variant)->rectValue
+ #define AMFVariantSize(_variant) (_variant)->sizeValue
+ #define AMFVariantPoint(_variant) (_variant)->pointValue
+ #define AMFVariantRate(_variant) (_variant)->rateValue
+ #define AMFVariantRatio(_variant) (_variant)->ratioValue
+ #define AMFVariantColor(_variant) (_variant)->colorValue
+
+ #define AMFVariantString(_variant) (_variant)->stringValue
+ #define AMFVariantWString(_variant) (_variant)->wstringValue
+ #define AMFVariantInterface(_variant) (_variant)->pInterface
+ //----------------------------------------------------------------------------------------------
+ // variant hleper functions
+ //----------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantInit(AMFVariantStruct* pVariant);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantClear(AMFVariantStruct* pVariant);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantCompare(const AMFVariantStruct* pFirst, const AMFVariantStruct* pSecond, amf_bool* equal);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantCopy(AMFVariantStruct* pDest, const AMFVariantStruct* pSrc);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignBool(AMFVariantStruct* pDest, amf_bool value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignInt64(AMFVariantStruct* pDest, amf_int64 value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignDouble(AMFVariantStruct* pDest, amf_double value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignString(AMFVariantStruct* pDest, const char* value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignWString(AMFVariantStruct* pDest, const wchar_t* value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignInterface(AMFVariantStruct* pDest, AMFInterface* value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRect(AMFVariantStruct* pDest, const AMFRect* value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignSize(AMFVariantStruct* pDest, const AMFSize* value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignPoint(AMFVariantStruct* pDest, const AMFPoint* value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRate(AMFVariantStruct* pDest, const AMFRate* value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRatio(AMFVariantStruct* pDest, const AMFRatio* value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignColor(AMFVariantStruct* pDest, const AMFColor* value);
+
+#if defined(__cplusplus)
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRect(AMFVariantStruct* pDest, const AMFRect& value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignSize(AMFVariantStruct* pDest, const AMFSize& value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignPoint(AMFVariantStruct* pDest, const AMFPoint& value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRate(AMFVariantStruct* pDest, const AMFRate& value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRatio(AMFVariantStruct* pDest, const AMFRatio& value);
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignColor(AMFVariantStruct* pDest, const AMFColor& value);
+
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantChangeType(AMFVariantStruct* pDest, const AMFVariantStruct* pSrc, AMF_VARIANT_TYPE newType);
+#endif
+ static AMF_INLINE char* AMF_CDECL_CALL AMFVariantDuplicateString(const char* from);
+ static AMF_INLINE void AMF_CDECL_CALL AMFVariantFreeString(char* from);
+ static AMF_INLINE wchar_t* AMF_CDECL_CALL AMFVariantDuplicateWString(const wchar_t* from);
+ static AMF_INLINE void AMF_CDECL_CALL AMFVariantFreeWString(wchar_t* from);
+
+#if defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+ // AMF_INLINE Variant helper class
+ //----------------------------------------------------------------------------------------------
+ class AMFVariant : public AMFVariantStruct
+ {
+ public:
+ class String;
+ class WString;
+
+ public:
+ AMFVariant() { AMFVariantInit(this); }
+ explicit AMFVariant(const AMFVariantStruct& other) { AMFVariantInit(this); AMFVariantCopy(this, const_cast<AMFVariantStruct*>(&other)); }
+
+ explicit AMFVariant(const AMFVariantStruct* pOther);
+ template<typename T>
+ explicit AMFVariant(const AMFInterfacePtr_T<T>& pValue);
+
+ AMFVariant(const AMFVariant& other) { AMFVariantInit(this); AMFVariantCopy(this, const_cast<AMFVariantStruct*>(static_cast<const AMFVariantStruct*>(&other))); }
+
+ explicit AMF_INLINE AMFVariant(amf_bool value) { AMFVariantInit(this); AMFVariantAssignBool(this, value); }
+ explicit AMF_INLINE AMFVariant(amf_int64 value) { AMFVariantInit(this); AMFVariantAssignInt64(this, value); }
+ explicit AMF_INLINE AMFVariant(amf_uint64 value) { AMFVariantInit(this); AMFVariantAssignInt64(this, (amf_int64)value); }
+ explicit AMF_INLINE AMFVariant(amf_int32 value) { AMFVariantInit(this); AMFVariantAssignInt64(this, value); }
+ explicit AMF_INLINE AMFVariant(amf_uint32 value) { AMFVariantInit(this); AMFVariantAssignInt64(this, value); }
+ explicit AMF_INLINE AMFVariant(amf_double value) { AMFVariantInit(this); AMFVariantAssignDouble(this, value); }
+ explicit AMF_INLINE AMFVariant(const AMFRect & value) { AMFVariantInit(this); AMFVariantAssignRect(this, &value); }
+ explicit AMF_INLINE AMFVariant(const AMFSize & value) { AMFVariantInit(this); AMFVariantAssignSize(this, &value); }
+ explicit AMF_INLINE AMFVariant(const AMFPoint& value) { AMFVariantInit(this); AMFVariantAssignPoint(this, &value); }
+ explicit AMF_INLINE AMFVariant(const AMFRate & value) { AMFVariantInit(this); AMFVariantAssignRate(this, &value); }
+ explicit AMF_INLINE AMFVariant(const AMFRatio& value) { AMFVariantInit(this); AMFVariantAssignRatio(this, &value); }
+ explicit AMF_INLINE AMFVariant(const AMFColor& value) { AMFVariantInit(this); AMFVariantAssignColor(this, &value); }
+ explicit AMF_INLINE AMFVariant(const char* value) { AMFVariantInit(this); AMFVariantAssignString(this, value); }
+ explicit AMF_INLINE AMFVariant(const wchar_t* value) { AMFVariantInit(this); AMFVariantAssignWString(this, value); }
+ explicit AMF_INLINE AMFVariant(AMFInterface* pValue) { AMFVariantInit(this); AMFVariantAssignInterface(this, pValue); }
+
+ ~AMFVariant() { AMFVariantClear(this); }
+
+ AMFVariant& operator=(const AMFVariantStruct& other);
+ AMFVariant& operator=(const AMFVariantStruct* pOther);
+ AMFVariant& operator=(const AMFVariant& other);
+
+ AMFVariant& operator=(amf_bool value) { AMFVariantAssignBool(this, value); return *this;}
+ AMFVariant& operator=(amf_int64 value) { AMFVariantAssignInt64(this, value); return *this;}
+ AMFVariant& operator=(amf_uint64 value) { AMFVariantAssignInt64(this, (amf_int64)value); return *this;}
+ AMFVariant& operator=(amf_int32 value) { AMFVariantAssignInt64(this, value); return *this;}
+ AMFVariant& operator=(amf_uint32 value) { AMFVariantAssignInt64(this, value); return *this;}
+ AMFVariant& operator=(amf_double value) { AMFVariantAssignDouble(this, value); return *this;}
+ AMFVariant& operator=(const AMFRect & value) { AMFVariantAssignRect(this, &value); return *this;}
+ AMFVariant& operator=(const AMFSize & value) { AMFVariantAssignSize(this, &value); return *this;}
+ AMFVariant& operator=(const AMFPoint& value) { AMFVariantAssignPoint(this, &value); return *this;}
+ AMFVariant& operator=(const AMFRate & value) { AMFVariantAssignRate(this, &value); return *this;}
+ AMFVariant& operator=(const AMFRatio& value) { AMFVariantAssignRatio(this, &value); return *this;}
+ AMFVariant& operator=(const AMFColor& value) { AMFVariantAssignColor(this, &value); return *this;}
+ AMFVariant& operator=(const char* value) { AMFVariantAssignString(this, value); return *this;}
+ AMFVariant& operator=(const wchar_t* value) { AMFVariantAssignWString(this, value); return *this;}
+ AMFVariant& operator=(AMFInterface* value) { AMFVariantAssignInterface(this, value); return *this;}
+
+ template<typename T> AMFVariant& operator=(const AMFInterfacePtr_T<T>& value);
+
+ operator amf_bool() const { return ToBool(); }
+ operator amf_int64() const { return ToInt64(); }
+ operator amf_uint64() const { return ToUInt64(); }
+ operator amf_int32() const { return ToInt32(); }
+ operator amf_uint32() const { return ToUInt32(); }
+ operator amf_double() const { return ToDouble(); }
+ operator amf_float() const { return ToFloat(); }
+ operator AMFRect () const { return ToRect (); }
+ operator AMFSize () const { return ToSize (); }
+ operator AMFPoint() const { return ToPoint(); }
+ operator AMFRate () const { return ToRate (); }
+ operator AMFRatio() const { return ToRatio(); }
+ operator AMFColor() const { return ToColor(); }
+ operator AMFInterface*() const { return ToInterface(); }
+
+ AMF_INLINE amf_bool ToBool() const { return Empty() ? false : GetValue<amf_bool, AMF_VARIANT_BOOL>(AMFVariantGetBool); }
+ AMF_INLINE amf_int64 ToInt64() const { return Empty() ? 0 : GetValue<amf_int64, AMF_VARIANT_INT64>(AMFVariantGetInt64); }
+ AMF_INLINE amf_uint64 ToUInt64() const { return Empty() ? 0 : GetValue<amf_uint64, AMF_VARIANT_INT64>(AMFVariantGetInt64); }
+ AMF_INLINE amf_int32 ToInt32() const { return Empty() ? 0 : GetValue<amf_int32, AMF_VARIANT_INT64>(AMFVariantGetInt64); }
+ AMF_INLINE amf_uint32 ToUInt32() const { return Empty() ? 0 : GetValue<amf_uint32, AMF_VARIANT_INT64>(AMFVariantGetInt64); }
+ AMF_INLINE amf_double ToDouble() const { return Empty() ? 0 : GetValue<amf_double, AMF_VARIANT_DOUBLE>(AMFVariantGetDouble); }
+ AMF_INLINE amf_float ToFloat() const { return Empty() ? 0 : GetValue<amf_float, AMF_VARIANT_DOUBLE>(AMFVariantGetDouble); }
+ AMF_INLINE AMFRect ToRect () const { return Empty() ? AMFRect() : GetValue<AMFRect, AMF_VARIANT_RECT>(AMFVariantGetRect); }
+ AMF_INLINE AMFSize ToSize () const { return Empty() ? AMFSize() : GetValue<AMFSize, AMF_VARIANT_SIZE>(AMFVariantGetSize); }
+ AMF_INLINE AMFPoint ToPoint() const { return Empty() ? AMFPoint() : GetValue<AMFPoint, AMF_VARIANT_POINT>(AMFVariantGetPoint); }
+ AMF_INLINE AMFRate ToRate () const { return Empty() ? AMFRate() : GetValue<AMFRate, AMF_VARIANT_RATE>(AMFVariantGetRate); }
+ AMF_INLINE AMFRatio ToRatio() const { return Empty() ? AMFRatio() : GetValue<AMFRatio, AMF_VARIANT_RATIO>(AMFVariantGetRatio); }
+ AMF_INLINE AMFColor ToColor() const { return Empty() ? AMFColor() : GetValue<AMFColor, AMF_VARIANT_COLOR>(AMFVariantGetColor); }
+ AMF_INLINE AMFInterface* ToInterface() const { return AMFVariantGetType(this) == AMF_VARIANT_INTERFACE ? this->pInterface : NULL; }
+ AMF_INLINE String ToString() const;
+ AMF_INLINE WString ToWString() const;
+
+ bool operator==(const AMFVariantStruct& other) const;
+ bool operator==(const AMFVariantStruct* pOther) const;
+
+ bool operator!=(const AMFVariantStruct& other) const;
+ bool operator!=(const AMFVariantStruct* pOther) const;
+
+ void Clear() { AMFVariantClear(this); }
+
+ void Attach(AMFVariantStruct& variant);
+ AMFVariantStruct Detach();
+
+ AMFVariantStruct& GetVariant();
+
+ void ChangeType(AMF_VARIANT_TYPE type, const AMFVariant* pSrc = NULL);
+
+ bool Empty() const;
+ private:
+ template<class ReturnType, AMF_VARIANT_TYPE variantType, typename Getter>
+ ReturnType GetValue(Getter getter) const;
+ };
+ //----------------------------------------------------------------------------------------------
+ // helper String class
+ //----------------------------------------------------------------------------------------------
+ class AMFVariant::String
+ {
+ friend class AMFVariant;
+ private:
+ void Free()
+ {
+ if (m_Str != NULL)
+ {
+ AMFVariantFreeString(m_Str);
+ m_Str = NULL;
+ }
+ }
+ public:
+ String() :m_Str(NULL){}
+ String(const char* str) : m_Str(NULL)
+ {
+ m_Str = AMFVariantDuplicateString(str);
+ }
+ String(const String& p_other) : m_Str(NULL)
+ {
+ operator=(p_other);
+ }
+
+#if (__cplusplus == 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X) || (_MSC_VER >= 1600)
+ String(String&& p_other) : m_Str(NULL)
+ {
+ operator=(p_other);
+ }
+#endif
+ ~String()
+ {
+ Free();
+ }
+
+ char& operator[](size_t index)
+ {
+ if (index >= size())
+ {
+ resize(index);
+ }
+ return m_Str[index];
+ }
+
+ String& operator=(const String& p_other)
+ {
+ Free();
+ m_Str = AMFVariantDuplicateString(p_other.m_Str);
+ return *this;
+ }
+#if (__cplusplus == 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X) || (_MSC_VER >= 1600)
+ String& operator=(String&& p_other)
+ {
+ Free();
+ m_Str = p_other.m_Str;
+ p_other.m_Str = NULL; // Transfer the ownership
+ return *this;
+ }
+#endif
+ bool operator==(const String& p_other) const
+ {
+ if (m_Str == NULL && p_other.m_Str == NULL)
+ {
+ return true;
+ }
+ else if ((m_Str == NULL && p_other.m_Str != NULL) || (m_Str != NULL && p_other.m_Str == NULL))
+ {
+ return false;
+ }
+ return strcmp(c_str(), p_other.c_str()) == 0;
+ }
+ const char* c_str() const { return m_Str; }
+ size_t size() const
+ {
+ if(m_Str == NULL)
+ {
+ return 0;
+ }
+ return (size_t)strlen(m_Str);
+ }
+
+ AMF_INLINE size_t length() const { return size(); }
+
+ void resize(size_t sizeAlloc)
+ {
+ if(sizeAlloc == 0)
+ {
+ Free();
+ return;
+ }
+ char* str = (char*)amf_variant_alloc(sizeof(char)*(sizeAlloc + 1));
+ if(m_Str != NULL)
+ {
+ size_t copySize = sizeAlloc;
+ if(copySize > size())
+ {
+ copySize = size();
+ }
+ memcpy(str, m_Str, copySize * sizeof(char));
+ Free();
+ str[sizeAlloc] = 0;
+ }
+ m_Str = str;
+ }
+ private:
+ char* m_Str;
+ };
+ //----------------------------------------------------------------------------------------------
+ // helper WString class
+ //----------------------------------------------------------------------------------------------
+ class AMFVariant::WString
+ {
+ friend class AMFVariant;
+ private:
+ void Free()
+ {
+ if (m_Str != NULL)
+ {
+ AMFVariantFreeWString(m_Str);
+ m_Str = NULL;
+ }
+ }
+ public:
+ WString() :m_Str(NULL){}
+ WString(const wchar_t* str) : m_Str(NULL)
+ {
+ m_Str = AMFVariantDuplicateWString(str);
+ }
+ WString(const WString& p_other) : m_Str(NULL)
+ {
+ operator=(p_other);
+ }
+#if (__cplusplus == 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X) || (_MSC_VER >= 1600)
+ WString(WString&& p_other) : m_Str(NULL)
+ {
+ operator=(p_other);
+ }
+#endif
+ ~WString()
+ {
+ Free();
+ }
+
+ WString& operator=(const WString& p_other)
+ {
+ Free();
+ m_Str = AMFVariantDuplicateWString(p_other.m_Str);
+ return *this;
+ }
+#if (__cplusplus == 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X) || (_MSC_VER >= 1600)
+ WString& operator=(WString&& p_other)
+ {
+ Free();
+ m_Str = p_other.m_Str;
+ p_other.m_Str = NULL; // Transfer the ownership
+ return *this;
+ }
+#endif
+ wchar_t& operator[](size_t index)
+ {
+ if (index >= size())
+ {
+ resize(index);
+ }
+ return m_Str[index];
+ }
+
+ bool operator==(const WString& p_other) const
+ {
+ if (m_Str == NULL && p_other.m_Str == NULL)
+ {
+ return true;
+ }
+ else if ((m_Str == NULL && p_other.m_Str != NULL) || (m_Str != NULL && p_other.m_Str == NULL))
+ {
+ return false;
+ }
+ return wcscmp(c_str(), p_other.c_str()) == 0;
+ }
+
+ const wchar_t* c_str() const { return m_Str; }
+ size_t size() const
+ {
+ if(m_Str == NULL)
+ {
+ return 0;
+ }
+ return (size_t)wcslen(m_Str);
+ }
+
+ AMF_INLINE size_t length() const { return size(); }
+
+ void resize(size_t sizeAlloc)
+ {
+ if(sizeAlloc == 0)
+ {
+ Free();
+ return;
+ }
+ wchar_t* str = (wchar_t*)amf_variant_alloc(sizeof(wchar_t)*(sizeAlloc + 1));
+ if(m_Str != NULL)
+ {
+ size_t copySize = sizeAlloc;
+ if(copySize > size())
+ {
+ copySize = size();
+ }
+ memcpy(str, m_Str, copySize * sizeof(wchar_t));
+ Free();
+ str[sizeAlloc] = 0;
+ }
+ m_Str = str;
+ }
+ private:
+ wchar_t* m_Str;
+ };
+ //-------------------------------------------------------------------------------------------------
+ AMFVariant::String AMFVariant::ToString() const
+ {
+ String temp = GetValue<String, AMF_VARIANT_STRING>(AMFVariantGetString);
+ return String(temp.c_str());
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMFVariant::WString AMFVariant::ToWString() const
+ {
+ WString temp = GetValue<WString, AMF_VARIANT_WSTRING>(AMFVariantGetWString);
+ return WString(temp.c_str());
+ }
+#endif // defined(__cplusplus)
+ //----------------------------------------------------------------------------------------------
+ // AMF_INLINE implementation of helper functions
+ //----------------------------------------------------------------------------------------------
+ #define AMF_VARIANT_RETURN_IF_INVALID_POINTER(p) \
+ { \
+ if(p == NULL) \
+ { \
+ return AMF_INVALID_POINTER; \
+ } \
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantInit(AMFVariantStruct* pVariant)
+ {
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pVariant);
+ pVariant->type = AMF_VARIANT_EMPTY;
+ return AMF_OK;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantClear(AMFVariantStruct* pVariant)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pVariant);
+
+ switch(AMFVariantGetType(pVariant))
+ {
+ case AMF_VARIANT_STRING:
+ amf_variant_free(AMFVariantString(pVariant));
+ pVariant->type = AMF_VARIANT_EMPTY;
+ break;
+
+ case AMF_VARIANT_WSTRING:
+ amf_variant_free(AMFVariantWString(pVariant));
+ pVariant->type = AMF_VARIANT_EMPTY;
+ break;
+
+ case AMF_VARIANT_INTERFACE:
+ if(AMFVariantInterface(pVariant) != NULL)
+ {
+#if defined(__cplusplus)
+ AMFVariantInterface(pVariant)->Release();
+#else
+ AMFVariantInterface(pVariant)->pVtbl->Release(AMFVariantInterface(pVariant));
+#endif
+ AMFVariantInterface(pVariant) = NULL;
+ }
+ pVariant->type = AMF_VARIANT_EMPTY;
+ break;
+
+ default:
+ pVariant->type = AMF_VARIANT_EMPTY;
+ break;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantCompare(const AMFVariantStruct* pFirst, const AMFVariantStruct* pSecond, amf_bool* bEqual)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pFirst);
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pSecond);
+
+ if(pFirst == pSecond)
+ {
+ *bEqual = true;
+ }
+ else if(AMFVariantGetType(pFirst) != AMFVariantGetType(pSecond))
+ {
+ *bEqual = false;
+ }
+ else
+ {
+ switch(AMFVariantGetType(pFirst))
+ {
+ case AMF_VARIANT_EMPTY:
+ *bEqual = true;
+ break;
+ case AMF_VARIANT_BOOL:
+ *bEqual = AMFVariantGetBool(pFirst) == AMFVariantBool(pSecond);
+ break;
+ case AMF_VARIANT_INT64:
+ *bEqual = AMFVariantGetInt64(pFirst) == AMFVariantInt64(pSecond);
+ break;
+ case AMF_VARIANT_DOUBLE:
+ *bEqual = AMFVariantGetDouble(pFirst) == AMFVariantDouble(pSecond);
+ break;
+ case AMF_VARIANT_RECT:
+#if defined(__cplusplus)
+ *bEqual = AMFVariantGetRect(pFirst) == AMFVariantGetRect(pSecond);
+#else
+ *bEqual = memcmp(&pFirst->rectValue, &pSecond->rectValue, sizeof(AMFRect)) == 0;
+#endif
+ break;
+ case AMF_VARIANT_SIZE:
+#if defined(__cplusplus)
+ *bEqual = AMFVariantGetSize(pFirst) == AMFVariantGetSize(pSecond);
+#else
+ *bEqual = memcmp(&pFirst->sizeValue, &pSecond->sizeValue, sizeof(AMFSize)) == 0;
+#endif
+ break;
+ case AMF_VARIANT_POINT:
+#if defined(__cplusplus)
+ *bEqual = AMFVariantGetPoint(pFirst) == AMFVariantGetPoint(pSecond);
+#else
+ *bEqual = memcmp(&pFirst->pointValue, &pSecond->pointValue, sizeof(AMFPoint)) == 0;
+#endif
+ break;
+ case AMF_VARIANT_RATE:
+#if defined(__cplusplus)
+ *bEqual = AMFVariantGetRate(pFirst) == AMFVariantGetRate(pSecond);
+#else
+ *bEqual = memcmp(&pFirst->rateValue, &pSecond->rateValue, sizeof(AMFRate)) == 0;
+#endif
+ break;
+ case AMF_VARIANT_RATIO:
+#if defined(__cplusplus)
+ *bEqual = AMFVariantGetRatio(pFirst) == AMFVariantGetRatio(pSecond);
+#else
+ *bEqual = memcmp(&pFirst->ratioValue, &pSecond->ratioValue, sizeof(AMFRatio)) == 0;
+#endif
+ break;
+ case AMF_VARIANT_COLOR:
+#if defined(__cplusplus)
+ *bEqual = AMFVariantGetColor(pFirst) == AMFVariantGetColor(pSecond);
+#else
+ *bEqual = memcmp(&pFirst->colorValue, &pSecond->colorValue, sizeof(AMFColor)) == 0;
+#endif
+ break;
+ case AMF_VARIANT_STRING:
+ *bEqual = strcmp(AMFVariantString(pFirst), AMFVariantString(pSecond)) == 0;
+ break;
+ case AMF_VARIANT_WSTRING:
+ *bEqual = wcscmp(AMFVariantWString(pFirst), AMFVariantWString(pSecond)) == 0;
+ break;
+ case AMF_VARIANT_INTERFACE:
+ *bEqual = AMFVariantInterface(pFirst) == AMFVariantInterface(pSecond);
+ break;
+ default:
+ errRet = AMF_INVALID_ARG;
+ break;
+ }
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantCopy(AMFVariantStruct* pDest, const AMFVariantStruct* pSrc)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pSrc);
+ if(pDest != pSrc)
+ {
+ switch(AMFVariantGetType(pSrc))
+ {
+ case AMF_VARIANT_EMPTY:
+ errRet = AMFVariantClear(pDest);
+ break;
+ case AMF_VARIANT_BOOL:
+ errRet = AMFVariantAssignBool(pDest, AMFVariantBool(pSrc));
+ break;
+ case AMF_VARIANT_INT64:
+ errRet = AMFVariantAssignInt64(pDest, AMFVariantInt64(pSrc));
+ break;
+ case AMF_VARIANT_DOUBLE:
+ errRet = AMFVariantAssignDouble(pDest, AMFVariantDouble(pSrc));
+ break;
+ case AMF_VARIANT_RECT:
+ errRet = AMFVariantAssignRect(pDest, &pSrc->rectValue);
+ break;
+ case AMF_VARIANT_SIZE:
+ errRet = AMFVariantAssignSize(pDest, &pSrc->sizeValue);
+ break;
+ case AMF_VARIANT_POINT:
+ errRet = AMFVariantAssignPoint(pDest, &pSrc->pointValue);
+ break;
+ case AMF_VARIANT_RATE:
+ errRet = AMFVariantAssignRate(pDest, &pSrc->rateValue);
+ break;
+ case AMF_VARIANT_RATIO:
+ errRet = AMFVariantAssignRatio(pDest, &pSrc->ratioValue);
+ break;
+ case AMF_VARIANT_COLOR:
+ errRet = AMFVariantAssignColor(pDest, &pSrc->colorValue);
+ break;
+ case AMF_VARIANT_STRING:
+ errRet = AMFVariantAssignString(pDest, AMFVariantString(pSrc));
+ break;
+ case AMF_VARIANT_WSTRING:
+ errRet = AMFVariantAssignWString(pDest, AMFVariantWString(pSrc));
+ break;
+ case AMF_VARIANT_INTERFACE:
+ errRet = AMFVariantAssignInterface(pDest, AMFVariantInterface(pSrc));
+ break;
+ default:
+ errRet = AMF_INVALID_ARG;
+ break;
+ }
+ }
+ return errRet;
+ }
+ #define AMFVariantTypeEmpty AMF_VARIANT_EMPTY
+
+ #define AMFVariantTypeBool AMF_VARIANT_BOOL
+ #define AMFVariantTypeInt64 AMF_VARIANT_INT64
+ #define AMFVariantTypeDouble AMF_VARIANT_DOUBLE
+
+ #define AMFVariantTypeRect AMF_VARIANT_RECT
+ #define AMFVariantTypeSize AMF_VARIANT_SIZE
+ #define AMFVariantTypePoint AMF_VARIANT_POINT
+ #define AMFVariantTypeRate AMF_VARIANT_RATE
+ #define AMFVariantTypeRatio AMF_VARIANT_RATIO
+ #define AMFVariantTypeColor AMF_VARIANT_COLOR
+
+ #define AMFVariantTypeString AMF_VARIANT_STRING
+ #define AMFVariantTypeWString AMF_VARIANT_WSTRING
+ #define AMFVariantTypeInterface AMF_VARIANT_INTERFACE
+
+#if defined(__cplusplus)
+
+ AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignString(AMFVariantStruct* pDest, const AMFVariant::String& value)
+ {
+ return AMFVariantAssignString(pDest, value.c_str());
+ }
+ AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignWString(AMFVariantStruct* pDest, const AMFVariant::WString& value)
+ {
+ return AMFVariantAssignWString(pDest, value.c_str());
+ }
+
+ AMF_INLINE amf_bool AMFConvertEmptyToBool(void*, AMF_RESULT& res) { res = AMF_OK; return false; }
+ AMF_INLINE amf_int64 AMFConvertEmptyToInt64(void*, AMF_RESULT& res) {res = AMF_OK; return 0; }
+ AMF_INLINE amf_double AMFConvertEmptyToDouble(void*, AMF_RESULT& res) {res = AMF_OK; return 0; }
+
+
+ AMF_INLINE AMFVariant::String AMFConvertEmptyToString(void*, AMF_RESULT& res) {res = AMF_OK; return ""; }
+ AMF_INLINE AMFVariant::WString AMFConvertEmptyToWString(void*, AMF_RESULT& res) {res = AMF_OK; return L""; }
+ AMF_INLINE amf_int64 AMFConvertBoolToInt64(bool value, AMF_RESULT& res){res = AMF_OK; return value ? 1 : 0;}
+ AMF_INLINE amf_double AMFConvertBoolToDouble(bool value, AMF_RESULT& res){res = AMF_OK; return value ? 1 : 0;}
+ AMF_INLINE AMFVariant::String AMFConvertBoolToString(bool value, AMF_RESULT& res){res = AMF_OK; return value ? "true" : "false";}
+ AMF_INLINE AMFVariant::WString AMFConvertBoolToWString(bool value, AMF_RESULT& res){res = AMF_OK; return value ? L"true" : L"false";}
+ AMF_INLINE bool AMFConvertInt64ToBool(amf_int64 value, AMF_RESULT& res){res = AMF_OK;return value != 0;}
+ AMF_INLINE amf_double AMFConvertInt64ToDouble(amf_int64 value, AMF_RESULT& res){res = AMF_OK;return (amf_double)value;}
+ AMF_INLINE AMFVariant::String AMFConvertInt64ToString(amf_int64 value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ char buff[0xFF];
+ sprintf(buff, "%" AMFPRId64, (long long)value);
+ return buff;
+ }
+ AMF_INLINE AMFVariant::WString AMFConvertInt64ToWString(amf_int64 value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ wchar_t buff[0xFF];
+ swprintf(buff, 0xFF, L"%" LPRId64, (long long)value);
+ return buff;
+ }
+
+ AMF_INLINE bool AMFConvertDoubleToBool(amf_double value, AMF_RESULT& res){res = AMF_OK;return value != 0;}
+ AMF_INLINE amf_int64 AMFConvertDoubleToInt64(amf_double value, AMF_RESULT& res){res = AMF_OK;return amf_int64(value);}
+ AMF_INLINE AMFVariant::String AMFConvertDoubleToString(amf_double value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ char buff[0xFF];
+ sprintf(buff, "%lf", value);
+ return buff;
+ }
+ AMF_INLINE AMFVariant::WString AMFConvertDoubleToWString(amf_double value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ wchar_t buff[0xFF];
+ swprintf(buff, 0xFF, L"%lf", value);
+ return buff;
+ }
+
+ AMF_INLINE bool AMFConvertStringToBool(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ AMFVariant::String tmp = value;
+ if(( tmp == "true") || ( tmp == "True") || ( tmp == "TRUE") || ( tmp == "1") )
+ {
+ return true;
+ }
+ else
+ {
+ if(( tmp == "false") || ( tmp == "False") || ( tmp == "FALSE") || ( tmp == "0") )
+ {
+ return false;
+ }
+ }
+ res = AMF_INVALID_ARG;
+ return false;
+ }
+
+ AMF_INLINE amf_int64 AMFConvertStringToInt64(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ long long tmp = 0;
+ int readElements = 0;
+
+ if(value.size() > 2 && ( value.c_str()[0] == '0') && ( value.c_str()[1] == 'x') )
+ {
+ readElements = sscanf(value.c_str(), "0x%" AMFPRIx64, &tmp);
+ }
+ else if(value.size() > 0)
+ {
+ readElements = sscanf(value.c_str(), "%" AMFPRId64, &tmp);
+ }
+ if(readElements)
+ {
+ return tmp;
+ }
+ res = AMF_INVALID_ARG;
+ return 0;
+ }
+
+ AMF_INLINE amf_double AMFConvertStringToDouble(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ amf_double tmp = 0;
+ int readElements = 0;
+ if(value.size() > 0)
+ {
+ readElements = sscanf(value.c_str(), "%lf", &tmp);
+ }
+ if(readElements)
+ {
+ return tmp;
+ }
+ res = AMF_INVALID_ARG;
+ return 0;
+ }
+
+ AMF_INLINE AMFVariant::WString AMFConvertStringToWString(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+// return amf_from_utf8_to_unicode(value);
+ AMFVariant::WString result;
+ if(0 == value.size())
+ {
+ return result;
+ }
+ const char* pUtf8Buff = value.c_str();
+
+#if defined(_WIN32)
+ _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
+ int UnicodeBuffSize = ::MultiByteToWideChar(CP_UTF8, 0, pUtf8Buff, -1, NULL, 0);
+ if(0 == UnicodeBuffSize)
+ {
+ return result;
+ }
+ UnicodeBuffSize += 8; // get some extra space
+ result.resize(UnicodeBuffSize);
+ UnicodeBuffSize = ::MultiByteToWideChar(CP_UTF8, 0, pUtf8Buff, -1, (LPWSTR)result.c_str(), UnicodeBuffSize);
+ UnicodeBuffSize--;
+
+#elif defined(__ANDROID__)
+ // on android mbstowcs cannot be used to define length
+ char* old_locale = setlocale(LC_CTYPE, "en_US.UTF8");
+
+ mbstate_t mbs;
+ mbrlen(NULL, 0, &mbs);
+ int len = value.size();
+ const char* pt = pUtf8Buff;
+ int UnicodeBuffSize = 0;
+ while(len > 0)
+ {
+ size_t length = mbrlen (pt, len, &mbs); //MM TODO Android always return 1
+ if((length == 0) || (length > len))
+ {
+ break;
+ }
+ UnicodeBuffSize++;
+ len -= length;
+ pt += length;
+ }
+ UnicodeBuffSize += 8; // get some extra space
+ result.resize(UnicodeBuffSize);
+
+ mbrlen (NULL, 0, &mbs);
+ len = value.size();
+ pt = pUtf8Buff;
+ UnicodeBuffSize = 0;
+ while(len > 0)
+ {
+ size_t length = mbrlen (pt, len, &mbs);
+ if((length == 0) || (length > len))
+ {
+ break;
+ }
+ mbrtowc(&result[UnicodeBuffSize], pt, length, &mbs); //MM TODO Android always return 1 char
+ UnicodeBuffSize++;
+ len -= length;
+ pt += length;
+ }
+ setlocale(LC_CTYPE, old_locale);
+
+ #else
+ char* old_locale = setlocale(LC_CTYPE, "en_US.UTF8");
+ int UnicodeBuffSize = mbstowcs(NULL, pUtf8Buff, 0);
+ if(0 == UnicodeBuffSize)
+ {
+ return result;
+ }
+ UnicodeBuffSize += 8; // get some extra space
+ result.resize(UnicodeBuffSize);
+ UnicodeBuffSize = mbstowcs(&result[0], pUtf8Buff, UnicodeBuffSize);
+ setlocale(LC_CTYPE, old_locale);
+#endif
+ result.resize(UnicodeBuffSize);
+ return result;
+ }
+ AMF_INLINE AMFVariant::String AMFConvertWStringToString(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+// return amf_from_unicode_to_utf8(value);
+ AMFVariant::String result;
+ if(0 == value.size())
+ {
+ return result;
+ }
+
+ const wchar_t* pwBuff = value.c_str();
+
+#if defined(_WIN32)
+ _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
+ int Utf8BuffSize = ::WideCharToMultiByte(CP_UTF8, 0, pwBuff, -1, NULL, 0, NULL, NULL);
+ if(0 == Utf8BuffSize)
+ {
+ return result;
+ }
+ Utf8BuffSize += 8; // get some extra space
+ result.resize(Utf8BuffSize);
+ Utf8BuffSize = ::WideCharToMultiByte(CP_UTF8, 0, pwBuff, -1, (LPSTR)result.c_str(), Utf8BuffSize, NULL, NULL);
+ Utf8BuffSize--;
+#elif defined(__ANDROID__)
+ char* old_locale = setlocale(LC_CTYPE, "en_US.UTF8");
+ int Utf8BuffSize = value.length();
+ if(0 == Utf8BuffSize)
+ {
+ return result;
+ }
+ Utf8BuffSize += 8; // get some extra space
+ result.resize(Utf8BuffSize);
+
+ mbstate_t mbs;
+ mbrlen(NULL, 0, &mbs);
+
+ Utf8BuffSize = 0;
+ for( int i = 0; i < value.length(); i++)
+ {
+ //MM TODO Android - not implemented
+ //int written = wcrtomb(&result[Utf8BuffSize], pwBuff[i], &mbs);
+ result[Utf8BuffSize] = (char)(pwBuff[i]);
+ int written = 1;
+ // temp replacement
+ Utf8BuffSize += written;
+ }
+ setlocale(LC_CTYPE, old_locale);
+
+#else
+ char* old_locale = setlocale(LC_CTYPE, "en_US.UTF8");
+ int Utf8BuffSize = wcstombs(NULL, pwBuff, 0);
+ if(0 == Utf8BuffSize)
+ {
+ return result;
+ }
+ Utf8BuffSize += 8; // get some extra space
+ result.resize(Utf8BuffSize);
+ Utf8BuffSize = wcstombs(&result[0], pwBuff, Utf8BuffSize);
+
+ setlocale(LC_CTYPE, old_locale);
+#endif
+ result.resize(Utf8BuffSize);
+ return result;
+ }
+
+
+ AMF_INLINE bool AMFConvertWStringToBool(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToBool(AMFConvertWStringToString(value, res), res);
+ }
+ AMF_INLINE amf_int64 AMFConvertWStringToInt64(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToInt64(AMFConvertWStringToString(value, res), res);
+ }
+ AMF_INLINE amf_double AMFConvertWStringToDouble(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToDouble(AMFConvertWStringToString(value, res), res);
+ }
+
+ AMF_INLINE AMFVariant::String AMF_STD_CALL AMFConvertRectToString(const AMFRect& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ char buff[0xFF];
+ sprintf(buff, "%d,%d,%d,%d", value.left, value.top, value.right, value.bottom);
+ return buff;
+ }
+ AMF_INLINE AMFVariant::String AMF_STD_CALL AMFConvertSizeToString(const AMFSize& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ char buff[0xFF];
+ sprintf(buff, "%d,%d", value.width, value.height);
+ return buff;
+ }
+ AMF_INLINE AMFVariant::String AMF_STD_CALL AMFConvertPointToString(const AMFPoint& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ char buff[0xFF];
+ sprintf(buff, "%d,%d", value.x, value.y);
+ return buff;
+ }
+ AMF_INLINE AMFVariant::String AMF_STD_CALL AMFConvertRateToString(const AMFRate& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ char buff[0xFF];
+ sprintf(buff, "%d,%d", value.num, value.den);
+ return buff;
+ }
+ AMF_INLINE AMFVariant::String AMF_STD_CALL AMFConvertRatioToString(const AMFRatio& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ char buff[0xFF];
+ sprintf(buff, "%d,%d", value.num, value.den);
+ return buff;
+ }
+ AMF_INLINE AMFVariant::String AMF_STD_CALL AMFConvertColorToString(const AMFColor& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ char buff[0xFF];
+ sprintf(buff, "%d,%d,%d,%d", value.r, value.g, value.b, value.a);
+ return buff;
+ }
+
+ AMF_INLINE AMFRect AMF_STD_CALL AMFConvertStringToRect(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ AMFRect tmp = {};
+ int readElements = 0;
+ if(value.size() > 0)
+ {
+ readElements = sscanf(value.c_str(), "%d,%d,%d,%d", &tmp.left, &tmp.top, &tmp.right, &tmp.bottom);
+ }
+ if(readElements)
+ {
+ return tmp;
+ }
+ res = AMF_INVALID_ARG;
+ return tmp;
+ }
+
+ AMF_INLINE AMFSize AMF_STD_CALL AMFConvertStringToSize(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ AMFSize tmp = {};
+ int readElements = 0;
+ if(value.size() > 0)
+ {
+ readElements = sscanf(value.c_str(), "%d,%d", &tmp.width, &tmp.height);
+ }
+ if(readElements)
+ {
+ return tmp;
+ }
+ res = AMF_INVALID_ARG;
+ return tmp;
+ }
+ AMF_INLINE AMFPoint AMF_STD_CALL AMFConvertStringToPoint(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ AMFPoint tmp = {};
+ int readElements = 0;
+ if(value.size() > 0)
+ {
+ readElements = sscanf(value.c_str(), "%d,%d", &tmp.x, &tmp.y);
+ }
+ if(readElements)
+ {
+ return tmp;
+ }
+ res = AMF_INVALID_ARG;
+ return tmp;
+ }
+ AMF_INLINE AMFRate AMF_STD_CALL AMFConvertStringToRate(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ AMFRate tmp = {};
+ int readElements = 0;
+ if(value.size() > 0)
+ {
+ readElements = sscanf(value.c_str(), "%d,%d", &tmp.num, &tmp.den);
+ }
+ if(readElements)
+ {
+ return tmp;
+ }
+ res = AMF_INVALID_ARG;
+ return tmp;
+ }
+ AMF_INLINE AMFRatio AMF_STD_CALL AMFConvertStringToRatio(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ AMFRatio tmp = {};
+ int readElements = 0;
+ if(value.size() > 0)
+ {
+ readElements = sscanf(value.c_str(), "%d,%d", &tmp.num, &tmp.den);
+ }
+ if(readElements)
+ {
+ return tmp;
+ }
+ res = AMF_INVALID_ARG;
+ return tmp;
+ }
+ AMF_INLINE AMFColor AMF_STD_CALL AMFConvertStringToColor(const AMFVariant::String& value, AMF_RESULT& res)
+ {
+ res = AMF_OK;
+ int readElements = 0;
+ amf_uint32 r = 0;
+ amf_uint32 g = 0;
+ amf_uint32 b = 0;
+ amf_uint32 a = 0;
+ if(value.size() > 0)
+ {
+ readElements = sscanf(value.c_str(), "%u,%u,%u,%u", &r, &g, &b, &a);
+ }
+ if(readElements)
+ {
+ return AMFConstructColor((amf_uint8)r, (amf_uint8)g, (amf_uint8)b, (amf_uint8)a);
+ }
+ res = AMF_INVALID_ARG;
+ return AMFConstructColor(0, 0, 0, 255);
+ }
+///////////////////////
+ AMF_INLINE AMFVariant::WString AMF_STD_CALL AMFConvertRectToWString(const AMFRect& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToWString(AMFConvertRectToString(value, res), res);
+ }
+ AMF_INLINE AMFVariant::WString AMF_STD_CALL AMFConvertSizeToWString(const AMFSize& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToWString(AMFConvertSizeToString(value, res), res);
+ }
+ AMF_INLINE AMFVariant::WString AMF_STD_CALL AMFConvertPointToWString(const AMFPoint& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToWString(AMFConvertPointToString(value, res), res);
+ }
+ AMF_INLINE AMFVariant::WString AMF_STD_CALL AMFConvertRateToWString(const AMFRate& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToWString(AMFConvertRateToString(value, res), res);
+ }
+ AMF_INLINE AMFVariant::WString AMF_STD_CALL AMFConvertRatioToWString(const AMFRatio& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToWString(AMFConvertRatioToString(value, res), res);
+ }
+ AMF_INLINE AMFVariant::WString AMF_STD_CALL AMFConvertColorToWString(const AMFColor& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToWString(AMFConvertColorToString(value, res), res);
+ }
+
+ AMF_INLINE AMFRect AMF_STD_CALL AMFConvertWStringToRect(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToRect(AMFConvertWStringToString(value, res), res);
+ }
+
+ AMF_INLINE AMFSize AMF_STD_CALL AMFConvertWStringToSize(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToSize(AMFConvertWStringToString(value, res), res);
+ }
+ AMF_INLINE AMFPoint AMF_STD_CALL AMFConvertWStringToPoint(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToPoint(AMFConvertWStringToString(value, res), res);
+ }
+ AMF_INLINE AMFRate AMF_STD_CALL AMFConvertWStringToRate(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToRate(AMFConvertWStringToString(value, res), res);
+ }
+ AMF_INLINE AMFRatio AMF_STD_CALL AMFConvertWStringToRatio(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToRatio(AMFConvertWStringToString(value, res), res);
+ }
+ AMF_INLINE AMFColor AMF_STD_CALL AMFConvertWStringToColor(const AMFVariant::WString& value, AMF_RESULT& res)
+ {
+ return AMFConvertStringToColor(AMFConvertWStringToString(value, res), res);
+ }
+
+ //-------------------------------------------------------------------------------------------------
+ #define AMFConvertTool(srcType, dstType)\
+ if(AMFVariantGetType(pSrc) == AMFVariantType##srcType && newType == AMFVariantType##dstType)\
+ {\
+ AMF_RESULT res = AMF_OK;\
+ AMFVariantAssign##dstType(pDest, AMFConvert##srcType##To##dstType(AMFVariant##srcType(pSrc), res));\
+ return res;\
+ }\
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantChangeType(AMFVariantStruct* pDest, const AMFVariantStruct* pSrc, AMF_VARIANT_TYPE newType)
+ {
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ if(pSrc == 0)
+ {
+ pSrc = pDest;
+ }
+
+ if(AMFVariantGetType(pSrc) == newType)
+ {
+ if(pDest == pSrc)
+ {
+ return AMF_OK;
+ }
+ return AMFVariantCopy(pDest, pSrc);
+ }
+ AMFVariantClear(pDest);
+
+ AMFConvertTool(Empty, Bool);
+ AMFConvertTool(Empty, Int64);
+ AMFConvertTool(Empty, Double);
+ AMFConvertTool(Empty, String);
+ AMFConvertTool(Empty, WString);
+
+ AMFConvertTool(Bool, Int64);
+ AMFConvertTool(Bool, Double);
+ AMFConvertTool(Bool, String);
+ AMFConvertTool(Bool, WString);
+
+ AMFConvertTool(Int64, Bool);
+ AMFConvertTool(Int64, Double);
+ AMFConvertTool(Int64, String);
+ AMFConvertTool(Int64, WString);
+
+ AMFConvertTool(Double, Bool);
+ AMFConvertTool(Double, Int64);
+ AMFConvertTool(Double, String);
+ AMFConvertTool(Double, String);
+
+ AMFConvertTool(String, Bool);
+ AMFConvertTool(String, Int64);
+ AMFConvertTool(String, Double);
+ AMFConvertTool(String, WString);
+
+ AMFConvertTool(WString, Bool);
+ AMFConvertTool(WString, Int64);
+ AMFConvertTool(WString, Double);
+ AMFConvertTool(WString, String);
+
+ AMFConvertTool(String, Rect);
+ AMFConvertTool(String, Size);
+ AMFConvertTool(String, Point);
+ AMFConvertTool(String, Rate);
+ AMFConvertTool(String, Ratio);
+ AMFConvertTool(String, Color);
+
+ AMFConvertTool(Rect , String);
+ AMFConvertTool(Size , String);
+ AMFConvertTool(Point, String);
+ AMFConvertTool(Rate , String);
+ AMFConvertTool(Ratio, String);
+ AMFConvertTool(Color, String);
+
+ AMFConvertTool(WString, Rect);
+ AMFConvertTool(WString, Size);
+ AMFConvertTool(WString, Point);
+ AMFConvertTool(WString, Rate);
+ AMFConvertTool(WString, Ratio);
+ AMFConvertTool(WString, Color);
+
+ AMFConvertTool(Rect , WString);
+ AMFConvertTool(Size , WString);
+ AMFConvertTool(Point, WString);
+ AMFConvertTool(Rate , WString);
+ AMFConvertTool(Ratio, WString);
+ AMFConvertTool(Color, WString);
+
+ return AMF_INVALID_ARG;
+ }
+#endif // #if defined(__cplusplus)
+
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignBool(AMFVariantStruct* pDest, amf_bool value)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_BOOL;
+ AMFVariantBool(pDest) = value;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignInt64(AMFVariantStruct* pDest, amf_int64 value)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_INT64;
+ AMFVariantInt64(pDest) = value;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignDouble(AMFVariantStruct* pDest, amf_double value)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_DOUBLE;
+ AMFVariantDouble(pDest) = value;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignString(AMFVariantStruct* pDest, const char* pValue)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pValue);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ size_t size = (strlen(pValue) + 1);
+ pDest->type = AMF_VARIANT_STRING;
+ AMFVariantString(pDest) = (char*)amf_variant_alloc(size * sizeof(char));
+ if(AMFVariantString(pDest))
+ {
+ strncpy(AMFVariantString(pDest), pValue, size);
+ }
+ else
+ {
+ errRet = AMF_OUT_OF_MEMORY;
+ }
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignWString(AMFVariantStruct* pDest, const wchar_t* pValue)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pValue);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ size_t size = (wcslen(pValue) + 1);
+ pDest->type = AMF_VARIANT_WSTRING;
+ AMFVariantWString(pDest) = (wchar_t*)amf_variant_alloc(size * sizeof(wchar_t));
+ if(AMFVariantWString(pDest))
+ {
+ wcsncpy(AMFVariantWString(pDest), pValue, size);
+ }
+ else
+ {
+ errRet = AMF_OUT_OF_MEMORY;
+ }
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignInterface(AMFVariantStruct* pDest, AMFInterface* pValue)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+ //AMF_VARIANT_RETURN_IF_INVALID_POINTER(pValue);//can be NULL
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_INTERFACE;
+ AMFVariantInterface(pDest) = pValue;
+ if(AMFVariantInterface(pDest))
+ {
+#if defined(__cplusplus)
+ AMFVariantInterface(pDest)->Acquire();
+#else
+ AMFVariantInterface(pDest)->pVtbl->Acquire(AMFVariantInterface(pDest));
+#endif
+
+ }
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRect(AMFVariantStruct* pDest, const AMFRect& value)
+ {
+ return AMFVariantAssignRect(pDest, &value);
+ }
+#endif
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRect (AMFVariantStruct* pDest, const AMFRect* value)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_RECT;
+ AMFVariantRect(pDest) = *value;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignSize (AMFVariantStruct* pDest, const AMFSize& value)
+ {
+ return AMFVariantAssignSize (pDest, &value);
+ }
+#endif
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignSize (AMFVariantStruct* pDest, const AMFSize* value)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_SIZE;
+ AMFVariantSize(pDest) = *value;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignPoint(AMFVariantStruct* pDest, const AMFPoint& value)
+ {
+ return AMFVariantAssignPoint(pDest, &value);
+ }
+#endif
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignPoint(AMFVariantStruct* pDest, const AMFPoint* value)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_POINT;
+ AMFVariantPoint(pDest) = *value;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRate (AMFVariantStruct* pDest, const AMFRate& value)
+ {
+ return AMFVariantAssignRate (pDest, &value);
+ }
+#endif
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRate (AMFVariantStruct* pDest, const AMFRate* value)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_RATE;
+ AMFVariantRate(pDest) = *value;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRatio(AMFVariantStruct* pDest, const AMFRatio& value)
+ {
+ return AMFVariantAssignRatio(pDest, &value);
+ }
+#endif
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignRatio(AMFVariantStruct* pDest, const AMFRatio* value)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_RATIO;
+ AMFVariantRatio(pDest) = *value;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignColor(AMFVariantStruct* pDest, const AMFColor& value)
+ {
+ return AMFVariantAssignColor(pDest, &value);
+ }
+#endif
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE AMF_RESULT AMF_CDECL_CALL AMFVariantAssignColor(AMFVariantStruct* pDest, const AMFColor* value)
+ {
+ AMF_RESULT errRet = AMF_OK;
+ AMF_VARIANT_RETURN_IF_INVALID_POINTER(pDest);
+
+ errRet = AMFVariantClear(pDest);
+ if(errRet == AMF_OK)
+ {
+ pDest->type = AMF_VARIANT_COLOR;
+ AMFVariantColor(pDest) = *value;
+ }
+ return errRet;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE char* AMF_CDECL_CALL AMFVariantDuplicateString(const char* from)
+ {
+ char* ret = 0;
+ if(from)
+ {
+ ret = (char*)amf_variant_alloc(sizeof(char)*(strlen(from) + 1));
+ if(ret)
+ {
+ strcpy(ret, from);
+ }
+ }
+ return ret;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE void AMF_CDECL_CALL AMFVariantFreeString(char* from)
+ {
+ amf_variant_free(from);
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE wchar_t* AMF_CDECL_CALL AMFVariantDuplicateWString(const wchar_t* from)
+ {
+ wchar_t* ret = 0;
+ if(from)
+ {
+ ret = (wchar_t*)amf_variant_alloc(sizeof(wchar_t)*(wcslen(from) + 1));
+ if(ret)
+ {
+ wcscpy(ret, from);
+ }
+ }
+ return ret;
+ }
+ //-------------------------------------------------------------------------------------------------
+ static AMF_INLINE void AMF_CDECL_CALL AMFVariantFreeWString(wchar_t* from)
+ {
+ amf_variant_free(from);
+ }
+ //----------------------------------------------------------------------------------------------
+ // AMF_INLINE implementation of AMFVariant class
+ //----------------------------------------------------------------------------------------------
+#if defined(__cplusplus)
+ AMF_INLINE AMFVariant::AMFVariant(const AMFVariantStruct* pOther)
+ {
+ AMFVariantInit(this);
+ if(pOther != NULL)
+ {
+ AMFVariantCopy(this, const_cast<AMFVariantStruct*>(pOther));
+ }
+ }
+ //-------------------------------------------------------------------------------------------------
+ template<typename T>
+ AMFVariant::AMFVariant(const AMFInterfacePtr_T<T>& pValue)
+ {
+ AMFVariantInit(this);
+ AMFVariantAssignInterface(this, pValue);
+ }
+ //-------------------------------------------------------------------------------------------------
+ template<class ReturnType, AMF_VARIANT_TYPE variantType, typename Getter>
+ ReturnType AMFVariant::GetValue(Getter getter) const
+ {
+ ReturnType str = ReturnType();
+ if(AMFVariantGetType(this) == variantType)
+ {
+ str = static_cast<ReturnType>(getter(this));
+ }
+ else
+ {
+ AMFVariant varDest;
+ varDest.ChangeType(variantType, this);
+ if(varDest.type != AMF_VARIANT_EMPTY)
+ {
+ str = static_cast<ReturnType>(getter(&varDest));
+ }
+ }
+ return str;
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE AMFVariant& AMFVariant::operator=(const AMFVariantStruct& other)
+ {
+ AMFVariantCopy(this, const_cast<AMFVariantStruct*>(&other));
+ return *this;
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE AMFVariant& AMFVariant::operator=(const AMFVariantStruct* pOther)
+ {
+ if(pOther != NULL)
+ {
+ AMFVariantCopy(this, const_cast<AMFVariantStruct*>(pOther));
+ }
+ return *this;
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE AMFVariant& AMFVariant::operator=(const AMFVariant& other)
+ {
+ AMFVariantCopy(this,
+ const_cast<AMFVariantStruct*>(static_cast<const AMFVariantStruct*>(&other)));
+ return *this;
+ }
+ //-------------------------------------------------------------------------------------------------
+ template<typename T>
+ AMFVariant& AMFVariant::operator=(const AMFInterfacePtr_T<T>& value)
+ {
+ AMFVariantAssignInterface(this, value);
+ return *this;
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE bool AMFVariant::operator==(const AMFVariantStruct& other) const
+ {
+ return *this == &other;
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE bool AMFVariant::operator==(const AMFVariantStruct* pOther) const
+ {
+ //TODO: double check
+ amf_bool ret = false;
+ if(pOther == NULL)
+ {
+ ret = false;
+ }
+ else
+ {
+ AMFVariantCompare(this, pOther, &ret);
+ }
+ return ret;
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE bool AMFVariant::operator!=(const AMFVariantStruct& other) const
+ {
+ return !(*this == &other);
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE bool AMFVariant::operator!=(const AMFVariantStruct* pOther) const
+ {
+ return !(*this == pOther);
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE void AMFVariant::Attach(AMFVariantStruct& variant)
+ {
+ Clear();
+ memcpy(this, &variant, sizeof(variant));
+ AMFVariantGetType(&variant) = AMF_VARIANT_EMPTY;
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE AMFVariantStruct AMFVariant::Detach()
+ {
+ AMFVariantStruct varResult = *this;
+ AMFVariantGetType(this) = AMF_VARIANT_EMPTY;
+ return varResult;
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE AMFVariantStruct& AMFVariant::GetVariant()
+ {
+ return *static_cast<AMFVariantStruct*>(this);
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE void AMFVariant::ChangeType(AMF_VARIANT_TYPE newType, const AMFVariant* pSrc)
+ {
+ AMFVariantChangeType(this, pSrc, newType);
+ }
+ //-------------------------------------------------------------------------------------------------
+ AMF_INLINE bool AMFVariant::Empty() const
+ {
+ return type == AMF_VARIANT_EMPTY;
+ }
+ //-------------------------------------------------------------------------------------------------
+#endif // #if defined(__cplusplus)
+
+#if defined(__cplusplus)
+} //namespace amf
+#endif
+
+#endif //#ifndef __AMFVariant_h__
diff --git a/compat/amd/amf/public/include/core/Version.h b/compat/amd/amf/public/include/core/Version.h
new file mode 100644
index 0000000..08809ab
--- /dev/null
+++ b/compat/amd/amf/public/include/core/Version.h
@@ -0,0 +1,59 @@
+//
+// Notice Regarding Standards. AMD does not provide a license or sublicense to
+// any Intellectual Property Rights relating to any standards, including but not
+// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
+// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
+// (collectively, the "Media Technologies"). For clarity, you will pay any
+// royalties due for such third party technologies, which may include the Media
+// Technologies that are owed as a result of AMD providing the Software to you.
+//
+// MIT license
+//
+// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+/**
+***************************************************************************************************
+* @file Version.h
+* @brief Version declaration
+***************************************************************************************************
+*/
+#ifndef __AMFVersion_h__
+#define __AMFVersion_h__
+#pragma once
+
+#include "Platform.h"
+
+#define AMF_MAKE_FULL_VERSION(VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE, VERSION_BUILD_NUM) ( ((amf_uint64)(VERSION_MAJOR) << 48ull) | ((amf_uint64)(VERSION_MINOR) << 32ull) | ((amf_uint64)(VERSION_RELEASE) << 16ull) | (amf_uint64)(VERSION_BUILD_NUM))
+
+#define AMF_GET_MAJOR_VERSION(x) ((x >> 48ull) & 0xFFFF)
+#define AMF_GET_MINOR_VERSION(x) ((x >> 32ull) & 0xFFFF)
+#define AMF_GET_SUBMINOR_VERSION(x) ((x >> 16ull) & 0xFFFF)
+#define AMF_GET_BUILD_VERSION(x) ((x >> 0ull) & 0xFFFF)
+
+#define AMF_VERSION_MAJOR 1
+#define AMF_VERSION_MINOR 4
+#define AMF_VERSION_RELEASE 4
+#define AMF_VERSION_BUILD_NUM 0
+
+#define AMF_FULL_VERSION AMF_MAKE_FULL_VERSION(AMF_VERSION_MAJOR, AMF_VERSION_MINOR, AMF_VERSION_RELEASE, AMF_VERSION_BUILD_NUM)
+
+#endif //#ifndef __AMFVersion_h__
diff --git a/configure b/configure
index ba38a73..dde5b10 100755
--- a/configure
+++ b/configure
@@ -304,6 +304,7 @@ External library support:
The following libraries provide various hardware acceleration features:
--disable-audiotoolbox disable Apple AudioToolbox code [autodetect]
+ --disable-amf disable AMF video encoding code [autodetect]
--disable-cuda disable dynamically linked Nvidia CUDA code [autodetect]
--enable-cuda-sdk enable CUDA features that require the CUDA SDK [no]
--disable-cuvid disable Nvidia CUVID support [autodetect]
@@ -1634,6 +1635,7 @@ EXTERNAL_LIBRARY_LIST="
HWACCEL_AUTODETECT_LIBRARY_LIST="
audiotoolbox
+ amf
crystalhd
cuda
cuvid
@@ -2779,12 +2781,15 @@ scale_npp_filter_deps="cuda libnpp"
scale_cuda_filter_deps="cuda_sdk"
thumbnail_cuda_filter_deps="cuda_sdk"
+amf_deps_any="dlopen LoadLibrary"
+amf_encoder_deps="amf"
+
nvenc_deps="cuda"
nvenc_deps_any="dlopen LoadLibrary"
nvenc_encoder_deps="nvenc"
-
h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m"
h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m"
+h264_amf_encoder_deps="amf"
h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
h264_cuvid_decoder_deps="cuda cuvid"
h264_cuvid_decoder_select="h264_mp4toannexb_bsf"
@@ -2805,6 +2810,7 @@ h264_vdpau_decoder_deps="vdpau"
h264_vdpau_decoder_select="h264_decoder"
h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
h264_v4l2m2m_encoder_deps="v4l2_m2m h264_v4l2_m2m"
+hevc_amf_encoder_deps="amf"
hevc_cuvid_decoder_deps="cuda cuvid"
hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf"
hevc_mediacodec_decoder_deps="mediacodec"
@@ -2848,6 +2854,8 @@ mpeg4_v4l2m2m_encoder_deps="v4l2_m2m mpeg4_v4l2_m2m"
mpeg_vdpau_decoder_deps="vdpau"
mpeg_vdpau_decoder_select="mpeg2video_decoder"
msmpeg4_crystalhd_decoder_select="crystalhd"
+amf_h264_encoder_select="h264_amf_encoder"
+amf_hevc_encoder_select="hevc_amf_encoder"
nvenc_h264_encoder_select="h264_nvenc_encoder"
nvenc_hevc_encoder_select="hevc_nvenc_encoder"
vc1_crystalhd_decoder_select="crystalhd"
@@ -5646,6 +5654,7 @@ frei0r_filter_extralibs='$ldl'
frei0r_src_filter_extralibs='$ldl'
ladspa_filter_extralibs='$ldl'
nvenc_extralibs='$ldl'
+amf_extralibs='$ldl'
if ! disabled network; then
check_func getaddrinfo $network_extralibs
@@ -6259,6 +6268,19 @@ else
disable cuda cuvid nvenc
fi
+if enabled x86; then
+ case $target_os in
+ mingw32*|mingw64*|win32|win64|cygwin*)
+ ;;
+ *)
+ disable amf
+ ;;
+ esac
+else
+ disable amf
+fi
+
+
enabled nvenc &&
check_cc -I$source_path <<EOF || disable nvenc
#include "compat/nvenc/nvEncodeAPI.h"
@@ -6267,6 +6289,13 @@ void f(void) { struct { const GUID guid; } s[] = { { NV_ENC_PRESET_HQ_GUID } };
int main(void) { return 0; }
EOF
+enabled amf &&
+ check_cc -I$source_path <<EOF || disable amf
+#include "compat/amd/amf/public/include/core/Factory.h"
+AMFFactory *factory;
+int main(void) { return 0; }
+EOF
+
# Funny iconv installations are not unusual, so check it after all flags have been set
if enabled libc_iconv; then
check_func_headers iconv.h iconv
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1b17c27..80d9ab1 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -54,6 +54,7 @@ OBJS = allcodecs.o \
# subsystems
OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o
OBJS-$(CONFIG_AC3DSP) += ac3dsp.o ac3.o ac3tab.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
@@ -334,6 +335,7 @@ OBJS-$(CONFIG_H264_DECODER) += h264dec.o h264_cabac.o h264_cavlc.o \
OBJS-$(CONFIG_H264_CUVID_DECODER) += cuvid.o
OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o
+OBJS-$(CONFIG_H264_AMF_ENCODER) += amfenc_h264.o
OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o
OBJS-$(CONFIG_NVENC_ENCODER) += nvenc_h264.o
OBJS-$(CONFIG_NVENC_H264_ENCODER) += nvenc_h264.o
@@ -352,6 +354,7 @@ OBJS-$(CONFIG_HEVC_DECODER) += hevcdec.o hevc_mvs.o \
hevcdsp.o hevc_filter.o hevc_data.o
OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuvid.o
OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
+OBJS-$(CONFIG_HEVC_AMF_ENCODER) += amfenc_hevc.o
OBJS-$(CONFIG_HEVC_NVENC_ENCODER) += nvenc_hevc.o
OBJS-$(CONFIG_NVENC_HEVC_ENCODER) += nvenc_hevc.o
OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec_h2645.o
@@ -1050,6 +1053,7 @@ SKIPHEADERS-$(CONFIG_JNI) += ffjni.h
SKIPHEADERS-$(CONFIG_LIBVPX) += libvpx.h
SKIPHEADERS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc_common.h
SKIPHEADERS-$(CONFIG_MEDIACODEC) += mediacodecdec_common.h mediacodec_surface.h mediacodec_wrapper.h mediacodec_sw_buffer.h
+SKIPHEADERS-$(CONFIG_AMF) += amfenc.h
SKIPHEADERS-$(CONFIG_NVENC) += nvenc.h
SKIPHEADERS-$(CONFIG_QSV) += qsv.h qsv_internal.h
SKIPHEADERS-$(CONFIG_QSVDEC) += qsvdec.h
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index db2db15..cd4a23f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -665,6 +665,8 @@ static void register_all(void)
/* external libraries, that shouldn't be used by default if one of the
* above is available */
REGISTER_ENCDEC (LIBOPENH264, libopenh264);
+ REGISTER_ENCODER(H264_AMF, h264_amf);
+ REGISTER_ENCODER(H264_AMF, h264_amf_d3d11va);
REGISTER_DECODER(H264_CUVID, h264_cuvid);
REGISTER_ENCODER(H264_NVENC, h264_nvenc);
REGISTER_ENCODER(H264_OMX, h264_omx);
@@ -676,6 +678,8 @@ static void register_all(void)
REGISTER_ENCODER(NVENC_H264, nvenc_h264);
REGISTER_ENCODER(NVENC_HEVC, nvenc_hevc);
#endif
+ REGISTER_ENCODER(HEVC_AMF, hevc_amf);
+ REGISTER_ENCODER(HEVC_AMF, hevc_amf_d3d11va);
REGISTER_DECODER(HEVC_CUVID, hevc_cuvid);
REGISTER_DECODER(HEVC_MEDIACODEC, hevc_mediacodec);
REGISTER_ENCODER(HEVC_NVENC, hevc_nvenc);
diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c
new file mode 100644
index 0000000..e3a7f74
--- /dev/null
+++ b/libavcodec/amfenc.c
@@ -0,0 +1,463 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "amfenc.h"
+
+#include "compat/amd/amf/public/include/components/VideoEncoderVCE.h"
+#include "compat/amd/amf/public/include/components/VideoEncoderHEVC.h"
+
+#include "libavutil/time.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/hwcontext.h"
+#include "libavutil/hwcontext_d3d11va.h"
+#include "libavutil/avassert.h"
+#include "libavutil/mem.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/hwcontext.h"
+#include "internal.h"
+
+#include <d3d11.h>
+
+#ifdef _WIN32
+#include "compat/w32dlfcn.h"
+#else
+#include <dlfcn.h>
+#endif
+
+#define FFMPEG_AMF_WRITER_ID L"ffmpeg_amf"
+#define AMF_DEBUG_TRACE 0
+
+const enum AVPixelFormat ff_amf_pix_fmts[] = {
+ AV_PIX_FMT_NV12,
+ AV_PIX_FMT_BGRA,
+ AV_PIX_FMT_ARGB,
+ AV_PIX_FMT_RGBA,
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_YUYV422,
+ AV_PIX_FMT_D3D11,
+ AV_PIX_FMT_NONE
+};
+
+typedef struct FormatMap {
+ enum AVPixelFormat av_format;
+ enum AMF_SURFACE_FORMAT amf_format;
+} FormatMap;
+
+static const FormatMap format_map[] =
+{
+ { AV_PIX_FMT_NONE, AMF_SURFACE_UNKNOWN },
+ { AV_PIX_FMT_NV12, AMF_SURFACE_NV12 },
+ { AV_PIX_FMT_BGRA, AMF_SURFACE_BGRA },
+ { AV_PIX_FMT_ARGB, AMF_SURFACE_ARGB },
+ { AV_PIX_FMT_RGBA, AMF_SURFACE_RGBA },
+ { AV_PIX_FMT_GRAY8, AMF_SURFACE_GRAY8 },
+ { AV_PIX_FMT_YUV420P, AMF_SURFACE_YUV420P },
+ { AV_PIX_FMT_BGR0, AMF_SURFACE_BGRA },
+ { AV_PIX_FMT_YUV420P, AMF_SURFACE_YV12 },
+ { AV_PIX_FMT_YUYV422, AMF_SURFACE_YUY2 },
+ { AV_PIX_FMT_D3D11, AMF_SURFACE_NV12 },
+};
+
+static enum AMF_SURFACE_FORMAT amf_av_to_amf_format(enum AVPixelFormat fmt)
+{
+ for (int i = 0; i < amf_countof(format_map); i++) {
+ if (format_map[i].av_format == fmt) {
+ return format_map[i].amf_format;
+ }
+ }
+ return AMF_SURFACE_UNKNOWN;
+}
+
+// virtual functions decalred
+static void AMF_CDECL_CALL AMFTraceWriter_Write(AMFTraceWriter* pThis,
+ const wchar_t* scope, const wchar_t* message)
+{
+ AmfTraceWriter *tracer = (AmfTraceWriter*)pThis;
+#if AMF_DEBUG_TRACE
+ av_log(tracer->avctx, AV_LOG_INFO, "%ls: %ls", scope, message);
+#else
+ av_log(tracer->avctx, AV_LOG_TRACE, "%ls: %ls", scope, message);
+#endif
+}
+
+static void AMF_CDECL_CALL AMFTraceWriter_Flush(AMFTraceWriter* pThis)
+{
+}
+
+static AMFTraceWriterVtbl tracer_vtbl =
+{
+ .Write = AMFTraceWriter_Write,
+ .Flush = AMFTraceWriter_Flush,
+};
+
+static int amf_load_library(AVCodecContext *avctx)
+{
+ AmfContext *ctx = avctx->priv_data;
+ AMFInit_Fn init_fun = 0;
+ AMFQueryVersion_Fn version_fun = 0;
+
+ ctx->library = dlopen(AMF_DLL_NAMEA, RTLD_NOW | RTLD_LOCAL);
+ AMF_RETURN_IF_FALSE(ctx, ctx->library != 0,
+ AVERROR_UNKNOWN, "DLL %s failed to open. \n", AMF_DLL_NAMEA);
+
+ init_fun = (AMFInit_Fn)dlsym(ctx->library, AMF_INIT_FUNCTION_NAME);
+ AMF_RETURN_IF_FALSE(ctx, init_fun != 0, AVERROR_UNKNOWN, "DLL %s failed to find function %s. \n", AMF_DLL_NAMEA, AMF_INIT_FUNCTION_NAME);
+
+ version_fun = (AMFQueryVersion_Fn)dlsym(ctx->library, AMF_QUERY_VERSION_FUNCTION_NAME);
+ AMF_RETURN_IF_FALSE(ctx, init_fun != 0, AVERROR_UNKNOWN, "DLL %s failed to find function %s. \n", AMF_DLL_NAMEA, AMF_QUERY_VERSION_FUNCTION_NAME);
+
+ version_fun(&ctx->version);
+ init_fun(AMF_FULL_VERSION, &ctx->factory);
+ ctx->factory->pVtbl->GetTrace(ctx->factory, &ctx->trace);
+ ctx->factory->pVtbl->GetDebug(ctx->factory, &ctx->debug);
+ return 0;
+}
+
+
+static int amf_init_context(AVCodecContext *avctx)
+{
+ AmfContext *ctx = avctx->priv_data;
+ AMF_RESULT res = AMF_OK;
+
+ ctx->trace->pVtbl->EnableWriter(ctx->trace, AMF_TRACE_WRITER_CONSOLE, false);
+
+#if AMF_DEBUG_TRACE
+ ctx->trace->pVtbl->EnableWriter(ctx->trace, AMF_TRACE_WRITER_DEBUG_OUTPUT, true);
+ ctx->trace->pVtbl->SetWriterLevel(ctx->trace, AMF_TRACE_WRITER_DEBUG_OUTPUT, AMF_TRACE_TRACE);
+ ctx->trace->pVtbl->SetGlobalLevel(ctx->trace, AMF_TRACE_TRACE);
+#else
+ ctx->trace->pVtbl->EnableWriter(ctx->trace, AMF_TRACE_WRITER_DEBUG_OUTPUT, false);
+#endif
+ ctx->tracer.vtbl = &tracer_vtbl;
+ ctx->tracer.avctx = avctx;
+ ctx->trace->pVtbl->RegisterWriter(ctx->trace, FFMPEG_AMF_WRITER_ID,
+ (AMFTraceWriter*)&ctx->tracer, true);
+
+ res = ctx->factory->pVtbl->CreateContext(ctx->factory, &ctx->context);
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, "CreateContext() failed with error %d", res);
+
+ // try to reuse existing DX device
+
+ if (avctx->hw_frames_ctx) {
+ AVHWFramesContext *device_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
+ if (device_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA){
+ if (device_ctx->device_ctx->hwctx) {
+ AVD3D11VADeviceContext *device_d3d11 = (AVD3D11VADeviceContext *)device_ctx->device_ctx->hwctx;
+ res = ctx->context->pVtbl->InitDX11(ctx->context, device_d3d11->device, AMF_DX11_1);
+ if (res == AMF_OK) {
+ ctx->hw_frames_ctx = av_buffer_ref(avctx->hw_frames_ctx);
+ } else {
+ av_log(avctx, AV_LOG_INFO, "amf_shared: avctx->hw_frames_ctx has non-AMD device, switching to default");
+ }
+
+ }
+ }
+ } else if (avctx->hw_device_ctx) {
+ AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)(avctx->hw_device_ctx->data);
+ if (device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) {
+ if (device_ctx->hwctx) {
+ AVD3D11VADeviceContext *device_d3d11 = (AVD3D11VADeviceContext *)device_ctx->hwctx;
+ res = ctx->context->pVtbl->InitDX11(ctx->context, device_d3d11->device, AMF_DX11_1);
+ if (res == AMF_OK) {
+ ctx->hw_device_ctx = av_buffer_ref(avctx->hw_device_ctx);
+ } else {
+ av_log(avctx, AV_LOG_INFO, "amf_shared: avctx->hw_device_ctx has non-AMD device, switching to default");
+ }
+ }
+ }
+ }
+
+ if (!ctx->hw_frames_ctx) {
+ res = ctx->context->pVtbl->InitDX11(ctx->context, 0, AMF_DX11_1);
+ if (res != AMF_OK) {
+ res = ctx->context->pVtbl->InitDX9(ctx->context, 0);
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, "InitDX9() failed with error %d", res);
+ }
+ }
+ return 0;
+}
+
+static int amf_init_encoder(AVCodecContext *avctx)
+{
+ AmfContext *ctx = avctx->priv_data;
+ const wchar_t *codec_id = 0;
+ AMF_RESULT res = AMF_OK;
+
+ switch (avctx->codec->id) {
+ case AV_CODEC_ID_H264:
+ codec_id = AMFVideoEncoderVCE_AVC;
+ break;
+ case AV_CODEC_ID_HEVC:
+ codec_id = AMFVideoEncoder_HEVC;
+ break;
+ default:
+ break;
+ }
+ AMF_RETURN_IF_FALSE(ctx, codec_id != 0, AVERROR(EINVAL), "Codec %d is not supported", avctx->codec->id);
+
+ ctx->format = amf_av_to_amf_format(avctx->pix_fmt);
+ AMF_RETURN_IF_FALSE(ctx, ctx->format != AMF_SURFACE_UNKNOWN, AVERROR(EINVAL), "Format %d is not supported", avctx->pix_fmt);
+
+ res = ctx->factory->pVtbl->CreateComponent(ctx->factory, ctx->context, codec_id, &ctx->encoder);
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_ENCODER_NOT_FOUND, "CreateComponent(%S) failed with error %d", codec_id, res);
+
+ ctx->eof = false;
+ return 0;
+}
+
+static int amf_terminate(AVCodecContext *avctx)
+{
+ AmfContext* ctx = avctx->priv_data;
+
+ if (ctx->encoder) {
+ ctx->encoder->pVtbl->Terminate(ctx->encoder);
+ ctx->encoder->pVtbl->Release(ctx->encoder);
+ ctx->encoder = 0;
+ }
+
+ if (ctx->context) {
+ ctx->context->pVtbl->Terminate(ctx->context);
+ ctx->context->pVtbl->Release(ctx->context);
+ ctx->context = 0;
+ }
+ if (ctx->hw_device_ctx){
+ av_buffer_unref(&ctx->hw_device_ctx);
+ ctx->hw_device_ctx = 0;
+ }
+ if (ctx->hw_frames_ctx) {
+ av_buffer_unref(&ctx->hw_frames_ctx);
+ ctx->hw_frames_ctx = 0;
+ }
+
+ if (ctx->trace) {
+ ctx->trace->pVtbl->UnregisterWriter(ctx->trace, FFMPEG_AMF_WRITER_ID);
+ }
+
+ if (ctx->library) {
+ dlclose(ctx->library);
+ ctx->library = 0;
+ }
+ ctx->trace = 0;
+ ctx->debug = 0;
+ ctx->factory = 0;
+ ctx->version = 0;
+
+ return 0;
+}
+
+static int amf_copy_surface(AVCodecContext *avctx, const AVFrame *frame,
+ AMFSurface* surface)
+{
+ AmfContext *ctx = avctx->priv_data;
+ AMFPlane *plane = 0;
+ uint8_t *dst_data[4];
+ int dst_linesize[4];
+
+ int planes = (int)surface->pVtbl->GetPlanesCount(surface);
+ AMF_RETURN_IF_FALSE(ctx, planes <= amf_countof(dst_data), AVERROR(EINVAL), "Invalid number of planes %d in surface", planes);
+
+ for (int i = 0; i < planes; i++) {
+ plane = surface->pVtbl->GetPlaneAt(surface, i);
+ dst_data[i] = plane->pVtbl->GetNative(plane);
+ dst_linesize[i] = plane->pVtbl->GetHPitch(plane);
+ }
+ av_image_copy(dst_data, dst_linesize,
+ (const uint8_t**)frame->data, frame->linesize, frame->format,
+ avctx->width, avctx->height);
+
+ surface->pVtbl->SetPts(surface, frame->pts);
+
+ return 0;
+}
+
+static int amf_copy_buffer(AVCodecContext *avctx, AVPacket *pkt, AMFBuffer *buffer)
+{
+ int ret = 0;
+ AMFVariantStruct var;
+ int size = (int)buffer->pVtbl->GetSize(buffer);
+
+ if (ret = ff_alloc_packet2(avctx, pkt, size, 0)) {
+ return ret;
+ }
+ memcpy(pkt->data, buffer->pVtbl->GetNative(buffer), size);
+
+ switch (avctx->codec->id) {
+ case AV_CODEC_ID_H264:
+ buffer->pVtbl->GetProperty(buffer, AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE, &var);
+ switch (var.int64Value) {
+ case AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_IDR:
+ pkt->flags = AV_PICTURE_TYPE_I | AV_PKT_FLAG_KEY;
+ break;
+ case AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_I:
+ pkt->flags = AV_PICTURE_TYPE_I;
+ break;
+ case AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_P:
+ pkt->flags = AV_PICTURE_TYPE_P;
+ break;
+ case AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE_B:
+ pkt->flags = AV_PICTURE_TYPE_B;
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unknown picture type encountered, expect the output to be broken.\n");
+ break;
+ }
+ break;
+ case AV_CODEC_ID_HEVC:
+ buffer->pVtbl->GetProperty(buffer, AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE, &var);
+ switch (var.int64Value) {
+ case AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE_IDR:
+ pkt->flags = AV_PICTURE_TYPE_I | AV_PKT_FLAG_KEY;
+ break;
+ case AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE_I:
+ pkt->flags = AV_PICTURE_TYPE_I | AV_PKT_FLAG_KEY;
+ break;
+ case AMF_VIDEO_ENCODER_HEVC_OUTPUT_DATA_TYPE_P:
+ pkt->flags = AV_PICTURE_TYPE_P;
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unknown picture type encountered, expect the output to be broken.\n");
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ pkt->pts = buffer->pVtbl->GetPts(buffer);
+ pkt->dts = pkt->pts;
+ return 0;
+}
+
+// amfenc API implmentation
+int ff_amf_encode_init(AVCodecContext *avctx)
+{
+ AmfContext *ctx = avctx->priv_data;
+ int ret = 0;
+
+ ctx->factory = 0;
+ ctx->debug = 0;
+ ctx->trace = 0;
+ ctx->context = 0;
+ ctx->encoder = 0;
+ ctx->library = 0;
+ ctx->version = 0;
+ ctx->eof = 0;
+ ctx->format = 0;
+ ctx->tracer.vtbl = 0;
+ ctx->tracer.avctx = 0;
+
+ if ((ret = amf_load_library(avctx)) == 0) {
+ if ((ret = amf_init_context(avctx)) == 0) {
+ if ((ret = amf_init_encoder(avctx)) == 0) {
+ return 0;
+ }
+ }
+ }
+ amf_terminate(avctx);
+ return ret;
+}
+
+int av_cold ff_amf_encode_close(AVCodecContext *avctx)
+{
+ int ret = 0;
+ ret = amf_terminate(avctx);
+ return ret;
+}
+
+static GUID AMFTextureArrayIndexGUID =
+{ 0x28115527, 0xe7c3, 0x4b66, { 0x99, 0xd3, 0x4f, 0x2a, 0xe6, 0xb4, 0x7f, 0xaf } };
+
+int ff_amf_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *frame, int *got_packet)
+{
+ int ret = 0;
+ AMF_RESULT res = AMF_OK;
+ AmfContext *ctx = avctx->priv_data;
+ AMFSurface *surface = 0;
+ AMFData *data = 0;
+ amf_bool submitted = false;
+
+ while (!submitted) {
+ if (!frame) { // submit drain
+ if (!ctx->eof) { // submit drain onre time only
+ res = ctx->encoder->pVtbl->Drain(ctx->encoder);
+ if (res == AMF_INPUT_FULL) {
+ av_usleep(1000); // input queue is full: wait, poll and submit Drain again
+ // need to get some output and try again
+ } else if (res == AMF_OK) {
+ ctx->eof = true; // drain started
+ submitted = true;
+ }
+ }
+ } else { // submit frame
+ if (surface == 0) { // prepare surface from frame one time only
+ if (frame->hw_frames_ctx && ( // HW frame detected
+ // check if the same hw_frames_ctx as used in initialization
+ (ctx->hw_frames_ctx && frame->hw_frames_ctx->data == ctx->hw_frames_ctx->data) ||
+ // check if the same hw_device_ctx as used in initialization
+ (ctx->hw_device_ctx && ((AVHWFramesContext*)frame->hw_frames_ctx->data)->device_ctx ==
+ (AVHWDeviceContext*)ctx->hw_device_ctx->data)
+ )) {
+ ID3D11Texture2D* texture = (ID3D11Texture2D*)frame->data[0]; // actual texture
+ int index = (int)(size_t)frame->data[1]; // index is a slice in texture array is - set to tell AMF which slice to use
+ texture->lpVtbl->SetPrivateData(texture, &AMFTextureArrayIndexGUID, sizeof(index), &index);
+
+ res = ctx->context->pVtbl->CreateSurfaceFromDX11Native(ctx->context, texture, &surface, NULL); // wrap to AMF surface
+ surface->pVtbl->SetCrop(surface, 0, 0, frame->width, frame->height); // decode surfaces are vertically aligned by 16 tell AMF real size
+ surface->pVtbl->SetPts(surface, frame->pts);
+ } else {
+ res = ctx->context->pVtbl->AllocSurface(ctx->context, AMF_MEMORY_HOST, ctx->format, avctx->width, avctx->height, &surface);
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_BUG, "AllocSurface() failed with error %d", res);
+ amf_copy_surface(avctx, frame, surface);
+ }
+ }
+ // encode
+ res = ctx->encoder->pVtbl->SubmitInput(ctx->encoder, (AMFData*)surface);
+ if (res == AMF_INPUT_FULL) { // handle full queue
+ av_usleep(1000); // input queue is full: wait, poll and submit surface again
+ } else {
+ surface->pVtbl->Release(surface);
+ surface = NULL;
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, "SubmitInput() failed with error %d", res);
+ submitted = 1;
+ }
+ }
+ // poll results
+ if (!data) {
+ res = ctx->encoder->pVtbl->QueryOutput(ctx->encoder, &data);
+ if (data) {
+ AMFBuffer* buffer;
+ AMFGuid guid = IID_AMFBuffer();
+ data->pVtbl->QueryInterface(data, &guid, (void**)&buffer); // query for buffer interface
+ ret = amf_copy_buffer(avctx, pkt, buffer);
+ if (!ret)
+ *got_packet = 1;
+ buffer->pVtbl->Release(buffer);
+ data->pVtbl->Release(data);
+ if (ctx->eof) {
+ submitted = true; // we are in the drain state - no submissions
+ }
+ } else if (res == AMF_EOF) {
+ submitted = true; // drain complete
+ } else {
+ if (!submitted) {
+ av_usleep(1000); // wait and poll again
+ }
+ }
+ }
+ }
+ return ret;
+}
diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h
new file mode 100644
index 0000000..a9da597
--- /dev/null
+++ b/libavcodec/amfenc.h
@@ -0,0 +1,129 @@
+/*
+* This file is part of FFmpeg.
+*
+* FFmpeg 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.
+*
+* FFmpeg 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 FFmpeg; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef AVCODEC_AMFENC_H
+#define AVCODEC_AMFENC_H
+
+#include "config.h"
+#include "avcodec.h"
+#include "compat/amd/amf/public/include/core/Factory.h"
+
+/**
+* AMF trace writer callback class
+* Used to capture all AMF logging
+*/
+
+typedef struct AmfTraceWriter {
+ AMFTraceWriterVtbl* vtbl;
+ AVCodecContext *avctx;
+} AmfTraceWriter;
+
+/**
+* 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_bool eof; ///< 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)
+
+ /** common encoder option options */
+
+ /** Static options, have to be set before Init() call */
+ int usage;
+ int profile;
+ int level;
+ int preanalysis;
+ int quality;
+ int b_frame_delta_qp;
+ int ref_b_frame_delta_qp;
+
+ /** Dynamic options, can be set after Init() call */
+
+ int rate_control_mode;
+ int enforce_hrd;
+ int filler_data;
+ int enable_vbaq;
+ int skip_frame;
+ int qp_i;
+ int qp_p;
+ int qp_b;
+ int max_au_size;
+ int header_spacing;
+ int b_frame_ref;
+ int intra_refresh_mb;
+ int slices;
+ int coding_mode;
+ int me_half_pel;
+ int me_quater_pel;
+
+ /** HEVC - specific options */
+
+ int gops_per_idr;
+ int header_insertion_mode;
+ int min_qp_i;
+ int max_qp_i;
+ int min_qp_p;
+ int max_qp_p;
+ int tier;
+} AmfContext;
+
+/**
+* Common encoder initization code
+*/
+int ff_amf_encode_init(AVCodecContext *avctx);
+/**
+* Common encoder termination code
+*/
+int ff_amf_encode_close(AVCodecContext *avctx);
+
+/**
+* Ecoding one frame - common for all AMF encoders
+*/
+int ff_amf_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *frame, int *got_packet);
+
+/**
+* Supported formats
+*/
+extern const enum AVPixelFormat ff_amf_pix_fmts[];
+
+/**
+* Error handling helper
+*/
+#define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*optional message,*/ ...) \
+ if (!(exp)) { \
+ av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
+ return AVERROR(ret_value); \
+ }
+
+#endif //AVCODEC_AMFENC_H
\ No newline at end of file
diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
new file mode 100644
index 0000000..30884a1
--- /dev/null
+++ b/libavcodec/amfenc_h264.c
@@ -0,0 +1,467 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "amfenc.h"
+#include "compat/amd/amf/public/include/components/VideoEncoderVCE.h"
+#include "libavutil/opt.h"
+#include "libavutil/internal.h"
+#include "internal.h"
+
+#define OFFSET(x) offsetof(AmfContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+
+static const AVOption options[] = {
+ // Static
+ /// Usage
+ { "usage", "Encoder Usage", OFFSET(usage), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_USAGE_TRANSCONDING }, AMF_VIDEO_ENCODER_USAGE_TRANSCONDING, AMF_VIDEO_ENCODER_USAGE_WEBCAM, VE, "usage" },
+ { "transcoding", "Generic Transcoding", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_TRANSCONDING }, 0, 0, VE, "usage" },
+ { "ultralowlatency","", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_ULTRA_LOW_LATENCY }, 0, 0, VE, "usage" },
+ { "lowlatency", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY }, 0, 0, VE, "usage" },
+ { "webcam", "Webcam", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_WEBCAM }, 0, 0, VE, "usage" },
+
+ /// Profile,
+ { "profile", "Profile", OFFSET(profile),AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_PROFILE_MAIN }, AMF_VIDEO_ENCODER_PROFILE_BASELINE, AMF_VIDEO_ENCODER_PROFILE_HIGH, VE, "profile" },
+ { "baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_BASELINE }, 0, 0, VE, "profile" },
+ { "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_MAIN }, 0, 0, VE, "profile" },
+ { "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_HIGH }, 0, 0, VE, "profile" },
+
+ /// Profile Level
+ { "level", "Profile Level", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 62, VE, "level" },
+ { "auto", "", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "level" },
+ { "1.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 10 }, 0, 0, VE, "level" },
+ { "1.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 11 }, 0, 0, VE, "level" },
+ { "1.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 12 }, 0, 0, VE, "level" },
+ { "1.3", "", 0, AV_OPT_TYPE_CONST, { .i64 = 13 }, 0, 0, VE, "level" },
+ { "2.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 20 }, 0, 0, VE, "level" },
+ { "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 21 }, 0, 0, VE, "level" },
+ { "2.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 22 }, 0, 0, VE, "level" },
+ { "3.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 30 }, 0, 0, VE, "level" },
+ { "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 31 }, 0, 0, VE, "level" },
+ { "3.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 32 }, 0, 0, VE, "level" },
+ { "4.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 40 }, 0, 0, VE, "level" },
+ { "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 41 }, 0, 0, VE, "level" },
+ { "4.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 42 }, 0, 0, VE, "level" },
+ { "5.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 50 }, 0, 0, VE, "level" },
+ { "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 51 }, 0, 0, VE, "level" },
+ { "5.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 52 }, 0, 0, VE, "level" },
+ { "6.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 60 }, 0, 0, VE, "level" },
+ { "6.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 61 }, 0, 0, VE, "level" },
+ { "6.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 62 }, 0, 0, VE, "level" },
+
+
+ /// Quality Preset
+ { "quality", "Quality Preference", OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_QUALITY_PRESET_SPEED }, AMF_VIDEO_ENCODER_QUALITY_PRESET_BALANCED, AMF_VIDEO_ENCODER_QUALITY_PRESET_QUALITY, VE, "quality" },
+ { "speed", "Prefer Speed", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_QUALITY_PRESET_SPEED }, 0, 0, VE, "quality" },
+ { "balanced", "Balanced", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_QUALITY_PRESET_BALANCED }, 0, 0, VE, "quality" },
+ { "quality", "Prefer Quality", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_QUALITY_PRESET_QUALITY }, 0, 0, VE, "quality" },
+
+ // Dynamic
+ /// Rate Control Method
+ { "rc", "Rate Control Method", OFFSET(rate_control_mode), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR }, AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP, AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR, VE, "rc" },
+ { "cqp", "Constant Quantization Parameter", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP }, 0, 0, VE, "rc" },
+ { "cbr", "Constant Bitrate", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CBR }, 0, 0, VE, "rc" },
+ { "vbr_peak", "Peak Contrained Variable Bitrate", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR }, 0, 0, VE, "rc" },
+ { "vbr_latency", "Latency Constrained Variable Bitrate", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR }, 0, 0, VE, "rc" },
+
+ /// Enforce HRD, Filler Data, VBAQ, Frame Skipping
+ { "enforce_hrd", "Enforce HRD", OFFSET(enforce_hrd), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE, NULL },
+ { "filler_data", "Filler Data Enable", OFFSET(filler_data), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE, NULL },
+ { "vbaq", "Enable VBAQ", OFFSET(enable_vbaq), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE, NULL },
+ { "frame_skipping", "Rate Control Based Frame Skip", OFFSET(skip_frame), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE, NULL },
+
+ /// QP Values
+ { "qp_i", "Quantization Parameter for I-Frame", OFFSET(qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
+ { "qp_p", "Quantization Parameter for P-Frame", OFFSET(qp_p), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
+ { "qp_b", "Quantization Parameter for B-Frame", OFFSET(qp_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
+
+ /// Pre-Pass, Pre-Analysis, Two-Pass
+ { "preanalysis", "Pre-Analysis Mode", OFFSET(preanalysis), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE, NULL },
+
+ /// Maximum Access Unit Size
+ { "max_au_size", "Maximum Access Unit Size (in bits)", OFFSET(max_au_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE, NULL },
+
+ /// Header Insertion Spacing
+ { "header_spacing", "Header Insertion Spacing", OFFSET(header_spacing), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1000, VE },
+
+ /// B-Frames
+ // BPicturesPattern=bf
+ { "bf_delta_qp", "B-Picture Delta QP", OFFSET(b_frame_delta_qp), AV_OPT_TYPE_INT, { .i64 = 4 }, -10, 10, VE, NULL },
+ { "bf_ref", "Enable Reference to B-Frames", OFFSET(b_frame_ref), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE, NULL },
+ { "bf_ref_delta_qp","Reference B-Picture Delta QP", OFFSET(ref_b_frame_delta_qp), AV_OPT_TYPE_INT, { .i64 = 4 }, -10, 10, VE, NULL },
+
+ /// Intra-Refresh
+ { "intra_refresh_mb","Intra Refresh MBs Number Per Slot in Macroblocks", OFFSET(intra_refresh_mb), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
+ { "slices", "Number of Slices per Frame", OFFSET(slices), AV_OPT_TYPE_INT, { .i64 = 1 } , 1, 8160, VE, NULL },
+
+ /// coder
+ { "coding", "Coding Type", OFFSET(coding_mode), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_UNDEFINED }, AMF_VIDEO_ENCODER_UNDEFINED, AMF_VIDEO_ENCODER_CALV, VE, "coding" },
+ { "auto", "Automatic", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_UNDEFINED }, 0, 0, VE, "coding" },
+ { "cavlc", "Context Adaptive Variable-Length Coding", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_CALV }, 0, 0, VE, "coding" },
+ { "cabac", "Context Adaptive Binary Arithmetic Coding", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_CABAC }, 0, 0, VE, "coding" },
+
+ { "me_half_pel", "Enable ME Half Pixel", OFFSET(me_half_pel), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE, NULL },
+ { "me_quater_pel", "Enable ME Quarter Pixel ", OFFSET(me_quater_pel), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE, NULL },
+
+ { NULL }
+};
+
+static av_cold int amf_encode_init_h264(AVCodecContext *avctx)
+{
+ int ret = 0;
+ AMF_RESULT res = AMF_OK;
+ AmfContext *ctx = avctx->priv_data;
+ AMFVariantStruct var = {0};
+ amf_int64 profile_level = 0;
+
+ AMFSize framesize = AMFConstructSize(avctx->width, avctx->height);
+ AMFRate framerate = AMFConstructRate(avctx->time_base.den, avctx->time_base.num * avctx->ticks_per_frame);
+
+ int deblocking_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
+
+ if ((ret = ff_amf_encode_init(avctx)) != 0)
+ return ret;
+
+ // Static parameters
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_USAGE, ctx->usage);
+
+ AMF_ASSIGN_PROPERTY_SIZE(res, ctx->encoder, AMF_VIDEO_ENCODER_FRAMESIZE, framesize);
+
+ AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_FRAMERATE, framerate);
+
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_PROFILE, ctx->profile);
+
+ profile_level = ctx->level;
+ if (profile_level == 0) {
+ // Automatic detection of correct profile level.
+ struct {
+ uint64_t max_samples;
+ uint64_t max_samples_per_sec;
+ int level;
+ } restrictions[] = {
+ { 25344, 380160, 10 },
+ { 101376, 768000, 11 },
+ { 101376, 1536000, 12 },
+ //{ 101376, 3041280, 13 }, // Backwards compatible 2.0
+ { 101376, 3041280, 20 },
+ { 202752, 5068800, 21 },
+ { 414720, 5184000, 22 },
+ { 414720, 10368000, 30 },
+ { 921600, 27648000, 31 },
+ { 1310720, 55296000, 32 },
+ //{ 2097152, 62914560, 40 }, // Backwards compatible 4.1
+ { 2097152, 62914560, 41 },
+ { 2228224, 133693440, 42 },
+ { 5652480, 150994994, 50 },
+ { 9437184, 251658240, 51 },
+ { 9437184, 530841600, 52 },
+ { 35651584, 1069547520, 60 },
+ { 35651584, 2139095040, 61 },
+ { 35651584, 4278190080, 62 },
+ { 0, 0, -1 }
+ };
+ uint64_t samples = framesize.width * framesize.height;
+ uint64_t samples_per_sec = (samples * framerate.num) / framerate.den;
+ profile_level = 52; // Default to 5.2 for now.
+ for (unsigned int index = 0; restrictions[index].level != -1; index++) {
+ if ((samples < restrictions[index].max_samples)
+ && (samples_per_sec < restrictions[index].max_samples_per_sec)) {
+ profile_level = restrictions[index].level;
+ break;
+ }
+ }
+ }
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_PROFILE_LEVEL, profile_level);
+
+ // Maximum Reference Frames
+ if (avctx->refs != -1) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_MAX_NUM_REFRAMES, avctx->refs);
+ }
+ if (avctx->sample_aspect_ratio.den && avctx->sample_aspect_ratio.num) {
+ AMFRatio ratio = AMFConstructRatio(avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
+ AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_ASPECT_RATIO, ratio);
+ }
+
+ /// Color Range (Partial/TV/MPEG or Full/PC/JPEG)
+ if (avctx->color_range == AVCOL_RANGE_JPEG) {
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FULL_RANGE_COLOR, 1);
+ }
+
+ if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_RATE_CONTROL_PREANALYSIS_ENABLE, false);
+ if (ctx->preanalysis)
+ av_log(ctx, AV_LOG_WARNING, "Pre-Analysis is not supported by cqp Rate Control Method, automatically disabled.");
+ } else {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_RATE_CONTROL_PREANALYSIS_ENABLE, ctx->preanalysis);
+ }
+
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_QUALITY_PRESET, ctx->quality);
+
+ // Initialize Encoder
+ res = ctx->encoder->pVtbl->Init(ctx->encoder, ctx->format, avctx->width, avctx->height);
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_BUG, "encoder->Init() failed with error %d", res);
+
+ // Dynamic parmaters
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD, ctx->rate_control_mode);
+
+ /// VBV Buffer
+ if (avctx->rc_buffer_size != 0)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_VBV_BUFFER_SIZE, avctx->rc_buffer_size);
+ if (avctx->rc_initial_buffer_occupancy != 0) {
+ int percent = avctx->rc_buffer_size * 64 / avctx->rc_initial_buffer_occupancy;
+ if (percent > 64)
+ percent = 64;
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_INITIAL_VBV_BUFFER_FULLNESS, percent);
+ }
+ /// Maximum Access Unit Size
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_MAX_AU_SIZE, ctx->max_au_size);
+
+
+ // QP Minimum / Maximum
+ if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_MIN_QP, 0);
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_MAX_QP, 51);
+ } else {
+ if (avctx->qmin != -1) {
+ int qval = avctx->qmin > 51 ? 51 : avctx->qmin;
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_MIN_QP, qval);
+ }
+ if (avctx->qmax != -1) {
+ int qval = avctx->qmax > 51 ? 51 : avctx->qmax;
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_MAX_QP, qval);
+ }
+ }
+ // QP Values
+ if (ctx->qp_i != -1)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_QP_I, ctx->qp_i);
+ if (ctx->qp_p != -1)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_QP_P, ctx->qp_p);
+ if (ctx->qp_b != -1)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_QP_B, ctx->qp_b);
+
+ // Bitrate
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_TARGET_BITRATE, avctx->bit_rate);
+ if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CBR) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_PEAK_BITRATE, avctx->bit_rate);
+ } else {
+ int rc_max_rate = avctx->rc_max_rate >= avctx->bit_rate ? avctx->rc_max_rate : avctx->bit_rate * 13 / 10;
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_PEAK_BITRATE, rc_max_rate);
+ }
+ // Enforce HRD, Filler Data, VBAQ, Frame Skipping, Deblocking Filter
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_ENFORCE_HRD, !!ctx->enforce_hrd);
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FILLER_DATA_ENABLE, !!ctx->filler_data);
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_RATE_CONTROL_SKIP_FRAME_ENABLE, !!ctx->skip_frame);
+ if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP) {
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_ENABLE_VBAQ, false);
+ if (ctx->enable_vbaq)
+ av_log(ctx, AV_LOG_WARNING, "VBAQ is not supported by cqp Rate Control Method, automatically disabled.");
+ } else {
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_ENABLE_VBAQ, !!ctx->enable_vbaq);
+ }
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_DE_BLOCKING_FILTER, !!deblocking_filter);
+
+ // B-Frames
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_B_PIC_PATTERN, avctx->max_b_frames);
+ if (avctx->max_b_frames && res == AMF_OK) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_B_PIC_DELTA_QP, ctx->b_frame_delta_qp);
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_B_REFERENCE_ENABLE, !!ctx->b_frame_ref);
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_REF_B_PIC_DELTA_QP, ctx->ref_b_frame_delta_qp);
+ }
+
+ // Keyframe Interval
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_IDR_PERIOD, avctx->gop_size);
+
+ // Header Insertion Spacing
+ if (ctx->header_spacing >= 0)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEADER_INSERTION_SPACING, ctx->header_spacing);
+
+ // Intra-Refresh, Slicing
+ if (ctx->intra_refresh_mb > 0)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_INTRA_REFRESH_NUM_MBS_PER_SLOT, ctx->intra_refresh_mb);
+ if (ctx->slices > 1)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_SLICES_PER_FRAME, ctx->slices);
+
+ // Coding
+ if (ctx->coding_mode != 0)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_CABAC_ENABLE, ctx->coding_mode);
+
+ // Motion Estimation
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_MOTION_HALF_PIXEL, !!ctx->me_half_pel);
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_MOTION_QUARTERPIXEL, !!ctx->me_quater_pel);
+
+ // fill extradata
+ AMFVariantInit(&var);
+ res = ctx->encoder->pVtbl->GetProperty(ctx->encoder, AMF_VIDEO_ENCODER_EXTRADATA, &var);
+ if (res == AMF_OK && var.pInterface) {
+ AMFBuffer* buffer;
+ AMFGuid guid = IID_AMFBuffer();
+
+ var.pInterface->pVtbl->QueryInterface(var.pInterface, &guid, (void**)&buffer); // query for buffer interface
+
+ avctx->extradata_size = (int)buffer->pVtbl->GetSize(buffer);
+ avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!avctx->extradata) {
+ buffer->pVtbl->Release(buffer);
+ var.pInterface->pVtbl->Release(var.pInterface);
+ return AVERROR(ENOMEM);
+ }
+ memcpy(avctx->extradata, buffer->pVtbl->GetNative(buffer), avctx->extradata_size);
+
+ buffer->pVtbl->Release(buffer);
+ var.pInterface->pVtbl->Release(var.pInterface);
+ }
+ return 0;
+}
+
+
+
+static const AVCodecDefault defaults[] = {
+ { "refs", "-1" },
+ { "aspect", "0" },
+ { "sar", "0" },
+ { "qmin", "-1" },
+ { "qmax", "-1" },
+ { "b", "2M" },
+ { "maxrate", "3M" },
+ { "g", "250" },
+ { "keyint_min", "0" },
+ { "bf", "0" },
+ { "slices", "1" },
+ { NULL },
+};
+
+static const AVClass h264_amf_class = {
+ .class_name = "h264_amf",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+static const AVClass h264_amf_d3d11va_class = {
+ .class_name = "h264_amf_d3d11va",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+// regular encoder
+AVCodec ff_h264_amf_encoder = {
+ .name = "h264_amf",
+ .long_name = NULL_IF_CONFIG_SMALL("AMD AMF H.264 Encoder"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_H264,
+ .init = amf_encode_init_h264,
+ .encode2 = ff_amf_encode_frame,
+ .close = ff_amf_encode_close,
+ .priv_data_size = sizeof(AmfContext),
+ .priv_class = &h264_amf_class,
+ .defaults = defaults,
+ .capabilities = AV_CODEC_CAP_DELAY,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+ .pix_fmts = ff_amf_pix_fmts,
+};
+// encoder connected with D3D11 HW accelerator
+AVCodec ff_h264_amf_d3d11va_encoder = {
+ .name = "h264_amf_d3d11va",
+ .long_name = NULL_IF_CONFIG_SMALL("AMD AMF H.264 Encoder with d3d11va"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_H264,
+ .init = amf_encode_init_h264,
+ .encode2 = ff_amf_encode_frame,
+ .close = ff_amf_encode_close,
+ .priv_data_size = sizeof(AmfContext),
+ .priv_class = &h264_amf_d3d11va_class,
+ .defaults = defaults,
+ .capabilities = AV_CODEC_CAP_DELAY,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+ .pix_fmts = ff_amf_pix_fmts,
+};
+
+/**
+* Basic test BAT file:
+echo off
+if "%~1"=="" (
+echo input file name is empty. Use basic_transcode_amf_h264.bat video.mp4
+goto error
+)
+
+SET "CWD=%~dp0"
+SET bitrate=5M
+SET maxbitrate=6M
+SET bufsize=2M
+SET x264_preset=veryfast
+SET amf_quality=speed
+
+
+rem veryfast and zerolatency options make x264 comparable with VCE
+
+rem change path to ffmpeg.exe if needed
+
+"%CWD%\..\bin\ffmpeg.exe" -y -t 100 -threads 0 -i "%~1" -c:v h264_amf -b:v %bitrate% -maxrate %maxbitrate% -bufsize %bufsize% -rc vbr_peak -quality %amf_quality% out_amf_h264.mp4
+"%CWD%\..\bin\ffmpeg.exe" -y -t 100 -threads 0 -i "%~1" -c:v libx264 -b:v %bitrate% -maxrate %maxbitrate% -bufsize %bufsize% -preset %x264_preset% -nal-hrd vbr -tune zerolatency out_x264_h264.mp4
+
+echo PSNR > result.txt
+
+"%CWD%\..\bin\ffmpeg.exe" -y -hide_banner -loglevel info -t 100 -threads 0 -i "%~1" -i out_amf_h264.mp4 -lavfi psnr="stats_file='amf_h264.psnr.log'" -f null - > "trace.txt" 2>&1
+for /f "tokens=*" %%A in ('type "trace.txt"') do @echo amf_h264 : %%A >end.txt
+type end.txt >> result.txt
+
+
+"%CWD%\..\bin\ffmpeg.exe" -y -hide_banner -loglevel info -t 100 -threads 0 -i "%~1" -i out_x264_h264.mp4 -lavfi psnr="stats_file='x264_h264.psnr.log'" -f null - > "trace.txt" 2>&1
+for /f "tokens=*" %%A in ('type "trace.txt"') do @echo x264_h264: %%A >end.txt
+type end.txt >> result.txt
+
+
+echo SSIM >> result.txt
+
+"%CWD%\..\bin\ffmpeg.exe" -y -hide_banner -loglevel info -t 100 -threads 0 -i "%~1" -i out_amf_h264.mp4 -lavfi ssim="stats_file='amf_h264_ssim.log'" -f null - > "trace.txt" 2>&1
+for /f "tokens=*" %%A in ('type "trace.txt"') do @echo amf_h264 : %%A >end.txt
+type end.txt >> result.txt
+
+"%CWD%\..\bin\ffmpeg.exe" -y -hide_banner -loglevel info -t 100 -threads 0 -i "%~1" -i out_x264_h264.mp4 -lavfi ssim="stats_file=x264_h264_ssim.log'" -f null - > "trace.txt" 2>&1
+for /f "tokens=*" %%A in ('type "trace.txt"') do @echo x264_h264: %%A >end.txt
+type end.txt >> result.txt
+
+del trace.txt
+del end.txt
+
+echo
+type result.txt
+
+
+:error
+*/
+
+
+/**
+* d3d11va integration test bat file
+rem echo off
+if "%~1"=="" (
+echo input file name is empty. Use dx11_transcode_amf_h264.bat video.mp4
+goto error
+)
+
+SET "CWD=%~dp0"
+SET bitrate=5M
+SET maxbitrate=6M
+SET bufsize=2M
+
+rem change path to ffmpeg.exe if needed
+
+"%CWD%\..\bin\ffmpeg.exe" -y -t 100 -hwaccel d3d11va -hwaccel_output_format d3d11 -threads 1 -i "%~1" -c:v h264_amf -b:v %bitrate% -maxrate %maxbitrate% -bufsize %bufsize% -rc vbr_peak shared_dx11_amf_h264.mp4
+"%CWD%\..\bin\ffmpeg.exe" -y -t 100 -hwaccel d3d11va -threads 1 -i "%~1" -c:v h264_amf_d3d11va -b:v %bitrate% -maxrate %maxbitrate% -bufsize %bufsize% -rc vbr_peak custom_dx11_amf_h264.mp4
+
+*/
+
diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c
new file mode 100644
index 0000000..7512ea1
--- /dev/null
+++ b/libavcodec/amfenc_hevc.c
@@ -0,0 +1,354 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "amfenc.h"
+#include "compat/amd/amf/public/include/components/VideoEncoderHEVC.h"
+#include "libavutil/opt.h"
+#include "libavutil/internal.h"
+#include "internal.h"
+
+#define OFFSET(x) offsetof(AmfContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "usage", "Set the encoding usage", OFFSET(usage), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCONDING }, AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCONDING, AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM, VE, "usage" },
+ { "transcoding", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCONDING }, 0, 0, VE, "usage" },
+ { "ultralowlatency","", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_ULTRA_LOW_LATENCY }, 0, 0, VE, "usage" },
+ { "lowlatency", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY }, 0, 0, VE, "usage" },
+ { "webcam", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM }, 0, 0, VE, "usage" },
+
+ { "profile", "Set the profile (default main)", OFFSET(profile), AV_OPT_TYPE_INT,{ .i64 = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN }, AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN, AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN, VE, "profile" },
+ { "main", "", 0, AV_OPT_TYPE_CONST,{ .i64 = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN }, 0, 0, VE, "profile" },
+
+ { "profile_tier", "Set the profile tier (default main)", OFFSET(tier), AV_OPT_TYPE_INT,{ .i64 = AMF_VIDEO_ENCODER_HEVC_TIER_MAIN }, AMF_VIDEO_ENCODER_HEVC_TIER_MAIN, AMF_VIDEO_ENCODER_HEVC_TIER_HIGH, VE, "tier" },
+ { "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_TIER_MAIN }, 0, 0, VE, "tier" },
+ { "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_TIER_HIGH }, 0, 0, VE, "tier" },
+
+ { "level", "Set the encoding level (default auto)", OFFSET(level), AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, AMF_LEVEL_6_2, VE, "level" },
+ { "auto", "", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "level" },
+ { "1.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_1 }, 0, 0, VE, "level" },
+ { "2.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_2 }, 0, 0, VE, "level" },
+ { "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_2_1 }, 0, 0, VE, "level" },
+ { "3.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_3 }, 0, 0, VE, "level" },
+ { "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_3_1 }, 0, 0, VE, "level" },
+ { "4.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_4 }, 0, 0, VE, "level" },
+ { "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_4_1 }, 0, 0, VE, "level" },
+ { "5.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_5 }, 0, 0, VE, "level" },
+ { "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_5_1 }, 0, 0, VE, "level" },
+ { "5.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_5_2 }, 0, 0, VE, "level" },
+ { "6.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_6 }, 0, 0, VE, "level" },
+ { "6.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_6_1 }, 0, 0, VE, "level" },
+ { "6.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_LEVEL_6_2 }, 0, 0, VE, "level" },
+
+ { "quality", "Set the encoding quality", OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_SPEED }, AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_QUALITY, AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_SPEED, VE, "quality" },
+ { "balanced", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_BALANCED }, 0, 0, VE, "quality" },
+ { "speed", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_SPEED }, 0, 0, VE, "quality" },
+ { "quality", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_QUALITY }, 0, 0, VE, "quality" },
+
+ { "rc", "Set the rate control mode", OFFSET(rate_control_mode), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR }, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CBR, VE, "rc" },
+ { "cqp", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP }, 0, 0, VE, "rc" },
+ { "cbr", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CBR }, 0, 0, VE, "rc" },
+ { "vbr_peak", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR }, 0, 0, VE, "rc" },
+ { "vbr_latency", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR }, 0, 0, VE, "rc" },
+
+
+ { "header_insertion_mode", "Set header insertion mode", OFFSET(header_insertion_mode), AV_OPT_TYPE_INT,{ .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_NONE }, AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_NONE, AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_IDR_ALIGNED, VE, "hdrmode" },
+ { "balanced", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_NONE }, 0, 0, VE, "hdrmode" },
+ { "speed", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_GOP_ALIGNED }, 0, 0, VE, "hdrmode" },
+ { "quality", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_IDR_ALIGNED }, 0, 0, VE, "hdrmode" },
+
+ { "gops_per_idr", "GOPs per IDR 0-no IDR will be inserted", OFFSET(gops_per_idr), AV_OPT_TYPE_INT,{ .i64 = 60 }, 0, INT_MAX, VE },
+ { "preanalysis", "Enable preanalysis", OFFSET(preanalysis), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE, NULL },
+ { "vbaq", "Enable VBAQ", OFFSET(enable_vbaq), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE, NULL },
+ { "enforce_hrd", "Enforce HRD", OFFSET(enforce_hrd), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE, NULL },
+ { "filler_data", "Filler Data Enable", OFFSET(filler_data), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE, NULL },
+ { "max_au_size", "Max AU Size in bits", OFFSET(max_au_size), AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX, VE, NULL },
+ { "min_qp_i", "min quantization parameter for I-frame", OFFSET(min_qp_i), AV_OPT_TYPE_INT,{ .i64 = -1 }, -1, 51, VE },
+ { "max_qp_i", "max quantization parameter for I-frame", OFFSET(max_qp_i), AV_OPT_TYPE_INT,{ .i64 = -1 }, -1, 51, VE },
+ { "min_qp_p", "min quantization parameter for P-frame", OFFSET(min_qp_p), AV_OPT_TYPE_INT,{ .i64 = -1 }, -1, 51, VE },
+ { "max_qp_p", "max quantization parameter for P-frame", OFFSET(max_qp_p), AV_OPT_TYPE_INT,{ .i64 = -1 }, -1, 51, VE },
+ { "qp_p", "quantization parameter for P-frame", OFFSET(qp_p), AV_OPT_TYPE_INT,{ .i64 = -1 }, -1, 51, VE },
+ { "qp_i", "quantization parameter for I-frame", OFFSET(qp_i), AV_OPT_TYPE_INT,{ .i64 = -1 }, -1, 51, VE },
+ { "skip_frame", "Rate Control Based Frame Skip", OFFSET(skip_frame), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE, NULL },
+ { "me_half_pel", "Enable ME Half Pixel", OFFSET(me_half_pel), AV_OPT_TYPE_BOOL,{ .i64 = 1 }, 0, 1, VE, NULL },
+ { "me_quater_pel", "Enable ME Quarter Pixel ", OFFSET(me_quater_pel), AV_OPT_TYPE_BOOL,{ .i64 = 1 }, 0, 1, VE, NULL },
+
+ { NULL }
+};
+
+static av_cold int amf_encode_init_hevc(AVCodecContext *avctx)
+{
+ int ret = 0;
+ AMF_RESULT res = AMF_OK;
+ AmfContext *ctx = avctx->priv_data;
+ AMFVariantStruct var = {0};
+
+ AMFSize framesize = AMFConstructSize(avctx->width, avctx->height);
+ AMFRate framerate = AMFConstructRate(avctx->time_base.den, avctx->time_base.num * avctx->ticks_per_frame);
+
+ int deblocking_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
+
+ if ((ret = ff_amf_encode_init(avctx)) < 0)
+ return ret;
+
+ // init static parameters
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_USAGE, ctx->usage);
+
+ AMF_ASSIGN_PROPERTY_SIZE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FRAMESIZE, framesize);
+
+ AMF_ASSIGN_PROPERTY_RATE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FRAMERATE, framerate);
+
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PROFILE, ctx->profile);
+
+ switch (ctx->profile) {
+ case AMF_VIDEO_ENCODER_HEVC_TIER_HIGH:
+ avctx->profile = FF_PROFILE_HEVC_REXT;
+ break;
+ case AMF_VIDEO_ENCODER_HEVC_TIER_MAIN:
+ avctx->profile = FF_PROFILE_HEVC_MAIN;
+ break;
+ default:
+ break;
+ }
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_TIER, ctx->tier);
+
+ if (ctx->level != 0) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PROFILE_LEVEL, ctx->level);
+ avctx->level = ctx->level;
+ }
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET, ctx->quality);
+ // Maximum Reference Frames
+ if (avctx->refs != 0) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_NUM_REFRAMES, avctx->refs);
+ }
+ // Aspect Ratio
+ if (avctx->sample_aspect_ratio.den && avctx->sample_aspect_ratio.num) {
+ AMFRatio ratio = AMFConstructRatio(avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
+ AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ASPECT_RATIO, ratio);
+ }
+
+ // Picture control properties
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_NUM_GOPS_PER_IDR, ctx->gops_per_idr);
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_GOP_SIZE, avctx->gop_size);
+ if (avctx->slices > 1) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_SLICES_PER_FRAME, avctx->slices);
+ }
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_DE_BLOCKING_FILTER_DISABLE, deblocking_filter);
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE, ctx->header_insertion_mode);
+
+ // Rate control
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD, ctx->rate_control_mode);
+ if (avctx->rc_buffer_size)
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_VBV_BUFFER_SIZE, avctx->rc_buffer_size);
+
+ if (avctx->rc_initial_buffer_occupancy != 0) {
+ int percent = avctx->rc_buffer_size * 64 / avctx->rc_initial_buffer_occupancy;
+ if (percent > 64)
+ percent = 64;
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_INITIAL_VBV_BUFFER_FULLNESS, percent);
+ }
+ // Pre-Pass, Pre-Analysis, Two-Pass
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_PREANALYSIS_ENABLE, ctx->preanalysis);
+
+ if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP) {
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ENABLE_VBAQ, false);
+ if (ctx->enable_vbaq)
+ av_log(ctx, AV_LOG_WARNING, "VBAQ is not supported by cqp Rate Control Method, automatically disabled.");
+ } else {
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ENABLE_VBAQ, !!ctx->enable_vbaq);
+ }
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MOTION_HALF_PIXEL, ctx->me_half_pel);
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MOTION_QUARTERPIXEL, ctx->me_quater_pel);
+
+ // init encoder
+ res = ctx->encoder->pVtbl->Init(ctx->encoder, ctx->format, avctx->width, avctx->height);
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_BUG, "encoder->Init() failed with error %d", res);
+
+ // init dynamic rate control params
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ENFORCE_HRD, ctx->enforce_hrd);
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_FILLER_DATA_ENABLE, ctx->filler_data);
+
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_TARGET_BITRATE, avctx->bit_rate);
+ if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CBR) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PEAK_BITRATE, avctx->bit_rate);
+ } else {
+ int rc_max_rate = avctx->rc_max_rate >= avctx->bit_rate ? avctx->rc_max_rate : avctx->bit_rate * 13 / 10;
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PEAK_BITRATE, rc_max_rate);
+ }
+
+ // init dynamic picture control params
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_AU_SIZE, ctx->max_au_size);
+
+
+ if (ctx->min_qp_i != -1) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MIN_QP_I, ctx->min_qp_i);
+ }
+ if (ctx->max_qp_i != -1) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_QP_I, ctx->max_qp_i);
+ }
+ if (ctx->min_qp_p != -1) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MIN_QP_P, ctx->min_qp_p);
+ }
+ if (ctx->max_qp_p != -1) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_QP_P, ctx->max_qp_p);
+ }
+
+ if (ctx->qp_p != -1) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QP_I, ctx->qp_p);
+ }
+ if (ctx->qp_i != -1) {
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QP_P, ctx->qp_i);
+ }
+ AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_SKIP_FRAME_ENABLE, ctx->skip_frame);
+
+
+ // fill extradata
+ AMFVariantInit(&var);
+ res = ctx->encoder->pVtbl->GetProperty(ctx->encoder, AMF_VIDEO_ENCODER_HEVC_EXTRADATA, &var);
+ if(res == AMF_OK && var.pInterface){
+ AMFBuffer* buffer;
+ AMFGuid guid = IID_AMFBuffer();
+
+ var.pInterface->pVtbl->QueryInterface(var.pInterface, &guid, (void**)&buffer); // query for buffer interface
+
+ avctx->extradata_size = (int)buffer->pVtbl->GetSize(buffer);
+ avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!avctx->extradata) {
+ buffer->pVtbl->Release(buffer);
+ var.pInterface->pVtbl->Release(var.pInterface);
+ return AVERROR(ENOMEM);
+ }
+ memcpy(avctx->extradata, buffer->pVtbl->GetNative(buffer), avctx->extradata_size);
+
+ buffer->pVtbl->Release(buffer);
+ var.pInterface->pVtbl->Release(var.pInterface);
+ }
+ return 0;
+}
+static const AVCodecDefault defaults[] = {
+ { "b", "2M" },
+ { "maxrate", "3M" },
+ { "qmin", "-1" },
+ { "qmax", "-1" },
+ { "qdiff", "-1" },
+ { "qblur", "-1" },
+ { "qcomp", "-1" },
+ { "g", "250" },
+ { "bf", "0" },
+ { NULL },
+};
+static const AVClass hevc_amf_class = {
+ .class_name = "hevc_amf",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+static const AVClass hevc_amf_amf_d3d11va_class = {
+ .class_name = "hevc_amf_amf_d3d11va",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+// regular encoder
+AVCodec ff_hevc_amf_encoder = {
+ .name = "hevc_amf",
+ .long_name = NULL_IF_CONFIG_SMALL("AMD AMF HEVC encoder"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_HEVC,
+ .init = amf_encode_init_hevc,
+ .encode2 = ff_amf_encode_frame,
+ .close = ff_amf_encode_close,
+ .priv_data_size = sizeof(AmfContext),
+ .priv_class = &hevc_amf_class,
+ .defaults = defaults,
+ .capabilities = AV_CODEC_CAP_DELAY,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+ .pix_fmts = ff_amf_pix_fmts,
+};
+// encoder connected with D3D11 HW accelerator
+AVCodec ff_hevc_amf_d3d11va_encoder = {
+.name = "hevc_amf_d3d11va",
+.long_name = NULL_IF_CONFIG_SMALL("AMD AMF HEVC encoder with d3d11va"),
+.type = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_HEVC,
+.init = amf_encode_init_hevc,
+.encode2 = ff_amf_encode_frame,
+.close = ff_amf_encode_close,
+.priv_data_size = sizeof(AmfContext),
+.priv_class = &hevc_amf_amf_d3d11va_class,
+.defaults = defaults,
+.capabilities = AV_CODEC_CAP_DELAY,
+.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+.pix_fmts = ff_amf_pix_fmts,
+};
+
+/**
+* Basic test BAT file:
+echo off
+if "%~1"=="" (
+echo input file name is empty. Use basic_transcode_amf_hevc.bat video.mp4
+goto error
+)
+
+SET "CWD=%~dp0"
+SET bitrate=5M
+SET maxbitrate=6M
+SET bufsize=2M
+SET x265_preset=veryfast
+SET amf_quality=speed
+
+
+rem veryfast and zerolatency options make x265 comparable with VCE
+
+rem change path to ffmpeg.exe if needed
+
+"%CWD%\..\bin\ffmpeg.exe" -y -t 100 -threads 0 -i "%~1" -c:v hevc_amf -b:v %bitrate% -maxrate %maxbitrate% -bufsize %bufsize% -rc vbr_peak -quality %amf_quality% out_amf_hevc.mp4
+"%CWD%\..\bin\ffmpeg.exe" -y -t 100 -threads 0 -i "%~1" -c:v libx265 -b:v %bitrate% -maxrate %maxbitrate% -bufsize %bufsize% -preset %x265_preset% -x265-params vbv-maxrate=6000:vbv-bufsize=2000 -tune zerolatency out_x265_hevc.mp4
+
+echo PSNR > result.txt
+
+"%CWD%\..\bin\ffmpeg.exe" -y -hide_banner -loglevel info -t 100 -threads 0 -i "%~1" -i out_amf_hevc.mp4 -lavfi psnr="stats_file='amf_hevc.psnr.log'" -f null - > "trace.txt" 2>&1
+for /f "tokens=*" %%A in ('type "trace.txt"') do @echo amf_hevc : %%A >end.txt
+type end.txt >> result.txt
+
+
+"%CWD%\..\bin\ffmpeg.exe" -y -hide_banner -loglevel info -t 100 -threads 0 -i "%~1" -i out_x265_hevc.mp4 -lavfi psnr="stats_file='x265_hevc.psnr.log'" -f null - > "trace.txt" 2>&1
+for /f "tokens=*" %%A in ('type "trace.txt"') do @echo x265_hevc: %%A >end.txt
+type end.txt >> result.txt
+
+
+echo SSIM >> result.txt
+
+"%CWD%\..\bin\ffmpeg.exe" -y -hide_banner -loglevel info -t 100 -threads 0 -i "%~1" -i out_amf_hevc.mp4 -lavfi ssim="stats_file='amf_hevc_ssim.log'" -f null - > "trace.txt" 2>&1
+for /f "tokens=*" %%A in ('type "trace.txt"') do @echo amf_hevc : %%A >end.txt
+type end.txt >> result.txt
+
+"%CWD%\..\bin\ffmpeg.exe" -y -hide_banner -loglevel info -t 100 -threads 0 -i "%~1" -i out_x265_hevc.mp4 -lavfi ssim="stats_file=x265_hevc_ssim.log'" -f null - > "trace.txt" 2>&1
+for /f "tokens=*" %%A in ('type "trace.txt"') do @echo x265_hevc: %%A >end.txt
+type end.txt >> result.txt
+
+del trace.txt
+del end.txt
+
+echo
+type result.txt
+
+
+:error
+
+
+*/
\ No newline at end of file
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 3008460..10d9ac4 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,8 +28,8 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 57
-#define LIBAVCODEC_VERSION_MINOR 106
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MINOR 107
+#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
--
2.8.3.windows.1
More information about the ffmpeg-devel
mailing list