FFmpeg
Data Structures | Macros | Functions | Variables
hwcontext_qsv.c File Reference
#include <stdatomic.h>
#include <stdint.h>
#include <string.h>
#include <mfxvideo.h>
#include "config.h"
#include "buffer.h"
#include "common.h"
#include "hwcontext.h"
#include "hwcontext_internal.h"
#include "hwcontext_qsv.h"
#include "mem.h"
#include "pixfmt.h"
#include "pixdesc.h"
#include "time.h"
#include "imgutils.h"
#include "avassert.h"

Go to the source code of this file.

Data Structures

struct  QSVDevicePriv
 
struct  QSVDeviceContext
 
struct  QSVFramesContext
 

Macros

#define COBJMACROS
 
#define QSV_VERSION_ATLEAST(MAJOR, MINOR)
 
#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR)
 
#define MFX_IMPL_VIA_MASK(impl)   (0x0f00 & (impl))
 
#define QSV_ONEVPL   QSV_VERSION_ATLEAST(2, 0)
 
#define QSV_HAVE_OPAQUE   !QSV_ONEVPL
 
#define MFXUnload(a)   do { } while(0)
 

Functions

int ff_qsv_get_surface_base_handle (mfxFrameSurface1 *surf, enum AVHWDeviceType base_dev_type, void **base_handle)
 Caller needs to allocate enough space for base_handle pointer. More...
 
static uint32_t qsv_fourcc_from_pix_fmt (enum AVPixelFormat pix_fmt)
 
static uint16_t qsv_shift_from_pix_fmt (enum AVPixelFormat pix_fmt)
 
static int qsv_fill_border (AVFrame *dst, const AVFrame *src)
 
static int qsv_device_init (AVHWDeviceContext *ctx)
 
static void qsv_frames_uninit (AVHWFramesContext *ctx)
 
static void qsv_pool_release_dummy (void *opaque, uint8_t *data)
 
static AVBufferRefqsv_pool_alloc (void *opaque, size_t size)
 
static int qsv_init_child_ctx (AVHWFramesContext *ctx)
 
static int qsv_init_surface (AVHWFramesContext *ctx, mfxFrameSurface1 *surf)
 
static int qsv_init_pool (AVHWFramesContext *ctx, uint32_t fourcc)
 
static mfxStatus frame_alloc (mfxHDL pthis, mfxFrameAllocRequest *req, mfxFrameAllocResponse *resp)
 
static mfxStatus frame_free (mfxHDL pthis, mfxFrameAllocResponse *resp)
 
