Path: blob/master/dep/ffmpeg/include/libavutil/hwcontext_d3d12va.h
4216 views
/*1* Direct3D 12 HW acceleration.2*3* copyright (c) 2022-2023 Wu Jianhua <[email protected]>4*5* This file is part of FFmpeg.6*7* FFmpeg is free software; you can redistribute it and/or8* modify it under the terms of the GNU Lesser General Public9* License as published by the Free Software Foundation; either10* version 2.1 of the License, or (at your option) any later version.11*12* FFmpeg is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU15* Lesser General Public License for more details.16*17* You should have received a copy of the GNU Lesser General Public18* License along with FFmpeg; if not, write to the Free Software19* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA20*/2122#ifndef AVUTIL_HWCONTEXT_D3D12VA_H23#define AVUTIL_HWCONTEXT_D3D12VA_H2425/**26* @file27* An API-specific header for AV_HWDEVICE_TYPE_D3D12VA.28*29* AVHWFramesContext.pool must contain AVBufferRefs whose30* data pointer points to an AVD3D12VAFrame struct.31*/32#include <stdint.h>33#include <initguid.h>34#include <d3d12.h>35#include <d3d12sdklayers.h>36#include <d3d12video.h>3738/**39* @brief This struct is allocated as AVHWDeviceContext.hwctx40*41*/42typedef struct AVD3D12VADeviceContext {43/**44* Device used for objects creation and access. This can also be45* used to set the libavcodec decoding device.46*47* Can be set by the user. This is the only mandatory field - the other48* device context fields are set from this and are available for convenience.49*50* Deallocating the AVHWDeviceContext will always release this interface,51* and it does not matter whether it was user-allocated.52*/53ID3D12Device *device;5455/**56* If unset, this will be set from the device field on init.57*58* Deallocating the AVHWDeviceContext will always release this interface,59* and it does not matter whether it was user-allocated.60*/61ID3D12VideoDevice *video_device;6263/**64* Callbacks for locking. They protect access to the internal staging65* texture (for av_hwframe_transfer_data() calls). They do NOT protect66* access to hwcontext or decoder state in general.67*68* If unset on init, the hwcontext implementation will set them to use an69* internal mutex.70*71* The underlying lock must be recursive. lock_ctx is for free use by the72* locking implementation.73*/74void (*lock)(void *lock_ctx);75void (*unlock)(void *lock_ctx);76void *lock_ctx;77} AVD3D12VADeviceContext;7879/**80* @brief This struct is used to sync d3d12 execution81*82*/83typedef struct AVD3D12VASyncContext {84/**85* D3D12 fence object86*/87ID3D12Fence *fence;8889/**90* A handle to the event object that's raised when the fence91* reaches a certain value.92*/93HANDLE event;9495/**96* The fence value used for sync97*/98uint64_t fence_value;99} AVD3D12VASyncContext;100101/**102* @brief D3D12VA frame descriptor for pool allocation.103*104*/105typedef struct AVD3D12VAFrame {106/**107* The texture in which the frame is located. The reference count is108* managed by the AVBufferRef, and destroying the reference will release109* the interface.110*/111ID3D12Resource *texture;112113/**114* The sync context for the texture115*116* @see: https://learn.microsoft.com/en-us/windows/win32/medfound/direct3d-12-video-overview#directx-12-fences117*/118AVD3D12VASyncContext sync_ctx;119} AVD3D12VAFrame;120121/**122* @brief This struct is allocated as AVHWFramesContext.hwctx123*124*/125typedef struct AVD3D12VAFramesContext {126/**127* DXGI_FORMAT format. MUST be compatible with the pixel format.128* If unset, will be automatically set.129*/130DXGI_FORMAT format;131132/**133* Options for working with resources.134* If unset, this will be D3D12_RESOURCE_FLAG_NONE.135*136* @see https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_flags137*/138D3D12_RESOURCE_FLAGS flags;139} AVD3D12VAFramesContext;140141#endif /* AVUTIL_HWCONTEXT_D3D12VA_H */142143144