FFmpeg
Data Structures | Macros | Functions | Variables
vaapi_encode.c File Reference
#include <inttypes.h>
#include <string.h>
#include "config.h"
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "vaapi_encode.h"
#include "encode.h"
#include "avcodec.h"
#include "refstruct.h"

Go to the source code of this file.

Data Structures

struct  VAAPIEncodeRTFormat
 

Macros

#define TRY_RC_MODE(mode, fail)
 

Functions

static int vaapi_encode_make_packed_header (AVCodecContext *avctx, VAAPIEncodePicture *pic, int type, char *data, size_t bit_len)
 
static int vaapi_encode_make_param_buffer (AVCodecContext *avctx, VAAPIEncodePicture *pic, int type, char *data, size_t len)
 
static int vaapi_encode_make_misc_param_buffer (AVCodecContext *avctx, VAAPIEncodePicture *pic, int type, const void *data, size_t len)
 
static int vaapi_encode_wait (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
 
static int vaapi_encode_make_row_slice (AVCodecContext *avctx, VAAPIEncodePicture *pic)
 
static int vaapi_encode_make_tile_slice (AVCodecContext *avctx, VAAPIEncodePicture *pic)
 
static int vaapi_encode_issue (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
 
static int vaapi_encode_get_coded_buffer_size (AVCodecContext *avctx, VABufferID buf_id)
 
static int vaapi_encode_get_coded_buffer_data (AVCodecContext *avctx, VABufferID buf_id, uint8_t **dst)
 
static int vaapi_encode_get_coded_data (AVCodecContext *avctx, VAAPIEncodePicture *pic, AVPacket *pkt)
 
static int vaapi_encode_output (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, AVPacket *pkt)
 
static int vaapi_encode_discard (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
 
static int vaapi_encode_init (AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
 
static int vaapi_encode_free (AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
 
static av_cold void vaapi_encode_add_global_param (AVCodecContext *avctx, int type, void *buffer, size_t size)
 
static av_cold int vaapi_encode_profile_entrypoint (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_init_rate_control (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_init_max_frame_size (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_init_gop_structure (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_init_row_slice_structure (AVCodecContext *avctx, uint32_t slice_structure)
 
static av_cold int vaapi_encode_init_tile_slice_structure (AVCodecContext *avctx, uint32_t slice_structure)
 
static av_cold int vaapi_encode_init_slice_structure (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_init_packed_headers (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_init_quality (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_init_roi (AVCodecContext *avctx)
 
static void vaapi_encode_free_output_buffer (FFRefStructOpaque opaque, void *obj)
 
static int vaapi_encode_alloc_output_buffer (FFRefStructOpaque opaque, void *obj)
 
static av_cold int vaapi_encode_create_recon_frames (AVCodecContext *avctx)
 
int ff_vaapi_encode_receive_packet (AVCodecContext *avctx, AVPacket *pkt)
 
av_cold int ff_vaapi_encode_init (AVCodecContext *avctx)
 
av_cold int ff_vaapi_encode_close (AVCodecContext *avctx)
 

Variables

const AVCodecHWConfigInternal *const ff_vaapi_encode_hw_configs []
 
static const VAAPIEncodeRTFormat vaapi_encode_rt_formats []
 
static const VAEntrypoint vaapi_encode_entrypoints_normal []
 
static const VAAPIEncodeRCMode vaapi_encode_rc_modes []
 
static const FFHWEncodePictureOperation vaapi_op
 

Macro Definition Documentation

◆ TRY_RC_MODE

#define TRY_RC_MODE (   mode,
  fail 
)
Value:
do { \
rc_mode = &vaapi_encode_rc_modes[mode]; \
if (!(rc_mode->va_mode & supported_va_rc_modes)) { \
if (fail) { \
av_log(avctx, AV_LOG_ERROR, "Driver does not support %s " \
"RC mode (supported modes: %s).\n", rc_mode->name, \
supported_rc_modes_string); \
return AVERROR(EINVAL); \
} \
av_log(avctx, AV_LOG_DEBUG, "Driver does not support %s " \
"RC mode.\n", rc_mode->name); \
rc_mode = NULL; \
} else { \
goto rc_mode_found; \
} \
} while (0)

Function Documentation

◆ vaapi_encode_make_packed_header()

static int vaapi_encode_make_packed_header ( AVCodecContext avctx,
VAAPIEncodePicture pic,
int  type,
char *  data,
size_t  bit_len 
)
static

Definition at line 41 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

◆ vaapi_encode_make_param_buffer()

static int vaapi_encode_make_param_buffer ( AVCodecContext avctx,
VAAPIEncodePicture pic,
int  type,
char *  data,
size_t  len 
)
static

Definition at line 87 of file vaapi_encode.c.

Referenced by vaapi_encode_issue(), and vaapi_encode_make_misc_param_buffer().

◆ vaapi_encode_make_misc_param_buffer()

static int vaapi_encode_make_misc_param_buffer ( AVCodecContext avctx,
VAAPIEncodePicture pic,
int  type,
const void *  data,
size_t  len 
)
static

Definition at line 115 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

◆ vaapi_encode_wait()

static int vaapi_encode_wait ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic 
)
static

Definition at line 138 of file vaapi_encode.c.

Referenced by vaapi_encode_discard(), and vaapi_encode_output().

◆ vaapi_encode_make_row_slice()

static int vaapi_encode_make_row_slice ( AVCodecContext avctx,
VAAPIEncodePicture pic 
)
static

Definition at line 186 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

◆ vaapi_encode_make_tile_slice()

static int vaapi_encode_make_tile_slice ( AVCodecContext avctx,
VAAPIEncodePicture pic 
)
static

Definition at line 241 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

◆ vaapi_encode_issue()

static int vaapi_encode_issue ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic 
)
static

Definition at line 268 of file vaapi_encode.c.

◆ vaapi_encode_get_coded_buffer_size()

static int vaapi_encode_get_coded_buffer_size ( AVCodecContext avctx,
VABufferID  buf_id 
)
static

Definition at line 657 of file vaapi_encode.c.

Referenced by vaapi_encode_get_coded_data().

◆ vaapi_encode_get_coded_buffer_data()

static int vaapi_encode_get_coded_buffer_data ( AVCodecContext avctx,
VABufferID  buf_id,
uint8_t **  dst 
)
static

Definition at line 688 of file vaapi_encode.c.

Referenced by vaapi_encode_get_coded_data().

◆ vaapi_encode_get_coded_data()

static int vaapi_encode_get_coded_data ( AVCodecContext avctx,
VAAPIEncodePicture pic,
AVPacket pkt 
)
static

Definition at line 724 of file vaapi_encode.c.

Referenced by vaapi_encode_output().

◆ vaapi_encode_output()

static int vaapi_encode_output ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic,
AVPacket pkt 
)
static

Definition at line 769 of file vaapi_encode.c.

◆ vaapi_encode_discard()

static int vaapi_encode_discard ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic 
)
static

Definition at line 817 of file vaapi_encode.c.

Referenced by vaapi_encode_free().

◆ vaapi_encode_init()

static int vaapi_encode_init ( AVCodecContext avctx,
FFHWBaseEncodePicture pic 
)
static

Definition at line 835 of file vaapi_encode.c.

◆ vaapi_encode_free()

static int vaapi_encode_free ( AVCodecContext avctx,
FFHWBaseEncodePicture pic 
)
static

Definition at line 854 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_close().

◆ vaapi_encode_add_global_param()

static av_cold void vaapi_encode_add_global_param ( AVCodecContext avctx,
int  type,
void *  buffer,
size_t  size 
)
static

Definition at line 878 of file vaapi_encode.c.

Referenced by vaapi_encode_init_quality(), and vaapi_encode_init_rate_control().

◆ vaapi_encode_profile_entrypoint()

static av_cold int vaapi_encode_profile_entrypoint ( AVCodecContext avctx)
static

Definition at line 935 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_init_rate_control()

static av_cold int vaapi_encode_init_rate_control ( AVCodecContext avctx)
static

Definition at line 1157 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_init_max_frame_size()

static av_cold int vaapi_encode_init_max_frame_size ( AVCodecContext avctx)
static

Definition at line 1515 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_init_gop_structure()

static av_cold int vaapi_encode_init_gop_structure ( AVCodecContext avctx)
static

Definition at line 1572 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_init_row_slice_structure()

static av_cold int vaapi_encode_init_row_slice_structure ( AVCodecContext avctx,
uint32_t  slice_structure 
)
static

Definition at line 1651 of file vaapi_encode.c.

Referenced by vaapi_encode_init_slice_structure().

◆ vaapi_encode_init_tile_slice_structure()

static av_cold int vaapi_encode_init_tile_slice_structure ( AVCodecContext avctx,
uint32_t  slice_structure 
)
static

Definition at line 1696 of file vaapi_encode.c.

Referenced by vaapi_encode_init_slice_structure().

◆ vaapi_encode_init_slice_structure()

static av_cold int vaapi_encode_init_slice_structure ( AVCodecContext avctx)
static

Definition at line 1757 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_init_packed_headers()

static av_cold int vaapi_encode_init_packed_headers ( AVCodecContext avctx)
static

Definition at line 1849 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_init_quality()

static av_cold int vaapi_encode_init_quality ( AVCodecContext avctx)
static

Definition at line 1909 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_init_roi()

static av_cold int vaapi_encode_init_roi ( AVCodecContext avctx)
static

Definition at line 1956 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_free_output_buffer()

static void vaapi_encode_free_output_buffer ( FFRefStructOpaque  opaque,
void *  obj 
)
static

Definition at line 1990 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_alloc_output_buffer()

static int vaapi_encode_alloc_output_buffer ( FFRefStructOpaque  opaque,
void *  obj 
)
static

Definition at line 2003 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_create_recon_frames()

static av_cold int vaapi_encode_create_recon_frames ( AVCodecContext avctx)
static

Definition at line 2030 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ ff_vaapi_encode_receive_packet()

int ff_vaapi_encode_receive_packet ( AVCodecContext avctx,
AVPacket pkt 
)

Definition at line 2086 of file vaapi_encode.c.

◆ ff_vaapi_encode_init()

av_cold int ff_vaapi_encode_init ( AVCodecContext avctx)

◆ ff_vaapi_encode_close()

av_cold int ff_vaapi_encode_close ( AVCodecContext avctx)

Variable Documentation

◆ ff_vaapi_encode_hw_configs

const AVCodecHWConfigInternal* const ff_vaapi_encode_hw_configs[]
Initial value:
= {
HW_CONFIG_ENCODER_FRAMES(VAAPI, VAAPI),
}

Definition at line 36 of file vaapi_encode.c.

◆ vaapi_encode_rt_formats

const VAAPIEncodeRTFormat vaapi_encode_rt_formats[]
static
Initial value:
= {
{ "YUV400", VA_RT_FORMAT_YUV400, 8, 1, },
{ "YUV420", VA_RT_FORMAT_YUV420, 8, 3, 1, 1 },
{ "YUV422", VA_RT_FORMAT_YUV422, 8, 3, 1, 0 },
{ "YUV444", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 },
{ "XYUV", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 },
{ "YUV411", VA_RT_FORMAT_YUV411, 8, 3, 2, 0 },
}

Definition at line 901 of file vaapi_encode.c.

Referenced by vaapi_encode_profile_entrypoint().

◆ vaapi_encode_entrypoints_normal

const VAEntrypoint vaapi_encode_entrypoints_normal[]
static
Initial value:
= {
VAEntrypointEncSlice,
VAEntrypointEncPicture,
0
}

Definition at line 920 of file vaapi_encode.c.

Referenced by vaapi_encode_profile_entrypoint().

◆ vaapi_encode_rc_modes

const VAAPIEncodeRCMode vaapi_encode_rc_modes[]
static
Initial value:
= {
{ 0 },
{ RC_MODE_CQP, "CQP", 1, VA_RC_CQP, 0, 0, 1, 0 },
{ RC_MODE_CBR, "CBR", 1, VA_RC_CBR, 1, 0, 0, 1 },
{ RC_MODE_VBR, "VBR", 1, VA_RC_VBR, 1, 1, 0, 1 },
{ RC_MODE_ICQ, "ICQ", 0 },
{ RC_MODE_QVBR, "QVBR", 0 },
{ RC_MODE_AVBR, "AVBR", 0 },
}

Definition at line 1136 of file vaapi_encode.c.

Referenced by vaapi_encode_init_rate_control().

◆ vaapi_op

const FFHWEncodePictureOperation vaapi_op
static
Initial value:
= {
.priv_size = sizeof(VAAPIEncodePicture),
.issue = &vaapi_encode_issue,
}

Definition at line 2074 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

RC_MODE_CBR
@ RC_MODE_CBR
Definition: d3d12va_encode.h:95
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
RC_MODE_CQP
@ RC_MODE_CQP
Definition: d3d12va_encode.h:94
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
vaapi_encode_output
static int vaapi_encode_output(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, AVPacket *pkt)
Definition: vaapi_encode.c:769
fail
#define fail()
Definition: checkasm.h:189
VAAPIEncodePicture
Definition: vaapi_encode.h:65
vaapi_encode_free
static int vaapi_encode_free(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
Definition: vaapi_encode.c:854
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:230
RC_MODE_ICQ
@ RC_MODE_ICQ
Definition: vaapi_encode.h:120
NULL
#define NULL
Definition: coverity.c:32
RC_MODE_AVBR
@ RC_MODE_AVBR
Definition: vaapi_encode.h:122
RC_MODE_VBR
@ RC_MODE_VBR
Definition: d3d12va_encode.h:96
RC_MODE_QVBR
@ RC_MODE_QVBR
Definition: d3d12va_encode.h:97
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
vaapi_encode_rc_modes
static const VAAPIEncodeRCMode vaapi_encode_rc_modes[]
Definition: vaapi_encode.c:1136
vaapi_encode_issue
static int vaapi_encode_issue(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
Definition: vaapi_encode.c:268
HW_CONFIG_ENCODER_FRAMES
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
Definition: hwconfig.h:98
mode
mode
Definition: ebur128.h:83
rc_mode
mfxU16 rc_mode
Definition: qsvenc.c:143
vaapi_encode_init
static int vaapi_encode_init(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
Definition: vaapi_encode.c:835