53 return VA_INVALID_SURFACE;
68 "Couldn't get bit depth from profile:%d.\n", seq->
seq_profile);
79 if (!
ctx->tmp_frame) {
81 "Failed to allocate frame.\n");
87 if (!
ctx->ref_tab[
i].frame) {
89 "Failed to allocate reference table frame %d.\n",
i);
92 ctx->ref_tab[
i].valid = 0;
102 if (
ctx->tmp_frame->buf[0])
107 if (
ctx->ref_tab[
i].frame->buf[0])
126 VADecPictureParameterBufferAV1 pic_param;
127 int8_t bit_depth_idx;
131 uint8_t segmentation_feature_signed[
AV1_SEG_LVL_MAX] = {1, 1, 1, 1, 1, 0, 0, 0};
136 if (bit_depth_idx < 0)
140 if (
ctx->tmp_frame->buf[0])
150 memset(&pic_param, 0,
sizeof(VADecPictureParameterBufferAV1));
151 pic_param = (VADecPictureParameterBufferAV1) {
152 .profile = seq->seq_profile,
153 .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1,
154 .bit_depth_idx = bit_depth_idx,
155 .matrix_coefficients = seq->color_config.matrix_coefficients,
156 .current_frame = pic->output_surface,
158 .frame_width_minus1 =
frame_header->frame_width_minus_1,
159 .frame_height_minus1 =
frame_header->frame_height_minus_1,
164 .context_update_tile_id =
frame_header->context_update_tile_id,
165 .superres_scale_denominator =
frame_header->use_superres ?
179 .cdef_damping_minus_3 =
frame_header->cdef_damping_minus_3,
181 .seq_info_fields.fields = {
182 .still_picture = seq->still_picture,
183 .use_128x128_superblock = seq->use_128x128_superblock,
184 .enable_filter_intra = seq->enable_filter_intra,
185 .enable_intra_edge_filter = seq->enable_intra_edge_filter,
186 .enable_interintra_compound = seq->enable_interintra_compound,
187 .enable_masked_compound = seq->enable_masked_compound,
188 .enable_dual_filter = seq->enable_dual_filter,
189 .enable_order_hint = seq->enable_order_hint,
190 .enable_jnt_comp = seq->enable_jnt_comp,
191 .enable_cdef = seq->enable_cdef,
192 .mono_chrome = seq->color_config.mono_chrome,
193 .color_range = seq->color_config.color_range,
194 .subsampling_x = seq->color_config.subsampling_x,
195 .subsampling_y = seq->color_config.subsampling_y,
196 .chroma_sample_position = seq->color_config.chroma_sample_position,
197 .film_grain_params_present = seq->film_grain_params_present &&
200 .seg_info.segment_info_fields.bits = {
203 .temporal_update =
frame_header->segmentation_temporal_update,
207 .film_grain_info_fields.bits = {
208 .apply_grain = apply_grain,
209 .chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma,
210 .grain_scaling_minus_8 = film_grain->grain_scaling_minus_8,
211 .ar_coeff_lag = film_grain->ar_coeff_lag,
212 .ar_coeff_shift_minus_6 = film_grain->ar_coeff_shift_minus_6,
213 .grain_scale_shift = film_grain->grain_scale_shift,
214 .overlap_flag = film_grain->overlap_flag,
215 .clip_to_restricted_range = film_grain->clip_to_restricted_range,
217 .grain_seed = film_grain->grain_seed,
218 .num_y_points = film_grain->num_y_points,
219 .num_cb_points = film_grain->num_cb_points,
220 .num_cr_points = film_grain->num_cr_points,
221 .cb_mult = film_grain->cb_mult,
222 .cb_luma_mult = film_grain->cb_luma_mult,
223 .cb_offset = film_grain->cb_offset,
224 .cr_mult = film_grain->cr_mult,
225 .cr_luma_mult = film_grain->cr_luma_mult,
226 .cr_offset = film_grain->cr_offset,
228 .pic_info_fields.bits = {
232 .error_resilient_mode =
frame_header->error_resilient_mode,
234 .allow_screen_content_tools =
frame_header->allow_screen_content_tools,
238 .allow_high_precision_mv =
frame_header->allow_high_precision_mv,
239 .is_motion_mode_switchable =
frame_header->is_motion_mode_switchable,
241 .disable_frame_end_update_cdf =
frame_header->disable_frame_end_update_cdf,
242 .uniform_tile_spacing_flag =
frame_header->uniform_tile_spacing_flag,
243 .allow_warped_motion =
frame_header->allow_warped_motion,
245 .loop_filter_info_fields.bits = {
247 .mode_ref_delta_enabled =
frame_header->loop_filter_delta_enabled,
248 .mode_ref_delta_update =
frame_header->loop_filter_delta_update,
250 .mode_control_fields.bits = {
253 .delta_lf_present_flag =
frame_header->delta_lf_present,
261 .loop_restoration_fields.bits = {
262 .yframe_restoration_type = remap_lr_type[
frame_header->lr_type[0]],
263 .cbframe_restoration_type = remap_lr_type[
frame_header->lr_type[1]],
264 .crframe_restoration_type = remap_lr_type[
frame_header->lr_type[2]],
268 .qmatrix_fields.bits = {
278 pic_param.ref_frame_map[
i] = VA_INVALID_ID;
280 pic_param.ref_frame_map[
i] =
ctx->ref_tab[
i].valid ?
288 pic_param.ref_deltas[
i] =
frame_header->loop_filter_ref_deltas[
i];
290 for (
int i = 0;
i < 2;
i++) {
291 pic_param.mode_deltas[
i] =
frame_header->loop_filter_mode_deltas[
i];
294 pic_param.cdef_y_strengths[
i] =
297 pic_param.cdef_uv_strengths[
i] =
302 pic_param.width_in_sbs_minus_1[
i] =
306 pic_param.height_in_sbs_minus_1[
i] =
310 pic_param.wm[
i - 1].invalid =
s->cur_frame.gm_invalid[
i];
311 pic_param.wm[
i - 1].wmtype =
s->cur_frame.gm_type[
i];
312 for (
int j = 0; j < 6; j++)
313 pic_param.wm[
i - 1].wmmat[j] =
s->cur_frame.gm_params[
i][j];
317 pic_param.seg_info.feature_mask[
i] |= (
frame_header->feature_enabled[
i][j] << j);
318 if (segmentation_feature_signed[j])
320 -segmentation_feature_max[j], segmentation_feature_max[j]);
323 0, segmentation_feature_max[j]);
327 for (
int i = 0;
i < film_grain->num_y_points;
i++) {
328 pic_param.film_grain_info.point_y_value[
i] =
329 film_grain->point_y_value[
i];
330 pic_param.film_grain_info.point_y_scaling[
i] =
331 film_grain->point_y_scaling[
i];
333 for (
int i = 0;
i < film_grain->num_cb_points;
i++) {
334 pic_param.film_grain_info.point_cb_value[
i] =
335 film_grain->point_cb_value[
i];
336 pic_param.film_grain_info.point_cb_scaling[
i] =
337 film_grain->point_cb_scaling[
i];
339 for (
int i = 0;
i < film_grain->num_cr_points;
i++) {
340 pic_param.film_grain_info.point_cr_value[
i] =
341 film_grain->point_cr_value[
i];
342 pic_param.film_grain_info.point_cr_scaling[
i] =
343 film_grain->point_cr_scaling[
i];
345 for (
int i = 0;
i < 24;
i++) {
346 pic_param.film_grain_info.ar_coeffs_y[
i] =
347 film_grain->ar_coeffs_y_plus_128[
i] - 128;
349 for (
int i = 0;
i < 25;
i++) {
350 pic_param.film_grain_info.ar_coeffs_cb[
i] =
351 film_grain->ar_coeffs_cb_plus_128[
i] - 128;
352 pic_param.film_grain_info.ar_coeffs_cr[
i] =
353 film_grain->ar_coeffs_cr_plus_128[
i] - 128;
357 VAPictureParameterBufferType,
358 &pic_param,
sizeof(pic_param));
384 if (
header->refresh_frame_flags & (1 <<
i)) {
385 if (
ctx->ref_tab[
i].frame->buf[0])
392 ctx->ref_tab[
i].valid = 1;
394 ctx->ref_tab[
i].valid = 0;
408 VASliceParameterBufferAV1 slice_param;
411 for (
int i =
s->tg_start; i <= s->tg_end;
i++) {
412 memset(&slice_param, 0,
sizeof(VASliceParameterBufferAV1));
414 slice_param = (VASliceParameterBufferAV1) {
415 .slice_data_size =
s->tile_group_info[
i].tile_size,
416 .slice_data_offset =
s->tile_group_info[
i].tile_offset,
417 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
418 .tile_row =
s->tile_group_info[
i].tile_row,
419 .tile_column =
s->tile_group_info[
i].tile_column,
420 .tg_start =
s->tg_start,
425 sizeof(VASliceParameterBufferAV1),