52 return VA_INVALID_SURFACE;
67 "Couldn't get bit depth from profile:%d.\n", seq->
seq_profile);
83 if (!
ctx->ref_tab[
i].frame)
85 ctx->ref_tab[
i].valid = 0;
114 VADecPictureParameterBufferAV1 pic_param;
115 int8_t bit_depth_idx;
119 uint8_t segmentation_feature_signed[
AV1_SEG_LVL_MAX] = {1, 1, 1, 1, 1, 0, 0, 0};
124 if (bit_depth_idx < 0)
128 if (
ctx->tmp_frame->buf[0])
138 memset(&pic_param, 0,
sizeof(VADecPictureParameterBufferAV1));
139 pic_param = (VADecPictureParameterBufferAV1) {
140 .profile = seq->seq_profile,
141 .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1,
142 .bit_depth_idx = bit_depth_idx,
143 .matrix_coefficients = seq->color_config.matrix_coefficients,
144 .current_frame = pic->output_surface,
146 .frame_width_minus1 =
frame_header->frame_width_minus_1,
147 .frame_height_minus1 =
frame_header->frame_height_minus_1,
152 .context_update_tile_id =
frame_header->context_update_tile_id,
153 .superres_scale_denominator =
frame_header->use_superres ?
167 .cdef_damping_minus_3 =
frame_header->cdef_damping_minus_3,
169 .seq_info_fields.fields = {
170 .still_picture = seq->still_picture,
171 .use_128x128_superblock = seq->use_128x128_superblock,
172 .enable_filter_intra = seq->enable_filter_intra,
173 .enable_intra_edge_filter = seq->enable_intra_edge_filter,
174 .enable_interintra_compound = seq->enable_interintra_compound,
175 .enable_masked_compound = seq->enable_masked_compound,
176 .enable_dual_filter = seq->enable_dual_filter,
177 .enable_order_hint = seq->enable_order_hint,
178 .enable_jnt_comp = seq->enable_jnt_comp,
179 .enable_cdef = seq->enable_cdef,
180 .mono_chrome = seq->color_config.mono_chrome,
181 .color_range = seq->color_config.color_range,
182 .subsampling_x = seq->color_config.subsampling_x,
183 .subsampling_y = seq->color_config.subsampling_y,
184 .chroma_sample_position = seq->color_config.chroma_sample_position,
185 .film_grain_params_present = seq->film_grain_params_present &&
188 .seg_info.segment_info_fields.bits = {
191 .temporal_update =
frame_header->segmentation_temporal_update,
195 .film_grain_info_fields.bits = {
196 .apply_grain = apply_grain,
197 .chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma,
198 .grain_scaling_minus_8 = film_grain->grain_scaling_minus_8,
199 .ar_coeff_lag = film_grain->ar_coeff_lag,
200 .ar_coeff_shift_minus_6 = film_grain->ar_coeff_shift_minus_6,
201 .grain_scale_shift = film_grain->grain_scale_shift,
202 .overlap_flag = film_grain->overlap_flag,
203 .clip_to_restricted_range = film_grain->clip_to_restricted_range,
205 .grain_seed = film_grain->grain_seed,
206 .num_y_points = film_grain->num_y_points,
207 .num_cb_points = film_grain->num_cb_points,
208 .num_cr_points = film_grain->num_cr_points,
209 .cb_mult = film_grain->cb_mult,
210 .cb_luma_mult = film_grain->cb_luma_mult,
211 .cb_offset = film_grain->cb_offset,
212 .cr_mult = film_grain->cr_mult,
213 .cr_luma_mult = film_grain->cr_luma_mult,
214 .cr_offset = film_grain->cr_offset,
216 .pic_info_fields.bits = {
220 .error_resilient_mode =
frame_header->error_resilient_mode,
222 .allow_screen_content_tools =
frame_header->allow_screen_content_tools,
226 .allow_high_precision_mv =
frame_header->allow_high_precision_mv,
227 .is_motion_mode_switchable =
frame_header->is_motion_mode_switchable,
229 .disable_frame_end_update_cdf =
frame_header->disable_frame_end_update_cdf,
230 .uniform_tile_spacing_flag =
frame_header->uniform_tile_spacing_flag,
231 .allow_warped_motion =
frame_header->allow_warped_motion,
233 .loop_filter_info_fields.bits = {
235 .mode_ref_delta_enabled =
frame_header->loop_filter_delta_enabled,
236 .mode_ref_delta_update =
frame_header->loop_filter_delta_update,
238 .mode_control_fields.bits = {
241 .delta_lf_present_flag =
frame_header->delta_lf_present,
249 .loop_restoration_fields.bits = {
250 .yframe_restoration_type = remap_lr_type[
frame_header->lr_type[0]],
251 .cbframe_restoration_type = remap_lr_type[
frame_header->lr_type[1]],
252 .crframe_restoration_type = remap_lr_type[
frame_header->lr_type[2]],
256 .qmatrix_fields.bits = {
266 pic_param.ref_frame_map[
i] = VA_INVALID_ID;
268 pic_param.ref_frame_map[
i] =
ctx->ref_tab[
i].valid ?
276 pic_param.ref_deltas[
i] =
frame_header->loop_filter_ref_deltas[
i];
278 for (
int i = 0;
i < 2;
i++) {
279 pic_param.mode_deltas[
i] =
frame_header->loop_filter_mode_deltas[
i];
282 pic_param.cdef_y_strengths[
i] =
285 pic_param.cdef_uv_strengths[
i] =
290 pic_param.width_in_sbs_minus_1[
i] =
294 pic_param.height_in_sbs_minus_1[
i] =
298 pic_param.wm[
i - 1].invalid =
s->cur_frame.gm_invalid[
i];
299 pic_param.wm[
i - 1].wmtype =
s->cur_frame.gm_type[
i];
300 for (
int j = 0; j < 6; j++)
301 pic_param.wm[
i - 1].wmmat[j] =
s->cur_frame.gm_params[
i][j];
305 pic_param.seg_info.feature_mask[
i] |= (
frame_header->feature_enabled[
i][j] << j);
306 if (segmentation_feature_signed[j])
308 -segmentation_feature_max[j], segmentation_feature_max[j]);
311 0, segmentation_feature_max[j]);
315 for (
int i = 0;
i < film_grain->num_y_points;
i++) {
316 pic_param.film_grain_info.point_y_value[
i] =
317 film_grain->point_y_value[
i];
318 pic_param.film_grain_info.point_y_scaling[
i] =
319 film_grain->point_y_scaling[
i];
321 for (
int i = 0;
i < film_grain->num_cb_points;
i++) {
322 pic_param.film_grain_info.point_cb_value[
i] =
323 film_grain->point_cb_value[
i];
324 pic_param.film_grain_info.point_cb_scaling[
i] =
325 film_grain->point_cb_scaling[
i];
327 for (
int i = 0;
i < film_grain->num_cr_points;
i++) {
328 pic_param.film_grain_info.point_cr_value[
i] =
329 film_grain->point_cr_value[
i];
330 pic_param.film_grain_info.point_cr_scaling[
i] =
331 film_grain->point_cr_scaling[
i];
333 for (
int i = 0;
i < 24;
i++) {
334 pic_param.film_grain_info.ar_coeffs_y[
i] =
335 film_grain->ar_coeffs_y_plus_128[
i] - 128;
337 for (
int i = 0;
i < 25;
i++) {
338 pic_param.film_grain_info.ar_coeffs_cb[
i] =
339 film_grain->ar_coeffs_cb_plus_128[
i] - 128;
340 pic_param.film_grain_info.ar_coeffs_cr[
i] =
341 film_grain->ar_coeffs_cr_plus_128[
i] - 128;
345 VAPictureParameterBufferType,
346 &pic_param,
sizeof(pic_param));
372 if (
header->refresh_frame_flags & (1 <<
i)) {
373 if (
ctx->ref_tab[
i].frame->buf[0])
380 ctx->ref_tab[
i].valid = 1;
382 ctx->ref_tab[
i].valid = 0;
396 VASliceParameterBufferAV1 slice_param;
399 for (
int i =
s->tg_start; i <= s->tg_end;
i++) {
400 memset(&slice_param, 0,
sizeof(VASliceParameterBufferAV1));
402 slice_param = (VASliceParameterBufferAV1) {
403 .slice_data_size =
s->tile_group_info[
i].tile_size,
404 .slice_data_offset =
s->tile_group_info[
i].tile_offset,
405 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
406 .tile_row =
s->tile_group_info[
i].tile_row,
407 .tile_column =
s->tile_group_info[
i].tile_column,
408 .tg_start =
s->tg_start,
413 sizeof(VASliceParameterBufferAV1),
426 .
p.
name =
"av1_vaapi",