FFmpeg
Loading...
Searching...
No Matches
qsvdec.c File Reference
#include "config_components.h"
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <mfxvideo.h>
#include "libavutil/common.h"
#include "libavutil/fifo.h"
#include "libavutil/frame.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_qsv.h"
#include "libavutil/mem.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "libavutil/time.h"
#include "libavutil/imgutils.h"
#include "libavutil/film_grain_params.h"
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/avassert.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "internal.h"
#include "decode.h"
#include "hwconfig.h"
#include "qsv.h"
#include "qsv_internal.h"
#include "libavutil/refstruct.h"

Go to the source code of this file.

Data Structures

struct  QSVAsyncFrame
 
struct  QSVContext
 
struct  QSVDecContext
 

Macros

#define MFXUnload(a)
 
#define PTS_TO_MFX_PTS(pts, pts_tb)
 
#define MFX_PTS_TO_PTS(mfx_pts, pts_tb)
 
#define MFX_IMPL_VIA_MASK(impl)
 
#define OFFSET(x)
 
#define VD   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 
#define DEFINE_QSV_DECODER_WITH_OPTION(x, X, bsf_name, opt)
 
#define DEFINE_QSV_DECODER(x, X, bsf_name)
 

Enumerations

enum  LoadPlugin { LOAD_PLUGIN_NONE , LOAD_PLUGIN_HEVC_SW , LOAD_PLUGIN_HEVC_HW }
 

Functions

static int qsv_get_continuous_buffer (AVCodecContext *avctx, AVFrame *frame, AVBufferPool *pool)
 
static int qsv_init_session (AVCodecContext *avctx, QSVContext *q, mfxSession session, AVBufferRef *hw_frames_ref, AVBufferRef *hw_device_ref)
 
static int qsv_decode_preinit (AVCodecContext *avctx, QSVContext *q, enum AVPixelFormat pix_fmt, mfxVideoParam *param)
 
static int qsv_decode_init_context (AVCodecContext *avctx, QSVContext *q, mfxVideoParam *param)
 
static int qsv_decode_header (AVCodecContext *avctx, QSVContext *q, const AVPacket *avpkt, enum AVPixelFormat pix_fmt, mfxVideoParam *param)
 
static int alloc_frame (AVCodecContext *avctx, QSVContext *q, QSVFrame *frame)
 
static void qsv_clear_unused_frames (QSVContext *q)
 
static int get_surface (AVCodecContext *avctx, QSVContext *q, mfxFrameSurface1 **surf)
 
static QSVFramefind_frame (QSVContext *q, mfxFrameSurface1 *surf)
 
static int qsv_decode (AVCodecContext *avctx, QSVContext *q, AVFrame *frame, int *got_frame, const AVPacket *avpkt)
 
static void qsv_decode_close_qsvcontext (QSVContext *q)
 
static int qsv_process_data (AVCodecContext *avctx, QSVContext *q, AVFrame *frame, int *got_frame, const AVPacket *pkt)
 
static void qsv_clear_buffers (QSVDecContext *s)
 
static av_cold int qsv_decode_close (AVCodecContext *avctx)
 
static av_cold int qsv_decode_init (AVCodecContext *avctx)
 
static int qsv_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
 
static void qsv_decode_flush (AVCodecContext *avctx)
 

Variables

static const AVRational mfx_tb = { 1, 90000 }
 
static const AVCodecHWConfigInternal *const qsv_hw_configs []
 
static const AVOption options []
 

Macro Definition Documentation

◆ MFXUnload

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

Definition at line 59 of file qsvdec.c.

Referenced by qsv_init_session().

◆ PTS_TO_MFX_PTS

#define PTS_TO_MFX_PTS ( pts,
pts_tb )
Value:
((pts) == AV_NOPTS_VALUE ? \
MFX_TIMESTAMP_UNKNOWN : pts_tb.num ? \
av_rescale_q(pts, pts_tb, mfx_tb) : pts)
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
static const AVRational mfx_tb
Definition qsvdec.c:62
static int64_t pts

Definition at line 64 of file qsvdec.c.

Referenced by qsv_decode(), and qsv_decode_header().

◆ MFX_PTS_TO_PTS

