FFmpeg
Data Structures | Macros | Functions | Variables
qsvenc.c File Reference
#include <string.h>
#include <sys/types.h>
#include <mfxvideo.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_qsv.h"
#include "libavutil/mem.h"
#include "libavutil/log.h"
#include "libavutil/dict.h"
#include "libavutil/time.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "encode.h"
#include "internal.h"
#include "packet_internal.h"
#include "qsv.h"
#include "qsv_internal.h"
#include "qsvenc.h"
#include "libavutil/refstruct.h"

Go to the source code of this file.

Data Structures

struct  profile_names
 
struct  QSVPacket
 

Macros

#define UPDATE_PARAM(a, b)
 
#define MFX_IMPL_VIA_MASK(impl)   (0x0f00 & (impl))
 
#define UNMATCH(x)   (param_out.mfx.x != q->param.mfx.x)
 

Functions

static const char * print_profile (enum AVCodecID codec_id, mfxU16 profile)
 
static const char * print_ratecontrol (mfxU16 rc_mode)
 
static const char * print_threestate (mfxU16 val)
 
static void dump_video_param (AVCodecContext *avctx, QSVEncContext *q, mfxExtBuffer **coding_opts)
 
static void dump_video_vp9_param (AVCodecContext *avctx, QSVEncContext *q, mfxExtBuffer **coding_opts)
 
static void dump_video_mjpeg_param (AVCodecContext *avctx, QSVEncContext *q)
 
static int select_rc_mode (AVCodecContext *avctx, QSVEncContext *q)
 
static int check_enc_param (AVCodecContext *avctx, QSVEncContext *q)
 
static int is_strict_gop (QSVEncContext *q)
 
static int init_video_param_jpeg (AVCodecContext *avctx, QSVEncContext *q)
 
static int init_video_param (AVCodecContext *avctx, QSVEncContext *q)
 
static int qsv_retrieve_enc_jpeg_params (AVCodecContext *avctx, QSVEncContext *q)
 
static int qsv_retrieve_enc_vp9_params (AVCodecContext *avctx, QSVEncContext *q)
 
static int qsv_retrieve_enc_av1_params (AVCodecContext *avctx, QSVEncContext *q)
 
static int qsv_retrieve_enc_params (AVCodecContext *avctx, QSVEncContext *q)
 
static int qsv_init_opaque_alloc (AVCodecContext *avctx, QSVEncContext *q)
 
static int qsvenc_init_session (AVCodecContext *avctx, QSVEncContext *q)
 
int ff_qsv_enc_init (AVCodecContext *avctx, QSVEncContext *q)
 
static void free_encoder_ctrl (mfxEncodeCtrl *enc_ctrl)
 
static void clear_unused_frames (QSVEncContext *q)
 
static int get_free_frame (QSVEncContext *q, QSVFrame **f)
 
static int qsvenc_fill_padding_area (AVFrame *frame, int new_w, int new_h)
 
static int qsvenc_get_continuous_buffer (AVFrame *frame)
 
static int submit_frame (QSVEncContext *q, const AVFrame *frame, QSVFrame **new_frame)
 
static void print_interlace_msg (AVCodecContext *avctx, QSVEncContext *q)
 
static int set_roi_encode_ctrl (AVCodecContext *avctx, const AVFrame *frame, mfxEncodeCtrl *enc_ctrl)
 
static void set_skip_frame_encode_ctrl (AVCodecContext *avctx, const AVFrame *frame, mfxEncodeCtrl *enc_ctrl)
 
static int update_qp (AVCodecContext *avctx, QSVEncContext *q)
 
static int update_max_frame_size (AVCodecContext *avctx, QSVEncContext *q)
 
static int update_gop_size (AVCodecContext *avctx, QSVEncContext *q)
 
static int update_rir (AVCodecContext *avctx, QSVEncContext *q)
 
static int update_min_max_qp (AVCodecContext *avctx, QSVEncContext *q)
 
static int update_low_delay_brc (AVCodecContext *avctx, QSVEncContext *q)
 
static int update_frame_rate (AVCodecContext *avctx, QSVEncContext *q)
 
static int update_bitrate (AVCodecContext *avctx, QSVEncContext *q)
 
