FFmpeg
Data Structures | Macros | Functions | Variables
hwcontext_vaapi.c File Reference
#include "config.h"
#include <fcntl.h>
#include "avassert.h"
#include "buffer.h"
#include "common.h"
#include "hwcontext.h"
#include "hwcontext_drm.h"
#include "hwcontext_internal.h"
#include "hwcontext_vaapi.h"
#include "mem.h"
#include "pixdesc.h"
#include "pixfmt.h"

Go to the source code of this file.

Data Structures

struct  VAAPIDevicePriv
 
struct  VAAPISurfaceFormat
 
struct  VAAPIDeviceContext
 
struct  VAAPIFramesContext
 
struct  VAAPIMapping
 
struct  VAAPIFormat
 

Macros

#define MAP(va, rt, av, swap_uv)
 

Functions

static const VAAPIFormatDescriptor * vaapi_format_from_fourcc (unsigned int fourcc)
 
static const VAAPIFormatDescriptor * vaapi_format_from_pix_fmt (enum AVPixelFormat pix_fmt)
 
static enum AVPixelFormat vaapi_pix_fmt_from_fourcc (unsigned int fourcc)
 
static int vaapi_get_image_format (AVHWDeviceContext *hwdev, enum AVPixelFormat pix_fmt, VAImageFormat **image_format)
 
static int vaapi_frames_get_constraints (AVHWDeviceContext *hwdev, const void *hwconfig, AVHWFramesConstraints *constraints)
 
static int vaapi_device_init (AVHWDeviceContext *hwdev)
 
static void vaapi_device_uninit (AVHWDeviceContext *hwdev)
 
static void vaapi_buffer_free (void *opaque, uint8_t *data)
 
static AVBufferRefvaapi_pool_alloc (void *opaque, size_t size)
 
static int vaapi_frames_init (AVHWFramesContext *hwfc)
 
static void vaapi_frames_uninit (AVHWFramesContext *hwfc)
 
static int vaapi_get_buffer (AVHWFramesContext *hwfc, AVFrame *frame)
 
