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/log.h"
#include "libavutil/pixdesc.h"
#include "vaapi_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_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)
 
int ff_vaapi_encode_send_frame (AVCodecContext *avctx, const 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_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, int 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

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

#define TRY_RC_MODE (   mode,
  fail 
)
Value:
do { \
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); \
} else { \
goto rc_mode_found; \
} \
} while (0)
#define NULL
Definition: coverity.c:32
mfxU16 rc_mode
Definition: qsvenc.c:82
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
#define fail()
Definition: checkasm.h:122
if(ret)
static const VAAPIEncodeRCMode vaapi_encode_rc_modes[]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return
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
mode
Use these values in ebur128_init (or&#39;ed).
Definition: ebur128.h:83

Referenced by vaapi_encode_init_rate_control().

Function Documentation

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

Definition at line 32 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

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

Definition at line 78 of file vaapi_encode.c.

Referenced by vaapi_encode_issue(), and 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 106 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

static int vaapi_encode_wait ( AVCodecContext avctx,
VAAPIEncodePicture pic 
)
static

Definition at line 129 of file vaapi_encode.c.

Referenced by vaapi_encode_discard(), and vaapi_encode_output().

static int vaapi_encode_issue ( AVCodecContext avctx,
VAAPIEncodePicture pic 
)
static

Definition at line 160 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_receive_packet().

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

Definition at line 576 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_receive_packet().

static int vaapi_encode_discard ( AVCodecContext avctx,
VAAPIEncodePicture pic 
)
static

Definition at line 645 of file vaapi_encode.c.

Referenced by vaapi_encode_free().

static VAAPIEncodePicture* vaapi_encode_alloc ( AVCodecContext avctx)
static

Definition at line 662 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_send_frame().

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

Definition at line 719 of file vaapi_encode.c.

Referenced by vaapi_encode_pick_next(), and vaapi_encode_set_b_pictures().

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

Definition at line 749 of file vaapi_encode.c.

Referenced by vaapi_encode_clear_old().

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

Definition at line 779 of file vaapi_encode.c.

Referenced by vaapi_encode_pick_next().

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

Definition at line 843 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_receive_packet().

static int vaapi_encode_clear_old ( AVCodecContext avctx)
static

Definition at line 977 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_receive_packet().

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

Definition at line 1015 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_send_frame().

int ff_vaapi_encode_send_frame ( AVCodecContext avctx,
const AVFrame frame 
)

Definition at line 1041 of file vaapi_encode.c.

int ff_vaapi_encode_receive_packet ( AVCodecContext avctx,
AVPacket pkt 
)

Definition at line 1108 of file vaapi_encode.c.

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

Definition at line 1162 of file vaapi_encode.c.

Referenced by vaapi_encode_init_quality(), and vaapi_encode_init_rate_control().

static av_cold int vaapi_encode_profile_entrypoint ( AVCodecContext avctx)
static

Definition at line 1211 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

static av_cold int vaapi_encode_init_rate_control ( AVCodecContext avctx)
static

Definition at line 1432 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

static av_cold int vaapi_encode_init_gop_structure ( AVCodecContext avctx)
static

Definition at line 1762 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

static av_cold int vaapi_encode_init_slice_structure ( AVCodecContext avctx)
static

Definition at line 1826 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

static av_cold int vaapi_encode_init_packed_headers ( AVCodecContext avctx)
static

Definition at line 1926 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

static av_cold int vaapi_encode_init_quality ( AVCodecContext avctx)
static

Definition at line 1986 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

static av_cold int vaapi_encode_init_roi ( AVCodecContext avctx)
static

Definition at line 2033 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

static void vaapi_encode_free_output_buffer ( void opaque,
uint8_t data 
)
static

Definition at line 2066 of file vaapi_encode.c.

Referenced by vaapi_encode_alloc_output_buffer().

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

Definition at line 2080 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

static av_cold int vaapi_encode_create_recon_frames ( AVCodecContext avctx)
static

Definition at line 2117 of file vaapi_encode.c.

Referenced by ff_vaapi_encode_init().

av_cold int ff_vaapi_encode_init ( AVCodecContext avctx)
av_cold int ff_vaapi_encode_close ( AVCodecContext avctx)

Variable Documentation

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

Definition at line 30 of file vaapi_encode.c.

Referenced by vaapi_encode_issue().

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

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

Definition at line 1196 of file vaapi_encode.c.

Referenced by vaapi_encode_profile_entrypoint().

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