#define MFX_PTS_TO_PTS ( mfx_pts,
pts_tb )
Value:
((mfx_pts) == MFX_TIMESTAMP_UNKNOWN ? \
AV_NOPTS_VALUE : pts_tb.num ? \
av_rescale_q(mfx_pts, mfx_tb, pts_tb) : mfx_pts)

Definition at line 68 of file qsvdec.c.

Referenced by qsv_decode().

◆ MFX_IMPL_VIA_MASK

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

Definition at line 72 of file qsvdec.c.

Referenced by qsv_init_session().

◆ OFFSET

#define OFFSET ( x)
Value:
offsetof(QSVDecContext, x)

Definition at line 1217 of file qsvdec.c.

◆ VD

Definition at line 1218 of file qsvdec.c.

◆ DEFINE_QSV_DECODER_WITH_OPTION

#define DEFINE_QSV_DECODER_WITH_OPTION ( x,
X,
bsf_name,
opt )
Value:
static const AVClass x##_qsv_class = { \
.class_name = #x "_qsv", \
.item_name = av_default_item_name, \
.option = opt, \
.version = LIBAVUTIL_VERSION_INT, \
}; \
const FFCodec ff_##x##_qsv_decoder = { \
.p.name = #x "_qsv", \
CODEC_LONG_NAME(#X " video (Intel Quick Sync Video acceleration)"), \
.priv_data_size = sizeof(QSVDecContext), \
.p.type = AVMEDIA_TYPE_VIDEO, \
.p.id = AV_CODEC_ID_##X, \
.init = qsv_decode_init, \
.flush = qsv_decode_flush, \
.close = qsv_decode_close, \
.bsfs = bsf_name, \
.p.priv_class = &x##_qsv_class, \
.hw_configs = qsv_hw_configs, \
.p.wrapper_name = "qsv", \
}; \
#define FF_CODEC_CAP_EXPORTS_CROPPING
The decoder sets the cropping fields in the output frames manually.
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_DECODE_CB(func)
#define X
Definition f_ebur128.c:157
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition codec.h:126
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition codec.h:79
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_HYBRID
Codec is potentially backed by a hardware implementation, but not necessarily.
Definition codec.h:140
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static int qsv_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition qsvdec.c:1157
static void qsv_decode_flush(AVCodecContext *avctx)
Definition qsvdec.c:1207
static const AVCodecHWConfigInternal *const qsv_hw_configs[]
Definition qsvdec.c:118
static av_cold int qsv_decode_init(AVCodecContext *avctx)
Definition qsvdec.c:1107
static av_cold int qsv_decode_close(AVCodecContext *avctx)
Definition qsvdec.c:1094
Describe the class of an AVClass context structure.
Definition log.h:76

Definition at line 1220 of file qsvdec.c.

◆ DEFINE_QSV_DECODER

#define DEFINE_QSV_DECODER ( x,
X,
bsf_name )
Value:
#define DEFINE_QSV_DECODER_WITH_OPTION(x, X, bsf_name, opt)
Definition qsvdec.c:1220

Definition at line 1245 of file qsvdec.c.

Enumeration Type Documentation

◆ LoadPlugin

enum LoadPlugin
Enumerator
LOAD_PLUGIN_NONE 
LOAD_PLUGIN_HEVC_SW 
LOAD_PLUGIN_HEVC_HW 

Definition at line 1068 of file qsvdec.c.

Function Documentation

◆ qsv_get_continuous_buffer()

static int qsv_get_continuous_buffer ( AVCodecContext * avctx,
AVFrame * frame,
AVBufferPool * pool )
static

Definition at line 131 of file qsvdec.c.

Referenced by alloc_frame().

◆ qsv_init_session()

static int qsv_init_session ( AVCodecContext * avctx,
QSVContext * q,
mfxSession session,
AVBufferRef * hw_frames_ref,
AVBufferRef * hw_device_ref )
static

Definition at line 186 of file qsvdec.c.

Referenced by qsv_decode_preinit().

◆ qsv_decode_preinit()

static int qsv_decode_preinit ( AVCodecContext * avctx,
QSVContext * q,
enum AVPixelFormat pix_fmt,
mfxVideoParam * param )
static

Definition at line 297 of file qsvdec.c.

Referenced by qsv_decode_header(), and qsv_process_data().

◆ qsv_decode_init_context()

static int qsv_decode_init_context ( AVCodecContext * avctx,
QSVContext * q,
mfxVideoParam * param )
static

