FFmpeg
Data Structures | Macros | Functions | Variables
vaapi_encode.c File Reference
#include <inttypes.h>
#include <string.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/log.h"
#include "libavutil/pixdesc.h"
#include "vaapi_encode.h"
#include "encode.h"
#include "avcodec.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, VAAPIEncodePicture *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, VAAPIEncodePicture *pic)
 
static int vaapi_encode_output (AVCodecContext *avctx, VAAPIEncodePicture *pic, AVPacket *pkt)
 
static int vaapi_encode_discard (AVCodecContext *avctx, VAAPIEncodePicture *pic)
 
static VAAPIEncodePicturevaapi_encode_alloc (AVCodecContext *avctx)
 
static int vaapi_encode_free (AVCodecContext *avctx, VAAPIEncodePicture *pic)
 
static void vaapi_encode_add_ref (AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodePicture *target, int is_ref, int in_dpb, int prev)
 
static void vaapi_encode_remove_refs (AVCodecContext *avctx, VAAPIEncodePicture *pic, int level)
 
static void vaapi_encode_set_b_pictures (AVCodecContext *avctx, VAAPIEncodePicture *start, VAAPIEncodePicture *end, VAAPIEncodePicture *prev, int current_depth, VAAPIEncodePicture **last)
 
static int vaapi_encode_pick_next (AVCodecContext *avctx, VAAPIEncodePicture **pic_out)
 
static int vaapi_encode_clear_old (AVCodecContext *avctx)
 
static int vaapi_encode_check_frame (AVCodecContext *avctx, const AVFrame *frame)
 
static int vaapi_encode_send_frame (AVCodecContext *avctx, AVFrame *frame)
 
int ff_vaapi_encode_receive_packet (AVCodecContext *avctx, AVPacket *pkt)
 
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_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 (void *opaque, uint8_t *data)
 
static AVBufferRefvaapi_encode_alloc_output_buffer (void *opaque, size_t size)
 
static av_cold int vaapi_encode_create_recon_frames (AVCodecContext *avctx)
 
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 char *const picture_type_name [] = { "IDR", "I", "P", "B" }
 
static const VAAPIEncodeRTFormat vaapi_encode_rt_formats []
 
static const VAEntrypoint vaapi_encode_entrypoints_normal []
 
static const VAAPIEncodeRCMode vaapi_encode_rc_modes []
 

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 39 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 85 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 113 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

◆ vaapi_encode_wait()

static int vaapi_encode_wait ( AVCodecContext avctx,
VAAPIEncodePicture pic 
)
static

Definition at line 136 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 167 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 222 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

◆ vaapi_encode_issue()

static int vaapi_encode_issue ( AVCodecContext avctx,
VAAPIEncodePicture pic 
)
static

Definition at line 249 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_receive_packet().

◆ vaapi_encode_output()

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

Definition at line 626 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_receive_packet().

◆ vaapi_encode_discard()

static int vaapi_encode_discard ( AVCodecContext avctx,
VAAPIEncodePicture pic 
)
static

Definition at line 695 of file vaapi_encode.c.

Referenced by vaapi_encode_free().

◆ vaapi_encode_alloc()

static VAAPIEncodePicture* vaapi_encode_alloc ( AVCodecContext avctx)
static

Definition at line 712 of file vaapi_encode.c.

Referenced by vaapi_encode_send_frame().

◆ vaapi_encode_free()

static int vaapi_encode_free ( AVCodecContext avctx,
VAAPIEncodePicture pic 
)
static

◆ vaapi_encode_add_ref()

static void vaapi_encode_add_ref ( AVCodecContext avctx,
VAAPIEncodePicture pic,
VAAPIEncodePicture target,
int  is_ref,
int  in_dpb,
int  prev 
)
static

Definition at line 767 of file vaapi_encode.c.

Referenced by vaapi_encode_pick_next(), and vaapi_encode_set_b_pictures().

◆ vaapi_encode_remove_refs()

static void vaapi_encode_remove_refs ( AVCodecContext avctx,
VAAPIEncodePicture pic,
int  level 
)
static

Definition at line 797 of file vaapi_encode.c.

Referenced by vaapi_encode_clear_old().

◆ vaapi_encode_set_b_pictures()

static void vaapi_encode_set_b_pictures ( AVCodecContext avctx,
VAAPIEncodePicture start,
VAAPIEncodePicture end,
VAAPIEncodePicture prev,
int  current_depth,
VAAPIEncodePicture **  last 
)
static

Definition at line 827 of file vaapi_encode.c.

Referenced by vaapi_encode_pick_next().

◆ vaapi_encode_pick_next()

static int vaapi_encode_pick_next ( AVCodecContext avctx,
VAAPIEncodePicture **  pic_out 
)
static

Definition at line 891 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_receive_packet().

◆ vaapi_encode_clear_old()

static int vaapi_encode_clear_old ( AVCodecContext avctx)
static

Definition at line 1025 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_receive_packet().

◆ vaapi_encode_check_frame()

static int vaapi_encode_check_frame ( AVCodecContext avctx,
const AVFrame frame 
)
static

Definition at line 1063 of file vaapi_encode.c.

Referenced by vaapi_encode_send_frame().

◆ vaapi_encode_send_frame()

static int vaapi_encode_send_frame ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 1089 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_receive_packet().

◆ ff_vaapi_encode_receive_packet()

int ff_vaapi_encode_receive_packet ( AVCodecContext avctx,
AVPacket pkt 
)

Definition at line 1155 of file vaapi_encode.c.

◆ 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 1221 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 1273 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 1494 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 1824 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 1888 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 1933 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 1994 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 2083 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 2143 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 2190 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ vaapi_encode_free_output_buffer()

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

Definition at line 2223 of file vaapi_encode.c.

Referenced by vaapi_encode_alloc_output_buffer().

◆ vaapi_encode_alloc_output_buffer()

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

Definition at line 2237 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 2274 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

◆ 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 32 of file vaapi_encode.c.

◆ picture_type_name

const char* const picture_type_name[] = { "IDR", "I", "P", "B" }
static

Definition at line 37 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

◆ 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 },
{ "YUV411", VA_RT_FORMAT_YUV411, 8, 3, 2, 0 },
}

Definition at line 1244 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 1258 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 1473 of file vaapi_encode.c.

Referenced by vaapi_encode_init_rate_control().

RC_MODE_CQP
@ RC_MODE_CQP
Definition: vaapi_encode.h:147
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_VBR
@ RC_MODE_VBR
Definition: vaapi_encode.h:149
RC_MODE_CBR
@ RC_MODE_CBR
Definition: vaapi_encode.h:148
fail
#define fail()
Definition: checkasm.h:127
RC_MODE_ICQ
@ RC_MODE_ICQ
Definition: vaapi_encode.h:150
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
NULL
#define NULL
Definition: coverity.c:32
RC_MODE_QVBR
@ RC_MODE_QVBR
Definition: vaapi_encode.h:151
vaapi_encode_rc_modes
static const VAAPIEncodeRCMode vaapi_encode_rc_modes[]
Definition: vaapi_encode.c:1473
HW_CONFIG_ENCODER_FRAMES
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
Definition: hwconfig.h:99
mode
mode
Definition: ebur128.h:83
rc_mode
mfxU16 rc_mode
Definition: qsvenc.c:84
RC_MODE_AVBR
@ RC_MODE_AVBR
Definition: vaapi_encode.h:152