33#include <AMF/core/Surface.h>
34#include <AMF/core/Trace.h>
37#include <AMF/core/VulkanAMF.h>
55#define FFMPEG_AMF_WRITER_ID L"ffmpeg_amf"
60 AMFVulkanDevice vk_dev;
81 const wchar_t *scope,
const wchar_t *
message)
100 writer->
avctx = avctx;
120typedef struct AVAMFFormatMap {
150 return AMF_SURFACE_UNKNOWN;
166 switch (color_space) {
169 return AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601;
171 return AMF_VIDEO_CONVERTER_COLOR_PROFILE_601;
176 return AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709;
178 return AMF_VIDEO_CONVERTER_COLOR_PROFILE_709;
184 return AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_2020;
186 return AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020;
191 return AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN;
197 if (!display_meta || !hdrmeta)
201 const unsigned int luma_den = 10000;
202 hdrmeta->maxMasteringLuminance =
204 hdrmeta->minMasteringLuminance =
209 const unsigned int chroma_den = 50000;
210 hdrmeta->redPrimary[0] =
212 hdrmeta->redPrimary[1] =
214 hdrmeta->greenPrimary[0] =
216 hdrmeta->greenPrimary[1] =
218 hdrmeta->bluePrimary[0] =
220 hdrmeta->bluePrimary[1] =
222 hdrmeta->whitePoint[0] =
224 hdrmeta->whitePoint[1] =
233 if (!light_meta || !hdrmeta)
236 hdrmeta->maxContentLightLevel = (amf_uint16)light_meta->
MaxCLL;
237 hdrmeta->maxFrameAverageLightLevel = (amf_uint16)light_meta->
MaxFALL;
248 if (!
frame || !hdrmeta)
255 mastering_display =
NULL;
262 content_light =
NULL;
265 if (!mastering_display && !content_light)
272 if (!hdrmeta || !
frame)
277 const int chroma_den = 50000;
278 const int luma_den = 10000;
284 av_make_q(hdrmeta->redPrimary[0], chroma_den);
286 av_make_q(hdrmeta->redPrimary[1], chroma_den);
289 av_make_q(hdrmeta->greenPrimary[0], chroma_den);
291 av_make_q(hdrmeta->greenPrimary[1], chroma_den);
294 av_make_q(hdrmeta->bluePrimary[0], chroma_den);
296 av_make_q(hdrmeta->bluePrimary[1], chroma_den);
302 av_make_q(hdrmeta->maxMasteringLuminance, luma_den);
304 av_make_q(hdrmeta->maxMasteringLuminance, luma_den);
308 if (hdrmeta->maxContentLightLevel) {
315 light->
MaxCLL = hdrmeta->maxContentLightLevel;
316 light->
MaxFALL = hdrmeta->maxFrameAverageLightLevel;
354 const void *hwconfig,
452 AMFSurface *surface = (AMFSurface*)(
data);
453 surface->pVtbl->Release(surface);
460 AMFSurface* surface = (AMFSurface*)
dst->data[0];
462 uint8_t *dst_data[4];
470 if (
dst->hw_frames_ctx->data != (uint8_t *)
ctx ||
src->format !=
ctx->sw_format)
477 res = amf_device_ctx->
context->pVtbl->AllocSurface(amf_device_ctx->
context, AMF_MEMORY_HOST,
format,
dst->width,
dst->height, &surface);
479 dst->data[0] = (uint8_t *)surface;
487 planes = (int)surface->pVtbl->GetPlanesCount(surface);
491 plane = surface->pVtbl->GetPlaneAt(surface,
i);
492 dst_data[
i] = plane->pVtbl->GetNative(plane);
493 dst_linesize[
i] = plane->pVtbl->GetHPitch(plane);
505 AMFSurface* surface = (AMFSurface*)
src->data[0];
507 const AMFGuid guid = IID_AMFSurface();
510 uint8_t *src_data[4];
518 if (
src->hw_frames_ctx->data != (uint8_t *)
ctx ||
dst->format !=
ctx->sw_format)
521 if (surface->pVtbl->GetMemoryType(surface) == AMF_MEMORY_HOST) {
522 surface->pVtbl->Acquire(surface);
525 ret = surface->pVtbl->Duplicate(surface, AMF_MEMORY_HOST, &
data);
528 ret =
data->pVtbl->QueryInterface(
data, &guid, (
void**)&surface);
533 planes = (int)surface->pVtbl->GetPlanesCount(surface);
537 plane = surface->pVtbl->GetPlaneAt(surface,
i);
538 src_data[
i] = plane->pVtbl->GetNative(plane);
539 src_linesize[
i] = plane->pVtbl->GetHPitch(plane);
542 src_data, src_linesize,
dst->format,
544 surface->pVtbl->Release(surface);
553 AMF_RESULT res = AMF_NOT_INITIALIZED;
567 res = amf_ctx->
factory->pVtbl->GetTrace(amf_ctx->
factory, &trace);
593 AMFContext *context = amf_ctx->
context;
594 AMFContext1 *context1 =
NULL;
595 AMFGuid guid1 = IID_AMFContext1();
596 void * device =
NULL;
600 AMFContext2 *context2 =
NULL;
608 static const AMFGuid guid2 = {
609 0x726241d3, 0xbd46, 0x4e90,
610 0x99, 0x68, 0x93, 0xe0, 0x7e, 0xa2, 0x98, 0x4d
615 return AMF_MEMORY_UNKNOWN;
618 if (
AMF_IFACE_CALL(context, QueryInterface, &guid2, (
void**)&context2) == AMF_OK)
624 return AMF_MEMORY_DX12;
628 return AMF_MEMORY_DX11;
631 return AMF_MEMORY_DX9;
634 if (
AMF_IFACE_CALL(context, QueryInterface, &guid1, (
void**)&context1) != AMF_OK)
635 return AMF_MEMORY_UNKNOWN;
640 return AMF_MEMORY_VULKAN;
642 return AMF_MEMORY_UNKNOWN;
648 AMFContext *context = amf_ctx->
context;
649 AMFContext1 *context1 =
NULL;
650 AMFGuid guid1 = IID_AMFContext1();
654 AMFContext2 *context2 =
NULL;
655 static const AMFGuid guid2 = {
656 0x726241d3, 0xbd46, 0x4e90,
657 0x99, 0x68, 0x93, 0xe0, 0x7e, 0xa2, 0x98, 0x4d
661 if (!amf_ctx->
lock) {
683 res =
AMF_IFACE_CALL(context, QueryInterface, &guid2, (
void**)&context2);
692 av_log(
ctx,
AV_LOG_VERBOSE,
"QueryInterface(AMFContext2) failed with error %d, trying older D3D APIs...\n", res);
701 av_log(
ctx,
AV_LOG_WARNING,
"AMF failed to initialize with any of supported versions of DirectX, trying Vulkan instead...\n");
704 res =
AMF_IFACE_CALL(context, QueryInterface, &guid1, (
void**)&context1);
716 if (res == AMF_NOT_SUPPORTED)
730 AMFQueryVersion_Fn version_fun;
733 amf_ctx->
library = dlopen(AMF_DLL_NAMEA, RTLD_NOW | RTLD_LOCAL);
737 init_fun = (AMFInit_Fn)dlsym(amf_ctx->
library, AMF_INIT_FUNCTION_NAME);
740 version_fun = (AMFQueryVersion_Fn)dlsym(amf_ctx->
library, AMF_QUERY_VERSION_FUNCTION_NAME);
747 res = init_fun(AMF_FULL_VERSION, &amf_ctx->
factory);
760 ret =
ctx->factory->pVtbl->GetTrace(
ctx->factory, &trace);
763 int level_amf = AMF_TRACE_TRACE;
764 amf_bool enable_log =
true;
768 level_amf = AMF_TRACE_ERROR;
774 level_amf = AMF_TRACE_ERROR;
778 level_amf = AMF_TRACE_WARNING;
781 level_amf = AMF_TRACE_INFO;
784 level_amf = AMF_TRACE_DEBUG;
787 level_amf = AMF_TRACE_TRACE;
790 if(
ctx->version == AMF_MAKE_FULL_VERSION(1, 4, 35, 0)){
791 level_amf = AMF_TRACE_WARNING;
794 trace->pVtbl->EnableWriter(trace, AMF_TRACE_WRITER_CONSOLE, 0);
795 trace->pVtbl->SetGlobalLevel(trace, level_amf);
802 trace->pVtbl->SetWriterLevel(trace, AMF_TRACE_WRITER_DEBUG_OUTPUT, level_amf);
803 trace->pVtbl->EnableWriter(trace, AMF_TRACE_WRITER_DEBUG_OUTPUT, enable_log);
807 ret =
ctx->factory->pVtbl->CreateContext(
ctx->factory, &
ctx->context);
809 AMF_ASSIGN_PROPERTY_INT64(
ret,
ctx->context,
L"DeviceSurfaceCacheSize", 50 );
822 IDirect3DDevice9 *device;
823 HANDLE device_handle;
828 hr = IDirect3DDeviceManager9_OpenDeviceHandle(hwctx->
devmgr, &device_handle);
830 av_log(child_device_ctx,
AV_LOG_ERROR,
"Failed to open device handle for Direct3D9 device: %lx.\n", (
unsigned long)hr);
834 hr = IDirect3DDeviceManager9_LockDevice(hwctx->
devmgr, device_handle, &device, FALSE);
836 IDirect3DDeviceManager9_UnlockDevice(hwctx->
devmgr, device_handle, FALSE);
839 av_log(child_device_ctx,
AV_LOG_ERROR,
"Failed to lock device handle for Direct3D9 device: %lx.\n", (
unsigned long)hr);
844 IDirect3DDeviceManager9_CloseDeviceHandle(hwctx->
devmgr, device_handle);
851 IDirect3DDevice9_Release(device);
853 if (res != AMF_OK && res != AMF_ALREADY_INITIALIZED) {
854 if (res == AMF_NOT_SUPPORTED)
855 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF via D3D9 is not supported on the given device.\n");
857 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF failed to initialise on given D3D9 device: %d.\n", res);
871 if (res != AMF_OK && res != AMF_ALREADY_INITIALIZED) {
872 if (res == AMF_NOT_SUPPORTED)
873 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF via D3D11 is not supported on the given device.\n");
875 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF failed to initialise on the given D3D11 device: %d.\n", res);
879 hwctx->
BindFlags |= D3D11_BIND_SHADER_RESOURCE;
889 AMFContext2 *context2 =
NULL;
890 AMFGuid guid = IID_AMFContext2();
891 res = amf_ctx->
context->pVtbl->QueryInterface(amf_ctx->
context, &guid, (
void**)&context2);
893 res = context2->pVtbl->InitDX12(context2, hwctx->
device, AMF_DX12);
894 context2->pVtbl->Release(context2);
895 if (res != AMF_OK && res != AMF_ALREADY_INITIALIZED) {
896 if (res == AMF_NOT_SUPPORTED)
897 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF via D3D12 is not supported on the given device.\n");
899 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF failed to initialise on the given D3D12 device: %d.\n", res);
908static int amf_vk_ext_enabled(
const char *
const *exts,
int nb_exts,
const char *
name)
910 for (
int i = 0;
i < nb_exts;
i++)
911 if (!strcmp(exts[
i],
name))
919 static const struct {
922 } required_exts[] = {
923 { VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, 0 },
924 { VK_KHR_SURFACE_EXTENSION_NAME, 0 },
925 { VK_KHR_SWAPCHAIN_EXTENSION_NAME, 1 },
930 int enabled = required_exts[
i].dev ?
932 amf_vk_ext_enabled(hwctx->enabled_inst_extensions, hwctx->nb_enabled_inst_extensions, required_exts[
i].
name);
935 required_exts[
i].dev ?
"device" :
"instance", required_exts[
i].
name);
941 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF requires them, create the Vulkan device with instance_extensions="
942 VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME
"+" VK_KHR_SURFACE_EXTENSION_NAME
943 ",device_extensions=" VK_KHR_SWAPCHAIN_EXTENSION_NAME
".\n");
946#if FF_API_VULKAN_SYNC_QUEUES
952 for (
int i = 0;
i < hwctx->
nb_qf;
i++)
960 for (
int i = 0;
i < hwctx->
nb_qf;
i++)
961 if (hwctx->
qf[
i].
idx == family)
969static void amf_lock_vulkan(
void *opaque)
973 int nb_families = amf_vk_nb_families(hwctx);
976 for (
int i = 0;
i < nb_families;
i++) {
977 int nb_queues = amf_vk_family_queues(hwctx,
i);
978 for (
int j = 0; j < nb_queues; j++)
979 hwctx->lock_queue(vk_ctx,
i, j);
984static void amf_unlock_vulkan(
void *opaque)
988 int nb_families = amf_vk_nb_families(hwctx);
991 for (
int i = 0;
i < nb_families;
i++) {
992 int nb_queues = amf_vk_family_queues(hwctx,
i);
993 for (
int j = 0; j < nb_queues; j++)
994 hwctx->unlock_queue(vk_ctx,
i, j);
1003 AMFVulkanDevice *vk_dev = &priv->vk_dev;
1004 AMFContext1 *context1 =
NULL;
1005 AMFGuid guid = IID_AMFContext1();
1011 vk_dev->cbSizeof =
sizeof(*vk_dev);
1012 vk_dev->pNext =
NULL;
1013 vk_dev->hInstance = hwctx->
inst;
1014 vk_dev->hPhysicalDevice = hwctx->
phys_dev;
1015 vk_dev->hDevice = hwctx->
act_dev;
1017 AMF_ASSIGN_PROPERTY_BOOL(res, context1, AMF_CONTEXT_VULKAN_USE_TIMELINE_SEMAPHORES, 1);
1019 av_log(child_device_ctx,
AV_LOG_WARNING,
"Failed to enable Vulkan timeline semaphores on the AMF context: %d.\n", res);
1021#if FF_API_VULKAN_SYNC_QUEUES
1022 priv->
p.
lock = amf_lock_vulkan;
1023 priv->
p.
unlock = amf_unlock_vulkan;
1032 if (res != AMF_OK && res != AMF_ALREADY_INITIALIZED) {
1033 if (res == AMF_NOT_SUPPORTED)
1034 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF via Vulkan is not supported on the given device.\n");
1036 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF failed to initialise on the given Vulkan device: %d.\n", res);
1038 amf_vulkan_log_missing_exts(child_device_ctx, hwctx);
1040 av_log(child_device_ctx,
AV_LOG_ERROR,
"The Vulkan queues were created with flags 0x%x (e.g. internally "
1041 "synchronized queues), which some AMF runtimes cannot use.\n", hwctx->
queue_flags);
1054#if CONFIG_DXVA2 || CONFIG_D3D11VA || CONFIG_D3D12VA
1063 switch (child_device_ctx->
type) {
1066 return amf_init_from_dxva2_device(amf_ctx, child_device_ctx);
1070 return amf_init_from_d3d11_device(amf_ctx, child_device_ctx);
1074 return amf_init_from_d3d12_device(amf_ctx, child_device_ctx);
1078 return amf_init_from_vulkan_device(device_ctx->
hwctx, child_device_ctx);
1081 av_log(child_device_ctx,
AV_LOG_ERROR,
"AMF initialisation from a %s device is not supported.\n",
1090 AMFSurface1 *surface1 = hwmap->
priv;
1100 static const GUID iid_unknown = { 0x00000000, 0x0000, 0x0000, { 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };
1101 IUnknown *unk_a, *unk_b;
1108 if (FAILED(
a->lpVtbl->QueryInterface(
a, &iid_unknown, (
void **)&unk_a)))
1110 if (FAILED(
b->lpVtbl->QueryInterface(
b, &iid_unknown, (
void **)&unk_b))) {
1111 unk_a->lpVtbl->Release(unk_a);
1114 same = unk_a == unk_b;
1115 unk_a->lpVtbl->Release(unk_a);
1116 unk_b->lpVtbl->Release(unk_b);
1125 AMFSurface *surface = (AMFSurface *)
src->data[0];
1126 D3D11_TEXTURE2D_DESC
desc;
1127 ID3D11Texture2D *texture;
1132 if (!
dst->hw_frames_ctx)
1137 d3d11_ctx = dst_fc->device_ctx->hwctx;
1138 if (dst_fc->sw_format !=
ctx->sw_format ||
1139 dst_fc->width !=
ctx->width || dst_fc->height !=
ctx->height)
1142 d3d11_ctx->device)) {
1151 texture = plane->pVtbl->GetNative(plane);
1155 if (!plane || plane->pVtbl->GetNative(plane) != texture)
1158 texture->lpVtbl->GetDesc(texture, &
desc);
1159 if (
desc.ArraySize > 1 ||
1160 desc.Width != dst_fc->width ||
desc.Height != dst_fc->height)
1167 dst->data[0] = (uint8_t *)texture;
1170 dst->height =
src->height;
1178 AMFSurface *surface = (AMFSurface *)
src->data[0];
1179 AMFSurface1 *surface1 =
NULL;
1180 size_t *linesizes =
NULL;
1182 int amf_mem_flags = AMF_MEMORY_CPU_NONE;
1183 const AMFGuid guid = IID_AMFSurface1();
1184 AMF_RESULT res = AMF_FAIL;
1185 size_t plane_count = 0;
1190 return amf_map_to_d3d11(device_ctx,
dst,
src);
1198 res =
AMF_IFACE_CALL(surface, QueryInterface, &guid, (
void**)&surface1);
1202 amf_mem_flags |= AMF_MEMORY_CPU_READ;
1205 amf_mem_flags |= AMF_MEMORY_CPU_WRITE;
1217 res =
AMF_IFACE_CALL(surface1, Map, amf_mem_flags, plane_count, linesizes, (
void**)
map);
1225 dst->height =
src->height;
1231 for (
int plane = 0; plane < plane_count; ++plane)
1233 dst->data[plane] =
map[plane];
1234 dst->linesize[plane] = linesizes[plane];
1244 if (
ret < 0 && surface1 !=
NULL)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const char *const format[]
static void amf_free_amfsurface(void *opaque, uint8_t *data)
#define FFMPEG_AMF_WRITER_ID
#define AMF_RETURN_IF_FALSE(avctx, exp, ret_value,...)
Error handling helper.
static AVFormatContext * ctx
static AVDictionary * opts
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
refcounted data buffer API
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
AVBufferPool * av_buffer_pool_init2(size_t size, void *opaque, AVBufferRef *(*alloc)(void *opaque, size_t size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_EXTERNAL
Generic error in an external library.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
#define AV_LOG_QUIET
Print no output.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_log_get_level(void)
Get the current log level.
static AVRational av_make_q(int num, int den)
Create an AVRational.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static void av_image_copy2(uint8_t *const dst_data[4], const int dst_linesizes[4], uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Wrapper around av_image_copy() to workaround the limitation that the conversion from uint8_t * const ...
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
@ AV_HWFRAME_MAP_WRITE
The mapping must be writeable.
AVHWFrameTransferDirection
@ AV_HWDEVICE_TYPE_D3D11VA
@ AV_HWDEVICE_TYPE_VULKAN
@ AV_HWDEVICE_TYPE_D3D12VA
int av_amf_display_mastering_meta_to_hdrmeta(const AVMasteringDisplayMetadata *display_meta, AMFHDRMetadata *hdrmeta)
static int amf_device_create(AVHWDeviceContext *device_ctx, const char *device, AVDictionary *opts, int flags)
static int amf_device_init(AVHWDeviceContext *ctx)
static void amf_unlock_default(void *opaque)
static int amf_load_library(AVAMFDeviceContext *amf_ctx, void *avcl)
enum AMF_MEMORY_TYPE av_amf_get_memory_type(AVAMFDeviceContext *amf_ctx)
static int amf_map_frame(AVHWFramesContext *device_ctx, AVFrame *dst, const AVFrame *src, int flags)
int av_amf_attach_hdr_metadata(AVFrame *frame, const AMFHDRMetadata *hdrmeta)
static void AMF_CDECL_CALL AMFTraceWriter_Write(AMFTraceWriter *pThis, const wchar_t *scope, const wchar_t *message)
static int amf_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
static int amf_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
const FormatMap format_map[]
const HWContextType ff_hwcontext_type_amf
static void amf_unmap_frame(AVHWFramesContext *ctx, HWMapDescriptor *hwmap)
int av_amf_light_metadata_to_hdrmeta(const AVContentLightMetadata *light_meta, AMFHDRMetadata *hdrmeta)
static void amf_device_uninit(AVHWDeviceContext *device_ctx)
static int amf_frames_init(AVHWFramesContext *ctx)
enum AMF_SURFACE_FORMAT av_av_to_amf_format(enum AVPixelFormat fmt)
static void amf_writer_free(void *opaque)
static enum AVPixelFormat supported_transfer_formats[]
static AmfTraceWriter * amf_writer_alloc(void *avctx)
static int amf_device_derive(AVHWDeviceContext *device_ctx, AVHWDeviceContext *child_device_ctx, AVDictionary *opts, int flags)
static int amf_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
static void amf_free_amfsurface(void *opaque, uint8_t *data)
int av_amf_extract_hdr_metadata(const AVFrame *frame, AMFHDRMetadata *hdrmeta)
enum AVPixelFormat av_amf_to_av_format(enum AMF_SURFACE_FORMAT fmt)
static void amf_lock_default(void *opaque)
static int amf_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
static void amf_dummy_free(void *opaque, uint8_t *data)
enum AMF_VIDEO_CONVERTER_COLOR_PROFILE_ENUM av_amf_get_color_profile(enum AVColorRange color_range, enum AVColorSpace color_space)
static int amf_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
static AVBufferRef * amf_pool_alloc(void *opaque, size_t size)
static void AMF_CDECL_CALL AMFTraceWriter_Flush(AMFTraceWriter *pThis)
#define AMF_GOTO_FAIL_IF_FALSE(avctx, exp, ret_value,...)
#define AMF_IFACE_CALL(this, function,...)
An API-specific header for AV_HWDEVICE_TYPE_D3D11VA.
An API-specific header for AV_HWDEVICE_TYPE_D3D12VA.
An API-specific header for AV_HWDEVICE_TYPE_DXVA2.
static FFHWFramesContext * ffhwframesctx(AVHWFramesContext *ctx)
const VDPAUPixFmtMap * map
API-specific header for AV_HWDEVICE_TYPE_VULKAN.
common internal API header
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
static int ff_mutex_unlock(AVMutex *mutex)
static int ff_mutex_lock(AVMutex *mutex)
static int ff_mutex_destroy(AVMutex *mutex)
static int ff_mutex_init(AVMutex *mutex, const void *attr)
static const struct @257111027162314367033347246032313251342043035002 planes[]
Memory handling functions.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
#define AV_PIX_FMT_RGBAF16
AVColorRange
Visual content value range.
@ AVCOL_RANGE_JPEG
Full range content.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
@ AV_PIX_FMT_AMF_SURFACE
HW acceleration through AMF.
#define AV_PIX_FMT_X2BGR10
AVColorSpace
YUV colorspace type.
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
#define FF_ARRAY_ELEMS(a)
We still need AVHWFramesContext to utilize our hardware memory otherwise, we will receive the error "...
This struct is allocated as AVHWDeviceContext.hwctx.
void(* lock)(void *lock_ctx)
void(* unlock)(void *lock_ctx)
int64_t version
version of AMF runtime
A reference to a data buffer.
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
This struct is allocated as AVHWDeviceContext.hwctx.
UINT BindFlags
D3D11_TEXTURE2D_DESC.BindFlags to be applied to D3D11 resources allocated for frames using this devic...
ID3D11Device * device
Device used for texture creation and access.
This struct is allocated as AVHWDeviceContext.hwctx.
ID3D12Device * device
Device used for objects creation and access.
This struct is allocated as AVHWDeviceContext.hwctx.
IDirect3DDeviceManager9 * devmgr
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
enum AVPixelFormat * valid_hw_formats
A list of possible values for format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
This struct describes a set or pool of "hardware" frames (i.e.
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
VkPhysicalDevice phys_dev
Physical device.
AVVulkanDeviceQueueFamily qf[64]
Queue families used.
const char *const * enabled_dev_extensions
Enabled device extensions.
VkDevice act_dev
Active device.
VkInstance inst
Vulkan instance.
int nb_enabled_dev_extensions
VkDeviceQueueCreateFlags queue_flags
AMFTraceWriterVtbl * vtblp
AVBufferPool * pool_internal
void * priv
Hardware-specific private data associated with the mapping.
#define av_malloc_array(a, b)
static enum AVPixelFormat supported_formats[]