static int update_pic_timing_sei (AVCodecContext *avctx, QSVEncContext *q)
 
static int encode_frame (AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame)
 
static int update_parameters (AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame)
 
int ff_qsv_encode (AVCodecContext *avctx, QSVEncContext *q, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
int ff_qsv_enc_close (AVCodecContext *avctx, QSVEncContext *q)
 

Variables

static const struct profile_names avc_profiles []
 
static const struct profile_names mpeg2_profiles []
 
static const struct profile_names hevc_profiles []
 
static const struct profile_names vp9_profiles []
 
static const struct profile_names av1_profiles []
 
struct {
   mfxU16   rc_mode
 
   const char *   name
 
rc_names []
 
const AVCodecHWConfigInternal *const ff_qsv_enc_hw_configs []
 

Macro Definition Documentation

◆ UPDATE_PARAM

#define UPDATE_PARAM (   a,
  b 
)
Value:
do { \
if ((a) != (b)) { \
a = b; \
updated = 1; \
} \
} while (0) \

Definition at line 165 of file qsvenc.c.

◆ MFX_IMPL_VIA_MASK

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

Definition at line 173 of file qsvenc.c.

◆ UNMATCH

#define UNMATCH (   x)    (param_out.mfx.x != q->param.mfx.x)

Function Documentation

◆ print_profile()

static const char* print_profile ( enum AVCodecID  codec_id,
mfxU16  profile 
)
static

Definition at line 100 of file qsvenc.c.

Referenced by dump_video_param(), and dump_video_vp9_param().

◆ print_ratecontrol()

static const char* print_ratecontrol ( mfxU16  rc_mode)
static

Definition at line 175 of file qsvenc.c.

Referenced by dump_video_param(), and dump_video_vp9_param().

◆ print_threestate()

static const char* print_threestate ( mfxU16  val)
static

◆ dump_video_param()

static void dump_video_param ( AVCodecContext avctx,
QSVEncContext q,
mfxExtBuffer **  coding_opts 
)
static

Definition at line 193 of file qsvenc.c.

Referenced by qsv_retrieve_enc_params().

◆ dump_video_vp9_param()

static void dump_video_vp9_param ( AVCodecContext avctx,
QSVEncContext q,
mfxExtBuffer **  coding_opts 
)
static

Definition at line 405 of file qsvenc.c.

Referenced by qsv_retrieve_enc_vp9_params().

◆ dump_video_mjpeg_param()

static void dump_video_mjpeg_param ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 476 of file qsvenc.c.

Referenced by qsv_retrieve_enc_jpeg_params().

◆ select_rc_mode()

static int select_rc_mode ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 572 of file qsvenc.c.

Referenced by init_video_param().

◆ check_enc_param()

static int check_enc_param ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 670 of file qsvenc.c.

Referenced by init_video_param().

◆ is_strict_gop()

static int is_strict_gop ( QSVEncContext q)
static

Definition at line 701 of file qsvenc.c.

Referenced by init_video_param().

◆ init_video_param_jpeg()

static int init_video_param_jpeg ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 707 of file qsvenc.c.

Referenced by ff_qsv_enc_init().

◆ init_video_param()

static int init_video_param ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 774 of file qsvenc.c.

Referenced by ff_qsv_enc_init().

◆ qsv_retrieve_enc_jpeg_params()

static int qsv_retrieve_enc_jpeg_params ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 1295 of file qsvenc.c.

Referenced by ff_qsv_enc_init().

◆ qsv_retrieve_enc_vp9_params()

static int qsv_retrieve_enc_vp9_params ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 1315 of file qsvenc.c.

Referenced by ff_qsv_enc_init().

◆ qsv_retrieve_enc_av1_params()

static int qsv_retrieve_enc_av1_params ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 1369 of file qsvenc.c.

Referenced by ff_qsv_enc_init().

◆ qsv_retrieve_enc_params()

static int qsv_retrieve_enc_params ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 1419 of file qsvenc.c.

Referenced by ff_qsv_enc_init().

◆ qsv_init_opaque_alloc()

static int qsv_init_opaque_alloc ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 1551 of file qsvenc.c.

Referenced by ff_qsv_enc_init().

◆ qsvenc_init_session()

static int qsvenc_init_session ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 1589 of file qsvenc.c.

Referenced by ff_qsv_enc_init().

◆ ff_qsv_enc_init()

int ff_qsv_enc_init ( AVCodecContext avctx,
QSVEncContext q 
)

Definition at line 1635 of file qsvenc.c.

Referenced by qsv_enc_init().

◆ free_encoder_ctrl()

static void free_encoder_ctrl ( mfxEncodeCtrl *  enc_ctrl)
static

Definition at line 1850 of file qsvenc.c.

Referenced by clear_unused_frames(), and ff_qsv_enc_close().

◆ clear_unused_frames()

static void clear_unused_frames ( QSVEncContext q)
static

Definition at line 1864 of file qsvenc.c.

Referenced by get_free_frame().

◆ get_free_frame()

static int get_free_frame ( QSVEncContext q,
QSVFrame **  f 
)
static

Definition at line 1883 of file qsvenc.c.

Referenced by submit_frame().

◆ qsvenc_fill_padding_area()

static int qsvenc_fill_padding_area ( AVFrame frame,
int  new_w,
int  new_h 
)
static

Definition at line 1920 of file qsvenc.c.

Referenced by submit_frame().

◆ qsvenc_get_continuous_buffer()

static int qsvenc_get_continuous_buffer ( AVFrame frame)
static

Definition at line 1979 of file qsvenc.c.

Referenced by submit_frame().

◆ submit_frame()

static int submit_frame ( QSVEncContext q,
const AVFrame frame,
QSVFrame **  new_frame 
)
static

Definition at line 2034 of file qsvenc.c.

Referenced by encode_frame().

◆ print_interlace_msg()

static void print_interlace_msg ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2122 of file qsvenc.c.

Referenced by encode_frame().

◆ set_roi_encode_ctrl()

static int set_roi_encode_ctrl ( AVCodecContext avctx,
const AVFrame frame,
mfxEncodeCtrl *  enc_ctrl 
)
static

Definition at line 2134 of file qsvenc.c.

Referenced by encode_frame().

◆ set_skip_frame_encode_ctrl()

static void set_skip_frame_encode_ctrl ( AVCodecContext avctx,
const AVFrame frame,
mfxEncodeCtrl *  enc_ctrl 
)
static

Definition at line 2195 of file qsvenc.c.

Referenced by encode_frame().

◆ update_qp()

static int update_qp ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2208 of file qsvenc.c.

Referenced by update_parameters().

◆ update_max_frame_size()

static int update_max_frame_size ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2237 of file qsvenc.c.

Referenced by update_parameters().

◆ update_gop_size()

static int update_gop_size ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2255 of file qsvenc.c.

Referenced by update_parameters().

◆ update_rir()

static int update_rir ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2269 of file qsvenc.c.

Referenced by update_parameters().

◆ update_min_max_qp()

static int update_min_max_qp ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2297 of file qsvenc.c.

Referenced by update_parameters().

◆ update_low_delay_brc()

static int update_low_delay_brc ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2362 of file qsvenc.c.

Referenced by update_parameters().

◆ update_frame_rate()

static int update_frame_rate ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2384 of file qsvenc.c.

Referenced by update_parameters().

◆ update_bitrate()

static int update_bitrate ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2408 of file qsvenc.c.

Referenced by update_parameters().

◆ update_pic_timing_sei()

static int update_pic_timing_sei ( AVCodecContext avctx,
QSVEncContext q 
)
static

Definition at line 2441 of file qsvenc.c.

Referenced by update_parameters().

◆ encode_frame()

static int encode_frame ( AVCodecContext avctx,
QSVEncContext q,
const AVFrame frame 
)
static

Definition at line 2460 of file qsvenc.c.

Referenced by ff_qsv_encode(), and update_parameters().

◆ update_parameters()

static int update_parameters ( AVCodecContext avctx,
QSVEncContext q,
const AVFrame frame 
)
static

Definition at line 2580 of file qsvenc.c.

Referenced by ff_qsv_encode().

◆ ff_qsv_encode()

int ff_qsv_encode ( AVCodecContext avctx,
QSVEncContext q,
AVPacket pkt,
const AVFrame frame,
int *  got_packet 
)

Definition at line 2640 of file qsvenc.c.

Referenced by qsv_enc_frame().

◆ ff_qsv_enc_close()

int ff_qsv_enc_close ( AVCodecContext avctx,
QSVEncContext q 
)

Definition at line 2708 of file qsvenc.c.

Referenced by qsv_enc_close(), and qsv_enc_init().

Variable Documentation

◆ avc_profiles

const struct profile_names avc_profiles[]
static
Initial value:
= {
{ MFX_PROFILE_AVC_BASELINE, "avc baseline" },
{ MFX_PROFILE_AVC_MAIN, "avc main" },
{ MFX_PROFILE_AVC_EXTENDED, "avc extended" },
{ MFX_PROFILE_AVC_HIGH, "avc high" },
{ MFX_PROFILE_AVC_HIGH_422, "avc high 422" },
{ MFX_PROFILE_AVC_CONSTRAINED_BASELINE, "avc constrained baseline" },
{ MFX_PROFILE_AVC_CONSTRAINED_HIGH, "avc constrained high" },
{ MFX_PROFILE_AVC_PROGRESSIVE_HIGH, "avc progressive high" },
}

Definition at line 52 of file qsvenc.c.

Referenced by print_profile().

◆ mpeg2_profiles

const struct profile_names mpeg2_profiles[]
static
Initial value:
= {
{ MFX_PROFILE_MPEG2_SIMPLE, "mpeg2 simple" },
{ MFX_PROFILE_MPEG2_MAIN, "mpeg2 main" },
{ MFX_PROFILE_MPEG2_HIGH, "mpeg2 high" },
}

Definition at line 63 of file qsvenc.c.

Referenced by print_profile().

◆ hevc_profiles

const struct profile_names hevc_profiles[]
static
Initial value:
= {
{ MFX_PROFILE_HEVC_MAIN, "hevc main" },
{ MFX_PROFILE_HEVC_MAIN10, "hevc main10" },
{ MFX_PROFILE_HEVC_MAINSP, "hevc mainsp" },
{ MFX_PROFILE_HEVC_REXT, "hevc rext" },
}

Definition at line 69 of file qsvenc.c.

Referenced by print_profile().

◆ vp9_profiles

const struct profile_names vp9_profiles[]
static
Initial value:
= {
{ MFX_PROFILE_VP9_0, "vp9 0" },
{ MFX_PROFILE_VP9_1, "vp9 1" },
{ MFX_PROFILE_VP9_2, "vp9 2" },
{ MFX_PROFILE_VP9_3, "vp9 3" },
}

Definition at line 79 of file qsvenc.c.

Referenced by print_profile().

◆ av1_profiles

const struct profile_names av1_profiles[]
static
Initial value:
= {
}

Definition at line 86 of file qsvenc.c.

Referenced by print_profile().

◆ rc_mode

mfxU16 rc_mode

◆ name

const char* name

Definition at line 144 of file qsvenc.c.

◆ rc_names

const { ... } rc_names[]
Initial value:
= {
{ MFX_RATECONTROL_CBR, "CBR" },
{ MFX_RATECONTROL_VBR, "VBR" },
{ MFX_RATECONTROL_CQP, "CQP" },
{ MFX_RATECONTROL_LA, "LA" },
{ MFX_RATECONTROL_ICQ, "ICQ" },
{ MFX_RATECONTROL_LA_ICQ, "LA_ICQ" },
{ MFX_RATECONTROL_LA_EXT, "LA_EXT" },
{ MFX_RATECONTROL_LA_HRD, "LA_HRD" },
{ MFX_RATECONTROL_QVBR, "QVBR" },
}

Referenced by print_ratecontrol().

◆ ff_qsv_enc_hw_configs

const AVCodecHWConfigInternal* const ff_qsv_enc_hw_configs[]
Initial value:

Definition at line 2760 of file qsvenc.c.

b
#define b
Definition: input.c:41
NULL
#define NULL
Definition: coverity.c:32
HW_CONFIG_ENCODER_DEVICE
#define HW_CONFIG_ENCODER_DEVICE(format, device_type_)
Definition: hwconfig.h:95
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
HW_CONFIG_ENCODER_FRAMES
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
Definition: hwconfig.h:98