FFmpeg
Data Structures | Macros | Typedefs | Functions | Variables
hwcontext_dxva2.c File Reference
#include <windows.h>
#include <d3d9.h>
#include <dxva2api.h>
#include <initguid.h>
#include "avassert.h"
#include "common.h"
#include "hwcontext.h"
#include "hwcontext_dxva2.h"
#include "hwcontext_internal.h"
#include "imgutils.h"
#include "pixdesc.h"
#include "pixfmt.h"
#include "compat/w32dlfcn.h"

Go to the source code of this file.

Data Structures

struct  DXVA2Mapping
 
struct  DXVA2FramesContext
 
struct  DXVA2DevicePriv
 

Macros

#define DXVA2API_USE_BITFIELDS
 
#define COBJMACROS
 
#define FF_D3DCREATE_FLAGS
 

Typedefs

typedef IDirect3D9 *WINAPI pDirect3DCreate9(UINT)
 
typedef HRESULT WINAPI pDirect3DCreate9Ex(UINT, IDirect3D9Ex **)
 
typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **)
 

Functions

 DEFINE_GUID (video_decoder_service, 0xfc51a551, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02)
 
 DEFINE_GUID (video_processor_service, 0xfc51a552, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02)
 
static void dxva2_frames_uninit (AVHWFramesContext *ctx)
 
static void dxva2_pool_release_dummy (void *opaque, uint8_t *data)
 
static AVBufferRefdxva2_pool_alloc (void *opaque, size_t size)
 
static int dxva2_init_pool (AVHWFramesContext *ctx)
 
static int dxva2_frames_init (AVHWFramesContext *ctx)
 
static int dxva2_get_buffer (AVHWFramesContext *ctx, AVFrame *frame)
 