static mfxStatus frame_lock (mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
 
static mfxStatus frame_unlock (mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
 
static mfxStatus frame_get_hdl (mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
 
static int qsv_create_mfx_session (void *ctx, mfxHDL handle, mfxHandleType handle_type, mfxIMPL implementation, mfxVersion *pver, mfxSession *psession, void **ploader)
 
static int qsv_init_internal_session (AVHWFramesContext *ctx, mfxSession *session, int upload)
 
static int qsv_frames_init (AVHWFramesContext *ctx)
 
static int qsv_get_buffer (AVHWFramesContext *ctx, AVFrame *frame)
 
static int qsv_transfer_get_formats (AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
 
static int qsv_frames_derive_from (AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
 
static int qsv_map_from (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
 
static int qsv_transfer_data_child (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
 
static int map_frame_to_surface (const AVFrame *frame, mfxFrameSurface1 *surface)
 
static int qsv_internal_session_check_init (AVHWFramesContext *ctx, int upload)
 
static int qsv_transfer_data_from (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
 
static int qsv_transfer_data_to (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
 
static int qsv_frames_derive_to (AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
 
static int qsv_map_to (AVHWFramesContext *dst_ctx, AVFrame *dst, const AVFrame *src, int flags)
 
static int qsv_frames_get_constraints (AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
 
static void qsv_device_free (AVHWDeviceContext *ctx)
 
static mfxIMPL choose_implementation (const char *device, enum AVHWDeviceType child_device_type)
 
static int qsv_device_derive_from_child (AVHWDeviceContext *ctx, mfxIMPL implementation, AVHWDeviceContext *child_device_ctx, int flags)
 
static int qsv_device_derive (AVHWDeviceContext *ctx, AVHWDeviceContext *child_device_ctx, AVDictionary *opts, int flags)
 
static int qsv_device_create (AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
 

Variables

struct {
   enum AVPixelFormat   pix_fmt
 
   uint32_t   fourcc
 
   uint16_t   mfx_shift
 
supported_pixel_formats []
 
const HWContextType ff_hwcontext_type_qsv
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 31 of file hwcontext_qsv.c.

◆ QSV_VERSION_ATLEAST

#define QSV_VERSION_ATLEAST (   MAJOR,
  MINOR 
)
Value:
(MFX_VERSION_MAJOR > (MAJOR) || \
MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))

Definition at line 54 of file hwcontext_qsv.c.

◆ QSV_RUNTIME_VERSION_ATLEAST

#define QSV_RUNTIME_VERSION_ATLEAST (   MFX_VERSION,
  MAJOR,
  MINOR 
)
Value:
((MFX_VERSION.Major > (MAJOR)) || \
(MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))

Definition at line 58 of file hwcontext_qsv.c.

◆ MFX_IMPL_VIA_MASK

#define MFX_IMPL_VIA_MASK (   impl)    (0x0f00 & (impl))

Definition at line 62 of file hwcontext_qsv.c.

◆ QSV_ONEVPL

#define QSV_ONEVPL   QSV_VERSION_ATLEAST(2, 0)

Definition at line 63 of file hwcontext_qsv.c.

◆ QSV_HAVE_OPAQUE

#define QSV_HAVE_OPAQUE   !QSV_ONEVPL

Definition at line 64 of file hwcontext_qsv.c.

◆ MFXUnload

#define MFXUnload (   a)    do { } while(0)

Definition at line 69 of file hwcontext_qsv.c.

Function Documentation

◆ ff_qsv_get_surface_base_handle()

int ff_qsv_get_surface_base_handle ( mfxFrameSurface1 *  surf,
enum AVHWDeviceType  base_dev_type,
void **  base_handle 
)

Caller needs to allocate enough space for base_handle pointer.

Definition at line 171 of file hwcontext_qsv.c.

◆ qsv_fourcc_from_pix_fmt()

static uint32_t qsv_fourcc_from_pix_fmt ( enum AVPixelFormat  pix_fmt)
static

Definition at line 198 of file hwcontext_qsv.c.

Referenced by qsv_frames_init(), and qsv_init_surface().

◆ qsv_shift_from_pix_fmt()

static uint16_t qsv_shift_from_pix_fmt ( enum AVPixelFormat  pix_fmt)
static

Definition at line 208 of file hwcontext_qsv.c.

Referenced by qsv_init_surface().

◆ qsv_fill_border()

static int qsv_fill_border ( AVFrame dst,
const AVFrame src 
)
static

Definition at line 235 of file hwcontext_qsv.c.

Referenced by qsv_transfer_data_to().

◆ qsv_device_init()

static int qsv_device_init ( AVHWDeviceContext ctx)
static

Definition at line 283 of file hwcontext_qsv.c.

◆ qsv_frames_uninit()

static void qsv_frames_uninit ( AVHWFramesContext ctx)
static

Definition at line 339 of file hwcontext_qsv.c.

◆ qsv_pool_release_dummy()

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

Definition at line 372 of file hwcontext_qsv.c.

Referenced by qsv_pool_alloc().

◆ qsv_pool_alloc()

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

Definition at line 376 of file hwcontext_qsv.c.

Referenced by qsv_init_pool().

◆ qsv_init_child_ctx()

static int qsv_init_child_ctx ( AVHWFramesContext ctx)
static

Definition at line 391 of file hwcontext_qsv.c.

Referenced by qsv_init_pool().

◆ qsv_init_surface()

static int qsv_init_surface ( AVHWFramesContext ctx,
mfxFrameSurface1 *  surf 
)
static

Definition at line 536 of file hwcontext_qsv.c.

Referenced by qsv_frames_derive_to(), and qsv_init_pool().

◆ qsv_init_pool()

static int qsv_init_pool ( AVHWFramesContext ctx,
uint32_t  fourcc 
)
static

Definition at line 572 of file hwcontext_qsv.c.

Referenced by qsv_frames_init().

◆ frame_alloc()

static mfxStatus frame_alloc ( mfxHDL  pthis,
mfxFrameAllocRequest *  req,
mfxFrameAllocResponse *  resp 
)
static

Definition at line 623 of file hwcontext_qsv.c.

Referenced by qsv_init_internal_session().

◆ frame_free()

static mfxStatus frame_free ( mfxHDL  pthis,
mfxFrameAllocResponse *  resp 
)
static

Definition at line 651 of file hwcontext_qsv.c.

Referenced by qsv_init_internal_session().

◆ frame_lock()

static mfxStatus frame_lock ( mfxHDL  pthis,
mfxMemId  mid,
mfxFrameData *  ptr 
)
static

Definition at line 656 of file hwcontext_qsv.c.

Referenced by qsv_init_internal_session().

◆ frame_unlock()

static mfxStatus frame_unlock ( mfxHDL  pthis,
mfxMemId  mid,
mfxFrameData *  ptr 
)
static

Definition at line 661 of file hwcontext_qsv.c.

Referenced by qsv_init_internal_session().

◆ frame_get_hdl()

static mfxStatus frame_get_hdl ( mfxHDL  pthis,
mfxMemId  mid,
mfxHDL *  hdl 
)
static

Definition at line 666 of file hwcontext_qsv.c.

Referenced by qsv_init_internal_session().

◆ qsv_create_mfx_session()

static int qsv_create_mfx_session ( void *  ctx,
mfxHDL  handle,
mfxHandleType  handle_type,
mfxIMPL  implementation,
mfxVersion *  pver,
mfxSession *  psession,
void **  ploader 
)
static

Definition at line 1062 of file hwcontext_qsv.c.

Referenced by qsv_device_derive_from_child(), and qsv_init_internal_session().

◆ qsv_init_internal_session()

static int qsv_init_internal_session ( AVHWFramesContext ctx,
mfxSession *  session,
int  upload 
)
static

Definition at line 1121 of file hwcontext_qsv.c.

Referenced by qsv_internal_session_check_init().

◆ qsv_frames_init()

static int qsv_frames_init ( AVHWFramesContext ctx)
static

Definition at line 1240 of file hwcontext_qsv.c.

◆ qsv_get_buffer()

static int qsv_get_buffer ( AVHWFramesContext ctx,
AVFrame frame 
)
static

Definition at line 1312 of file hwcontext_qsv.c.

◆ qsv_transfer_get_formats()

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

Definition at line 1326 of file hwcontext_qsv.c.

◆ qsv_frames_derive_from()

static int qsv_frames_derive_from ( AVHWFramesContext dst_ctx,
AVHWFramesContext src_ctx,
int  flags 
)
static

Definition at line 1344 of file hwcontext_qsv.c.

◆ qsv_map_from()

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

Definition at line 1416 of file hwcontext_qsv.c.

◆ qsv_transfer_data_child()

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

Definition at line 1519 of file hwcontext_qsv.c.

Referenced by qsv_transfer_data_from(), and qsv_transfer_data_to().

◆ map_frame_to_surface()

static int map_frame_to_surface ( const AVFrame frame,
mfxFrameSurface1 *  surface 
)
static

Definition at line 1553 of file hwcontext_qsv.c.

Referenced by qsv_transfer_data_from(), and qsv_transfer_data_to().

◆ qsv_internal_session_check_init()

static int qsv_internal_session_check_init ( AVHWFramesContext ctx,
int  upload 
)
static

Definition at line 1622 of file hwcontext_qsv.c.

Referenced by qsv_transfer_data_from(), and qsv_transfer_data_to().

◆ qsv_transfer_data_from()

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

Definition at line 1648 of file hwcontext_qsv.c.

◆ qsv_transfer_data_to()

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

Definition at line 1731 of file hwcontext_qsv.c.

◆ qsv_frames_derive_to()

static int qsv_frames_derive_to ( AVHWFramesContext dst_ctx,
AVHWFramesContext src_ctx,
int  flags 
)
static

Definition at line 1824 of file hwcontext_qsv.c.

◆ qsv_map_to()

static int qsv_map_to ( AVHWFramesContext dst_ctx,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

Definition at line 1927 of file hwcontext_qsv.c.

◆ qsv_frames_get_constraints()

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

Definition at line 1987 of file hwcontext_qsv.c.

◆ qsv_device_free()

static void qsv_device_free ( AVHWDeviceContext ctx)
static

Definition at line 2012 of file hwcontext_qsv.c.

Referenced by qsv_device_create(), and qsv_device_derive().

◆ choose_implementation()

static mfxIMPL choose_implementation ( const char *  device,
enum AVHWDeviceType  child_device_type 
)
static

Definition at line 2026 of file hwcontext_qsv.c.

Referenced by qsv_device_create(), and qsv_device_derive().

◆ qsv_device_derive_from_child()

static int qsv_device_derive_from_child ( AVHWDeviceContext ctx,
mfxIMPL  implementation,
AVHWDeviceContext child_device_ctx,
int  flags 
)
static

Definition at line 2065 of file hwcontext_qsv.c.

Referenced by qsv_device_create(), and qsv_device_derive().

◆ qsv_device_derive()

static int qsv_device_derive ( AVHWDeviceContext ctx,
AVHWDeviceContext child_device_ctx,
AVDictionary opts,
int  flags 
)
static

Definition at line 2138 of file hwcontext_qsv.c.

◆ qsv_device_create()

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

Definition at line 2157 of file hwcontext_qsv.c.

Variable Documentation

◆ pix_fmt

enum AVPixelFormat pix_fmt

◆ fourcc

uint32_t fourcc

Definition at line 125 of file hwcontext_qsv.c.

Referenced by qsv_frames_init(), and qsv_init_surface().

◆ mfx_shift

uint16_t mfx_shift

Definition at line 126 of file hwcontext_qsv.c.

◆ supported_pixel_formats

const { ... } supported_pixel_formats[]

◆ ff_hwcontext_type_qsv

const HWContextType ff_hwcontext_type_qsv
Initial value:
= {
.name = "QSV",
.device_hwctx_size = sizeof(QSVDeviceContext),
.frames_hwctx_size = sizeof(QSVFramesContext),
.device_create = qsv_device_create,
.device_derive = qsv_device_derive,
.device_init = qsv_device_init,
.frames_get_constraints = qsv_frames_get_constraints,
.frames_init = qsv_frames_init,
.frames_uninit = qsv_frames_uninit,
.frames_get_buffer = qsv_get_buffer,
.transfer_get_formats = qsv_transfer_get_formats,
.transfer_data_to = qsv_transfer_data_to,
.transfer_data_from = qsv_transfer_data_from,
.map_to = qsv_map_to,
.map_from = qsv_map_from,
.frames_derive_to = qsv_frames_derive_to,
.frames_derive_from = qsv_frames_derive_from,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_QSV, AV_PIX_FMT_NONE },
}

Definition at line 2279 of file hwcontext_qsv.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
qsv_transfer_data_to
static int qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_qsv.c:1731
qsv_map_from
static int qsv_map_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
Definition: hwcontext_qsv.c:1416
qsv_device_derive
static int qsv_device_derive(AVHWDeviceContext *ctx, AVHWDeviceContext *child_device_ctx, AVDictionary *opts, int flags)
Definition: hwcontext_qsv.c:2138
qsv_frames_derive_from
static int qsv_frames_derive_from(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
Definition: hwcontext_qsv.c:1344
QSVDeviceContext
Definition: hwcontext_qsv.c:76
qsv_transfer_data_from
static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_qsv.c:1648
qsv_frames_get_constraints
static int qsv_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
Definition: hwcontext_qsv.c:1987
qsv_frames_derive_to
static int qsv_frames_derive_to(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
Definition: hwcontext_qsv.c:1824
qsv_frames_uninit
static void qsv_frames_uninit(AVHWFramesContext *ctx)
Definition: hwcontext_qsv.c:339
qsv_frames_init
static int qsv_frames_init(AVHWFramesContext *ctx)
Definition: hwcontext_qsv.c:1240
AV_PIX_FMT_QSV
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition: pixfmt.h:247
qsv_get_buffer
static int qsv_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
Definition: hwcontext_qsv.c:1312
qsv_transfer_get_formats
static int qsv_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
Definition: hwcontext_qsv.c:1326
qsv_device_init
static int qsv_device_init(AVHWDeviceContext *ctx)
Definition: hwcontext_qsv.c:283
qsv_map_to
static int qsv_map_to(AVHWFramesContext *dst_ctx, AVFrame *dst, const AVFrame *src, int flags)
Definition: hwcontext_qsv.c:1927
AV_HWDEVICE_TYPE_QSV
@ AV_HWDEVICE_TYPE_QSV
Definition: hwcontext.h:33
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
qsv_device_create
static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
Definition: hwcontext_qsv.c:2157
QSVFramesContext
Definition: qsv_internal.h:114