FFmpeg
Macros | Functions | Variables
qsv.c File Reference
#include <mfxvideo.h>
#include <mfxjpeg.h>
#include <mfxvp8.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/error.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_qsv.h"
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "avcodec.h"
#include "qsv_internal.h"
#include "libavutil/refstruct.h"
#include <mfxplugin.h>

Go to the source code of this file.

Macros

#define MFX_IMPL_VIA_MASK(impl)   (0x0f00 & (impl))
 
#define QSV_HAVE_USER_PLUGIN   !QSV_ONEVPL
 
#define QSV_HAVE_AUDIO   !QSV_ONEVPL
 
#define MFXUnload(a)   do { } while(0)
 

Functions

int ff_qsv_codec_id_to_mfx (enum AVCodecID codec_id)
 
int ff_qsv_print_iopattern (void *log_ctx, int mfx_iopattern, const char *extra_string)
 
static int qsv_map_error (mfxStatus mfx_err, const char **desc)
 Convert a libmfx error code into an FFmpeg error code. More...
 
int ff_qsv_print_error (void *log_ctx, mfxStatus err, const char *error_string)
 
int ff_qsv_print_warning (void *log_ctx, mfxStatus err, const char *warning_string)
 
enum AVPixelFormat ff_qsv_map_fourcc (uint32_t fourcc)
 
int ff_qsv_map_pixfmt (enum AVPixelFormat format, uint32_t *fourcc, uint16_t *shift)
 
int ff_qsv_map_frame_to_surface (const AVFrame *frame, mfxFrameSurface1 *surface)
 
int ff_qsv_find_surface_idx (QSVFramesContext *ctx, QSVFrame *frame)
 
enum AVFieldOrder ff_qsv_map_picstruct (int mfx_pic_struct)
 
enum AVPictureType ff_qsv_map_pictype (int mfx_pic_type)
 
static int qsv_load_plugins (mfxSession session, const char *load_plugins, void *logctx)
 
static int qsv_create_mfx_session (AVCodecContext *avctx, mfxIMPL implementation, mfxVersion *pver, int gpu_copy, mfxSession *psession, void **ploader)
 
int ff_qsv_init_internal_session (AVCodecContext *avctx, QSVSession *qs, const char *load_plugins, int gpu_copy)
 
static void mids_buf_free (AVRefStructOpaque opaque, void *obj)
 
static QSVMidqsv_create_mids (AVBufferRef *hw_frames_ref)
 
static int qsv_setup_mids (mfxFrameAllocResponse *resp, AVBufferRef *hw_frames_ref, QSVMid *mids)
 
static mfxStatus qsv_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest *req, mfxFrameAllocResponse *resp)
 
static mfxStatus qsv_frame_free (mfxHDL pthis, mfxFrameAllocResponse *resp)
 
