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",
306 .
p.
name =
"vp9_vaapi",
326 .p.wrapper_name =
"vaapi",