static int vaapi_transfer_get_formats (AVHWFramesContext *hwfc, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
 
static void vaapi_unmap_frame (AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
 
static int vaapi_map_frame (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
 
static int vaapi_transfer_data_from (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
 
static int vaapi_transfer_data_to (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
 
static int vaapi_map_to_memory (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
 
static int vaapi_map_to (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
 
static int vaapi_map_from (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
 
static void vaapi_device_free (AVHWDeviceContext *ctx)
 
static int vaapi_device_connect (AVHWDeviceContext *ctx, VADisplay display)
 
static int vaapi_device_create (AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
 
static int vaapi_device_derive (AVHWDeviceContext *ctx, AVHWDeviceContext *src_ctx, AVDictionary *opts, int flags)
 

Variables

static const VAAPIFormatDescriptor vaapi_format_map []
 
struct {
   const char *   friendly_name
 
   const char *   match_string
 
   unsigned int   quirks
 
vaapi_driver_quirks_table []
 
const HWContextType ff_hwcontext_type_vaapi
 

Macro Definition Documentation

◆ MAP

#define MAP (   va,
  rt,
  av,
  swap_uv 
)
Value:
{ \
VA_FOURCC_ ## va, \
VA_RT_FORMAT_ ## rt, \
AV_PIX_FMT_ ## av, \
swap_uv, \
}

Definition at line 101 of file hwcontext_vaapi.c.

Function Documentation

◆ vaapi_format_from_fourcc()

static const VAAPIFormatDescriptor* vaapi_format_from_fourcc ( unsigned int  fourcc)
static

Definition at line 149 of file hwcontext_vaapi.c.

Referenced by vaapi_map_frame(), and vaapi_pix_fmt_from_fourcc().

◆ vaapi_format_from_pix_fmt()

static const VAAPIFormatDescriptor* vaapi_format_from_pix_fmt ( enum AVPixelFormat  pix_fmt)
static

Definition at line 159 of file hwcontext_vaapi.c.

Referenced by vaapi_frames_init().

◆ vaapi_pix_fmt_from_fourcc()

static enum AVPixelFormat vaapi_pix_fmt_from_fourcc ( unsigned int  fourcc)
static

Definition at line 168 of file hwcontext_vaapi.c.

Referenced by vaapi_device_init(), and vaapi_frames_get_constraints().

◆ vaapi_get_image_format()

static int vaapi_get_image_format ( AVHWDeviceContext hwdev,
enum AVPixelFormat  pix_fmt,
VAImageFormat **  image_format 
)
static

Definition at line 178 of file hwcontext_vaapi.c.

Referenced by vaapi_frames_init(), vaapi_map_frame(), and vaapi_map_to_memory().

◆ vaapi_frames_get_constraints()

static int vaapi_frames_get_constraints ( AVHWDeviceContext hwdev,
const void *  hwconfig,
AVHWFramesConstraints constraints 
)
static

Definition at line 195 of file hwcontext_vaapi.c.

◆ vaapi_device_init()

static int vaapi_device_init ( AVHWDeviceContext hwdev)
static

Definition at line 357 of file hwcontext_vaapi.c.

◆ vaapi_device_uninit()

static void vaapi_device_uninit ( AVHWDeviceContext hwdev)
static

Definition at line 447 of file hwcontext_vaapi.c.

◆ vaapi_buffer_free()

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

Definition at line 454 of file hwcontext_vaapi.c.

Referenced by vaapi_pool_alloc().

◆ vaapi_pool_alloc()

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

Definition at line 470 of file hwcontext_vaapi.c.

Referenced by vaapi_frames_init().

◆ vaapi_frames_init()

static int vaapi_frames_init ( AVHWFramesContext hwfc)
static

Definition at line 514 of file hwcontext_vaapi.c.

◆ vaapi_frames_uninit()

static void vaapi_frames_uninit ( AVHWFramesContext hwfc)
static

Definition at line 666 of file hwcontext_vaapi.c.

◆ vaapi_get_buffer()

static int vaapi_get_buffer ( AVHWFramesContext hwfc,
AVFrame frame 
)
static

Definition at line 675 of file hwcontext_vaapi.c.

◆ vaapi_transfer_get_formats()

static int vaapi_transfer_get_formats ( AVHWFramesContext hwfc,
enum AVHWFrameTransferDirection  dir,
enum AVPixelFormat **  formats 
)
static

Definition at line 689 of file hwcontext_vaapi.c.

◆ vaapi_unmap_frame()

static void vaapi_unmap_frame ( AVHWFramesContext hwfc,
HWMapDescriptor hwmap 
)
static

Definition at line 725 of file hwcontext_vaapi.c.

Referenced by vaapi_map_frame().

◆ vaapi_map_frame()

static int vaapi_map_frame ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

◆ vaapi_transfer_data_from()

static int vaapi_transfer_data_from ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 897 of file hwcontext_vaapi.c.

◆ vaapi_transfer_data_to()

static int vaapi_transfer_data_to ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 928 of file hwcontext_vaapi.c.

◆ vaapi_map_to_memory()

static int vaapi_map_to_memory ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

Definition at line 959 of file hwcontext_vaapi.c.

Referenced by vaapi_map_from().

◆ vaapi_map_to()

static int vaapi_map_to ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

Definition at line 1533 of file hwcontext_vaapi.c.

◆ vaapi_map_from()

static int vaapi_map_from ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

Definition at line 1546 of file hwcontext_vaapi.c.

◆ vaapi_device_free()

static void vaapi_device_free ( AVHWDeviceContext ctx)
static

Definition at line 1559 of file hwcontext_vaapi.c.

Referenced by vaapi_device_create(), and vaapi_device_derive().

◆ vaapi_device_connect()

static int vaapi_device_connect ( AVHWDeviceContext ctx,
VADisplay  display 
)
static

Definition at line 1594 of file hwcontext_vaapi.c.

Referenced by vaapi_device_create(), and vaapi_device_derive().

◆ vaapi_device_create()

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

Definition at line 1620 of file hwcontext_vaapi.c.

◆ vaapi_device_derive()

static int vaapi_device_derive ( AVHWDeviceContext ctx,
AVHWDeviceContext src_ctx,
AVDictionary opts,
int  flags 
)
static

Definition at line 1775 of file hwcontext_vaapi.c.

Variable Documentation

◆ vaapi_format_map

const VAAPIFormatDescriptor vaapi_format_map[]
static

Definition at line 109 of file hwcontext_vaapi.c.

Referenced by vaapi_format_from_fourcc(), and vaapi_format_from_pix_fmt().

◆ friendly_name

const char* friendly_name

Definition at line 333 of file hwcontext_vaapi.c.

Referenced by vaapi_device_init().

◆ match_string

const char* match_string

Definition at line 334 of file hwcontext_vaapi.c.

Referenced by vaapi_device_init().

◆ quirks

unsigned int quirks

Definition at line 335 of file hwcontext_vaapi.c.

Referenced by vaapi_device_init().

◆ vaapi_driver_quirks_table

const { ... } vaapi_driver_quirks_table[]
Initial value:
= {
{
"Intel i965 (Quick Sync)",
"i965",
},
{
"Intel iHD",
"ubit",
},
{
"VDPAU wrapper",
"Splitted-Desktop Systems VDPAU backend for VA-API",
},
}

Referenced by vaapi_device_init().

◆ ff_hwcontext_type_vaapi

const HWContextType ff_hwcontext_type_vaapi
Initial value:
= {
.name = "VAAPI",
.device_hwctx_size = sizeof(AVVAAPIDeviceContext),
.device_priv_size = sizeof(VAAPIDeviceContext),
.device_hwconfig_size = sizeof(AVVAAPIHWConfig),
.frames_hwctx_size = sizeof(AVVAAPIFramesContext),
.frames_priv_size = sizeof(VAAPIFramesContext),
.device_create = &vaapi_device_create,
.device_derive = &vaapi_device_derive,
.device_uninit = &vaapi_device_uninit,
.frames_get_constraints = &vaapi_frames_get_constraints,
.frames_init = &vaapi_frames_init,
.frames_uninit = &vaapi_frames_uninit,
.frames_get_buffer = &vaapi_get_buffer,
.transfer_get_formats = &vaapi_transfer_get_formats,
.transfer_data_to = &vaapi_transfer_data_to,
.transfer_data_from = &vaapi_transfer_data_from,
.map_to = &vaapi_map_to,
.map_from = &vaapi_map_from,
.pix_fmts = (const enum AVPixelFormat[]) {
},
}

Definition at line 1863 of file hwcontext_vaapi.c.

vaapi_device_derive
static int vaapi_device_derive(AVHWDeviceContext *ctx, AVHWDeviceContext *src_ctx, AVDictionary *opts, int flags)
Definition: hwcontext_vaapi.c:1775
VAAPIDeviceContext
Definition: hwcontext_vaapi.c:68
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
AVVAAPIHWConfig
VAAPI hardware pipeline configuration details.
Definition: hwcontext_vaapi.h:110
AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES
@ AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES
The driver does not support surface attributes at all.
Definition: hwcontext_vaapi.h:60
vaapi_map_to
static int vaapi_map_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
Definition: hwcontext_vaapi.c:1533
vaapi_frames_init
static int vaapi_frames_init(AVHWFramesContext *hwfc)
Definition: hwcontext_vaapi.c:514
vaapi_transfer_data_to
static int vaapi_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_vaapi.c:928
vaapi_get_buffer
static int vaapi_get_buffer(AVHWFramesContext *hwfc, AVFrame *frame)
Definition: hwcontext_vaapi.c:675
vaapi_transfer_get_formats
static int vaapi_transfer_get_formats(AVHWFramesContext *hwfc, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
Definition: hwcontext_vaapi.c:689
device_init
static int device_init(AVFormatContext *ctx, int *width, int *height, uint32_t pixelformat)
Definition: v4l2.c:203
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
vaapi_device_init
static int vaapi_device_init(AVHWDeviceContext *hwdev)
Definition: hwcontext_vaapi.c:357
vaapi_transfer_data_from
static int vaapi_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_vaapi.c:897
vaapi_device_create
static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
Definition: hwcontext_vaapi.c:1620
AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE
@ AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE
The driver does not support the VASurfaceAttribMemoryType attribute, so the surface allocation code w...
Definition: hwcontext_vaapi.h:53
AV_PIX_FMT_VAAPI
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
Definition: pixfmt.h:119
AV_HWDEVICE_TYPE_VAAPI
@ AV_HWDEVICE_TYPE_VAAPI
Definition: hwcontext.h:31
vaapi_frames_get_constraints
static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, const void *hwconfig, AVHWFramesConstraints *constraints)
Definition: hwcontext_vaapi.c:195
vaapi_device_uninit
static void vaapi_device_uninit(AVHWDeviceContext *hwdev)
Definition: hwcontext_vaapi.c:447
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS
@ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
Definition: hwcontext_vaapi.h:47
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
VAAPIFramesContext
Definition: hwcontext_vaapi.c:74
AVVAAPIFramesContext
VAAPI-specific data associated with a frame pool.
Definition: hwcontext_vaapi.h:88
vaapi_map_from
static int vaapi_map_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
Definition: hwcontext_vaapi.c:1546
AVVAAPIDeviceContext
VAAPI connection details.
Definition: hwcontext_vaapi.h:68
vaapi_frames_uninit
static void vaapi_frames_uninit(AVHWFramesContext *hwfc)
Definition: hwcontext_vaapi.c:666