51 return VA_INVALID_SURFACE;
66 "Couldn't get bit depth from profile:%d.\n", seq->
seq_profile);
77 if (!
ctx->tmp_frame.f) {
79 "Failed to allocate frame.\n");
85 if (!
ctx->ref_tab[
i].frame.f) {
87 "Failed to allocate reference table frame %d.\n",
i);
90 ctx->ref_tab[
i].valid = 0;
100 if (
ctx->tmp_frame.f->buf[0])
105 if (
ctx->ref_tab[
i].frame.f->buf[0])
124 VADecPictureParameterBufferAV1 pic_param;
125 int8_t bit_depth_idx;
129 uint8_t segmentation_feature_signed[
AV1_SEG_LVL_MAX] = {1, 1, 1, 1, 1, 0, 0, 0};
134 if (bit_depth_idx < 0)
138 if (
ctx->tmp_frame.f->buf[0])
148 memset(&pic_param, 0,
sizeof(VADecPictureParameterBufferAV1));
149 pic_param = (VADecPictureParameterBufferAV1) {
150 .profile = seq->seq_profile,
151 .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1,
152 .bit_depth_idx = bit_depth_idx,
153 .matrix_coefficients = seq->color_config.matrix_coefficients,
154 .current_frame = pic->output_surface,
156 .frame_width_minus1 =
frame_header->frame_width_minus_1,
157 .frame_height_minus1 =
frame_header->frame_height_minus_1,
162 .context_update_tile_id =
frame_header->context_update_tile_id,
163 .superres_scale_denominator =
frame_header->use_superres ?
177 .cdef_damping_minus_3 =
frame_header->cdef_damping_minus_3,
179 .seq_info_fields.fields = {
180 .still_picture = seq->still_picture,
181 .use_128x128_superblock = seq->use_128x128_superblock,
182 .enable_filter_intra = seq->enable_filter_intra,
183 .enable_intra_edge_filter = seq->enable_intra_edge_filter,
184 .enable_interintra_compound = seq->enable_interintra_compound,
185 .enable_masked_compound = seq->enable_masked_compound,
186 .enable_dual_filter = seq->enable_dual_filter,
187 .enable_order_hint = seq->enable_order_hint,
188 .enable_jnt_comp = seq->enable_jnt_comp,
189 .enable_cdef = seq->enable_cdef,
190 .mono_chrome = seq->color_config.mono_chrome,
191 .color_range = seq->color_config.color_range,
192 .subsampling_x = seq->color_config.subsampling_x,
193 .subsampling_y = seq->color_config.subsampling_y,
194 .chroma_sample_position = seq->color_config.chroma_sample_position,
195 .film_grain_params_present = seq->film_grain_params_present &&
198 .seg_info.segment_info_fields.bits = {
201 .temporal_update =
frame_header->segmentation_temporal_update,
205 .film_grain_info_fields.bits = {
206 .apply_grain = apply_grain,
207 .chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma,
208 .grain_scaling_minus_8 = film_grain->grain_scaling_minus_8,
209 .ar_coeff_lag = film_grain->ar_coeff_lag,
210 .ar_coeff_shift_minus_6 = film_grain->ar_coeff_shift_minus_6,
211 .grain_scale_shift = film_grain->grain_scale_shift,
212 .overlap_flag = film_grain->overlap_flag,
213 .clip_to_restricted_range = film_grain->clip_to_restricted_range,
215 .grain_seed = film_grain->grain_seed,
216 .num_y_points = film_grain->num_y_points,
217 .num_cb_points = film_grain->num_cb_points,
218 .num_cr_points = film_grain->num_cr_points,
219 .cb_mult = film_grain->cb_mult,
220 .cb_luma_mult = film_grain->cb_luma_mult,
221 .cb_offset = film_grain->cb_offset,
222 .cr_mult = film_grain->cr_mult,
223 .cr_luma_mult = film_grain->cr_luma_mult,
224 .cr_offset = film_grain->cr_offset,
226 .pic_info_fields.bits = {
230 .error_resilient_mode =
frame_header->error_resilient_mode,
232 .allow_screen_content_tools =
frame_header->allow_screen_content_tools,
236 .allow_high_precision_mv =
frame_header->allow_high_precision_mv,
237 .is_motion_mode_switchable =
frame_header->is_motion_mode_switchable,
239 .disable_frame_end_update_cdf =
frame_header->disable_frame_end_update_cdf,
240 .uniform_tile_spacing_flag =
frame_header->uniform_tile_spacing_flag,
241 .allow_warped_motion =
frame_header->allow_warped_motion,
243 .loop_filter_info_fields.bits = {
245 .mode_ref_delta_enabled =
frame_header->loop_filter_delta_enabled,
246 .mode_ref_delta_update =
frame_header->loop_filter_delta_update,
248 .mode_control_fields.bits = {
251 .delta_lf_present_flag =
frame_header->delta_lf_present,
259 .loop_restoration_fields.bits = {
260 .yframe_restoration_type = remap_lr_type[
frame_header->lr_type[0]],
261 .cbframe_restoration_type = remap_lr_type[
frame_header->lr_type[1]],
262 .crframe_restoration_type = remap_lr_type[
frame_header->lr_type[2]],
266 .qmatrix_fields.bits = {
275 if (pic_param.pic_info_fields.bits.frame_type ==
AV1_FRAME_KEY)
276 pic_param.ref_frame_map[
i] = VA_INVALID_ID;
278 pic_param.ref_frame_map[
i] =
ctx->ref_tab[
i].valid ?
286 pic_param.ref_deltas[
i] =
frame_header->loop_filter_ref_deltas[
i];
288 for (
int i = 0;
i < 2;
i++) {
289 pic_param.mode_deltas[
i] =
frame_header->loop_filter_mode_deltas[
i];
292 pic_param.cdef_y_strengths[
i] =
295 pic_param.cdef_uv_strengths[
i] =
300 pic_param.width_in_sbs_minus_1[
i] =
304 pic_param.height_in_sbs_minus_1[
i] =
308 pic_param.wm[
i - 1].invalid =
s->cur_frame.gm_invalid[
i];
309 pic_param.wm[
i - 1].wmtype =
s->cur_frame.gm_type[
i];
310 for (
int j = 0; j < 6; j++)
311 pic_param.wm[
i - 1].wmmat[j] =
s->cur_frame.gm_params[
i][j];
315 pic_param.seg_info.feature_mask[
i] |= (
frame_header->feature_enabled[
i][j] << j);
316 if (segmentation_feature_signed[j])
318 -segmentation_feature_max[j], segmentation_feature_max[j]);
321 0, segmentation_feature_max[j]);
325 for (
int i = 0;
i < film_grain->num_y_points;
i++) {
326 pic_param.film_grain_info.point_y_value[
i] =
327 film_grain->point_y_value[
i];
328 pic_param.film_grain_info.point_y_scaling[
i] =
329 film_grain->point_y_scaling[
i];
331 for (
int i = 0;
i < film_grain->num_cb_points;
i++) {
332 pic_param.film_grain_info.point_cb_value[
i] =
333 film_grain->point_cb_value[
i];
334 pic_param.film_grain_info.point_cb_scaling[
i] =
335 film_grain->point_cb_scaling[
i];
337 for (
int i = 0;
i < film_grain->num_cr_points;
i++) {
338 pic_param.film_grain_info.point_cr_value[
i] =
339 film_grain->point_cr_value[
i];
340 pic_param.film_grain_info.point_cr_scaling[
i] =
341 film_grain->point_cr_scaling[
i];
343 for (
int i = 0;
i < 24;
i++) {
344 pic_param.film_grain_info.ar_coeffs_y[
i] =
345 film_grain->ar_coeffs_y_plus_128[
i] - 128;
347 for (
int i = 0;
i < 25;
i++) {
348 pic_param.film_grain_info.ar_coeffs_cb[
i] =
349 film_grain->ar_coeffs_cb_plus_128[
i] - 128;
350 pic_param.film_grain_info.ar_coeffs_cr[
i] =
351 film_grain->ar_coeffs_cr_plus_128[
i] - 128;
355 VAPictureParameterBufferType,
356 &pic_param,
sizeof(pic_param));
382 if (
header->refresh_frame_flags & (1 <<
i)) {
383 if (
ctx->ref_tab[
i].frame.f->buf[0])
390 ctx->ref_tab[
i].valid = 1;
392 ctx->ref_tab[
i].valid = 0;
406 VASliceParameterBufferAV1 slice_param;
409 for (
int i =
s->tg_start; i <= s->tg_end;
i++) {
410 memset(&slice_param, 0,
sizeof(VASliceParameterBufferAV1));
412 slice_param = (VASliceParameterBufferAV1) {
413 .slice_data_size =
s->tile_group_info[
i].tile_size,
414 .slice_data_offset =
s->tile_group_info[
i].tile_offset,
415 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
416 .tile_row =
s->tile_group_info[
i].tile_row,
417 .tile_column =
s->tile_group_info[
i].tile_column,
418 .tg_start =
s->tg_start,
423 sizeof(VASliceParameterBufferAV1),