FFmpeg
Data Structures | Macros | Functions | Variables
vaapi_encode.c File Reference
#include "config_components.h"
#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_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 (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 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,
VAAPIEncodePicture 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 183 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 238 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 265 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 653 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 731 of file vaapi_encode.c.

Referenced by vaapi_encode_free().

◆ vaapi_encode_alloc()

static VAAPIEncodePicture* vaapi_encode_alloc ( AVCodecContext avctx)
static

Definition at line 748 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 805 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 835 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 865 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 929 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 1065 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 1103 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 1129 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 1205 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 1300 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 1357 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 1578 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 1908 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 1965 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 2086 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 2131 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 2192 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 2283 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 2343 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 2390 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 2423 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 2437 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 2474 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 34 of file vaapi_encode.c.

◆ picture_type_name

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

Definition at line 39 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 },
{ "XYUV", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 },
{ "YUV411", VA_RT_FORMAT_YUV411, 8, 3, 2, 0 },
}

Definition at line 1323 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 1342 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 1557 of file vaapi_encode.c.

Referenced by vaapi_encode_init_rate_control().

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
fail
#define fail()
Definition: checkasm.h:134
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
RC_MODE_CQP
@ RC_MODE_CQP
Definition: vaapi_encode.h:153
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
RC_MODE_CBR
@ RC_MODE_CBR
Definition: vaapi_encode.h:154
RC_MODE_QVBR
@ RC_MODE_QVBR
Definition: vaapi_encode.h:157
NULL
#define NULL
Definition: coverity.c:32
vaapi_encode_rc_modes
static const VAAPIEncodeRCMode vaapi_encode_rc_modes[]
Definition: vaapi_encode.c:1557
RC_MODE_AVBR
@ RC_MODE_AVBR
Definition: vaapi_encode.h:158
HW_CONFIG_ENCODER_FRAMES
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
Definition: hwconfig.h:97
RC_MODE_VBR
@ RC_MODE_VBR
Definition: vaapi_encode.h:155
mode
mode
Definition: ebur128.h:83
RC_MODE_ICQ
@ RC_MODE_ICQ
Definition: vaapi_encode.h:156
rc_mode
mfxU16 rc_mode
Definition: qsvenc.c:142