FFmpeg
Loading...
Searching...
No Matches
hwcontext_d3d11va.c File Reference
#include "config.h"
#include <windows.h>
#include <initguid.h>
#include <d3d11.h>
#include <dxgi1_2.h>
#include "avassert.h"
#include "common.h"
#include "hwcontext.h"
#include "hwcontext_d3d11va.h"
#include "hwcontext_internal.h"
#include "imgutils.h"
#include "mem.h"
#include "pixdesc.h"
#include "pixfmt.h"
#include "thread.h"
#include "compat/w32dlfcn.h"

Go to the source code of this file.

Data Structures

struct  D3D11VAFramesContext
 

Macros

#define COBJMACROS
 
#define MAX_ARRAY_SIZE   64
 

Typedefs

typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY) (REFIID riid, void **ppFactory)
 

Functions

static av_cold void load_functions (void)
 
static void d3d11va_default_lock (void *ctx)
 
static void d3d11va_default_unlock (void *ctx)
 
static void d3d11va_frames_uninit (AVHWFramesContext *ctx)
 
static int d3d11va_frames_get_constraints (AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
 
static void free_texture (void *opaque, uint8_t *data)
 
static AVBufferRefwrap_texture_buf (AVHWFramesContext *ctx, ID3D11Texture2D *tex, int index)
 
static AVBufferRefd3d11va_alloc_single (AVHWFramesContext *ctx)
 
static AVBufferRefd3d11va_pool_alloc (void *opaque, size_t size)
 
static int d3d11va_frames_init (AVHWFramesContext *ctx)
 
static int d3d11va_get_buffer (AVHWFramesContext *ctx, AVFrame *frame)
 
static int d3d11va_transfer_get_formats (AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
 
static int d3d11va_create_staging_texture (AVHWFramesContext *ctx, DXGI_FORMAT format)
 
static void fill_texture_ptrs (uint8_t *data[4], int linesize[4], AVHWFramesContext *ctx, D3D11_TEXTURE2D_DESC *desc, D3D11_MAPPED_SUBRESOURCE *map)
 
static int d3d11va_transfer_data (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
 
static int d3d11va_device_init (AVHWDeviceContext *hwdev)
 
static void d3d11va_device_uninit (AVHWDeviceContext *hwdev)
 
static int d3d11va_device_find_adapter_by_vendor_id (AVHWDeviceContext *ctx, uint32_t flags, const char *vendor_id)
 
static int d3d11va_device_create (AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
 

Variables

static AVOnce functions_loaded = AV_ONCE_INIT
 
static PFN_CREATE_DXGI_FACTORY mCreateDXGIFactory
 
static PFN_D3D11_CREATE_DEVICE mD3D11CreateDevice
 
struct { 
 
   DXGI_FORMAT   d3d_format 
 
   enum AVPixelFormat   pix_fmt 
 
supported_formats [] 
 
const HWContextType ff_hwcontext_type_d3d11va
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file hwcontext_d3d11va.c.

◆ MAX_ARRAY_SIZE

#define MAX_ARRAY_SIZE   64

Definition at line 45 of file hwcontext_d3d11va.c.

Referenced by d3d11va_frames_init().

Typedef Documentation

◆ PFN_CREATE_DXGI_FACTORY

typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY) (REFIID riid, void **ppFactory)

Definition at line 47 of file hwcontext_d3d11va.c.

Function Documentation

◆ load_functions()

static av_cold void load_functions ( void )
static

Definition at line 54 of file hwcontext_d3d11va.c.

Referenced by gfxcapture_init().

◆ d3d11va_default_lock()

static void d3d11va_default_lock ( void * ctx)
static

Definition at line 119 of file hwcontext_d3d11va.c.

Referenced by d3d11va_device_init(), and d3d11va_device_uninit().

◆ d3d11va_default_unlock()

static void d3d11va_default_unlock ( void * ctx)
static

Definition at line 124 of file hwcontext_d3d11va.c.

Referenced by d3d11va_device_init().

◆ d3d11va_frames_uninit()

static void d3d11va_frames_uninit ( AVHWFramesContext * ctx)
static

Definition at line 129 of file hwcontext_d3d11va.c.

◆ d3d11va_frames_get_constraints()

static int d3d11va_frames_get_constraints ( AVHWDeviceContext * ctx,
const void * hwconfig,
AVHWFramesConstraints * constraints )
static

Definition at line 145 of file hwcontext_d3d11va.c.

◆ free_texture()

static void free_texture ( void * opaque,
uint8_t * data )
static

◆ wrap_texture_buf()

static AVBufferRef * wrap_texture_buf ( AVHWFramesContext * ctx,
ID3D11Texture2D * tex,
int index )
static

Definition at line 183 of file hwcontext_d3d11va.c.

Referenced by d3d11va_alloc_single(), and d3d11va_pool_alloc().

◆ d3d11va_alloc_single()

static AVBufferRef * d3d11va_alloc_single ( AVHWFramesContext * ctx)
static

Definition at line 223 of file hwcontext_d3d11va.c.

Referenced by d3d11va_pool_alloc().

◆ d3d11va_pool_alloc()

static AVBufferRef * d3d11va_pool_alloc ( void * opaque,
size_t size )
static

Definition at line 251 of file hwcontext_d3d11va.c.

Referenced by d3d11va_frames_init().

◆ d3d11va_frames_init()

static int d3d11va_frames_init ( AVHWFramesContext * ctx)
static

Definition at line 272 of file hwcontext_d3d11va.c.

◆ d3d11va_get_buffer()

static int d3d11va_get_buffer ( AVHWFramesContext * ctx,
AVFrame * frame )
static

Definition at line 347 of file hwcontext_d3d11va.c.

◆ d3d11va_transfer_get_formats()

static int d3d11va_transfer_get_formats ( AVHWFramesContext * ctx,
enum AVHWFrameTransferDirection dir,
enum AVPixelFormat ** formats )
static

Definition at line 366 of file hwcontext_d3d11va.c.

◆ d3d11va_create_staging_texture()

static int d3d11va_create_staging_texture ( AVHWFramesContext * ctx,
DXGI_FORMAT format )
static

Definition at line 389 of file hwcontext_d3d11va.c.

Referenced by d3d11va_transfer_data().

◆ fill_texture_ptrs()

static void fill_texture_ptrs ( uint8_t * data[4],
int linesize[4],
AVHWFramesContext * ctx,
D3D11_TEXTURE2D_DESC * desc,
D3D11_MAPPED_SUBRESOURCE * map )
static

Definition at line 414 of file hwcontext_d3d11va.c.

Referenced by d3d11va_transfer_data().

◆ d3d11va_transfer_data()

static int d3d11va_transfer_data ( AVHWFramesContext * ctx,
AVFrame * dst,
const AVFrame * src )
static

Definition at line 428 of file hwcontext_d3d11va.c.

◆ d3d11va_device_init()

static int d3d11va_device_init ( AVHWDeviceContext * hwdev)
static

Definition at line 508 of file hwcontext_d3d11va.c.

◆ d3d11va_device_uninit()

static void d3d11va_device_uninit ( AVHWDeviceContext * hwdev)
static

Definition at line 546 of file hwcontext_d3d11va.c.

◆ d3d11va_device_find_adapter_by_vendor_id()

static int d3d11va_device_find_adapter_by_vendor_id ( AVHWDeviceContext * ctx,
uint32_t flags,
const char * vendor_id )
static

Definition at line 577 of file hwcontext_d3d11va.c.

Referenced by d3d11va_device_create().

◆ d3d11va_device_create()

static int d3d11va_device_create ( AVHWDeviceContext * ctx,
const char * device,
AVDictionary * opts,
int flags )
static

Definition at line 618 of file hwcontext_d3d11va.c.

Variable Documentation

◆ functions_loaded

AVOnce functions_loaded = AV_ONCE_INIT
static

Definition at line 49 of file hwcontext_d3d11va.c.

Referenced by d3d11va_device_create().

◆ mCreateDXGIFactory

◆ mD3D11CreateDevice

PFN_D3D11_CREATE_DEVICE mD3D11CreateDevice
static

◆ d3d_format

DXGI_FORMAT d3d_format

Definition at line 94 of file hwcontext_d3d11va.c.

Referenced by txd_decode_frame().

◆ pix_fmt

enum AVPixelFormat pix_fmt

Definition at line 95 of file hwcontext_d3d11va.c.

◆ [struct]

const struct { ... } supported_formats[]
Initial value:
= {
{ DXGI_FORMAT_NV12, AV_PIX_FMT_NV12 },
{ DXGI_FORMAT_P010, AV_PIX_FMT_P010 },
{ DXGI_FORMAT_R10G10B10A2_UNORM, AV_PIX_FMT_X2BGR10 },
{ DXGI_FORMAT_AYUV, AV_PIX_FMT_VUYX },
{ DXGI_FORMAT_YUY2, AV_PIX_FMT_YUYV422 },
{ DXGI_FORMAT_Y210, AV_PIX_FMT_Y210 },
{ DXGI_FORMAT_Y410, AV_PIX_FMT_XV30 },
{ DXGI_FORMAT_P016, AV_PIX_FMT_P016 },
{ DXGI_FORMAT_Y216, AV_PIX_FMT_Y216 },
{ DXGI_FORMAT_Y416, AV_PIX_FMT_XV48 },
{ DXGI_FORMAT_P016, AV_PIX_FMT_P012 },
{ DXGI_FORMAT_Y216, AV_PIX_FMT_Y212 },
{ DXGI_FORMAT_Y416, AV_PIX_FMT_XV36 },
{ DXGI_FORMAT_420_OPAQUE, AV_PIX_FMT_YUV420P },
}
@ DXGI_FORMAT_B8G8R8A8_UNORM
Definition dds.c:92
@ DXGI_FORMAT_R16G16B16A16_FLOAT
Definition dds.c:63
#define AV_PIX_FMT_RGBAF16
Definition pixfmt.h:630
#define AV_PIX_FMT_P012
Definition pixfmt.h:609
#define AV_PIX_FMT_Y210
Definition pixfmt.h:612
#define AV_PIX_FMT_P010
Definition pixfmt.h:608
#define AV_PIX_FMT_P016
Definition pixfmt.h:610
#define AV_PIX_FMT_XV30
Definition pixfmt.h:615
#define AV_PIX_FMT_XV48
Definition pixfmt.h:617
@ 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...
Definition pixfmt.h:96
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_VUYX
packed VUYX 4:4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined
Definition pixfmt.h:406
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition pixfmt.h:102
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition pixfmt.h:74
#define AV_PIX_FMT_X2BGR10
Definition pixfmt.h:620
#define AV_PIX_FMT_Y216
Definition pixfmt.h:614
#define AV_PIX_FMT_Y212
Definition pixfmt.h:613
#define AV_PIX_FMT_XV36
Definition pixfmt.h:616

◆ ff_hwcontext_type_d3d11va

const HWContextType ff_hwcontext_type_d3d11va
Initial value:
= {
.name = "D3D11VA",
.device_hwctx_size = sizeof(AVD3D11VADeviceContext),
.frames_hwctx_size = sizeof(D3D11VAFramesContext),
.device_create = d3d11va_device_create,
.device_init = d3d11va_device_init,
.device_uninit = d3d11va_device_uninit,
.frames_get_constraints = d3d11va_frames_get_constraints,
.frames_init = d3d11va_frames_init,
.frames_uninit = d3d11va_frames_uninit,
.frames_get_buffer = d3d11va_get_buffer,
.transfer_get_formats = d3d11va_transfer_get_formats,
.transfer_data_to = d3d11va_transfer_data,
.transfer_data_from = d3d11va_transfer_data,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_D3D11, AV_PIX_FMT_NONE },
}
@ AV_HWDEVICE_TYPE_D3D11VA
Definition hwcontext.h:35
static int d3d11va_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
static int d3d11va_device_init(AVHWDeviceContext *hwdev)
static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
static int d3d11va_transfer_data(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
static int d3d11va_frames_init(AVHWFramesContext *ctx)
static void d3d11va_frames_uninit(AVHWFramesContext *ctx)
static int d3d11va_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
static int d3d11va_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
static void d3d11va_device_uninit(AVHWDeviceContext *hwdev)
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
Definition pixfmt.h:336
This struct is allocated as AVHWDeviceContext.hwctx.

Definition at line 732 of file hwcontext_d3d11va.c.