static mfxStatus qsv_frame_lock (mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
 
static mfxStatus qsv_frame_unlock (mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
 
static mfxStatus qsv_frame_get_hdl (mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
 
int ff_qsv_init_session_device (AVCodecContext *avctx, mfxSession *psession, AVBufferRef *device_ref, const char *load_plugins, int gpu_copy)
 
int ff_qsv_init_session_frames (AVCodecContext *avctx, mfxSession *psession, QSVFramesContext *qsv_frames_ctx, const char *load_plugins, int opaque, int gpu_copy)
 
int ff_qsv_close_internal_session (QSVSession *qs)
 
void ff_qsv_frame_add_ext_param (AVCodecContext *avctx, QSVFrame *frame, mfxExtBuffer *param)
 

Variables

struct {
   int   mfx_iopattern
 
   const char *   desc
 
qsv_iopatterns []
 
struct {
   mfxStatus   mfxerr
 
   int   averr
 
   const char *   desc
 
qsv_errors []
 

Macro Definition Documentation

◆ MFX_IMPL_VIA_MASK

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

Definition at line 40 of file qsv.c.

◆ QSV_HAVE_USER_PLUGIN

#define QSV_HAVE_USER_PLUGIN   !QSV_ONEVPL

Definition at line 41 of file qsv.c.

◆ QSV_HAVE_AUDIO

#define QSV_HAVE_AUDIO   !QSV_ONEVPL

Definition at line 42 of file qsv.c.

◆ MFXUnload

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

Definition at line 51 of file qsv.c.

Function Documentation

◆ ff_qsv_codec_id_to_mfx()

int ff_qsv_codec_id_to_mfx ( enum AVCodecID  codec_id)

Definition at line 54 of file qsv.c.

Referenced by init_video_param(), init_video_param_jpeg(), and qsv_decode_header().

◆ ff_qsv_print_iopattern()

int ff_qsv_print_iopattern ( void *  log_ctx,
int  mfx_iopattern,
const char *  extra_string 
)

Definition at line 104 of file qsv.c.

Referenced by ff_qsv_enc_init(), and qsv_decode_preinit().

◆ qsv_map_error()

static int qsv_map_error ( mfxStatus  mfx_err,
const char **  desc 
)
static

Convert a libmfx error code into an FFmpeg error code.

Definition at line 174 of file qsv.c.

Referenced by ff_qsv_print_error(), and ff_qsv_print_warning().

◆ ff_qsv_print_error()

int ff_qsv_print_error ( void *  log_ctx,
mfxStatus  err,
const char *  error_string 
)

◆ ff_qsv_print_warning()

int ff_qsv_print_warning ( void *  log_ctx,
mfxStatus  err,
const char *  warning_string 
)

Definition at line 198 of file qsv.c.

Referenced by encode_frame(), ff_qsv_enc_init(), qsv_create_mfx_session(), and qsv_decode().

◆ ff_qsv_map_fourcc()

enum AVPixelFormat ff_qsv_map_fourcc ( uint32_t  fourcc)

Definition at line 207 of file qsv.c.

Referenced by qsv_decode_init_context(), qsv_frame_alloc(), and qsv_process_data().

◆ ff_qsv_map_pixfmt()

int ff_qsv_map_pixfmt ( enum AVPixelFormat  format,
uint32_t *  fourcc,
uint16_t *  shift 
)

Definition at line 228 of file qsv.c.

Referenced by init_video_param(), and init_video_param_jpeg().

◆ ff_qsv_map_frame_to_surface()

int ff_qsv_map_frame_to_surface ( const AVFrame frame,
mfxFrameSurface1 *  surface 
)

Definition at line 287 of file qsv.c.

Referenced by alloc_frame(), and submit_frame().

◆ ff_qsv_find_surface_idx()

int ff_qsv_find_surface_idx ( QSVFramesContext ctx,
QSVFrame frame 
)

Definition at line 348 of file qsv.c.

Referenced by alloc_frame(), and submit_frame().

◆ ff_qsv_map_picstruct()

enum AVFieldOrder ff_qsv_map_picstruct ( int  mfx_pic_struct)

Definition at line 361 of file qsv.c.

Referenced by qsv_decode_init_context().

◆ ff_qsv_map_pictype()

enum AVPictureType ff_qsv_map_pictype ( int  mfx_pic_type)

Definition at line 379 of file qsv.c.

Referenced by qsv_decode().

◆ qsv_load_plugins()

static int qsv_load_plugins ( mfxSession  session,
const char *  load_plugins,
void *  logctx 
)
static

Definition at line 408 of file qsv.c.

Referenced by ff_qsv_init_internal_session(), and ff_qsv_init_session_device().

◆ qsv_create_mfx_session()

static int qsv_create_mfx_session ( AVCodecContext avctx,
mfxIMPL  implementation,
mfxVersion *  pver,
int  gpu_copy,
mfxSession *  psession,
void **  ploader 
)
static

Definition at line 642 of file qsv.c.

Referenced by ff_qsv_init_internal_session(), and ff_qsv_init_session_device().

◆ ff_qsv_init_internal_session()

int ff_qsv_init_internal_session ( AVCodecContext avctx,
QSVSession qs,
const char *  load_plugins,
int  gpu_copy 
)

Definition at line 681 of file qsv.c.

Referenced by qsv_init_session(), and qsvenc_init_session().

◆ mids_buf_free()

static void mids_buf_free ( AVRefStructOpaque  opaque,
void *  obj 
)
static

Definition at line 748 of file qsv.c.

Referenced by qsv_create_mids().

◆ qsv_create_mids()

static QSVMid* qsv_create_mids ( AVBufferRef hw_frames_ref)
static

Definition at line 754 of file qsv.c.

Referenced by ff_qsv_init_session_frames(), and qsv_frame_alloc().

◆ qsv_setup_mids()

static int qsv_setup_mids ( mfxFrameAllocResponse *  resp,
AVBufferRef hw_frames_ref,
QSVMid mids 
)
static

Definition at line 784 of file qsv.c.

Referenced by qsv_frame_alloc().

◆ qsv_frame_alloc()

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

Definition at line 814 of file qsv.c.

Referenced by ff_qsv_init_session_frames().

◆ qsv_frame_free()

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

Definition at line 916 of file qsv.c.

Referenced by ff_qsv_init_session_frames().

◆ qsv_frame_lock()

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

Definition at line 927 of file qsv.c.

Referenced by ff_qsv_init_session_frames().

◆ qsv_frame_unlock()

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

Definition at line 993 of file qsv.c.

Referenced by ff_qsv_init_session_frames().

◆ qsv_frame_get_hdl()

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

Definition at line 1010 of file qsv.c.

Referenced by ff_qsv_init_session_frames().

◆ ff_qsv_init_session_device()

int ff_qsv_init_session_device ( AVCodecContext avctx,
mfxSession *  psession,
AVBufferRef device_ref,
const char *  load_plugins,
int  gpu_copy 
)

Definition at line 1032 of file qsv.c.

Referenced by ff_qsv_init_session_frames(), qsv_init_session(), and qsvenc_init_session().

◆ ff_qsv_init_session_frames()

int ff_qsv_init_session_frames ( AVCodecContext avctx,
mfxSession *  psession,
QSVFramesContext qsv_frames_ctx,
const char *  load_plugins,
int  opaque,
int  gpu_copy 
)

Definition at line 1109 of file qsv.c.

Referenced by qsv_init_session(), and qsvenc_init_session().

◆ ff_qsv_close_internal_session()

int ff_qsv_close_internal_session ( QSVSession qs)

Definition at line 1159 of file qsv.c.

Referenced by ff_qsv_enc_close(), and qsv_decode_close_qsvcontext().

◆ ff_qsv_frame_add_ext_param()

void ff_qsv_frame_add_ext_param ( AVCodecContext avctx,
QSVFrame frame,
mfxExtBuffer *  param 
)

Definition at line 1177 of file qsv.c.

Referenced by alloc_frame().

Variable Documentation

◆ mfx_iopattern

int mfx_iopattern

Definition at line 89 of file qsv.c.

Referenced by ff_qsv_print_iopattern().

◆ desc

const char* desc

◆ qsv_iopatterns

const { ... } qsv_iopatterns[]
Initial value:
= {
{MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface" },
{MFX_IOPATTERN_IN_SYSTEM_MEMORY, "input is system memory surface" },
{MFX_IOPATTERN_IN_OPAQUE_MEMORY, "input is opaque memory surface" },
{MFX_IOPATTERN_OUT_VIDEO_MEMORY, "output is video memory surface" },
{MFX_IOPATTERN_OUT_SYSTEM_MEMORY, "output is system memory surface" },
{MFX_IOPATTERN_OUT_OPAQUE_MEMORY, "output is opaque memory surface" },
}

Referenced by ff_qsv_print_iopattern().

◆ mfxerr

mfxStatus mfxerr

Definition at line 122 of file qsv.c.

Referenced by qsv_map_error().

◆ averr

int averr

Definition at line 123 of file qsv.c.

◆ qsv_errors

const { ... } qsv_errors[]

Referenced by qsv_map_error().