static int dxva2_transfer_get_formats (AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
 
static void dxva2_unmap_frame (AVHWFramesContext *ctx, HWMapDescriptor *hwmap)
 
static int dxva2_map_frame (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
 
static int dxva2_transfer_data_to (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
 
static int dxva2_transfer_data_from (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
 
static int dxva2_map_from (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
 
static void dxva2_device_free (AVHWDeviceContext *ctx)
 
static int dxva2_device_create9 (AVHWDeviceContext *ctx, UINT adapter)
 
static int dxva2_device_create9ex (AVHWDeviceContext *ctx, UINT adapter)
 
static int dxva2_device_create (AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
 

Variables

static const D3DPRESENT_PARAMETERS dxva2_present_params
 
struct {
   D3DFORMAT   d3d_format
 
   enum AVPixelFormat   pix_fmt
 
supported_formats []
 
const HWContextType ff_hwcontext_type_dxva2
 

Macro Definition Documentation

◆ DXVA2API_USE_BITFIELDS

#define DXVA2API_USE_BITFIELDS

Definition at line 21 of file hwcontext_dxva2.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file hwcontext_dxva2.c.

◆ FF_D3DCREATE_FLAGS

#define FF_D3DCREATE_FLAGS
Value:
(D3DCREATE_SOFTWARE_VERTEXPROCESSING | \
D3DCREATE_MULTITHREADED | \
D3DCREATE_FPU_PRESERVE)

Definition at line 42 of file hwcontext_dxva2.c.

Typedef Documentation

◆ pDirect3DCreate9

typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT)

Definition at line 38 of file hwcontext_dxva2.c.

◆ pDirect3DCreate9Ex

typedef HRESULT WINAPI pDirect3DCreate9Ex(UINT, IDirect3D9Ex **)

Definition at line 39 of file hwcontext_dxva2.c.

◆ pCreateDeviceManager9

typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **)

Definition at line 40 of file hwcontext_dxva2.c.

Function Documentation

◆ DEFINE_GUID() [1/2]

DEFINE_GUID ( video_decoder_service  ,
0xfc51a551  ,
0xd5e7  ,
0x11d9  ,
0xaf  ,
0x55  ,
0x00  ,
0x05  ,
0x4e  ,
0x43  ,
0xff  ,
0x02   
)

◆ DEFINE_GUID() [2/2]

DEFINE_GUID ( video_processor_service  ,
0xfc51a552  ,
0xd5e7  ,
0x11d9  ,
0xaf  ,
0x55  ,
0x00  ,
0x05  ,
0x4e  ,
0x43  ,
0xff  ,
0x02   
)

◆ dxva2_frames_uninit()

static void dxva2_frames_uninit ( AVHWFramesContext ctx)
static

Definition at line 104 of file hwcontext_dxva2.c.

◆ dxva2_pool_release_dummy()

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

Definition at line 133 of file hwcontext_dxva2.c.

Referenced by dxva2_pool_alloc().

◆ dxva2_pool_alloc()

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

Definition at line 140 of file hwcontext_dxva2.c.

Referenced by dxva2_init_pool().

◆ dxva2_init_pool()

static int dxva2_init_pool ( AVHWFramesContext ctx)
static

Definition at line 155 of file hwcontext_dxva2.c.

Referenced by dxva2_frames_init().

◆ dxva2_frames_init()

static int dxva2_frames_init ( AVHWFramesContext ctx)
static

Definition at line 223 of file hwcontext_dxva2.c.

◆ dxva2_get_buffer()

static int dxva2_get_buffer ( AVHWFramesContext ctx,
AVFrame frame 
)
static

Definition at line 250 of file hwcontext_dxva2.c.

◆ dxva2_transfer_get_formats()

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

Definition at line 264 of file hwcontext_dxva2.c.

◆ dxva2_unmap_frame()

static void dxva2_unmap_frame ( AVHWFramesContext ctx,
HWMapDescriptor hwmap 
)
static

Definition at line 282 of file hwcontext_dxva2.c.

Referenced by dxva2_map_frame().

◆ dxva2_map_frame()

static int dxva2_map_frame ( AVHWFramesContext ctx,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

◆ dxva2_transfer_data_to()

static int dxva2_transfer_data_to ( AVHWFramesContext ctx,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 347 of file hwcontext_dxva2.c.

◆ dxva2_transfer_data_from()

static int dxva2_transfer_data_from ( AVHWFramesContext ctx,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 373 of file hwcontext_dxva2.c.

◆ dxva2_map_from()

static int dxva2_map_from ( AVHWFramesContext ctx,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

Definition at line 403 of file hwcontext_dxva2.c.

◆ dxva2_device_free()

static void dxva2_device_free ( AVHWDeviceContext ctx)
static

Definition at line 423 of file hwcontext_dxva2.c.

Referenced by dxva2_device_create().

◆ dxva2_device_create9()

static int dxva2_device_create9 ( AVHWDeviceContext ctx,
UINT  adapter 
)
static

Definition at line 449 of file hwcontext_dxva2.c.

Referenced by dxva2_device_create().

◆ dxva2_device_create9ex()

static int dxva2_device_create9ex ( AVHWDeviceContext ctx,
UINT  adapter 
)
static

Definition at line 482 of file hwcontext_dxva2.c.

Referenced by dxva2_device_create().

◆ dxva2_device_create()

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

Definition at line 521 of file hwcontext_dxva2.c.

Variable Documentation

◆ dxva2_present_params

const D3DPRESENT_PARAMETERS dxva2_present_params
static
Initial value:
= {
.Windowed = TRUE,
.BackBufferWidth = 640,
.BackBufferHeight = 480,
.BackBufferCount = 0,
.SwapEffect = D3DSWAPEFFECT_DISCARD,
.Flags = D3DPRESENTFLAG_VIDEO,
}

Definition at line 46 of file hwcontext_dxva2.c.

Referenced by dxva2_device_create9(), and dxva2_device_create9ex().

◆ d3d_format

D3DFORMAT d3d_format

Definition at line 85 of file hwcontext_dxva2.c.

◆ pix_fmt

enum AVPixelFormat pix_fmt

Definition at line 86 of file hwcontext_dxva2.c.

◆ supported_formats

const { ... } supported_formats[]
Initial value:
= {
{ MKTAG('N', 'V', '1', '2'), AV_PIX_FMT_NV12 },
{ MKTAG('P', '0', '1', '0'), AV_PIX_FMT_P010 },
{ MKTAG('A', 'Y', 'U', 'V'), AV_PIX_FMT_VUYX },
{ MKTAG('Y', 'U', 'Y', '2'), AV_PIX_FMT_YUYV422 },
{ MKTAG('Y', '2', '1', '0'), AV_PIX_FMT_Y210 },
{ MKTAG('Y', '4', '1', '0'), AV_PIX_FMT_XV30 },
{ MKTAG('P', '0', '1', '6'), AV_PIX_FMT_P012 },
{ MKTAG('Y', '2', '1', '6'), AV_PIX_FMT_Y212 },
{ MKTAG('Y', '4', '1', '6'), AV_PIX_FMT_XV36 },
{ D3DFMT_P8, AV_PIX_FMT_PAL8 },
{ D3DFMT_A8R8G8B8, AV_PIX_FMT_BGRA },
}

Referenced by dxva2_init_pool().

◆ ff_hwcontext_type_dxva2

const HWContextType ff_hwcontext_type_dxva2
Initial value:
= {
.name = "DXVA2",
.device_hwctx_size = sizeof(AVDXVA2DeviceContext),
.frames_hwctx_size = sizeof(DXVA2FramesContext),
.device_create = dxva2_device_create,
.frames_init = dxva2_frames_init,
.frames_uninit = dxva2_frames_uninit,
.frames_get_buffer = dxva2_get_buffer,
.transfer_get_formats = dxva2_transfer_get_formats,
.transfer_data_to = dxva2_transfer_data_to,
.transfer_data_from = dxva2_transfer_data_from,
.map_from = dxva2_map_from,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_DXVA2_VLD, AV_PIX_FMT_NONE },
}

Definition at line 590 of file hwcontext_dxva2.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
dxva2_transfer_data_from
static int dxva2_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_dxva2.c:373
DXVA2FramesContext
Definition: hwcontext_dxva2.c:59
dxva2_get_buffer
static int dxva2_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
Definition: hwcontext_dxva2.c:250
dxva2_device_create
static int dxva2_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
Definition: hwcontext_dxva2.c:521
AV_PIX_FMT_XV30
#define AV_PIX_FMT_XV30
Definition: pixfmt.h:534
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
dxva2_frames_init
static int dxva2_frames_init(AVHWFramesContext *ctx)
Definition: hwcontext_dxva2.c:223
dxva2_transfer_get_formats
static int dxva2_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
Definition: hwcontext_dxva2.c:264
AV_PIX_FMT_Y210
#define AV_PIX_FMT_Y210
Definition: pixfmt.h:532
AV_PIX_FMT_DXVA2_VLD
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
Definition: pixfmt.h:134
dxva2_frames_uninit
static void dxva2_frames_uninit(AVHWFramesContext *ctx)
Definition: hwcontext_dxva2.c:104
AV_HWDEVICE_TYPE_DXVA2
@ AV_HWDEVICE_TYPE_DXVA2
Definition: hwcontext.h:32
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
AV_PIX_FMT_P012
#define AV_PIX_FMT_P012
Definition: pixfmt.h:529
dxva2_map_from
static int dxva2_map_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
Definition: hwcontext_dxva2.c:403
AV_PIX_FMT_Y212
#define AV_PIX_FMT_Y212
Definition: pixfmt.h:533
dxva2_transfer_data_to
static int dxva2_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_dxva2.c:347
AVDXVA2DeviceContext
This struct is allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_dxva2.h:39
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:84
AV_PIX_FMT_NV12
@ 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_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:528
AV_PIX_FMT_XV36
#define AV_PIX_FMT_XV36
Definition: pixfmt.h:535
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
AV_PIX_FMT_VUYX
@ AV_PIX_FMT_VUYX
packed VUYX 4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined
Definition: pixfmt.h:406