20#include <va/va_enc_vp9.h>
32#define VP9_MAX_QUANT 255
34#define VP9_MAX_TILE_WIDTH 4096
58 VAEncSequenceParameterBufferVP9 *vseq =
ctx->codec_sequence_params;
59 VAEncPictureParameterBufferVP9 *vpic =
ctx->codec_picture_params;
61 vseq->max_frame_width = avctx->
width;
62 vseq->max_frame_height = avctx->
height;
66 if (!(
ctx->va_rc_mode & VA_RC_CQP)) {
67 vseq->bits_per_second =
ctx->va_bit_rate;
68 vseq->intra_period = base_ctx->
gop_size;
71 vpic->frame_width_src = avctx->
width;
72 vpic->frame_height_src = avctx->
height;
73 vpic->frame_width_dst = avctx->
width;
74 vpic->frame_height_dst = avctx->
height;
97 vpic->log2_tile_columns = num_tile_columns == 1 ? 0 :
av_log2(num_tile_columns - 1) + 1;
102 vpic->ref_flags.bits.force_kf = 1;
103 vpic->refresh_frame_flags = 0xff;
114 vpic->refresh_frame_flags = 1 << hpic->
slot | 0xfc;
117 vpic->refresh_frame_flags = 0xff;
119 vpic->ref_flags.bits.ref_frame_ctrl_l0 = 1;
120 vpic->ref_flags.bits.ref_last_idx = href->
slot;
121 vpic->ref_flags.bits.ref_last_sign_bias = 1;
130 href1->slot < pic->
b_depth + 1);
134 vpic->refresh_frame_flags = 0x00;
137 vpic->refresh_frame_flags = 0xfe << pic->
b_depth & 0xff;
140 vpic->ref_flags.bits.ref_frame_ctrl_l0 = 1;
141 vpic->ref_flags.bits.ref_frame_ctrl_l1 = 2;
142 vpic->ref_flags.bits.ref_last_idx = href0->
slot;
143 vpic->ref_flags.bits.ref_last_sign_bias = 1;
144 vpic->ref_flags.bits.ref_gf_idx = href1->slot;
145 vpic->ref_flags.bits.ref_gf_sign_bias = 0;
151 if (vpic->refresh_frame_flags == 0x00) {
160 vpic->reference_frames[
i] = VA_INVALID_SURFACE;
163 for (
int j = 0; j < pic->
nb_refs[
i]; j++) {
167 av_assert0(vpic->reference_frames[slot] == VA_INVALID_SURFACE);
178 vpic->luma_ac_qindex = priv->
q_idx_p;
180 vpic->luma_ac_qindex = priv->
q_idx_b;
181 vpic->luma_dc_qindex_delta = 0;
182 vpic->chroma_ac_qindex_delta = 0;
183 vpic->chroma_dc_qindex_delta = 0;
207 if (
ctx->rc_mode->quality) {
247 .default_quality = 100,
254 .sequence_params_size =
sizeof(VAEncSequenceParameterBufferVP9),
257 .picture_params_size =
sizeof(VAEncPictureParameterBufferVP9),
270 ctx->desired_packed_headers = 0;
275#define OFFSET(x) offsetof(VAAPIEncodeVP9Context, x)
276#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
282 {
"loop_filter_level",
"Loop filter level",
284 {
"loop_filter_sharpness",
"Loop filter sharpness",
300 .class_name =
"vp9_vaapi",
307 .p.name =
"vp9_vaapi",
324 .p.wrapper_name =
"vaapi",
const FFCodec ff_vp9_vaapi_encoder
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_RECEIVE_PACKET_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
#define AV_PROFILE_UNKNOWN
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
#define HW_BASE_ENCODE_COMMON_OPTIONS
@ FF_HW_FLAG_B_PICTURE_REFERENCES
#define MAX_REFERENCE_LIST_NUM
const AVCodecHWConfigInternal *const ff_vaapi_encode_hw_configs[]
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)
common internal API header
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
main external API structure.
int width
picture width / height.
float b_quant_offset
qscale offset between IP and B-frames
float b_quant_factor
qscale factor between IP and B-frames If > 0 then the last P-frame quantizer will be used (q= lastp_q...
float i_quant_factor
qscale factor between P- and I-frames If > 0 then the last P-frame quantizer will be used (q = lastp_...
float i_quant_offset
qscale offset between P and I-frames
int nb_refs[MAX_REFERENCE_LIST_NUM]
struct FFHWBaseEncodePicture * refs[MAX_REFERENCE_LIST_NUM][MAX_PICTURE_REFERENCES]
void * codec_picture_params
VASurfaceID recon_surface
VAAPIEncodeContext common
int loop_filter_sharpness
#define VAAPI_ENCODE_COMMON_OPTIONS
#define VAAPI_ENCODE_RC_OPTIONS
static const AVClass vaapi_encode_vp9_class
#define VP9_MAX_TILE_WIDTH
static av_cold int vaapi_encode_vp9_init(AVCodecContext *avctx)
static const VAAPIEncodeProfile vaapi_encode_vp9_profiles[]
static const VAAPIEncodeType vaapi_encode_type_vp9
static const AVOption vaapi_encode_vp9_options[]
static av_cold int vaapi_encode_vp9_configure(AVCodecContext *avctx)
static av_cold int vaapi_encode_vp9_get_encoder_caps(AVCodecContext *avctx)
static const FFCodecDefault vaapi_encode_vp9_defaults[]
static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
static int vaapi_encode_vp9_init_sequence_params(AVCodecContext *avctx)