Definition at line 396 of file qsvdec.c.

Referenced by qsv_process_data().

◆ qsv_decode_header()

static int qsv_decode_header ( AVCodecContext * avctx,
QSVContext * q,
const AVPacket * avpkt,
enum AVPixelFormat pix_fmt,
mfxVideoParam * param )
static

Definition at line 425 of file qsvdec.c.

Referenced by qsv_process_data().

◆ alloc_frame()

static int alloc_frame ( AVCodecContext * avctx,
QSVContext * q,
QSVFrame * frame )
static

Definition at line 494 of file qsvdec.c.

Referenced by get_surface().

◆ qsv_clear_unused_frames()

static void qsv_clear_unused_frames ( QSVContext * q)
static

Definition at line 563 of file qsvdec.c.

Referenced by get_surface().

◆ get_surface()

static int get_surface ( AVCodecContext * avctx,
QSVContext * q,
mfxFrameSurface1 ** surf )
static

Definition at line 575 of file qsvdec.c.

Referenced by qsv_decode().

◆ find_frame()

static QSVFrame * find_frame ( QSVContext * q,
mfxFrameSurface1 * surf )
static

Definition at line 616 of file qsvdec.c.

Referenced by qsv_decode().

◆ qsv_decode()

static int qsv_decode ( AVCodecContext * avctx,
QSVContext * q,
AVFrame * frame,
int * got_frame,
const AVPacket * avpkt )
static

Definition at line 788 of file qsvdec.c.

Referenced by qsv_process_data().

◆ qsv_decode_close_qsvcontext()

static void qsv_decode_close_qsvcontext ( QSVContext * q)
static

Definition at line 964 of file qsvdec.c.

Referenced by qsv_decode_close().

◆ qsv_process_data()

static int qsv_process_data ( AVCodecContext * avctx,
QSVContext * q,
AVFrame * frame,
int * got_frame,
const AVPacket * pkt )
static

Definition at line 992 of file qsvdec.c.

Referenced by qsv_decode_frame().

◆ qsv_clear_buffers()

static void qsv_clear_buffers ( QSVDecContext * s)
static

Definition at line 1085 of file qsvdec.c.

Referenced by qsv_decode_close(), and qsv_decode_flush().

◆ qsv_decode_close()

static av_cold int qsv_decode_close ( AVCodecContext * avctx)
static

Definition at line 1094 of file qsvdec.c.

Referenced by qsv_decode_init().

◆ qsv_decode_init()

static av_cold int qsv_decode_init ( AVCodecContext * avctx)
static

Definition at line 1107 of file qsvdec.c.

◆ qsv_decode_frame()

static int qsv_decode_frame ( AVCodecContext * avctx,
AVFrame * frame,
int * got_frame,
AVPacket * avpkt )
static

Definition at line 1157 of file qsvdec.c.

◆ qsv_decode_flush()

static void qsv_decode_flush ( AVCodecContext * avctx)
static

Definition at line 1207 of file qsvdec.c.

Variable Documentation

◆ mfx_tb

const AVRational mfx_tb = { 1, 90000 }
static

Definition at line 62 of file qsvdec.c.

◆ qsv_hw_configs

const AVCodecHWConfigInternal* const qsv_hw_configs[]
static
Initial value:
= {
.public = {
.pix_fmt = AV_PIX_FMT_QSV,
.device_type = AV_HWDEVICE_TYPE_QSV,
},
.hwaccel = NULL,
},
}
#define NULL
Definition coverity.c:32
@ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
The codec supports this format via the hw_frames_ctx interface.
Definition codec.h:295
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
Definition codec.h:282
@ AV_HWDEVICE_TYPE_QSV
Definition hwcontext.h:33
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition pixfmt.h:247

Definition at line 118 of file qsvdec.c.

◆ options

const AVOption options[]
static
Initial value:
= {
{ "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
{ "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, .unit = "gpu_copy"},
{ "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, .unit = "gpu_copy"},
{ "on", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON }, 0, 0, VD, .unit = "gpu_copy"},
{ "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF }, 0, 0, VD, .unit = "gpu_copy"},
{ NULL },
}
#define VD
Definition amfdec.c:787
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
#define ASYNC_DEPTH_DEFAULT

Definition at line 1268 of file qsvdec.c.