20 #include <va/va_enc_vp9.h>
32 #define VP9_MAX_QUANT 255
34 #define VP9_MAX_TILE_WIDTH 4096
57 VAEncSequenceParameterBufferVP9 *vseq =
ctx->codec_sequence_params;
58 VAEncPictureParameterBufferVP9 *vpic =
ctx->codec_picture_params;
60 vseq->max_frame_width = avctx->
width;
61 vseq->max_frame_height = avctx->
height;
65 if (!(
ctx->va_rc_mode & VA_RC_CQP)) {
66 vseq->bits_per_second =
ctx->va_bit_rate;
67 vseq->intra_period =
ctx->gop_size;
70 vpic->frame_width_src = avctx->
width;
71 vpic->frame_height_src = avctx->
height;
72 vpic->frame_width_dst = avctx->
width;
73 vpic->frame_height_dst = avctx->
height;
95 vpic->log2_tile_columns = num_tile_columns == 1 ? 0 :
av_log2(num_tile_columns - 1) + 1;
100 vpic->ref_flags.bits.force_kf = 1;
101 vpic->refresh_frame_flags = 0xff;
110 if (
ctx->max_b_depth > 0) {
112 vpic->refresh_frame_flags = 1 << hpic->
slot | 0xfc;
115 vpic->refresh_frame_flags = 0xff;
117 vpic->ref_flags.bits.ref_frame_ctrl_l0 = 1;
118 vpic->ref_flags.bits.ref_last_idx = href->
slot;
119 vpic->ref_flags.bits.ref_last_sign_bias = 1;
128 href1->slot < pic->
b_depth + 1);
132 vpic->refresh_frame_flags = 0x00;
135 vpic->refresh_frame_flags = 0xfe << pic->
b_depth & 0xff;
138 vpic->ref_flags.bits.ref_frame_ctrl_l0 = 1;
139 vpic->ref_flags.bits.ref_frame_ctrl_l1 = 2;
140 vpic->ref_flags.bits.ref_last_idx = href0->
slot;
141 vpic->ref_flags.bits.ref_last_sign_bias = 1;
142 vpic->ref_flags.bits.ref_gf_idx = href1->slot;
143 vpic->ref_flags.bits.ref_gf_sign_bias = 0;
149 if (vpic->refresh_frame_flags == 0x00) {
158 vpic->reference_frames[
i] = VA_INVALID_SURFACE;
164 av_assert0(vpic->reference_frames[slot] == VA_INVALID_SURFACE);
174 vpic->luma_ac_qindex = priv->
q_idx_p;
176 vpic->luma_ac_qindex = priv->
q_idx_b;
177 vpic->luma_dc_qindex_delta = 0;
178 vpic->chroma_ac_qindex_delta = 0;
179 vpic->chroma_dc_qindex_delta = 0;
192 if (
ctx->rc_mode->quality) {
230 .default_quality = 100,
236 .sequence_params_size =
sizeof(VAEncSequenceParameterBufferVP9),
239 .picture_params_size =
sizeof(VAEncPictureParameterBufferVP9),
252 ctx->desired_packed_headers = 0;
261 #define OFFSET(x) offsetof(VAAPIEncodeVP9Context, x)
262 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
267 {
"loop_filter_level",
"Loop filter level",
269 {
"loop_filter_sharpness",
"Loop filter sharpness",
309 .wrapper_name =
"vaapi",